change the Admin monthly overview by figma - add tester
This commit is contained in:
@@ -4,5 +4,5 @@ public enum IsActive
|
||||
{
|
||||
False,
|
||||
True,
|
||||
|
||||
None
|
||||
}
|
||||
@@ -47,4 +47,9 @@ public class AdminMonthlyOverview:EntityBase
|
||||
}
|
||||
Status -= 1;
|
||||
}
|
||||
|
||||
public void SetStatus(AdminMonthlyOverviewStatus status)
|
||||
{
|
||||
Status = status;
|
||||
}
|
||||
}
|
||||
@@ -7,5 +7,6 @@ namespace Company.Domain.AdminMonthlyOverviewAgg;
|
||||
|
||||
public interface IAdminMonthlyOverviewRepository:IRepository<long, AdminMonthlyOverview>
|
||||
{
|
||||
Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(long accountId, int month, int year);
|
||||
Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(AdminMonthlyOverviewSearchModel searchModel);
|
||||
Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId);
|
||||
}
|
||||
@@ -9,11 +9,17 @@ public interface IAdminMonthlyOverviewApplication
|
||||
/// <summary>
|
||||
/// نمایش لیست ماهانه کارگاه ها - درصورت وجود نداشتن اطلاعات در این ماه، یک رکورد جدید ایجاد میکند
|
||||
/// </summary>
|
||||
/// <param name="accountId"></param>
|
||||
/// <param name="month"></param>
|
||||
/// <param name="year"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopsStatus(long accountId, int month, int year);
|
||||
Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopListByStatus(AdminMonthlyOverviewSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// شمارش تعداد هر تب
|
||||
/// </summary>
|
||||
/// <param name="year"></param>
|
||||
/// <param name="month"></param>
|
||||
/// <param name="accountId"></param>
|
||||
/// <returns></returns>
|
||||
Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId);
|
||||
|
||||
/// <summary>
|
||||
/// رفتن به مرحله بعدی
|
||||
@@ -30,10 +36,43 @@ public interface IAdminMonthlyOverviewApplication
|
||||
Task<OperationResult> Back(long id);
|
||||
}
|
||||
|
||||
public class AdminMonthlyOverViewCounterVm
|
||||
{
|
||||
public int CreateDocument { get; set; }
|
||||
public int VisitPending { get; set; }
|
||||
public int VisitInProgress { get; set; }
|
||||
public int VisitCompleted { get; set; }
|
||||
public int Archived { get; set; }
|
||||
public int All { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class AdminMonthlyOverviewSearchModel
|
||||
{
|
||||
public int Year { get; set; }
|
||||
public int Month { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public long EmployerId { get; set; }
|
||||
public long AdminAccountId { get; set; }
|
||||
public IsActive ActivationStatus { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AdminMonthlyOverviewListViewModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public string WorkshopName { get; set; }
|
||||
public string WorkshopArchiveCode { get; set; }
|
||||
public string Province { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string AgentPhoneNumber { get; set; }
|
||||
public string AdminFullName { get; set; }
|
||||
public string EmployerName { get; set; }
|
||||
public string EmployerPhoneNumber { get; set; }
|
||||
public int EmployeeCount { get; set; }
|
||||
public AdminMonthlyOverviewStatus Status { get; set; }
|
||||
public bool IsBlock { get; set; }
|
||||
}
|
||||
@@ -17,9 +17,14 @@ public class AdminMonthlyOverviewApplication:IAdminMonthlyOverviewApplication
|
||||
_adminMonthlyOverviewRepository = adminMonthlyOverviewRepository;
|
||||
}
|
||||
|
||||
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopsStatus(long accountId, int month, int year)
|
||||
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopListByStatus(AdminMonthlyOverviewSearchModel searchModel)
|
||||
{
|
||||
return await _adminMonthlyOverviewRepository.GetWorkshopStatus(accountId, month, year);
|
||||
return await _adminMonthlyOverviewRepository.GetWorkshopStatus(searchModel);
|
||||
}
|
||||
|
||||
public async Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId)
|
||||
{
|
||||
return await _adminMonthlyOverviewRepository.GetCounter(year, month, accountId);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> Next(long id)
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.InfraStructure;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain.AdminMonthlyOverviewAgg;
|
||||
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
@@ -15,62 +16,167 @@ namespace CompanyManagment.EFCore.Repository;
|
||||
public class AdminMonthlyOverviewRepository : RepositoryBase<long, AdminMonthlyOverview>, IAdminMonthlyOverviewRepository
|
||||
{
|
||||
private readonly CompanyContext _companyContext;
|
||||
public AdminMonthlyOverviewRepository(CompanyContext companyContext) : base(companyContext)
|
||||
private readonly AccountContext _accountContext;
|
||||
public AdminMonthlyOverviewRepository(CompanyContext companyContext, AccountContext accountContext) : base(companyContext)
|
||||
{
|
||||
_companyContext = companyContext;
|
||||
_accountContext = accountContext;
|
||||
}
|
||||
|
||||
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(long accountId, int month, int year)
|
||||
public async Task<List<AdminMonthlyOverviewListViewModel>> GetWorkshopStatus(AdminMonthlyOverviewSearchModel searchModel)
|
||||
{
|
||||
if ($"{year:0000}/{month:00}/01".TryToGeorgianDateTime(out var dateTime) == false)
|
||||
var year = searchModel.Year;
|
||||
var month = searchModel.Month;
|
||||
var accountId = searchModel.AdminAccountId;
|
||||
// اگر تبدیل تاریخ به میلادی موفق نبود، لیست خالی برگردان
|
||||
if ($"{year:0000}/{month:00}/01".TryToGeorgianDateTime(out var targetDate) == false)
|
||||
return [];
|
||||
|
||||
var contractingPartyIdsQuery = _companyContext.InstitutionContractSet
|
||||
.Where(c => c.ContractStartGr <= dateTime && c.ContractEndGr >= dateTime && c.IsActiveString == "true")
|
||||
.Select(c => c.ContractingPartyId);
|
||||
// دریافت اطلاعات ادمین
|
||||
var adminAccount = await _accountContext.Accounts.FirstOrDefaultAsync(x => x.id == searchModel.AdminAccountId);
|
||||
|
||||
var accountWorkshopIdsQuery = _companyContext.WorkshopAccounts
|
||||
// اگر ادمین پیدا نشد، لیست خالی برگردان
|
||||
if (adminAccount == null)
|
||||
return [];
|
||||
|
||||
// دریافت طرف حساب های معتبر برای تاریخ مورد نظر
|
||||
var contractingPartyIds = await _companyContext.InstitutionContractSet.AsNoTracking()
|
||||
.Where(c => c.ContractStartGr <= targetDate && c.ContractEndGr >= targetDate && c.IsActiveString == "true")
|
||||
.Select(c => c.ContractingPartyId)
|
||||
.ToListAsync();
|
||||
|
||||
// دریافت کارگاههای مرتبط با اکانت
|
||||
var accountWorkshopIds = await _companyContext.WorkshopAccounts
|
||||
.AsNoTracking()
|
||||
.Where(w => w.AccountId == accountId)
|
||||
.Select(w => w.WorkshopId);
|
||||
.Select(w => w.WorkshopId)
|
||||
.ToListAsync();
|
||||
|
||||
var workshops = await _companyContext.PersonalContractingParties
|
||||
.Include(p => p.Employers)
|
||||
.ThenInclude(e => e.WorkshopEmployers)
|
||||
.ThenInclude(we => we.Workshop)
|
||||
.Where(p => contractingPartyIdsQuery.Contains(p.id))
|
||||
.SelectMany(p => p.Employers)
|
||||
.SelectMany(e => e.WorkshopEmployers)
|
||||
.Where(we => accountWorkshopIdsQuery.Contains(we.WorkshopId))
|
||||
.Select(we => we.Workshop).ToListAsync();
|
||||
// دریافت کارگاههای مربوط به طرف حساب و اکانت
|
||||
// Replace the selected code with the following to return a list of anonymous objects containing both workshop and contractingParty
|
||||
|
||||
var workshopIds = workshops.Select(x => x.id).ToList();
|
||||
var workshopsWithContractingParty = await _companyContext.Workshops
|
||||
.AsNoTracking()
|
||||
.Where(w => accountWorkshopIds.Contains(w.id))
|
||||
.Include(w => w.WorkshopEmployers)
|
||||
.ThenInclude(we => we.Employer)
|
||||
.ThenInclude(e => e.ContractingParty).AsSplitQuery()
|
||||
.Where(w => w.WorkshopEmployers.Any(we =>
|
||||
we.Employer != null &&
|
||||
contractingPartyIds.Contains(we.Employer.ContractingPartyId)))
|
||||
.Select(w => new
|
||||
{
|
||||
Workshop = w,
|
||||
ContractingParty = w.WorkshopEmployers
|
||||
.Where(we => we.Employer != null && contractingPartyIds.Contains(we.Employer.ContractingPartyId))
|
||||
.Select(we => we.Employer.ContractingParty)
|
||||
.FirstOrDefault()
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var adminMonthlyOverviewWorkshopIds = _companyContext.AdminMonthlyOverviews.Where(x =>
|
||||
workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year).Select(x => x.WorkshopId).ToList();
|
||||
var workshopIds = workshopsWithContractingParty.Select(x => x.Workshop.id).ToList();
|
||||
|
||||
// پیدا کردن کارگاههایی که قبلاً برای این ماه/سال AdminMonthlyOverview دارند
|
||||
var adminMonthlyOverviewWorkshopIds = await _companyContext.AdminMonthlyOverviews
|
||||
.AsNoTracking()
|
||||
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year)
|
||||
.Select(x => x.WorkshopId)
|
||||
.ToListAsync();
|
||||
|
||||
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds.Where(x => !adminMonthlyOverviewWorkshopIds.Contains(x)).ToList();
|
||||
// پیدا کردن کارگاههایی که نیاز به ایجاد AdminMonthlyOverview جدید دارند
|
||||
var notExistAdminMonthlyReviewsWorkshopIds = workshopIds
|
||||
.Except(adminMonthlyOverviewWorkshopIds)
|
||||
.ToList();
|
||||
|
||||
// ایجاد رکوردهای AdminMonthlyOverview که وجود ندارند
|
||||
if (notExistAdminMonthlyReviewsWorkshopIds.Any())
|
||||
await CreateRangeAdminMonthlyOverview(notExistAdminMonthlyReviewsWorkshopIds, month, year);
|
||||
|
||||
// بهروزرسانی وضعیتها
|
||||
await UpdateAdminMonthlyOverviewStatus(year, month, workshopIds);
|
||||
|
||||
// دریافت همه AdminMonthlyOverview برای این کارگاهها/ماه/سال
|
||||
var adminMonthlyOverviewsQuery = _companyContext.AdminMonthlyOverviews
|
||||
.Where(x => workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year);
|
||||
|
||||
var adminMonthlyOverViews = _companyContext.AdminMonthlyOverviews.Where(x =>
|
||||
workshopIds.Contains(x.WorkshopId) && x.Month == month && x.Year == year).ToList().Select(x =>
|
||||
if (searchModel.WorkshopId > 0)
|
||||
{
|
||||
var workshop = workshops.FirstOrDefault(w => w.id == x.WorkshopId);
|
||||
return new AdminMonthlyOverviewListViewModel()
|
||||
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => x.WorkshopId == searchModel.WorkshopId);
|
||||
}
|
||||
|
||||
if (searchModel.EmployerId > 0)
|
||||
{
|
||||
var searchWorkshopId = workshopsWithContractingParty.Where(x => x.Workshop.WorkshopEmployers.Any(e => e.EmployerId == searchModel.EmployerId)).Select(x => x.Workshop.id).ToList();
|
||||
adminMonthlyOverviewsQuery = adminMonthlyOverviewsQuery.Where(x => searchWorkshopId.Contains(x.WorkshopId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
var adminMonthlyOverviewsList = await adminMonthlyOverviewsQuery.ToListAsync();
|
||||
var employeeCounts = _companyContext.LeftWorkList.Where(x =>
|
||||
x.StartWorkDate < targetDate && x.LeftWorkDate > targetDate && workshopIds.Contains(x.WorkshopId))
|
||||
.GroupBy(x => x.WorkshopId).Select(x => new { EmployeeCounts = x.Count(), WorkshopId = x.Key }).ToList();
|
||||
|
||||
// نگاشت به ViewModel
|
||||
var adminMonthlyOverviewList = adminMonthlyOverviewsList.Select(x =>
|
||||
{
|
||||
var employeeCount = employeeCounts.FirstOrDefault(e => e.WorkshopId == x.WorkshopId);
|
||||
var workshopWithContractingParty =
|
||||
workshopsWithContractingParty.FirstOrDefault(w => w.Workshop.id == x.WorkshopId);
|
||||
|
||||
var workshop = workshopWithContractingParty?.Workshop;
|
||||
var contractingParty = workshopWithContractingParty?.ContractingParty;
|
||||
var employer = workshop?.WorkshopEmployers.FirstOrDefault()?.Employer;
|
||||
return new AdminMonthlyOverviewListViewModel
|
||||
{
|
||||
WorkshopId = x.WorkshopId,
|
||||
Status = x.Status,
|
||||
Id = x.id,
|
||||
WorkshopName = workshop?.WorkshopFullName ?? ""
|
||||
WorkshopName = workshop?.WorkshopFullName ?? "",
|
||||
WorkshopArchiveCode = workshop?.ArchiveCode ?? "",
|
||||
Address = workshop?.Address ?? "",
|
||||
City = workshop?.City ?? "",
|
||||
Province = workshop?.State ?? "",
|
||||
EmployerName = employer?.FullName ?? "",
|
||||
EmployerPhoneNumber = employer?.Phone ?? "",
|
||||
AdminFullName = adminAccount.Fullname,
|
||||
EmployeeCount = employeeCount?.EmployeeCounts ?? 0,
|
||||
AgentPhoneNumber = "",
|
||||
IsBlock = contractingParty?.IsBlock == "true"
|
||||
};
|
||||
}).OrderBy(x => x.IsBlock).ToList();
|
||||
|
||||
return adminMonthlyOverviewList;
|
||||
}
|
||||
|
||||
public async Task<AdminMonthlyOverViewCounterVm> GetCounter(int year, int month, long accountId)
|
||||
{
|
||||
var searchModel = new AdminMonthlyOverviewSearchModel()
|
||||
{
|
||||
AdminAccountId = accountId,
|
||||
Month = month,
|
||||
Year = year
|
||||
};
|
||||
var list = await GetWorkshopStatus(searchModel);
|
||||
|
||||
var allCount = list.Count;
|
||||
var archivedCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.Archived);
|
||||
var createDocCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.CreateDocuments);
|
||||
var visitCompleteCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitCompleted);
|
||||
var visitInProgressCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitInProgress);
|
||||
var visitPendingCount = list.Count(x => x.Status == AdminMonthlyOverviewStatus.VisitPending);
|
||||
|
||||
return new AdminMonthlyOverViewCounterVm
|
||||
{
|
||||
All = allCount,
|
||||
Archived = archivedCount,
|
||||
VisitPending = visitPendingCount,
|
||||
VisitInProgress = visitInProgressCount,
|
||||
VisitCompleted = visitCompleteCount,
|
||||
CreateDocument = createDocCount
|
||||
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
return adminMonthlyOverViews;
|
||||
}
|
||||
|
||||
private async Task UpdateAdminMonthlyOverviewStatus(int year, int month, List<long> workshopIds)
|
||||
@@ -78,50 +184,63 @@ public class AdminMonthlyOverviewRepository : RepositoryBase<long, AdminMonthlyO
|
||||
var targetDate = $"{year:0000}/{month:00}/01".ToGeorgianDateTime();
|
||||
_ = $"{year:0000}/{month:00}/01".ToGeorgianDateTime().AddMonthsFa(1, out var nextMonth);
|
||||
|
||||
var workingEmployeeIds = (await _companyContext.LeftWorkList
|
||||
|
||||
var workingEmployeeIds = (await _companyContext.LeftWorkList.AsNoTracking()
|
||||
.Where(x => workshopIds.Contains(x.WorkshopId) && x.StartWorkDate <= targetDate && x.LeftWorkDate >= targetDate)
|
||||
.Select(x => new { x.WorkshopId, x.EmployeeId })
|
||||
.Distinct()
|
||||
.ToListAsync());
|
||||
.ToListAsync()).Distinct();
|
||||
|
||||
var contractKeys = await _companyContext.Contracts
|
||||
var contractSet = (await _companyContext.Contracts.AsNoTracking()
|
||||
.Where(x => x.ContarctStart <= nextMonth && x.ContractEnd >= nextMonth)
|
||||
.Select(x => new { WorkshopId = x.WorkshopIds, x.EmployeeId })
|
||||
.ToListAsync();
|
||||
.Select(x => new { x.WorkshopIds, x.EmployeeId })
|
||||
.ToListAsync())
|
||||
.Select(x => (x.WorkshopIds, x.EmployeeId))
|
||||
.ToHashSet();
|
||||
|
||||
var contractSet = contractKeys.ToHashSet();
|
||||
|
||||
var workshopsWithFullContracts = workingEmployeeIds
|
||||
.GroupBy(x => x.WorkshopId)
|
||||
.Where(group => group.All(emp => contractSet.Contains(new { emp.WorkshopId, emp.EmployeeId })))
|
||||
.Select(group => group.Key)
|
||||
.ToList();
|
||||
|
||||
var checkoutKeys = await _companyContext.CheckoutSet
|
||||
var checkoutSet = (await _companyContext.CheckoutSet.AsNoTracking()
|
||||
.Where(x => x.ContractStart <= targetDate && x.ContractEnd >= targetDate)
|
||||
.Select(x => new { x.WorkshopId, x.EmployeeId })
|
||||
.ToListAsync())
|
||||
.Select(x => (x.WorkshopId, x.EmployeeId))
|
||||
.ToHashSet();
|
||||
|
||||
var grouped = workingEmployeeIds.GroupBy(x => x.WorkshopId).ToList();
|
||||
|
||||
var workshopsWithFullContracts = grouped
|
||||
.Where(g => g.All(emp => contractSet.Contains((emp.WorkshopId, emp.EmployeeId))))
|
||||
.Select(g => g.Key)
|
||||
.ToList();
|
||||
|
||||
var workshopsWithFullCheckout = grouped
|
||||
.Where(g => g.All(emp => checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
|
||||
.Select(g => g.Key)
|
||||
.ToList();
|
||||
|
||||
var fullyCoveredWorkshops = workshopsWithFullContracts.Intersect(workshopsWithFullCheckout).ToList();
|
||||
|
||||
var notFullyCoveredWorkshops = grouped
|
||||
.Where(g => g.Any(emp =>
|
||||
!contractSet.Contains((emp.WorkshopId, emp.EmployeeId)) ||
|
||||
!checkoutSet.Contains((emp.WorkshopId, emp.EmployeeId))))
|
||||
.Select(g => g.Key)
|
||||
.ToList();
|
||||
|
||||
var adminMonthlyOverviews = _companyContext.AdminMonthlyOverviews
|
||||
.Where(x => x.Month == month && x.Year == year);
|
||||
|
||||
var adminMonthlyOverviewsWithFullContracts = await adminMonthlyOverviews
|
||||
.Where(x => fullyCoveredWorkshops.Contains(x.WorkshopId) && x.Status == AdminMonthlyOverviewStatus.CreateDocuments)
|
||||
.ToListAsync();
|
||||
|
||||
var checkoutSet = checkoutKeys.ToHashSet();
|
||||
var adminMonthlyOverviewsWithNotFullContracts = await adminMonthlyOverviews
|
||||
.Where(x => notFullyCoveredWorkshops.Contains(x.WorkshopId)&&x.Status != AdminMonthlyOverviewStatus.CreateDocuments)
|
||||
.ToListAsync();
|
||||
|
||||
var workshopsWithFullCheckout = workingEmployeeIds
|
||||
.GroupBy(x => x.WorkshopId)
|
||||
.Where(group => group.All(emp => checkoutSet.Contains(new { emp.WorkshopId, emp.EmployeeId })))
|
||||
.Select(group => group.Key)
|
||||
.ToList();
|
||||
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithFullContracts)
|
||||
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.VisitPending);
|
||||
|
||||
var fullyCoveredWorkshops = workshopsWithFullContracts
|
||||
.Intersect(workshopsWithFullCheckout)
|
||||
.ToList();
|
||||
|
||||
|
||||
var adminMonthlyOverviews = await _companyContext.AdminMonthlyOverviews.Where(x =>
|
||||
fullyCoveredWorkshops.Contains(x.WorkshopId) && x.Month == month && x.Year == year && x.Status == AdminMonthlyOverviewStatus.CreateDocuments).ToListAsync();
|
||||
|
||||
foreach (var adminMonthlyOverview in adminMonthlyOverviews)
|
||||
{
|
||||
adminMonthlyOverview.Next();
|
||||
}
|
||||
foreach (var adminMonthlyOverview in adminMonthlyOverviewsWithNotFullContracts)
|
||||
adminMonthlyOverview.SetStatus(AdminMonthlyOverviewStatus.CreateDocuments);
|
||||
|
||||
await _companyContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using ServiceHost.Hubs;
|
||||
using ServiceHost.MiddleWare;
|
||||
using WorkFlow.Infrastructure.Config;
|
||||
using _0_Framework.Application.UID;
|
||||
using ServiceHost.Test;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -49,6 +50,12 @@ builder.Services.AddTransient<IUidService, UidService>();
|
||||
//services.AddSingleton<IWorkingTest, WorkingTest>();
|
||||
//services.AddHostedService<JobWorker>();
|
||||
|
||||
#region Mahan
|
||||
|
||||
builder.Services.AddTransient<Tester>();
|
||||
|
||||
#endregion
|
||||
|
||||
builder.Services.Configure<FormOptions>(options =>
|
||||
{
|
||||
options.ValueCountLimit = int.MaxValue;
|
||||
@@ -151,6 +158,15 @@ builder.Services.AddSignalR();
|
||||
var app = builder.Build();
|
||||
#region Mahan
|
||||
app.UseStatusCodePagesWithRedirects("/error/{0}");
|
||||
|
||||
//the backend Tester
|
||||
if (builder.Environment.IsDevelopment())
|
||||
{
|
||||
using var scope = app.Services.CreateScope();
|
||||
var tester = scope.ServiceProvider.GetRequiredService<Tester>();
|
||||
await tester.Test();
|
||||
}
|
||||
|
||||
#endregion
|
||||
//Create Http Pipeline
|
||||
|
||||
|
||||
38
ServiceHost/Test/Tester.cs
Normal file
38
ServiceHost/Test/Tester.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Diagnostics;
|
||||
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
|
||||
using CompanyManagment.EFCore;
|
||||
using ServiceHost.Areas.AdminNew.Pages.Company.RollCall;
|
||||
|
||||
namespace ServiceHost.Test;
|
||||
|
||||
public class Tester
|
||||
{
|
||||
private readonly IAdminMonthlyOverviewApplication _adminMonthlyOverviewApplication;
|
||||
private readonly CompanyContext _companyContext;
|
||||
public Tester(IAdminMonthlyOverviewApplication adminMonthlyOverviewApplication, CompanyContext companyContext)
|
||||
{
|
||||
_adminMonthlyOverviewApplication = adminMonthlyOverviewApplication;
|
||||
_companyContext = companyContext;
|
||||
}
|
||||
|
||||
public async Task Test()
|
||||
{
|
||||
|
||||
await AdminMonthlyOverviewTest();
|
||||
|
||||
}
|
||||
private async Task AdminMonthlyOverviewTest()
|
||||
{
|
||||
var acc = _companyContext.WorkshopAccounts.FirstOrDefault(x => x.AccountId == 322);
|
||||
var searchModel = new AdminMonthlyOverviewSearchModel()
|
||||
{
|
||||
Year = 1403,
|
||||
Month = 12,
|
||||
AdminAccountId = 322
|
||||
};
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var workshopsStatus = await _adminMonthlyOverviewApplication.GetWorkshopListByStatus(searchModel);
|
||||
Console.WriteLine(stopwatch.Elapsed);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user