public AgentChatContext(string ticketID, string sessionID, LenovoAgent agent) : this(ticketID, sessionID, agent.AgentId) { if (agent == null) { throw new Exception("参数 agent 不能为空!"); } this.agent = agent; }
/// <summary> /// 链接服务器 /// </summary> /// <returns></returns> public JsonResult ConnectionServer(string tid, string interactionID, string queueName , string agentID, string placeID, string nickName, string host, string port, int isMeeting) { AjaxReturn result = new AjaxReturn(); if (!string.IsNullOrEmpty(interactionID)) { LenovoAgent agent = new LenovoAgent() { TicketID = tid, InteractionID = interactionID, AgentId = agentID, PlaceId = placeID, DisplayName = nickName }; try { ChatLog.GetInstance().FormatMessage("连接ChatServer:sessionid-{0},queue-{1},agentID-{2},chatServer-{3}:{4}" , interactionID, queueName, agentID, host, port); AgentChatContext context = new AgentChatContext(tid, interactionID, agent); context.ChatServerHost = host; context.ChatServerPort = port; context.InitConnecton(); if (context.IsAvailableConnection) { string title = GetEmployeeTitle(queueName); context.ChatJoin(interactionID, title); if (isMeeting == 1) { context.SendMessage(interactionID, "<font color='red'>您已进入了多方支持。</font>"); } result.Code = 1; DateTime beginTime = context.Room.CreateDate; result.d = new { ChatBeginTime = beginTime.Ticks, ChatID = string.Format("{0}{1:yyyyMMddHHmmsshh}C", agentID, beginTime), StrChatBeginTime = beginTime.ToString("yyyy-MM-dd HH:mm:ss") }; //JsonResult jr = new JsonpResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; //string s=jr.ToString(); //ChatLog.GetInstance().FormatMessage("返回数据:【{0}】", s); } } catch (Exception ex) { ChatLog.GetInstance().LogException(ex); } } return(new JsonpResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }