You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB
C#

10 months ago
using log4net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JobReqWebData
{
public class JobSendAccount : IJob
{
private ILog log = LogManager.GetLogger(typeof(JobSendAccount));
public void Execute(IJobExecutionContext context)
{
try
{
string reqUrl = context.JobDetail.JobDataMap.GetString("ReqUrl");
string customer = context.JobDetail.JobDataMap.GetString("Customer");
string password = context.JobDetail.JobDataMap.GetString("Password");
string accountJson = context.JobDetail.JobDataMap.GetString("AccountJson");
int reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
log.Debug($"请求URL{reqUrl}");
log.Debug($"用户:{customer}");
log.Debug($"密码:{password}");
log.Debug($"账号密码json{accountJson}");
log.Debug($"请求超时:{reqTimeout}");
JObject reqObj = new JObject();
reqObj.Add("custname", new JValue(customer));
reqObj.Add("psw", new JValue(password));
reqObj.Add("bslist", new JRaw(accountJson));
log.Debug($"reqObj{reqObj.ToString(Formatting.None)}");
//发送请求数据
string rtn = WebRequestHelper.DoPost(reqUrl, reqObj.ToString(Formatting.None), reqTimeout * 1000);
var objRtn = JsonConvert.DeserializeAnonymousType(rtn, new { status = "", message = "" });
log.Debug($"爬取服务返回:{objRtn.message}(Code:{objRtn.status})");
}
catch (Exception ex)
{
log.Error(ex.Message);
log.Error(ex.StackTrace);
}
}
}
}