RG3.PF.Quartz.StartUsed.Jobs.JsonToDbJob
public async Task<ResultDetail<dynamic>> BuildAsyncDb(string table, IConfiguration _configuration, SchedulerConfig sc, IAsyncProvider asyncProvider, IDbContext _dbContext, ICache _cache, string cookie, string token)
{
DateTime dateS = DateTime.Now;
if (sc.ResponseFromData == null || !sc.ResponseFromData.Any() || sc.ResponseFromData.Count() == 0)
{
Console.WriteLine(string.Format(sc.Msg.Process, 0, 0, 0));
return new ResultDetail<dynamic> { Success = true, Data = new { datas = 0 } };
}
int success = 0;
//List<Dictionary<string, object>> datas = new List<Dictionary<string, object>>();
//List<Dictionary<string, object>> datasT = new List<Dictionary<string, object>>();
int totalCount = 0;
var env = EnvPFUtil.CurrentEnv(); // Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var os = EnvPFUtil.CurrentSystemName();
//"~/Config/Scheduler/idc"
string dirPhy = PhyPathUtil.ConvertVirToPhyPath(sc.DirPhyRoot);
foreach (var responseFromData in sc.ResponseFromData)
{
var content = await FileUtil.ReadFileAndContentByVirUrlAsync(responseFromData.Value);
var resultT = JsonUtil.Deserialize<ResultList<Dictionary<string, object>>>(content);
//new PFGlobalParameter { OwnerId = "idc" }
int resultCT = 0;
try
{
if (resultT.Data != null && resultT.Data.Count() > 0)
{
resultCT = resultT.Data.Count();
string mkey = responseFromData.Mkey;
//绑定操作的列表
var configBuilder = new ConfigurationBuilder().SetBasePath(dirPhy);
configBuilder.AddJsonFile($"{mkey}.json", optional: true, reloadOnChange: true);
configBuilder.AddJsonFile($"{mkey}.{env}.json", optional: true, reloadOnChange: true);
configBuilder.AddJsonFile($"{mkey}.{env}.{os}.json", optional: true, reloadOnChange: true);
var config = configBuilder.Build();
SchedulerConfig scT = new SchedulerConfig();
scT.Bulk.DoMethod = sc.Bulk.DoMethod;
config.GetSection($"scheduler:{mkey}").Bind(scT);
//数据入库
int count = await asyncProvider.DoAsync(sc.GlobalParameter, scT, resultT.Data, table);
totalCount = totalCount + count;
}
}
catch (Exception e)
{
Console.WriteLine(string.Format(sc.Msg.Process, DateTime.Now, 0, 0, resultCT));
}
}
DateTime dateE = DateTime.Now;
long dateLS = 0;
long dateLE = 0;
Console.WriteLine(string.Format(sc.Msg.Process + ";开始时间:" + dateLS + ";结束时间:" + dateLE, DateTime.Now, (dateE - dateS).TotalSeconds, dateS.AddSeconds(sc.Job.WithIntervalInSeconds),totalCount));
return new ResultDetail<dynamic> { Success = true, Data = new { datas = totalCount, success = success } };
}
文档更新时间: 2021-08-22 08:00 作者:admin