コード例 #1
0
ファイル: Form1.cs プロジェクト: radtek/crm
        //MessageHandler _handler = new MessageHandler();
        private void button1_Click(object sender, EventArgs e)
        {
            SMSSendDAO dao  = new SMSSendDAO(new JIT.Utility.BasicUserInfo());
            var        temp = dao.GetNoSend();

            this.dataGridView1.DataSource = temp.ToList();
        }
コード例 #2
0
        private void DoWork()
        {
            #region 一条一条发送

            while (true)
            {
                try
                {
                    SMSSendDAO Dao = new SMSSendDAO(new BasicUserInfo());
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "开始查询数据库"
                    });
                    var entities = Dao.GetNoSend();
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("获取{0}条数据", entities.Length)
                    });
                    foreach (var item in entities)
                    {
                        var result = GetResult(item.GetSMS().Send(JIT.Utility.SMS.Base.SendType.Get));
                        if (result.IsSuccess)
                        {
                            item.Status            = 1;
                            item.SendCount         = (item.SendCount ?? 0) + 1;
                            item.Mtmsgid           = result.SMSID;
                            item.RegularlySendTime = DateTime.Now;
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result)
                            });
                        }
                        else
                        {
                            item.SendCount = (item.SendCount ?? 0) + 1;
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result)
                            });
                        }
                        Dao.Update(item);
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(CycleInterval ?? 5));
                }
                catch (Exception ex)
                {
                    Loggers.Exception(new ExceptionLogInfo(ex));
                }
            }

            #endregion
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: radtek/crm
        //private bool IsSuccess(string result)
        //{
        //    if (result.EndsWith("000"))
        //        return true;
        //    else
        //        return false;
        //}

        private void button3_Click(object sender, EventArgs e)
        {
            //BaiYunSMS sms = new BaiYunSMS();
            //sms.Mobile = "18302159648";
            //sms.Message = "你好";
            //var result = sms.Send(JIT.Utility.SMS.Base.SendType.Get);
            //var blance = sms.GetBalance();

            SMSSendDAO Dao = new SMSSendDAO(new BasicUserInfo());

            Loggers.Debug(new DebugLogInfo()
            {
                Message = "开始查询数据库"
            });
            var entities = Dao.GetNoSend();

            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("获取{0}条数据", entities.Length)
            });
            foreach (var item in entities)
            {
                var NO     = item.MobileNO;
                var result = GetResult(item.GetSMS().Send2(JIT.Utility.SMS.Base.SendType.Get));
                if (result.IsSuccess)
                {
                    item.Status            = 1;
                    item.SendCount         = (item.SendCount ?? 0) + 1;
                    item.Mtmsgid           = result.SMSID;
                    item.RegularlySendTime = DateTime.Now;
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result)
                    });
                }
                else
                {
                    item.SendCount = (item.SendCount ?? 0) + 1;
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result)
                    });
                }
                Dao.Update(item);
            }
        }
コード例 #4
0
ファイル: ReceiveService.asmx.cs プロジェクト: radtek/crm
 public string Recieve(string phoneNO, string message, string sign)
 {
     try
     {
         var dao = new SMSSendDAO(new BasicUserInfo());
         dao.Create(new SMSSendEntity
         {
             MobileNO   = phoneNO,
             SMSContent = message,
             Status     = 0,//未发送
             Sign       = sign,
             SendTime   = DateTime.Now
         });
     }
     catch (Exception ex)
     {
         Loggers.Exception(new BasicUserInfo(), ex);
         return("F");
     }
     return("T");
 }
コード例 #5
0
ファイル: Service1.cs プロジェクト: radtek/crm
        private void DoWork()
        {
            #region 一条一条发送

            while (true)
            {
                try
                {
                    SMSSendDAO Dao = new SMSSendDAO(new BasicUserInfo());
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "开始查询数据库"
                    });
                    var entities = Dao.GetNoSend();
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("获取{0}条数据", entities.Length)
                    });
                    foreach (var item in entities)
                    {
                        var result = GetResult(item.GetSMS().Send2(JIT.Utility.SMS.Base.SendType.Get));
                        if (result.IsSuccess)
                        {
                            item.Status            = 1;
                            item.SendCount         = (item.SendCount ?? 0) + 1;
                            item.Mtmsgid           = result.SMSID;
                            item.RegularlySendTime = DateTime.Now;
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = "【发送成功】{0}【手机号】:{1}{0}【内容】:{2}{0}【返回码】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result.ToJSON())
                            });
                        }
                        else
                        {
                            var msg = "【发送失败】{0}【手机号】:{1}{0}【内容】:{2}{0}【错误信息】:{3}".Fmt(Environment.NewLine, item.MobileNO, item.SMSContent, result.ToJSON());
                            item.SendCount = (item.SendCount ?? 0) + 1;
                            Loggers.Debug(new DebugLogInfo {
                                Message = msg
                            });
                            if (item.SendCount > 2)
                            {
                                Loggers.Debug(new DebugLogInfo
                                {
                                    Message = item.SendCount.ToString() + _sendMailForFailMessage == null ? "空" : "非空"
                                });
                                if (!string.IsNullOrEmpty(item.Sign))
                                {
                                    string mailto = string.Empty;
                                    if (_dict.TryGetValue(item.Sign, out mailto))
                                    {
                                        _sendMailForFailMessage.BeginInvoke(msg, item.Sign, mailto, null, null);
                                    }
                                }
                                else
                                {
                                    Loggers.Debug(new DebugLogInfo
                                    {
                                        Message = "没有签名"
                                    });
                                }
                            }
                        }
                        Dao.Update(item);
                        //由于平台对发送频率有限制,同一个号码一分钟内不能发送2次以上,所以对4081的代码作延迟1分钟处理.
                        if (result.Code == "4081")
                        {
                            Thread.Sleep(TimeSpan.FromMinutes(1));
                        }
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(CycleInterval ?? 5));
                }
                catch (Exception ex)
                {
                    Loggers.Exception(new ExceptionLogInfo(ex));
                    Thread.Sleep(TimeSpan.FromMinutes(2));
                }
            }

            #endregion
        }
コード例 #6
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public SMSSendBLL(BasicUserInfo pUserInfo)
 {
     this._currentDAO = new SMSSendDAO(pUserInfo);
 }