Compare commits
19 Commits
Feature/ro
...
Feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
| 8839b54dd3 | |||
| d9c431e20e | |||
|
|
2746bf69ea | ||
|
|
77dbb50512 | ||
|
|
1c7e8824c7 | ||
| 0eff1b9a66 | |||
|
|
0d33d79620 | ||
|
|
e4355faffc | ||
|
|
577fe5db76 | ||
|
|
ec8333c715 | ||
|
|
8aa93e089a | ||
|
|
0ab3052251 | ||
|
|
5202779d9f | ||
|
|
67a85735f0 | ||
|
|
35e6355069 | ||
|
|
4de2e12ac5 | ||
|
|
23b65cfbfe | ||
|
|
48b75d2baa | ||
|
|
63edb33bf5 |
@@ -2,6 +2,8 @@
|
||||
|
||||
public enum TypeOfSmsSetting
|
||||
{
|
||||
//همه انواع پیامک
|
||||
All = 0,
|
||||
|
||||
/// <summary>
|
||||
/// پیامک
|
||||
@@ -23,7 +25,7 @@ public enum TypeOfSmsSetting
|
||||
|
||||
/// <summary>
|
||||
/// پیامک
|
||||
/// هشدار اول
|
||||
/// هشدار بدهی
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
@@ -38,4 +40,14 @@ public enum TypeOfSmsSetting
|
||||
/// </summary>
|
||||
InstitutionContractConfirm,
|
||||
|
||||
/// <summary>
|
||||
/// ارسال کد تاییدیه قرارداد مالی
|
||||
/// </summary>
|
||||
SendInstitutionContractConfirmationCode,
|
||||
|
||||
/// <summary>
|
||||
/// یادآور وظایف
|
||||
/// </summary>
|
||||
TaskReminder,
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace _0_Framework.Application;
|
||||
public class PagedResult<T> where T : class
|
||||
{
|
||||
public int TotalCount { get; set; }
|
||||
public List<T> List { get; set; } = [];
|
||||
public List<T> List { get; set; }
|
||||
}
|
||||
public class PagedResult<T,TMeta>:PagedResult<T> where T : class
|
||||
{
|
||||
|
||||
@@ -18,3 +18,17 @@ public class ApiResultViewModel
|
||||
public string DeliveryColor { get; set; }
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ApiReportDto
|
||||
{
|
||||
public int MessageId { get; set; }
|
||||
|
||||
public long Mobile { get; set; }
|
||||
|
||||
public string SendUnixTime { get; set; }
|
||||
public string DeliveryState { get; set; }
|
||||
public string DeliveryUnixTime { get; set; }
|
||||
public string DeliveryColor { get; set; }
|
||||
|
||||
}
|
||||
@@ -19,6 +19,13 @@ public interface ISmsService
|
||||
bool SendAccountsInfo(string number,string fullName, string userName);
|
||||
Task<ApiResultViewModel> GetByMessageId(int messId);
|
||||
Task<List<ApiResultViewModel>> GetApiResult(string startDate, string endDate);
|
||||
|
||||
#region ForApi
|
||||
|
||||
Task<List<ApiReportDto>> GetApiReport(string startDate, string endDate);
|
||||
|
||||
#endregion
|
||||
|
||||
string DeliveryStatus(byte? dv);
|
||||
string DeliveryColorStatus(byte? dv);
|
||||
string UnixTimeStampToDateTime(int? unixTimeStamp);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.Sms;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
@@ -12,19 +13,21 @@ public class JobSchedulerRegistrator
|
||||
private readonly IBackgroundJobClient _backgroundJobClient;
|
||||
private readonly SmsReminder _smsReminder;
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private readonly IInstitutionContractSmsServiceRepository _institutionContractSmsServiceRepository;
|
||||
private static DateTime? _lastRunCreateTransaction;
|
||||
private static DateTime? _lastRunSendMonthlySms;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly ILogger<JobSchedulerRegistrator> _logger;
|
||||
|
||||
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService, ILogger<JobSchedulerRegistrator> logger)
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService, ILogger<JobSchedulerRegistrator> logger, IInstitutionContractSmsServiceRepository institutionContractSmsServiceRepository)
|
||||
{
|
||||
_smsReminder = smsReminder;
|
||||
_backgroundJobClient = backgroundJobClient;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_smsService = smsService;
|
||||
_logger = logger;
|
||||
_institutionContractSmsServiceRepository = institutionContractSmsServiceRepository;
|
||||
}
|
||||
|
||||
public void Register()
|
||||
@@ -58,17 +61,43 @@ public class JobSchedulerRegistrator
|
||||
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
);
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.SendWarningSms",
|
||||
// () => SendWarningSms(),
|
||||
// "*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
//);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.SendWarningSms",
|
||||
() => SendWarningSms(),
|
||||
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
);
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.SendLegalActionSms",
|
||||
// () => SendLegalActionSms(),
|
||||
// "*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
//);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.SendLegalActionSms",
|
||||
() => SendLegalActionSms(),
|
||||
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
);
|
||||
|
||||
|
||||
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.Block",
|
||||
() => Block(),
|
||||
"*/30 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
);
|
||||
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.UnBlock",
|
||||
() => UnBlock(),
|
||||
"*/10 * * * *"
|
||||
);
|
||||
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.DeActiveInstitutionEndOfContract",
|
||||
() => DeActiveInstitutionEndOfContract(),
|
||||
"*/30 * * * *"
|
||||
);
|
||||
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.BlueDeActiveAfterZeroDebt",
|
||||
() => BlueDeActiveAfterZeroDebt(),
|
||||
"*/10 * * * *"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +108,7 @@ public class JobSchedulerRegistrator
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 1200)]
|
||||
public async System.Threading.Tasks.Task CreateFinancialTransaction()
|
||||
{
|
||||
var now =DateTime.Now;
|
||||
var now = DateTime.Now;
|
||||
var endOfMonth = now.ToFarsi().FindeEndOfMonth();
|
||||
var endOfMonthGr = endOfMonth.ToGeorgianDateTime();
|
||||
_logger.LogInformation("CreateFinancialTransaction job run");
|
||||
@@ -134,7 +163,7 @@ public class JobSchedulerRegistrator
|
||||
|
||||
try
|
||||
{
|
||||
await _institutionContractRepository.SendMonthlySms(now);
|
||||
await _institutionContractSmsServiceRepository.SendMonthlySms(now);
|
||||
_lastRunSendMonthlySms = now;
|
||||
Console.WriteLine("Send Monthly sms executed");
|
||||
|
||||
@@ -156,7 +185,7 @@ public class JobSchedulerRegistrator
|
||||
public async System.Threading.Tasks.Task SendReminderSms()
|
||||
{
|
||||
_logger.LogInformation("SendReminderSms job run");
|
||||
await _institutionContractRepository.SendReminderSmsForBackgroundTask();
|
||||
await _institutionContractSmsServiceRepository.SendReminderSmsForBackgroundTask();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -167,7 +196,7 @@ public class JobSchedulerRegistrator
|
||||
public async System.Threading.Tasks.Task SendBlockSms()
|
||||
{
|
||||
_logger.LogInformation("SendBlockSms job run");
|
||||
await _institutionContractRepository.SendBlockSmsForBackgroundTask();
|
||||
await _institutionContractSmsServiceRepository.SendBlockSmsForBackgroundTask();
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +208,7 @@ public class JobSchedulerRegistrator
|
||||
public async System.Threading.Tasks.Task SendInstitutionContractConfirmSms()
|
||||
{
|
||||
_logger.LogInformation("SendInstitutionContractConfirmSms job run");
|
||||
await _institutionContractRepository.SendInstitutionContractConfirmSmsTask();
|
||||
await _institutionContractSmsServiceRepository.SendInstitutionContractConfirmSmsTask();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -190,14 +219,86 @@ public class JobSchedulerRegistrator
|
||||
public async System.Threading.Tasks.Task SendWarningSms()
|
||||
{
|
||||
_logger.LogInformation("SendWarningSms job run");
|
||||
await _institutionContractRepository.SendWarningSmsTask();
|
||||
await _institutionContractSmsServiceRepository.SendWarningOrLegalActionSmsTask(TypeOfSmsSetting.Warning);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// پیامک اقدام قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 100)]
|
||||
public async System.Threading.Tasks.Task SendLegalActionSms()
|
||||
{
|
||||
_logger.LogInformation("SendWarningSms job run");
|
||||
await _institutionContractRepository.SendLegalActionSmsTask();
|
||||
await _institutionContractSmsServiceRepository.SendWarningOrLegalActionSmsTask(TypeOfSmsSetting.LegalAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// بلاگ سازی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 100)]
|
||||
public async System.Threading.Tasks.Task Block()
|
||||
{
|
||||
_logger.LogInformation("block job run");
|
||||
var now = DateTime.Now;
|
||||
var executeDate = now.ToFarsi().Substring(8, 2);
|
||||
if (executeDate == "20")
|
||||
{
|
||||
if (now.Hour >= 9 && now.Hour < 10)
|
||||
{
|
||||
await _institutionContractSmsServiceRepository.Block(now);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// آنبلاک
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 100)]
|
||||
public async System.Threading.Tasks.Task UnBlock()
|
||||
{
|
||||
_logger.LogInformation("UnBlock job run");
|
||||
|
||||
await _institutionContractSmsServiceRepository.UnBlock();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// غیر فعال سازی قراداد های پایان یافته
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 100)]
|
||||
public async System.Threading.Tasks.Task DeActiveInstitutionEndOfContract()
|
||||
{
|
||||
_logger.LogInformation("DeActiveInstitutionEndOfContract job run");
|
||||
|
||||
|
||||
var now = DateTime.Now;
|
||||
var executeDate = now.ToFarsi().Substring(8, 2);
|
||||
if (executeDate == "01")
|
||||
{
|
||||
if (now.Hour >= 9 && now.Hour < 10)
|
||||
{
|
||||
await _institutionContractSmsServiceRepository.DeActiveInstitutionEndOfContract(now);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// غیرفعال سازس قرارداد های آبی که بدهی ندارند
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 800)]
|
||||
public async System.Threading.Tasks.Task BlueDeActiveAfterZeroDebt()
|
||||
{
|
||||
_logger.LogInformation("BlueDeActiveAfterZeroDebt job run");
|
||||
await _institutionContractSmsServiceRepository.BlueDeActiveAfterZeroDebt();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,65 +91,7 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
Task<List<InstitutionContractPrintViewModel>> PrintAllAsync(List<long> ids);
|
||||
|
||||
|
||||
#region ReminderSMS
|
||||
/// <summary>
|
||||
/// دریافت لیست - ارسال پیامک
|
||||
/// فراخوانی از سمت بک گراند سرویس
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<bool> SendReminderSmsForBackgroundTask();
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک صورت حساب ماهانه
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
/// <returns></returns>
|
||||
Task SendMonthlySms(DateTime now);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودی از طرف بک گراند سرویس
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendBlockSmsForBackgroundTask();
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست واجد شرایط بلاک
|
||||
/// جهت ارسال پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <param name="checkDate"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<BlockSmsListData>> GetBlockListData(DateTime checkDate);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <param name="smsListData"></param>
|
||||
/// <param name="typeOfSms"></param>
|
||||
/// <param name="sendMessStart"></param>
|
||||
/// <param name="sendMessEnd"></param>
|
||||
/// <returns></returns>
|
||||
Task SendBlockSmsToContractingParties(List<BlockSmsListData> smsListData, string typeOfSms,
|
||||
string sendMessStart, string sendMessEnd);
|
||||
|
||||
/// <summary>
|
||||
///دریافت لیست بدهکارن
|
||||
/// جهت ارسال پیامک
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsListData>> GetSmsListData(DateTime checkDate, TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک های یاد آور بدهی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendReminderSmsToContractingParties(List<SmsListData> smsListData, string typeOfSms, string sendMessStart, string sendMessEnd);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک یادآور تایید قراداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendInstitutionContractConfirmSmsTask();
|
||||
#endregion
|
||||
|
||||
#region CreateMontlyTransaction
|
||||
|
||||
@@ -162,24 +104,12 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
|
||||
#endregion
|
||||
|
||||
#region WarningSms
|
||||
/// <summary>
|
||||
/// پیامک های هشدار
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendWarningSmsTask();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region legalAction
|
||||
/// <summary>
|
||||
/// پیامک اقدام قضائی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendLegalActionSmsTask();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
Task<long> GetIdByInstallmentId(long installmentId);
|
||||
Task<InstitutionContract> GetPreviousContract(long currentInstitutionContractId);
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.InstitutionContractAgg;
|
||||
|
||||
public interface IInstitutionContractSmsServiceRepository : IRepository<long, InstitutionContract>
|
||||
{
|
||||
#region reminderSMs
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک یادآور تایید قراداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendInstitutionContractConfirmSmsTask();
|
||||
#endregion
|
||||
|
||||
//هشدار و اقدام قضایی
|
||||
#region WarningOrLegalActionSmsListData
|
||||
/// <summary>
|
||||
/// اجرای تسک پیامک هشدار یا اقدام قضایی
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task SendWarningOrLegalActionSmsTask(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست بدهکاران آبی جهت هشدار یا اقدام قضایی
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsListData>> GetWarningOrLegalActionSmsListData(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک هشدار یا اقدام قضایی
|
||||
/// </summary>
|
||||
/// <param name="smsListData"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task SendWarningOrLegalActionSms(List<SmsListData> smsListData, TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
#endregion
|
||||
|
||||
//بلاک - آنبلاک - پیامک بلاک -
|
||||
// غیر فعال سازی قراداد های پایان یافته
|
||||
#region Block
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودی از طرف بک گراند سرویس
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendBlockSmsForBackgroundTask();
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست واجد شرایط بلاک
|
||||
/// جهت ارسال پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <param name="checkDate"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<BlockSmsListData>> GetBlockListData(DateTime checkDate);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <param name="smsListData"></param>
|
||||
/// <param name="typeOfSms"></param>
|
||||
/// <param name="sendMessStart"></param>
|
||||
/// <param name="sendMessEnd"></param>
|
||||
/// <returns></returns>
|
||||
Task SendBlockSmsToContractingParties(List<BlockSmsListData> smsListData, string typeOfSms,
|
||||
string sendMessStart, string sendMessEnd);
|
||||
|
||||
/// <summary>
|
||||
/// بلاک سازی
|
||||
/// </summary>
|
||||
/// <param name="checkDate"></param>
|
||||
/// <returns></returns>
|
||||
Task Block(DateTime checkDate);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست بدهکارانی که باید بلاک شوند
|
||||
/// </summary>
|
||||
/// <param name="checkDate"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<long>> GetToBeBlockList(DateTime checkDate);
|
||||
|
||||
/// <summary>
|
||||
/// آنبلاک
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task UnBlock();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// غیر فعالسازی قرارداد های پایان یافته
|
||||
/// </summary>
|
||||
/// <param name="checkDate"></param>
|
||||
/// <returns></returns>
|
||||
Task DeActiveInstitutionEndOfContract(DateTime checkDate);
|
||||
|
||||
/// <summary>
|
||||
/// غیرفعال سازس قرارداد های آبی که بدهی ندارند
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task BlueDeActiveAfterZeroDebt();
|
||||
#endregion
|
||||
|
||||
|
||||
#region ReminderSMS
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست - ارسال پیامک
|
||||
/// فراخوانی از سمت بک گراند سرویس
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<bool> SendReminderSmsForBackgroundTask();
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک صورت حساب ماهانه
|
||||
/// </summary>
|
||||
/// <param name="now"></param>
|
||||
/// <returns></returns>
|
||||
Task SendMonthlySms(DateTime now);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///دریافت لیست بدهکارن
|
||||
/// جهت ارسال پیامک
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsListData>> GetSmsListData(DateTime checkDate, TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک های یاد آور بدهی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task SendReminderSmsToContractingParties(List<SmsListData> smsListData, string typeOfSms, string sendMessStart, string sendMessEnd);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
@@ -92,9 +91,5 @@ namespace Company.Domain.RollCallAgg
|
||||
Task<List<RollCall>> GetRollCallsUntilNowWithWorkshopIdEmployeeIds(long workshopId, List<long> employeeIds,
|
||||
DateTime fromDate);
|
||||
#endregion
|
||||
|
||||
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
|
||||
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
|
||||
string titleId, RollCallCaseHistorySearchModel searchModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.SmsResultAgg;
|
||||
|
||||
public interface ISmsResultRepository : IRepository<long, SmsResult>
|
||||
{
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامکها
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsReportDto>> GetSmsReportList(SmsReportSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اکسپند لیست هر تاریخ
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date);
|
||||
|
||||
#endregion
|
||||
List<SmsResultViewModel> Search(SmsResultSearchModel searchModel);
|
||||
}
|
||||
@@ -1,12 +1,6 @@
|
||||
using _0_Framework.Excel;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.Drawing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
|
||||
@@ -314,111 +308,6 @@ public class RollCallExcelGenerator : ExcelGenerator
|
||||
return package.GetAsByteArray();
|
||||
}
|
||||
|
||||
public static byte[] CaseHistoryExcelForEmployee(List<RollCallCaseHistoryDetail> data, string titleId)
|
||||
{
|
||||
if (!Regex.IsMatch(titleId, @"^\d{4}_\d{2}$"))
|
||||
throw new ArgumentException("Invalid titleId format.", nameof(titleId));
|
||||
|
||||
var splitDate = titleId.Split("_");
|
||||
var year = Convert.ToInt32(splitDate.First());
|
||||
var month = Convert.ToInt32(splitDate.Last());
|
||||
|
||||
var startDateFa = $"{year:D4}/{month:D2}/01";
|
||||
var startDate = startDateFa.ToGeorgianDateTime();
|
||||
var endDateFa = startDateFa.FindeEndOfMonth();
|
||||
var endDate = endDateFa.ToGeorgianDateTime();
|
||||
|
||||
var dateRange = (int)(endDate.Date - startDate.Date).TotalDays + 1;
|
||||
var dates = Enumerable.Range(0, dateRange).Select(x => startDate.AddDays(x)).ToList();
|
||||
|
||||
var safeData = data ?? new List<RollCallCaseHistoryDetail>();
|
||||
var first = safeData.FirstOrDefault();
|
||||
var totalWorkingTime = new TimeSpan(safeData.Sum(x => x.TotalWorkingTime.Ticks));
|
||||
|
||||
var viewModel = new CaseHistoryRollCallExcelForEmployeeViewModel
|
||||
{
|
||||
EmployeeId = first?.EmployeeId ?? 0,
|
||||
DateGr = startDate,
|
||||
PersonnelCode = first?.PersonnelCode,
|
||||
EmployeeFullName = first?.EmployeeFullName,
|
||||
PersianMonthName = month.ToFarsiMonthByIntNumber(),
|
||||
PersianYear = year.ToString(),
|
||||
TotalWorkingHoursFa = totalWorkingTime.ToFarsiHoursAndMinutes("-"),
|
||||
TotalWorkingTimeSpan = $"{(int)totalWorkingTime.TotalHours}:{totalWorkingTime.Minutes:00}",
|
||||
RollCalls = dates.Select((date, index) =>
|
||||
{
|
||||
var item = index < safeData.Count ? safeData[index] : null;
|
||||
var records = item?.Records ?? new List<RollCallCaseHistoryDetailRecord>();
|
||||
|
||||
return new RollCallItemForEmployeeExcelViewModel
|
||||
{
|
||||
DateGr = date,
|
||||
DateFa = date.ToFarsi(),
|
||||
DayOfWeekFa = date.DayOfWeek.DayOfWeeKToPersian(),
|
||||
PersonnelCode = item?.PersonnelCode,
|
||||
EmployeeFullName = item?.EmployeeFullName,
|
||||
IsAbsent = item?.Status == RollCallRecordStatus.Absent,
|
||||
HasLeave = item?.Status == RollCallRecordStatus.Leaved,
|
||||
IsHoliday = false,
|
||||
TotalWorkingHours = (item?.TotalWorkingTime ?? TimeSpan.Zero).ToFarsiHoursAndMinutes("-"),
|
||||
StartsItems = JoinRecords(records, r => r.StartTime),
|
||||
EndsItems = JoinRecords(records, r => r.EndTime),
|
||||
EnterTimeDifferences = JoinRecords(records, r => FormatSignedTimeSpan(r.EntryTimeDifference)),
|
||||
ExitTimeDifferences = JoinRecords(records, r => FormatSignedTimeSpan(r.ExitTimeDifference))
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return CaseHistoryExcelForEmployee(viewModel);
|
||||
}
|
||||
|
||||
public static byte[] CaseHistoryExcelForOneDay(List<RollCallCaseHistoryDetail> data, string titleId)
|
||||
{
|
||||
if (!Regex.IsMatch(titleId, @"^\d{4}/\d{2}/\d{2}$"))
|
||||
throw new ArgumentException("Invalid titleId format.", nameof(titleId));
|
||||
|
||||
var dateGr = titleId.ToGeorgianDateTime();
|
||||
var safeData = data ?? new List<RollCallCaseHistoryDetail>();
|
||||
|
||||
var viewModel = new CaseHistoryRollCallForOneDayViewModel
|
||||
{
|
||||
DateFa = titleId,
|
||||
DateGr = dateGr,
|
||||
DayOfWeekFa = dateGr.DayOfWeek.DayOfWeeKToPersian(),
|
||||
RollCalls = safeData.Select(item =>
|
||||
{
|
||||
var records = item.Records ?? new List<RollCallCaseHistoryDetailRecord>();
|
||||
return new RollCallItemForOneDayExcelViewModel
|
||||
{
|
||||
EmployeeFullName = item.EmployeeFullName,
|
||||
PersonnelCode = item.PersonnelCode,
|
||||
StartsItems = JoinRecords(records, r => r.StartTime),
|
||||
EndsItems = JoinRecords(records, r => r.EndTime),
|
||||
TotalWorkingHours = item.TotalWorkingTime.ToFarsiHoursAndMinutes("-")
|
||||
};
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return CaseHistoryExcelForOneDay(viewModel);
|
||||
}
|
||||
|
||||
private static string JoinRecords(IEnumerable<RollCallCaseHistoryDetailRecord> records, Func<RollCallCaseHistoryDetailRecord, string> selector)
|
||||
{
|
||||
var safeRecords = records ?? Enumerable.Empty<RollCallCaseHistoryDetailRecord>();
|
||||
var values = safeRecords.Select(selector).Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
|
||||
return values.Count == 0 ? string.Empty : string.Join(Environment.NewLine, values);
|
||||
}
|
||||
|
||||
private static string FormatSignedTimeSpan(TimeSpan value)
|
||||
{
|
||||
if (value == TimeSpan.Zero)
|
||||
return "-";
|
||||
|
||||
var abs = value.Duration();
|
||||
var sign = value.Ticks < 0 ? "-" : "+";
|
||||
return $"{(int)abs.TotalHours}:{abs.Minutes:00}{sign}";
|
||||
}
|
||||
|
||||
private string CalculateExitMinuteDifference(TimeSpan early, TimeSpan late)
|
||||
{
|
||||
if (early == TimeSpan.Zero && late == TimeSpan.Zero)
|
||||
|
||||
@@ -4,8 +4,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.RollCall
|
||||
{
|
||||
@@ -127,62 +125,7 @@ namespace CompanyManagment.App.Contracts.RollCall
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> RecalculateValues(long workshopId, List<ReCalculateRollCallValues> command);
|
||||
|
||||
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
|
||||
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel);
|
||||
|
||||
Task<RollCallCaseHistoryExcelDto> DownloadCaseHistoryExcel(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel);
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryExcelDto
|
||||
{
|
||||
public byte[] Bytes { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryDetail
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
public TimeSpan TotalWorkingTime { get; set; }
|
||||
public List<RollCallCaseHistoryDetailRecord> Records { get; set; }
|
||||
public RollCallRecordStatus Status { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
}
|
||||
|
||||
public enum RollCallRecordStatus
|
||||
{
|
||||
Worked = 0,
|
||||
Absent = 1,
|
||||
Leaved = 2
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryDetailRecord
|
||||
{
|
||||
public TimeSpan EntryTimeDifference { get; set; }
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public TimeSpan ExitTimeDifference { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class RollCallCaseHistorySearchModel:PaginationRequest
|
||||
{
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public string OneDayDate { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryTitleDto
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
|
||||
public class ReCalculateRollCallValues
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
15
CompanyManagment.App.Contracts/SmsResult/Dto/SendStatus.cs
Normal file
15
CompanyManagment.App.Contracts/SmsResult/Dto/SendStatus.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت ارسال پیامک
|
||||
/// </summary>
|
||||
public enum SendStatus
|
||||
{
|
||||
All=0,
|
||||
/// <summary>
|
||||
/// موفق
|
||||
/// </summary>
|
||||
Success,
|
||||
//ناموفق
|
||||
Failed,
|
||||
}
|
||||
54
CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportDto.cs
Normal file
54
CompanyManagment.App.Contracts/SmsResult/Dto/SmsReportDto.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
|
||||
public class SmsReportDto
|
||||
{
|
||||
/// <summary>
|
||||
/// تاریخ ارسال
|
||||
/// </summary>
|
||||
public string SentDate { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SmsReportListDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// آی دی پیامک در sms.ir
|
||||
/// </summary>
|
||||
public int MessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت ارسال
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع پیامک
|
||||
/// </summary>
|
||||
public string TypeOfSms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام طرف حساب
|
||||
/// </summary>
|
||||
public string ContractingPartyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره موبایل
|
||||
/// </summary>
|
||||
public string Mobile { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ساعت و دقیقه
|
||||
/// </summary>
|
||||
public string HourAndMinute { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
|
||||
public class SmsReportSearchModel
|
||||
{
|
||||
//نوع پیامک
|
||||
public TypeOfSmsSetting TypeOfSms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت ارسال پیامک
|
||||
/// </summary>
|
||||
public SendStatus SendStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره موبایل
|
||||
/// </summary>
|
||||
public string Mobile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی طرف حساب
|
||||
/// </summary>
|
||||
public long ContractingPatyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// سال
|
||||
/// </summary>
|
||||
public string Year { get; set; }
|
||||
/// <summary>
|
||||
/// ماه
|
||||
/// </summary>
|
||||
public string Month { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ شروع
|
||||
/// </summary>
|
||||
public string StartDateFa { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ پایان
|
||||
/// </summary>
|
||||
public string EndDateFa { get; set; }
|
||||
}
|
||||
@@ -1,14 +1,34 @@
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SmsResult;
|
||||
|
||||
public interface ISmsResultApplication
|
||||
{
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامکها
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsReportDto>> GetSmsReportList(SmsReportSearchModel searchModel);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اکسپند لیست هر تاریخ
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date);
|
||||
|
||||
#endregion
|
||||
|
||||
OperationResult Create(CreateSmsResult command);
|
||||
List<SmsResultViewModel> Search(SmsResultSearchModel searchModel);
|
||||
}
|
||||
@@ -13,7 +13,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
|
||||
<ProjectReference Include="..\Company.Domain\Company.Domain.csproj" />
|
||||
<ProjectReference Include="..\CompanyManagement.Infrastructure.Excel\CompanyManagement.Infrastructure.Excel.csproj" />
|
||||
<ProjectReference Include="..\CompanyManagment.App.Contracts\CompanyManagment.App.Contracts.csproj" />
|
||||
<ProjectReference Include="..\CompanyManagment.EFCore\CompanyManagment.EFCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,11 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain.CustomizeCheckoutShared.Enums;
|
||||
using _0_Framework.Exceptions;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutAgg;
|
||||
using Company.Domain.CustomizeCheckoutTempAgg;
|
||||
@@ -18,8 +16,6 @@ using Company.Domain.LeaveAgg;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using Company.Domain.RollCallEmployeeAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
@@ -38,9 +34,8 @@ public class RollCallApplication : IRollCallApplication
|
||||
private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository;
|
||||
private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository;
|
||||
private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository;
|
||||
private readonly IWorkshopRepository _workshopRepository;
|
||||
|
||||
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IWorkshopRepository workshopRepository)
|
||||
public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository)
|
||||
{
|
||||
_rollCallRepository = rollCallRepository;
|
||||
_rollCallEmployeeRepository = rollCallEmployeeRepository;
|
||||
@@ -52,7 +47,6 @@ public class RollCallApplication : IRollCallApplication
|
||||
_customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository;
|
||||
_customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository;
|
||||
_customizeCheckoutTempRepository = customizeCheckoutTempRepository;
|
||||
_workshopRepository = workshopRepository;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateRollCall command)
|
||||
@@ -864,58 +858,4 @@ public class RollCallApplication : IRollCallApplication
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallRepository.GetCaseHistoryTitles(workshopId,searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
|
||||
string titleId, RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallRepository.GetCaseHistoryDetails(workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
public async Task<RollCallCaseHistoryExcelDto> DownloadCaseHistoryExcel(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
var data = await _rollCallRepository
|
||||
.GetCaseHistoryDetails(workshopId, titleId, searchModel);
|
||||
string nameSecondPart = "";
|
||||
byte[] excelBytes;
|
||||
|
||||
if (Regex.IsMatch(titleId, @"^\d{4}_\d{2}$"))
|
||||
{
|
||||
var splitDate = titleId.Split("_");
|
||||
var year = Convert.ToInt32(splitDate.First());
|
||||
var month = Convert.ToInt32(splitDate.Last());
|
||||
|
||||
var monthName = Convert.ToInt32(month).ToFarsiMonthByIntNumber();
|
||||
nameSecondPart = $"{year}/{monthName}";
|
||||
excelBytes = RollCallExcelGenerator.CaseHistoryExcelForEmployee(data, titleId);
|
||||
}
|
||||
else if (Regex.IsMatch(titleId, @"^\d{4}/\d{2}/\d{2}$"))
|
||||
{
|
||||
var oneDayDate = titleId.ToGeorgianDateTime();
|
||||
nameSecondPart = $" {oneDayDate.DayOfWeek.DayOfWeeKToPersian()}،{titleId}";
|
||||
excelBytes = RollCallExcelGenerator.CaseHistoryExcelForOneDay(data, titleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BadRequestException("شناسه سر تیتر وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var workshopFullName = _workshopRepository.Get(workshopId)?.WorkshopFullName ?? "بدون کارگاه";
|
||||
|
||||
var fileName = $"{workshopFullName} - {nameSecondPart}.xlsx";
|
||||
|
||||
var res = new RollCallCaseHistoryExcelDto()
|
||||
{
|
||||
Bytes = excelBytes,
|
||||
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
FileName = fileName
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -15,6 +17,23 @@ public class SmsResultApplication : ISmsResultApplication
|
||||
_smsResultRepository = smsResultRepository;
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<List<SmsReportDto>> GetSmsReportList(SmsReportSearchModel searchModel)
|
||||
{
|
||||
return await _smsResultRepository.GetSmsReportList(searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
|
||||
{
|
||||
return await _smsResultRepository.GetSmsReportExpandList(searchModel, date);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public OperationResult Create(CreateSmsResult command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -15,11 +16,13 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
{
|
||||
private readonly ISmsSettingsRepository _smsSettingsRepository;
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private readonly IInstitutionContractSmsServiceRepository _institutionContractSmsServiceRepository;
|
||||
|
||||
public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository)
|
||||
public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository, IInstitutionContractSmsServiceRepository institutionContractSmsServiceRepository)
|
||||
{
|
||||
_smsSettingsRepository = smsSettingsRepository;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_institutionContractSmsServiceRepository = institutionContractSmsServiceRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,12 +119,12 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
|
||||
public async Task<List<SmsListData>> GetSmsListData(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _institutionContractRepository.GetSmsListData(DateTime.Now, typeOfSmsSetting);
|
||||
return await _institutionContractSmsServiceRepository.GetSmsListData(DateTime.Now, typeOfSmsSetting);
|
||||
}
|
||||
|
||||
public async Task<List<BlockSmsListData>> GetBlockSmsListData(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _institutionContractRepository.GetBlockListData(DateTime.Now);
|
||||
return await _institutionContractSmsServiceRepository.GetBlockListData(DateTime.Now);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +137,7 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
|
||||
if (command.Any())
|
||||
{
|
||||
await _institutionContractRepository.SendReminderSmsToContractingParties(command, typeOfSms, sendMessStart, sendMessEnd);
|
||||
await _institutionContractSmsServiceRepository.SendReminderSmsToContractingParties(command, typeOfSms, sendMessStart, sendMessEnd);
|
||||
return op.Succcedded();
|
||||
}
|
||||
else
|
||||
@@ -153,7 +156,7 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
string sendMessEnd = "پایان مسدودی آنی ";
|
||||
if (command.Any())
|
||||
{
|
||||
await _institutionContractRepository.SendBlockSmsToContractingParties(command, typeOfSms, sendMessStart,
|
||||
await _institutionContractSmsServiceRepository.SendBlockSmsToContractingParties(command, typeOfSms, sendMessStart,
|
||||
sendMessEnd);
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
@@ -713,15 +713,10 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
var itemsQuery = _companyContext.EmployeeDocumentItems
|
||||
.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted)
|
||||
.Include(x => x.EmployeeDocuments)
|
||||
.ThenInclude(x => x.Workshop)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x => x.Employer)
|
||||
.GroupBy(x => x.WorkshopId)
|
||||
.Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x => x.WorkshopEmployers).ThenInclude(x => x.Employer)
|
||||
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
{
|
||||
SubmittedItemsCount = x
|
||||
.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin
|
||||
|| y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
WorkshopId = x.Key,
|
||||
WorkshopFullName = x.First().EmployeeDocuments.Workshop.WorkshopName,
|
||||
EmployerName = x.First().EmployeeDocuments.Workshop.WorkshopEmployers.First().Employer.FullName
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application.Enums;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class SmsResultRepository : RepositoryBase<long, SmsResult> , ISmsResultRepository
|
||||
public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
public SmsResultRepository(CompanyContext context) : base(context)
|
||||
@@ -15,6 +22,260 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult> , ISmsResultR
|
||||
_context = context;
|
||||
}
|
||||
|
||||
#region ForApi
|
||||
|
||||
|
||||
|
||||
public async Task<List<SmsReportDto>> GetSmsReportList(SmsReportSearchModel searchModel)
|
||||
{
|
||||
|
||||
// مرحله 1: همه رکوردها را با projection ساده بگیرید
|
||||
var rawQuery = await _context.SmsResults
|
||||
.Select(x => new
|
||||
{
|
||||
x.id,
|
||||
x.ContractingPatyId,
|
||||
x.Mobile,
|
||||
x.Status,
|
||||
x.TypeOfSms,
|
||||
x.CreationDate,
|
||||
DateOnly = x.CreationDate.Date // فقط تاریخ بدون ساعت
|
||||
})
|
||||
.AsNoTracking()
|
||||
.ToListAsync(); // اینجا SQL اجرا میشود و همه دادهها به client میآیند
|
||||
|
||||
if (searchModel.ContractingPatyId > 0)
|
||||
{
|
||||
rawQuery = rawQuery.Where(x => x.ContractingPatyId == searchModel.ContractingPatyId).ToList();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Mobile))
|
||||
{
|
||||
rawQuery = rawQuery.Where(x => x.Mobile.Contains(searchModel.Mobile)).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.TypeOfSms != TypeOfSmsSetting.All && searchModel.TypeOfSms != TypeOfSmsSetting.Warning)
|
||||
{
|
||||
var typeOfSms = "All";
|
||||
switch (searchModel.TypeOfSms)
|
||||
{
|
||||
case TypeOfSmsSetting.InstitutionContractDebtReminder:
|
||||
typeOfSms = "یادآور بدهی ماهانه";
|
||||
break;
|
||||
case TypeOfSmsSetting.MonthlyInstitutionContract:
|
||||
typeOfSms = "صورت حساب ماهانه";
|
||||
break;
|
||||
case TypeOfSmsSetting.BlockContractingParty:
|
||||
typeOfSms = "اعلام مسدودی طرف حساب";
|
||||
break;
|
||||
case TypeOfSmsSetting.LegalAction:
|
||||
typeOfSms = "اقدام قضایی";
|
||||
break;
|
||||
case TypeOfSmsSetting.InstitutionContractConfirm:
|
||||
typeOfSms = "یادآور تایید قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.SendInstitutionContractConfirmationCode:
|
||||
typeOfSms = "کد تاییدیه قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.TaskReminder:
|
||||
typeOfSms = "یادآور وظایف";
|
||||
break;
|
||||
}
|
||||
|
||||
rawQuery = rawQuery.Where(x => x.TypeOfSms == typeOfSms).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.TypeOfSms == TypeOfSmsSetting.Warning)
|
||||
{
|
||||
rawQuery = rawQuery.Where(x => x.TypeOfSms.Contains("هشدار")).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.SendStatus != SendStatus.All)
|
||||
{
|
||||
var status = "All";
|
||||
|
||||
switch (searchModel.SendStatus)
|
||||
{
|
||||
case SendStatus.Success: status = "موفق";
|
||||
break;
|
||||
case SendStatus.Failed: status = "ناموفق";
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
rawQuery = rawQuery.Where(x => x.Status == status).ToList();
|
||||
|
||||
}
|
||||
#region searchByDate
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.StartDateFa) &&
|
||||
!string.IsNullOrWhiteSpace(searchModel.EndDateFa))
|
||||
{
|
||||
if (searchModel.StartDateFa.TryToGeorgianDateTime(out var startGr) == false ||
|
||||
searchModel.EndDateFa.TryToGeorgianDateTime(out var endGr) == false)
|
||||
return new List<SmsReportDto>();
|
||||
|
||||
rawQuery = rawQuery.Where(x => x.CreationDate.Date >= startGr.Date && x.CreationDate.Date <= endGr.Date).ToList();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Year) && !string.IsNullOrWhiteSpace(searchModel.Month))
|
||||
{
|
||||
var start = searchModel.Year + "/" + searchModel.Month + "/01";
|
||||
var end = start.FindeEndOfMonth();
|
||||
var startGr = start.ToGeorgianDateTime();
|
||||
var endGr = end.ToGeorgianDateTime();
|
||||
rawQuery = rawQuery.Where(x => x.CreationDate.Date >= startGr.Date && x.CreationDate.Date <= endGr.Date).ToList();
|
||||
|
||||
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(searchModel.Year) && string.IsNullOrWhiteSpace(searchModel.Month))
|
||||
{
|
||||
var start = searchModel.Year + "/01/01";
|
||||
var findEndOfYear = searchModel.Year + "/12/01";
|
||||
var end = findEndOfYear.FindeEndOfMonth();
|
||||
var startGr = start.ToGeorgianDateTime();
|
||||
var endGr = end.ToGeorgianDateTime();
|
||||
rawQuery = rawQuery.Where(x => x.CreationDate.Date >= startGr.Date && x.CreationDate.Date <= endGr.Date).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// مرحله 2: گروهبندی و انتخاب آخرین رکورد هر روز روی Client
|
||||
var grouped = rawQuery
|
||||
.GroupBy(x => x.DateOnly)
|
||||
.Select(g => g.OrderByDescending(x => x.CreationDate).First())
|
||||
.OrderByDescending(x => x.CreationDate)
|
||||
.ToList();
|
||||
|
||||
// مرحله 3: تبدیل به DTO و ToFarsi
|
||||
var result = grouped.Select(x => new SmsReportDto
|
||||
{
|
||||
SentDate = x.CreationDate.ToFarsi()
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(date))
|
||||
return new List<SmsReportListDto>();
|
||||
|
||||
if (date.TryToGeorgianDateTime(out var searchDate) == false)
|
||||
return new List<SmsReportListDto>();
|
||||
|
||||
var query = await _context.SmsResults.Where(x => x.CreationDate.Date == searchDate.Date)
|
||||
.Select(x =>
|
||||
new
|
||||
{
|
||||
x.id,
|
||||
x.MessageId,
|
||||
x.Status,
|
||||
x.TypeOfSms,
|
||||
x.ContractingPartyName,
|
||||
x.Mobile,
|
||||
x.ContractingPatyId,
|
||||
x.InstitutionContractId,
|
||||
x.CreationDate,
|
||||
x.CreationDate.Hour,
|
||||
x.CreationDate.Minute
|
||||
|
||||
}).AsNoTracking()
|
||||
.ToListAsync(); ;
|
||||
|
||||
if (searchModel.ContractingPatyId > 0)
|
||||
{
|
||||
query = query.Where(x => x.ContractingPatyId == searchModel.ContractingPatyId).ToList();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Mobile))
|
||||
{
|
||||
query = query.Where(x => x.Mobile.Contains(searchModel.Mobile)).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.TypeOfSms != TypeOfSmsSetting.All && searchModel.TypeOfSms != TypeOfSmsSetting.Warning)
|
||||
{
|
||||
var typeOfSms = "All";
|
||||
switch (searchModel.TypeOfSms)
|
||||
{
|
||||
case TypeOfSmsSetting.InstitutionContractDebtReminder:
|
||||
typeOfSms = "یادآور بدهی ماهانه";
|
||||
break;
|
||||
case TypeOfSmsSetting.MonthlyInstitutionContract:
|
||||
typeOfSms = "صورت حساب ماهانه";
|
||||
break;
|
||||
case TypeOfSmsSetting.BlockContractingParty:
|
||||
typeOfSms = "اعلام مسدودی طرف حساب";
|
||||
break;
|
||||
case TypeOfSmsSetting.LegalAction:
|
||||
typeOfSms = "اقدام قضایی";
|
||||
break;
|
||||
case TypeOfSmsSetting.InstitutionContractConfirm:
|
||||
typeOfSms = "یادآور تایید قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.SendInstitutionContractConfirmationCode:
|
||||
typeOfSms = "کد تاییدیه قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.TaskReminder:
|
||||
typeOfSms = "یادآور وظایف";
|
||||
break;
|
||||
}
|
||||
|
||||
query = query.Where(x => x.TypeOfSms == typeOfSms).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.TypeOfSms == TypeOfSmsSetting.Warning)
|
||||
{
|
||||
query = query.Where(x => x.TypeOfSms.Contains("هشدار")).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.SendStatus != SendStatus.All)
|
||||
{
|
||||
var status = "All";
|
||||
|
||||
switch (searchModel.SendStatus)
|
||||
{
|
||||
case SendStatus.Success:
|
||||
status = "موفق";
|
||||
break;
|
||||
case SendStatus.Failed:
|
||||
status = "ناموفق";
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
query = query.Where(x => x.Status == status).ToList();
|
||||
|
||||
}
|
||||
|
||||
if (query.Count == 0)
|
||||
return new List<SmsReportListDto>();
|
||||
|
||||
var result = query.OrderByDescending(x => x.CreationDate.Hour)
|
||||
.ThenByDescending(x => x.CreationDate.Minute).Select(x =>
|
||||
new SmsReportListDto()
|
||||
{
|
||||
Id = x.id,
|
||||
MessageId = x.MessageId,
|
||||
Status = x.Status,
|
||||
TypeOfSms = x.TypeOfSms,
|
||||
ContractingPartyName = x.ContractingPartyName,
|
||||
Mobile = x.Mobile,
|
||||
HourAndMinute = x.CreationDate.TimeOfDay.ToString(@"hh\:mm"),
|
||||
}).ToList();
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public List<App.Contracts.SmsResult.SmsResultViewModel> Search(SmsResultSearchModel searchModel)
|
||||
{
|
||||
|
||||
@@ -82,7 +343,7 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult> , ISmsResultR
|
||||
|
||||
|
||||
query = query.OrderByDescending(x => x.CreationDate)
|
||||
.ThenByDescending(x=>x.CreationDate.Hour).ThenByDescending(x=>x.CreationDate.Minute);
|
||||
.ThenByDescending(x => x.CreationDate.Hour).ThenByDescending(x => x.CreationDate.Minute);
|
||||
|
||||
return query.Skip(searchModel.PageIndex).Take(30).ToList();
|
||||
|
||||
|
||||
@@ -207,16 +207,11 @@ public class SmsService : ISmsService
|
||||
}
|
||||
public async Task<List<ApiResultViewModel>> GetApiResult(string startDate, string endDate)
|
||||
{
|
||||
var st = new DateTime(2024, 6, 2);
|
||||
var ed = new DateTime(2024, 7, 1);
|
||||
if (!string.IsNullOrWhiteSpace(startDate) && startDate.Length == 10)
|
||||
{
|
||||
st = startDate.ToGeorgianDateTime();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(endDate) && endDate.Length == 10)
|
||||
{
|
||||
ed = endDate.ToGeorgianDateTime();
|
||||
}
|
||||
|
||||
|
||||
if(startDate.TryToGeorgianDateTime(out var st) == false || endDate.TryToGeorgianDateTime(out var ed) == false)
|
||||
return new List<ApiResultViewModel>();
|
||||
|
||||
var res = new List<ApiResultViewModel>();
|
||||
Int32 unixTimestamp = (int)st.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
Int32 unixTimestamp2 = (int)ed.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
@@ -248,6 +243,44 @@ public class SmsService : ISmsService
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<List<ApiReportDto>> GetApiReport(string startDate, string endDate)
|
||||
{
|
||||
|
||||
|
||||
if (startDate.TryToGeorgianDateTime(out var st) == false || endDate.TryToGeorgianDateTime(out var ed) == false)
|
||||
return new List<ApiReportDto>();
|
||||
|
||||
var res = new List<ApiReportDto>();
|
||||
Int32 unixTimestamp = (int)st.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
Int32 unixTimestamp2 = (int)ed.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
// int? fromDateUnixTime = null; // unix time - for instance: 1700598600
|
||||
//int? toDateUnixTime = null; // unix time - for instance: 1703190600
|
||||
int pageNumber = 2;
|
||||
int pageSize = 100; // max: 100
|
||||
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var response = await smsIr.GetArchivedReportAsync(pageNumber, pageSize, unixTimestamp, unixTimestamp2);
|
||||
|
||||
MessageReportResult[] messages = response.Data;
|
||||
foreach (var message in messages)
|
||||
{
|
||||
var appendData = new ApiReportDto()
|
||||
{
|
||||
MessageId = message.MessageId,
|
||||
|
||||
Mobile = message.Mobile,
|
||||
|
||||
SendUnixTime = UnixTimeStampToDateTime(message.SendDateTime),
|
||||
DeliveryState = DeliveryStatus(message.DeliveryState),
|
||||
DeliveryUnixTime = UnixTimeStampToDateTime(message.DeliveryDateTime),
|
||||
DeliveryColor = DeliveryColorStatus(message.DeliveryState),
|
||||
};
|
||||
res.Add(appendData);
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public string DeliveryStatus(byte? dv)
|
||||
{
|
||||
string mess = "";
|
||||
|
||||
@@ -563,6 +563,7 @@ public class PersonalBootstrapper
|
||||
services.AddTransient<ISmsSettingsRepository, SmsSettingsRepository>();
|
||||
services.AddTransient<ISmsSettingApplication, SmsSettingApplication>();
|
||||
|
||||
services.AddTransient<IInstitutionContractSmsServiceRepository, InstitutionContractSmsServiceRepository>();
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.Project
|
||||
public record ProjectBoardListQuery: IBaseQuery<List<ProjectBoardListResponse>>
|
||||
{
|
||||
public long? UserId { get; set; }
|
||||
public string? SearchText { get; set; }
|
||||
public TaskSectionStatus? Status { get; set; }
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using GozareshgirProgramManager.Application._Common.Interfaces;
|
||||
using GozareshgirProgramManager.Application._Common.Models;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query.Internal;
|
||||
|
||||
namespace GozareshgirProgramManager.Application.Modules.Projects.Queries.ProjectBoardList;
|
||||
|
||||
@@ -24,7 +23,8 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
||||
var currentUserId = _authHelper.GetCurrentUserId();
|
||||
|
||||
var queryable = _programManagerDbContext.TaskSections.AsNoTracking()
|
||||
.Where(x => x.InitialEstimatedHours > TimeSpan.Zero && x.Status != TaskSectionStatus.Completed)
|
||||
.Where(x => x.InitialEstimatedHours > TimeSpan.Zero
|
||||
&& x.Status != TaskSectionStatus.Completed)
|
||||
.Include(x => x.Task)
|
||||
.ThenInclude(x => x.Phase)
|
||||
.ThenInclude(x => x.Project)
|
||||
@@ -46,9 +46,17 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
||||
queryable = queryable.Where(x => x.CurrentAssignedUserId == request.UserId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.SearchText))
|
||||
{
|
||||
queryable = queryable.Where(x=>x.Task.Name.Contains(request.SearchText)
|
||||
|| x.Task.Phase.Name.Contains(request.SearchText)
|
||||
|| x.Task.Phase.Project.Name.Contains(request.SearchText));
|
||||
}
|
||||
|
||||
var data = await queryable.ToListAsync(cancellationToken);
|
||||
|
||||
var activityUserIds = data.SelectMany(x => x.Activities).Select(a => a.UserId).Distinct().ToList();
|
||||
var activityUserIds = data.SelectMany(x => x.Activities)
|
||||
.Select(a => a.UserId).Distinct().ToList();
|
||||
var assignedUser = data.Select(x => x.CurrentAssignedUserId)
|
||||
.Concat(data.Select(x => x.OriginalAssignedUserId)).ToList();
|
||||
var allUserIds = activityUserIds.Concat(assignedUser).Distinct().ToList();
|
||||
@@ -72,7 +80,7 @@ public class ProjectBoardListQueryHandler : IBaseQueryHandler<ProjectBoardListQu
|
||||
{
|
||||
Activity = a,
|
||||
TimeSpent = timeSpent,
|
||||
TotalSeconds = timeSpent.TotalSeconds,
|
||||
timeSpent.TotalSeconds,
|
||||
FormattedTime = timeSpent.ToString(@"hh\:mm")
|
||||
};
|
||||
}).ToList();
|
||||
|
||||
@@ -20,7 +20,7 @@ public class ProjectTask : ProjectHierarchyNode
|
||||
{
|
||||
PhaseId = phaseId;
|
||||
_sections = new List<TaskSection>();
|
||||
Priority = ProjectTaskPriority.Medium;
|
||||
Priority = ProjectTaskPriority.Low;
|
||||
AddDomainEvent(new TaskCreatedEvent(Id, phaseId, name));
|
||||
}
|
||||
|
||||
|
||||
59
ServiceHost/Areas/Admin/Controllers/SmsReportController.cs
Normal file
59
ServiceHost/Areas/Admin/Controllers/SmsReportController.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using _0_Framework.Application.Sms;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Controllers;
|
||||
|
||||
public class SmsReportController : AdminBaseController
|
||||
{
|
||||
private readonly ISmsResultApplication _smsResultApplication;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
public SmsReportController(ISmsResultApplication smsResultApplication, ISmsService smsService)
|
||||
{
|
||||
_smsResultApplication = smsResultApplication;
|
||||
_smsService = smsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک ها
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<List<SmsReportDto>> GetSmsReportList(SmsReportSearchModel searchModel)
|
||||
{
|
||||
|
||||
var result =await _smsResultApplication.GetSmsReportList(searchModel);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات هر تاریخ برای اکسپند
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetExpandedList")]
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
|
||||
{
|
||||
var result =await _smsResultApplication.GetSmsReportExpandList(searchModel, date);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// گزارش ای پی آی
|
||||
/// </summary>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="endDate"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetApiReport")]
|
||||
public async Task<List<ApiReportDto>> GetApiReport(string startDate, string endDate)
|
||||
{
|
||||
var result =await _smsService.GetApiReport(startDate, endDate);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1289,7 +1289,7 @@
|
||||
تمدید قرارداد
|
||||
</p>
|
||||
</a>
|
||||
<a permission="30715" class="btn btn-inverse pull-left rad" style="background-color: #f57373;border: 1px solid #f57373;margin-left:5px;"
|
||||
<a class="btn btn-inverse pull-left rad" style="background-color: #f57373;border: 1px solid #f57373;margin-left:5px;"
|
||||
asp-page="./FinancialStatments" asp-route-name="@item.ContractingPartyName" asp-route-id="@item.ContractingPartyId" asp-route-pageNumber="0">
|
||||
<i class="fa fa-file-text-o faSize"></i>
|
||||
<p>
|
||||
|
||||
53
ServiceHost/Areas/Client/Controllers/RewardController.cs
Normal file
53
ServiceHost/Areas/Client/Controllers/RewardController.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Reward;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
|
||||
public class RewardController:ClientBaseController
|
||||
{
|
||||
private readonly IRewardApplication _rewardApplication;
|
||||
private readonly long _workshopId;
|
||||
|
||||
public RewardController(IRewardApplication rewardApplication, IAuthHelper authHelper)
|
||||
{
|
||||
_rewardApplication = rewardApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult<RewardsGroupedViewModel> GetList(RewardSearchModel searchModel)
|
||||
{
|
||||
searchModel.WorkshopId = _workshopId;
|
||||
var res = _rewardApplication.GetSearchListAsGrouped(searchModel);
|
||||
return res;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult<OperationResult> Create(CreateRewardViewModel create)
|
||||
{
|
||||
create.WorkshopId = _workshopId;
|
||||
return _rewardApplication.Create(create);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public ActionResult<OperationResult> Edit(EditRewardViewModel edit)
|
||||
{
|
||||
edit.WorkshopId = _workshopId;
|
||||
return _rewardApplication.Edit(edit);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
public ActionResult<OperationResult> Delete(long id)
|
||||
{
|
||||
return _rewardApplication.Remove(id);
|
||||
}
|
||||
|
||||
[HttpGet("{id:long}")]
|
||||
public ActionResult<EditRewardViewModel> Details(long id)
|
||||
{
|
||||
return _rewardApplication.GetDetails(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers.RollCall;
|
||||
|
||||
public class RollCallCaseHistoryController : ClientBaseController
|
||||
{
|
||||
private readonly IRollCallApplication _rollCallApplication;
|
||||
private readonly long _workshopId;
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly IRollCallEmployeeApplication _rollCallEmployeeApplication;
|
||||
public RollCallCaseHistoryController(IRollCallApplication rollCallApplication,
|
||||
IAuthHelper authHelper, IWorkshopApplication workshopApplication,
|
||||
IRollCallEmployeeApplication rollCallEmployeeApplication)
|
||||
{
|
||||
_rollCallApplication = rollCallApplication;
|
||||
_workshopApplication = workshopApplication;
|
||||
_rollCallEmployeeApplication = rollCallEmployeeApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<PagedResult<RollCallCaseHistoryTitleDto>>> GetTitles(
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryTitles(_workshopId, searchModel);
|
||||
}
|
||||
|
||||
[HttpGet("details")]
|
||||
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetDetails(string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد و ویرایش
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult<OperationResult> Upsert(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
return _rollCallApplication.ManualEdit(command);
|
||||
}
|
||||
|
||||
[HttpGet("print")]
|
||||
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetPrintDetails(string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
[HttpGet("total-working")]
|
||||
public ActionResult<OperationResult<string>> OnGetTotalWorking(
|
||||
string startDate,
|
||||
string startTime,
|
||||
string endDate,
|
||||
string endTime)
|
||||
{
|
||||
var op = new OperationResult<string>();
|
||||
const string emptyValue = "-";
|
||||
|
||||
if (!TryParseDateTime(startDate, startTime, out var start) ||
|
||||
!TryParseDateTime(endDate, endTime, out var end))
|
||||
{
|
||||
return op.Succcedded(emptyValue);
|
||||
}
|
||||
|
||||
if (start >= end)
|
||||
{
|
||||
return op.Succcedded(emptyValue);
|
||||
}
|
||||
|
||||
var duration = (end - start).ToFarsiHoursAndMinutes(emptyValue);
|
||||
return op.Succcedded(duration);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpGet("excel")]
|
||||
public async Task<IActionResult> GetDownload(string titleId, RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
var res =await _rollCallApplication.DownloadCaseHistoryExcel(_workshopId, titleId, searchModel);
|
||||
|
||||
return File(res.Bytes,
|
||||
res.MimeType,
|
||||
res.FileName);
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("edit")]
|
||||
public ActionResult<EditRollCallDetailsResult> GetEditDetails(string date, long employeeId)
|
||||
{
|
||||
var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
|
||||
//var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
|
||||
var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
|
||||
|
||||
var total = new TimeSpan(result.Sum(x =>
|
||||
(x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
|
||||
|
||||
var res = new EditRollCallDetailsResult()
|
||||
{
|
||||
EmployeeFullName = name.EmployeeFullName,
|
||||
EmployeeId = employeeId,
|
||||
DateFa = date,
|
||||
//EditableDates = dates,
|
||||
Records = result.Select(x=>new EmployeeRollCallRecord()
|
||||
{
|
||||
Date = x.DateGr,
|
||||
EndDate = x.EndDateFa,
|
||||
EndTime = x.EndTimeString,
|
||||
RollCallId = x.Id,
|
||||
StartDate = x.StartDateFa,
|
||||
StartTime = x.StartTimeString
|
||||
}).ToList(),
|
||||
TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
|
||||
};
|
||||
|
||||
return res;
|
||||
}
|
||||
[HttpPost("edit")]
|
||||
public ActionResult<OperationResult> Edit(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
var result = _rollCallApplication.ManualEdit(command);
|
||||
return result;
|
||||
}
|
||||
[HttpDelete("delete")]
|
||||
public IActionResult OnPostRemoveEmployeeRollCallsInDate(RemoveEmployeeRollCallRequest request)
|
||||
{
|
||||
var result = _rollCallApplication.RemoveEmployeeRollCallsInDate(_workshopId, request.EmployeeId, request.Date);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
success = result.IsSuccedded,
|
||||
message = result.Message,
|
||||
});
|
||||
}
|
||||
|
||||
// [HttpGet("edit")]
|
||||
// public ActionResult<> GetEditDetails(string date,long employeeId)
|
||||
// {
|
||||
// var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
|
||||
// //var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
|
||||
// var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
|
||||
//
|
||||
// var total = new TimeSpan(result.Sum(x =>
|
||||
// (x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
|
||||
//
|
||||
// var command = new EmployeeRollCallsViewModel()
|
||||
// {
|
||||
// EmployeeFullName = name.EmployeeFullName,
|
||||
// EmployeeId = employeeId,
|
||||
// DateFa = date,
|
||||
// //EditableDates = dates,
|
||||
// RollCalls = result,
|
||||
// TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
|
||||
// };
|
||||
// }
|
||||
|
||||
|
||||
private static bool TryParseDateTime(string date, string time, out DateTime result)
|
||||
{
|
||||
result = default;
|
||||
|
||||
try
|
||||
{
|
||||
var dateTime = date.ToGeorgianDateTime();
|
||||
var timeOnly = TimeOnly.Parse(time);
|
||||
result = dateTime.AddTicks(timeOnly.Ticks);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EditRollCallDetailsResult
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public string DateFa { get; set; }
|
||||
public string TotalRollCallsDuration { get; set; }
|
||||
public List<EmployeeRollCallRecord> Records { get; set; }
|
||||
}
|
||||
|
||||
public class RemoveEmployeeRollCallRequest
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
public string Date { get; set; }
|
||||
}
|
||||
@@ -251,6 +251,8 @@ namespace ServiceHost.Areas.Client.Pages.Company.RollCall
|
||||
var hours = (int)span.TotalHours;
|
||||
var minutes = span.Minutes;
|
||||
|
||||
|
||||
|
||||
if (hours > 0 && minutes > 0)
|
||||
{
|
||||
return new JsonResult(new
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ServiceHost.BaseControllers;
|
||||
|
||||
[Authorize(Policy = "AdminArea")]
|
||||
|
||||
@@ -42,15 +42,6 @@ public class GeneralController : GeneralBaseController
|
||||
currentDate
|
||||
});
|
||||
}
|
||||
[HttpGet("persian-day-of-week")]
|
||||
public ActionResult<OperationResult<string>> OnGetDayOfWeek(string dateFa)
|
||||
{
|
||||
var op = new OperationResult<string>();
|
||||
if (!dateFa.TryToGeorgianDateTime(out DateTime date))
|
||||
return op.Failed("تاریخ وارد شده نامعتبر است");
|
||||
|
||||
return op.Succcedded(date.DayOfWeek.DayOfWeeKToPersian());
|
||||
}
|
||||
|
||||
// [HttpGet("pm-permissions")]
|
||||
// public IActionResult GetPMPermissions()
|
||||
@@ -105,8 +96,44 @@ public class GeneralController : GeneralBaseController
|
||||
var statusCode = isSuccess ? "1" : "0";
|
||||
return $"{baseUrl}/callback?Status={statusCode}&transactionId={transactionId}";
|
||||
}
|
||||
}
|
||||
|
||||
public class TokenReq
|
||||
{
|
||||
public long Amount { get; set; }
|
||||
|
||||
public string CallbackUrl { get; set; }
|
||||
|
||||
[Display(Name = "شماره فاکتور")]
|
||||
[MaxLength(100)]
|
||||
[Required]
|
||||
[Key]
|
||||
// be ezaye har pazirande bayad yekta bashad
|
||||
public string invoiceID { get; set; }
|
||||
|
||||
[Required] public long terminalID { get; set; }
|
||||
|
||||
/*
|
||||
* JSON Bashad
|
||||
* etelaate takmili site harchi
|
||||
* nabayad char khas dashte bashe (*'"xp_%!+- ...)
|
||||
*/
|
||||
public string Payload { get; set; } = "";
|
||||
public string email { get; set; }
|
||||
}
|
||||
|
||||
public class TokenResp
|
||||
{
|
||||
// if 0 = success
|
||||
public int Status { get; set; }
|
||||
public string AccessToken { get; set; }
|
||||
}
|
||||
|
||||
public class PayRequest
|
||||
{
|
||||
[Required] [MaxLength(3000)] public string token { get; set; }
|
||||
[Required] public long terminalID { get; set; }
|
||||
public string nationalCode { get; set; }
|
||||
}
|
||||
|
||||
public class SepehrGatewayPayResponse
|
||||
@@ -143,3 +170,9 @@ public class SepehrGatewayPayResponse
|
||||
|
||||
[Display(Name = " شماره کارت ")] public string cardnumber { get; set; }
|
||||
}
|
||||
|
||||
public class AdviceReq
|
||||
{
|
||||
[Display(Name = " رسید دیجیتال ")] public string digitalreceipt { get; set; }
|
||||
public long Tid { get; set; }
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
"sqlDebugging": true,
|
||||
"dotnetRunMessages": "true",
|
||||
"nativeDebugging": true,
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;https://192.168.0.117:5005",
|
||||
"applicationUrl": "https://localhost:5004;http://localhost:5003;",
|
||||
"jsWebView2Debugging": false,
|
||||
"hotReloadEnabled": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user