|
|
using DSWeb.Common.DB;
|
|
|
using DSWeb.Common.Helper;
|
|
|
using DSWeb.Common.Model;
|
|
|
using log4net;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
using Quartz;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace DSWeb.Job.Common
|
|
|
{
|
|
|
public class TaskPostSiStatusJob : IJob
|
|
|
{
|
|
|
private CommonDataContext commonData = new CommonDataContext();
|
|
|
private BookingDB bookingData = new BookingDB();
|
|
|
private OpTaskDataContext taskData = new OpTaskDataContext();
|
|
|
private ILog logger = LogManager.GetLogger("TaskPostSiStatusJob");
|
|
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
|
{
|
|
|
var urlCfg = commonData.ParamSets.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "bookingPostSiStatusUrl");
|
|
|
var postUrl = urlCfg.PARAMVALUE;
|
|
|
|
|
|
var todoList = commonData.BackgroundTaskCommon
|
|
|
.Where(t => t.Status == BackgroundTaskCommon.StatusCreate && t.Type == BackgroundTaskCommon.TypeBookingPostSiStatus)
|
|
|
.ToList();
|
|
|
if (todoList.Count > 0)
|
|
|
{
|
|
|
logger.Debug($"发现{todoList.Count}条待反馈SI状态的任务");
|
|
|
|
|
|
todoList.ForEach(t =>
|
|
|
{
|
|
|
t.Status = BackgroundTaskCommon.StatusDoing;
|
|
|
t.ExecuteCount++;
|
|
|
t.ExecuteTime = DateTime.Now;
|
|
|
});
|
|
|
commonData.SaveChanges();
|
|
|
|
|
|
foreach (var item in todoList)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
logger.Debug($"准备反馈SI状态:{item.GID} {item.ParamData}");
|
|
|
var rtn = WebRequestHelper.DoPost(postUrl, item.ParamData);
|
|
|
|
|
|
logger.Debug($"反馈SI状态返回:{rtn}");
|
|
|
|
|
|
item.Status = BackgroundTaskCommon.StatusSuccess;
|
|
|
commonData.SaveChanges();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
item.Status = BackgroundTaskCommon.StatusFail;
|
|
|
commonData.SaveChanges();
|
|
|
|
|
|
logger.Error($"反馈SI状态出错:{item.GID} {item.ParamData}");
|
|
|
logger.Error(ex.Message);
|
|
|
logger.Error(ex.StackTrace);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
logger.Debug($"{todoList.Count}条反馈SI状态的任务执行完成");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|