Пример #1
0
        //create/update a client object based on a client event received from the client
        public static Client CreateFromClientEvent(ClientEvent clientEvent, ClientStateEnum clientState)
        {
            if (log.IsDebugEnabled) { log.Debug("CreateFromClientEvent.ClientEvent." + (clientEvent == null ? "null" : clientEvent.ToJsonString())); }

            Client client = null;

            if (clientEvent != null &&
                clientEvent.ClientData != null)
            {
                MongoDatabase mongoDb = Helper.MongoDb.GetDatabase();

                //try to find existing
                client = Client.FindOneBySessionNodeId(mongoDb, clientEvent.SessionNodeId);
                if (client == null)
                    client = Client.FindOneBySessionAspNetId(mongoDb, clientEvent.ClientData.SessionAspNetId);
                if (client == null)
                    client = new Client();

                //upsert the client for future use
                client.ClientSessionNodeId = clientEvent.SessionNodeId;
                client.ClientSessionAspNetId = clientEvent.ClientData.SessionAspNetId;
                client.ClientState = clientState;
                client.Save(mongoDb);
            }

            if (log.IsDebugEnabled) { log.Debug("CreateFromClientEvent.Client." + (client == null ? "null" : client.ToJsonString())); }

            return client;
        }
        /// <summary>Call to initiate connection to server.</summary>
        public void Connect()
        {
            //Connect.
            this._state         = ClientStateEnum.Working;
            this._lastException = null;

            this._client.Connection_Authenticate2Async(this._user, this._password, Business.StaticFuncs.getCultureResource.GetString("app_ReportName"), this);
        }
Пример #3
0
        public Boolean WaitFor(ClientStateEnum state)
        {
            while (ClientState != state)
            {
                Thread.Sleep(100);
            }

            return(true);
        }
Пример #4
0
 public bool IsCurState(ClientStateEnum state)
 {
     if (curState == state)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #5
0
 public static void AutoTransfer(int project, ClientStateEnum state, int gonggong, int chenshui)
 {
     string field = "";
     string type = "";
     switch (state)
     {
         case ClientStateEnum.来电客户:
             field = "TelToVisitDays";
             type = "电转访超期转移";
             break;
         case ClientStateEnum.来访客户:
             field = "VisitToCardDays";
             type = "访转卡超期转移";
             break;
         case ClientStateEnum.办卡客户:
             field = "CardToOrderDays";
             type = "卡转定超期转移";
             break;
     }
     string sql = @"select c.* from clients c join departments d on c.groupid=d.id join roomtypes t on t.departmentid=c.projectid and t.name=c.roomtype where c.createtime>'2013-12-1' and c.projectid={0} and  c.state={1} and t.{2} >0 and  DATEADD(dd,t.{2},c.statedate)<getdate()";
     sql = string.Format(sql, project, (int)state, field, type);
     using (Context db = new Context())
     {
         List<Client> list = db.Database.SqlQuery<Client>(sql).ToList();
         foreach (Client client in list)
         {
             Client c = db.Clients.Find(client.Id);
             db.ClientTransfers.Add(new ClientTransfer()
             {
                 ClientId = c.Id,
                 InGroup = c.SleepTimes == 0 ? gonggong : chenshui,
                 OutGroup = c.GroupId,
                 Reason = type,
                 Person = 1,
                 TransferDate = DateTime.Today
             });
             if (c.SleepTimes == 0)
             {
                 c.GroupId = gonggong;
                 c.State = ClientStateEnum.公共客户;
             }
             else
             {
                 c.GroupId = chenshui;
                 c.State = ClientStateEnum.沉睡客户;
             }
             c.SleepTimes++;
             c.StateDate = DateTime.Today;
             db.SaveChanges();
             //Client.StateUpdate(client.Id, DateTime.Today);
         }
     }
 }
Пример #6
0
    void StateExit(ClientStateEnum preState)
    {
        Debug.Log("StateExit执行退出状态:" + preState);
        switch (preState)
        {
        case ClientStateEnum.Connect:
            Debug.Log("hide panel Connect0");
            ConnectPanelTrm.gameObject.SetActive(false);
            Debug.Log("hide panel Connect1");
            break;

        case ClientStateEnum.Keyboard:

            break;
        }
    }
 /// <summary>Hit when the client's finished connecting.</summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _client_Connection_Authenticate2Completed(object sender, SpiraTeam_Client.Connection_Authenticate2CompletedEventArgs e)
 {
     if (e.Error == null)
     {
         this._isConnected = true;
         if (this.ConnectionReady != null)
         {
             this.ConnectionReady(this, new EventArgs());
         }
     }
     else
     {
         this._lastException = e.Error;
         this._state         = ClientStateEnum.Idle;
         if (this.ConnectionError != null)
         {
             this.ConnectionError(this, new ConnectionException(e.Error));
         }
     }
 }
Пример #8
0
    public void SetState(ClientStateEnum state)
    {
        if (state == curState)
        {
            return;
        }

        preState = curState;
        StateExit(preState);
        curState = state;

        Debug.Log("SetState切换状态到:" + state);

        switch (curState)
        {
        case ClientStateEnum.Connect:
            ConnectPanelTrm.gameObject.SetActive(true);
            break;

        case ClientStateEnum.Keyboard:
            AppPanelTrm.gameObject.SetActive(true);
            break;
        }
    }
Пример #9
0
 public List<OutTimeClient> GetOutTimeAlert(int project,int group, ClientStateEnum state)
 {
     string field="";
     string alertField = "";
     string type = "";
     switch (state)
     {
         case ClientStateEnum.来电客户:
             field = "TelToVisitDays";
             alertField = "TelToVisitAheads";
             type = "电转访超期预警";
             break;
             case ClientStateEnum.来访客户:
             field = "VisitToCardDays";
             alertField = "VisitToCardAheads";
             type = "访转卡超期预警";
             break;
             case ClientStateEnum.办卡客户:
             field = "CardToOrderDays";
             alertField = "CardToOrderAheads";
             type = "卡转定超期预警";
             break;
     }
     string sql = @"select c.id as clientid,c.name,c.state,d.name as groupname ,'{5}' as type from clients c join departments d on c.groupid=d.id
     join roomtypes t on t.departmentid=c.projectid and t.name=c.roomtype
     where c.projectid={0} and  c.state={1} {2} and t.{3} >0 and  DATEADD(dd,t.{3}-t.{4},c.statedate)<=getdate()
     order by DATEADD(dd,t.{3}-t.{4},c.statedate)-getdate()";
     string groupSql = "";
     if (group != 0)
     {
         groupSql = "and c.groupid=" + group.ToString();
     }
     sql = string.Format(sql, project, (int) state, groupSql, field, alertField,type);
     using (Context db = new Context())
     {
         List<OutTimeClient> list = db.Database.SqlQuery<OutTimeClient>(sql).ToList();
         return list;
     }
 }
Пример #10
0
		public Boolean WaitFor (ClientStateEnum state)
		{
			while (ClientState != state) {
				Thread.Sleep(100);
			}

			return true;
		}