/// <summary> /// 跟据公司ID获取当前在线的客服例表 /// </summary> /// <param name="accountId"></param> /// <returns></returns> private List <Socket> GetOnlineOperatorSockets(string accountId) { List <Socket> ss = new List <Socket>(); foreach (var item in OperatorService.GetAllOperatorsByAccountId(accountId)) { if (operatorSocketMap.ContainsKey(item.OperatorId)) { ss.Add(operatorSocketMap[item.OperatorId]); } } return(ss); }
public static NewChangesCheckResult CheckNewChanges(string operatorId, string operatorSessionId, NewChangesCheck check) { Trace.WriteLine(string.Format("OperatorService.CheckNewChanges(operatorId = {0},NewChangesCheck={1})", operatorId, check.ToString())); Operator op = OperatorService.GetOperatorById(operatorId); op.HeartBeatTime = DateTime.Now;//设置心跳时间 NewChangesCheckResult checkResult = new NewChangesCheckResult(); if (op.OperatorSession != operatorSessionId) { checkResult.ReturnCode = NewChangesCheckResult.ReturnCodeEnum.ReturnCode_SessionInvalid; return(checkResult); } // 新访客 checkResult.NewVisitors = VisitorService.GetNewVisitors(op.AccountId, check.NewVisitorLastCheckTime); checkResult.Chats = ChatService.GetAllChatByAccountId(op.AccountId); // 访问会话状态更新 checkResult.VisitSessionChange = VisitSessionService.GetVisitSessionChange(op.AccountId, check.NewVisitorLastCheckTime); // 消息更新 //List<VisitSession> visitSessions = VisitSessionService.GetActiveSessionsByOperatorId(Authentication.OperatorId); checkResult.Messages = new List <MessageCheckResult>(); foreach (MessageCheck item in check.ChatSessionChecks) { MessageCheckResult mcr = new MessageCheckResult(); mcr.ChatId = item.ChatId; mcr.Messages = MessageService.GetMessagesForOperator(item.ChatId, item.LastCheckTime); checkResult.Messages.Add(mcr); } checkResult.Operators = OperatorService.GetAllOperatorsByAccountId(op.AccountId); checkResult.ReturnCode = NewChangesCheckResult.ReturnCodeEnum.ReturnCode_Success; // 客服状态更新 Trace.WriteLine(string.Format("ChecknewChanges(OperatorId={0},NewChangesCheck={{1}},NewChangesCheckResult={{2}}", operatorId, check.ToString(), checkResult.ToString())); return(checkResult); }