コード例 #1
0
ファイル: OperatorService.cs プロジェクト: uwitec/ideacode
    private static void sendUploadFileCompletedMessage(string fileName, string chatId)
    {
        Message m = new Message();

        m.ChatId = chatId;
        Util   util    = new Util();
        string httpURL = System.Configuration.ConfigurationManager.AppSettings["HomeRootUrl"] + "/upload/" + chatId + "/" + fileName.Replace("'", "%27");

        if (util.IsImageFile(fileName))
        {
            m.Text = string.Format("客服已给您发送文件 {0}<a target='_blank' href='{1}\'>点击保存</a> <br/><img height='120px'  width='120px'  src='{2}\' />", fileName, httpURL, httpURL);
        }
        else
        {
            m.Text = string.Format("客服已给您发送文件 {0} <a target='_blank' href='{1}'>点击保存</a>", fileName, httpURL);
        }
        m.Type = MessageType.SystemMessage_ToVisitor;
        ChatService.SendMessage(m);

        m        = new LiveSupport.LiveSupportModel.Message();
        m.ChatId = chatId;
        m.Text   = string.Format("文件 {0} 发送成功!  ...", fileName);
        m.Type   = MessageType.SystemMessage_ToOperator;
        ChatService.SendMessage(m);
    }
コード例 #2
0
 //写信息
 private void WriteMessage(string message, string From)
 {
     LiveSupport.LiveSupportModel.Message msg = new LiveSupport.LiveSupportModel.Message();
     msg.ChatId   = Chat.ChatId;
     msg.Text     = message;
     msg.Source   = From;
     msg.SentDate = DateTime.Now;
     msg.Type     = MessageType.ChatMessage_OperatorToVisitor;
     operatorServiceAgent.SendMessage(msg);
     chatMessageViewerControl1.AddMessage(msg);
 }
コード例 #3
0
    //文件传送
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        //验证文件路径
        try
        {
            if (CurrentChat == null || CurrentChat.Status != ChatStatus.Accepted)
            {
                this.Response.Write("<script>alert('对话未接受');</script>");
                return;
            }
            string fileName = this.fuFile.FileName.ToString();
            if (fileName.Trim().Length == 0 || fileName == null)//验证上传文件
            {
                this.Response.Write("<script>alert('请选择传送的文件');</script>");
                return;
            }
            if (this.fuFile.FileContent.Length >= 2097152)
            {
                this.Response.Write("<script>alert('传送的文件过大');</script>");
                return;
            }
            else
            {
                LiveSupport.LiveSupportModel.Message m = new LiveSupport.LiveSupportModel.Message();
                m.ChatId = CurrentChat.ChatId;
                m.Text   = string.Format("正在传送文件 {0} ...", fileName);
                m.Type   = MessageType.SystemMessage_ToVisitor;
                ChatService.SendMessage(m);
                //string path = ConfigurationManager.AppSettings["FileUploadPath"] + "\\" + m.ChatId;
                string path = Server.MapPath("~/App_Data/" + m.ChatId);
                Directory.CreateDirectory(path);

                this.fuFile.PostedFile.SaveAs(path + "\\" + fileName.Trim());

                m        = new LiveSupport.LiveSupportModel.Message();
                m.ChatId = CurrentChat.ChatId;
                m.Text   = string.Format("文件 {0} 发送成功!  ...", fileName);
                m.Type   = MessageType.SystemMessage_ToVisitor;
                ChatService.SendMessage(m);

                OperatorService.SendFile(m.ChatId, fileName.Trim());
            }
        }
        catch (Exception ex)
        {
            this.Response.Write("<script>alert('文件传送失败,错误:" + ex.ToString() + "');</script>");
        }
    }
コード例 #4
0
        public void RecieveMessage(LiveSupport.LiveSupportModel.Message message)
        {
            if (!this.IsDisposed && receiveMessage)
            {
                chatMessageViewerControl1.AddMessage(message);

                if (!this.ringToolStripMenuItem.Checked)
                {
                    PlayMsgSound();
                }
                if (!this.flashToolStripMenuItem.Checked)
                {
                    API.FlashWindowEx(this.Handle);
                }
            }
        }
コード例 #5
0
    public static string SendMsg(string msg, string chtID)
    {
        if (chtID != null && msg.Length > 0)
        {
            // Add a new message to the discussion
            string chatId = chtID;
            //创建一个聊天消息实例
            LiveSupport.LiveSupportModel.Message m = new LiveSupport.LiveSupportModel.Message();
            m.ChatId = chatId;
            m.Source = VName;
            m.Text   = HttpUtility.HtmlEncode(msg);
            m.Type   = MessageType.ChatMessage_VistorToOperator;
            ChatService.SendMessage(m);

            //OperatorWS ws = new OperatorWS();
            //ws.SetTyping(chatId, false, false);
        }
        return("");
    }
コード例 #6
0
        public void AddMessage(LiveSupport.LiveSupportModel.Message message)
        {
            string msg = string.Empty;

            if (API.FromSystem(message))
            {
                msg = string.Format("<span style='color: #FF9933; FONT-SIZE: 13px'> {0}</span><br />", message.Text);
                //ucm.GetMessage(msg, " ");
            }
            if (message.Type == MessageType.ChatMessage_VistorToOperator)
            {
                msg = string.Format("<span style='font-family: Arial;color:#008040;font-weight: bold;font-size: 12px;'>{0} </span><br/><span style='font-family: Arial;font-size: 12px;'>{1}</span><br />", message.Source + "&nbsp;&nbsp;&nbsp;" + message.SentDate.ToString("hh:mm:ss"), message.Text);
                //ucm.GetMessage(msg, " ");
            }
            if (message.Type == MessageType.ChatMessage_OperatorToVisitor)
            {
                msg = string.Format("<span style='font-family: Arial;color:blue;font-weight: bold;font-size: 12px;'>{0} </span><br/><span style='font-family: Arial;font-size: 12px;'>{1}</span><br />", message.Source + "&nbsp;&nbsp;&nbsp;" + message.SentDate.ToString("hh:mm:ss"), message.Text);
                //ucm.GetMessage(msg, " ");
            }
            AddText(msg);
            wb.Document.Window.ScrollTo(wb.Document.Body.ScrollRectangle.Left, wb.Document.Body.ScrollRectangle.Height);
        }
コード例 #7
0
ファイル: SqlMessageProvider.cs プロジェクト: honj51/ideacode
        public void AddMessage(Message msg)
        {
            SqlConnection conn = DBHelper.Getconn();
            SqlCommand cmd = new SqlCommand("LiveChat_ChatMessagesAdd", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader data = null;
            List<Message> retList = new List<Message>();
            try
            {
                cmd.Parameters.Add("@MessageId", SqlDbType.VarChar, 50).Value = msg.MessageId;
                cmd.Parameters.Add("@ChatID", SqlDbType.VarChar, 50).Value = msg.ChatId;
                cmd.Parameters.Add("@Source", SqlDbType.VarChar, 50).Value = msg.Source;
                cmd.Parameters.Add("@Destination", SqlDbType.VarChar, 50).Value = msg.Destination;
                cmd.Parameters.Add("@Text", SqlDbType.Text).Value = msg.Text;
                cmd.Parameters.Add("@SentDate", SqlDbType.BigInt).Value = msg.SentDate.Ticks;
                cmd.Parameters.Add("@Type", SqlDbType.VarChar, 50).Value = msg.Type.ToString();
                conn.Open();
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                conn.Close();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    if (conn.State == ConnectionState.Open)
                        conn.Close();

                    conn.Dispose();
                    conn = null;
                }
            }
        }
コード例 #8
0
ファイル: Message.cs プロジェクト: honj51/ideacode
 public static bool ToOperator(Message m)
 {
     return m.Type == MessageType.ChatMessage_VistorToOperator || m.Type == MessageType.SystemMessage_ToBoth || m.Type == MessageType.SystemMessage_ToOperator;
 }
コード例 #9
0
ファイル: TestFixture.cs プロジェクト: honj51/ideacode
 private Message NewMessage()
 {
     Random r = new Random();
     int index = r.Next(0, visitors.Count - 1);
     
     Message m = new Message();
     m.Type = MessageType.ChatMessage_VistorToOperator;
     m.ChatId = visitors[index].CurrentSession.SessionId;
     m.Source = "访客" + index;
     m.SentDate = DateTime.Now;
     m.Text = Guid.NewGuid().ToString();
     return m;
 }
コード例 #10
0
ファイル: Chat.aspx.cs プロジェクト: honj51/ideacode
    //�ļ�����
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        //��֤�ļ�·��
        try
        {
            if (CurrentChat == null || CurrentChat.Status != ChatStatus.Accepted)
            {
                this.Response.Write("<script>alert('�Ի�δ����');</script>");
                return;
            }
            string fileName = this.fuFile.FileName.ToString();
            if (fileName.Trim().Length == 0||fileName==null)//��֤�ϴ��ļ�
            {
                this.Response.Write("<script>alert('��ѡ���͵��ļ�');</script>");
                return;
            }
            if (this.fuFile.FileContent.Length >= 2097152)
            {
                this.Response.Write("<script>alert('���͵��ļ�����');</script>");
                return;
            }
            else
            {
                LiveSupport.LiveSupportModel.Message m = new LiveSupport.LiveSupportModel.Message();
                m.ChatId = CurrentChat.ChatId;
                m.Text = string.Format("���ڴ����ļ� {0} ...", fileName);
                m.Type = MessageType.SystemMessage_ToVisitor;
                ChatService.SendMessage(m);
                //string path = ConfigurationManager.AppSettings["FileUploadPath"] + "\\" + m.ChatId;
                string path = Server.MapPath("~/App_Data/" + m.ChatId);
                Directory.CreateDirectory(path);

                this.fuFile.PostedFile.SaveAs(path + "\\" + fileName.Trim());

                m = new LiveSupport.LiveSupportModel.Message();
                m.ChatId = CurrentChat.ChatId;
                m.Text = string.Format("�ļ� {0} ���ͳɹ�!  ...", fileName);
                m.Type = MessageType.SystemMessage_ToVisitor;
                ChatService.SendMessage(m);

                OperatorService.SendFile(m.ChatId, fileName.Trim());
            }

        }
        catch (Exception ex)
        {
            this.Response.Write("<script>alert('�ļ�����ʧ��,����" + ex.ToString() + "');</script>");
        }
    }
コード例 #11
0
ファイル: API.cs プロジェクト: honj51/ideacode
 public static bool IsSystemMessage(Message m)
 {
     return !IsChatMessage(m);
 }
コード例 #12
0
ファイル: API.cs プロジェクト: honj51/ideacode
 public static bool FromVisitor(Message m)
 {
     return m.Type == MessageType.ChatMessage_VistorToOperator;
 }
コード例 #13
0
        void operatorServiceAgent_AsyncCallCompleted(object sender, AsyncCallCompletedEventArg e)
        {
            if (e.Result == null)
            {
                return;
            }

            this.Invoke(new UpdateUIDelegate(delegate(object obj)
            {
                if (e.Result.GetType() == typeof(LiveSupport.OperatorConsole.LiveChatWS.SendMessageCompletedEventArgs))
                {
                    LiveSupport.OperatorConsole.LiveChatWS.SendMessageCompletedEventArgs arg = e.Result as LiveSupport.OperatorConsole.LiveChatWS.SendMessageCompletedEventArgs;
                    if (arg != null && arg.Error != null)
                    {
                        LiveSupport.LiveSupportModel.Message m = arg.UserState as LiveSupport.LiveSupportModel.Message;
                        if (m.ChatId == this.chat.ChatId)
                        {
                            string text = "<span style='color: #cccccc; FONT-SIZE: 15px'>" + m.SentDate + "\r\n\r\n可能由于网络原因“" + m.Text + "”消息发送失败。</span><br />";
                            chatMessageViewerControl1.AddText(text);
                        }
                    }
                }
                else if (e.Result.GetType() == typeof(LiveSupport.OperatorConsole.LiveChatWS.AcceptChatRequestCompletedEventArgs))
                {
                    LiveSupport.OperatorConsole.LiveChatWS.AcceptChatRequestCompletedEventArgs arg = e.Result as LiveSupport.OperatorConsole.LiveChatWS.AcceptChatRequestCompletedEventArgs;
                    if (arg.Error == null)
                    {
                        if (arg.Result == -1)
                        {
                            chatMessageViewerControl1.ResetContent("该访客对话请求已被其他客服接受");
                            receiveMessage             = false;
                            txtMsg.Enabled             = false;
                            TextWriterTraceListener tl = new TextWriterTraceListener();
                            return;
                        }
                        else if (arg.Result == -3)
                        {
                            chatMessageViewerControl1.ResetContent("服务器错误");
                            receiveMessage = false;
                            txtMsg.Enabled = false;
                            return;
                        }
                        Directory.CreateDirectory(chat.ChatId);

                        uploadURL = Properties.Settings.Default.FtpURL + "/" + chat.ChatId + "/";
                    }
                    else
                    {
                        chatMessageViewerControl1.ResetContent("可能由于网络原因,接受访客对话请求操作失败");
                        receiveMessage = false;
                        txtMsg.Enabled = false;
                        return;
                    }
                }
                else if (e.Result.GetType() == typeof(LiveSupport.OperatorConsole.LiveChatWS.InviteChatCompletedEventArgs))
                {
                    LiveSupport.OperatorConsole.LiveChatWS.InviteChatCompletedEventArgs arg = e.Result as LiveSupport.OperatorConsole.LiveChatWS.InviteChatCompletedEventArgs;

                    chat = (Chat)Common.Convert(arg.Result);
                    operatorServiceAgent.Chats.Add(chat);
                    Directory.CreateDirectory(chat.ChatId);
                    uploadURL = Properties.Settings.Default.FtpURL + "/" + chat.ChatId + "/";
                }
                else if (e.Result.GetType() == typeof(LiveSupport.OperatorConsole.LiveChatWS.CloseChatCompletedEventArgs))
                {
                    LiveSupport.OperatorConsole.LiveChatWS.CloseChatCompletedEventArgs arg = e.Result as LiveSupport.OperatorConsole.LiveChatWS.CloseChatCompletedEventArgs;
                }
                else if (e.Result.GetType() == typeof(System.ComponentModel.AsyncCompletedEventArgs))
                {
                    System.ComponentModel.AsyncCompletedEventArgs arg = e.Result as System.ComponentModel.AsyncCompletedEventArgs;
                    if (arg.Error != null)
                    {
                        Trace.WriteLine("sendFile exception:" + arg.Error.Message);
                        chatMessageViewerControl1.AddInformation("网络出现问题,暂时无法获取及发送消息");
                    }
                }
            }), e);
        }
コード例 #14
0
        public static object Convert(object obj)
        {
            if (obj == null)
            {
                return(null);
            }
            if (obj is LiveSupport.OperatorConsole.LiveChatWS.Visitor)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Visitor v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Visitor;

                LiveSupportModel.Visitor v2 = new LiveSupport.LiveSupportModel.Visitor();
                v2.AccountId      = v1.AccountId;
                v2.Company        = v1.Company;
                v2.Email          = v1.Email;
                v2.IsVIP          = v1.IsVIP;
                v2.Name           = v1.Name;
                v2.Remark         = v1.Remark;
                v2.VisitCount     = v1.VisitCount;
                v2.VisitorId      = v1.VisitorId;
                v2.CurrentSession = Convert(v1.CurrentSession) as LiveSupportModel.VisitSession;
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.VisitSession)
            {
                LiveSupport.OperatorConsole.LiveChatWS.VisitSession v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.VisitSession;
                LiveSupportModel.VisitSession v2 = new LiveSupport.LiveSupportModel.VisitSession();
                v2.Browser         = v1.Browser;
                v2.ChatingTime     = v1.ChatingTime;
                v2.ChatRequestTime = v1.ChatRequestTime;
                v2.ChattingDuring  = v1.ChattingDuring;
                v2.DomainRequested = v1.DomainRequested;
                v2.IP               = v1.IP;
                v2.LeaveTime        = v1.LeaveTime;
                v2.Location         = v1.Location;
                v2.OperatorId       = v1.OperatorId;
                v2.PageRequestCount = v1.PageRequestCount;
                v2.PageRequested    = v1.PageRequested;
                v2.SessionId        = v1.SessionId;
                v2.Referrer         = v1.Referrer;
                v2.Status           = (LiveSupportModel.VisitSessionStatus)Enum.Parse(typeof(LiveSupportModel.VisitSessionStatus), v1.Status.ToString());
                v2.VisitingTime     = v1.VisitingTime;
                v2.VisitorId        = v1.VisitorId;
                v2.WaitingDuring    = v1.WaitingDuring;
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Operator)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Operator v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Operator;
                LiveSupportModel.Operator v2 = new LiveSupport.LiveSupportModel.Operator();
                v2.AccountId       = v1.AccountId;
                v2.AVChatStatus    = v1.AVChatStatus;
                v2.Email           = v1.Email;
                v2.HeartBeatTime   = v1.HeartBeatTime;
                v2.IsAdmin         = v1.IsAdmin;
                v2.LoginName       = v1.LoginName;
                v2.NickName        = v1.NickName;
                v2.OperatorId      = v1.OperatorId;
                v2.OperatorSession = v1.OperatorSession;
                v2.Password        = v1.Password;
                v2.Status          = (LiveSupportModel.OperatorStatus)Enum.Parse(typeof(LiveSupportModel.OperatorStatus), v1.Status.ToString());
                return(v2);
            }
            else if (obj is LiveSupportModel.Message)
            {
                LiveSupportModel.Message v1 = obj as  LiveSupport.LiveSupportModel.Message;
                LiveSupport.OperatorConsole.LiveChatWS.Message v2 = new LiveSupport.OperatorConsole.LiveChatWS.Message();
                v2.ChatId      = v1.ChatId;
                v2.Destination = v1.Destination;
                v2.MessageId   = v1.MessageId;
                v2.SentDate    = v1.SentDate;
                v2.Source      = v1.Source;
                v2.Text        = v1.Text;
                v2.Type        = (LiveSupport.OperatorConsole.LiveChatWS.MessageType)Enum.Parse(typeof(LiveSupport.OperatorConsole.LiveChatWS.MessageType), v1.Type.ToString());
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Chat)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Chat v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Chat;
                LiveSupportModel.Chat v2 = new LiveSupport.LiveSupportModel.Chat();
                v2.ChatId             = v1.ChatId;
                v2.AcceptTime         = v1.AcceptTime;
                v2.AccountId          = v1.AccountId;
                v2.CloseBy            = v1.CloseBy;
                v2.CloseTime          = v1.CloseTime;
                v2.CreateBy           = v1.CreateBy;
                v2.CreateTime         = v1.CreateTime;
                v2.IsInviteByOperator = v1.IsInviteByOperator;
                v2.LastCheckTime      = v1.LastCheckTime;
                v2.OperatorId         = v1.OperatorId;
                v2.Status             = (LiveSupportModel.ChatStatus)Enum.Parse(typeof(LiveSupportModel.ChatStatus), v1.Status.ToString());
                v2.VisitorId          = v1.VisitorId;
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.LeaveWord)
            {
                LiveSupport.OperatorConsole.LiveChatWS.LeaveWord v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.LeaveWord;
                LiveSupportModel.LeaveWord v2 = new LiveSupport.LiveSupportModel.LeaveWord();
                // v2.Account = v1.Account;
                v2.CallerDate   = v1.CallerDate;
                v2.CallerName   = v1.CallerName;
                v2.Content      = v1.Content;
                v2.DomainName   = v1.DomainName;
                v2.Email        = v1.Email;
                v2.Id           = v1.Id;
                v2.Ip           = v1.Ip;
                v2.IsReplied    = v1.IsReplied;
                v2.IsSend       = v1.IsSend;
                v2.OperatorName = v1.OperatorName;
                v2.Phone        = v1.Phone;
                v2.Senddate     = v1.Senddate;
                v2.Subject      = v1.Subject;
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Account)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Account v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Account;
                LiveSupportModel.Account v2 = new LiveSupport.LiveSupportModel.Account();
                v2.AccountId     = v1.AccountId;
                v2.AccountNumber = v1.AccountNumber;
                v2.City          = v1.City;
                v2.CompanyName   = v1.CompanyName;
                v2.ContactName   = v1.ContactName;
                v2.Domain        = v1.Domain;
                v2.Email         = v1.Email;
                v2.Industry      = v1.Industry;
                v2.OperatorCount = v1.OperatorCount;
                v2.PaymentId     = v1.PaymentId;
                v2.Phone         = v1.Phone;
                v2.Province      = v1.Province;
                v2.RegisterDate  = v1.RegisterDate;
                v2.Remark        = v1.Remark;
                v2.Url           = v1.Url;
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.PageRequest)
            {
                LiveSupport.OperatorConsole.LiveChatWS.PageRequest v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.PageRequest;
                LiveSupportModel.PageRequest v2 = new LiveSupport.LiveSupportModel.PageRequest();
                v2.AccountId   = v1.AccountId;
                v2.Page        = v1.Page;
                v2.Referrer    = v1.Referrer;
                v2.RequestTime = v1.RequestTime;
                v2.SessionId   = v1.SessionId;
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory)
            {
                LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory;
                LiveSupportModel.QuickResponseCategory v2 = new LiveSupport.LiveSupportModel.QuickResponseCategory();
                v2.AccountId = v1.AccountId;
                v2.Name      = v1.Name;
                v2.QuickId   = v1.QuickId;
                v2.Responses = new List <string>(v1.Responses);
                return(v2);
            }
            else if (obj is LiveSupportModel.QuickResponseCategory)
            {
                LiveSupportModel.QuickResponseCategory v1 = obj as LiveSupportModel.QuickResponseCategory;
                LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory v2 = new LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory();
                v2.AccountId = v1.AccountId;
                v2.Name      = v1.Name;
                v2.QuickId   = v1.QuickId;
                v2.Responses = v1.Responses.ToArray();
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Message)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Message v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Message;
                LiveSupportModel.Message v2 = new LiveSupport.LiveSupportModel.Message();
                v2.ChatId      = v1.ChatId;
                v2.Destination = v1.Destination;
                v2.MessageId   = v1.MessageId;
                v2.SentDate    = v1.SentDate;
                v2.Source      = v1.Source;
                v2.Text        = v1.Text;
                v2.Type        = (LiveSupport.LiveSupportModel.MessageType)Enum.Parse(typeof(LiveSupport.LiveSupportModel.MessageType), v1.Type.ToString());
                return(v2);
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.SystemAdvertise)
            {
                LiveSupport.OperatorConsole.LiveChatWS.SystemAdvertise v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.SystemAdvertise;
                LiveSupportModel.SystemAdvertise v2 = new LiveSupport.LiveSupportModel.SystemAdvertise();
                v2.AdvertiseMessage = v1.AdvertiseMessage;
                v2.AdvertiseUrl     = v1.AdvertiseUrl;
                return(v2);
            }
            else
            {
                throw new ArgumentException("Unknow type");
            }
            return(null);
        }
コード例 #15
0
 public void SendMessage(LiveSupport.LiveSupportModel.Message msg)
 {
     msg.Text = "Echo > " + msg.Text;
     NewMessage(this, new ChatMessageEventArgs(msg));
 }
コード例 #16
0
ファイル: ChatForm.cs プロジェクト: honj51/ideacode
 //写信息
 private void WriteMessage(string message, string From)
 {
     LiveSupport.LiveSupportModel.Message msg = new LiveSupport.LiveSupportModel.Message();
     msg.ChatId = Chat.ChatId;
     msg.Text = message;
     msg.Source = From;
     msg.SentDate = DateTime.Now;
     msg.Type = MessageType.ChatMessage_OperatorToVisitor;
     operatorServiceAgent.SendMessage(msg);
     chatMessageViewerControl1.AddMessage(msg);
 }
コード例 #17
0
ファイル: API.cs プロジェクト: honj51/ideacode
 public static bool FromSystem(Message m)
 {
     return m.Type == MessageType.SystemMessage_ToBoth || m.Type == MessageType.SystemMessage_ToOperator || m.Type == MessageType.SystemMessage_ToVisitor;
 }
コード例 #18
0
ファイル: OperatorService.cs プロジェクト: honj51/ideacode
    private static void sendUploadFileCompletedMessage(string fileName, string chatId)
    {
        Message m = new Message();
        m.ChatId = chatId;
        Util util = new Util();
        string httpURL = System.Configuration.ConfigurationManager.AppSettings["HomeRootUrl"] + "/upload/" + chatId + "/" + fileName.Replace("'","%27");
        if (util.IsImageFile(fileName))
        {
            m.Text = string.Format("客服已给您发送文件 {0}<a target='_blank' href='{1}\'>点击保存</a> <br/><img height='120px'  width='120px'  src='{2}\' />", fileName, httpURL, httpURL);
        }
        else
        {
            m.Text = string.Format("客服已给您发送文件 {0} <a target='_blank' href='{1}'>点击保存</a>", fileName, httpURL);
        }
        m.Type = MessageType.SystemMessage_ToVisitor;
        ChatService.SendMessage(m);

        m = new LiveSupport.LiveSupportModel.Message();
        m.ChatId = chatId;
        m.Text = string.Format("文件 {0} 发送成功!  ...", fileName);
        m.Type = MessageType.SystemMessage_ToOperator;
        ChatService.SendMessage(m);
    }
コード例 #19
0
ファイル: API.cs プロジェクト: honj51/ideacode
 public static bool IsChatMessage(Message m)
 {
     return m.Type == MessageType.ChatMessage_VistorToOperator || m.Type == MessageType.ChatMessage_OperatorToVisitor;
 }
コード例 #20
0
ファイル: Common.cs プロジェクト: honj51/ideacode
        public static object Convert(object obj)
        {
            if (obj == null)
            {
                return null;
            }
            if (obj is LiveSupport.OperatorConsole.LiveChatWS.Visitor)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Visitor v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Visitor;

                LiveSupportModel.Visitor v2 = new LiveSupport.LiveSupportModel.Visitor();
                v2.AccountId = v1.AccountId;
                v2.Company = v1.Company;
                v2.Email = v1.Email;
                v2.IsVIP = v1.IsVIP;
                v2.Name = v1.Name;
                v2.Remark = v1.Remark;
                v2.VisitCount = v1.VisitCount;
                v2.VisitorId = v1.VisitorId;
                v2.CurrentSession = Convert(v1.CurrentSession) as LiveSupportModel.VisitSession;
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.VisitSession)
            {
                LiveSupport.OperatorConsole.LiveChatWS.VisitSession v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.VisitSession;
                LiveSupportModel.VisitSession v2 = new LiveSupport.LiveSupportModel.VisitSession();
                v2.Browser = v1.Browser;
                v2.ChatingTime = v1.ChatingTime;
                v2.ChatRequestTime = v1.ChatRequestTime;
                v2.ChattingDuring = v1.ChattingDuring;
                v2.DomainRequested = v1.DomainRequested;
                v2.IP = v1.IP;
                v2.LeaveTime = v1.LeaveTime;
                v2.Location = v1.Location;
                v2.OperatorId = v1.OperatorId;
                v2.PageRequestCount = v1.PageRequestCount;
                v2.PageRequested = v1.PageRequested;
                v2.SessionId = v1.SessionId;
                v2.Referrer = v1.Referrer;
                v2.Status = (LiveSupportModel.VisitSessionStatus)Enum.Parse(typeof(LiveSupportModel.VisitSessionStatus), v1.Status.ToString());
                v2.VisitingTime = v1.VisitingTime;
                v2.VisitorId = v1.VisitorId;
                v2.WaitingDuring = v1.WaitingDuring;
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Operator)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Operator v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Operator;
                LiveSupportModel.Operator v2 = new LiveSupport.LiveSupportModel.Operator();
                v2.AccountId = v1.AccountId;
                v2.AVChatStatus = v1.AVChatStatus;
                v2.Email = v1.Email;
                v2.HeartBeatTime = v1.HeartBeatTime;
                v2.IsAdmin = v1.IsAdmin;
                v2.LoginName = v1.LoginName;
                v2.NickName = v1.NickName;
                v2.OperatorId = v1.OperatorId;
                v2.OperatorSession = v1.OperatorSession;
                v2.Password = v1.Password;
                v2.Status = (LiveSupportModel.OperatorStatus)Enum.Parse(typeof(LiveSupportModel.OperatorStatus), v1.Status.ToString());
                return v2;
            }
            else if (obj is LiveSupportModel.Message)
            {
                LiveSupportModel.Message v1 = obj as  LiveSupport.LiveSupportModel.Message;
                LiveSupport.OperatorConsole.LiveChatWS.Message v2 = new LiveSupport.OperatorConsole.LiveChatWS.Message();
                v2.ChatId = v1.ChatId;
                v2.Destination = v1.Destination;
                v2.MessageId = v1.MessageId;
                v2.SentDate = v1.SentDate;
                v2.Source = v1.Source;
                v2.Text = v1.Text;
                v2.Type = (LiveSupport.OperatorConsole.LiveChatWS.MessageType)Enum.Parse(typeof(LiveSupport.OperatorConsole.LiveChatWS.MessageType), v1.Type.ToString());
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Chat)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Chat v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Chat;
                LiveSupportModel.Chat v2 = new LiveSupport.LiveSupportModel.Chat();
                v2.ChatId = v1.ChatId;
                v2.AcceptTime = v1.AcceptTime;
                v2.AccountId = v1.AccountId;
                v2.CloseBy = v1.CloseBy;
                v2.CloseTime = v1.CloseTime;
                v2.CreateBy = v1.CreateBy;
                v2.CreateTime = v1.CreateTime;
                v2.IsInviteByOperator = v1.IsInviteByOperator;
                v2.LastCheckTime = v1.LastCheckTime;
                v2.OperatorId = v1.OperatorId;
                v2.Status = (LiveSupportModel.ChatStatus)Enum.Parse(typeof(LiveSupportModel.ChatStatus), v1.Status.ToString());
                v2.VisitorId = v1.VisitorId;
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.LeaveWord)
            {
                LiveSupport.OperatorConsole.LiveChatWS.LeaveWord v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.LeaveWord;
                LiveSupportModel.LeaveWord v2 = new LiveSupport.LiveSupportModel.LeaveWord();
               // v2.Account = v1.Account;
                v2.CallerDate = v1.CallerDate;
                v2.CallerName = v1.CallerName;
                v2.Content = v1.Content;
                v2.DomainName = v1.DomainName;
                v2.Email = v1.Email;
                v2.Id = v1.Id;
                v2.Ip = v1.Ip;
                v2.IsReplied = v1.IsReplied;
                v2.IsSend = v1.IsSend;
                v2.OperatorName = v1.OperatorName;
                v2.Phone = v1.Phone;
                 v2.Senddate = v1.Senddate;
                 v2.Subject = v1.Subject;
                 return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Account)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Account v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Account;
                LiveSupportModel.Account v2 = new LiveSupport.LiveSupportModel.Account();
                v2.AccountId = v1.AccountId;
                v2.AccountNumber = v1.AccountNumber;
                v2.City = v1.City;
                v2.CompanyName = v1.CompanyName;
                v2.ContactName = v1.ContactName;
                v2.Domain = v1.Domain;
                v2.Email = v1.Email;
                v2.Industry = v1.Industry;
                v2.OperatorCount = v1.OperatorCount;
                v2.PaymentId = v1.PaymentId;
                v2.Phone = v1.Phone;
                v2.Province = v1.Province;
                v2.RegisterDate = v1.RegisterDate;
                v2.Remark = v1.Remark;
                v2.Url = v1.Url;
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.PageRequest)
            {
             LiveSupport.OperatorConsole.LiveChatWS.PageRequest v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.PageRequest;
                LiveSupportModel.PageRequest v2 = new LiveSupport.LiveSupportModel.PageRequest();
                v2.AccountId = v1.AccountId;
                v2.Page = v1.Page;
                v2.Referrer = v1.Referrer;
                v2.RequestTime = v1.RequestTime;
                v2.SessionId = v1.SessionId;
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory)
            {
                LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory;
                LiveSupportModel.QuickResponseCategory v2 = new LiveSupport.LiveSupportModel.QuickResponseCategory();
                v2.AccountId = v1.AccountId;
                v2.Name = v1.Name;
                v2.QuickId = v1.QuickId;
                v2.Responses =new List<string>(v1.Responses);
                return v2;
            }
            else if (obj is LiveSupportModel.QuickResponseCategory)
            {
                LiveSupportModel.QuickResponseCategory v1 = obj as LiveSupportModel.QuickResponseCategory;
                LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory v2 = new LiveSupport.OperatorConsole.LiveChatWS.QuickResponseCategory();
                v2.AccountId = v1.AccountId;
                v2.Name = v1.Name;
                v2.QuickId = v1.QuickId;
                v2.Responses = v1.Responses.ToArray();
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.Message)
            {
                LiveSupport.OperatorConsole.LiveChatWS.Message v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.Message;
                LiveSupportModel.Message v2 = new LiveSupport.LiveSupportModel.Message();
                v2.ChatId = v1.ChatId;
                v2.Destination = v1.Destination;
                v2.MessageId = v1.MessageId;
                v2.SentDate = v1.SentDate;
                v2.Source = v1.Source;
                v2.Text = v1.Text;
                v2.Type = (LiveSupport.LiveSupportModel.MessageType)Enum.Parse(typeof(LiveSupport.LiveSupportModel.MessageType), v1.Type.ToString());
                return v2;
            }
            else if (obj is LiveSupport.OperatorConsole.LiveChatWS.SystemAdvertise)
            {
                LiveSupport.OperatorConsole.LiveChatWS.SystemAdvertise v1 = obj as LiveSupport.OperatorConsole.LiveChatWS.SystemAdvertise;
                LiveSupportModel.SystemAdvertise v2 = new LiveSupport.LiveSupportModel.SystemAdvertise();
                v2.AdvertiseMessage = v1.AdvertiseMessage;
                v2.AdvertiseUrl = v1.AdvertiseUrl;
                return v2;
            }
            else
            {
                throw new ArgumentException("Unknow type");
            }
            return null;
        }
コード例 #21
0
 public void SendMessage(Message msg)
 {
     ws.SendMessageAsync(Common.Convert(msg) as LiveChatWS.Message, Guid.NewGuid());
 }
コード例 #22
0
ファイル: Chat.aspx.cs プロジェクト: honj51/ideacode
    public static string SendMsg(string msg, string chtID)
    {
        if (chtID != null && msg.Length > 0)
        {
            // Add a new message to the discussion
            string chatId = chtID;
            //����һ��������Ϣʵ��
            LiveSupport.LiveSupportModel.Message m = new LiveSupport.LiveSupportModel.Message();
            m.ChatId = chatId;
            m.Source = VName;
            m.Text = HttpUtility.HtmlEncode(msg);
            m.Type = MessageType.ChatMessage_VistorToOperator;
            ChatService.SendMessage(m);

            //OperatorWS ws = new OperatorWS();
            //ws.SetTyping(chatId, false, false);
        }
        return "";
    }