97 lines
3.5 KiB
C#
97 lines
3.5 KiB
C#
using System;
|
|
using System.Collections.Specialized;
|
|
using System.Net;
|
|
using System.Text;
|
|
using WX.CRM.CRMServices.SMS.InterfaceModel;
|
|
|
|
namespace WX.CRM.CRMServices.SMS.InterfaceExec
|
|
{
|
|
internal class Sms360 : IMsgSend
|
|
{
|
|
string Assembly = "";
|
|
string url = "";
|
|
string action = "send";
|
|
string userid = "";
|
|
string account = "";
|
|
string password = "";
|
|
string mobile = "";
|
|
string content = "";
|
|
string sendTime = "";
|
|
string extno = "";
|
|
public Sms360(string _account = "", string _password = "")
|
|
{
|
|
Sms360Config config = new Sms360Config();
|
|
Assembly = config.Assembly;
|
|
url = config.url;
|
|
userid = config.userid;
|
|
account = config.account;
|
|
password = config.password;
|
|
if (!string.IsNullOrEmpty(_account) && !string.IsNullOrEmpty(_password))
|
|
{
|
|
account = _account;
|
|
password = _password;
|
|
}
|
|
}
|
|
|
|
public InterfaceModel.ReturnResult Execute(string[] mobiles, string msg)
|
|
{
|
|
return SendPkg(mobiles, msg);
|
|
}
|
|
|
|
public decimal queryAmt()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
#region
|
|
InterfaceModel.ReturnResult SendPkg(string[] mobiles, string msg)
|
|
{
|
|
InterfaceModel.ReturnResult result = new InterfaceModel.ReturnResult();
|
|
content = msg;
|
|
mobile = string.Join(",", mobiles);
|
|
result.SendStr = mobile;
|
|
try
|
|
{
|
|
#region 发送方式样
|
|
WebClient webClient = new WebClient();
|
|
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
|
NameValueCollection postValues = new NameValueCollection();
|
|
webClient.Encoding = Encoding.UTF8;
|
|
postValues.Add("action", action);
|
|
postValues.Add("userid", userid);
|
|
postValues.Add("account", account);
|
|
postValues.Add("password", password);
|
|
postValues.Add("mobile", mobile);
|
|
postValues.Add("content", content);
|
|
postValues.Add("sendTime", sendTime);
|
|
postValues.Add("extno", extno);
|
|
byte[] responseArray = webClient.UploadValues(url, postValues);
|
|
result.ReturnStr = Encoding.UTF8.GetString(responseArray);
|
|
#endregion
|
|
returnsms re = WX.CRM.Common.Utility.JSONToObject<returnsms>(result.ReturnStr);
|
|
if (re != null)
|
|
result.submitStatus = re.returnstatus.ToUpper() == "SUCCESS" ? SMS.InterfaceModel.SubmitStatus.success : SMS.InterfaceModel.SubmitStatus.fail;
|
|
else
|
|
throw new Exception("反序列化异常,返回值:" + result.ReturnStr);
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.submitStatus = SMS.InterfaceModel.SubmitStatus.fail;
|
|
WX.CRM.Common.LogHelper.Error("Sms360.sendPkg:" + ex.Message + ex.StackTrace);
|
|
}
|
|
return result;
|
|
|
|
}
|
|
public class returnsms
|
|
{
|
|
public string returnstatus { get; set; }
|
|
public string message { get; set; }
|
|
public int remainpoint { get; set; }
|
|
public int taskID { get; set; }
|
|
public int successCounts { get; set; }
|
|
}
|
|
#endregion
|
|
}
|
|
}
|