Beispiel #1
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="info">计划信息</param>
        private void SendSMS(EyouSoft.Model.SMSStructure.SendPlanInfo info)
        {
            EyouSoft.BackgroundServices.SMSSOAP.SMSChannel channel = SmsUtils.GetSmsSendChannel(info.SendChannel.Index);

            EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo    messageInfo = new EyouSoft.BackgroundServices.SMSSOAP.SendMessageInfo();
            EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[] mobiles     = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo[info.Mobiles.Count];
            for (int i = 0; i < info.Mobiles.Count; i++)
            {
                mobiles[i]           = new EyouSoft.BackgroundServices.SMSSOAP.AcceptMobileInfo();
                mobiles[i].Mobile    = info.Mobiles[i].Mobile;
                mobiles[i].IsEncrypt = info.Mobiles[i].IsEncrypt;
            }
            messageInfo.Mobiles      = mobiles;
            messageInfo.CompanyId    = info.CompanyId;
            messageInfo.CompanyName  = info.CompanyName;
            messageInfo.SendChannel  = channel;
            messageInfo.SendTime     = info.SendTime;
            messageInfo.SendType     = EyouSoft.BackgroundServices.SMSSOAP.SendType.直接发送;
            messageInfo.SMSContent   = info.SMSContent;
            messageInfo.SMSType      = info.SMSType;
            messageInfo.UserFullName = info.ContactName;
            messageInfo.UserId       = info.UserId;

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

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

            /*
             * EyouSoft.Model.EnumType.SmsStructure.PlanStatus state = EyouSoft.Model.EnumType.SmsStructure.PlanStatus.未发送;
             * string stateDesc = string.Empty;
             *
             * if (result.IsSucceed)
             * {
             *  state = EyouSoft.Model.EnumType.SmsStructure.PlanStatus.发送成功;
             * }
             * else
             * {
             *  state = EyouSoft.Model.EnumType.SmsStructure.PlanStatus.发送失败;
             *  stateDesc = result.ErrorMessage;
             * }
             *
             * dal.SaveSendResult(info.PlanId, state, stateDesc);*/
        }
Beispiel #2
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
        }