|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace JobCreateFee
|
|
|
|
|
{
|
|
|
|
|
public class JobSendMscSwbData : IJob
|
|
|
|
|
{
|
|
|
|
|
private ILog log = LogManager.GetLogger(typeof(JobSendMscSwbData));
|
|
|
|
|
|
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
|
|
|
|
|
string sqlQuery = context.JobDetail.JobDataMap.GetString("QuerySql");
|
|
|
|
|
string reqUrl = context.JobDetail.JobDataMap.GetString("ReqUrl");
|
|
|
|
|
int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
|
|
|
|
|
|
|
|
|
|
log.Debug($"连接字符串:{connStr}");
|
|
|
|
|
log.Debug($"查询SQL:{sqlQuery}");
|
|
|
|
|
log.Debug($"请求URL:{reqUrl}");
|
|
|
|
|
log.Debug($"请求超时:{reqTimeout}");
|
|
|
|
|
|
|
|
|
|
SqlConnection conn = new SqlConnection(connStr);
|
|
|
|
|
SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlQuery, conn);
|
|
|
|
|
DataTable tQuery = new DataTable();
|
|
|
|
|
dataAdapter.Fill(tQuery);
|
|
|
|
|
|
|
|
|
|
if (tQuery.Rows.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
log.Debug("没有要发送的数据!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var json = DataTableToJsonHelper.ConvertToJson(tQuery);
|
|
|
|
|
log.Debug($"jsonStr:{json.ToString(Formatting.None)}");
|
|
|
|
|
|
|
|
|
|
JObject reqObj = new JObject();
|
|
|
|
|
reqObj.Add("type", new JValue("issue"));
|
|
|
|
|
reqObj.Add("data", json);
|
|
|
|
|
|
|
|
|
|
log.Debug($"reqObj:{reqObj.ToString(Formatting.None)}");
|
|
|
|
|
|
|
|
|
|
//发送请求数据
|
|
|
|
|
string rtn = WebRequestHelper.DoPost(reqUrl, reqObj.ToString(Formatting.None), reqTimeout * 1000);
|
|
|
|
|
var objRtn = JsonConvert.DeserializeAnonymousType(rtn, new { code = "", msg = "" });
|
|
|
|
|
log.Debug($"爬取服务返回:{objRtn.msg}(Code:{objRtn.code})");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error(ex.Message);
|
|
|
|
|
log.Error(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|