contract resolution added
This commit is contained in:
parent
3c923a66df
commit
37849f8ecf
|
|
@ -17,9 +17,13 @@ using birzha_contracts.Models;
|
|||
builder.Entity<Contract>(entity => {
|
||||
entity.ToTable("tContract");
|
||||
});
|
||||
builder.Entity<ContractResolution>(entity => {
|
||||
entity.ToTable("tContract_Resolution");
|
||||
});
|
||||
}
|
||||
|
||||
public DbSet<birzha_contracts.Models.Contract> Contract { get; set; } = default!;
|
||||
public DbSet<birzha_contracts.Models.ContractResolution> ContractResolution { get; set; } = default!;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3,6 +3,9 @@ using Quartz;
|
|||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using birzha_contracts.Managers;
|
||||
using birzha_contracts.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace birzha_contracts.Jobs{
|
||||
[DisallowConcurrentExecution]
|
||||
|
|
@ -13,6 +16,8 @@ namespace birzha_contracts.Jobs{
|
|||
private readonly IServiceProvider _provider;
|
||||
private HttpClient client = new HttpClient();
|
||||
|
||||
|
||||
|
||||
public HelloWorldJob(ILogger<HelloWorldJob> logger, IServiceProvider provider)
|
||||
{
|
||||
_logger = logger;
|
||||
|
|
@ -23,21 +28,34 @@ namespace birzha_contracts.Jobs{
|
|||
{
|
||||
using(var scope = _provider.CreateScope())
|
||||
{
|
||||
var firstTimeDB = Convert.ToBoolean(ConfigManager.AppSetting["FirstTimeDB"]);
|
||||
var dbContext = scope.ServiceProvider.GetService<MvcContractContext>();
|
||||
|
||||
var contracts = dbContext!.Contract.Where(x => x.ModifiedDate > DateTime.Now.AddMinutes(-30)).OrderByDescending(d => d.ModifiedDate).ToList();
|
||||
|
||||
var contracts = new List<Contract>();
|
||||
if(firstTimeDB){
|
||||
var dateFrom = Convert.ToDateTime(ConfigManager.AppSetting["FirstTimeDBFillDateFrom"]);
|
||||
contracts = dbContext!.Contract.Where(x => x.ModifiedDate >= dateFrom).OrderByDescending(d => d.ModifiedDate).ToList();
|
||||
}
|
||||
else{
|
||||
var minutesAgo = Convert.ToDouble(ConfigManager.AppSetting["DataMinutesAgo"]);
|
||||
minutesAgo = minutesAgo * (-1);
|
||||
contracts = dbContext!.Contract.Where(x => x.ModifiedDate > DateTime.Now.AddMinutes(minutesAgo)).OrderByDescending(d => d.ModifiedDate).ToList();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Sending request: Contracts");
|
||||
var data = JsonConvert.SerializeObject(contracts);
|
||||
|
||||
var content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
|
||||
|
||||
client.BaseAddress = new Uri("http://ba.digital-tps.tk");
|
||||
var domain = Convert.ToString(ConfigManager.AppSetting["Domain"]);
|
||||
client.BaseAddress = new Uri(domain);
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, $"/api/contract/import");
|
||||
var api = ConfigManager.AppSetting["API_contracts"];
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, $""+api+"");
|
||||
|
||||
request.Content = content;
|
||||
|
||||
var response = client.Send(request);
|
||||
_logger.LogInformation("Sending success!");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Success!");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using birzha_contracts.Managers;
|
||||
using birzha_contracts.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace birzha_contracts.Jobs{
|
||||
[DisallowConcurrentExecution]
|
||||
public class UpdateJob : IJob
|
||||
{
|
||||
|
||||
private readonly ILogger<UpdateJob> _logger;
|
||||
private readonly IServiceProvider _provider;
|
||||
private HttpClient client = new HttpClient();
|
||||
|
||||
|
||||
|
||||
public UpdateJob(ILogger<UpdateJob> logger, IServiceProvider provider)
|
||||
{
|
||||
_logger = logger;
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
public Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
using(var scope = _provider.CreateScope())
|
||||
{
|
||||
var firstTimeDB = Convert.ToBoolean(ConfigManager.AppSetting["FirstTimeDB"]);
|
||||
var dbContext = scope.ServiceProvider.GetService<MvcContractContext>();
|
||||
var contracts = new List<ContractResolution>();
|
||||
var minutesAgo = Convert.ToDouble(ConfigManager.AppSetting["DataMinutesAgo"]);
|
||||
minutesAgo = minutesAgo * (-1);
|
||||
contracts = dbContext!.ContractResolution.Where(x => x.ModifiedDate > DateTime.Now.AddMinutes(minutesAgo)).OrderByDescending(d => d.ModifiedDate).ToList();
|
||||
|
||||
_logger.LogInformation("Sending request: Contract-Resolution");
|
||||
var data = JsonConvert.SerializeObject(contracts);
|
||||
|
||||
var content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
|
||||
|
||||
var domain = Convert.ToString(ConfigManager.AppSetting["Domain"]);
|
||||
client.BaseAddress = new Uri(domain);
|
||||
|
||||
var api = ConfigManager.AppSetting["API_contract_resolution"];
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, $""+api+"");
|
||||
|
||||
request.Content = content;
|
||||
|
||||
var response = client.Send(request);
|
||||
_logger.LogInformation("Sending success!");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Success!");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
namespace birzha_contracts.Models;
|
||||
|
||||
|
||||
public class ContractResolution
|
||||
{
|
||||
public long ID { get; set; }
|
||||
|
||||
public long Contract_ID { get; set; }
|
||||
|
||||
public long Department_ID { get; set; }
|
||||
|
||||
public long Workflow_ID { get; set; }
|
||||
|
||||
public long Resolution_ID { get; set; }
|
||||
|
||||
public long ResolutionBasis { get; set; }
|
||||
|
||||
public DateTime? ModifiedDate { get; set; }
|
||||
}
|
||||
|
|
@ -17,15 +17,20 @@ builder.Services.AddQuartz(q =>
|
|||
{
|
||||
q.UseMicrosoftDependencyInjectionJobFactory();
|
||||
var jobKey = new JobKey("HelloWorldJob");
|
||||
var updateJobKey = new JobKey("UpdateJob");
|
||||
q.AddJob<HelloWorldJob>(opts => opts.WithIdentity(jobKey));
|
||||
|
||||
|
||||
q.AddJob<UpdateJob>(opts => opts.WithIdentity(updateJobKey));
|
||||
|
||||
q.AddTrigger(opts => opts
|
||||
.ForJob(jobKey)
|
||||
.WithIdentity("HelloWorldJob-trigger")
|
||||
.WithCronSchedule(time));
|
||||
|
||||
q.AddTrigger(opts => opts
|
||||
.ForJob(updateJobKey)
|
||||
.WithIdentity("UpdateJob-trigger")
|
||||
.WithCronSchedule(time));
|
||||
|
||||
});
|
||||
builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,13 @@
|
|||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"UpdateTime":"0,30 * * * * ?",
|
||||
"UpdateTime":"0 */3 * * * ?",
|
||||
"Domain":"https://panel.exchange.gov.tm",
|
||||
"DataMinutesAgo":3,
|
||||
"FirstTimeDBFillDateFrom": "2022-10-01 00:00:10.183",
|
||||
"FirstTimeDB":false,
|
||||
"API_contracts":"/api/contract/import",
|
||||
"API_contract_resolution":"/api/contract/resolution-import",
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"MvcContractContext": "Server=.\\SQLEXPRESS;Database=clmDB2;User Id=admin;Password=qazwsx12"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,13 @@
|
|||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"UpdateTime":"0,1 * * * * ?",
|
||||
"UpdateTime":"0 */1 * * * ?",
|
||||
"Domain":"https://panel.exchange.gov.tm",
|
||||
"DataMinutesAgo":30,
|
||||
"FirstTimeDBFillDateFrom": "2022-10-03 16:59:40.183",
|
||||
"FirstTimeDB":false,
|
||||
"API_contracts":"/api/contract/import",
|
||||
"API_contract_resolution":"/api/contract/resolution-import",
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"MvcContractContext": "Server=.\\SQLEXPRESS;Database=clmDB2;User Id=admin;Password=qazwsx12"
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"MvcContractContext": "Server=.\\SQLEXPRESS;Database=clmDB2;User Id=admin;Password=qazwsx12"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net6.0",
|
||||
"frameworks": [
|
||||
{
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "6.0.0"
|
||||
},
|
||||
{
|
||||
"name": "Microsoft.AspNetCore.App",
|
||||
"version": "6.0.0"
|
||||
}
|
||||
],
|
||||
"configProperties": {
|
||||
"System.GC.Server": true,
|
||||
"System.Reflection.NullabilityInfoContext.IsSupported": true,
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue