def get(self):
     tAgent = Agent()
     tUser = users.get_current_user()
     if (tUser):
         tAgent = Agent().GetAgentByEmail(tUser.email())
         if (tAgent.agentOnline == True):
             if (tAgent.agentNotify == True):
                 tAgent.agentNotify = False
                 tAgent.put()
                 self.response.out.write("1")
             elif (tAgent.agentNotify == False):
                 self.response.out.write("0")
             else:
                 self.response.out.write("0")
                 tAgent.agentNotify = False
                 tAgent.put()
         else:
             self.response.out.write("2")
 def get(self):
     tAgent = Agent()
     tUser = users.get_current_user()
     if (tUser):
         tAgent = Agent().GetAgentByEmail(tUser.email())
         if(tAgent.agentOnline == True):
             if (tAgent.agentNotify == True):
                 tAgent.agentNotify = False
                 tAgent.put()
                 self.response.out.write("1")
             elif (tAgent.agentNotify == False):
                 self.response.out.write("0")
             else:
                 self.response.out.write("0")
                 tAgent.agentNotify = False
                 tAgent.put()
         else:
             self.response.out.write("2")
             
Exemplo n.º 3
0
    def GetAssignedAgent(self, pOrder=None):
        tAgent = Agent()
        tPaypal = PaypalOrder()
        tAgents = []
        Switch = {}
        tOrder = Order()
        tOrder = pOrder

        #Need to implement these methods
        #Switch[(1,2)] = tPaypal.UseFullAndBackupAgents
        #Switch[(0,2)] = tPaypal.UseBackupAgent
        #Switch[(2,2)] = tPaypal.UseFullAgent
        Switch[(0, 0)] = tPaypal.AssignNoAgent
        Switch[(0, 1)] = tPaypal.UseBackupAgent
        Switch[(1, 0)] = tPaypal.UseFullAgent
        Switch[(1, 1)] = tPaypal.UseFullAndBackupAgents
        Switch[(2, 0)] = tPaypal.UseFullAgent
        Switch[(2, 1)] = tPaypal.UseFullAndBackupAgents
        Switch[(3, 0)] = tPaypal.UseFullAgent
        Switch[(3, 1)] = tPaypal.UseFullAgent

        #Based on the raw online numbers of each group
        tCurrentState = (tPaypal.GetNumberofOnlineFullAgents(),
                         tPaypal.GetNumberofOnlineBackupAgents())
        #logging.debug("Current State" + str(tCurrentState))

        #The end agent will be handled in each function
        tAgent = Switch[tCurrentState]()
        if (tOrder != None):
            try:
                #logging.debug("Agent Current Total: " + str(tAgent.agentCurrentOrderTotal))
                #logging.debug("Order Quantity: " + str(tOrder.orderQuantity))
                tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + int(
                    tOrder.orderQuantity)
                #logging.debug("New Agent Current Total: " + str(tAgent.agentCurrentOrderTotal))
                tAgent.agentNotify = True
                tAgent.put()
                #logging.debug("GetAssignedAgent returning agent: " + str(tAgent.agentId))
                return tAgent.agentId
            except:
                #logging.debug("Hit an error")
                return "No Agent Online"
        else:
            try:
                return str(tAgent.agentId)
            except:
                return "No Agent Online"
 def GetAssignedAgent(self, pOrder = None):
     tAgent = Agent()
     tAssignment = DeliveryAssignment()
     tAgents = []
     Switch = {}
     tOrder = PaOrder()
     tOrder = pOrder
     
     #Need to implement these methods
     #Switch[(1,2)] = tPaypal.UseFullAndBackupAgents
     #Switch[(0,2)] = tPaypal.UseBackupAgent
     #Switch[(2,2)] = tPaypal.UseFullAgent
     Switch[(0,0)] = tAssignment.AssignNoAgent
     Switch[(0,1)] = tAssignment.UseBackupAgent
     Switch[(1,0)] = tAssignment.UseFullAgent
     Switch[(1,1)] = tAssignment.UseFullAndBackupAgents
     Switch[(2,0)] = tAssignment.UseFullAgent
     Switch[(2,1)] = tAssignment.UseFullAndBackupAgents
     Switch[(3,0)] = tAssignment.UseFullAgent
     Switch[(3,1)] = tAssignment.UseFullAgent
     
     
     #Based on the raw online numbers of each group
     tCurrentState = (tAssignment.GetNumberofOnlineFullAgents(), tAssignment.GetNumberofOnlineBackupAgents())
     #logging.debug("Current State" + str(tCurrentState))
     
     #The end agent will be handled in each function
     tAgent = Switch[tCurrentState]()
     if (tOrder != None):
         try:
             #logging.debug("Agent Current Total: " + str(tAgent.agentCurrentOrderTotal))
             #logging.debug("Order Quantity: " + str(tOrder.paAmountInt))
             tAgent.agentCurrentOrderTotal = tAgent.agentCurrentOrderTotal + 1
             #logging.debug("New Agent Current Total: " + str(tAgent.agentCurrentOrderTotal))
             tAgent.agentNotify = True
             tAgent.put()
             #logging.debug("GetAssignedAgent returning agent: " + str(tAgent.agentId))
             return tAgent
         except:
             #logging.debug("Hit an error")
             return "No Agent Online"
     else:
         try:
             return tAgent
         except:
             return "No Agent Online"