Пример #1
0
        public void Run()
        {
            SmsUtils.WLog("短信中心定时短信后台服务开启\r\n", "Config/BackgroundServicesLog.txt");

            try
            {
                //获取要发送的短信集合
                if (this._queue == null || this._queue.Count == 0)
                {
                    this._queue = this.dal.GetSends();
                }

                //发送短信
                if (this._queue != null && this._queue.Count > 0)
                {
                    SmsUtils.WLog(string.Format("短信中心定时短信后台服务发送短信记录数:{0}", this._queue.Count), "Config/BackgroundServicesLog.txt");
                    while (true)
                    {
                        if (this._queue.Count == 0)
                        {
                            break;
                        }
                        var info = this._queue.Dequeue();
                        this.SendSMS(info);
                    }
                }
            }
            catch { }
        }
Пример #2
0
        /// <summary>
        /// 发送固定时间(指定的时间值)短信
        /// </summary>
        private void SendFixedTimeMessage()
        {
            IList <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo> items = dal.GetTimeSend(DateTime.Now);

            if (items != null && items.Count > 0)
            {
                SmsUtils.WLog(string.Format("客户关怀后台服务发送固定时间(指定的时间值)短信记录数:{0}", items.Count), "Config/BackgroundServicesLog.txt");
                foreach (var item in items)
                {
                    this.SendMessage(item);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 发送节假日及生日短信
        /// </summary>
        private void SendHolidaysMessage()
        {
            DateTime now = DateTime.Now;
            //客户关怀固定节假日及生日短信发送时间(点时间)验证
            int caringSmsSendHours = Utils.GetInt(Toolkit.ConfigHelper.ConfigClass.GetConfigString("CaringSmsSendHours"), 9);

            if (now.Hour != caringSmsSendHours)
            {
                return;
            }

            IList <EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo> items = dal.GetFixTypeSend(this.GetSpecialTimeTypes());

            if (items != null && items.Count > 0)
            {
                SmsUtils.WLog(string.Format("客户关怀后台服务发送节假日及生日短信记录数:{0}", items.Count), "Config/BackgroundServicesLog.txt");
                foreach (var item in items)
                {
                    this.SendMessage(item);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="info"></param>
        private void SendMessage(EyouSoft.Model.CompanyStructure.CustomerCareforSendInfo info)
        {
            if (info == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(info.MobileCode) && (info.NameAndMobile == null || info.NameAndMobile.Count < 1))
            {
                return;
            }

            EyouSoft.BackgroundServices.SMSSOAP.SMSChannel channel = SmsUtils.GetSmsSendChannel(info.ChannelId);

            #region 输入号码
            if (!string.IsNullOrEmpty(info.MobileCode))//输入号码
            {
                EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo messageInfo = new EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo();
                string[] mobileArr = info.MobileCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[] mobiles = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[mobileArr.Length];
                for (int i = 0; i < mobileArr.Length; i++)
                {
                    mobiles[i]           = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo();
                    mobiles[i].Mobile    = mobileArr[i];
                    mobiles[i].IsEncrypt = false;
                }

                SmsUtils.WLog(string.Format("客户关怀后台服务发送固定时间(指定的时间值)将要发送短信条数:{0}", mobiles.Length), "Config/BackgroundServicesLog.txt");

                messageInfo.Mobiles      = mobiles;
                messageInfo.CompanyId    = info.CompanyId;
                messageInfo.CompanyName  = "";
                messageInfo.SendChannel  = channel;
                messageInfo.SendTime     = DateTime.Now;
                messageInfo.SendType     = EyouSoft.BackgroundServices.SMSSOAP.SendType.直接发送;
                messageInfo.SMSContent   = info.Content;
                messageInfo.SMSType      = 0;
                messageInfo.UserFullName = "";
                messageInfo.UserId       = info.OperatorId;

                EyouSoft.BackgroundServices.SMSSOAP.SMSAPI api = EyouSoft.Services.BackgroundServices.SmsUtils.GetSmsApi();

                EyouSoft.BackgroundServices.SMSSOAP.SendResultInfo result = api.Send(messageInfo);
            }
            #endregion

            #region 匹配号码
            if (info.NameAndMobile != null && info.NameAndMobile.Count > 0)//匹配号码
            {
                SmsUtils.WLog(string.Format("客户关怀后台服务发送节假日及生日短信将要发送短信条数:{0}", info.NameAndMobile.Count), "Config/BackgroundServicesLog.txt");
                foreach (var nameAndMobile in info.NameAndMobile)
                {
                    if (string.IsNullOrEmpty(nameAndMobile.ContactMobile))
                    {
                        continue;
                    }

                    EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo    messageInfo = new EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo();
                    EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[] mobiles     = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[1];
                    mobiles[0]           = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo();
                    mobiles[0].Mobile    = nameAndMobile.ContactMobile;
                    mobiles[0].IsEncrypt = false;

                    messageInfo.Mobiles      = mobiles;
                    messageInfo.CompanyId    = info.CompanyId;
                    messageInfo.CompanyName  = "";
                    messageInfo.SendChannel  = channel;
                    messageInfo.SendTime     = DateTime.Now;
                    messageInfo.SendType     = EyouSoft.BackgroundServices.SMSSOAP.SendType.直接发送;
                    messageInfo.SMSContent   = info.Content.Replace("[姓名]", nameAndMobile.ContactName);
                    messageInfo.SMSType      = 0;
                    messageInfo.UserFullName = "";
                    messageInfo.UserId       = info.OperatorId;

                    EyouSoft.BackgroundServices.SMSSOAP.SMSAPI api = EyouSoft.Services.BackgroundServices.SmsUtils.GetSmsApi();

                    EyouSoft.BackgroundServices.SMSSOAP.SendResultInfo result = api.Send(messageInfo);
                }
            }
            #endregion
        }
Пример #5
0
 public void Run()
 {
     SmsUtils.WLog("客户关怀后台服务开启\r\n", "Config/BackgroundServicesLog.txt");
     this.SendFixedTimeMessage();
     this.SendHolidaysMessage();
 }