Example #1
0
        /// <summary>
        /// 发送回团提醒短信
        /// </summary>
        /// <param name="model">出回团提醒短信任务实体</param>
        /// <param name="message">短信内容(未替换)</param>
        private void SendMessage(MSmsTourTimePlan model, string message)
        {
            if (model == null || string.IsNullOrEmpty(model.CompanyId) || model.Traveller == null ||
                model.Traveller.Count < 1 || string.IsNullOrEmpty(message))
            {
                return;
            }

            string smscontent = message.Replace("[线路名称]", model.RouteName).Replace("[回团时间]", model.BackTime.ToString("yyyy-MM-dd"));

            foreach (var t in model.Traveller)
            {
                var sendMessage = new EyouSoft.BackgroundServices.SmsApi.MSendMessage
                {
                    CompanyId = model.CompanyId,
                    Mobiles   =
                        new[] { new EyouSoft.BackgroundServices.SmsApi.MSmsNumber {
                                    Code = t.Code
                                } },
                    SendChannel  = 0,
                    SendTime     = DateTime.Now,
                    SendType     = EyouSoft.BackgroundServices.SmsApi.SendType.直接发送,
                    SmsContent   = smscontent.Replace("[游客姓名]", t.Traveller),
                    UserFullName = string.Empty,//直接包含在内容中
                    UserId       = model.SellerId
                };

                SmsUtils.GetSmsApi().SendMessage(sendMessage);
            }
        }
Example #2
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="info">计划信息</param>
        private void SendSms(Model.SmsStructure.MSmsTimerTask info)
        {
            if (info == null || string.IsNullOrEmpty(info.CompanyId) || string.IsNullOrEmpty(info.Content) ||
                info.Number == null)
            {
                return;
            }

            var sendMessage = new EyouSoft.BackgroundServices.SmsApi.MSendMessage();
            var number      = new EyouSoft.BackgroundServices.SmsApi.MSmsNumber[info.Number.Count];

            for (int i = 0; i < info.Number.Count; i++)
            {
                if (info.Number[i] == null)
                {
                    continue;
                }
                number[i] = new EyouSoft.BackgroundServices.SmsApi.MSmsNumber
                {
                    Code = info.Number[i].Code,
                    Type =
                        (EyouSoft.BackgroundServices.SmsApi.MobileType)
                        Convert.ToInt32(info.Number[i].Type)
                };
            }
            sendMessage.CompanyId    = info.CompanyId;
            sendMessage.Mobiles      = number;
            sendMessage.SendChannel  = info.Channel;
            sendMessage.SendTime     = info.SendTime;
            sendMessage.SendType     = EyouSoft.BackgroundServices.SmsApi.SendType.直接发送;
            sendMessage.SmsContent   = info.Content;
            sendMessage.UserFullName = string.Empty;
            sendMessage.UserId       = info.OperatorId;

            EyouSoft.BackgroundServices.SmsApi.MSendResult result = SmsUtils.GetSmsApi().SendMessage(sendMessage);

            if (result.IsSucceed == false)
            {
                IList <Model.SmsStructure.MSmsTaskState> list = new List <Model.SmsStructure.MSmsTaskState>
                {
                    new Model.SmsStructure.MSmsTaskState
                    {
                        RealTime   = null,
                        Status     = SendStatus.发送失败,
                        StatusDesc = result.ErrorMessage,
                        TaskId     = info.TaskId
                    }
                };

                _dal.UpdateSmsTimerTaskState(list);
            }
        }
        /// <summary>
        /// 发送生日提醒短信
        /// </summary>
        /// <param name="model">生日提醒短信配置实体</param>
        private void SendSms(MSmsSetting model)
        {
            if (model == null || string.IsNullOrEmpty(model.CompanyId))
            {
                return;
            }

            var list = _dal.GetSmsBirthdayRemindPlan(model.CompanyId, model.BeforeDay);

            if (list == null || list.Count < 1)
            {
                return;
            }

            EyouSoft.Toolkit.Utils.WLog(string.Format("系统{0}发送{1}条生日提醒短信", model.CompanyId, list.Count), "/log/service.sms.birthday.log");

            foreach (var t in list)
            {
                if (t == null || string.IsNullOrEmpty(t.CompanyId) || string.IsNullOrEmpty(t.MobilePhone))
                {
                    continue;
                }

                var sendMessage = new EyouSoft.BackgroundServices.SmsApi.MSendMessage
                {
                    CompanyId = t.CompanyId,
                    Mobiles   =
                        new[] { new EyouSoft.BackgroundServices.SmsApi.MSmsNumber {
                                    Code = t.MobilePhone
                                } },
                    SendChannel  = 0,
                    SendTime     = DateTime.Now,
                    SendType     = EyouSoft.BackgroundServices.SmsApi.SendType.直接发送,
                    SmsContent   = model.Message.Replace("[姓名]", t.Name).Replace("[生日]", t.Birthday.ToString("MM-dd")),
                    UserFullName = string.Empty,//直接包含在内容中
                    UserId       = model.OperatorId
                };

                SmsUtils.GetSmsApi().SendMessage(sendMessage);
            }
        }