private void WriteResponse(string result, string msgid) { SendSMSResult ret = new SendSMSResult(); ret.Result = result; ret.MsgID = msgid; string data = JsonSerialize.Serialize <SendSMSResult>(ret); Response.Write(data); Response.End(); }
public ActionResult SendSMS(string User, string Pass, string Mobiles, string Content, string SendTime) { SendSMSResult ret = new SendSMSResult(); // 判断参数合法性 if (string.IsNullOrWhiteSpace(User)) { ret.Result = _ERR_USERISEMPTY; } else if (string.IsNullOrWhiteSpace(Pass)) { ret.Result = _ERR_PASSISEMPTY; } else if (string.IsNullOrWhiteSpace(Mobiles)) { ret.Result = _ERR_DESTISEMPTY; } else { // 发送短信 try { var r = InterfaceProxy.GetSendService().SendSMS(User, Pass, Content, Mobiles.Split(',').ToList(), "http"); if (r.Success) { ret.Result = _ERR_SUCCESS; ret.MsgID = r.Value.Message.ID; if (r.Value.Message.AuditType == SMS.Model.AuditType.Manual) { Util.SendToDoToSMSAuditor(r.Value.Message); } } else { ret.Result = r.Message; } } catch (Exception ex) { ret.Result = _ERR_SERVICE; } } string data = JsonSerialize.Serialize <SendSMSResult>(ret); return(base.Content(data)); }
public string SendSMS(string UserName, string UserPass, string Destination, string SMContent) { string[] dest; if (UserName == "") { return(_ERR_USERISEMPTY); } if (UserPass == "") { return(_ERR_PASSISEMPTY); } if (Destination == "") { return(_ERR_DESTISEMPTY); } else { dest = Regex.Split(Destination, ","); if (dest.Count() > 100) { return(_ERR_DESTTOLONG); } } ISMS interface_sms = (ISMS)Activator.GetObject(typeof(ISMS), ConfigurationManager.AppSettings["Pretreatment"]); SMS model_sms = new SMS(); // 是否审核 model_sms.Audit = AuditType.Manual; // 是否过滤 model_sms.Filter = FilterType.Failure; // 消息级别 model_sms.Level = LevelType.Level0; // 用户名 model_sms.Account = UserName; // 短信内容 model_sms.Content = SMContent; model_sms.SPNumber = ""; // 接收短信的号码 List <string> num = new List <string>(); foreach (string destnum in dest) { num.Add(destnum); } model_sms.Number = num; model_sms.SendTime = DateTime.Now; model_sms.SerialNumber = Guid.NewGuid(); // 是否需要短信报告 model_sms.StatusReport = StatusReportType.Enabled; // 通道类型 model_sms.Channel = ChannelType.Industry; // 发送短信 RPCResult <Guid> r = interface_sms.SendSMS(model_sms); SendSMSResult ret = new SendSMSResult(); ret.Result = r.Message; ret.MsgId = r.Value.ToString(); string data = JsonSerialize.Serialize <SendSMSResult>(ret); return(data); }
public string SendSMS(string User, string Pass, string Destinations, string Content, string SendTime) { string result = ""; string msgid = ""; string[] dest; if (User == "") { result = _ERR_USERISEMPTY; } else { if (Pass == "") { result = _ERR_PASSISEMPTY; } else { if (Destinations == "") { result = _ERR_DESTISEMPTY; } else { dest = Regex.Split(Destinations, ","); if (dest.Count() > 1000) // 接收短信的终端数量大于1000个 { result = _ERR_DESTTOLONG; } else // 发送短信 { // 接收短信的号码 List <string> num = new List <string>(); foreach (string destnum in dest) { num.Add(destnum); } // 发送短信 try { // 密码加密 //SMS.Model.RPCResult<string> enpass = InterfaceProxy.GetSendService().Encrypt(Pass); var r = InterfaceProxy.GetSendService().SendSMS(User, Pass, Content, num, "webservice"); if (r.Success) { result = _ERR_SUCCESS; msgid = r.Value.SMSNumbers[0].ID.ToString(); if (r.Value.Message.AuditType == SMS.Model.AuditType.Manual) { Util.SendToDoToSMSAuditor(r.Value.Message); } } else { result = r.Message; } } catch (Exception ex) { result = _ERR_SERVICE; } } } } } SendSMSResult ret = new SendSMSResult(); ret.Result = result; ret.MsgID = msgid; string data = JsonSerialize.Serialize <SendSMSResult>(ret); return(data); }