Ejemplo n.º 1
0
        /// <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
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 发送信息
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public JsonResult SendMessage(string tid, string message, string interactionID, string agentID)
 {
     if (!string.IsNullOrEmpty(interactionID))
     {
         try
         {
             var context = new AgentChatContext(tid, interactionID, agentID);
             context.SendMessage(interactionID, message);
         }
         catch (Exception ex)
         {
             ChatLog.GetInstance().LogException(ex);
         }
     }
     return(new JsonpResult()
     {
         Data = "", JsonRequestBehavior = JsonRequestBehavior.AllowGet
     });
 }