60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using System;
|
|
using WX.CRM.CRMServices.SMS.DataDrive;
|
|
using WX.CRM.CRMServices.SMS.InterfaceModel;
|
|
|
|
namespace WX.CRM.CRMServices.SMS
|
|
{
|
|
public class SendCrmMsg
|
|
{
|
|
public void Send()
|
|
{
|
|
do
|
|
{
|
|
SendSMS();
|
|
} while (CrmMsg.waitCount > 0);
|
|
}
|
|
|
|
void SendSMS()
|
|
{
|
|
var logInfo = new WX.CRM.Model.Entity.SMS_SENDLOG();
|
|
decimal _messageid = 0;
|
|
try
|
|
{
|
|
CrmMsgSendModel info = CrmMsg.GetInfo();
|
|
if (info == null)
|
|
{
|
|
CrmMsg.ClearWait();
|
|
return;
|
|
}
|
|
_messageid = info.messageid;
|
|
string[] mbs = { info.mobile };
|
|
|
|
InterfaceModel.SmsAccountID _id = InterfaceFactory.GetInterfaceIdByCode(info.interfaceCode);
|
|
MsgSend sms = new MsgSend(_id, info.interfaceAccount, info.interfacePwd);
|
|
|
|
InterfaceModel.ReturnResult result = sms.Execute(mbs, info.msgContent);
|
|
|
|
logInfo.SENDSTR = result.SendStr;
|
|
logInfo.CLIENTCODE = info.clientCode;
|
|
logInfo.MSGSOURCEID = info.messageid;
|
|
logInfo.RETURNMSG = result.ReturnStr;
|
|
logInfo.SENDTIME = System.DateTime.Now;
|
|
logInfo.SENDSUCCESS = (short)(result.submitStatus == SubmitStatus.success ? 1 : 0);
|
|
//插入日志
|
|
CrmMsg.ExecLog(info.messageid, logInfo);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//插入日志
|
|
logInfo.SENDSUCCESS = 0;
|
|
logInfo.RETURNMSG = ex.Message;
|
|
CrmMsg.ExecLog(_messageid, logInfo);
|
|
|
|
CrmMsg.ClearWait();
|
|
WX.CRM.Common.LogHelper.Error("WX.CRM.CRMServices.SMS.SendCrmMsg:" + ex.Message + ex.StackTrace);
|
|
}
|
|
}
|
|
}
|
|
}
|