Merge branch 'master' into Main
# Conflicts: # Company.Domain/InstitutionContractAgg/IInstitutionContractRepository.cs # CompanyManagment.App.Contracts/InstitutionContract/IInstitutionContractApplication.cs # CompanyManagment.Application/InstitutionContractApplication.cs # CompanyManagment.EFCore/Repository/InstitutionContractRepository.cs
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
namespace _0_Framework.Application.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// وضعیت تایید قرادا مالی
|
||||
/// </summary>
|
||||
public enum InstitutionContractVerificationStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// در انتظار تایید
|
||||
/// </summary>
|
||||
PendingForVerify = 0,
|
||||
|
||||
/// <summary>
|
||||
/// در انتظار کارپوشه
|
||||
/// </summary>
|
||||
PendingWorkflow = 1,
|
||||
|
||||
/// <summary>
|
||||
/// تایید شده
|
||||
/// </summary>
|
||||
Verified = 2
|
||||
}
|
||||
36
0_Framework/Application/Enums/TypeOfSmsSetting.cs
Normal file
36
0_Framework/Application/Enums/TypeOfSmsSetting.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace _0_Framework.Application.Enums;
|
||||
|
||||
public enum TypeOfSmsSetting
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// پیامک
|
||||
/// یادآور بدهی ماهیانه قرارداد مالی
|
||||
/// </summary>
|
||||
InstitutionContractDebtReminder,
|
||||
|
||||
/// <summary>
|
||||
/// پیامک
|
||||
/// صورت حساب ماهانه قرارداد مالی
|
||||
/// </summary>
|
||||
MonthlyInstitutionContract,
|
||||
|
||||
/// <summary>
|
||||
/// پیامک
|
||||
/// اعلام مسدودی طرف حساب
|
||||
/// </summary>
|
||||
BlockContractingParty,
|
||||
|
||||
/// <summary>
|
||||
/// پیامک
|
||||
/// هشدار اول
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
|
||||
/// <summary>
|
||||
///پیامک اقدام قضائی
|
||||
/// </summary>
|
||||
LegalAction,
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class AqayePardakhtPaymentGateway:IPaymentGateway
|
||||
amount = command.Amount,
|
||||
callback = command.CallBackUrl,
|
||||
card_number = command.CardNumber,
|
||||
invoice_id = command.InvoiceId,
|
||||
invoice_id = command.TransactionId,
|
||||
mobile = command.Mobile,
|
||||
email = command.Email??"",
|
||||
description = command.Description,
|
||||
@@ -73,7 +73,7 @@ public class AqayePardakhtPaymentGateway:IPaymentGateway
|
||||
amount = command.Amount,
|
||||
callback = command.CallBackUrl,
|
||||
card_number = command.Amount,
|
||||
invoice_id = command.InvoiceId,
|
||||
invoice_id = command.TransactionId,
|
||||
mobile = command.Mobile,
|
||||
email = command.Email,
|
||||
description = command.Email,
|
||||
|
||||
@@ -49,12 +49,13 @@ public class WalletAmountResponse
|
||||
public class CreatePaymentGatewayRequest
|
||||
{
|
||||
public double Amount { get; set; }
|
||||
public string TransactionId { get; set; }
|
||||
public string CallBackUrl { get; set; }
|
||||
public string InvoiceId { get; set; }
|
||||
public string CardNumber { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Description { get; set; }
|
||||
public long FinancialInvoiceId { get; set; }
|
||||
public IDictionary<string, object> ExtraData { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading;
|
||||
@@ -16,18 +17,18 @@ public class SepehrPaymentGateway:IPaymentGateway
|
||||
{
|
||||
_httpClient = httpClient.CreateClient();
|
||||
_httpClient.BaseAddress = new Uri("https://sepehr.shaparak.ir/Rest/V1/PeymentApi/");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<PaymentGatewayResponse> Create(CreatePaymentGatewayRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
command.ExtraData ??= new Dictionary<string, object>();
|
||||
command.ExtraData.Add("financialInvoiceId", command.FinancialInvoiceId);
|
||||
var extraData = JsonConvert.SerializeObject(command.ExtraData);
|
||||
var res = await _httpClient.PostAsJsonAsync("GetToken", new
|
||||
{
|
||||
TerminalID = TerminalId,
|
||||
Amount = command.Amount,
|
||||
InvoiceID = command.InvoiceId,
|
||||
InvoiceID = command.TransactionId,
|
||||
callbackURL = command.CallBackUrl,
|
||||
payload = extraData
|
||||
}, cancellationToken: cancellationToken);
|
||||
|
||||
@@ -33,6 +33,60 @@ public interface ISmsService
|
||||
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
|
||||
long contractingPartyId, long institutionContractId);
|
||||
|
||||
SmsResult TaskReminderSms(string number, string taskCount);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region InstitutionContractSMS
|
||||
/// <summary>
|
||||
/// پیامک اهانه جدید
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="tamplateId"></param>
|
||||
/// <param name="fullname"></param>
|
||||
/// <param name="amount"></param>
|
||||
/// <param name="code1"></param>
|
||||
/// <param name="code2"></param>
|
||||
/// <returns></returns>
|
||||
Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBillNew(string number, int tamplateId, string fullname, string amount, string code1,
|
||||
string code2);
|
||||
/// <summary>
|
||||
/// پیامک ماهانه قدیم
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="tamplateId"></param>
|
||||
/// <param name="fullname"></param>
|
||||
/// <param name="amount"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="aprove"></param>
|
||||
/// <returns></returns>
|
||||
Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBill(string number, int tamplateId, string fullname, string amount, string id, string aprove);
|
||||
|
||||
/// <summary>
|
||||
/// پیامک مسدودی طرف حساب
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="fullname"></param>
|
||||
/// <param name="amount"></param>
|
||||
/// <param name="accountType"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="aprove"></param>
|
||||
/// <returns></returns>
|
||||
Task<(byte status, string message, int messaeId, bool isSucceded)> BlockMessage(string number, string fullname, string amount, string accountType, string id, string aprove);
|
||||
|
||||
#endregion
|
||||
|
||||
#region AlarmMessage
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک های خطا یا اعمال ارسال
|
||||
/// </summary>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Alarm(string number, string message);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
32
0_Framework/Application/Sms/SmsResult.cs
Normal file
32
0_Framework/Application/Sms/SmsResult.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace _0_Framework.Application.Sms;
|
||||
|
||||
public class SmsResult
|
||||
{
|
||||
public SmsResult()
|
||||
{
|
||||
IsSuccedded = false;
|
||||
}
|
||||
|
||||
public bool IsSuccedded { get; set; }
|
||||
public string Message { get; set; }
|
||||
public byte StatusCode { get; set; }
|
||||
public int MessageId { get; set; }
|
||||
|
||||
public SmsResult Succedded(byte statusCode, string message, int messageId)
|
||||
{
|
||||
IsSuccedded = true;
|
||||
Message = message;
|
||||
StatusCode = statusCode;
|
||||
MessageId = messageId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SmsResult Failed(byte statusCode, string message, int messageId)
|
||||
{
|
||||
IsSuccedded = false;
|
||||
Message = message;
|
||||
StatusCode = statusCode;
|
||||
MessageId = messageId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<AssemblyName>BackgroundInstitutionContract.Task</AssemblyName>
|
||||
<RootNamespace>BackgroundInstitutionContract.Task</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\0_Framework\0_Framework.csproj" />
|
||||
<ProjectReference Include="..\..\AccountManagement.Configuration\AccountManagement.Configuration.csproj" />
|
||||
<ProjectReference Include="..\..\PersonalContractingParty.Config\PersonalContractingParty.Config.csproj" />
|
||||
<ProjectReference Include="..\..\Query.Bootstrapper\Query.Bootstrapper.csproj" />
|
||||
<ProjectReference Include="..\..\WorkFlow\Infrastructure\WorkFlow.Infrastructure.Config\WorkFlow.Infrastructure.Config.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,32 @@
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace BackgroundInstitutionContract.Task
|
||||
{
|
||||
public class FileUploader : IFileUploader
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
|
||||
public FileUploader(IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
}
|
||||
|
||||
public string Upload(IFormFile file, string path)
|
||||
{
|
||||
if (file == null) return "";
|
||||
|
||||
var directoryPath = $"{_webHostEnvironment.WebRootPath}\\ProductPictures\\{path}";
|
||||
|
||||
if (!Directory.Exists(directoryPath))
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
var fileName = $"{DateTime.Now.ToFileName()}-{file.FileName}";
|
||||
var filePath = $"{directoryPath}\\{fileName}";
|
||||
var output = System.IO.File.Create(filePath);
|
||||
file.CopyTo(output);
|
||||
return $"{path}/{fileName}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.ContarctingPartyAgg;
|
||||
using Company.Domain.InstitutionContractAgg;
|
||||
using Hangfire;
|
||||
|
||||
namespace BackgroundInstitutionContract.Task.Jobs;
|
||||
|
||||
public class JobSchedulerRegistrator
|
||||
{
|
||||
private readonly IBackgroundJobClient _backgroundJobClient;
|
||||
private readonly SmsReminder _smsReminder;
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private static DateTime? _lastRunCreateTransaction;
|
||||
private static DateTime? _lastRunSendMonthlySms;
|
||||
|
||||
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository)
|
||||
{
|
||||
_smsReminder = smsReminder;
|
||||
_backgroundJobClient = backgroundJobClient;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
}
|
||||
|
||||
public void Register()
|
||||
{
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.CreateFinancialTransaction",
|
||||
// () => CreateFinancialTransaction(),
|
||||
// "*/30 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
//);
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.SendMonthlySms",
|
||||
// () => SendMonthlySms(),
|
||||
// "*/20 * * * *" // هر 30 دقیقه یکبار چک کن
|
||||
//);
|
||||
|
||||
//RecurringJob.AddOrUpdate(
|
||||
// "InstitutionContract.SendReminderSms",
|
||||
// () => SendReminderSms(),
|
||||
// "*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
//);
|
||||
RecurringJob.AddOrUpdate(
|
||||
"InstitutionContract.SendBlockSms",
|
||||
() => SendBlockSms(),
|
||||
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد سند بدهی ماهیانه برای قراداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 1200)]
|
||||
public async System.Threading.Tasks.Task CreateFinancialTransaction()
|
||||
{
|
||||
var now =DateTime.Now;
|
||||
var endOfMonth = now.ToFarsi().FindeEndOfMonth();
|
||||
var endOfMonthGr = endOfMonth.ToGeorgianDateTime();
|
||||
|
||||
if (now.Date == endOfMonthGr.Date && now.Hour >= 2 && now.Hour < 4 &&
|
||||
now.Date != _lastRunCreateTransaction?.Date)
|
||||
{
|
||||
|
||||
var month = endOfMonth.Substring(5, 2);
|
||||
var year = endOfMonth.Substring(0, 4);
|
||||
var monthName = month.ToFarsiMonthByNumber();
|
||||
var description = $"{monthName} {year}";
|
||||
|
||||
|
||||
|
||||
var endnew = ($"{endOfMonth.Substring(0, 8)}01").FindeEndOfMonth();
|
||||
|
||||
var endNewGr = endnew.ToGeorgianDateTime();
|
||||
var endNewFa = endNewGr.ToFarsi();
|
||||
|
||||
try
|
||||
{
|
||||
await _institutionContractRepository.CreateTransactionForInstitutionContracts(endNewGr, endNewFa, description);
|
||||
_lastRunCreateTransaction = now;
|
||||
Console.WriteLine("CreateTransAction executed");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//_smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک صورت حساب ماهانه
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 1000)]
|
||||
public async System.Threading.Tasks.Task SendMonthlySms()
|
||||
{
|
||||
//var now = new DateTime(2025,11,21, 10,30,0);
|
||||
var now = DateTime.Now;
|
||||
var endOfMonth = now.ToFarsi().FindeEndOfMonth();
|
||||
var endOfMonthGr = endOfMonth.ToGeorgianDateTime();
|
||||
|
||||
if (now.Date == endOfMonthGr.Date && now.Hour >= 10 && now.Hour < 11 &&
|
||||
now.Date != _lastRunSendMonthlySms?.Date)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
await _institutionContractRepository.SendMonthlySms(now);
|
||||
_lastRunSendMonthlySms = now;
|
||||
Console.WriteLine("Send Monthly sms executed");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//_smsService.Alarm("09114221321", "خطا-ایجاد سند مالی");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک یاد آور بدهی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 1200)]
|
||||
public async System.Threading.Tasks.Task SendReminderSms()
|
||||
{
|
||||
await _institutionContractRepository.SendReminderSmsForBackgroundTask();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DisableConcurrentExecution(timeoutInSeconds: 100)]
|
||||
public async System.Threading.Tasks.Task SendBlockSms()
|
||||
{
|
||||
await _institutionContractRepository.SendBlockSmsForBackgroundTask();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using _0_Framework.Application.Sms;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SmsResult = Company.Domain.SmsResultAgg.SmsResult;
|
||||
|
||||
namespace BackgroundInstitutionContract.Task.Jobs;
|
||||
public class SmsReminder
|
||||
{
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
|
||||
public SmsReminder(ISmsService smsService, AccountContext accountContext, ISmsResultRepository smsResultRepository)
|
||||
{
|
||||
_smsService = smsService;
|
||||
_accountContext = accountContext;
|
||||
_smsResultRepository = smsResultRepository;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
//var accounts = _accountContext.Accounts.Where(x => x.PositionId > 0 && x.IsActiveString == "true").Select(x => new AccountViewModel() { Id = x.id, Mobile = x.Mobile, Fullname = x.Fullname }).ToList();
|
||||
//Thread.Sleep(300);
|
||||
//var accounts = new List<AccountViewModel>() { new AccountViewModel() { Mobile = "09114221321", Id = 2 } };
|
||||
var accounts= _accountContext.Accounts.Where(x => x.Username.ToLower()=="mahan").Select(x => new AccountViewModel() { Id = x.id, Mobile = x.Mobile, Fullname = x.Fullname }).ToList();
|
||||
var smsVM = accounts.Select(x => new AccountSmsTaskViewModel()
|
||||
{
|
||||
Mobile = x.Mobile,
|
||||
AccountId = x.Id,
|
||||
FullName = x.Fullname,
|
||||
TaskCount = GetLateTasksCount(x.Id)
|
||||
}).Where(x => x.TaskCount > 0 && !string.IsNullOrEmpty(x.Mobile) && x.Mobile.Length == 11).ToList();
|
||||
Thread.Sleep(300);
|
||||
|
||||
|
||||
foreach (var viewmodel in smsVM)
|
||||
{
|
||||
var smsResult = _smsService.TaskReminderSms(viewmodel.Mobile, $"{viewmodel.TaskCount}");
|
||||
Thread.Sleep(1000);
|
||||
var createSmsResult = new SmsResult(smsResult.MessageId, smsResult.Message, "یادآور وظایف",
|
||||
viewmodel.FullName, viewmodel.Mobile, viewmodel.AccountId, viewmodel.AccountId);
|
||||
_smsResultRepository.Create(createSmsResult);
|
||||
_smsResultRepository.SaveChanges();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
private int GetLateTasksCount(long accountId)
|
||||
{
|
||||
var positionValue = _accountContext.Accounts
|
||||
.Where(x => x.id == accountId)
|
||||
.Include(p => p.Position)
|
||||
.Select(x => x.Position.PositionValue)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (positionValue == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
int overdueTasksCount;
|
||||
|
||||
if (positionValue == 1)
|
||||
{
|
||||
overdueTasksCount = _accountContext.Assigns.Include(x => x.Task).Where(x => x.AssignedId == accountId &&
|
||||
x.AssignerId == accountId && x.Task.Assigns.Count == 1 &&
|
||||
!x.IsCancel && !x.IsCanceledRequest &&
|
||||
!x.IsDone && !x.TimeRequest && !x.IsDoneRequest && x.EndTaskDate.Date <= DateTime.Now.Date && x.Task.IsActiveString == "true")
|
||||
.GroupBy(x => x.TaskId).Select(x => x.First()).Count();
|
||||
|
||||
//overdueTasksCount = _accountContext.Tasks.Include(x =>
|
||||
// x.Assigns).Count(x => !x.Assigns.Any(a => a.IsCancel) && !x.Assigns.Any(a => a.IsCanceledRequest) &&
|
||||
// !x.Assigns.Any(a => a.IsDone) && !x.Assigns.Any(a => a.IsDoneRequest) &&
|
||||
// !x.Assigns.Any(a => a.TimeRequest)
|
||||
// && x.Assigns.Any(a => a.AssignedId == accountId && a.AssignerId == accountId) &&
|
||||
// (x.Assigns.First(a => a.AssignedId == accountId && a.AssignerId == accountId)
|
||||
// .EndTaskDate.Date <= DateTime.Now.Date) && x.Assigns.Count == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
overdueTasksCount = _accountContext.Assigns
|
||||
.Include(x => x.Task)
|
||||
.Where(x => x.AssignedId == accountId &&
|
||||
!x.IsCancel && !x.IsCanceledRequest &&
|
||||
!x.IsDone && !x.TimeRequest && !x.IsDoneRequest && x.EndTaskDate.Date <= DateTime.Now.Date && x.Task.IsActiveString == "true")
|
||||
.GroupBy(x => x.TaskId).Select(x => x.First()).Count();
|
||||
}
|
||||
|
||||
|
||||
//overdueTasksCount = _accountContext.Tasks.Include(x =>
|
||||
// x.Assigns).Count(x => !x.Assigns.Any(a => a.IsCancel) && !x.Assigns.Any(a => a.IsCanceledRequest) &&
|
||||
// !x.Assigns.Any(a => a.IsDone) && !x.Assigns.Any(a => a.IsDoneRequest) &&
|
||||
// !x.Assigns.Any(a => a.TimeRequest)
|
||||
// && x.Assigns.Any(a => a.AssignedId == accountId) &&
|
||||
// (x.Assigns.First(a => a.AssignedId == accountId).EndTaskDate.Date <= DateTime.Now.Date));
|
||||
|
||||
|
||||
var overdueRequestsCount = _accountContext.Assigns.Include(x => x.Task)
|
||||
.Where(x => (x.IsCanceledRequest
|
||||
|| x.IsDoneRequest || x.TimeRequest) && !x.IsCancel && !x.IsDone &&
|
||||
x.Task.IsActiveString == "true" &&
|
||||
x.Task.SenderId == accountId).GroupBy(x => x.TaskId).Select(x => x.First()).Count();
|
||||
|
||||
return overdueTasksCount + overdueRequestsCount;
|
||||
}
|
||||
|
||||
}
|
||||
public class AccountSmsTaskViewModel
|
||||
{
|
||||
public int TaskCount { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using BackgroundInstitutionContract.Task.Jobs;
|
||||
|
||||
|
||||
namespace BackgroundInstitutionContract.Task;
|
||||
|
||||
public class JobsBootstrapper
|
||||
{
|
||||
public static void Configure(IServiceCollection services)
|
||||
{
|
||||
var currentNamespace = typeof(JobSchedulerRegistrator).Namespace; // همون namespace کلاس
|
||||
|
||||
var assembly = typeof(JobSchedulerRegistrator).Assembly;
|
||||
|
||||
var jobTypes = assembly.GetTypes()
|
||||
.Where(t =>
|
||||
t is { IsClass: true, IsAbstract: false, Namespace: not null } &&
|
||||
t.Namespace.StartsWith(currentNamespace, StringComparison.Ordinal))
|
||||
.ToList();
|
||||
|
||||
foreach (var jobType in jobTypes)
|
||||
{
|
||||
services.AddTransient(jobType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Application.UID;
|
||||
using _0_Framework.InfraStructure.Mongo;
|
||||
using AccountManagement.Configuration;
|
||||
using BackgroundInstitutionContract.Task;
|
||||
using BackgroundInstitutionContract.Task.Jobs;
|
||||
using CompanyManagment.EFCore.Services;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using MongoDB.Driver;
|
||||
using PersonalContractingParty.Config;
|
||||
using Query.Bootstrapper;
|
||||
using WorkFlow.Infrastructure.Config;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var hangfireConnectionString = builder.Configuration.GetConnectionString("HangfireDb");
|
||||
builder.Services.AddHangfire(x => x.UseSqlServerStorage(hangfireConnectionString));
|
||||
builder.Services.AddHangfireServer();
|
||||
var connectionString = builder.Configuration.GetConnectionString("MesbahDb");
|
||||
var connectionStringTestDb = builder.Configuration.GetConnectionString("TestDb");
|
||||
builder.Services.AddSingleton<IPasswordHasher, PasswordHasher>();
|
||||
builder.Services.AddTransient<IAuthHelper, AuthHelper>();
|
||||
builder.Services.AddTransient<ISmsService, SmsService>();
|
||||
builder.Services.AddTransient<IUidService, UidService>();
|
||||
builder.Services.AddTransient<IFileUploader, FileUploader>();
|
||||
builder.Services.Configure<AppSettingConfiguration>(builder.Configuration);
|
||||
|
||||
#region MongoDb
|
||||
|
||||
var mongoConnectionSection = builder.Configuration.GetSection("MongoDb");
|
||||
var mongoDbSettings = mongoConnectionSection.Get<MongoDbConfig>();
|
||||
var mongoClient = new MongoClient(mongoDbSettings.ConnectionString);
|
||||
var mongoDatabase = mongoClient.GetDatabase(mongoDbSettings.DatabaseName);
|
||||
|
||||
builder.Services.AddSingleton<IMongoDatabase>(mongoDatabase);
|
||||
|
||||
#endregion
|
||||
|
||||
PersonalBootstrapper.Configure(builder.Services, connectionString);
|
||||
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
|
||||
AccountManagementBootstrapper.Configure(builder.Services, connectionString);
|
||||
WorkFlowBootstrapper.Configure(builder.Services, connectionString);
|
||||
QueryBootstrapper.Configure(builder.Services);
|
||||
JobsBootstrapper.Configure(builder.Services);
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapHangfireDashboard();
|
||||
app.MapGet("/", () => "Hello World!");
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var jobScheduler = scope.ServiceProvider.GetRequiredService<JobSchedulerRegistrator>();
|
||||
jobScheduler.Register();
|
||||
}
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:56492",
|
||||
"sslPort": 44378
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5216",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7223;http://localhost:5217",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
//تست
|
||||
//"MesbahDb": "Data Source=DESKTOP-NUE119G\\MSNEW;Initial Catalog=Mesbah_db;Integrated Security=True"
|
||||
|
||||
//server
|
||||
//"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;",
|
||||
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//dad-mehr
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=teamWork;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//mahan Docker
|
||||
//"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;",
|
||||
"HangfireDb": "Data Source=.;Initial Catalog=hangfire_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
},
|
||||
|
||||
"GoogleRecaptchaV3": {
|
||||
"SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH",
|
||||
"SecretKey": "6Lfhp_AnAAAAANjDDY6DPrbbUQS7k6ZCRmrVP5Lb"
|
||||
},
|
||||
"SmsSecrets": {
|
||||
"ApiKey": "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa",
|
||||
"SecretKey": "dadmehr"
|
||||
},
|
||||
"Domain": ".gozareshgir.ir",
|
||||
"MongoDb": {
|
||||
"ConnectionString": "mongodb://localhost:27017",
|
||||
"DatabaseName": "Gozareshgir"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\0_Framework\0_Framework.csproj" />
|
||||
<ProjectReference Include="..\..\AccountManagement.Configuration\AccountManagement.Configuration.csproj" />
|
||||
<ProjectReference Include="..\..\PersonalContractingParty.Config\PersonalContractingParty.Config.csproj" />
|
||||
<ProjectReference Include="..\..\Query.Bootstrapper\Query.Bootstrapper.csproj" />
|
||||
<ProjectReference Include="..\..\WorkFlow\Infrastructure\WorkFlow.Infrastructure.Config\WorkFlow.Infrastructure.Config.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
32
BackgroundJobs/BackgroundJobs.Task/FileUploader.cs
Normal file
32
BackgroundJobs/BackgroundJobs.Task/FileUploader.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace BackgroundJobs.Task
|
||||
{
|
||||
public class FileUploader : IFileUploader
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
|
||||
public FileUploader(IWebHostEnvironment webHostEnvironment)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
}
|
||||
|
||||
public string Upload(IFormFile file, string path)
|
||||
{
|
||||
if (file == null) return "";
|
||||
|
||||
var directoryPath = $"{_webHostEnvironment.WebRootPath}\\ProductPictures\\{path}";
|
||||
|
||||
if (!Directory.Exists(directoryPath))
|
||||
Directory.CreateDirectory(directoryPath);
|
||||
|
||||
var fileName = $"{DateTime.Now.ToFileName()}-{file.FileName}";
|
||||
var filePath = $"{directoryPath}\\{fileName}";
|
||||
var output = System.IO.File.Create(filePath);
|
||||
file.CopyTo(output);
|
||||
return $"{path}/{fileName}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Hangfire;
|
||||
|
||||
namespace BackgroundJobs.Task.Jobs;
|
||||
|
||||
public class JobSchedulerRegistrator
|
||||
{
|
||||
private readonly IBackgroundJobClient _backgroundJobClient;
|
||||
private readonly SmsReminder _smsReminder;
|
||||
private static DateTime? _lastRunDateMorning;
|
||||
private static DateTime? _lastRunDateEvening;
|
||||
|
||||
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient)
|
||||
{
|
||||
_smsReminder = smsReminder;
|
||||
_backgroundJobClient = backgroundJobClient;
|
||||
}
|
||||
|
||||
public void Register()
|
||||
{
|
||||
RecurringJob.AddOrUpdate(
|
||||
"Task.SmsReminderChecker",
|
||||
() => SmsReminderCheckAndSchedule(),
|
||||
"*/5 * * * *" // هر 5 دقیقه یکبار چک کن
|
||||
);
|
||||
}
|
||||
|
||||
public void SmsReminderCheckAndSchedule()
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
var startMorning = new TimeSpan(9, 0, 0);
|
||||
var endMorning = new TimeSpan(9, 40, 0);
|
||||
|
||||
var startEvening = new TimeSpan(15, 30, 0);
|
||||
var endEvening = new TimeSpan(15, 40, 0);
|
||||
|
||||
// صبح
|
||||
if (now.DayOfWeek != DayOfWeek.Friday &&
|
||||
now.TimeOfDay >= startMorning &&
|
||||
now.TimeOfDay < endMorning)
|
||||
{
|
||||
if (_lastRunDateMorning?.Date != now.Date)
|
||||
{
|
||||
_backgroundJobClient.Enqueue(() => _smsReminder.Execute());
|
||||
_lastRunDateMorning = now;
|
||||
}
|
||||
}
|
||||
|
||||
// عصر - پنجشنبه و جمعه تعطیل است
|
||||
if (now.DayOfWeek != DayOfWeek.Friday &&
|
||||
now.DayOfWeek != DayOfWeek.Thursday &&
|
||||
now.TimeOfDay >= startEvening &&
|
||||
now.TimeOfDay < endEvening)
|
||||
{
|
||||
if (_lastRunDateEvening?.Date != now.Date)
|
||||
{
|
||||
_backgroundJobClient.Enqueue(() => _smsReminder.Execute());
|
||||
_lastRunDateEvening = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
116
BackgroundJobs/BackgroundJobs.Task/Jobs/SmsReminder.cs
Normal file
116
BackgroundJobs/BackgroundJobs.Task/Jobs/SmsReminder.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using _0_Framework.Application.Sms;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
using AccountMangement.Infrastructure.EFCore;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SmsResult = Company.Domain.SmsResultAgg.SmsResult;
|
||||
|
||||
namespace BackgroundJobs.Task.Jobs;
|
||||
public class SmsReminder
|
||||
{
|
||||
private readonly AccountContext _accountContext;
|
||||
private readonly ISmsService _smsService;
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
|
||||
public SmsReminder(ISmsService smsService, AccountContext accountContext, ISmsResultRepository smsResultRepository)
|
||||
{
|
||||
_smsService = smsService;
|
||||
_accountContext = accountContext;
|
||||
_smsResultRepository = smsResultRepository;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
//var accounts = _accountContext.Accounts.Where(x => x.PositionId > 0 && x.IsActiveString == "true").Select(x => new AccountViewModel() { Id = x.id, Mobile = x.Mobile, Fullname = x.Fullname }).ToList();
|
||||
//Thread.Sleep(300);
|
||||
//var accounts = new List<AccountViewModel>() { new AccountViewModel() { Mobile = "09114221321", Id = 2 } };
|
||||
var accounts= _accountContext.Accounts.Where(x => x.Username.ToLower()=="mahan").Select(x => new AccountViewModel() { Id = x.id, Mobile = x.Mobile, Fullname = x.Fullname }).ToList();
|
||||
var smsVM = accounts.Select(x => new AccountSmsTaskViewModel()
|
||||
{
|
||||
Mobile = x.Mobile,
|
||||
AccountId = x.Id,
|
||||
FullName = x.Fullname,
|
||||
TaskCount = GetLateTasksCount(x.Id)
|
||||
}).Where(x => x.TaskCount > 0 && !string.IsNullOrEmpty(x.Mobile) && x.Mobile.Length == 11).ToList();
|
||||
Thread.Sleep(300);
|
||||
|
||||
|
||||
foreach (var viewmodel in smsVM)
|
||||
{
|
||||
var smsResult = _smsService.TaskReminderSms(viewmodel.Mobile, $"{viewmodel.TaskCount}");
|
||||
Thread.Sleep(1000);
|
||||
var createSmsResult = new SmsResult(smsResult.MessageId, smsResult.Message, "یادآور وظایف",
|
||||
viewmodel.FullName, viewmodel.Mobile, viewmodel.AccountId, viewmodel.AccountId);
|
||||
_smsResultRepository.Create(createSmsResult);
|
||||
_smsResultRepository.SaveChanges();
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
}
|
||||
private int GetLateTasksCount(long accountId)
|
||||
{
|
||||
var positionValue = _accountContext.Accounts
|
||||
.Where(x => x.id == accountId)
|
||||
.Include(p => p.Position)
|
||||
.Select(x => x.Position.PositionValue)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (positionValue == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
int overdueTasksCount;
|
||||
|
||||
if (positionValue == 1)
|
||||
{
|
||||
overdueTasksCount = _accountContext.Assigns.Include(x => x.Task).Where(x => x.AssignedId == accountId &&
|
||||
x.AssignerId == accountId && x.Task.Assigns.Count == 1 &&
|
||||
!x.IsCancel && !x.IsCanceledRequest &&
|
||||
!x.IsDone && !x.TimeRequest && !x.IsDoneRequest && x.EndTaskDate.Date <= DateTime.Now.Date && x.Task.IsActiveString == "true")
|
||||
.GroupBy(x => x.TaskId).Select(x => x.First()).Count();
|
||||
|
||||
//overdueTasksCount = _accountContext.Tasks.Include(x =>
|
||||
// x.Assigns).Count(x => !x.Assigns.Any(a => a.IsCancel) && !x.Assigns.Any(a => a.IsCanceledRequest) &&
|
||||
// !x.Assigns.Any(a => a.IsDone) && !x.Assigns.Any(a => a.IsDoneRequest) &&
|
||||
// !x.Assigns.Any(a => a.TimeRequest)
|
||||
// && x.Assigns.Any(a => a.AssignedId == accountId && a.AssignerId == accountId) &&
|
||||
// (x.Assigns.First(a => a.AssignedId == accountId && a.AssignerId == accountId)
|
||||
// .EndTaskDate.Date <= DateTime.Now.Date) && x.Assigns.Count == 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
overdueTasksCount = _accountContext.Assigns
|
||||
.Include(x => x.Task)
|
||||
.Where(x => x.AssignedId == accountId &&
|
||||
!x.IsCancel && !x.IsCanceledRequest &&
|
||||
!x.IsDone && !x.TimeRequest && !x.IsDoneRequest && x.EndTaskDate.Date <= DateTime.Now.Date && x.Task.IsActiveString == "true")
|
||||
.GroupBy(x => x.TaskId).Select(x => x.First()).Count();
|
||||
}
|
||||
|
||||
|
||||
//overdueTasksCount = _accountContext.Tasks.Include(x =>
|
||||
// x.Assigns).Count(x => !x.Assigns.Any(a => a.IsCancel) && !x.Assigns.Any(a => a.IsCanceledRequest) &&
|
||||
// !x.Assigns.Any(a => a.IsDone) && !x.Assigns.Any(a => a.IsDoneRequest) &&
|
||||
// !x.Assigns.Any(a => a.TimeRequest)
|
||||
// && x.Assigns.Any(a => a.AssignedId == accountId) &&
|
||||
// (x.Assigns.First(a => a.AssignedId == accountId).EndTaskDate.Date <= DateTime.Now.Date));
|
||||
|
||||
|
||||
var overdueRequestsCount = _accountContext.Assigns.Include(x => x.Task)
|
||||
.Where(x => (x.IsCanceledRequest
|
||||
|| x.IsDoneRequest || x.TimeRequest) && !x.IsCancel && !x.IsDone &&
|
||||
x.Task.IsActiveString == "true" &&
|
||||
x.Task.SenderId == accountId).GroupBy(x => x.TaskId).Select(x => x.First()).Count();
|
||||
|
||||
return overdueTasksCount + overdueRequestsCount;
|
||||
}
|
||||
|
||||
}
|
||||
public class AccountSmsTaskViewModel
|
||||
{
|
||||
public int TaskCount { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public string Mobile { get; set; }
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
24
BackgroundJobs/BackgroundJobs.Task/JobsBootstrapper.cs
Normal file
24
BackgroundJobs/BackgroundJobs.Task/JobsBootstrapper.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using BackgroundJobs.Task.Jobs;
|
||||
|
||||
namespace BackgroundJobs.Task;
|
||||
|
||||
public class JobsBootstrapper
|
||||
{
|
||||
public static void Configure(IServiceCollection services)
|
||||
{
|
||||
var currentNamespace = typeof(JobSchedulerRegistrator).Namespace; // همون namespace کلاس
|
||||
|
||||
var assembly = typeof(JobSchedulerRegistrator).Assembly;
|
||||
|
||||
var jobTypes = assembly.GetTypes()
|
||||
.Where(t =>
|
||||
t is { IsClass: true, IsAbstract: false, Namespace: not null } &&
|
||||
t.Namespace.StartsWith(currentNamespace, StringComparison.Ordinal))
|
||||
.ToList();
|
||||
|
||||
foreach (var jobType in jobTypes)
|
||||
{
|
||||
services.AddTransient(jobType);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
BackgroundJobs/BackgroundJobs.Task/Program.cs
Normal file
59
BackgroundJobs/BackgroundJobs.Task/Program.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Application.UID;
|
||||
using _0_Framework.InfraStructure.Mongo;
|
||||
using AccountManagement.Configuration;
|
||||
using BackgroundJobs.Task;
|
||||
using BackgroundJobs.Task.Jobs;
|
||||
using CompanyManagment.EFCore.Services;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using MongoDB.Driver;
|
||||
using PersonalContractingParty.Config;
|
||||
using Query.Bootstrapper;
|
||||
using WorkFlow.Infrastructure.Config;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var hangfireConnectionString = builder.Configuration.GetConnectionString("HangfireDb");
|
||||
builder.Services.AddHangfire(x => x.UseSqlServerStorage(hangfireConnectionString));
|
||||
builder.Services.AddHangfireServer();
|
||||
var connectionString = builder.Configuration.GetConnectionString("MesbahDb");
|
||||
var connectionStringTestDb = builder.Configuration.GetConnectionString("TestDb");
|
||||
builder.Services.AddSingleton<IPasswordHasher, PasswordHasher>();
|
||||
builder.Services.AddTransient<IAuthHelper, AuthHelper>();
|
||||
builder.Services.AddTransient<ISmsService, SmsService>();
|
||||
builder.Services.AddTransient<IUidService, UidService>();
|
||||
builder.Services.AddTransient<IFileUploader, FileUploader>();
|
||||
builder.Services.Configure<AppSettingConfiguration>(builder.Configuration);
|
||||
|
||||
#region MongoDb
|
||||
|
||||
var mongoConnectionSection = builder.Configuration.GetSection("MongoDb");
|
||||
var mongoDbSettings = mongoConnectionSection.Get<MongoDbConfig>();
|
||||
var mongoClient = new MongoClient(mongoDbSettings.ConnectionString);
|
||||
var mongoDatabase = mongoClient.GetDatabase(mongoDbSettings.DatabaseName);
|
||||
|
||||
builder.Services.AddSingleton<IMongoDatabase>(mongoDatabase);
|
||||
|
||||
#endregion
|
||||
|
||||
PersonalBootstrapper.Configure(builder.Services, connectionString);
|
||||
TestDbBootStrapper.Configure(builder.Services, connectionStringTestDb);
|
||||
AccountManagementBootstrapper.Configure(builder.Services, connectionString);
|
||||
WorkFlowBootstrapper.Configure(builder.Services, connectionString);
|
||||
QueryBootstrapper.Configure(builder.Services);
|
||||
JobsBootstrapper.Configure(builder.Services);
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapHangfireDashboard();
|
||||
app.MapGet("/", () => "Hello World!");
|
||||
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var jobScheduler = scope.ServiceProvider.GetRequiredService<JobSchedulerRegistrator>();
|
||||
jobScheduler.Register();
|
||||
}
|
||||
|
||||
app.Run();
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:56492",
|
||||
"sslPort": 44378
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5216",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7222;http://localhost:5216",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"DetailedErrors": true,
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
//تست
|
||||
//"MesbahDb": "Data Source=DESKTOP-NUE119G\\MSNEW;Initial Catalog=Mesbah_db;Integrated Security=True"
|
||||
|
||||
//server
|
||||
//"MesbahDb": "Data Source=171.22.24.15;Initial Catalog=mesbah_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;",
|
||||
|
||||
|
||||
//local
|
||||
"MesbahDb": "Data Source=.;Initial Catalog=mesbah_db;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//dad-mehr
|
||||
//"MesbahDb": "Data Source=.;Initial Catalog=teamWork;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
"TestDb": "Data Source=.;Initial Catalog=TestDb;Integrated Security=True;TrustServerCertificate=true;",
|
||||
|
||||
//mahan Docker
|
||||
//"MesbahDb": "Data Source=localhost,5069;Initial Catalog=mesbah_db;User ID=sa;Password=YourPassword123;TrustServerCertificate=True;",
|
||||
"HangfireDb": "Data Source=.;Initial Catalog=hangfire_db;Integrated Security=True;TrustServerCertificate=true;"
|
||||
},
|
||||
|
||||
"GoogleRecaptchaV3": {
|
||||
"SiteKey": "6Lfhp_AnAAAAAB79WkrMoHd1k8ir4m8VvfjE7FTH",
|
||||
"SecretKey": "6Lfhp_AnAAAAANjDDY6DPrbbUQS7k6ZCRmrVP5Lb"
|
||||
},
|
||||
"SmsSecrets": {
|
||||
"ApiKey": "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa",
|
||||
"SecretKey": "dadmehr"
|
||||
},
|
||||
"Domain": ".gozareshgir.ir",
|
||||
"MongoDb": {
|
||||
"ConnectionString": "mongodb://localhost:27017",
|
||||
"DatabaseName": "Gozareshgir"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
9
BackgroundJobs/BackgroundJobs.Task/appsettings.json
Normal file
9
BackgroundJobs/BackgroundJobs.Task/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -75,5 +75,5 @@ public interface IPersonalContractingPartyRepository :IRepository<long, Personal
|
||||
Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id);
|
||||
|
||||
Task<PersonalContractingParty> GetByNationalCode(string nationalCode);
|
||||
Task<PersonalContractingParty> GetByRegisterId(string registerId);
|
||||
Task<PersonalContractingParty> GetByNationalId(string registerId);
|
||||
}
|
||||
108
Company.Domain/FinancialInvoiceAgg/FinancialInvoice.cs
Normal file
108
Company.Domain/FinancialInvoiceAgg/FinancialInvoice.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.PaymentTransactionAgg;
|
||||
using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
namespace Company.Domain.FinancialInvoiceAgg;
|
||||
|
||||
public class FinancialInvoice : EntityBase
|
||||
{
|
||||
|
||||
public string InvoiceNumber { get; private set; }
|
||||
public string Description { get; set; }
|
||||
public FinancialInvoiceStatus Status { get; private set; }
|
||||
public DateTime? PaidAt { get; private set; }
|
||||
public double Amount { get; private set; }
|
||||
public Guid PublicId { get; private set; }
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public List<PaymentTransaction> PaymentTransactions { get; private set; }
|
||||
public long ContractingPartyId { get; private set; }
|
||||
|
||||
public List<FinancialInvoiceItem> Items { get; private set; }
|
||||
|
||||
public FinancialInvoice(double amount, long contractingPartyId, string description)
|
||||
{
|
||||
InvoiceNumber = GenerateInvoiceNumber();
|
||||
Status = FinancialInvoiceStatus.Unpaid;
|
||||
Amount = amount;
|
||||
PublicId = Guid.NewGuid();
|
||||
ContractingPartyId = contractingPartyId;
|
||||
Description = description;
|
||||
IsActive = true;
|
||||
Items = [];
|
||||
PaymentTransactions = [];
|
||||
}
|
||||
|
||||
public void AddItem(FinancialInvoiceItem item)
|
||||
{
|
||||
Items ??= [];
|
||||
|
||||
Items.Add(item);
|
||||
}
|
||||
|
||||
public void SetItems(List<FinancialInvoiceItem> items)
|
||||
{
|
||||
Items = items;
|
||||
}
|
||||
|
||||
public void SetPaid(DateTime paidAt)
|
||||
{
|
||||
Status = FinancialInvoiceStatus.Paid;
|
||||
PaidAt = paidAt;
|
||||
}
|
||||
public void SetUnpaid()
|
||||
{
|
||||
Status = FinancialInvoiceStatus.Unpaid;
|
||||
PaidAt = null;
|
||||
}
|
||||
public void SetCancelled()
|
||||
{
|
||||
Status = FinancialInvoiceStatus.Cancelled;
|
||||
PaidAt = null;
|
||||
}
|
||||
public void SetRefunded()
|
||||
{
|
||||
Status = FinancialInvoiceStatus.Refunded;
|
||||
PaidAt = null;
|
||||
}
|
||||
|
||||
public void DeActivate()
|
||||
{
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
public void SetInvoiceNumber(string invoiceNumber)
|
||||
{
|
||||
InvoiceNumber = invoiceNumber;
|
||||
}
|
||||
|
||||
private string GenerateInvoiceNumber()
|
||||
{
|
||||
var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
var random = new Random().Next(1000, 9999);
|
||||
return $"GZ_{timestamp}{random}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FinancialInvoiceItem : EntityBase
|
||||
{
|
||||
public string Description { get; private set; }
|
||||
public double Amount { get; private set; }
|
||||
public FinancialInvoiceItemType Type { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
public FinancialInvoice FinancialInvoice { get; set; }
|
||||
public long FinancialInvoiceId { get; set; }
|
||||
public FinancialInvoiceItem(string description, double amount,
|
||||
long financialInvoiceId, FinancialInvoiceItemType type, long entityId)
|
||||
{
|
||||
Description = description;
|
||||
Amount = amount;
|
||||
FinancialInvoiceId = financialInvoiceId;
|
||||
Type = type;
|
||||
EntityId = entityId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
namespace Company.Domain.FinancialInvoiceAgg;
|
||||
|
||||
public interface IFinancialInvoiceRepository : IRepository<long, FinancialInvoice>
|
||||
{
|
||||
EditFinancialInvoice GetDetails(long id);
|
||||
List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel);
|
||||
Task<FinancialInvoice> GetUnPaidByEntityId(long entityId, FinancialInvoiceItemType financialInvoiceItemType);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using Company.Domain.FinancialTransactionAgg;
|
||||
|
||||
namespace Company.Domain.FinancialStatmentAgg;
|
||||
|
||||
@@ -22,6 +22,8 @@ public interface IFinancialStatmentRepository : IRepository<long, FinancialStatm
|
||||
Task<OperationResult<ClientFinancialStatementViewModel>> GetDetailsByPublicId(string publicId);
|
||||
Task<GetFinancialStatementBalanceAmount> GetBalanceAmount(long id);
|
||||
Task<double> GetClientDebtAmount(long accountId);
|
||||
Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel);
|
||||
Task<double> GetClientDebtAmountByContractingPartyId(long contractingPartyId);
|
||||
|
||||
Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel);
|
||||
Task<FinancialStatment> GetByContractingPartyId(long contractingPartyId);
|
||||
}
|
||||
@@ -26,6 +26,35 @@ public class FinancialTransaction : EntityBase
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد از طرف بک گراند سرویس
|
||||
/// </summary>
|
||||
/// <param name="financialStatementId"></param>
|
||||
/// <param name="tdateGr"></param>
|
||||
/// <param name="tdateFa"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="typeOfTransaction"></param>
|
||||
/// <param name="descriptionOption"></param>
|
||||
/// <param name="deptor"></param>
|
||||
/// <param name="creditor"></param>
|
||||
/// <param name="balance"></param>
|
||||
/// <param name="sentSms"></param>
|
||||
public FinancialTransaction(long financialStatementId, DateTime tdateGr, string tdateFa, string description,
|
||||
string typeOfTransaction, string descriptionOption, double deptor, double creditor, double balance,
|
||||
bool sentSms)
|
||||
{
|
||||
FinancialStatementId = financialStatementId;
|
||||
TdateGr = tdateGr;
|
||||
TdateFa = tdateFa;
|
||||
Description = description;
|
||||
TypeOfTransaction = typeOfTransaction;
|
||||
DescriptionOption = descriptionOption;
|
||||
Deptor = deptor;
|
||||
Creditor = creditor;
|
||||
Balance = balance;
|
||||
SentSms = sentSms;
|
||||
}
|
||||
|
||||
public long FinancialStatementId { get; private set; }
|
||||
public DateTime TdateGr { get; private set; }
|
||||
public string TdateFa { get; private set; }
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
@@ -43,7 +44,7 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
/// <param name="endOfMonthGr"></param>
|
||||
/// <param name="endOfMonth"></param>
|
||||
/// <param name="description"></param>
|
||||
void RollcallServiceCreateTransaction();
|
||||
Task RollCallServiceCreateTransaction();
|
||||
|
||||
Task<PagedResult<GetInstitutionContractListItemsViewModel>> GetList(InstitutionContractListSearchModel searchModel);
|
||||
Task<GetInstitutionContractListStatsViewModel> GetListStats(InstitutionContractListSearchModel searchModel);
|
||||
@@ -79,4 +80,71 @@ public interface IInstitutionContractRepository : IRepository<long, InstitutionC
|
||||
Task<GetInstitutionContractWorkshopsDetails> GetContractWorkshopsDetails(long id);
|
||||
Task AmendmentComplete(InstitutionContractAmendmentCompleteRequest request);
|
||||
Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id, long amendmentId);
|
||||
|
||||
|
||||
#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);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateMontlyTransaction
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد سند مالی برای قرارداد ها
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task CreateTransactionForInstitutionContracts(DateTime endOfMonthGr, string endOfMonthFa, string description);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.InstitutionContractContactInfoAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
@@ -462,20 +463,3 @@ public enum InstitutionContractAmendmentChangeType
|
||||
WorkshopCreated
|
||||
}
|
||||
|
||||
public enum InstitutionContractVerificationStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// در انتظار تایید
|
||||
/// </summary>
|
||||
PendingForVerify = 0,
|
||||
|
||||
/// <summary>
|
||||
/// در انتظار کارپوشه
|
||||
/// </summary>
|
||||
PendingWorkflow = 1,
|
||||
|
||||
/// <summary>
|
||||
/// تایید شده
|
||||
/// </summary>
|
||||
Verified = 2
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using _0_Framework.Domain;
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using CompanyManagment.App.Contracts.PaymentTransaction;
|
||||
|
||||
namespace Company.Domain.PaymentTransactionAgg;
|
||||
@@ -9,14 +10,15 @@ namespace Company.Domain.PaymentTransactionAgg;
|
||||
/// </summary>
|
||||
public class PaymentTransaction:EntityBase
|
||||
{
|
||||
/// <summary>
|
||||
/// سازنده کلاس PaymentTransaction با دریافت اطلاعات تراکنش.
|
||||
/// </summary>
|
||||
/// <param name="contractingPartyId">شناسه طرف قرارداد</param>
|
||||
/// <param name="amount">مبلغ تراکنش</param>
|
||||
/// <param name="contractingPartyName"></param>
|
||||
/// <param name="callBackUrl"></param>
|
||||
public PaymentTransaction(long contractingPartyId,
|
||||
/// <summary>
|
||||
/// سازنده کلاس PaymentTransaction با دریافت اطلاعات تراکنش.
|
||||
/// </summary>
|
||||
/// <param name="contractingPartyId">شناسه طرف قرارداد</param>
|
||||
/// <param name="amount">مبلغ تراکنش</param>
|
||||
/// <param name="contractingPartyName"></param>
|
||||
/// <param name="callBackUrl"></param>
|
||||
/// <param name="gateway"></param>
|
||||
public PaymentTransaction(long contractingPartyId,
|
||||
double amount,
|
||||
string contractingPartyName,string callBackUrl,
|
||||
PaymentTransactionGateWay gateway)
|
||||
@@ -74,6 +76,9 @@ public class PaymentTransaction:EntityBase
|
||||
public string Rrn { get; private set; }
|
||||
public string DigitalReceipt { get; private set; }
|
||||
|
||||
public FinancialInvoice FinancialInvoice { get; set; }
|
||||
public long? FinancialInvoiceId { get; set; }
|
||||
|
||||
|
||||
public void SetPaid(string cardNumber,string bankName,string rrn,string digitalReceipt)
|
||||
{
|
||||
|
||||
30
Company.Domain/SmsResultAgg/ISmsSettingsRepository.cs
Normal file
30
Company.Domain/SmsResultAgg/ISmsSettingsRepository.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.SmsResultAgg;
|
||||
|
||||
public interface ISmsSettingsRepository : IRepository<long, SmsSetting>
|
||||
{
|
||||
/// <summary>
|
||||
/// ویرایش پیامک خودکار
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<EditSmsSetting> GetSmsSettingToEdit(long id);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<SmsSettingViewModel> GetSmsSettingsByType(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// حذف از دیتابیس
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveItem(long id);
|
||||
}
|
||||
72
Company.Domain/SmsResultAgg/SmsSetting.cs
Normal file
72
Company.Domain/SmsResultAgg/SmsSetting.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using System;
|
||||
|
||||
namespace Company.Domain.SmsResultAgg;
|
||||
|
||||
public class SmsSetting : EntityBaseWithoutCreationDate
|
||||
{
|
||||
/// <summary>
|
||||
/// ایجاد تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
public SmsSetting(TypeOfSmsSetting typeOfSmsSetting, int dayOfMonth, TimeSpan timeOfDay)
|
||||
{
|
||||
TypeOfSmsSetting = typeOfSmsSetting;
|
||||
DayOfMonth = dayOfMonth;
|
||||
TimeOfDay = timeOfDay;
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// نوع پیامک
|
||||
/// </summary>
|
||||
public TypeOfSmsSetting TypeOfSmsSetting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// عدد روز از ماه
|
||||
/// </summary>
|
||||
public int DayOfMonth { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ساعت
|
||||
/// </summary>
|
||||
public TimeSpan TimeOfDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فعال/غیرفعال
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
public void Edit(int dayOfMonth, TimeSpan timeOfDay)
|
||||
{
|
||||
DayOfMonth = dayOfMonth;
|
||||
TimeOfDay = timeOfDay;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// فعال نمودن
|
||||
/// </summary>
|
||||
public void Active()
|
||||
{
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// غیر فعال نمودن
|
||||
/// </summary>
|
||||
public void DeActive()
|
||||
{
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public class CreateFinancialInvoice
|
||||
{
|
||||
public double Amount { get; set; }
|
||||
public long ContractingPartyId { get; set; }
|
||||
public string Description { get; set; }
|
||||
public List<CreateFinancialInvoiceItem>? Items { get; set; }
|
||||
}
|
||||
|
||||
public class CreateFinancialInvoiceItem
|
||||
{
|
||||
public string Description { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public FinancialInvoiceItemType Type { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public class EditFinancialInvoice
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public string Description { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public FinancialInvoiceStatus Status { get; set; }
|
||||
|
||||
public List<EditFinancialInvoiceItem>? Items { get; set; }
|
||||
}
|
||||
|
||||
public class EditFinancialInvoiceItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public FinancialInvoiceItemType Type { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public enum FinancialInvoiceItemType
|
||||
{
|
||||
/// <summary>
|
||||
/// قسط قرارداد خرید از موسسه
|
||||
/// </summary>
|
||||
BuyInstitutionContractInstallment,
|
||||
/// <summary>
|
||||
/// خرید قرارداد از موسسه
|
||||
/// </summary>
|
||||
BuyInstitutionContract,
|
||||
/// <summary>
|
||||
///قسط ارتقا قرارداد موسسه
|
||||
/// </summary>
|
||||
AmendmentInstitutionContractInstallment,
|
||||
/// <summary>
|
||||
/// ارتقا قرارداد موسسه
|
||||
/// </summary>
|
||||
AmendmentInstitutionContract,
|
||||
/// <summary>
|
||||
/// بدهی قبلی
|
||||
/// </summary>
|
||||
PreviousDebt,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public class FinancialInvoiceSearchModel
|
||||
{
|
||||
public string? Description { get; set; }
|
||||
public FinancialInvoiceStatus? Status { get; set; }
|
||||
public long? ContractingPartyId { get; set; }
|
||||
public string? FromDate { get; set; }
|
||||
public string? ToDate { get; set; }
|
||||
public double? MinAmount { get; set; }
|
||||
public double? MaxAmount { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public enum FinancialInvoiceStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// پرداخت نشده
|
||||
/// </summary>
|
||||
Unpaid = 0,
|
||||
/// <summary>
|
||||
/// پرداخت شده کامل
|
||||
/// </summary>
|
||||
Paid = 1,
|
||||
/// <summary>
|
||||
/// فاکتور لغو شده
|
||||
/// </summary>
|
||||
Cancelled = 4,
|
||||
/// <summary>
|
||||
/// // بازپرداخت شده (در صورت برگشت وجه)
|
||||
/// </summary>
|
||||
Refunded = 5,
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public class FinancialInvoiceViewModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string PaidAt { get; set; }
|
||||
public double Amount { get; set; }
|
||||
public Guid PublicId { get; set; }
|
||||
public long ContractingPartyId { get; set; }
|
||||
public string ContractingPartyName { get; set; }
|
||||
public string CreationDate { get; set; }
|
||||
public int ItemsCount { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
|
||||
public interface IFinancialInvoiceApplication
|
||||
{
|
||||
OperationResult Create(CreateFinancialInvoice command);
|
||||
OperationResult Edit(EditFinancialInvoice command);
|
||||
OperationResult SetPaid(long id, DateTime paidAt);
|
||||
OperationResult SetUnpaid(long id);
|
||||
OperationResult SetCancelled(long id);
|
||||
OperationResult SetRefunded(long id);
|
||||
EditFinancialInvoice GetDetails(long id);
|
||||
List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel);
|
||||
}
|
||||
@@ -9,6 +9,7 @@ public class FinancialStatmentViewModel
|
||||
public long Id { get; set; }
|
||||
public long ContractingPartyId { get; set; }
|
||||
public string ContractingPartyName { get; set; }
|
||||
public string PublicId { get; set; }
|
||||
|
||||
public List<FinancialTransactionViewModel> FinancialTransactionViewModels { get; set; }
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ public class FinancialTransactionViewModel
|
||||
public string TdateFa { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string TypeOfTransaction { get; set; }
|
||||
public string DescriptionOption { get; set; }
|
||||
public double Deptor { get; set; }
|
||||
public string DeptorString { get; set; }
|
||||
public double Creditor { get; set; }
|
||||
@@ -20,4 +21,7 @@ public class FinancialTransactionViewModel
|
||||
public string MessageText { get; set; }
|
||||
public string SentSmsDateFa { get; set; }
|
||||
public int Counter { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
20
CompanyManagment.App.Contracts/Hubs/SendSmsHub.cs
Normal file
20
CompanyManagment.App.Contracts/Hubs/SendSmsHub.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Hubs;
|
||||
|
||||
|
||||
public class SendSmsHub : Hub
|
||||
{
|
||||
|
||||
public async Task send(long id)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(id));
|
||||
}
|
||||
|
||||
public static string GetGroupName(long id)
|
||||
{
|
||||
return $"group-sms-{id}";
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public interface IInstitutionContractApplication
|
||||
|
||||
Task<GetInstitutionVerificationDetailsViewModel> GetVerificationDetails(Guid id);
|
||||
Task<OperationResult<OtpResultViewModel>> SendVerifyOtp(Guid id);
|
||||
Task<OperationResult> VerifyOtp(Guid publicId, string code);
|
||||
Task<OperationResult<string>> VerifyOtpAndMakeGateway(Guid publicId, string code, string callbackUrl);
|
||||
Task<InstitutionContractWorkshopDetailViewModel> GetWorkshopInitialDetails(long workshopDetailsId);
|
||||
|
||||
#region Extension
|
||||
@@ -252,6 +252,8 @@ public interface IInstitutionContractApplication
|
||||
/// <returns></returns>
|
||||
Task<InstitutionContractPrintViewModel> PrintOneAsync(long id);
|
||||
|
||||
Task<OperationResult> SetPendingWorkflow(long entityId);
|
||||
|
||||
Task<GetInstitutionContractWorkshopsDetails> GetContractWorkshopsDetails(long id);
|
||||
|
||||
Task<GetInstitutionAmendmentVerificationDetailsViewModel> GetAmendmentVerificationDetails(Guid id, long amendmentId);
|
||||
|
||||
@@ -27,7 +27,13 @@ public class InstitutionContractInstallmentViewModel
|
||||
/// مبلغ قسط
|
||||
/// </summary>
|
||||
public string Amount { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ قسط
|
||||
/// Double
|
||||
/// </summary>
|
||||
public double AmountDouble { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// عدد قسط فارسی
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application.Enums;
|
||||
using CompanyManagment.App.Contracts.Employer;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
|
||||
@@ -25,6 +26,7 @@ public class InstitutionContractViewModel
|
||||
public DateTime ContractEndGr { get; set; }
|
||||
public string ContractEndFa { get; set; }
|
||||
public string ContractAmount { get; set; }
|
||||
public double ContractAmountDouble { get; set; }
|
||||
public string DailyCompenseation { get; set; }
|
||||
|
||||
public string Obligation { get; set; }
|
||||
@@ -70,4 +72,9 @@ public class InstitutionContractViewModel
|
||||
public int LeftWorkEmployeeCount { get; set; }
|
||||
public int InsuranceLeftWorkEmployeeCount { get; set; }
|
||||
public string IsExpier { get; set; }
|
||||
|
||||
public bool IsInstallment { get; set; }
|
||||
public InstitutionContractVerificationStatus VerificationStatus { get; set; }
|
||||
|
||||
public List<InstitutionContractInstallmentViewModel> InstallmentList { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
||||
|
||||
/// <summary>
|
||||
/// لیست پیامکهای بدهکاران قرارداد ملی
|
||||
/// </summary>
|
||||
public class SmsListData
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره تماس طرف حساب
|
||||
/// </summary>
|
||||
public string PhoneNumber { get; set; }
|
||||
/// <summary>
|
||||
/// تمپلیت آی دی
|
||||
/// </summary>
|
||||
public int TemplateId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام طرف حساب
|
||||
/// </summary>
|
||||
public string PartyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ بدهی
|
||||
/// </summary>
|
||||
public string Amount { get; set; }
|
||||
/// <summary>
|
||||
/// آی دی طرف حساب
|
||||
/// </summary>
|
||||
public long ContractingPartyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی صورت حساب مالی
|
||||
/// </summary>
|
||||
public string AproveId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع متد ارسال پیامک
|
||||
/// </summary>
|
||||
public string TypeOfSmsMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// پابلیک آی دی بخش یک
|
||||
/// </summary>
|
||||
public string Code1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// پابلیک آی دی بخش دو
|
||||
/// </summary>
|
||||
public string Code2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ای دی قراداد مالی
|
||||
/// </summary>
|
||||
public long InstitutionContractId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لیست پیامک های بلاک
|
||||
/// </summary>
|
||||
public class BlockSmsListData
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره تماس طرف حساب
|
||||
/// </summary>
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام طرف حساب
|
||||
/// </summary>
|
||||
public string PartyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ بدهی
|
||||
/// </summary>
|
||||
public string Amount { get; set; }
|
||||
/// <summary>
|
||||
/// آی دی طرف حساب
|
||||
/// </summary>
|
||||
public long ContractingPartyId { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// نوع حساب - رسمی یا غیر رسمی
|
||||
/// </summary>
|
||||
public string AccountType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ای دی قراداد مالی
|
||||
/// </summary>
|
||||
public long InstitutionContractId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آی دی صورت حساب مالی
|
||||
/// </summary>
|
||||
public string AproveId { get; set; }
|
||||
}
|
||||
62
CompanyManagment.App.Contracts/SmsResult/CreateSmsSetting.cs
Normal file
62
CompanyManagment.App.Contracts/SmsResult/CreateSmsSetting.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Domain;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SmsResult;
|
||||
|
||||
/// <summary>
|
||||
/// مدل ایجاد تنظیمات پیامک
|
||||
/// </summary>
|
||||
public class CreateSmsSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// نوع پیامک
|
||||
/// </summary>
|
||||
public TypeOfSmsSetting TypeOfSmsSetting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// عدد روز از ماه
|
||||
/// </summary>
|
||||
public int DayOfMonth { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ساعت
|
||||
/// </summary>
|
||||
public TimeSpan TimeOfDay { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
public class EditSmsSetting : CreateSmsSetting
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فعال/غیرفعال
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نمایش ساعت و دقیقه
|
||||
/// </summary>
|
||||
public string TimeOfDayDisplay { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ویو مدل تنظیمات پیامک
|
||||
/// </summary>
|
||||
public class SmsSettingViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک
|
||||
/// </summary>
|
||||
public List<EditSmsSetting> EditSmsSettings { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SmsResult;
|
||||
|
||||
public interface ISmsSettingApplication
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public Task<SmsSettingViewModel> GetSmsSettingsByType(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد تنظیمات پیامک یادآور
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CreateSmsSetting(int dayOfMonth, string timeOfDay, TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش پیامک خودکار
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<EditSmsSetting> GetSmsSettingToEdit(long id);
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد تنظیمات پیامک یادآور
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> EditeSmsSetting(EditSmsSetting command);
|
||||
|
||||
/// <summary>
|
||||
/// حذف از دیتابیس
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveSetting(long id);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست بدهکاران
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsListData>> GetSmsListData(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست کسانی که باید بلاک شوند
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<BlockSmsListData>> GetBlockSmsListData(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک یاد آور آنی
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> InstantSendReminderSms(List<SmsListData> command);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودس
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> InstantSendBlockSms(List<BlockSmsListData> command);
|
||||
}
|
||||
214
CompanyManagment.Application/FinancialInvoiceApplication.cs
Normal file
214
CompanyManagment.Application/FinancialInvoiceApplication.cs
Normal file
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
using CompanyManagment.EFCore;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class FinancialInvoiceApplication : RepositoryBase<long, FinancialInvoice>, IFinancialInvoiceApplication
|
||||
{
|
||||
private readonly IFinancialInvoiceRepository _financialInvoiceRepository;
|
||||
private readonly CompanyContext _context;
|
||||
|
||||
public FinancialInvoiceApplication(IFinancialInvoiceRepository financialInvoiceRepository, CompanyContext context) : base(context)
|
||||
{
|
||||
_financialInvoiceRepository = financialInvoiceRepository;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public OperationResult Create(CreateFinancialInvoice command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
|
||||
if (command.Amount <= 0)
|
||||
return operation.Failed("مبلغ فاکتور باید بزرگتر از صفر باشد");
|
||||
|
||||
if (command.ContractingPartyId <= 0)
|
||||
return operation.Failed("طرف قرارداد نامعتبر است");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.Description))
|
||||
return operation.Failed("توضیحات فاکتور الزامی است");
|
||||
|
||||
var financialInvoice = new FinancialInvoice(command.Amount, command.ContractingPartyId, command.Description);
|
||||
|
||||
if (command.Items != null && command.Items.Any())
|
||||
{
|
||||
foreach (var item in command.Items)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.Description))
|
||||
return operation.Failed("توضیحات آیتم الزامی است");
|
||||
|
||||
if (item.Amount <= 0)
|
||||
return operation.Failed("مبلغ آیتم باید بزرگتر از صفر باشد");
|
||||
|
||||
var invoiceItem = new FinancialInvoiceItem(item.Description, item.Amount,
|
||||
financialInvoice.id, item.Type, item.EntityId);
|
||||
|
||||
financialInvoice.AddItem(invoiceItem);
|
||||
}
|
||||
}
|
||||
|
||||
_financialInvoiceRepository.Create(financialInvoice);
|
||||
_financialInvoiceRepository.SaveChanges();
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult Edit(EditFinancialInvoice command)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var financialInvoice = _financialInvoiceRepository.Get(command.Id);
|
||||
|
||||
if (financialInvoice == null)
|
||||
return operation.Failed("فاکتور مورد نظر یافت نشد");
|
||||
|
||||
if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
|
||||
return operation.Failed("امکان ویرایش فاکتور پرداخت شده وجود ندارد");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.Description))
|
||||
return operation.Failed("توضیحات فاکتور الزامی است");
|
||||
|
||||
// Update description
|
||||
financialInvoice.Description = command.Description;
|
||||
|
||||
// Update items if provided
|
||||
if (command.Items != null)
|
||||
{
|
||||
// Clear existing items
|
||||
if (financialInvoice.Items != null)
|
||||
{
|
||||
financialInvoice.Items.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
financialInvoice.SetItems([]);
|
||||
}
|
||||
|
||||
// Add updated items
|
||||
foreach (var item in command.Items)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(item.Description))
|
||||
return operation.Failed("توضیحات آیتم الزامی است");
|
||||
|
||||
if (item.Amount <= 0)
|
||||
return operation.Failed("مبلغ آیتم باید بزرگتر از صفر باشد");
|
||||
|
||||
var invoiceItem = new FinancialInvoiceItem(item.Description, item.Amount,
|
||||
financialInvoice.id, item.Type, item.EntityId);
|
||||
|
||||
financialInvoice.AddItem(invoiceItem);
|
||||
}
|
||||
}
|
||||
|
||||
_financialInvoiceRepository.SaveChanges();
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult SetPaid(long id, DateTime paidAt)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var financialInvoice = _financialInvoiceRepository.Get(id);
|
||||
|
||||
if (financialInvoice == null)
|
||||
return operation.Failed("فاکتور مورد نظر یافت نشد");
|
||||
|
||||
if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
|
||||
return operation.Failed("فاکتور قبلاً پرداخت شده است");
|
||||
|
||||
if (financialInvoice.Status == FinancialInvoiceStatus.Cancelled)
|
||||
return operation.Failed("امکان پرداخت فاکتور لغو شده وجود ندارد");
|
||||
|
||||
financialInvoice.SetPaid(paidAt);
|
||||
_financialInvoiceRepository.SaveChanges();
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult SetUnpaid(long id)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var financialInvoice = _financialInvoiceRepository.Get(id);
|
||||
|
||||
if (financialInvoice == null)
|
||||
return operation.Failed("فاکتور مورد نظر یافت نشد");
|
||||
|
||||
financialInvoice.SetUnpaid();
|
||||
_financialInvoiceRepository.SaveChanges();
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult SetCancelled(long id)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var financialInvoice = _financialInvoiceRepository.Get(id);
|
||||
|
||||
if (financialInvoice == null)
|
||||
return operation.Failed("فاکتور مورد نظر یافت نشد");
|
||||
|
||||
if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
|
||||
return operation.Failed("امکان لغو فاکتور پرداخت شده وجود ندارد");
|
||||
|
||||
financialInvoice.SetCancelled();
|
||||
_financialInvoiceRepository.SaveChanges();
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public OperationResult SetRefunded(long id)
|
||||
{
|
||||
var operation = new OperationResult();
|
||||
var financialInvoice = _financialInvoiceRepository.Get(id);
|
||||
|
||||
if (financialInvoice == null)
|
||||
return operation.Failed("فاکتور مورد نظر یافت نشد");
|
||||
|
||||
if (financialInvoice.Status != FinancialInvoiceStatus.Paid)
|
||||
return operation.Failed("فقط فاکتورهای پرداخت شده قابل بازپرداخت هستند");
|
||||
|
||||
financialInvoice.SetRefunded();
|
||||
_financialInvoiceRepository.SaveChanges();
|
||||
|
||||
return operation.Succcedded();
|
||||
}
|
||||
|
||||
public EditFinancialInvoice GetDetails(long id)
|
||||
{
|
||||
return _financialInvoiceRepository.GetDetails(id);
|
||||
}
|
||||
|
||||
public List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel)
|
||||
{
|
||||
return _financialInvoiceRepository.Search(searchModel);
|
||||
}
|
||||
|
||||
//public OperationResult Remove(long id)
|
||||
//{
|
||||
// var operation = new OperationResult();
|
||||
|
||||
// try
|
||||
// {
|
||||
// var financialInvoice = _financialInvoiceRepository.Get(id);
|
||||
|
||||
// if (financialInvoice == null)
|
||||
// return operation.Failed("فاکتور مورد نظر یافت نشد");
|
||||
|
||||
// if (financialInvoice.Status == FinancialInvoiceStatus.Paid)
|
||||
// return operation.Failed("امکان حذف فاکتور پرداخت شده وجود ندارد");
|
||||
|
||||
// // Remove the entity using the context directly since Remove method might not be available
|
||||
// _context.FinancialInvoiceSet.Remove(financialInvoice);
|
||||
// _financialInvoiceRepository.SaveChanges();
|
||||
|
||||
// return operation.Succcedded();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return operation.Failed("خطا در حذف فاکتور");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
165
CompanyManagment.Application/SmsSettingApplication.cs
Normal file
165
CompanyManagment.Application/SmsSettingApplication.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
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;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class SmsSettingApplication : ISmsSettingApplication
|
||||
{
|
||||
private readonly ISmsSettingsRepository _smsSettingsRepository;
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
|
||||
public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository)
|
||||
{
|
||||
_smsSettingsRepository = smsSettingsRepository;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
}
|
||||
|
||||
|
||||
public async Task<SmsSettingViewModel> GetSmsSettingsByType(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _smsSettingsRepository.GetSmsSettingsByType(typeOfSmsSetting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد تنظیمات پیامک یادآور
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<OperationResult> CreateSmsSetting(int dayOfMonth, string timeOfDay,
|
||||
TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var timeSpan = new TimeSpan();
|
||||
if (string.IsNullOrWhiteSpace(timeOfDay))
|
||||
return op.Failed("ساعت وارد نشده است");
|
||||
|
||||
try
|
||||
{
|
||||
timeSpan = TimeSpan.ParseExact(timeOfDay, @"hh\:mm", null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return op.Failed("فرمت ساعت اشتباه است");
|
||||
}
|
||||
|
||||
|
||||
if (dayOfMonth < 1 || dayOfMonth > 31)
|
||||
{
|
||||
return op.Failed("عدد روز می بایست بین 1 تا 31 باشد");
|
||||
}
|
||||
|
||||
if (_smsSettingsRepository.Exists(x => x.DayOfMonth == dayOfMonth && x.TimeOfDay == timeSpan && x.TypeOfSmsSetting == typeOfSmsSetting))
|
||||
return op.Failed("رکورد ایجاد شده تکراری است");
|
||||
|
||||
var create = new SmsSetting(typeOfSmsSetting, dayOfMonth, timeSpan);
|
||||
await _smsSettingsRepository.CreateAsync(create);
|
||||
await _smsSettingsRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<EditSmsSetting> GetSmsSettingToEdit(long id)
|
||||
{
|
||||
return await _smsSettingsRepository.GetSmsSettingToEdit(id);
|
||||
}
|
||||
|
||||
public async Task<OperationResult> EditeSmsSetting(EditSmsSetting command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var timeSpan = new TimeSpan();
|
||||
if (string.IsNullOrWhiteSpace(command.TimeOfDayDisplay))
|
||||
return op.Failed("ساعت وارد نشده است");
|
||||
|
||||
try
|
||||
{
|
||||
timeSpan = TimeSpan.ParseExact(command.TimeOfDayDisplay, @"hh\:mm", null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return op.Failed("فرمت ساعت اشتباه است");
|
||||
}
|
||||
|
||||
if (command.DayOfMonth < 1 || command.DayOfMonth > 31)
|
||||
{
|
||||
return op.Failed("عدد روز می بایست بین 1 تا 31 باشد");
|
||||
}
|
||||
|
||||
if (_smsSettingsRepository.Exists(x => x.DayOfMonth == command.DayOfMonth && x.TimeOfDay == timeSpan && x.TypeOfSmsSetting == command.TypeOfSmsSetting && x.id != command.Id))
|
||||
return op.Failed("رکورد ایجاد شده تکراری است");
|
||||
|
||||
var editSmsSetting = _smsSettingsRepository.Get(command.Id);
|
||||
editSmsSetting.Edit(command.DayOfMonth, timeSpan);
|
||||
await _smsSettingsRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task RemoveSetting(long id)
|
||||
{
|
||||
await _smsSettingsRepository.RemoveItem(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<SmsListData>> GetSmsListData(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _institutionContractRepository.GetSmsListData(DateTime.Now, typeOfSmsSetting);
|
||||
}
|
||||
|
||||
public async Task<List<BlockSmsListData>> GetBlockSmsListData(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _institutionContractRepository.GetBlockListData(DateTime.Now);
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> InstantSendReminderSms(List<SmsListData> command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
string typeOfSms = "یادآور بدهی ماهانه";
|
||||
string sendMessStart = "شروع یادآور آنی";
|
||||
string sendMessEnd = "پایان یادآور آنی";
|
||||
|
||||
if (command.Any())
|
||||
{
|
||||
await _institutionContractRepository.SendReminderSmsToContractingParties(command, typeOfSms, sendMessStart, sendMessEnd);
|
||||
return op.Succcedded();
|
||||
}
|
||||
else
|
||||
{
|
||||
return op.Failed("موردی انتخاب نشده است");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<OperationResult> InstantSendBlockSms(List<BlockSmsListData> command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
string typeOfSms = "اعلام مسدودی طرف حساب";
|
||||
string sendMessStart = "شروع مسدودی آنی";
|
||||
string sendMessEnd = "پایان مسدودی آنی ";
|
||||
if (command.Any())
|
||||
{
|
||||
await _institutionContractRepository.SendBlockSmsToContractingParties(command, typeOfSms, sendMessStart,
|
||||
sendMessEnd);
|
||||
return op.Succcedded();
|
||||
}
|
||||
else
|
||||
{
|
||||
return op.Failed("موردی انتخاب نشده است");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,6 +209,11 @@ public class TemporaryClientRegistrationApplication : ITemporaryClientRegistrati
|
||||
if (apiRespons.ResponseContext.Status.Code == 14)
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code == 2)
|
||||
{
|
||||
throw new InternalServerException("سیستم احراز هویت در دسترس نمی باشد");
|
||||
}
|
||||
|
||||
if (apiRespons.ResponseContext.Status.Code != 0)
|
||||
return op.Failed($"{apiRespons.ResponseContext.Status.Message}");
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ using Company.Domain.FileEmployerAgg;
|
||||
using Company.Domain.FileState;
|
||||
using Company.Domain.FileTiming;
|
||||
using Company.Domain.FileTitle;
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using Company.Domain.FinancialStatmentAgg;
|
||||
using Company.Domain.FinancialTransactionAgg;
|
||||
using Company.Domain.FineAgg;
|
||||
@@ -162,6 +163,12 @@ public class CompanyContext : DbContext
|
||||
|
||||
//-------Main-Project----------------------------
|
||||
|
||||
#region SmsSettings
|
||||
|
||||
public DbSet<SmsSetting> SmsSettings { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mahan
|
||||
|
||||
//-----------------------------RollCallWorkshopSettings-----------------------------
|
||||
@@ -204,12 +211,13 @@ public class CompanyContext : DbContext
|
||||
|
||||
public DbSet<AuthorizedBankDetails> AuthorizedBankDetails { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
public DbSet<FinancialInvoice> FinancialInvoices { get; set; }
|
||||
|
||||
#region Pooya
|
||||
#endregion
|
||||
|
||||
public DbSet<EmployeeDocumentItem> EmployeeDocumentItems { get; set; }
|
||||
#region Pooya
|
||||
|
||||
public DbSet<EmployeeDocumentItem> EmployeeDocumentItems { get; set; }
|
||||
public DbSet<EmployeeDocuments> EmployeeDocuments { get; set; }
|
||||
|
||||
public DbSet<WorkshopSubAccount> WorkshopSubAccounts { get; set; }
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping;
|
||||
|
||||
public class FinancialInvoiceItemMapping : IEntityTypeConfiguration<FinancialInvoiceItem>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<FinancialInvoiceItem> builder)
|
||||
{
|
||||
builder.Property(x=>x.Description).HasMaxLength(800);
|
||||
builder.Property(x => x.Type).HasConversion<string>().HasMaxLength(50);
|
||||
|
||||
builder.HasOne(x => x.FinancialInvoice).WithMany(x => x.Items)
|
||||
.HasForeignKey(x => x.FinancialInvoiceId);
|
||||
}
|
||||
}
|
||||
25
CompanyManagment.EFCore/Mapping/FinancialInvoiceMapping.cs
Normal file
25
CompanyManagment.EFCore/Mapping/FinancialInvoiceMapping.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping;
|
||||
|
||||
public class FinancialInvoiceMapping:IEntityTypeConfiguration<FinancialInvoice>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<FinancialInvoice> builder)
|
||||
{
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.Status).HasConversion<string>().HasMaxLength(20);
|
||||
builder.Property(x => x.PaidAt).IsRequired(false);
|
||||
builder.Property(x => x.Description).HasMaxLength(800);
|
||||
builder.Property(x => x.InvoiceNumber).HasMaxLength(22);
|
||||
|
||||
builder.HasMany(x => x.Items).WithOne(x => x.FinancialInvoice)
|
||||
.HasForeignKey(x => x.FinancialInvoiceId).IsRequired().OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasMany(x => x.PaymentTransactions).WithOne(x => x.FinancialInvoice)
|
||||
.HasForeignKey(x => x.FinancialInvoiceId).IsRequired(false).OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class FinancialTransactionMapping : IEntityTypeConfiguration<FinancialTra
|
||||
builder.Property(x => x.TdateFa);
|
||||
builder.Property(x => x.TdateFa).HasMaxLength(10);
|
||||
builder.Property(x => x.TypeOfTransaction).HasMaxLength(10);
|
||||
builder.Property(x => x.DescriptionOption).HasMaxLength(50);
|
||||
builder.Property(x => x.DescriptionOption).HasMaxLength(100);
|
||||
builder.Property(x => x.Description).HasMaxLength(600);
|
||||
builder.Property(x => x.Deptor);
|
||||
builder.Property(x => x.Creditor);
|
||||
|
||||
@@ -11,7 +11,7 @@ public class InstitutinContractContactInfoMapping : IEntityTypeConfiguration<Ins
|
||||
builder.ToTable("InstitutinContractContactInfo");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
builder.Property(x => x.FnameLname).HasMaxLength(50);
|
||||
builder.Property(x => x.FnameLname).HasMaxLength(150);
|
||||
builder.Property(x => x.PhoneNumber).HasMaxLength(20);
|
||||
builder.Property(x => x.PhoneType).HasMaxLength(20);
|
||||
builder.Property(x => x.Position).HasMaxLength(50);
|
||||
|
||||
@@ -14,8 +14,8 @@ public class PersonalContractingpartyMapping : IEntityTypeConfiguration<Personal
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
//builder.Property(x => x.LegalName).HasMaxLength(255).IsRequired();
|
||||
builder.Property(x => x.FName).HasMaxLength(50).IsRequired();
|
||||
builder.Property(x => x.LName).HasMaxLength(50).IsRequired();
|
||||
builder.Property(x => x.FName).HasMaxLength(150).IsRequired();
|
||||
builder.Property(x => x.LName).HasMaxLength(150).IsRequired();
|
||||
builder.Property(x => x.SureName).HasMaxLength(50).IsRequired(false);
|
||||
builder.Property(x => x.Nationalcode).HasMaxLength(10).IsRequired();
|
||||
builder.Property(x => x.IdNumber).HasMaxLength(20).IsRequired(false);
|
||||
|
||||
30
CompanyManagment.EFCore/Mapping/SmsSettingMapping.cs
Normal file
30
CompanyManagment.EFCore/Mapping/SmsSettingMapping.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using _0_Framework.Application.Enums;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace CompanyManagment.EFCore.Mapping;
|
||||
|
||||
public class SmsSettingMapping : IEntityTypeConfiguration<SmsSetting>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SmsSetting> builder)
|
||||
{
|
||||
builder.ToTable("SmsSettings");
|
||||
builder.HasKey(x => x.id);
|
||||
|
||||
|
||||
builder.Property(x => x.DayOfMonth)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.TimeOfDay)
|
||||
.HasColumnType("time(0)")
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.TypeOfSmsSetting).HasConversion(
|
||||
v => v.ToString(),
|
||||
v => (TypeOfSmsSetting)Enum.Parse(typeof(TypeOfSmsSetting), v)).HasMaxLength(70);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
10013
CompanyManagment.EFCore/Migrations/20250715100203_Add financialInvoiceTable.Designer.cs
generated
Normal file
10013
CompanyManagment.EFCore/Migrations/20250715100203_Add financialInvoiceTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddfinancialInvoiceTable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FinancialInvoice",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Month = table.Column<int>(type: "int", nullable: false),
|
||||
Year = table.Column<int>(type: "int", nullable: false),
|
||||
Status = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
|
||||
PaidAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
Amount = table.Column<double>(type: "float", nullable: false),
|
||||
SmsCode = table.Column<string>(type: "nvarchar(122)", maxLength: 122, nullable: true),
|
||||
FinancialStatementId = table.Column<long>(type: "bigint", nullable: true),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FinancialInvoice", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FinancialInvoice_FinancialStatments_FinancialStatementId",
|
||||
column: x => x.FinancialStatementId,
|
||||
principalTable: "FinancialStatments",
|
||||
principalColumn: "id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FinancialInvoice_FinancialStatementId",
|
||||
table: "FinancialInvoice",
|
||||
column: "FinancialStatementId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FinancialInvoice");
|
||||
}
|
||||
}
|
||||
}
|
||||
11252
CompanyManagment.EFCore/Migrations/20251113072842_add financial invoice .Designer.cs
generated
Normal file
11252
CompanyManagment.EFCore/Migrations/20251113072842_add financial invoice .Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addfinancialinvoice : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_FinancialInvoice_FinancialStatments_FinancialStatementId",
|
||||
table: "FinancialInvoice");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_FinancialInvoice",
|
||||
table: "FinancialInvoice");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Month",
|
||||
table: "FinancialInvoice");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SmsCode",
|
||||
table: "FinancialInvoice");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Year",
|
||||
table: "FinancialInvoice");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "FinancialInvoice",
|
||||
newName: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "FinancialStatementId",
|
||||
table: "FinancialInvoices",
|
||||
newName: "FinancialStatmentid");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_FinancialInvoice_FinancialStatementId",
|
||||
table: "FinancialInvoices",
|
||||
newName: "IX_FinancialInvoices_FinancialStatmentid");
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "FinancialInvoiceId",
|
||||
table: "PaymentTransactions",
|
||||
type: "bigint",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "ContractingPartyId",
|
||||
table: "FinancialInvoices",
|
||||
type: "bigint",
|
||||
nullable: false,
|
||||
defaultValue: 0L);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Description",
|
||||
table: "FinancialInvoices",
|
||||
type: "nvarchar(800)",
|
||||
maxLength: 800,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsActive",
|
||||
table: "FinancialInvoices",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "PublicId",
|
||||
table: "FinancialInvoices",
|
||||
type: "uniqueidentifier",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_FinancialInvoices",
|
||||
table: "FinancialInvoices",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FinancialInvoiceItem",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Description = table.Column<string>(type: "nvarchar(800)", maxLength: 800, nullable: true),
|
||||
Amount = table.Column<double>(type: "float", nullable: false),
|
||||
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
||||
EntityId = table.Column<long>(type: "bigint", nullable: false),
|
||||
FinancialInvoiceId = table.Column<long>(type: "bigint", nullable: false),
|
||||
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FinancialInvoiceItem", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FinancialInvoiceItem_FinancialInvoices_FinancialInvoiceId",
|
||||
column: x => x.FinancialInvoiceId,
|
||||
principalTable: "FinancialInvoices",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PaymentTransactions_FinancialInvoiceId",
|
||||
table: "PaymentTransactions",
|
||||
column: "FinancialInvoiceId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FinancialInvoiceItem_FinancialInvoiceId",
|
||||
table: "FinancialInvoiceItem",
|
||||
column: "FinancialInvoiceId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
|
||||
table: "FinancialInvoices",
|
||||
column: "FinancialStatmentid",
|
||||
principalTable: "FinancialStatments",
|
||||
principalColumn: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_PaymentTransactions_FinancialInvoices_FinancialInvoiceId",
|
||||
table: "PaymentTransactions",
|
||||
column: "FinancialInvoiceId",
|
||||
principalTable: "FinancialInvoices",
|
||||
principalColumn: "id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_PaymentTransactions_FinancialInvoices_FinancialInvoiceId",
|
||||
table: "PaymentTransactions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "FinancialInvoiceItem");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_PaymentTransactions_FinancialInvoiceId",
|
||||
table: "PaymentTransactions");
|
||||
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_FinancialInvoices",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FinancialInvoiceId",
|
||||
table: "PaymentTransactions");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ContractingPartyId",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Description",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsActive",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PublicId",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.RenameTable(
|
||||
name: "FinancialInvoices",
|
||||
newName: "FinancialInvoice");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "FinancialStatmentid",
|
||||
table: "FinancialInvoice",
|
||||
newName: "FinancialStatementId");
|
||||
|
||||
migrationBuilder.RenameIndex(
|
||||
name: "IX_FinancialInvoices_FinancialStatmentid",
|
||||
table: "FinancialInvoice",
|
||||
newName: "IX_FinancialInvoice_FinancialStatementId");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Month",
|
||||
table: "FinancialInvoice",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "SmsCode",
|
||||
table: "FinancialInvoice",
|
||||
type: "nvarchar(122)",
|
||||
maxLength: 122,
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "Year",
|
||||
table: "FinancialInvoice",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_FinancialInvoice",
|
||||
table: "FinancialInvoice",
|
||||
column: "id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_FinancialInvoice_FinancialStatments_FinancialStatementId",
|
||||
table: "FinancialInvoice",
|
||||
column: "FinancialStatementId",
|
||||
principalTable: "FinancialStatments",
|
||||
principalColumn: "id");
|
||||
}
|
||||
}
|
||||
}
|
||||
11140
CompanyManagment.EFCore/Migrations/20251115080049_SmsSettingsTable.Designer.cs
generated
Normal file
11140
CompanyManagment.EFCore/Migrations/20251115080049_SmsSettingsTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SmsSettingsTable : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SmsSettings",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TypeOfSmsSetting = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
|
||||
DayOfMonth = table.Column<int>(type: "int", nullable: false),
|
||||
TimeOfDay = table.Column<TimeSpan>(type: "time(0)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SmsSettings", x => x.id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "SmsSettings");
|
||||
}
|
||||
}
|
||||
}
|
||||
11140
CompanyManagment.EFCore/Migrations/20251115092700_SmsSettingsTableChange.Designer.cs
generated
Normal file
11140
CompanyManagment.EFCore/Migrations/20251115092700_SmsSettingsTableChange.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SmsSettingsTableChange : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "TypeOfSmsSetting",
|
||||
table: "SmsSettings",
|
||||
type: "nvarchar(70)",
|
||||
maxLength: 70,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(30)",
|
||||
oldMaxLength: 30);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "TypeOfSmsSetting",
|
||||
table: "SmsSettings",
|
||||
type: "nvarchar(30)",
|
||||
maxLength: 30,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(70)",
|
||||
oldMaxLength: 70);
|
||||
}
|
||||
}
|
||||
}
|
||||
11143
CompanyManagment.EFCore/Migrations/20251116133447_addIsActiveToSmsSeting.Designer.cs
generated
Normal file
11143
CompanyManagment.EFCore/Migrations/20251116133447_addIsActiveToSmsSeting.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addIsActiveToSmsSeting : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsActive",
|
||||
table: "SmsSettings",
|
||||
type: "bit",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsActive",
|
||||
table: "SmsSettings");
|
||||
}
|
||||
}
|
||||
}
|
||||
11242
CompanyManagment.EFCore/Migrations/20251117140111_add invoice number.Designer.cs
generated
Normal file
11242
CompanyManagment.EFCore/Migrations/20251117140111_add invoice number.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class addinvoicenumber : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_FinancialInvoices_FinancialStatmentid",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FinancialStatmentid",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "InvoiceNumber",
|
||||
table: "FinancialInvoices",
|
||||
type: "nvarchar(18)",
|
||||
maxLength: 18,
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "InvoiceNumber",
|
||||
table: "FinancialInvoices");
|
||||
|
||||
migrationBuilder.AddColumn<long>(
|
||||
name: "FinancialStatmentid",
|
||||
table: "FinancialInvoices",
|
||||
type: "bigint",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FinancialInvoices_FinancialStatmentid",
|
||||
table: "FinancialInvoices",
|
||||
column: "FinancialStatmentid");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_FinancialInvoices_FinancialStatments_FinancialStatmentid",
|
||||
table: "FinancialInvoices",
|
||||
column: "FinancialStatmentid",
|
||||
principalTable: "FinancialStatments",
|
||||
principalColumn: "id");
|
||||
}
|
||||
}
|
||||
}
|
||||
11242
CompanyManagment.EFCore/Migrations/20251117142046_change max length for financial invoice number.Designer.cs
generated
Normal file
11242
CompanyManagment.EFCore/Migrations/20251117142046_change max length for financial invoice number.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class changemaxlengthforfinancialinvoicenumber : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "InvoiceNumber",
|
||||
table: "FinancialInvoices",
|
||||
type: "nvarchar(22)",
|
||||
maxLength: 22,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(18)",
|
||||
oldMaxLength: 18,
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "InvoiceNumber",
|
||||
table: "FinancialInvoices",
|
||||
type: "nvarchar(18)",
|
||||
maxLength: 18,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(22)",
|
||||
oldMaxLength: 22,
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11242
CompanyManagment.EFCore/Migrations/20251117163856_change descriptionOption max length.Designer.cs
generated
Normal file
11242
CompanyManagment.EFCore/Migrations/20251117163856_change descriptionOption max length.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class changedescriptionOptionmaxlength : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "DescriptionOption",
|
||||
table: "FinancialTransactions",
|
||||
type: "nvarchar(100)",
|
||||
maxLength: 100,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(50)",
|
||||
oldMaxLength: 50,
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "DescriptionOption",
|
||||
table: "FinancialTransactions",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(100)",
|
||||
oldMaxLength: 100,
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11277
CompanyManagment.EFCore/Migrations/20251119171531_change max length of contracting party.Designer.cs
generated
Normal file
11277
CompanyManagment.EFCore/Migrations/20251119171531_change max length of contracting party.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class changemaxlengthofcontractingparty : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LName",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(150)",
|
||||
maxLength: 150,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(50)",
|
||||
oldMaxLength: 50);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FName",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(150)",
|
||||
maxLength: 150,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(50)",
|
||||
oldMaxLength: 50);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "LName",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(150)",
|
||||
oldMaxLength: 150);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FName",
|
||||
table: "PersonalContractingParties",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(150)",
|
||||
oldMaxLength: 150);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CompanyManagment.EFCore.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class changemaxlengthofcontactinfoofinstitutioncontract : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FnameLname",
|
||||
table: "InstitutinContractContactInfo",
|
||||
type: "nvarchar(150)",
|
||||
maxLength: 150,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(50)",
|
||||
oldMaxLength: 50,
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FnameLname",
|
||||
table: "InstitutinContractContactInfo",
|
||||
type: "nvarchar(50)",
|
||||
maxLength: 50,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(150)",
|
||||
oldMaxLength: 150,
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,8 +793,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
b.Property<string>("FName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)");
|
||||
|
||||
b.Property<string>("FatherName")
|
||||
.HasMaxLength(20)
|
||||
@@ -835,8 +835,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
b.Property<string>("LName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)");
|
||||
|
||||
b.Property<string>("LegalPosition")
|
||||
.HasMaxLength(50)
|
||||
@@ -2835,6 +2835,86 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("File_Titles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<double>("Amount")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<long>("ContractingPartyId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(800)
|
||||
.HasColumnType("nvarchar(800)");
|
||||
|
||||
b.Property<string>("InvoiceNumber")
|
||||
.HasMaxLength(22)
|
||||
.HasColumnType("nvarchar(22)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<DateTime?>("PaidAt")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("PublicId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("FinancialInvoices");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoiceItem", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<double>("Amount")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<DateTime>("CreationDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(800)
|
||||
.HasColumnType("nvarchar(800)");
|
||||
|
||||
b.Property<long>("EntityId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("FinancialInvoiceId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("FinancialInvoiceId");
|
||||
|
||||
b.ToTable("FinancialInvoiceItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialStatmentAgg.FinancialStatment", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -2886,8 +2966,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasColumnType("nvarchar(600)");
|
||||
|
||||
b.Property<string>("DescriptionOption")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<long>("FinancialStatementId")
|
||||
.HasColumnType("bigint");
|
||||
@@ -3548,8 +3628,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("FnameLname")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
.HasMaxLength(150)
|
||||
.HasColumnType("nvarchar(150)");
|
||||
|
||||
b.Property<long>("InstitutionContractId")
|
||||
.HasColumnType("bigint");
|
||||
@@ -5019,6 +5099,9 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)");
|
||||
|
||||
b.Property<long?>("FinancialInvoiceId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("Gateway")
|
||||
.IsRequired()
|
||||
.HasMaxLength(35)
|
||||
@@ -5042,6 +5125,8 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.HasIndex("FinancialInvoiceId");
|
||||
|
||||
b.ToTable("PaymentTransactions", (string)null);
|
||||
});
|
||||
|
||||
@@ -5675,6 +5760,33 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.ToTable("SmsResults", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.SmsResultAgg.SmsSetting", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<int>("DayOfMonth")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<TimeSpan>("TimeOfDay")
|
||||
.HasColumnType("time(0)");
|
||||
|
||||
b.Property<string>("TypeOfSmsSetting")
|
||||
.IsRequired()
|
||||
.HasMaxLength(70)
|
||||
.HasColumnType("nvarchar(70)");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("SmsSettings", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.SubtitleAgg.EntitySubtitle", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
@@ -9975,6 +10087,17 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Navigation("FileTiming");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoiceItem", b =>
|
||||
{
|
||||
b.HasOne("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", "FinancialInvoice")
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("FinancialInvoiceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("FinancialInvoice");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialTransactionAgg.FinancialTransaction", b =>
|
||||
{
|
||||
b.HasOne("Company.Domain.FinancialStatmentAgg.FinancialStatment", "FinancialStatment")
|
||||
@@ -10522,6 +10645,16 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Navigation("PaymentToEmployee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.PaymentTransactionAgg.PaymentTransaction", b =>
|
||||
{
|
||||
b.HasOne("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", "FinancialInvoice")
|
||||
.WithMany("PaymentTransactions")
|
||||
.HasForeignKey("FinancialInvoiceId")
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
b.Navigation("FinancialInvoice");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.PenaltyTitle.PenaltyTitle", b =>
|
||||
{
|
||||
b.HasOne("Company.Domain.Petition.Petition", "Petition")
|
||||
@@ -10926,6 +11059,13 @@ namespace CompanyManagment.EFCore.Migrations
|
||||
b.Navigation("FileStates");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialInvoiceAgg.FinancialInvoice", b =>
|
||||
{
|
||||
b.Navigation("Items");
|
||||
|
||||
b.Navigation("PaymentTransactions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Company.Domain.FinancialStatmentAgg.FinancialStatment", b =>
|
||||
{
|
||||
b.Navigation("FinancialTransactionList");
|
||||
|
||||
103
CompanyManagment.EFCore/Repository/FinancialInvoiceRepository.cs
Normal file
103
CompanyManagment.EFCore/Repository/FinancialInvoiceRepository.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class FinancialInvoiceRepository : RepositoryBase<long, FinancialInvoice>, IFinancialInvoiceRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
|
||||
public FinancialInvoiceRepository(CompanyContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public EditFinancialInvoice GetDetails(long id)
|
||||
{
|
||||
var financialInvoice = _context.FinancialInvoices
|
||||
.Include(x => x.Items)
|
||||
.FirstOrDefault(x => x.id == id);
|
||||
|
||||
if (financialInvoice == null)
|
||||
return null;
|
||||
|
||||
return new EditFinancialInvoice
|
||||
{
|
||||
Id = financialInvoice.id,
|
||||
Description = financialInvoice.Description,
|
||||
Amount = financialInvoice.Amount,
|
||||
Status = financialInvoice.Status,
|
||||
InvoiceNumber = financialInvoice.InvoiceNumber,
|
||||
Items = financialInvoice.Items?.Select(x => new EditFinancialInvoiceItem
|
||||
{
|
||||
Id = x.id,
|
||||
Description = x.Description,
|
||||
Amount = x.Amount,
|
||||
Type = x.Type,
|
||||
EntityId = x.EntityId
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public List<FinancialInvoiceViewModel> Search(FinancialInvoiceSearchModel searchModel)
|
||||
{
|
||||
var query = _context.FinancialInvoices
|
||||
.Include(x => x.Items)
|
||||
.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.Description))
|
||||
query = query.Where(x => x.Description.Contains(searchModel.Description));
|
||||
|
||||
if (searchModel.Status.HasValue)
|
||||
query = query.Where(x => x.Status == searchModel.Status.Value);
|
||||
|
||||
if (searchModel.ContractingPartyId.HasValue)
|
||||
query = query.Where(x => x.ContractingPartyId == searchModel.ContractingPartyId.Value);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.FromDate))
|
||||
{
|
||||
var fromDate = searchModel.FromDate.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDate >= fromDate);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(searchModel.ToDate))
|
||||
{
|
||||
var toDate = searchModel.ToDate.ToGeorgianDateTime();
|
||||
query = query.Where(x => x.CreationDate <= toDate);
|
||||
}
|
||||
|
||||
if (searchModel.MinAmount.HasValue)
|
||||
query = query.Where(x => x.Amount >= searchModel.MinAmount.Value);
|
||||
|
||||
if (searchModel.MaxAmount.HasValue)
|
||||
query = query.Where(x => x.Amount <= searchModel.MaxAmount.Value);
|
||||
|
||||
return query.OrderByDescending(x => x.id)
|
||||
.Select(x => new FinancialInvoiceViewModel
|
||||
{
|
||||
Id = x.id,
|
||||
Description = x.Description,
|
||||
Status = x.Status.ToString(),
|
||||
PaidAt = x.PaidAt.HasValue ? x.PaidAt.Value.ToFarsi() : "",
|
||||
Amount = x.Amount,
|
||||
PublicId = x.PublicId,
|
||||
ContractingPartyId = x.ContractingPartyId,
|
||||
CreationDate = x.CreationDate.ToFarsi(),
|
||||
ItemsCount = x.Items != null ? x.Items.Count : 0
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public async Task<FinancialInvoice> GetUnPaidByEntityId(long entityId,
|
||||
FinancialInvoiceItemType financialInvoiceItemType)
|
||||
{
|
||||
return await _context.FinancialInvoices.Include(x => x.Items)
|
||||
.Where(x => x.Status == FinancialInvoiceStatus.Unpaid).FirstOrDefaultAsync(x => x.Items
|
||||
.Any(y => y.Type == financialInvoiceItemType && y.EntityId == entityId));
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,21 @@ public class FinancialStatmentRepository : RepositoryBase<long, FinancialStatmen
|
||||
|
||||
}
|
||||
|
||||
public async Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel)
|
||||
public async Task<double> GetClientDebtAmountByContractingPartyId(long contractingPartyId)
|
||||
{
|
||||
|
||||
var resStatement = await _context.FinancialStatments.Include(x => x.FinancialTransactionList)
|
||||
.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
|
||||
|
||||
if (resStatement == null)
|
||||
return 0;
|
||||
|
||||
return resStatement.FinancialTransactionList.Sum(x => x.Deptor) -
|
||||
resStatement.FinancialTransactionList.Sum(x => x.Creditor);
|
||||
|
||||
}
|
||||
|
||||
public async Task<FinancialStatmentDetailsByContractingPartyViewModel> GetDetailsByContractingParty(long contractingPartyId,FinancialStatementSearchModel searchModel)
|
||||
{
|
||||
var contractingParty = await _context.PersonalContractingParties
|
||||
.FirstOrDefaultAsync(x=>x.id == contractingPartyId);
|
||||
@@ -413,6 +427,6 @@ public class FinancialStatmentRepository : RepositoryBase<long, FinancialStatmen
|
||||
|
||||
public async Task<FinancialStatment> GetByContractingPartyId(long contractingPartyId)
|
||||
{
|
||||
return await _context.FinancialStatments.FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
|
||||
return await _context.FinancialStatments.Include(x=>x.FinancialTransactionList).FirstOrDefaultAsync(x => x.ContractingPartyId == contractingPartyId);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -768,9 +768,9 @@ public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalC
|
||||
return await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.Nationalcode == nationalCode);
|
||||
}
|
||||
|
||||
public async Task<PersonalContractingParty> GetByRegisterId(string registerId)
|
||||
public async Task<PersonalContractingParty> GetByNationalId(string nationalId)
|
||||
{
|
||||
return await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.RegisterId == registerId);
|
||||
return await _context.PersonalContractingParties.FirstOrDefaultAsync(x => x.NationalId == nationalId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
71
CompanyManagment.EFCore/Repository/SmsSettingsRepository.cs
Normal file
71
CompanyManagment.EFCore/Repository/SmsSettingsRepository.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompanyManagment.EFCore.Repository;
|
||||
|
||||
public class SmsSettingsRepository : RepositoryBase<long, SmsSetting>, ISmsSettingsRepository
|
||||
{
|
||||
private readonly CompanyContext _context;
|
||||
public SmsSettingsRepository(CompanyContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش پیامک خودکار
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<EditSmsSetting> GetSmsSettingToEdit(long id)
|
||||
{
|
||||
var edit = new EditSmsSetting();
|
||||
var getItem = await _context.SmsSettings.FirstOrDefaultAsync(x => x.id == id);
|
||||
|
||||
if (getItem != null)
|
||||
{
|
||||
edit.Id = getItem.id;
|
||||
edit.TimeOfDayDisplay = getItem.TimeOfDay.ToString(@"hh\:mm");
|
||||
edit.DayOfMonth = getItem.DayOfMonth;
|
||||
edit.TypeOfSmsSetting = getItem.TypeOfSmsSetting;
|
||||
}
|
||||
|
||||
return edit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SmsSettingViewModel> GetSmsSettingsByType(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
var result = new SmsSettingViewModel();
|
||||
var data =await _context.SmsSettings
|
||||
.Where(x => x.TypeOfSmsSetting == typeOfSmsSetting).Select(x =>
|
||||
new EditSmsSetting
|
||||
{
|
||||
Id = x.id,
|
||||
DayOfMonth = x.DayOfMonth,
|
||||
IsActive = x.IsActive,
|
||||
TimeOfDay = x.TimeOfDay,
|
||||
TypeOfSmsSetting = x.TypeOfSmsSetting,
|
||||
TimeOfDayDisplay = x.TimeOfDay.ToString(@"hh\:mm")
|
||||
}).OrderBy(x=>x.DayOfMonth).ThenBy(x=>x.TimeOfDay).ToListAsync();
|
||||
|
||||
result.EditSmsSettings = data;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task RemoveItem(long id)
|
||||
{
|
||||
var removeItem = Get(id);
|
||||
_context.SmsSettings.Remove(removeItem);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
28
CompanyManagment.EFCore/Repository/ValueTuple.cs
Normal file
28
CompanyManagment.EFCore/Repository/ValueTuple.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace CompanyManagment.EFCore.Repository
|
||||
{
|
||||
internal class ValueTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>
|
||||
{
|
||||
private string phoneNumber;
|
||||
private int v1;
|
||||
private string partyName;
|
||||
private string balanceToMoney;
|
||||
private string id;
|
||||
private string aprove;
|
||||
private string v2;
|
||||
private string v3;
|
||||
private string v4;
|
||||
|
||||
public ValueTuple(string phoneNumber, int v1, string partyName, string balanceToMoney, string id, string aprove, string v2, string v3, string v4)
|
||||
{
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.v1 = v1;
|
||||
this.partyName = partyName;
|
||||
this.balanceToMoney = balanceToMoney;
|
||||
this.id = id;
|
||||
this.aprove = aprove;
|
||||
this.v2 = v2;
|
||||
this.v3 = v3;
|
||||
this.v4 = v4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,397 +10,524 @@ using IPE.SmsIrClient;
|
||||
using IPE.SmsIrClient.Models.Requests;
|
||||
using IPE.SmsIrClient.Models.Results;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SmsResult = Company.Domain.SmsResultAgg.SmsResult;
|
||||
|
||||
|
||||
namespace CompanyManagment.EFCore.Services;
|
||||
|
||||
public class SmsService : ISmsService
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
private readonly bool _isDevEnvironment;
|
||||
private readonly List<string> _testNumbers;
|
||||
public SmsIr SmsIr { get; set; }
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
private readonly bool _isDevEnvironment;
|
||||
private readonly List<string> _testNumbers;
|
||||
public SmsIr SmsIr { get; set; }
|
||||
|
||||
|
||||
public SmsService(IConfiguration configuration, ISmsResultRepository smsResultRepository)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_smsResultRepository = smsResultRepository;
|
||||
SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
public SmsService(IConfiguration configuration, ISmsResultRepository smsResultRepository)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_smsResultRepository = smsResultRepository;
|
||||
SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
|
||||
// خواندن تنظیمات SMS از appsettings
|
||||
var smsSettings = _configuration.GetSection("SmsSettings");
|
||||
_isDevEnvironment = smsSettings.GetValue<bool>("IsTestMode");
|
||||
_testNumbers = smsSettings.GetSection("TestNumbers").Get<List<string>>() ?? new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// متد مرکزی برای ارسال پیامک که محیط dev را چک میکند
|
||||
/// </summary>
|
||||
private async Task<SmsIrResult<VerifySendResult>> VerifySendSmsAsync(string number, int templateId, VerifySendParameter[] parameters)
|
||||
{
|
||||
// اگر محیط dev است و شمارههای تست وجود دارد، به شمارههای تست ارسال میشود
|
||||
if (_isDevEnvironment && _testNumbers is { Count: > 0 })
|
||||
{
|
||||
// ارسال به همه شمارههای تست
|
||||
SmsIrResult<VerifySendResult> lastResult = null;
|
||||
foreach (var testNumber in _testNumbers)
|
||||
{
|
||||
lastResult = await SmsIr.VerifySendAsync(testNumber, templateId, parameters);
|
||||
}
|
||||
return lastResult; // برگرداندن نتیجه آخرین ارسال
|
||||
}
|
||||
else
|
||||
{
|
||||
// ارسال به شماره واقعی
|
||||
return await SmsIr.VerifySendAsync(number, templateId, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
public void Send(string number, string message)
|
||||
{
|
||||
//var token = GetToken();
|
||||
//var lines = new SmsLine().GetSmsLines(token);
|
||||
//if (lines == null) return;
|
||||
|
||||
//var line = lines.SMSLines.Last().LineNumber.ToString();
|
||||
//var data = new MessageSendObject
|
||||
//{
|
||||
// Messages = new List<string>
|
||||
// {message}.ToArray(),
|
||||
// MobileNumbers = new List<string> {number}.ToArray(),
|
||||
// LineNumber = line,
|
||||
// SendDateTime = DateTime.Now,
|
||||
// CanContinueInCaseOfError = true
|
||||
//};
|
||||
//var messageSendResponseObject =
|
||||
// new MessageSend().Send(token, data);
|
||||
|
||||
//if (messageSendResponseObject.IsSuccessful) return;
|
||||
|
||||
//line = lines.SMSLines.First().LineNumber.ToString();
|
||||
//data.LineNumber = line;
|
||||
//new MessageSend().Send(token, data);
|
||||
}
|
||||
public bool VerifySend(string number, string message)
|
||||
{
|
||||
var verificationSendResult = VerifySendSmsAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", message) });
|
||||
Thread.Sleep(2000);
|
||||
if (verificationSendResult.IsCompletedSuccessfully)
|
||||
{
|
||||
|
||||
var resStartStatus = verificationSendResult.Result;
|
||||
var b = resStartStatus.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var a = verificationSendResult.IsCompleted;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var resStartStatus = verificationSendResult.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public bool LoginSend(string number, string message)
|
||||
{
|
||||
var verificationSendResult = VerifySendSmsAsync(number, 635330, new VerifySendParameter[] { new VerifySendParameter("LOGINCODE", message) });
|
||||
Thread.Sleep(2000);
|
||||
if (verificationSendResult.IsCompletedSuccessfully)
|
||||
{
|
||||
|
||||
var resStartStatus = verificationSendResult.Result;
|
||||
var b = resStartStatus.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var a = verificationSendResult.IsCompleted;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var resStartStatus = verificationSendResult.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<SentSmsViewModel> SendVerifyCodeToClient(string number, string code)
|
||||
{
|
||||
var result = new SentSmsViewModel();
|
||||
var sendResult = await VerifySendSmsAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", code) });
|
||||
Thread.Sleep(2000);
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
var status = sendResult.Status;
|
||||
var message = sendResult.Message;
|
||||
var messaeId = sendResult.Data.MessageId;
|
||||
return result.Succedded(status, message, messaeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var status = sendResult.Status;
|
||||
var message = sendResult.Message;
|
||||
var messaeId = sendResult.Data.MessageId;
|
||||
return result.Failed(status, message, messaeId);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SendAccountsInfo(string number, string fullName, string userName)
|
||||
{
|
||||
|
||||
var checkLength = fullName.Length;
|
||||
if (checkLength > 25)
|
||||
fullName = fullName.Substring(0, 24);
|
||||
|
||||
var sendResult = VerifySendSmsAsync(number, 725814, new VerifySendParameter[] { new VerifySendParameter("FULLNAME", fullName), new VerifySendParameter("USERNAME", userName), new VerifySendParameter("PASSWORD", userName) });
|
||||
|
||||
|
||||
Console.WriteLine(userName + " - " + sendResult.Result.Status);
|
||||
if (sendResult.IsCompletedSuccessfully)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<ApiResultViewModel> GetByMessageId(int messId)
|
||||
{
|
||||
|
||||
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var response = await smsIr.GetReportAsync(messId);
|
||||
MessageReportResult messages = response.Data;
|
||||
|
||||
var appendData = new ApiResultViewModel()
|
||||
{
|
||||
MessageId = messages.MessageId,
|
||||
LineNumber = messages.LineNumber,
|
||||
Mobile = messages.Mobile,
|
||||
MessageText = messages.MessageText,
|
||||
SendUnixTime = UnixTimeStampToDateTime(messages.SendDateTime),
|
||||
DeliveryState = DeliveryStatus(messages.DeliveryState),
|
||||
DeliveryUnixTime = UnixTimeStampToDateTime(messages.DeliveryDateTime),
|
||||
DeliveryColor = DeliveryColorStatus(messages.DeliveryState),
|
||||
};
|
||||
return appendData;
|
||||
}
|
||||
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();
|
||||
}
|
||||
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;
|
||||
// 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 ApiResultViewModel()
|
||||
{
|
||||
MessageId = message.MessageId,
|
||||
LineNumber = message.LineNumber,
|
||||
Mobile = message.Mobile,
|
||||
MessageText = message.MessageText,
|
||||
SendUnixTime = UnixTimeStampToDateTime(message.SendDateTime),
|
||||
DeliveryState = DeliveryStatus(message.DeliveryState),
|
||||
DeliveryUnixTime = UnixTimeStampToDateTime(message.DeliveryDateTime),
|
||||
DeliveryColor = DeliveryColorStatus(message.DeliveryState),
|
||||
};
|
||||
res.Add(appendData);
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
// خواندن تنظیمات SMS از appsettings
|
||||
var smsSettings = _configuration.GetSection("SmsSettings");
|
||||
_isDevEnvironment = smsSettings.GetValue<bool>("IsTestMode");
|
||||
_testNumbers = smsSettings.GetSection("TestNumbers").Get<List<string>>() ?? new List<string>();
|
||||
}
|
||||
|
||||
public string DeliveryStatus(byte? dv)
|
||||
{
|
||||
string mess = "";
|
||||
switch (dv)
|
||||
{
|
||||
case 1:
|
||||
mess = "رسیده به گوشی";
|
||||
break;
|
||||
case 2:
|
||||
mess = "نرسیده به گوشی";
|
||||
break;
|
||||
case 3:
|
||||
mess = "پردازش در مخابرات";
|
||||
break;
|
||||
case 4:
|
||||
mess = "نرسیده به مخابرات";
|
||||
break;
|
||||
case 5:
|
||||
mess = "سیده به مخابرات";
|
||||
break;
|
||||
case 6:
|
||||
mess = "خطا";
|
||||
break;
|
||||
case 7:
|
||||
mess = "لیست سیاه";
|
||||
break;
|
||||
default:
|
||||
mess="";
|
||||
break;
|
||||
/// <summary>
|
||||
/// متد مرکزی برای ارسال پیامک که محیط dev را چک میکند
|
||||
/// </summary>
|
||||
private async Task<SmsIrResult<VerifySendResult>> VerifySendSmsAsync(string number, int templateId, VerifySendParameter[] parameters)
|
||||
{
|
||||
// اگر محیط dev است و شمارههای تست وجود دارد، به شمارههای تست ارسال میشود
|
||||
if (_isDevEnvironment && _testNumbers is { Count: > 0 })
|
||||
{
|
||||
// ارسال به همه شمارههای تست
|
||||
SmsIrResult<VerifySendResult> lastResult = null;
|
||||
foreach (var testNumber in _testNumbers)
|
||||
{
|
||||
lastResult = await SmsIr.VerifySendAsync(testNumber, templateId, parameters);
|
||||
}
|
||||
return lastResult; // برگرداندن نتیجه آخرین ارسال
|
||||
}
|
||||
else
|
||||
{
|
||||
// ارسال به شماره واقعی
|
||||
return await SmsIr.VerifySendAsync(number, templateId, parameters);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void Send(string number, string message)
|
||||
{
|
||||
//var token = GetToken();
|
||||
//var lines = new SmsLine().GetSmsLines(token);
|
||||
//if (lines == null) return;
|
||||
|
||||
return mess;
|
||||
}
|
||||
public string DeliveryColorStatus(byte? dv)
|
||||
{
|
||||
string mess = "";
|
||||
switch (dv)
|
||||
{
|
||||
case 1:
|
||||
mess = "successSend";
|
||||
break;
|
||||
case 2:
|
||||
mess = "errSend";
|
||||
break;
|
||||
case 3:
|
||||
mess = "pSend";
|
||||
break;
|
||||
case 4:
|
||||
mess = "noSend";
|
||||
break;
|
||||
case 5:
|
||||
mess = "itcSend";
|
||||
break;
|
||||
case 6:
|
||||
mess = "redSend";
|
||||
break;
|
||||
case 7:
|
||||
mess = "blockSend";
|
||||
break;
|
||||
default:
|
||||
mess = "";
|
||||
break;
|
||||
//var line = lines.SMSLines.Last().LineNumber.ToString();
|
||||
//var data = new MessageSendObject
|
||||
//{
|
||||
// Messages = new List<string>
|
||||
// {message}.ToArray(),
|
||||
// MobileNumbers = new List<string> {number}.ToArray(),
|
||||
// LineNumber = line,
|
||||
// SendDateTime = DateTime.Now,
|
||||
// CanContinueInCaseOfError = true
|
||||
//};
|
||||
//var messageSendResponseObject =
|
||||
// new MessageSend().Send(token, data);
|
||||
|
||||
}
|
||||
//if (messageSendResponseObject.IsSuccessful) return;
|
||||
|
||||
return mess;
|
||||
}
|
||||
public string UnixTimeStampToDateTime(int? unixTimeStamp)
|
||||
{
|
||||
if (unixTimeStamp != null)
|
||||
{
|
||||
// Unix timestamp is seconds past epoch
|
||||
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
dateTime = dateTime.AddSeconds(Convert.ToDouble(unixTimeStamp)).ToLocalTime();
|
||||
var time = dateTime.ToFarsiFull();
|
||||
return time;
|
||||
}
|
||||
//line = lines.SMSLines.First().LineNumber.ToString();
|
||||
//data.LineNumber = line;
|
||||
//new MessageSend().Send(token, data);
|
||||
}
|
||||
public bool VerifySend(string number, string message)
|
||||
{
|
||||
var verificationSendResult = VerifySendSmsAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", message) });
|
||||
Thread.Sleep(2000);
|
||||
if (verificationSendResult.IsCompletedSuccessfully)
|
||||
{
|
||||
|
||||
return "";
|
||||
}
|
||||
private string GetToken()
|
||||
{
|
||||
return "";
|
||||
//var smsSecrets = _configuration.GetSection("SmsSecrets");
|
||||
//var tokenService = new Token();
|
||||
//return tokenService.GetToken("x-api-key", "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
}
|
||||
var resStartStatus = verificationSendResult.Result;
|
||||
var b = resStartStatus.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var a = verificationSendResult.IsCompleted;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#region Mahan
|
||||
var resStartStatus = verificationSendResult.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
|
||||
public async Task<double> GetCreditAmount()
|
||||
{
|
||||
try
|
||||
{
|
||||
var credit = await SmsIr.GetCreditAsync();
|
||||
return (double)credit.Data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId)
|
||||
{
|
||||
var guidStr=institutionId.ToString();
|
||||
var firstPart = guidStr.Substring(0, 15);
|
||||
var secondPart = guidStr.Substring(15);
|
||||
var verificationSendResult =await VerifySendSmsAsync(number, 527519, new VerifySendParameter[]
|
||||
{
|
||||
new("FULLNAME", fullName),
|
||||
new("CODE1",firstPart),
|
||||
new("CODE2",secondPart)
|
||||
});
|
||||
|
||||
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ایجاد قرارداد مالی",
|
||||
fullName, number, contractingPartyId, institutionContractId);
|
||||
await _smsResultRepository.CreateAsync(smsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionAmendmentVerificationLink(string number, string fullName, Guid institutionId,
|
||||
long contractingPartyId, long institutionContractId)
|
||||
{
|
||||
var guidStr=institutionId.ToString();
|
||||
var firstPart = guidStr.Substring(0, 15);
|
||||
var secondPart = guidStr.Substring(15);
|
||||
var verificationSendResult =await VerifySendSmsAsync(number, 527519, new VerifySendParameter[]
|
||||
{
|
||||
new("FULLNAME", fullName),
|
||||
new("CODE1",firstPart),
|
||||
new("CODE2",secondPart)
|
||||
});
|
||||
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ارتقا قرارداد مالی",
|
||||
fullName, number, contractingPartyId, institutionContractId);
|
||||
await _smsResultRepository.CreateAsync(smsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
|
||||
long contractingPartyId, long institutionContractId)
|
||||
{
|
||||
var verificationSendResult =await VerifySendSmsAsync(number, 965348, new VerifySendParameter[]
|
||||
{
|
||||
new("VERIFYCODE", code)
|
||||
});
|
||||
|
||||
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "کد تاییدیه قرارداد مالی",
|
||||
contractingPartyFullName, number, contractingPartyId, institutionContractId);
|
||||
await _smsResultRepository.CreateAsync(smsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public bool LoginSend(string number, string message)
|
||||
{
|
||||
var verificationSendResult = VerifySendSmsAsync(number, 635330, new VerifySendParameter[] { new VerifySendParameter("LOGINCODE", message) });
|
||||
Thread.Sleep(2000);
|
||||
if (verificationSendResult.IsCompletedSuccessfully)
|
||||
{
|
||||
|
||||
var resStartStatus = verificationSendResult.Result;
|
||||
var b = resStartStatus.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var a = verificationSendResult.IsCompleted;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var resStartStatus = verificationSendResult.Status;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<SentSmsViewModel> SendVerifyCodeToClient(string number, string code)
|
||||
{
|
||||
var result = new SentSmsViewModel();
|
||||
var sendResult = await VerifySendSmsAsync(number, 768382, new VerifySendParameter[] { new VerifySendParameter("VerificationCode", code) });
|
||||
Thread.Sleep(2000);
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
var status = sendResult.Status;
|
||||
var message = sendResult.Message;
|
||||
var messaeId = sendResult.Data.MessageId;
|
||||
return result.Succedded(status, message, messaeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
var status = sendResult.Status;
|
||||
var message = sendResult.Message;
|
||||
var messaeId = sendResult.Data.MessageId;
|
||||
return result.Failed(status, message, messaeId);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SendAccountsInfo(string number, string fullName, string userName)
|
||||
{
|
||||
|
||||
var checkLength = fullName.Length;
|
||||
if (checkLength > 25)
|
||||
fullName = fullName.Substring(0, 24);
|
||||
|
||||
var sendResult = VerifySendSmsAsync(number, 725814, new VerifySendParameter[] { new VerifySendParameter("FULLNAME", fullName), new VerifySendParameter("USERNAME", userName), new VerifySendParameter("PASSWORD", userName) });
|
||||
|
||||
|
||||
Console.WriteLine(userName + " - " + sendResult.Result.Status);
|
||||
if (sendResult.IsCompletedSuccessfully)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<ApiResultViewModel> GetByMessageId(int messId)
|
||||
{
|
||||
|
||||
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var response = await smsIr.GetReportAsync(messId);
|
||||
MessageReportResult messages = response.Data;
|
||||
|
||||
var appendData = new ApiResultViewModel()
|
||||
{
|
||||
MessageId = messages.MessageId,
|
||||
LineNumber = messages.LineNumber,
|
||||
Mobile = messages.Mobile,
|
||||
MessageText = messages.MessageText,
|
||||
SendUnixTime = UnixTimeStampToDateTime(messages.SendDateTime),
|
||||
DeliveryState = DeliveryStatus(messages.DeliveryState),
|
||||
DeliveryUnixTime = UnixTimeStampToDateTime(messages.DeliveryDateTime),
|
||||
DeliveryColor = DeliveryColorStatus(messages.DeliveryState),
|
||||
};
|
||||
return appendData;
|
||||
}
|
||||
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();
|
||||
}
|
||||
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;
|
||||
// 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 ApiResultViewModel()
|
||||
{
|
||||
MessageId = message.MessageId,
|
||||
LineNumber = message.LineNumber,
|
||||
Mobile = message.Mobile,
|
||||
MessageText = message.MessageText,
|
||||
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 = "";
|
||||
switch (dv)
|
||||
{
|
||||
case 1:
|
||||
mess = "رسیده به گوشی";
|
||||
break;
|
||||
case 2:
|
||||
mess = "نرسیده به گوشی";
|
||||
break;
|
||||
case 3:
|
||||
mess = "پردازش در مخابرات";
|
||||
break;
|
||||
case 4:
|
||||
mess = "نرسیده به مخابرات";
|
||||
break;
|
||||
case 5:
|
||||
mess = "سیده به مخابرات";
|
||||
break;
|
||||
case 6:
|
||||
mess = "خطا";
|
||||
break;
|
||||
case 7:
|
||||
mess = "لیست سیاه";
|
||||
break;
|
||||
default:
|
||||
mess = "";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return mess;
|
||||
}
|
||||
public string DeliveryColorStatus(byte? dv)
|
||||
{
|
||||
string mess = "";
|
||||
switch (dv)
|
||||
{
|
||||
case 1:
|
||||
mess = "successSend";
|
||||
break;
|
||||
case 2:
|
||||
mess = "errSend";
|
||||
break;
|
||||
case 3:
|
||||
mess = "pSend";
|
||||
break;
|
||||
case 4:
|
||||
mess = "noSend";
|
||||
break;
|
||||
case 5:
|
||||
mess = "itcSend";
|
||||
break;
|
||||
case 6:
|
||||
mess = "redSend";
|
||||
break;
|
||||
case 7:
|
||||
mess = "blockSend";
|
||||
break;
|
||||
default:
|
||||
mess = "";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return mess;
|
||||
}
|
||||
public string UnixTimeStampToDateTime(int? unixTimeStamp)
|
||||
{
|
||||
if (unixTimeStamp != null)
|
||||
{
|
||||
// Unix timestamp is seconds past epoch
|
||||
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
dateTime = dateTime.AddSeconds(Convert.ToDouble(unixTimeStamp)).ToLocalTime();
|
||||
var time = dateTime.ToFarsiFull();
|
||||
return time;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
private string GetToken()
|
||||
{
|
||||
return "";
|
||||
//var smsSecrets = _configuration.GetSection("SmsSecrets");
|
||||
//var tokenService = new Token();
|
||||
//return tokenService.GetToken("x-api-key", "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
}
|
||||
|
||||
#region Mahan
|
||||
|
||||
public async Task<double> GetCreditAmount()
|
||||
{
|
||||
try
|
||||
{
|
||||
var credit = await SmsIr.GetCreditAsync();
|
||||
return (double)credit.Data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId)
|
||||
{
|
||||
var full = fullName;
|
||||
var fullName1 = fullName;
|
||||
if (fullName.Length >= 25)
|
||||
{
|
||||
fullName1 = fullName.Substring(0, 25);
|
||||
}
|
||||
var fullName2 = "";
|
||||
if (full.Length > 25)
|
||||
{
|
||||
fullName2 = full.Substring(25);
|
||||
if (fullName2.Length>25)
|
||||
{
|
||||
fullName2 = fullName2.Substring(0, 25);
|
||||
}
|
||||
}
|
||||
var guidStr = institutionId.ToString();
|
||||
var firstPart = guidStr.Substring(0, 15);
|
||||
var secondPart = guidStr.Substring(15);
|
||||
var verificationSendResult = await VerifySendSmsAsync(number, 527519, new VerifySendParameter[]
|
||||
{
|
||||
new("FULLNAME1", fullName1),
|
||||
new("FULLNAME2", fullName2),
|
||||
new("CODE1",firstPart),
|
||||
new("CODE2",secondPart)
|
||||
});
|
||||
|
||||
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ایجاد قرارداد مالی",
|
||||
fullName, number, contractingPartyId, institutionContractId);
|
||||
await _smsResultRepository.CreateAsync(smsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionAmendmentVerificationLink(string number, string fullName, Guid institutionId,
|
||||
long contractingPartyId, long institutionContractId)
|
||||
{
|
||||
var guidStr = institutionId.ToString();
|
||||
var firstPart = guidStr.Substring(0, 15);
|
||||
var secondPart = guidStr.Substring(15);
|
||||
var verificationSendResult = await VerifySendSmsAsync(number, 527519, new VerifySendParameter[]
|
||||
{
|
||||
new("FULLNAME", fullName),
|
||||
new("CODE1",firstPart),
|
||||
new("CODE2",secondPart)
|
||||
});
|
||||
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه ارتقا قرارداد مالی",
|
||||
fullName, number, contractingPartyId, institutionContractId);
|
||||
await _smsResultRepository.CreateAsync(smsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
|
||||
public async Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
|
||||
long contractingPartyId, long institutionContractId)
|
||||
{
|
||||
var verificationSendResult = await VerifySendSmsAsync(number, 965348, new VerifySendParameter[]
|
||||
{
|
||||
new("VERIFYCODE", code)
|
||||
});
|
||||
|
||||
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "کد تاییدیه قرارداد مالی",
|
||||
contractingPartyFullName, number, contractingPartyId, institutionContractId);
|
||||
await _smsResultRepository.CreateAsync(smsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
return verificationSendResult.Status == 0;
|
||||
}
|
||||
|
||||
public _0_Framework.Application.Sms.SmsResult TaskReminderSms(string number, string taskCount)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region InstitutionContractSMS
|
||||
|
||||
public async Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBillNew(string number, int tamplateId, string fullname, string amount, string code1,
|
||||
string code2)
|
||||
{
|
||||
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var result = new ValueTuple<byte, string, int, bool>();
|
||||
var sendResult = await smsIr.VerifySendAsync(number, tamplateId,
|
||||
new VerifySendParameter[]
|
||||
{ new("FULLNAME", fullname), new("AMOUNT", amount), new("CODE1", code1), new("CODE2", code2) });
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
public async Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBill(string number, int tamplateId, string fullname, string amount, string id,
|
||||
string aprove)
|
||||
{
|
||||
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var result = new ValueTuple<byte, string, int, bool>();
|
||||
var sendResult = await smsIr.VerifySendAsync(number, tamplateId,
|
||||
new VerifySendParameter[]
|
||||
{ new("FULLNAME", fullname), new("AMOUNT", amount), new("ID", id), new("APROVE", aprove) });
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<(byte status, string message, int messaeId, bool isSucceded)> BlockMessage(string number, string fullname, string amount, string accountType, string id,
|
||||
string aprove)
|
||||
{
|
||||
var tamplateId = 117946;
|
||||
var result = new ValueTuple<byte, string, int, bool>();
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
|
||||
var sendResult = await smsIr.VerifySendAsync(number, tamplateId,
|
||||
new VerifySendParameter[]
|
||||
{
|
||||
new("FULLNAME", fullname), new("AMOUNT", amount), new("ACCOUNTTYPE", accountType), new("ID", id),
|
||||
new("APROVE", aprove)
|
||||
});
|
||||
Thread.Sleep(500);
|
||||
|
||||
|
||||
if (sendResult.Message == "موفق")
|
||||
{
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region AlarmMessage
|
||||
|
||||
public async Task<bool> Alarm(string number, string message)
|
||||
{
|
||||
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
|
||||
//var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" });
|
||||
|
||||
var verificationSendResult =
|
||||
smsIr.VerifySendAsync(number, 662874, new VerifySendParameter[] { new("ALARM", message) });
|
||||
Thread.Sleep(1000);
|
||||
var status = verificationSendResult.Result.Status;
|
||||
var mess = verificationSendResult.Result.Message;
|
||||
var messaeId = verificationSendResult.Result.Data.MessageId;
|
||||
if (verificationSendResult.IsCompletedSuccessfully) return true;
|
||||
|
||||
var resStartStatus = verificationSendResult.Result;
|
||||
var resResult = verificationSendResult.Status;
|
||||
var reseExceptiont = verificationSendResult.Exception;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ public class UidService : IUidService
|
||||
{
|
||||
_httpClient = new HttpClient()
|
||||
{
|
||||
BaseAddress = new Uri(BaseUrl)
|
||||
BaseAddress = new Uri(BaseUrl),
|
||||
Timeout = new TimeSpan(0, 0, 12)
|
||||
};
|
||||
_authorizedPersonApplication = authorizedPersonApplication;
|
||||
_authorizedBankDetailsApplication = authorizedBankDetailsApplication;
|
||||
@@ -63,6 +64,7 @@ public class UidService : IUidService
|
||||
try
|
||||
{
|
||||
var requestResult = await _httpClient.PostAsync("inquiry/person/v2", contentType);
|
||||
|
||||
if (!requestResult.IsSuccessStatusCode)
|
||||
return null;
|
||||
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
|
||||
@@ -79,7 +81,7 @@ public class UidService : IUidService
|
||||
return responseResult;
|
||||
}
|
||||
catch
|
||||
{
|
||||
{
|
||||
return new PersonalInfoResponse(new UidBasicInformation(),
|
||||
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
|
||||
new ResponseContext(new UidStatus(14, "")));
|
||||
|
||||
@@ -80,8 +80,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Query.Bootstrapper", "Query
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyManagement.Infrastructure.Excel", "CompanyManagement.Infrastructure.Excel\CompanyManagement.Infrastructure.Excel.csproj", "{BF98173C-42AF-4897-A7CB-4CACEB2B52A2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundJobs.Task", "BackgroundJobs\BackgroundJobs.Task\BackgroundJobs.Task.csproj", "{97E148FA-3C36-40DD-B121-D90C1C0F3B47}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BackgroundJobs", "BackgroundJobs", "{C10E256D-7E7D-4C77-B416-E577A34AF924}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyManagement.Infrastructure.Mongo", "CompanyManagement.Infrastructure.Mongo\CompanyManagement.Infrastructure.Mongo.csproj", "{4CDAA60E-C7DD-4883-85CC-E7E26CCC6ED3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundInstitutionContract.Task", "BackgroundInstitutionContract\BackgroundInstitutionContract.Task\BackgroundInstitutionContract.Task.csproj", "{F78FBB92-294B-88BA-168D-F0C578B0D7D6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -180,10 +186,18 @@ Global
|
||||
{BF98173C-42AF-4897-A7CB-4CACEB2B52A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BF98173C-42AF-4897-A7CB-4CACEB2B52A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BF98173C-42AF-4897-A7CB-4CACEB2B52A2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{97E148FA-3C36-40DD-B121-D90C1C0F3B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{97E148FA-3C36-40DD-B121-D90C1C0F3B47}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{97E148FA-3C36-40DD-B121-D90C1C0F3B47}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{97E148FA-3C36-40DD-B121-D90C1C0F3B47}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4CDAA60E-C7DD-4883-85CC-E7E26CCC6ED3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4CDAA60E-C7DD-4883-85CC-E7E26CCC6ED3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4CDAA60E-C7DD-4883-85CC-E7E26CCC6ED3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4CDAA60E-C7DD-4883-85CC-E7E26CCC6ED3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -218,7 +232,8 @@ Global
|
||||
{339E05B6-E99F-4403-AFDF-CD0540E96C8D} = {708E8D7E-F190-47C5-B78E-F43131FB7D6D}
|
||||
{02892882-2A02-484B-BAF9-7E63F6BDCFA0} = {708E8D7E-F190-47C5-B78E-F43131FB7D6D}
|
||||
{BF98173C-42AF-4897-A7CB-4CACEB2B52A2} = {86921E1B-2AFA-4B8A-9403-EE16D58B5B26}
|
||||
{4CDAA60E-C7DD-4883-85CC-E7E26CCC6ED3} = {86921E1B-2AFA-4B8A-9403-EE16D58B5B26}
|
||||
{97E148FA-3C36-40DD-B121-D90C1C0F3B47} = {C10E256D-7E7D-4C77-B416-E577A34AF924}
|
||||
{F78FBB92-294B-88BA-168D-F0C578B0D7D6} = {C10E256D-7E7D-4C77-B416-E577A34AF924}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E6CFB3A7-A7C8-4E82-8F06-F750408F0BA9}
|
||||
|
||||
@@ -214,6 +214,7 @@ using Company.Domain.AuthorizedBankDetailsAgg;
|
||||
using Company.Domain.ContractingPartyBankAccountsAgg;
|
||||
using Company.Domain.PaymentInstrumentAgg;
|
||||
using Company.Domain.PaymentTransactionAgg;
|
||||
using Company.Domain.FinancialInvoiceAgg;
|
||||
using CompanyManagment.App.Contracts.AdminMonthlyOverview;
|
||||
using CompanyManagment.App.Contracts.ContractingPartyBankAccounts;
|
||||
using CompanyManagment.App.Contracts.PaymentInstrument;
|
||||
@@ -228,6 +229,7 @@ using CompanyManagement.Infrastructure.Mongo.InstitutionContractInsertTempRepo;
|
||||
using CompanyManagment.App.Contracts.EmployeeFaceEmbedding;
|
||||
using CompanyManagment.App.Contracts.Law;
|
||||
using CompanyManagment.EFCore.Repository;
|
||||
using CompanyManagment.App.Contracts.FinancialInvoice;
|
||||
using _0_Framework.Application.FaceEmbedding;
|
||||
using _0_Framework.Infrastructure;
|
||||
using _0_Framework.InfraStructure;
|
||||
@@ -484,11 +486,14 @@ public class PersonalBootstrapper
|
||||
services.AddTransient<IAuthorizedBankDetailsApplication, AuthorizedBankDetailsApplication>();
|
||||
|
||||
services
|
||||
.AddTransient<IInstitutionContractExtenstionTempRepository, InstitutionContractExtenstionTempRepository>();
|
||||
.AddTransient<IInstitutionContractExtenstionTempRepository, InstitutionContractExtenstionTempRepository>();
|
||||
|
||||
services.AddTransient<IEmployeeFaceEmbeddingRepository, EmployeeFaceEmbeddingRepository>();
|
||||
services.AddTransient<IEmployeeFaceEmbeddingApplication, EmployeeFaceEmbeddingApplication>();
|
||||
|
||||
|
||||
services.AddTransient<IFinancialInvoiceRepository, FinancialInvoiceRepository>();
|
||||
services.AddTransient<IFinancialInvoiceApplication, FinancialInvoiceApplication>();
|
||||
#endregion
|
||||
|
||||
#region Pooya
|
||||
@@ -533,6 +538,14 @@ public class PersonalBootstrapper
|
||||
|
||||
services.AddTransient<IPlanPercentageRepository, PlanPercentageRepository>();
|
||||
services.AddTransient<IInstitutionPlanApplication, InstitutionPlanApplication>();
|
||||
|
||||
|
||||
#region SmsSettings
|
||||
|
||||
services.AddTransient<ISmsSettingsRepository, SmsSettingsRepository>();
|
||||
services.AddTransient<ISmsSettingApplication, SmsSettingApplication>();
|
||||
|
||||
#endregion
|
||||
//=========End Of Main====================================
|
||||
|
||||
//---File Project------------------------------------
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Concurrent;
|
||||
using System.Transactions;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.PaymentGateway;
|
||||
using _0_Framework.Application.Sms;
|
||||
using _0_Framework.Exceptions;
|
||||
using AccountManagement.Application.Contracts.Account;
|
||||
@@ -37,6 +38,8 @@ public class institutionContractController : AdminBaseController
|
||||
private readonly IWorkshopApplication _workshopApplication;
|
||||
private readonly ITemporaryClientRegistrationApplication _temporaryClientRegistration;
|
||||
private readonly ITemporaryClientRegistrationApplication _clientRegistrationApplication;
|
||||
private readonly IPaymentGateway _paymentGateway;
|
||||
|
||||
private static readonly ConcurrentDictionary<Guid, SemaphoreSlim> _locks
|
||||
= new ConcurrentDictionary<Guid, SemaphoreSlim>();
|
||||
|
||||
@@ -45,7 +48,8 @@ public class institutionContractController : AdminBaseController
|
||||
public institutionContractController(IInstitutionContractApplication institutionContractApplication,
|
||||
IPersonalContractingPartyApp contractingPartyApplication, IContactInfoApplication contactInfoApplication,
|
||||
IAccountApplication accountApplication, IEmployerApplication employerApplication,
|
||||
IWorkshopApplication workshopApplication, ITemporaryClientRegistrationApplication temporaryClientRegistration, ITemporaryClientRegistrationApplication clientRegistrationApplication)
|
||||
IWorkshopApplication workshopApplication, ITemporaryClientRegistrationApplication temporaryClientRegistration,
|
||||
ITemporaryClientRegistrationApplication clientRegistrationApplication,IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
_institutionContractApplication = institutionContractApplication;
|
||||
_contractingPartyApplication = contractingPartyApplication;
|
||||
@@ -55,6 +59,7 @@ public class institutionContractController : AdminBaseController
|
||||
_workshopApplication = workshopApplication;
|
||||
_temporaryClientRegistration = temporaryClientRegistration;
|
||||
_clientRegistrationApplication = clientRegistrationApplication;
|
||||
_paymentGateway = new SepehrPaymentGateway(httpClientFactory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -469,11 +474,38 @@ public class institutionContractController : AdminBaseController
|
||||
|
||||
[HttpPost("/api/institutionContract/Verify")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<OperationResult>> Verify([FromBody] InstitutionVerificationRequest command)
|
||||
public async Task<ActionResult<OperationResult<string>>> Verify([FromBody] InstitutionVerificationRequest command)
|
||||
{
|
||||
var res = await _institutionContractApplication.VerifyOtp(command.Id, command.Code);
|
||||
return res;
|
||||
// URL برای redirect به درگاه پرداخت
|
||||
var paymentRedirectUrl = Url.Action("ProcessPayment", "institutionContract", null, Request.Scheme);
|
||||
var callback = Url.Action("Verify", "General", null, Request.Scheme);
|
||||
var res = await _institutionContractApplication.VerifyOtpAndMakeGateway(command.Id, command.Code, callback);
|
||||
|
||||
if (!res.IsSuccedded)
|
||||
return new OperationResult<string>().Failed(res.Message);
|
||||
|
||||
var payUrl = _paymentGateway.GetStartPayUrl(res.Data);
|
||||
|
||||
// URL کامل برای redirect شامل paymentUrl به عنوان query parameter
|
||||
var redirectUrl = $"{paymentRedirectUrl}?paymentUrl={Uri.EscapeDataString(payUrl)}";
|
||||
|
||||
return new OperationResult<string>().Succcedded(redirectUrl);
|
||||
}
|
||||
|
||||
[HttpGet("/api/institutionContract/ProcessPayment")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ProcessPayment([FromQuery] string paymentUrl)
|
||||
{
|
||||
if (string.IsNullOrEmpty(paymentUrl))
|
||||
{
|
||||
return BadRequest("Payment URL is required");
|
||||
}
|
||||
|
||||
// redirect به درگاه پرداخت
|
||||
return Redirect(paymentUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost("/api/institutionContract/Verification/{id:guid}/send-otp")]
|
||||
[AllowAnonymous]
|
||||
|
||||
@@ -278,6 +278,7 @@
|
||||
<input type="hidden" id="mobile" name="Mobile" value="@Model.Mobile"/>
|
||||
<input type="hidden" id="typeOfSms" name="TypeOfSms" value="@Model.TypeOfSms"/>
|
||||
<a asp-page="/Company/SmsResult/ApiResults" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 api">گزارش ای پی آی</a>
|
||||
<a asp-page="/Company/SmsResult/SmsSettings" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 api"> تنظیمات پیامک خودکار </a>
|
||||
<div class="container filter">
|
||||
<h3 class="panel-title" style="display: inline-block;color: #7a96a6"><i class="fa fa-search" style="padding-left: 3px; font-size: 14px"></i> جستجو</h3>
|
||||
<button class="btn btn-info btn-rounded waves-effect waves-light m-b-5 goToTop"> <i class="fa fa-chevron-up" style="font-size: 20px"></i> برو بالا</button>
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
@page
|
||||
@using _0_Framework.Application.Enums
|
||||
@using Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@model ServiceHost.Areas.Admin.Pages.Company.SmsResult.SmsSettingsModel
|
||||
@Html.AntiForgeryToken()
|
||||
@{
|
||||
|
||||
string adminVersion = _0_Framework.Application.Version.AdminVersion;
|
||||
<link href="~/admintheme/css/workshop-create.css?ver=@adminVersion" rel="stylesheet" />
|
||||
<style>
|
||||
body{
|
||||
|
||||
background-color: #fefefe;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%232ebfbf' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
.hiddenTab{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.errored {
|
||||
animation: shake 300ms;
|
||||
box-shadow: inset 0 0 2px #eb3434, 0 0 5px #eb3434 !important;
|
||||
border: 1px solid #eb3434 !important;
|
||||
}
|
||||
|
||||
.date-input {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button.rounded-pill {
|
||||
border-radius: 5px !important;
|
||||
}
|
||||
|
||||
.instantSendSms {
|
||||
background-color: #75aea7;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div style="max-width: 80%;margin: 0 auto">
|
||||
<div class="col-xs-12" style="float: unset;">
|
||||
<div class="handle-title">
|
||||
<h3 id="titleHead"> تنظیمات پیامک های خودکار مالی </h3>
|
||||
<a asp-page="./index" class="btn btn-rounded" type="button">
|
||||
<span>بازگشت</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-xs-12" style="float: unset;">
|
||||
<div class="card card-pattern">
|
||||
<ul class="nav nav-tabs nav-fill wizard" id="myTab" role="tablist">
|
||||
|
||||
<li class="li-wizard step active" id="institutionContractDebtReminderTab" data-url="/Admin/Company/SmsResult/SmsSettings?handler=InstitutionContractDebtReminderTab">
|
||||
<a class="nav-link">
|
||||
<div class="success-icon" id="success-icon1" style="display:none;">
|
||||
<svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1.25 4L4.14393 6.89393C4.20251 6.95251 4.29749 6.95251 4.35607 6.89393L10.25 1" stroke="#222222" stroke-width="1.2" />
|
||||
</svg>
|
||||
</div>
|
||||
<span> پیامک یاد آور </span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="li-wizard step" id="blockContractingPartyTab" data-url="/Admin/Company/SmsResult/SmsSettings?handler=BlockContractingPartyTab">
|
||||
<a class="nav-link">
|
||||
<div class="success-icon" id="success-icon2" style="display:none;">
|
||||
<svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1.25 4L4.14393 6.89393C4.20251 6.95251 4.29749 6.95251 4.35607 6.89393L10.25 1" stroke="#222222" stroke-width="1.2" />
|
||||
</svg>
|
||||
</div>
|
||||
<span> پیامک مسدودی </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="li-wizard step" id="warningTab" data-url="/Admin/Company/SmsResult/SmsSettings?handler=WarningTab">
|
||||
<a class="nav-link">
|
||||
<div class="success-icon" id="success-icon3" style="display:none;">
|
||||
<svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1.25 4L4.14393 6.89393C4.20251 6.95251 4.29749 6.95251 4.35607 6.89393L10.25 1" stroke="#222222" stroke-width="1.2" />
|
||||
</svg>
|
||||
</div>
|
||||
<span> پیامک هشدار برای اقدام قضائی </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="li-wizard step" id="legalActionTab" data-url="/Admin/Company/SmsResult/SmsSettings?handler=LegalActionTab">
|
||||
<a class="nav-link">
|
||||
<div class="success-icon" id="success-icon2" style="display:none;">
|
||||
<svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1.25 4L4.14393 6.89393C4.20251 6.95251 4.29749 6.95251 4.35607 6.89393L10.25 1" stroke="#222222" stroke-width="1.2" />
|
||||
</svg>
|
||||
</div>
|
||||
<span> پیامک اقدام قضائی </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="partial-tabs" id="partialContainer"></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Script
|
||||
{
|
||||
<script src="~/AdminTheme/assets/js/site.js"></script>
|
||||
<script src="~/AdminTheme/js/numeral.min.js"></script>
|
||||
<script src="~/admintheme/js/jquery.mask_1.14.16.min.js"></script>
|
||||
<script src="~/js/signalr/dist/browser/signalr.js"></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('.time-input').mask('00:00', {
|
||||
translation: {
|
||||
'0': {pattern: /[0-9]/},
|
||||
// برای اولین رقم ساعت فقط 0-2
|
||||
'H': {pattern: /[0-2]/},
|
||||
// اگر اولین رقم 2 باشد دومین رقم فقط 0-3
|
||||
'h': {pattern: /[0-3]/},
|
||||
// برای دقیقه
|
||||
'M': {pattern: /[0-5]/},
|
||||
'm': {pattern: /[0-9]/},
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// پیشفرض: لود تب اول با workshopId
|
||||
loadPartial("/Admin/Company/SmsResult/SmsSettings?handler=InstitutionContractDebtReminderTab");
|
||||
$("#institutionContractDebtReminderTab").addClass("active");
|
||||
|
||||
// کلیک روی تبها
|
||||
$("#institutionContractDebtReminderTab, #blockContractingPartyTab, #legalActionTab, #warningTab").click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
|
||||
let url = $(this).data("url");
|
||||
|
||||
|
||||
|
||||
switch(this.id){
|
||||
case "institutionContractDebtReminderTab" :
|
||||
|
||||
loadPartial(url);
|
||||
|
||||
$("#institutionContractDebtReminderTab, #blockContractingPartyTab, #legalActionTab, #warningTab").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
break;
|
||||
case "blockContractingPartyTab" :
|
||||
|
||||
loadPartial(url);
|
||||
$("#institutionContractDebtReminderTab, #blockContractingPartyTab, #legalActionTab, #warningTab").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
|
||||
break;
|
||||
case "legalActionTab" :
|
||||
loadPartial(url);
|
||||
$("#institutionContractDebtReminderTab, #blockContractingPartyTab, #legalActionTab, #warningTab").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
break;
|
||||
case "warningTab" :
|
||||
loadPartial(url);
|
||||
$("#institutionContractDebtReminderTab, #blockContractingPartyTab, #legalActionTab, #warningTab").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function loadPartial(url) {
|
||||
$.get(url, function (data) {
|
||||
$("#partialContainer").html(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function remove(id){
|
||||
|
||||
|
||||
var urlAjaxToRemove = '@Url.Page("/Company/SmsResult/SmsSettings", "RemoveSetting")';
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
url: urlAjaxToRemove,
|
||||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||||
data: { id: id },
|
||||
|
||||
success: function (response) {
|
||||
if(response.isSuccess){
|
||||
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
|
||||
|
||||
|
||||
setTimeout(function () {
|
||||
$(".li-wizard.step.active").trigger("click");
|
||||
|
||||
|
||||
|
||||
}, 500);
|
||||
}else{
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
|
||||
}
|
||||
|
||||
},
|
||||
failure: function (response) {
|
||||
//console.log(5, response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using CompanyManagment.App.Contracts.Module;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using ServiceHost.Areas.Admin.Pages.Company.Bill;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Pages.Company.SmsResult
|
||||
{
|
||||
public class SmsSettingsModel : PageModel
|
||||
{
|
||||
private readonly ISmsSettingApplication _smsSettingApplication;
|
||||
|
||||
public SmsSettingsModel(ISmsSettingApplication smsSettingApplication)
|
||||
{
|
||||
_smsSettingApplication = smsSettingApplication;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=================================== ایجاد ========================================//
|
||||
|
||||
#region Create
|
||||
/// <summary>
|
||||
/// لود مدال ایجاد پیامک خودکار
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetCreateSmsSetting(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
var createModel = new CreateSmsSetting();
|
||||
createModel.TypeOfSmsSetting = typeOfSmsSetting;
|
||||
return Partial("_SmsSettingPartials/_CreateSmsSetting", createModel);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره مدال ایجاد پیامک خودکار
|
||||
/// </summary>
|
||||
/// <param name="dayOfMonth"></param>
|
||||
/// <param name="timeOfDay"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<JsonResult> OnPostCreateSmsSetting(int dayOfMonth, string timeOfDay, TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(dayOfMonth, timeOfDay, typeOfSmsSetting);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
//=================================== ویرایش ========================================//
|
||||
|
||||
#region Edit
|
||||
/// <summary>
|
||||
/// لود مدال ویرایش پیامک خودکار
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetEditSmsSettings(long id, TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
var editModel = await _smsSettingApplication.GetSmsSettingToEdit(id);
|
||||
return Partial("_SmsSettingPartials/_EditSmsSetting", editModel);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره مودال ویرایش پیامک خودکار
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<JsonResult> OnPostEditSmsSettings(EditSmsSetting command)
|
||||
{
|
||||
var result = await _smsSettingApplication.EditeSmsSetting(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
//=================================== حذف ========================================//
|
||||
/// <summary>
|
||||
/// حذف از دیتابیس
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetRemoveSetting(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _smsSettingApplication.RemoveSetting(id);
|
||||
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = true,
|
||||
message = "حذف شد"
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = false,
|
||||
message = "خطا در حذف اطلاعات"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//=================================== ارسال آنی ========================================//
|
||||
|
||||
/// <summary>
|
||||
/// لود مودال ارسال پیامک آنی
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetInstantSendSms(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return Partial("_SmsSettingPartials/InstantSms");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لود دیتای ارسال پیامک آنی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetInstantReminderSendSms()
|
||||
{
|
||||
var dataModel = await _smsSettingApplication.GetSmsListData(TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return Partial("_SmsSettingPartials/_InstantReminderSms", dataModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک آنی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<JsonResult> OnPostInstantReminderSendSms([FromBody] List<SmsListData> command)
|
||||
{
|
||||
|
||||
var result = await _smsSettingApplication.InstantSendReminderSms(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لود مودال ارسال پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetInstantBlockSms(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return Partial("_SmsSettingPartials/InstantBlockSms");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لود دیتای ارسال پیامک مسدودس آنی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetInstantBlockSendSms()
|
||||
{
|
||||
var dataModel = await _smsSettingApplication.GetBlockSmsListData(TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return Partial("_SmsSettingPartials/_InstantSendBlockSms", dataModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک مسدودی آنی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<JsonResult> OnPostInstantBlockSendSms([FromBody] List<BlockSmsListData> command)
|
||||
{
|
||||
|
||||
var result = await _smsSettingApplication.InstantSendBlockSms(command);
|
||||
return new JsonResult(new
|
||||
{
|
||||
isSuccess = result.IsSuccedded,
|
||||
message = result.Message
|
||||
});
|
||||
}
|
||||
//=================================== تب ها ========================================//
|
||||
|
||||
#region Tabs
|
||||
/// <summary>
|
||||
/// تب پیامک یادآور
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetInstitutionContractDebtReminderTab()
|
||||
{
|
||||
var modelData = await _smsSettingApplication.GetSmsSettingsByType(TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return Partial("_SmsSettingPartials/ReminderSmsListData", modelData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// تب پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetBlockContractingPartyTab()
|
||||
{
|
||||
var modelData = await _smsSettingApplication.GetSmsSettingsByType(TypeOfSmsSetting.BlockContractingParty);
|
||||
return Partial("_SmsSettingPartials/BlockSmsListData", modelData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// تب پیامک اقدام قضائی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetLegalActionTab()
|
||||
{
|
||||
var modelData = await _smsSettingApplication.GetSmsSettingsByType(TypeOfSmsSetting.LegalAction);
|
||||
return Partial("_SmsSettingPartials/LegalActionSmsListData", modelData);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تب پیامک هشدار قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IActionResult> OnGetWarningTab()
|
||||
{
|
||||
var modelData = await _smsSettingApplication.GetSmsSettingsByType(TypeOfSmsSetting.Warning);
|
||||
return Partial("_SmsSettingPartials/WarningSmsListData", modelData);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
@using _0_Framework.Application.Enums
|
||||
@model CompanyManagment.App.Contracts.SmsResult.SmsSettingViewModel
|
||||
@Html.AntiForgeryToken()
|
||||
@{
|
||||
|
||||
int index = 1;
|
||||
<style>
|
||||
.head-table {
|
||||
font-size: 14px;
|
||||
background-color: #2dbcbc;
|
||||
padding: 4px 1px;
|
||||
border-radius: 5px;
|
||||
color: aliceblue;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.tr-table {
|
||||
background-color: #ddf4f4;
|
||||
border-radius: 5px;
|
||||
padding: 4px 1px;
|
||||
margin-bottom: 3px;
|
||||
font-family: "IranText" !important;
|
||||
}
|
||||
|
||||
div.tr-table:nth-of-type(even) {
|
||||
background-color: #b0e0e08f !important;
|
||||
}
|
||||
|
||||
.row-number {
|
||||
background-color: rgb(187, 240, 240);
|
||||
color: #0B5959;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
|
||||
.icon-span {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
line-height: 14px;
|
||||
border-radius: 5px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.icon-span svg {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
</style>
|
||||
}
|
||||
<div class="card card-pattern m-t-10">
|
||||
<a class="btn btn-success"
|
||||
style="border-radius:5px;" href="#showmodal=@Url.Page("./SmsSettings", "CreateSmsSetting", new {typeOfSmsSetting = TypeOfSmsSetting.BlockContractingParty})">
|
||||
|
||||
|
||||
<span class="icon-span">
|
||||
|
||||
<svg width="19" height="19" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="11" cy="11" r="8.25" stroke="white" />
|
||||
<path d="M11 13.75L11 8.25" stroke="white" stroke-linecap="round" />
|
||||
<path d="M13.75 11L8.25 11" stroke="white" stroke-linecap="round" />
|
||||
</svg>
|
||||
<span style="margin-right:4px"> ایجاد پیامک مسدودی </span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
<a class="btn btn-success instantSendSms"
|
||||
style="border-radius:5px;" href="#showmodal=@Url.Page("./SmsSettings", "InstantBlockSms")">
|
||||
|
||||
|
||||
<span class="icon-span">
|
||||
|
||||
<svg width="20px" height="20px" viewBox="-11.26 -11.26 49.32 49.32" xmlns="http://www.w3.org/2000/svg" fill="#000000" transform="matrix(-1, 0, 0, 1, 0, 0)rotate(0)" stroke="#000000" stroke-width="0.00026804">
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
|
||||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.053608"></g>
|
||||
<g id="SVGRepo_iconCarrier">
|
||||
<g id="Group_37" data-name="Group 37" transform="translate(-108.142 -942.014)">
|
||||
<path id="Path_17" data-name="Path 17" d="M109.642,968.818a1.5,1.5,0,0,1-1.5-1.5v-23.8a1.5,1.5,0,0,1,2.25-1.3l20.616,11.9a1.5,1.5,0,0,1,0,2.6l-20.616,11.9A1.5,1.5,0,0,1,109.642,968.818Zm1.5-22.707V964.72l16.116-9.3Z" fill="#ffffff"></path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
<span style="margin-right:4px"> ارسال آنی پیامک مسدودی </span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
<div class="card card-pattern m-t-10">
|
||||
|
||||
@if (Model.EditSmsSettings.Any())
|
||||
{
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- هدر -->
|
||||
<div class="row fw-bold mb-2 head-table">
|
||||
<div class="col-2 col-md-1">ردیف</div>
|
||||
<div class="col-10 col-md-3"> روز ارسال </div>
|
||||
<div class="col-6 col-md-2"> ساعت ارسال </div>
|
||||
<div class="col-12 col-md-3" style="float:left; direction:ltr">عملیات</div>
|
||||
</div>
|
||||
|
||||
<!-- لیست -->
|
||||
@foreach (var item in Model.EditSmsSettings)
|
||||
{
|
||||
<div class="row align-items-center p-2 tr-table">
|
||||
|
||||
<div class="col-2 col-md-1"><div class="row-number">@index</div></div>
|
||||
<div class="col-10 col-md-3">@item.DayOfMonth</div>
|
||||
<div class="col-6 col-md-2">@item.TimeOfDayDisplay</div>
|
||||
|
||||
@{
|
||||
index++;
|
||||
}
|
||||
<div class="col-12 col-md-3 align-items-center" style="float:left; direction:ltr">
|
||||
|
||||
<a href="#" onclick="remove(@item.Id);"
|
||||
style="border-radius:5px;" return false;>
|
||||
<span class="icon-span" style="background-color:#ddd3e0">
|
||||
<svg width="19" height="18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="18.5047" height="18.5047" transform="translate(0.523438 0.523438)" fill="#DDD3E0"></rect>
|
||||
<path d="M7.84814 11.7031L7.84814 9.39004" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
<path d="M11.7031 11.7031L11.7031 9.39004" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
<path d="M2.83643 5.53125H16.7149V5.53125C16.0652 5.53125 15.7403 5.53125 15.4745 5.60604C14.8039 5.79477 14.2799 6.31884 14.0911 6.98943C14.0163 7.25518 14.0163 7.58007 14.0163 8.22985V11.5546C14.0163 13.4402 14.0163 14.383 13.4305 14.9688C12.8448 15.5546 11.902 15.5546 10.0163 15.5546H9.53502C7.64941 15.5546 6.7066 15.5546 6.12081 14.9688C5.53502 14.383 5.53502 13.4402 5.53502 11.5546V8.22985C5.53502 7.58007 5.53502 7.25518 5.46023 6.98943C5.27151 6.31884 4.74744 5.79477 4.07685 5.60604C3.8111 5.53125 3.48621 5.53125 2.83643 5.53125V5.53125Z" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
<path d="M7.84799 3.22434C7.84799 3.22434 8.2335 2.45312 9.77556 2.45312C11.3176 2.45312 11.7031 3.22415 11.7031 3.22415" stroke="#BF3737" stroke-linecap="round"></path>
|
||||
</svg>
|
||||
</span>
|
||||
|
||||
</a>
|
||||
|
||||
<a href="#showmodal=@Url.Page("./SmsSettings", "EditSmsSettings" ,new {id = item.Id, typeOfSmsSetting = item.TypeOfSmsSetting})">
|
||||
<span class="icon-span" style="background-color:#ade7f2">
|
||||
<svg width="19" height="18" viewBox="0 0 19 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="18.5047" height="18.5047" transform="translate(0.074707 0.679688)" fill="#ADE7F2"></rect>
|
||||
<path d="M11.3213 5.25293C11.5664 5.19964 11.8217 5.20913 12.0635 5.28027L12.2178 5.33691C12.3659 5.40344 12.4945 5.49613 12.6152 5.59766C12.7711 5.72874 12.9467 5.90375 13.1504 6.10742L13.4326 6.39258C13.5184 6.48132 13.5946 6.56459 13.6602 6.64258C13.7953 6.80336 13.914 6.97832 13.9775 7.19434L14.0049 7.29883C14.0506 7.50888 14.0506 7.72647 14.0049 7.93652L13.9775 8.04102C13.914 8.25701 13.7953 8.43201 13.6602 8.59277C13.5946 8.67073 13.5184 8.75407 13.4326 8.84277L13.1504 9.12793L7.75879 14.5186C7.62672 14.6506 7.50929 14.7722 7.37793 14.8701L7.24121 14.959C7.14574 15.013 7.04539 15.0527 6.93848 15.0859L6.59766 15.1768L4.85938 15.6113C4.69519 15.6524 4.51668 15.6984 4.36816 15.7129C4.23271 15.7261 4.01567 15.7249 3.82324 15.584L3.74316 15.5146C3.53379 15.3053 3.52979 15.0444 3.54492 14.8896C3.55945 14.7411 3.60544 14.5626 3.64648 14.3984L4.08105 12.6602L4.17188 12.3193C4.20508 12.2124 4.24479 12.1121 4.29883 12.0166L4.3877 11.8799C4.48563 11.7485 4.60719 11.6311 4.73926 11.499L10.1299 6.10742L10.415 5.8252C10.5036 5.7396 10.5862 5.66312 10.6641 5.59766C10.8249 5.46245 11.0007 5.34385 11.2168 5.28027L11.3213 5.25293Z" stroke="#009EE2"></path>
|
||||
<path d="M9.7124 6.46393L12.0255 4.92188L14.3386 7.23496L12.7965 9.54804L9.7124 6.46393Z" fill="#009EE2"></path>
|
||||
</svg>
|
||||
</span>
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
@Html.AntiForgeryToken()
|
||||
@{
|
||||
<style>
|
||||
.modal .modal-dialog .modal-content{
|
||||
padding-bottom: 10px !important;
|
||||
}
|
||||
.modal-title{
|
||||
position: absolute;
|
||||
width: 291px;
|
||||
font-size: 18px;
|
||||
background-color: inherit;
|
||||
left: 47%;
|
||||
top: 19px;
|
||||
margin-left: -100px;
|
||||
text-align: center;
|
||||
color: black;
|
||||
border: 1px solid #00000030;
|
||||
border-radius: 9px;
|
||||
padding: 2px 0px;
|
||||
}
|
||||
.skeleton-loader {
|
||||
width: 100%;
|
||||
height: 35px;
|
||||
background: linear-gradient(90deg, #EEEEEE 25%, #DEDEDE 50%, #EEEEEE 75%);
|
||||
background-size: 200% 100%;
|
||||
animation: loading 2s infinite ease-in-out;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 3px
|
||||
}
|
||||
|
||||
|
||||
.progBar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#createProcess {
|
||||
background-color: #fdfdfd;
|
||||
height: 70px;
|
||||
border-radius: 7px;
|
||||
margin: 4px 2px 4px 2px;
|
||||
box-shadow: 0px 1px 7px 0 #155c5c;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
color: #fff !important;
|
||||
font-size: 17px !important;
|
||||
line-height: 23px !important;
|
||||
border-radius: 10px !important;
|
||||
}
|
||||
|
||||
@@keyframes loading {
|
||||
0% {
|
||||
background-position: 200% 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
background-position: -200% 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
}
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">ارسال آنی پیامک مسدودی</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="بستن">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="card card-pattern m-t-10" style="border-radius: 15px 15px 0px 0px;">
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- هدر -->
|
||||
<div class="row fw-bold mb-2 head-table">
|
||||
<div class="col-2 col-md-1">ردیف</div>
|
||||
<div class="col-10 col-md-3"> نام طرف حساب </div>
|
||||
<div class="col-6 col-md-3"> شماره تماس </div>
|
||||
<div class="col-6 col-md-3" style="text-align:left; left:1.2%"> مبلغ بدهی </div>
|
||||
<div class="col-12 col-md-2" style="float:right;text-align:right; direction:ltr; left: 1.2%">
|
||||
تیک ارسال
|
||||
<label class="switch">
|
||||
<input id="checkAll" type="checkbox" checked />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="createProcess" class="row progress-bar-striped progBar">
|
||||
<div class="form-group" style="padding: 0px 10px;">
|
||||
<span style="text-align: center">
|
||||
<h3 style="font-size: 15px;color: #767575;margin-top: 3px;margin-bottom:0px">درصد ارسال پیامک ها</h3>
|
||||
</span>
|
||||
|
||||
|
||||
<div class="progress" style="height: 20px">
|
||||
<div id="progress-bar-w" style="background-color: rgb(16 170 18)" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="card card-pattern " style="margin-top:2px;height:600px; overflow-y:scroll; border-radius: 0 0 15px 15px">
|
||||
|
||||
|
||||
<div class="container-fluid" id="partialAppendBlockList">
|
||||
|
||||
|
||||
<div id="loading">
|
||||
|
||||
@for (var j = 0; j < 16; j++)
|
||||
{
|
||||
<div class="skeleton-loader"></div>
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="modal-footer border-0">
|
||||
<button type="button" onclick="sendToSms()" class="btn btn-success px-4 rounded-pill">ارسال پیامک</button>
|
||||
<button type="button" class="btn btn-outline-secondary px-4 rounded-pill" data-dismiss="modal">بستن</button>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
var url = "/Admin/Company/SmsResult/SmsSettings?handler=InstantBlockSendSms";
|
||||
$.get(url, function (data) {
|
||||
$("#loading").hide();
|
||||
$("#partialAppendBlockList").html(data);
|
||||
|
||||
});
|
||||
|
||||
var gNo = Number(10);
|
||||
setTimeout(function () {
|
||||
|
||||
connectToGroupW(gNo);
|
||||
|
||||
},
|
||||
2000);
|
||||
|
||||
});
|
||||
console.log('befor start ...');
|
||||
var connection = new signalR.HubConnectionBuilder().withUrl("/trackingSendSmsHub").build();
|
||||
|
||||
|
||||
connection.start().then(function () {
|
||||
console.log("connect.....!");
|
||||
}).catch(function (err) {
|
||||
return console.error(err.toString());
|
||||
});
|
||||
|
||||
function connectToGroupW(id) {
|
||||
connection.invoke("send", id)
|
||||
.catch(function (err) {
|
||||
console.error(err.toString());
|
||||
});
|
||||
console.log(`connected to group...${id}`);
|
||||
|
||||
}
|
||||
|
||||
connection.on('showStatus',
|
||||
function (percent) {
|
||||
$('#progress-bar-w').css("width", percent + "%");
|
||||
$('#progress-bar-w').text(percent + '%');
|
||||
});
|
||||
//ارسال پیامک
|
||||
function sendToSms() {
|
||||
const recordItems = document.querySelectorAll(".record");
|
||||
const command = [];
|
||||
|
||||
recordItems.forEach(recordItem => {
|
||||
|
||||
const checkbox = recordItem.querySelector('input[type="checkbox"]');
|
||||
|
||||
if (checkbox && checkbox.checked) {
|
||||
|
||||
const SmsListData = {
|
||||
PhoneNumber: checkbox.dataset.phonenumber,
|
||||
PartyName: checkbox.dataset.partyname,
|
||||
Amount: checkbox.dataset.amount,
|
||||
ContractingPartyId: Number(checkbox.dataset.contractingpartyid),
|
||||
AccountType: checkbox.dataset.accountType,
|
||||
InstitutionContractId: Number(checkbox.dataset.institutioncontractid),
|
||||
AproveId: checkbox.dataset.aproveid,
|
||||
};
|
||||
|
||||
command.push(SmsListData);
|
||||
}
|
||||
});
|
||||
|
||||
if (command.length === 0) {
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "هیچ موردی انتخاب نشده است");
|
||||
return;
|
||||
}
|
||||
$('#createProcess').removeClass("progBar");
|
||||
var urlAjaxToSendSms = '@Url.Page("/Company/SmsResult/SmsSettings", "InstantBlockSendSms")';
|
||||
|
||||
$.ajax({
|
||||
url: urlAjaxToSendSms,
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
|
||||
data: JSON.stringify(command),
|
||||
success: function (response) {
|
||||
if (response.isSuccess) {
|
||||
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
|
||||
} else {
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
|
||||
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "خطا در ارسال اطلاعات");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
//روشن یا خاموش کردن تیک برای همه
|
||||
$('#checkAll').on('change', function () {
|
||||
const status = this.checked; // true یا false
|
||||
$('input[type="checkbox"]').each(function () {
|
||||
|
||||
|
||||
$(this).prop('checked', status);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user