ComplianceServer/oldcode/CRMServices/PkgSms/SendBatchMsg.cs

77 lines
4.0 KiB
C#

using System;
using System.Linq;
using WX.CRM.CRMServices.SMS.DataDrive;
using WX.CRM.CRMServices.SMS.InterfaceModel;
namespace WX.CRM.CRMServices.SMS
{
public class SendBatchMsg
{
public void Send()
{
try
{
do
{
//InterfaceModel.Sms360Config sms360 = new InterfaceModel.Sms360Config();
//InterfaceModel.RuiXinConfig YX = new InterfaceModel.RuiXinConfig();
//InterfaceModel.HuiZhiConfig hj = new InterfaceModel.HuiZhiConfig();
//InterfaceModel.EntSmsConfig ent = new InterfaceModel.EntSmsConfig();
//InterfaceModel.QiXinTongConfig qx = new InterfaceModel.QiXinTongConfig();
//PkgSms.InterfaceModel.upCatConfig cat = new PkgSms.InterfaceModel.upCatConfig();
//Common.LogHelper.Info(Common.Utility.ObjectToJson<InterfaceModel.Sms360Config>(sms360));
//Common.LogHelper.Info(Common.Utility.ObjectToJson<InterfaceModel.RuiXinConfig>(YX));
//Common.LogHelper.Info(Common.Utility.ObjectToJson<InterfaceModel.HuiZhiConfig>(hj));
//Common.LogHelper.Info(Common.Utility.ObjectToJson<InterfaceModel.EntSmsConfig>(ent));
//Common.LogHelper.Info(Common.Utility.ObjectToJson<InterfaceModel.QiXinTongConfig>(qx));
//Common.LogHelper.Info(Common.Utility.ObjectToJson<PkgSms.InterfaceModel.upCatConfig>(cat));
SendSMS();
} while (BatchMsg.NumberCount > 0);
}
catch (Exception ex)
{
WX.CRM.Common.LogHelper.Error("WX.CRM.CRMServices.SMS.SendBatchMsg.Send:" + ex.Message + ex.StackTrace);
}
}
void SendSMS()
{
try
{
//Common.LogHelper.Error("【批量短信发送开始】:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
BatchMsgSendModel info = BatchMsg.GetInfo();
if (info == null || info.mobiles == null || info.mobiles.Count() == 0)
{
//Common.LogHelper.Error("【批量短信为空】:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
BatchMsg.ClearBatch();
return;
}
//Common.LogHelper.Error("【批量短信提交开始】:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
InterfaceModel.SmsAccountID _id = InterfaceFactory.GetInterfaceIdByCode(info.interfaceCode);
MsgSend sms = new MsgSend(_id, info.interfaceAccount, info.interfacePwd);
InterfaceModel.ReturnResult result = sms.Execute(info.mobiles.ToArray(), info.msgContent);
//Common.LogHelper.Error("【批量短信提交结束日志处理开始】:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
//插入日志
var logInfo = new WX.CRM.Model.Entity.SMS_SENDLOG
{
SENDSTR = result.SendStr.Substring(0, result.SendStr.Length > 1900 ? 1900 : result.SendStr.Length - 1),
CLIENTCODE = info.clientCode,
MSGSOURCEID = info.batchId,
RETURNMSG = result.ReturnStr.Substring(0, result.ReturnStr.Length > 480 ? 480 : result.ReturnStr.Length),
SENDTIME = System.DateTime.Now,
SENDSUCCESS = (short)(result.submitStatus == SubmitStatus.success ? 1 : 0)
};
BatchMsg.ExecLog(info.pkids, logInfo);
//Common.LogHelper.Error("【批量短日志处理结束】:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"));
}
catch (Exception ex)
{
BatchMsg.ClearBatch();
WX.CRM.Common.LogHelper.Error("WX.CRM.CRMServices.SMS.SendBatchMsg:" + ex.Message + ex.StackTrace);
}
}
}
}