Example #1
0
        public void ServiceCommited(int connectID, string userID, int serviceKey, int dataCount)
        {
            if (userID == NetHelper.SystemUserID)
            {
                return;
            }

            //激活定时器中的用户
            this.tcpUserOnLineChecker.RegisterOrActivateUser(userID);

            //修改任务列表
            ITaskMainRecord mainRecord = this.CreateOrGetMainRecord(connectID, userID);

            if (((mainRecord.UserID == null) || (mainRecord.UserID.Trim() == "")) && (userID != null) && (userID != ""))
            {
                mainRecord.UserID = userID;
            }

            ITaskDetailRecord detail = this.taskReporter.CreateRudeTaskDetailRecord();

            detail.DataCount   = dataCount;
            detail.ServiceKey  = serviceKey;
            detail.RequestTime = DateTime.Now;

            mainRecord.Details.Add(detail);

            //更新界面
            if (mainRecord.UserID != null)
            {
                int totalLen = this.GetTotalDataLen(mainRecord);
                this.tcpUserDisplayer.SetOrUpdateUserItem(mainRecord.UserID, serviceKey, totalLen);
            }
        }
Example #2
0
        //将指定连接从列表中移除,并将用户任务上报
        private void UngisterUser(string userID, DisconnectedCause cause)
        {
            if (this.htableClient[userID] == null)
            {
                return;
            }

            //上报任务
            ITaskMainRecord mainRecord = (ITaskMainRecord)this.htableClient[userID];

            mainRecord.TimeLogout     = DateTime.Now;
            mainRecord.RequestCount   = mainRecord.Details.Count;
            mainRecord.TotalDataCount = this.GetTotalDataLen(mainRecord);
            this.taskReporter.RecordTaskList(mainRecord);

            this.rwLocker.AcquireWriterLock(TcpUserManager.WaitLockerSpan);
            this.htableClient.Remove(userID);
            this.htableConnect.Remove(userID);
            this.rwLocker.ReleaseWriterLock();

            //更新显示
            this.tcpUserDisplayer.RemoveUser(userID, cause);

            //触发事件
            this.ActivateDisConnectedEvent(userID, cause);
        }
Example #3
0
        private int GetTotalDataLen(ITaskMainRecord mainRecord)
        {
            int totalCount = 0;

            foreach (ITaskDetailRecord detail in mainRecord.Details)
            {
                totalCount += detail.DataCount;
            }

            return(totalCount);
        }
Example #4
0
        private ITaskMainRecord CreateOrGetMainRecord(int connectID, string userID)
        {
            if (this.htableClient[userID] == null)
            {
                ITaskMainRecord mainRecord = this.taskReporter.CreateRudeTaskMainRecord();
                mainRecord.TimeLogon      = DateTime.Now;
                mainRecord.RequestCount   = 0;
                mainRecord.TotalDataCount = 0;
                mainRecord.UserID         = userID;
                mainRecord.Details        = new List <ITaskDetailRecord>();

                this.rwLocker.AcquireWriterLock(TcpUserManager.WaitLockerSpan);
                this.htableClient.Add(userID, mainRecord);
                this.htableConnect.Add(userID, connectID);
                this.rwLocker.ReleaseWriterLock();

                this.ActivateConnectedEvent(userID);
            }

            return((ITaskMainRecord)this.htableClient[userID]);
        }
Example #5
0
 public void RecordTaskList(ITaskMainRecord mainRecord)
 {
     // TODO:  添加 EmptyUserTaskReporter.RecordTaskList 实现
 }