Ejemplo n.º 1
0
        /// <summary>
        /// 消息转发多客服
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="sendKey"></param>
        private void SendCustomerService(Object obj)
        {
            string result = string.Empty;
            string date   = string.Empty;
            string strUrl = string.Empty;

            try
            {
                ReceiveMsgBase msg = obj as ReceiveMsgBase;

                if (msg == null)
                {
                    return;
                }


                if (msg is LinkMsg)
                {
                    LinkMsg link = msg as LinkMsg;
                    link.Title       = "<![CDATA[" + link.Title + "]]>";
                    link.Description = "<![CDATA[" + link.Description + "]]>";
                    link.Url         = "<![CDATA[" + link.Url + "]]>";
                }
                else if (msg is LocationMsg)
                {
                    LocationMsg link = msg as LocationMsg;
                    link.Location_X = "<![CDATA[" + link.Location_X + "]]>";
                    link.Location_Y = "<![CDATA[" + link.Location_Y + "]]>";
                    link.Scale      = "<![CDATA[" + link.Scale + "]]>";
                    link.Label      = "<![CDATA[" + link.Label + "]]>";
                }
                else if (msg is PicMsg)
                {
                    PicMsg link = msg as PicMsg;
                    link.PicUrl  = "<![CDATA[" + link.PicUrl + "]]>";
                    link.MediaId = "<![CDATA[" + link.MediaId + "]]>";
                }
                else if (msg is TextMsg)
                {
                    TextMsg link = msg as TextMsg;
                    link.Content = "<![CDATA[" + link.Content + "]]>";
                }
                else if (msg is VideoMsg)
                {
                    VideoMsg link = msg as VideoMsg;
                    link.ThumbMediaId = "<![CDATA[" + link.ThumbMediaId + "]]>";
                    link.MediaId      = "<![CDATA[" + link.MediaId + "]]>";
                }
                else if (msg is VoiceMsg)
                {
                    VoiceMsg link = msg as VoiceMsg;
                    link.MediaId     = "<![CDATA[" + link.MediaId + "]]>";
                    link.Format      = "<![CDATA[" + link.Format + "]]>";
                    link.Recognition = "<![CDATA[" + link.Recognition + "]]>";
                }

                //try
                //{
                //    DataTable dt = DalMemberCommon.GetMemberInfoByWeiXinOpenId(msg.FromUserName);
                //    if (dt != null && dt.Rows.Count > 0)
                //    {
                date   = msg.ToXml();
                strUrl = @"http://dkf.ozner.net/service/wxcustomer.aspx";
            }
            catch (Exception ex)
            {
                string errorinfo = "错误堆栈:" + ex.StackTrace;

                if (obj != null)
                {
                    string addition = "";

                    string baseName = obj.GetType().Name;
                    if (obj is ReceiveMsgBase)
                    {
                        ReceiveMsgBase rmb  = obj as ReceiveMsgBase;
                        Type           type = rmb.GetType();

                        if (rmb is LinkMsg)
                        {
                            LinkMsg link = rmb as LinkMsg;
                            addition = link.Title + "|" + link.Description + "|" + link.Url;
                        }
                        else if (rmb is LocationMsg)
                        {
                            LocationMsg link = rmb as LocationMsg;
                            addition = link.Location_X + "|" + link.Location_Y + "|" + link.Scale + "|" + link.Label;
                        }
                        else if (rmb is PicMsg)
                        {
                            PicMsg link = rmb as PicMsg;
                            addition = link.PicUrl + "|" + link.MediaId;
                        }
                        else if (rmb is TextMsg)
                        {
                            TextMsg link = rmb as TextMsg;
                            addition = link.Content;
                        }
                        else if (rmb is VideoMsg)
                        {
                            VideoMsg link = rmb as VideoMsg;
                            addition = link.MediaId + "|" + link.ThumbMediaId;
                        }
                        else if (rmb is VoiceMsg)
                        {
                            VoiceMsg link = rmb as VoiceMsg;
                            addition = link.MediaId + "|" + link.Format + "|" + link.Recognition;
                        }
                    }
                    errorinfo = "类型:" + obj.GetType().Name + " 额外信息:" + addition + " 错误信息:" + errorinfo;
                }

                //LogBase.LogHzLkt.LogExErr("HzLktSite", "OznerMall", "SendCustomerService", errorinfo, ELogExLevel.Higher, errorinfo);
            }

            try
            {
                result = WebClientHelper.CallPost(strUrl, date, Encoding.UTF8);
            }
            catch (Exception ex)
            {
                //LogBase.LogHzLkt.LogExErr(ex, ELogExLevel.Middle);
            }
        }