Exemple #1
0
        public void Insert(string PhoneNumber,string MsnContent,DateTime? MsnDate,string MsnCode,bool? IsChecked,int? OrderId,string Status)
        {
            SysMsnLog item = new SysMsnLog();

            item.PhoneNumber = PhoneNumber;

            item.MsnContent = MsnContent;

            item.MsnDate = MsnDate;

            item.MsnCode = MsnCode;

            item.IsChecked = IsChecked;

            item.OrderId = OrderId;

            item.Status = Status;

            item.Save(UserName);
        }
Exemple #2
0
 private static bool SendMessageCore(string phone, string content, string checkCode, int orderId, out int logId, out string message)
 {
     //BackgroundWorker.DoWork<int>(logId, (o) =>
     //{
     message = "发送成功";
     content = FormatContent(content);
     SysMsnLog log = new SysMsnLog( )
     {
         MsnDate = DateTime.Now,
         MsnContent = content,
         PhoneNumber = phone,
         OrderId = orderId,
         MsnCode = checkCode,
         IsChecked = false,
         Status = null
     };
     bool isSuccess = true;
     #if !NoMsn
     try
     {
         var request = (HttpWebRequest)HttpWebRequest.Create(BuildRequestParam(phone, content));
         request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
         request.Method = "GET";
         request.Timeout = 5000;
         MsnResult result = new MsnResult( );
         System.Net.ServicePointManager.DefaultConnectionLimit = 100;
         using (WebResponse hs = request.GetResponse( ))
         {
             using (Stream stream = hs.GetResponseStream( ))
             {
                 //using (StreamReader reader = new StreamReader(stream, __encoding))
                 //{
                 //    message = reader.ReadToEnd( );
                 //}
                 //stream.Position = 0L;
                 using (XmlReader xr = XmlReader.Create(stream))
                 {
                     string name = null;
                     while (xr.Read( ))
                     {
                         if (xr.NodeType == XmlNodeType.Element)
                         {
                             name = xr.Name;
                         }
                         else if (xr.NodeType == XmlNodeType.Text)
                             result.SetResult(name, xr.ReadString( ));
                     }
                 }
             }
         }
         isSuccess = result.State == "0";
         if (!isSuccess)
             message = result.MsgState;
     }
     catch (Exception ex)
     {
         message = ex.Message + Environment.NewLine + ex.StackTrace;
         Logging.Log("MsnBLL->SendMessageCore", ex);
     }
     #endif
     log.Status = message;
     log.Save( );
     logId = log.Id;
     return isSuccess;
     //});
 }