85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using System;
|
|
using System.Text;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.CRMServices.SMS.InterfaceModel;
|
|
|
|
namespace WX.CRM.CRMServices.SMS.InterfaceExec
|
|
{
|
|
internal class EntSms : IMsgSend
|
|
{
|
|
string account = "";
|
|
string pwd = "";
|
|
string url = "";
|
|
public EntSms(string _account = "", string _password = "")
|
|
{
|
|
EntSmsConfig config = new EntSmsConfig();
|
|
account = config.account;
|
|
pwd = config.pwd;
|
|
url = config.url;
|
|
if (!string.IsNullOrEmpty(_account) && !string.IsNullOrEmpty(_password))
|
|
{
|
|
pwd = _password;
|
|
account = _account;
|
|
}
|
|
}
|
|
public InterfaceModel.ReturnResult Execute(string[] mobiles, string msg)
|
|
{
|
|
return Send(mobiles, msg);
|
|
}
|
|
|
|
public decimal queryAmt()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
InterfaceModel.ReturnResult Send(string[] mobiles, string msg)
|
|
{
|
|
var mobilesStr = string.Join(",", mobiles);
|
|
var result = new InterfaceModel.ReturnResult
|
|
{
|
|
SendStr = mobilesStr
|
|
};
|
|
try
|
|
{
|
|
var tm = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
var pw = Utility.UserMd5(pwd + tm);
|
|
|
|
var para = "uid=" + account + "&pw=" + pw + "&mb=" + mobilesStr + "&ms=" + msg + "tm=" + tm;
|
|
|
|
LogHelper.Info("para:" + para);
|
|
|
|
var rsp = Utility.PostData(url, para, Encoding.UTF8);
|
|
|
|
LogHelper.Info("短信接口返回结果:" + rsp);
|
|
|
|
var arr = rsp.Split(',');
|
|
|
|
if (!string.IsNullOrEmpty(arr[0]))
|
|
{
|
|
var a = int.Parse(arr[0]);
|
|
if (a >= 0)
|
|
{
|
|
result.submitStatus = SubmitStatus.success;
|
|
}
|
|
else
|
|
{
|
|
result.submitStatus = SubmitStatus.fail;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result.submitStatus = SubmitStatus.fail;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.submitStatus = SubmitStatus.fail;
|
|
WX.CRM.Common.LogHelper.Error("EntSms.Send:" + ex.Message + ex.StackTrace);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
}
|
|
}
|