background job changed
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
using Hangfire;
|
||||
@@ -13,13 +14,15 @@ public class JobSchedulerRegistrator
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private static DateTime? _lastRunCreateTransaction;
|
||||
private static DateTime? _lastRunSendMonthlySms;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository)
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService)
|
||||
{
|
||||
_smsReminder = smsReminder;
|
||||
_backgroundJobClient = backgroundJobClient;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_smsService = smsService;
|
||||
}
|
||||
|
||||
public void Register()
|
||||
@@ -91,8 +94,8 @@ public class JobSchedulerRegistrator
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//_smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
|
||||
|
||||
await _smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using GozareshgirProgramManager.Application.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
|
||||
public class NullBoardNotificationPublisher:IBoardNotificationPublisher
|
||||
{
|
||||
public Task SendProjectStatusChanged(long userId, TaskSectionStatus oldStatus, TaskSectionStatus newStatus, Guid sectionId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using BackgroundInstitutionContract.Task.Jobs;
|
||||
using CompanyManagment.App.Contracts.Hubs;
|
||||
using CompanyManagment.EFCore.Services;
|
||||
using GozareshgirProgramManager.Application._Bootstrapper;
|
||||
using GozareshgirProgramManager.Application.Interfaces;
|
||||
using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser;
|
||||
using GozareshgirProgramManager.Infrastructure;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Seed;
|
||||
@@ -31,7 +32,7 @@ builder.Services.AddTransient<ISmsService, SmsService>();
|
||||
builder.Services.AddTransient<IUidService, UidService>();
|
||||
builder.Services.AddTransient<IFileUploader, FileUploader>();
|
||||
builder.Services.Configure<AppSettingConfiguration>(builder.Configuration);
|
||||
|
||||
builder.Services.AddScoped<IBoardNotificationPublisher, NullBoardNotificationPublisher>();
|
||||
#region MongoDb
|
||||
|
||||
var mongoConnectionSection = builder.Configuration.GetSection("MongoDb");
|
||||
|
||||
@@ -76,5 +76,7 @@ public class InstitutionContractViewModel
|
||||
public bool IsInstallment { get; set; }
|
||||
public InstitutionContractVerificationStatus VerificationStatus { get; set; }
|
||||
|
||||
public InstitutionContractSigningType? SigningType { get; set; }
|
||||
|
||||
public List<InstitutionContractInstallmentViewModel> InstallmentList { get; set; }
|
||||
}
|
||||
@@ -4364,6 +4364,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
{
|
||||
var sendResult = await _smsService.SendInstitutionCreationVerificationLink(item.Number, item.FullName,
|
||||
item.InstitutionId, item.ContractingPartyId, item.InstitutionContractId, typeOfSms);
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
Console.WriteLine("executed at : " + persianNow + " - " + hour + ":" + minute);
|
||||
@@ -4415,12 +4416,13 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsInstallment = x.IsInstallment,
|
||||
VerificationStatus = x.VerificationStatus,
|
||||
SigningType = x.SigningType,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
.OrderBy(ins => ins.InstallmentDateGr).Skip(1).ToList(),
|
||||
}).Where(x =>
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0)
|
||||
x.ContractStartGr < endOfMonthGr && x.ContractEndGr >= endOfMonthGr && x.ContractAmountDouble > 0 && x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
|
||||
.ToListAsync();
|
||||
|
||||
#endregion
|
||||
@@ -4438,13 +4440,13 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
|
||||
#region GetDectivedContractOnCurrentMonth
|
||||
|
||||
|
||||
if (futureContracts.Any())
|
||||
{
|
||||
List<long> futureContractIds = futureContracts.Select(x => x.ContractingPartyId).ToList();
|
||||
List<InstitutionContractViewModel> deatcivedContract = await _context.InstitutionContractSet
|
||||
.Where(x => x.IsActiveString == "false" && futureContractIds.Contains(x.ContractingPartyId) &&
|
||||
x.ContractEndGr.Date == endOfCurrentMonth.Date && x.ContractAmount > 0)
|
||||
x.ContractEndGr.Date == endOfCurrentMonth.Date && x.ContractAmount > 0 && x.VerificationStatus != InstitutionContractVerificationStatus.PendingForVerify)
|
||||
.Select(x => new InstitutionContractViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
@@ -4459,6 +4461,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
TypeOfContract = x.TypeOfContract,
|
||||
IsInstallment = x.IsInstallment,
|
||||
VerificationStatus = x.VerificationStatus,
|
||||
SigningType = x.SigningType,
|
||||
InstallmentList = x.Installments
|
||||
.Select(ins => new InstitutionContractInstallmentViewModel
|
||||
{ AmountDouble = ins.Amount, InstallmentDateGr = ins.InstallmentDateGr })
|
||||
@@ -4469,6 +4472,12 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
institutionContracts.AddRange(deatcivedContract);
|
||||
}
|
||||
|
||||
// قرارداد هایی که پطور یکجا پرداخت شده اند
|
||||
var paidInFull = institutionContracts.Where(x =>
|
||||
x.SigningType != InstitutionContractSigningType.Legacy && x.IsInstallment == false && x.SigningType != null).ToList();
|
||||
|
||||
//حذف قراداد هایی که یکجا پرداخت شده اند از لیست ایجاد سند ماهانه
|
||||
institutionContracts = institutionContracts.Except(paidInFull).ToList();
|
||||
|
||||
#region RollCallServicCompute
|
||||
|
||||
@@ -4516,8 +4525,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
if (!alreadyCreated)
|
||||
{
|
||||
if (item.IsInstallment &&
|
||||
item.VerificationStatus == InstitutionContractVerificationStatus.Verified)
|
||||
if (item.IsInstallment)
|
||||
{
|
||||
var instalment = item.InstallmentList
|
||||
.FirstOrDefault(x =>
|
||||
@@ -4551,8 +4559,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
await _financialStatmentRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
if (item.IsInstallment &&
|
||||
item.VerificationStatus == InstitutionContractVerificationStatus.Verified)
|
||||
if (item.IsInstallment)
|
||||
{
|
||||
var instalment = item.InstallmentList
|
||||
.FirstOrDefault(x =>
|
||||
@@ -4579,12 +4586,17 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
||||
|
||||
|
||||
#region RollCallServicCompute
|
||||
|
||||
if (item.VerificationStatus != InstitutionContractVerificationStatus.Verified &&
|
||||
!item.IsInstallment && item.ContractingPartyId != 30520 && item.ContractingPartyId != 30739)
|
||||
//ایجاد سند مالی حضورغیاب
|
||||
//قرارداد هایی که جدید نیستند و اقساط ندارند
|
||||
//کارگاه های استثناء : کباب مهدی 30520 و نمونه پروتئین 30739
|
||||
if (item.SigningType != InstitutionContractSigningType.OtpBased && item.SigningType != InstitutionContractSigningType.Physical
|
||||
&& !item.IsInstallment && item.ContractingPartyId != 30520 && item.ContractingPartyId != 30739)
|
||||
{
|
||||
try
|
||||
{
|
||||
//TODO
|
||||
//@refactor Need
|
||||
|
||||
var employers = await _context.Employers
|
||||
.Where(x => x.ContractingPartyId == item.ContractingPartyId)
|
||||
.Select(x => x.id).ToListAsync();
|
||||
|
||||
Reference in New Issue
Block a user