ComplianceServer/oldcode/CoreService/SmsJob/SmsBatchSendExc.cs

91 lines
3.0 KiB
C#

using CRM.Core.CoreService.PkgSms;
using CRM.Core.CoreService.PkgSms.DataDrive;
using Quartz;
using System;
using System.Linq;
using WX.CRM.Common;
namespace CRM.Core.CoreService.SmsJob
{
public class SmsBatchSendExc
{
public void Send()
{
try
{
do
{
SendSMS();
} while (SmsBatchSendDomain.SmsWaitCount > 0);
}
catch (Exception ex)
{
WX.CRM.Common.LogHelper.Error("WX.CRM.CRMServices.SMS.SendBatchMsg.Send:" + ex.Message + ex.StackTrace);
}
}
void SendSMS()
{
try
{
var info = new SmsBatchSendDomain().GetInfo();
if (info == null || info.mobiles.Any())
{
SmsBatchSendDomain.ClearBatch();
return;
}
var _id = InterfaceFactory.GetInterfaceIdByCode(info.interfaceCode);
MsgSend sms = new MsgSend(_id, info.interfaceAccount, info.interfacePwd);
//var 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();
//logInfo.SENDSTR = result.SendStr.Substring(0, result.SendStr.Length > 1900 ? 1900 : result.SendStr.Length - 1);
//logInfo.CLIENTCODE = info.clientCode;
//logInfo.MSGSOURCEID = info.batchId;
//logInfo.RETURNMSG = result.ReturnStr.Substring(0, result.ReturnStr.Length > 480 ? 480 : result.ReturnStr.Length);
//logInfo.SENDTIME = System.DateTime.Now;
//logInfo.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)
{
SmsBatchSendDomain.ClearBatch();
WX.CRM.Common.LogHelper.Error("WX.CRM.CRMServices.SMS.SendBatchMsg:" + ex.Message + ex.StackTrace);
}
}
}
public class SmsBatchSendJob : IJob
{
#region IJob
static bool bRunning = false;
public void Execute(JobExecutionContext context)
{
if (bRunning)
return;
bRunning = true;
try
{
new SmsBatchSendExc().Send();
}
catch (Exception e)
{
LogHelper.Error(e);
}
finally
{
bRunning = false;
}
}
#endregion
private void execSms()
{
LogHelper.Info("execSms");
}
}
}