private void HaiMeiSendMessage(SiteSettings settings, string cellphone) { try { string text = HiContext.Current.GenerateRandomNumber(4); ConfigData configData = new ConfigData(HiCryptographer.Decrypt(settings.SMSSettings)); SMSSender sMSSender = SMSSender.CreateInstance(settings.SMSSender, configData.SettingsXml); string text2 = string.Format(@"您好!您正在进行海美生活会员修改密码,本次的验证码为:{0},请勿向任何人提供您收到的短信验证码,并尽快完成验证。", text); string text3; bool flag = sMSSender.Send(cellphone, text2, out text3); if (flag) { //HiCache.Insert(HiContext.Current.User.UserId + "cellphone", text, 10800); EcShop.Entities.Members.Verify verfyinfo = new Entities.Members.Verify(); verfyinfo.VerifyCode = text; verfyinfo.CellPhone = cellphone.Trim(); EcShop.ControlPanel.Members.TelVerifyHelper.CreateVerify(verfyinfo); } this.message = "{\"success\":true,\"msg\":\"" + text3 + "\"}"; } catch (System.Exception) { this.message = "{\"success\":false,\"msg\":\"未知错误\"}"; } }
private ConfigData LoadConfig(out string selectedName) { selectedName = base.Request.Form["ddlSms"]; this.txtSelectedName.Value = selectedName; this.txtConfigData.Value = ""; ConfigData result; if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0) { result = null; } else { ConfigablePlugin plugin = SMSSender.CreateInstance(selectedName); if (plugin == null) { result = null; } else { ConfigData configData = plugin.GetConfigData(base.Request.Form); if (configData != null) { this.txtConfigData.Value = configData.SettingsXml; } result = configData; } } return(result); }
private ConfigData LoadConfig(out string selectedName) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); selectedName = masterSettings.SMSSender; //selectedName = base.Request.Form["ddlSms"]; this.txtSelectedName.Value = selectedName; this.txtConfigData.Value = ""; if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0) { return(null); } ConfigablePlugin configablePlugin = SMSSender.CreateInstance(selectedName); if (configablePlugin == null) { return(null); } ConfigData configData = configablePlugin.GetConfigData(base.Request.Form); if (configData != null) { this.txtConfigData.Value = configData.SettingsXml; } return(configData); }
private void btnTestSend_Click(object sender, EventArgs e) { string str; ConfigData data = LoadConfig(out str); if (string.IsNullOrEmpty(str) || (data == null)) { ShowMsg("请先选择发送方式并填写配置信息", false); } else if (!data.IsValid) { string msg = ""; foreach (string str3 in data.ErrorMsgs) { msg = msg + Formatter.FormatErrorMessage(str3); } ShowMsg(msg, false); } else if ((string.IsNullOrEmpty(txtTestCellPhone.Text) || string.IsNullOrEmpty(txtTestSubject.Text)) || ((txtTestCellPhone.Text.Trim().Length == 0) || (txtTestSubject.Text.Trim().Length == 0))) { ShowMsg("接收手机号和发送内容不能为空", false); } else if (!Regex.IsMatch(txtTestCellPhone.Text.Trim(), @"^(13|15)\d{9}$")) { ShowMsg("请填写正确的手机号码", false); } else { string str4; bool success = SMSSender.CreateInstance(str, data.SettingsXml).Send(txtTestCellPhone.Text.Trim(), txtTestSubject.Text.Trim(), out str4); ShowMsg(str4, success); } }
private ConfigData LoadConfig(out string selectedName) { selectedName = base.Request.Form["ddlSms"]; this.txtSelectedName.Value = selectedName; this.txtConfigData.Value = ""; if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0) { return(null); } ConfigablePlugin configablePlugin = SMSSender.CreateInstance(selectedName); if (configablePlugin == null) { return(null); } ConfigData configData = configablePlugin.GetConfigData(base.Request.Form); if (configData != null) { this.txtConfigData.Value = configData.SettingsXml; } Globals.AppendLog(new Dictionary <string, string>(), "SMSSettings-LoadConfig:" + selectedName + "," + configData.ToString(), "", "", "/log/SMSSettings.txt"); return(configData); }
internal static SMSSender CreateSMSSender(SiteSettings settings, out string msg) { try { msg = ""; if (!settings.SMSEnabled) { return(null); } return(SMSSender.CreateInstance(settings.SMSSender, HiCryptographer.Decrypt(settings.SMSSettings))); } catch (Exception exception) { msg = exception.Message; return(null); } }
private ConfigData LoadConfig(out string selectedName) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); selectedName = masterSettings.SMSSender; if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0) { return(null); } ConfigablePlugin configablePlugin = SMSSender.CreateInstance(selectedName); if (configablePlugin == null) { return(null); } ConfigData configData = configablePlugin.GetConfigData(base.Request.Form); return(configData); }
private void btnTestSend_Click(object sender, System.EventArgs e) { string str; ConfigData data = this.LoadConfig(out str); if (string.IsNullOrEmpty(str) || data == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); } else { if (!data.IsValid) { string msg = ""; foreach (string str2 in data.ErrorMsgs) { msg += Formatter.FormatErrorMessage(str2); } this.ShowMsg(msg, false); } else { if (string.IsNullOrEmpty(this.txtTestCellPhone.Text) || string.IsNullOrEmpty(this.txtTestSubject.Text) || this.txtTestCellPhone.Text.Trim().Length == 0 || this.txtTestSubject.Text.Trim().Length == 0) { this.ShowMsg("接收手机号和发送内容不能为空", false); } else { if (!Regex.IsMatch(this.txtTestCellPhone.Text.Trim(), "^(13|14|15|18)\\d{9}$")) { this.ShowMsg("请填写正确的手机号码", false); } else { string str3; bool success = SMSSender.CreateInstance(str, data.SettingsXml).Send(this.txtTestCellPhone.Text.Trim(), this.txtTestSubject.Text.Trim(), out str3); this.ShowMsg(str3, success); } } } } }
private ConfigData LoadConfig(out string selectedName) { selectedName = base.Request.Form["ddlSms"]; this.txtSelectedName.Value = selectedName; this.txtConfigData.Value = ""; if (string.IsNullOrEmpty(selectedName) || selectedName.Length == 0) { return(null); } if (SMSSender.CreateInstance(selectedName) == null) { return(null); } this.txtConfigData.Value = string.Format("<xml><Appkey>{0}</Appkey><Appsecret>{1}</Appsecret></xml>", this.txtAppkey.Text.Trim(), this.txtAppsecret.Text.Trim()); ConfigData configData = new ConfigData(this.txtConfigData.Value); if (configData != null) { this.txtConfigData.Value = configData.SettingsXml; } return(configData); }
private void btnTestSend_Click(object sender, EventArgs e) { string text = default(string); ConfigData configData = this.LoadConfig(out text); string templateCode = this.txtTestSMSTemplateCode.Text.Trim();//短信模板编码 if (string.IsNullOrEmpty(text) || configData == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); } else if (!configData.IsValid) { string text2 = ""; foreach (string errorMsg in configData.ErrorMsgs) { text2 += Formatter.FormatErrorMessage(errorMsg); } this.ShowMsg(text2, false); } else if (string.IsNullOrEmpty(this.txtTestCellPhone.Text) || string.IsNullOrEmpty(this.txtTestSubject.Text) || this.txtTestCellPhone.Text.Trim().Length == 0 || this.txtTestSubject.Text.Trim().Length == 0) { this.ShowMsg("接收手机号和发送内容不能为空", false); } else if (!Regex.IsMatch(this.txtTestCellPhone.Text.Trim(), "^(13|14|15|18)\\d{9}$")) { this.ShowMsg("请填写正确的手机号码", false); } else if (string.IsNullOrEmpty(templateCode) || templateCode.Trim().Length == 0) { this.ShowMsg("请填写正确的模板code", false); } else { SMSSender sMSSender = SMSSender.CreateInstance(text, configData.SettingsXml); string msg = default(string); bool success = sMSSender.Send(this.txtTestCellPhone.Text.Trim(), templateCode, this.txtTestSubject.Text.Trim(), out msg); this.ShowMsg(msg, success); } }
internal static SMSSender CreateSMSSender(SiteSettings settings, out string string_0) { SMSSender result; try { string_0 = ""; if (!settings.SMSEnabled) { result = null; } else { result = SMSSender.CreateInstance(settings.SMSSender, HiCryptographer.Decrypt(settings.SMSSettings)); } } catch (System.Exception ex) { string_0 = ex.Message; result = null; } return(result); }
private void btnTestSend_Click(object sender, System.EventArgs e) { string text; ConfigData configData = this.LoadConfig(out text); if (string.IsNullOrEmpty(text) || configData == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); return; } if (!configData.IsValid) { string text2 = ""; foreach (string current in configData.ErrorMsgs) { text2 += Formatter.FormatErrorMessage(current); } this.ShowMsg(text2, false); return; } if (string.IsNullOrEmpty(this.txtTestCellPhone.Text) || string.IsNullOrEmpty(this.txtTestSubject.Text) || this.txtTestCellPhone.Text.Trim().Length == 0 || this.txtTestSubject.Text.Trim().Length == 0) { this.ShowMsg("接收手机号和发送内容不能为空", false); return; } if (!System.Text.RegularExpressions.Regex.IsMatch(this.txtTestCellPhone.Text.Trim(), "^(13|14|15|18)\\d{9}$")) { this.ShowMsg("请填写正确的手机号码", false); return; } SMSSender sMSSender = SMSSender.CreateInstance(text, configData.SettingsXml); string msg; bool success = sMSSender.Send(this.txtTestCellPhone.Text.Trim(), this.txtTestSubject.Text.Trim(), out msg); this.ShowMsg(msg, success); }
private void btnSendMessage_Click(object sender, EventArgs e) { SiteSettings siteSetting = this.GetSiteSetting(); string sMSSender = siteSetting.SMSSender; if (string.IsNullOrEmpty(sMSSender)) { this.ShowMsg("请先选择发送方式", false); } else { ConfigData data = null; if (siteSetting.SMSEnabled) { data = new ConfigData(HiCryptographer.Decrypt(siteSetting.SMSSettings)); } if (data == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); } else if (!data.IsValid) { string msg = ""; foreach (string str3 in data.ErrorMsgs) { msg = msg + Formatter.FormatErrorMessage(str3); } this.ShowMsg(msg, false); } else { string str4 = this.txtmsgcontent.Value.Trim(); if (string.IsNullOrEmpty(str4)) { this.ShowMsg("请先填写发送的内容信息", false); } else { int smsValidCount = this.GetSmsValidCount(); string str5 = null; foreach (GridViewRow row in this.grdMemberList.Rows) { CheckBox box = (CheckBox)row.FindControl("checkboxCol"); if (box.Checked) { string str6 = ((DataBoundLiteralControl)row.Controls[4].Controls[0]).Text.Trim().Replace("<div></div>", "").Replace(" ", ""); HiddenField field = (HiddenField)row.FindControl("hidCellPhone"); str6 = field.Value; if (!string.IsNullOrEmpty(str6) && Regex.IsMatch(str6, @"^(13|14|15|18)\d{9}$")) { str5 = str5 + str6 + ","; } } } if (str5 == null) { this.ShowMsg("请先选择要发送的会员或检测所选手机号格式是否正确", false); } else { str5 = str5.Substring(0, str5.Length - 1); string[] phoneNumbers = null; if (str5.Contains(",")) { phoneNumbers = str5.Split(new char[] { ',' }); } else { phoneNumbers = new string[] { str5 }; } if (smsValidCount < phoneNumbers.Length) { this.ShowMsg("发送失败,您的剩余短信条数不足。可用条数:" + smsValidCount.ToString(), false); } else { string str7; bool success = SMSSender.CreateInstance(sMSSender, data.SettingsXml).Send(phoneNumbers, str4, out str7); this.ShowMsg(str7, success); this.ValidSmsNum = this.GetSmsValidCount().ToString(); } } } } } }
private void btnSendMessage_Click(object sender, System.EventArgs e) { SiteSettings siteSetting = this.GetSiteSetting(); string sMSSender = siteSetting.SMSSender; if (string.IsNullOrEmpty(sMSSender)) { this.ShowMsg("请先选择发送方式", false); } else { ConfigData data = null; if (siteSetting.SMSEnabled) { data = new ConfigData(HiCryptographer.Decrypt(siteSetting.SMSSettings)); } if (data == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); } else { if (!data.IsValid) { string msg = ""; foreach (string str3 in data.ErrorMsgs) { msg += Formatter.FormatErrorMessage(str3); } this.ShowMsg(msg, false); } else { string str4 = this.txtmsgcontent.Value.Trim(); if (string.IsNullOrEmpty(str4)) { this.ShowMsg("请先填写发送的内容信息", false); } else { int num = System.Convert.ToInt32(this.litsmscount.Text); string str5 = null; foreach (System.Web.UI.WebControls.GridViewRow row in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox box = (System.Web.UI.WebControls.CheckBox)row.FindControl("checkboxCol"); if (box.Checked) { string str6 = ((System.Web.UI.DataBoundLiteralControl)row.Controls[3].Controls[0]).Text.Trim().Replace("<div></div>", ""); if (!string.IsNullOrEmpty(str6)) { str6 = str6.Replace(" ", ""); if (Regex.IsMatch(str6, "^1[3458]\\d{9}$")) { str5 = str5 + str6 + ","; } } } } if (str5 == null) { this.ShowMsg("请先选择要发送的会员或检测所选手机号格式是否正确", false); } else { str5 = str5.Substring(0, str5.Length - 1); string[] phoneNumbers; if (str5.Contains(",")) { phoneNumbers = str5.Split(new char[] { ',' }); } else { phoneNumbers = new string[] { str5 }; } if (num < phoneNumbers.Length) { this.ShowMsg("发送失败,您的剩余短信条数不足", false); } else { string str7; bool success = SMSSender.CreateInstance(sMSSender, data.SettingsXml).Send(phoneNumbers, str4, out str7); this.ShowMsg(str7, success); this.txtmsgcontent.Value = "输入发送内容……"; this.litsmscount.Text = (num - phoneNumbers.Length).ToString(); } } } } } } }
private void btnSendMessage_Click(object sender, System.EventArgs e) { SiteSettings siteSetting = this.GetSiteSetting(); string sMSSender = siteSetting.SMSSender; if (string.IsNullOrEmpty(sMSSender)) { this.ShowMsg("请先选择发送方式", false); return; } ConfigData configData = null; if (siteSetting.SMSEnabled) { configData = new ConfigData(HiCryptographer.Decrypt(siteSetting.SMSSettings)); } if (configData == null) { this.ShowMsg("请先选择发送方式并填写配置信息", false); return; } if (!configData.IsValid) { string text = ""; foreach (string current in configData.ErrorMsgs) { text += Formatter.FormatErrorMessage(current); } this.ShowMsg(text, false); return; } string text2 = this.txtmsgcontent.Value.Trim(); if (string.IsNullOrEmpty(text2)) { this.ShowMsg("请先填写发送的内容信息", false); return; } int num = System.Convert.ToInt32(this.litsmscount.Text); string text3 = null; foreach (System.Web.UI.WebControls.GridViewRow gridViewRow in this.grdMemberList.Rows) { System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)gridViewRow.FindControl("checkboxCol"); if (checkBox.Checked) { string text4 = ((System.Web.UI.DataBoundLiteralControl)gridViewRow.Controls[2].Controls[0]).Text.Trim().Replace("<div></div>", ""); if (!string.IsNullOrEmpty(text4) && System.Text.RegularExpressions.Regex.IsMatch(text4, "^(13|14|15|17|18)\\d{9}$")) { text3 = text3 + text4 + ","; } } } if (text3 == null) { this.ShowMsg("请先选择要发送的会员或检测所选手机号格式是否正确", false); return; } text3 = text3.Substring(0, text3.Length - 1); string[] array; if (text3.Contains(",")) { array = text3.Split(new char[] { ',' }); } else { array = new string[] { text3 }; } if (num < array.Length) { this.ShowMsg("发送失败,您的剩余短信条数不足", false); return; } SMSSender sMSSender2 = SMSSender.CreateInstance(sMSSender, configData.SettingsXml); string msg; bool success = sMSSender2.Send(array, text2, out msg); this.ShowMsg(msg, success); this.txtmsgcontent.Value = "输入发送内容……"; this.litsmscount.Text = (num - array.Length).ToString(); }
public IHttpActionResult SendSMSCode(JObject request) { Logger.WriterLogger("Account.SendSMSCode, Params: " + request.ToString(), LoggerType.Info); ParamSendSMSCode param = new ParamSendSMSCode(); try { param = request.ToObject <ParamSendSMSCode>(); } catch { return(base.JsonFaultResult(new CommonException(40100).GetMessage(), request.ToString())); } string accessToken = param.accessToken; string sessionKey = ""; string sessionSecret = ""; // 验证令牌 int accessTookenCode = VerifyAccessToken(accessToken, out sessionKey, out sessionSecret); if (accessTookenCode > 0) { return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), request.ToString())); } string mobile = param.Mobile; int cType = param.CType; if (string.IsNullOrEmpty(mobile)) { return(base.JsonFaultResult(new FaultInfo(40100, "手机号码为空"), request.ToString())); } if (!System.Text.RegularExpressions.Regex.IsMatch(mobile, "^(13|14|15|17|18)\\d{9}$")) { return(base.JsonFaultResult(new FaultInfo(40100, "请输入正确的手机号码"), request.ToString())); } if (cType == 1 && UserHelper.IsExistCellPhoneAndUserName(mobile) > 0) { return(base.JsonFaultResult(new FaultInfo(40100, "已经存在相同的手机号码"), request.ToString())); } int channel = param.channel; int platform = param.platform; string ver = param.ver; // 保存访问信息 base.SaveVisitInfo("", channel, platform, ver); SiteSettings settings = HiContext.Current.SiteSettings; if (!settings.SMSEnabled || string.IsNullOrEmpty(settings.SMSSettings)) { return(base.JsonFaultResult(new FaultInfo(40999, "手机服务未配置"), request.ToString())); } //生成随机短信验证码 string verifyCode = HiContext.Current.GenerateRandomNumber(4); ConfigData configData = new ConfigData(HiCryptographer.Decrypt(settings.SMSSettings)); SMSSender sMSSender = SMSSender.CreateInstance(settings.SMSSender, configData.SettingsXml); string smsContent = string.Format(SMS_FORART, verifyCode); string msg; bool flag = sMSSender.Send(mobile, smsContent, out msg); if (flag) { // 保存到数据库 Verify verfyinfo = new Verify(); verfyinfo.VerifyCode = verifyCode; verfyinfo.CellPhone = mobile; verfyinfo.CType = cType; TelVerifyHelper.CreateVerify(verfyinfo); Verify verifyto = new TelVerifyDao().GetVerify(mobile); if (verifyto != null && verifyto.CType == cType && verifyto.VerifyCode == verifyCode) { StandardResult <string> okResult = new StandardResult <string>(); okResult.code = 0; okResult.msg = "成功返回短信验证码"; okResult.data = base.Encrypt(verifyCode, sessionKey, sessionSecret); return(base.JsonActionResult(okResult)); } return(base.JsonFaultResult(new CommonException(40205).GetMessage(), request.ToString())); } return(base.JsonFaultResult(new CommonException(40999).GetMessage(), request.ToString())); }
private void SendSMS(HttpContext context) { string parameter = base.GetParameter(context, "content", true); string parameter2 = base.GetParameter(context, "ids", true); string TemplateCode = ""; if (string.IsNullOrWhiteSpace(parameter2)) { throw new HidistroAshxException("请先选择要删除的会员账号"); } if (string.IsNullOrEmpty(parameter)) { throw new HidistroAshxException("请先填写发送的内容信息"); } string sMSSender = base.CurrentSiteSetting.SMSSender; if (string.IsNullOrEmpty(sMSSender)) { throw new HidistroAshxException("请先选择发送方式"); } ConfigData configData = null; if (base.CurrentSiteSetting.SMSEnabled) { configData = new ConfigData(HiCryptographer.TryDecypt(base.CurrentSiteSetting.SMSSettings)); } if (configData == null) { throw new HidistroAshxException("请先选择发送方式并填写配置信息"); } if (!configData.IsValid) { string text = ""; foreach (string errorMsg in configData.ErrorMsgs) { text += Formatter.FormatErrorMessage(errorMsg); } throw new HidistroAshxException(text); } int amount = this.GetAmount(base.CurrentSiteSetting); int[] array = (from d in parameter2.Split(',') where !string.IsNullOrWhiteSpace(d) select int.Parse(d)).ToArray(); parameter2 = string.Join(",", array); int num = array.Count(); int num2 = 0; string text2 = null; IEnumerable <MemberInfo> membersById = MemberHelper.GetMembersById(parameter2); foreach (MemberInfo item in membersById) { string cellPhone = item.CellPhone; if (!string.IsNullOrEmpty(cellPhone) && Regex.IsMatch(cellPhone, "^(13|14|15|18|17)\\d{9}$")) { text2 = text2 + cellPhone + ","; } } if (string.IsNullOrWhiteSpace(text2)) { throw new HidistroAshxException("请先选择要发送的会员或检测所选手机号格式是否正确"); } text2 = text2.Substring(0, text2.Length - 1); string[] array2 = null; array2 = ((!text2.Contains(",")) ? new string[1] { text2 } : text2.Split(',')); if (amount < array2.Length) { throw new HidistroAshxException("发送失败,您的剩余短信条数不足"); } SMSSender sMSSender2 = SMSSender.CreateInstance(sMSSender, configData.SettingsXml); string message = default(string); if (sMSSender2.Send(array2, TemplateCode, parameter, out message)) { base.ReturnSuccessResult(context, (amount - array2.Length).ToString(), 0, true); return; } throw new HidistroAshxException(message); }