protected void SendSMSMethod(int typeID) { #region 获取表单数据 //单条短信价格 //SMSDecimal = EyouSoft.Common.ConfigModel.ConfigClass.GetConfigDecimal("SMS_COSTOFSINGLE"); EyouSoft.IBLL.SMSStructure.ISendMessage sBll = EyouSoft.BLL.SMSStructure.SendMessage.CreateInstance(); string returnVal = ""; //bool flag = false; List <EyouSoft.Model.SMSStructure.AcceptMobileInfo> list = new List <EyouSoft.Model.SMSStructure.AcceptMobileInfo>(); string strErr = ""; decimal teleNum = 0;//号码数量 string erroNumber = ""; string sendCustomer = ""; if (!string.IsNullOrEmpty(Utils.GetFormValue(this.txt_SendPeople.UniqueID).Trim()) && ShowSender.Checked) { sendCustomer = Utils.GetFormValue(this.txt_SendPeople.UniqueID).Trim(); } string tmpPhoneNo = Utils.GetFormValue(this.txt_TelePhoneGroup.UniqueID).Trim(); string tmpSendInfo = ""; if (!string.IsNullOrEmpty(Utils.GetFormValue(this.txt_SendContent.UniqueID).Trim())) { tmpSendInfo = Utils.GetFormValue(this.txt_SendContent.UniqueID).Trim(); } DateTime sendTime = DateTime.Now; if (!string.IsNullOrEmpty(Utils.GetFormValue("txt_SendSMS_OrderTime")) && StringValidate.IsDateTime(Utils.GetFormValue("txt_SendSMS_OrderTime"))) { sendTime = DateTime.Parse(Utils.GetFormValue("txt_SendSMS_OrderTime")); } //发送类型 EyouSoft.Model.SMSStructure.SendType sendType = (EyouSoft.Model.SMSStructure.SendType)Utils.GetInt(Utils.GetFormValue(this.ddl_SendType.UniqueID)); //发送通道 EyouSoft.Model.SMSStructure.SMSChannel sendChannel = new EyouSoft.Model.SMSStructure.SMSChannelList()[Utils.GetInt(Utils.GetFormValue(this.ddlSendChannel.UniqueID))]; //加密手机号码 string strEncryMobile = Utils.GetFormValue("EncryMobile"); //有关发送所有的数据 //isSend: false, dataSource:2, companyName:"",customerType:0, provinceId:0, cityId:0 bool sendAll_isSend = Convert.ToBoolean(Utils.GetFormValue("isSendAll")); EyouSoft.Model.SMSStructure.CustomerInfo.CustomerSource sendAll_dataSource = EyouSoft.Model.SMSStructure.CustomerInfo.CustomerSource.平台组团社客户; string sendAll_companyName = ""; int sendAll_customerType = 0; int sendAll_provinceId = 0; int sendAll_cityId = 0; if (sendAll_isSend) { sendAll_dataSource = (EyouSoft.Model.SMSStructure.CustomerInfo.CustomerSource)Convert.ToInt32(Utils.GetFormValue("sendAll.dataSource")); sendAll_customerType = Convert.ToInt32(Utils.GetFormValue("sendAll.customerType")); sendAll_companyName = Utils.GetFormValue("sendAll.companyName"); sendAll_provinceId = Convert.ToInt32(Utils.GetFormValue("sendAll.provinceId")); sendAll_cityId = Convert.ToInt32(Utils.GetFormValue("sendAll.cityId")); } #endregion #region 数据验证 if (string.IsNullOrEmpty(tmpSendInfo)) { strErr += "请输入或导入发送内容!" + "\n"; } //验证手机号码 if (!string.IsNullOrEmpty(tmpPhoneNo)) { tmpPhoneNo = tmpPhoneNo.Replace(',', ','); if (tmpPhoneNo.EndsWith(",")) { tmpPhoneNo = tmpPhoneNo.Substring(0, tmpPhoneNo.Length - 1); } string[] numberGroup = tmpPhoneNo.Split(','); teleNum = numberGroup.Length; for (int i = 0; i < teleNum; i++) { if (StringValidate.IsMobileOrPHS(numberGroup[i]) == false) { erroNumber += numberGroup[i] + "\n"; } else { list.Add(new EyouSoft.Model.SMSStructure.AcceptMobileInfo() { Mobile = numberGroup[i], IsEncrypt = false }); } } } //添加加密手机号码 if (!string.IsNullOrEmpty(strEncryMobile)) { string[] numberGroup = strEncryMobile.Split(','); teleNum = numberGroup.Length; for (int i = 0; i < teleNum; i++) { if (StringValidate.IsMobileOrPHS(numberGroup[i]) == false) { erroNumber += numberGroup[i] + "\n"; } else { list.Add(new EyouSoft.Model.SMSStructure.AcceptMobileInfo() { Mobile = numberGroup[i], IsEncrypt = true }); } } } //添加发送所有的号码 if (sendAll_isSend) { IList <EyouSoft.Model.SMSStructure.AcceptMobileInfo> sendAll_list = EyouSoft.BLL.SMSStructure.Customer.CreateInstance().GetMobiles(CompanyID, "", sendAll_customerType, sendAll_dataSource, sendAll_provinceId, sendAll_cityId); if (sendAll_list != null && sendAll_list.Count > 0) { list.AddRange(sendAll_list); } } if (list == null || list.Count <= 0) { strErr += "请输入或导入手机号码!" + "\n"; } if (erroNumber != "") { strErr += erroNumber + "以上号码格式不正确!" + "\n"; } #endregion if (strErr != "") { returnVal = "0@" + strErr; } else { if (typeID == 0) { #region 发送短信之前确认发送信息 EyouSoft.Model.SMSStructure.SendMessageInfo SMS_Model = new EyouSoft.Model.SMSStructure.SendMessageInfo(); SMS_Model.Mobiles = list; SMS_Model.CompanyId = CompanyID; SMS_Model.SMSContent = tmpSendInfo; SMS_Model.UserFullName = sendCustomer; SMS_Model.SendChannel = sendChannel; SMS_Model.SendType = sendType; SMS_Model.SendTime = sendTime; EyouSoft.Model.SMSStructure.SendResultInfo sModel = sBll.ValidateSend(SMS_Model); if (sModel != null) { if (sModel.IsSucceed == true) { //验证成功返回帐户余额以及此次所要发送的短信条数 returnVal = string.Format("1@您的账户当前余额为:{0},此次消费金额为:{1},将共发送短信{2}条!是否确定发送短信?" , sModel.AccountMoney.ToString("C2") , sModel.CountFee.ToString("C2") , (sModel.WaitSendMobileCount + sModel.WaitSendPHSCount).ToString()); } else if (sModel.ErrorMessage.IndexOf("余额不足") > -1) { returnVal = "2@" + sModel.ErrorMessage; } else { returnVal = "0@" + sModel.ErrorMessage; } } sModel = null; SMS_Model = null; #endregion } else { #region 发送操作 EyouSoft.Model.SMSStructure.SendMessageInfo sendMessageInfo = new EyouSoft.Model.SMSStructure.SendMessageInfo(); sendMessageInfo.CompanyId = CompanyID; sendMessageInfo.CompanyName = this.SiteUserInfo.CompanyName; sendMessageInfo.UserId = this.SiteUserInfo.ID; sendMessageInfo.UserFullName = sendCustomer; sendMessageInfo.SMSContent = tmpSendInfo; sendMessageInfo.SendTime = sendTime; sendMessageInfo.Mobiles = list; sendMessageInfo.SendChannel = sendChannel; sendMessageInfo.SendType = sendType; EyouSoft.Model.SMSStructure.SendResultInfo SendResultModel = sBll.Send(sendMessageInfo); if (SendResultModel.IsSucceed) { string isHasSendUser = ""; if (!string.IsNullOrEmpty(sendMessageInfo.UserFullName)) { isHasSendUser = "******"; } decimal costFee = sendMessageInfo.SendType == EyouSoft.Model.SMSStructure.SendType.直接发送 ? SendResultModel.SendFee : SendResultModel.CountFee; returnVal = "1@您本次共发送短信" + sendMessageInfo.SMSContentSendComplete.Length + "个字" + isHasSendUser + "!\n发送移动、联通共" + SendResultModel.MobileSendNumberCount + "个号码、\n发送小灵通共" + SendResultModel.PHSSendNumberCount + "个号码、\n实际共消费金额为:" + costFee.ToString("C2") + "、\n实际发送短信" + (SendResultModel.MobileSendCount + SendResultModel.PHSSendCount) + "条"; } else if (SendResultModel.ErrorMessage.IndexOf("余额不足") > -1) { returnVal = "2@" + SendResultModel.ErrorMessage; } else { returnVal = "0@" + SendResultModel.ErrorMessage; } SendResultModel = null; sendMessageInfo = null; #endregion } } Response.Clear(); Response.Write(returnVal); Response.End(); sBll = null; }