Compare commits
1 Commits
Feature/Sm
...
Feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
| 3a6e115f73 |
@@ -45,11 +45,6 @@ public enum TypeOfSmsSetting
|
||||
/// </summary>
|
||||
SendInstitutionContractConfirmationCode,
|
||||
|
||||
/// <summary>
|
||||
/// لینک تاییدیه ایجاد قرارداد مالی
|
||||
/// </summary>
|
||||
SendInstitutionContractConfirmationLink,
|
||||
|
||||
/// <summary>
|
||||
/// یادآور وظایف
|
||||
/// </summary>
|
||||
|
||||
@@ -30,22 +30,5 @@ public class ApiReportDto
|
||||
public string DeliveryState { get; set; }
|
||||
public string DeliveryUnixTime { get; set; }
|
||||
public string DeliveryColor { get; set; }
|
||||
public string FullName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class SmsDetailsDto
|
||||
{
|
||||
|
||||
|
||||
public string MessageText { get; set; }
|
||||
|
||||
public long Mobile { get; set; }
|
||||
|
||||
public string SendUnixTime { get; set; }
|
||||
public string DeliveryState { get; set; }
|
||||
public string DeliveryUnixTime { get; set; }
|
||||
public string DeliveryColor { get; set; }
|
||||
public string FullName { get; set; }
|
||||
|
||||
}
|
||||
@@ -16,21 +16,15 @@ public interface ISmsService
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
Task<SentSmsViewModel> SendVerifyCodeToClient(string number, string code);
|
||||
bool SendAccountsInfo(string number, string fullName, string userName);
|
||||
bool SendAccountsInfo(string number,string fullName, string userName);
|
||||
Task<ApiResultViewModel> GetByMessageId(int messId);
|
||||
Task<List<ApiResultViewModel>> GetApiResult(string startDate, string endDate);
|
||||
|
||||
#region ForApi
|
||||
|
||||
Task<List<ApiReportDto>> GetApiReport(string startDate, string endDate);
|
||||
/// <summary>
|
||||
/// دریافت جزئیات پیامک
|
||||
/// </summary>
|
||||
/// <param name="messId"></param>
|
||||
/// <param name="fullName"></param>
|
||||
/// <returns></returns>
|
||||
Task<SmsDetailsDto> GetSmsDetailsByMessageId(int messId, string fullName);
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
string DeliveryStatus(byte? dv);
|
||||
string DeliveryColorStatus(byte? dv);
|
||||
@@ -39,9 +33,9 @@ public interface ISmsService
|
||||
#region Mahan
|
||||
|
||||
Task<double> GetCreditAmount();
|
||||
|
||||
|
||||
public Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId, string typeOfSms = null);
|
||||
|
||||
|
||||
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
|
||||
long contractingPartyId, long institutionContractId);
|
||||
|
||||
@@ -74,7 +68,7 @@ public interface ISmsService
|
||||
/// <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>
|
||||
/// پیامک مسدودی طرف حساب
|
||||
/// قراردادهای قدیم
|
||||
|
||||
@@ -66,4 +66,9 @@ public class File1 : EntityBase
|
||||
Description = description;
|
||||
Status = status;
|
||||
}
|
||||
|
||||
public void ChangeStatus(int status)
|
||||
{
|
||||
Status = status;
|
||||
}
|
||||
}
|
||||
@@ -531,6 +531,11 @@ namespace Company.Domain.RollCallAgg
|
||||
FridayWorkTimeSpan = CalculateFridayWorkDuration(StartDate.Value, EndDate.Value);
|
||||
}
|
||||
|
||||
public void SetStartDate(DateTime start)
|
||||
{
|
||||
StartDate = start;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// جیزه
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using System.Collections.Generic;
|
||||
@@ -23,9 +22,8 @@ public interface ISmsResultRepository : IRepository<long, SmsResult>
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date, string typeOfSmsSetting);
|
||||
Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date);
|
||||
|
||||
#endregion
|
||||
List<SmsResultViewModel> Search(SmsResultSearchModel searchModel);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.SmsResultAgg;
|
||||
@@ -28,25 +27,4 @@ public interface ISmsSettingsRepository : IRepository<long, SmsSetting>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task RemoveItem(long id);
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات تنظیمات پیامک جهت ویرایش
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<SmsSettingDto> GetSmsSettingDataToEdit(long id);
|
||||
#endregion
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Hubs;
|
||||
@@ -8,20 +7,6 @@ namespace CompanyManagment.App.Contracts.Hubs;
|
||||
|
||||
public class SendSmsHub : Hub
|
||||
{
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public SendSmsHub(IAuthHelper authHelper)
|
||||
{
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
public override async Task OnConnectedAsync()
|
||||
{
|
||||
var accountId = _authHelper.CurrentAccountId();
|
||||
var connectionId = Context.ConnectionId;
|
||||
await send(accountId);
|
||||
await base.OnConnectedAsync();
|
||||
}
|
||||
|
||||
public async Task send(long id)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
||||
namespace CompanyManagment.App.Contracts.InstitutionContract;
|
||||
|
||||
/// <summary>
|
||||
/// لیست پیامکهای بدهکاران قرارداد ملی
|
||||
@@ -115,30 +113,10 @@ public class BlockSmsListData
|
||||
|
||||
|
||||
/// <summary>
|
||||
///پیامک آنی یادآور
|
||||
/// لیست قراداد های آبی
|
||||
/// جهت ارسال هشدار یا اقدام قضائی
|
||||
/// </summary>
|
||||
public class InstantReminderSendSms
|
||||
public class BlueWarningSmsData
|
||||
{
|
||||
/// <summary>
|
||||
/// نام طرف حساب
|
||||
/// </summary>
|
||||
public string FullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ بدهی
|
||||
/// </summary>
|
||||
public string Amount { get; set; }
|
||||
public List<InstantReminderSmsList> InstantReminderSmsList { get; set; }
|
||||
}
|
||||
|
||||
public class InstantReminderSmsList
|
||||
{
|
||||
/// <summary>
|
||||
/// شماره تماس طرف حساب
|
||||
/// </summary>
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -60,43 +60,3 @@ public class SmsSettingViewModel
|
||||
/// </summary>
|
||||
public List<EditSmsSetting> EditSmsSettings { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک خودکار
|
||||
/// </summary>
|
||||
public class SmsSettingDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// عدد روز از ماه
|
||||
/// </summary>
|
||||
public int DayOfMonth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نمایش ساعت و دقیقه
|
||||
/// </summary>
|
||||
public string TimeOfDayDisplay { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class CreateSmsSettingDto
|
||||
{
|
||||
/// <summary>
|
||||
/// عدد روز از ماه
|
||||
/// </summary>
|
||||
public int DayOfMonth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نمایش ساعت و دقیقه
|
||||
/// </summary>
|
||||
public string TimeOfDayDisplay { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,6 @@ public class SmsReportDto
|
||||
/// </summary>
|
||||
public string SentDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نوع پیامک
|
||||
/// </summary>
|
||||
public string TypeOfSms { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -25,9 +24,8 @@ public interface ISmsResultApplication
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date, string typeOfSmsSetting);
|
||||
Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -75,45 +75,4 @@ public interface ISmsSettingApplication
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> InstantSendBlockSms(List<BlockSmsListData> command);
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات تنظیمات پیامک جهت ویرایش
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<SmsSettingDto> GetSmsSettingDataToEdit(long id);
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> EditSmsSetting(SmsSettingDto command);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست ارسال آنی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<List<InstantReminderSendSms>> GetInstantReminderSmsListData(TypeOfSmsSetting typeOfSmsSetting);
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک آنی
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <param name="phoneNumbers"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> InstantSmsSendApi(TypeOfSmsSetting typeOfSmsSetting, List<string> phoneNumbers);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,26 +1,20 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.Sms;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.SmsResultAgg;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using CompanyManagment.EFCore.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using SmsResult = Company.Domain.SmsResultAgg.SmsResult;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
public class SmsResultApplication : ISmsResultApplication
|
||||
{
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
public SmsResultApplication(ISmsResultRepository smsResultRepository, ISmsService smsService)
|
||||
public SmsResultApplication(ISmsResultRepository smsResultRepository)
|
||||
{
|
||||
_smsResultRepository = smsResultRepository;
|
||||
_smsService = smsService;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +25,9 @@ public class SmsResultApplication : ISmsResultApplication
|
||||
return await _smsResultRepository.GetSmsReportList(searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date, string typeOfSmsSetting)
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
|
||||
{
|
||||
return await _smsResultRepository.GetSmsReportExpandList(searchModel, date, typeOfSmsSetting);
|
||||
return await _smsResultRepository.GetSmsReportExpandList(searchModel, date);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -73,6 +67,4 @@ public class SmsResultApplication : ISmsResultApplication
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -9,8 +9,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace CompanyManagment.Application;
|
||||
|
||||
@@ -19,15 +17,12 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
private readonly ISmsSettingsRepository _smsSettingsRepository;
|
||||
private readonly IInstitutionContractRepository _institutionContractRepository;
|
||||
private readonly IInstitutionContractSmsServiceRepository _institutionContractSmsServiceRepository;
|
||||
private readonly IHostEnvironment _hostEnvironment;
|
||||
|
||||
public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository, IInstitutionContractSmsServiceRepository institutionContractSmsServiceRepository, IHostEnvironment hostEnvironment)
|
||||
public SmsSettingApplication(ISmsSettingsRepository smsSettingsRepository, IInstitutionContractRepository institutionContractRepository, IInstitutionContractSmsServiceRepository institutionContractSmsServiceRepository)
|
||||
{
|
||||
_smsSettingsRepository = smsSettingsRepository;
|
||||
_institutionContractRepository = institutionContractRepository;
|
||||
_institutionContractSmsServiceRepository = institutionContractSmsServiceRepository;
|
||||
_hostEnvironment = hostEnvironment;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -136,34 +131,6 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
public async Task<OperationResult> InstantSendReminderSms(List<SmsListData> command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
List<string> devModeNumberList = [];
|
||||
if (_hostEnvironment.IsDevelopment())
|
||||
{
|
||||
int taker = 0;
|
||||
switch (command.Count)
|
||||
{
|
||||
case >= 3:
|
||||
taker = 3;
|
||||
break;
|
||||
case > 0:
|
||||
case < 3:
|
||||
taker = command.Count;
|
||||
break;
|
||||
default:
|
||||
taker = 0;
|
||||
}
|
||||
|
||||
if (taker > 0)
|
||||
{
|
||||
devModeNumberList = ["09114221321", "09116967898", "09116067106"];
|
||||
command = command.Take(taker).ToList();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
command[i].PhoneNumber = devModeNumberList[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
string typeOfSms = "یادآور بدهی ماهانه";
|
||||
string sendMessStart = "شروع یادآور آنی";
|
||||
string sendMessEnd = "پایان یادآور آنی";
|
||||
@@ -184,35 +151,6 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
public async Task<OperationResult> InstantSendBlockSms(List<BlockSmsListData> command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
List<string> devModeNumberList = [];
|
||||
if (_hostEnvironment.IsDevelopment())
|
||||
{
|
||||
int taker = 0;
|
||||
switch (command.Count)
|
||||
{
|
||||
case >= 3:
|
||||
taker = 3;
|
||||
break;
|
||||
case > 0:
|
||||
case < 3:
|
||||
taker = command.Count;
|
||||
break;
|
||||
default:
|
||||
taker = 0;
|
||||
}
|
||||
|
||||
if (taker > 0)
|
||||
{
|
||||
devModeNumberList = ["09114221321", "09116967898", "09116067106"];
|
||||
command = command.Take(taker).ToList();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
command[i].PhoneNumber = devModeNumberList[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
string typeOfSms = "اعلام مسدودی طرف حساب";
|
||||
string sendMessStart = "شروع مسدودی آنی";
|
||||
string sendMessEnd = "پایان مسدودی آنی ";
|
||||
@@ -227,157 +165,4 @@ public class SmsSettingApplication : ISmsSettingApplication
|
||||
return op.Failed("موردی انتخاب نشده است");
|
||||
}
|
||||
}
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
return await _smsSettingsRepository.GetSmsSettingList(typeOfSmsSetting);
|
||||
}
|
||||
|
||||
|
||||
public async Task<SmsSettingDto> GetSmsSettingDataToEdit(long id)
|
||||
{
|
||||
return await _smsSettingsRepository.GetSmsSettingDataToEdit(id);
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> EditSmsSetting(SmsSettingDto command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var editSmsSetting = _smsSettingsRepository.Get(command.Id);
|
||||
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 == editSmsSetting.TypeOfSmsSetting && x.id != command.Id))
|
||||
return op.Failed("رکورد ایجاد شده تکراری است");
|
||||
|
||||
|
||||
editSmsSetting.Edit(command.DayOfMonth, timeSpan);
|
||||
await _smsSettingsRepository.SaveChangesAsync();
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<InstantReminderSendSms>> GetInstantReminderSmsListData(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
var result = new List<InstantReminderSendSms>();
|
||||
|
||||
|
||||
if (typeOfSmsSetting == TypeOfSmsSetting.InstitutionContractDebtReminder)
|
||||
{
|
||||
var data = await _institutionContractSmsServiceRepository.GetSmsListData(DateTime.Now, TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
|
||||
if (data.Any())
|
||||
{
|
||||
result = data.GroupBy(x => x.PartyName).Select(m => new InstantReminderSendSms()
|
||||
{
|
||||
FullName = m.Key,
|
||||
Amount = m.Select(c => c.Amount).First(),
|
||||
InstantReminderSmsList = m.Select(c => new InstantReminderSmsList()
|
||||
{
|
||||
PhoneNumber = c.PhoneNumber,
|
||||
}).ToList()
|
||||
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
if (typeOfSmsSetting == TypeOfSmsSetting.BlockContractingParty)
|
||||
{
|
||||
var data = await _institutionContractSmsServiceRepository.GetBlockListData(DateTime.Now);
|
||||
|
||||
if (data.Any())
|
||||
{
|
||||
result = data.GroupBy(x => x.PartyName).Select(m => new InstantReminderSendSms()
|
||||
{
|
||||
FullName = m.Key,
|
||||
Amount = m.Select(c => c.Amount).First(),
|
||||
InstantReminderSmsList = m.Select(c => new InstantReminderSmsList()
|
||||
{
|
||||
PhoneNumber = c.PhoneNumber,
|
||||
}).ToList()
|
||||
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<OperationResult> InstantSmsSendApi(TypeOfSmsSetting typeOfSmsSetting, List<string> phoneNumbers)
|
||||
{
|
||||
|
||||
var op = new OperationResult();
|
||||
|
||||
if (typeOfSmsSetting == TypeOfSmsSetting.InstitutionContractDebtReminder)
|
||||
{
|
||||
if (phoneNumbers.Any())
|
||||
{
|
||||
var data = await _institutionContractSmsServiceRepository.GetSmsListData(DateTime.Now, TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
|
||||
if (data.Any())
|
||||
{
|
||||
phoneNumbers = phoneNumbers.Where(x => x.Length == 11).ToList();
|
||||
var sendItems = data.Where(x => phoneNumbers.Contains(x.PhoneNumber)).ToList();
|
||||
var res = await InstantSendReminderSms(sendItems);
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
return op.Failed("موردی انتخاب نشده است");
|
||||
|
||||
}
|
||||
|
||||
if (typeOfSmsSetting == TypeOfSmsSetting.BlockContractingParty)
|
||||
{
|
||||
if (phoneNumbers.Any())
|
||||
{
|
||||
var data = await _institutionContractSmsServiceRepository.GetBlockListData(DateTime.Now);
|
||||
|
||||
if (data.Any())
|
||||
{
|
||||
phoneNumbers = phoneNumbers.Where(x => x.Length == 11).ToList();
|
||||
var sendItems = data.Where(x => phoneNumbers.Contains(x.PhoneNumber)).ToList();
|
||||
var res = await InstantSendBlockSms(sendItems);
|
||||
return res;
|
||||
}
|
||||
return op.Succcedded();
|
||||
}
|
||||
return op.Failed("موردی انتخاب نشده است");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return op.Failed("خطای انتخاب نوع ارسال");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -31,9 +31,8 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
private readonly ISmsResultRepository _smsResultRepository;
|
||||
private readonly IHubContext<SendSmsHub> _hubContext;
|
||||
private readonly IPersonalContractingPartyRepository _personalContractingPartyRepository;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public InstitutionContractSmsServiceRepository(CompanyContext context, ISmsService smsService, ILogger<InstitutionContractSmsServiceRepository> logger, ISmsResultRepository smsResultRepository, IHubContext<SendSmsHub> hubContext, IPersonalContractingPartyRepository personalContractingPartyRepository, IAuthHelper authHelper) : base(context)
|
||||
public InstitutionContractSmsServiceRepository(CompanyContext context, ISmsService smsService, ILogger<InstitutionContractSmsServiceRepository> logger, ISmsResultRepository smsResultRepository, IHubContext<SendSmsHub> hubContext, IPersonalContractingPartyRepository personalContractingPartyRepository) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
_smsService = smsService;
|
||||
@@ -41,7 +40,6 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
_smsResultRepository = smsResultRepository;
|
||||
_hubContext = hubContext;
|
||||
_personalContractingPartyRepository = personalContractingPartyRepository;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
//هشدار - اقدام قضائی
|
||||
@@ -939,31 +937,15 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
public async Task SendBlockSmsToContractingParties(List<BlockSmsListData> smsListData, string typeOfSms,
|
||||
string sendMessStart, string sendMessEnd)
|
||||
{
|
||||
var currentAccountId = _authHelper.CurrentAccountId();
|
||||
var signalR = _hubContext.Clients.Group(SendSmsHub.GetGroupName(currentAccountId));
|
||||
if (smsListData.Any())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sendingStart = await _smsService.Alarm("09114221321", sendMessStart);
|
||||
Thread.Sleep(1000);
|
||||
|
||||
if (!sendingStart)
|
||||
{
|
||||
await signalR.SendAsync("sendToApi", "failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await signalR.SendAsync("sendToApi", "failed");
|
||||
return;
|
||||
}
|
||||
await _smsService.Alarm("09114221321", sendMessStart);
|
||||
Thread.Sleep(1000);
|
||||
await _smsService.Alarm("09111485044", sendMessStart);
|
||||
Thread.Sleep(1000);
|
||||
int successProcess = 1;
|
||||
int countList = smsListData.Count;
|
||||
List<string> failedNumberList = [];
|
||||
int successSend = 0;
|
||||
int failedSend = 0;
|
||||
|
||||
foreach (var item in smsListData)
|
||||
{
|
||||
try
|
||||
@@ -978,7 +960,6 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
item.PartyName, item.PhoneNumber, item.ContractingPartyId, item.InstitutionContractId);
|
||||
await _smsResultRepository.CreateAsync(createSmsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -990,31 +971,28 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
item.PartyName, item.PhoneNumber, item.ContractingPartyId, item.InstitutionContractId);
|
||||
await _smsResultRepository.CreateAsync(createSmsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
successSend += 1;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string name = item.PartyName.Length > 18 ? item.PartyName.Substring(0, 18) : item.PartyName;
|
||||
string errMess = $"{name}-خطا";
|
||||
failedNumberList.Add(item.PhoneNumber);
|
||||
failedSend += 1;
|
||||
await _smsService.Alarm("09114221321", errMess);
|
||||
}
|
||||
|
||||
Thread.Sleep(600);
|
||||
var percent = (successProcess / (double)countList) * 100;
|
||||
await signalR.SendAsync("showStatus", countList, failedSend, successSend,(int)percent, failedNumberList);
|
||||
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(10))
|
||||
.SendAsync("showStatus", (int)percent);
|
||||
|
||||
successProcess += 1;
|
||||
}
|
||||
|
||||
|
||||
await _smsService.Alarm("09114221321", sendMessEnd);
|
||||
|
||||
Thread.Sleep(1000);
|
||||
await _smsService.Alarm("09111485044", sendMessEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2121,38 +2099,21 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
|
||||
#region SendSMSFromList
|
||||
|
||||
var currentAccountId = _authHelper.CurrentAccountId();
|
||||
var signalR = _hubContext.Clients.Group(SendSmsHub.GetGroupName(currentAccountId));
|
||||
if (smsListData.Any())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sendingStart = await _smsService.Alarm("09114221321", sendMessStart);
|
||||
Thread.Sleep(1000);
|
||||
//await _smsService.Alarm("09114221321", sendMessStart);
|
||||
//Thread.Sleep(1000);
|
||||
//await _smsService.Alarm("09111485044", sendMessStart);
|
||||
//Thread.Sleep(1000);
|
||||
|
||||
if (!sendingStart)
|
||||
{
|
||||
await signalR.SendAsync("sendToApi", "failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await signalR.SendAsync("sendToApi", "failed");
|
||||
return;
|
||||
}
|
||||
|
||||
int successProcess = 1;
|
||||
int countList = smsListData.Count;
|
||||
List<string> failedNumberList = [];
|
||||
int successSend = 0;
|
||||
int failedSend = 0;
|
||||
|
||||
|
||||
foreach (var item in smsListData)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (item.TypeOfSmsMethod == "MonthlyBill")
|
||||
{
|
||||
var res = await _smsService.MonthlyBill(item.PhoneNumber, item.TemplateId, item.PartyName,
|
||||
@@ -2164,9 +2125,9 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
var createSmsResult = new Company.Domain.SmsResultAgg.SmsResult(res.messaeId,
|
||||
res.message, typeOfSms, item.PartyName, item.PhoneNumber,
|
||||
item.ContractingPartyId, item.InstitutionContractId);
|
||||
|
||||
await _smsResultRepository.CreateAsync(createSmsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2178,25 +2139,25 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
|
||||
var createSmsResult = new Company.Domain.SmsResultAgg.SmsResult(res.messaeId,
|
||||
res.message, typeOfSms, item.PartyName, item.PhoneNumber,
|
||||
item.ContractingPartyId, item.InstitutionContractId);
|
||||
|
||||
await _smsResultRepository.CreateAsync(createSmsResult);
|
||||
await _smsResultRepository.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
successSend += 1;
|
||||
|
||||
Thread.Sleep(600);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string name = item.PartyName.Length > 18 ? item.PartyName.Substring(0, 18) : item.PartyName;
|
||||
string errMess = $"{name}-خطا";
|
||||
failedNumberList.Add(item.PhoneNumber);
|
||||
failedSend += 1;
|
||||
_logger.LogError(errMess);
|
||||
await _smsService.Alarm("09114221321", errMess);
|
||||
}
|
||||
|
||||
var percent = (successProcess / (double)countList) * 100;
|
||||
await signalR.SendAsync("showStatus", countList, failedSend, successSend, (int)percent, failedNumberList);
|
||||
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(7))
|
||||
.SendAsync("showStatus", (int)percent);
|
||||
|
||||
successProcess += 1;
|
||||
}
|
||||
|
||||
@@ -82,45 +82,25 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
|
||||
|
||||
var service = _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);
|
||||
|
||||
//اگر سرویس حضور غیاب نداشت
|
||||
if (!service.Any(x => x.StartService.Date <= contractStart.Date && x.EndService.Date >= contractEnd.Date))
|
||||
return false;
|
||||
//var rollCallEmployee = GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
|
||||
|
||||
//if (rollCallEmployee == null)
|
||||
// return false;
|
||||
var rollCallEmployee = _context.RollCallEmployees.Include(xs => xs.EmployeesStatus)
|
||||
.FirstOrDefault(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId);
|
||||
//اگر تنظیمات حضور غیاب نداشت
|
||||
if (rollCallEmployee == null)
|
||||
return false;
|
||||
|
||||
//اگر استاتوس نداشت
|
||||
if (!rollCallEmployee.EmployeesStatus.Any())
|
||||
var rollCallEmployee = _context.RollCallEmployees
|
||||
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)
|
||||
.Include(x => x.EmployeesStatus);
|
||||
if (!rollCallEmployee.Any())
|
||||
return false;
|
||||
|
||||
var leftWork =
|
||||
_context.LeftWorkList.FirstOrDefault(x =>
|
||||
x.StartWorkDate <= contractEnd.Date && x.LeftWorkDate > contractStart);
|
||||
if (leftWork == null)
|
||||
return false;
|
||||
|
||||
var status = rollCallEmployee.EmployeesStatus.FirstOrDefault(s =>
|
||||
(s.StartDate <= contractStart.Date && s.EndDate.Date >= contractEnd.Date));
|
||||
//اگر استاتوس کامل پوشش داد
|
||||
if (status != null)
|
||||
return true;
|
||||
|
||||
|
||||
status = rollCallEmployee.EmployeesStatus.FirstOrDefault(s =>
|
||||
(s.StartDate.Date <= contractStart.Date && s.EndDate.Date > contractStart.Date &&
|
||||
s.EndDate.Date < contractEnd.Date));
|
||||
//اگر قبل از پایان فیس استاتوس قطع شده ولی ترک کار داره
|
||||
if (status != null && leftWork.HasLeft)
|
||||
return true;
|
||||
|
||||
|
||||
return false;
|
||||
var a = rollCallEmployee.Any(x => x.EmployeesStatus.Any(s =>
|
||||
(s.StartDate <= contractStart.Date && s.EndDate.Date >= contractEnd.Date) ||
|
||||
(s.StartDate.Date <= contractStart.Date && s.EndDate.Date > contractStart.Date)));
|
||||
//var result = _employeeRollCallStatusRepository.w(x => x.RollCallEmployeeId == rollCallEmployee.Id &&
|
||||
// (x.StartDate.Date <= contractStart.Date && x.EndDate.Date >= contractEnd.Date) ||
|
||||
// (x.StartDate.Date <= contractStart.Date && x.EndDate.Date > contractStart.Date));
|
||||
return a;
|
||||
}
|
||||
public List<RollCallEmployeeViewModel> GetByWorkshopId(long workshopId)
|
||||
{
|
||||
|
||||
@@ -77,9 +77,6 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
|
||||
case TypeOfSmsSetting.SendInstitutionContractConfirmationCode:
|
||||
typeOfSms = "کد تاییدیه قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.SendInstitutionContractConfirmationLink:
|
||||
typeOfSms = "لینک تاییدیه ایجاد قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.TaskReminder:
|
||||
typeOfSms = "یادآور وظایف";
|
||||
break;
|
||||
@@ -150,7 +147,7 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
|
||||
|
||||
// مرحله 2: گروهبندی و انتخاب آخرین رکورد هر روز روی Client
|
||||
var grouped = rawQuery
|
||||
.GroupBy(x => (x.DateOnly, x.TypeOfSms))
|
||||
.GroupBy(x => x.DateOnly)
|
||||
.Select(g => g.OrderByDescending(x => x.CreationDate).First())
|
||||
.OrderByDescending(x => x.CreationDate)
|
||||
.ToList();
|
||||
@@ -158,16 +155,15 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
|
||||
// مرحله 3: تبدیل به DTO و ToFarsi
|
||||
var result = grouped.Select(x => new SmsReportDto
|
||||
{
|
||||
SentDate = x.CreationDate.ToFarsi(),
|
||||
TypeOfSms = x.TypeOfSms
|
||||
SentDate = x.CreationDate.ToFarsi()
|
||||
}).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date, string typeOfSmsSetting)
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(date) || string.IsNullOrWhiteSpace(typeOfSmsSetting))
|
||||
if(string.IsNullOrWhiteSpace(date))
|
||||
return new List<SmsReportListDto>();
|
||||
|
||||
if (date.TryToGeorgianDateTime(out var searchDate) == false)
|
||||
@@ -202,12 +198,41 @@ public class SmsResultRepository : RepositoryBase<long, SmsResult>, ISmsResultRe
|
||||
query = query.Where(x => x.Mobile.Contains(searchModel.Mobile)).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.TypeOfSms != TypeOfSmsSetting.All && searchModel.TypeOfSms != TypeOfSmsSetting.Warning)
|
||||
{
|
||||
var typeOfSms = "All";
|
||||
switch (searchModel.TypeOfSms)
|
||||
{
|
||||
case TypeOfSmsSetting.InstitutionContractDebtReminder:
|
||||
typeOfSms = "یادآور بدهی ماهانه";
|
||||
break;
|
||||
case TypeOfSmsSetting.MonthlyInstitutionContract:
|
||||
typeOfSms = "صورت حساب ماهانه";
|
||||
break;
|
||||
case TypeOfSmsSetting.BlockContractingParty:
|
||||
typeOfSms = "اعلام مسدودی طرف حساب";
|
||||
break;
|
||||
case TypeOfSmsSetting.LegalAction:
|
||||
typeOfSms = "اقدام قضایی";
|
||||
break;
|
||||
case TypeOfSmsSetting.InstitutionContractConfirm:
|
||||
typeOfSms = "یادآور تایید قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.SendInstitutionContractConfirmationCode:
|
||||
typeOfSms = "کد تاییدیه قرارداد مالی";
|
||||
break;
|
||||
case TypeOfSmsSetting.TaskReminder:
|
||||
typeOfSms = "یادآور وظایف";
|
||||
break;
|
||||
}
|
||||
|
||||
if (typeOfSmsSetting.Contains("هشدار"))
|
||||
query = query.Where(x => x.TypeOfSms == typeOfSms).ToList();
|
||||
}
|
||||
|
||||
if (searchModel.TypeOfSms == TypeOfSmsSetting.Warning)
|
||||
{
|
||||
query = query.Where(x => x.TypeOfSms.Contains("هشدار")).ToList();
|
||||
}
|
||||
query = query.Where(x => x.TypeOfSms == typeOfSmsSetting).ToList();
|
||||
|
||||
if (searchModel.SendStatus != SendStatus.All)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.InfraStructure;
|
||||
@@ -69,48 +68,4 @@ public class SmsSettingsRepository : RepositoryBase<long, SmsSetting>, ISmsSetti
|
||||
_context.SmsSettings.Remove(removeItem);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
/// <summary>
|
||||
/// دریافت لیست پیامک های خودکار بر اساس نوع آن
|
||||
/// Api
|
||||
/// </summary>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<SmsSettingDto>> GetSmsSettingList(TypeOfSmsSetting typeOfSmsSetting)
|
||||
{
|
||||
|
||||
var data = await _context.SmsSettings
|
||||
.Where(x => x.TypeOfSmsSetting == typeOfSmsSetting)
|
||||
.OrderBy(x => x.DayOfMonth).ThenBy(x => x.TimeOfDay)
|
||||
.Select(x =>
|
||||
new SmsSettingDto()
|
||||
{
|
||||
Id = x.id,
|
||||
DayOfMonth = x.DayOfMonth,
|
||||
TimeOfDayDisplay = x.TimeOfDay.ToString(@"hh\:mm")
|
||||
}).ToListAsync();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<SmsSettingDto> GetSmsSettingDataToEdit(long id)
|
||||
{
|
||||
var edit = new SmsSettingDto();
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
return edit;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -2859,7 +2859,7 @@ public class YearlySalaryRepository : RepositoryBase<long, YearlySalary>, IYearl
|
||||
var contactCanToleaveList = new List<ContractsCanToLeave>();
|
||||
var allContractsBetween = _context.Contracts.AsSplitQuery().Include(x => x.WorkingHoursList)
|
||||
.Where(x => x.WorkshopIds == workshopId && x.EmployeeId == employeeId &&
|
||||
x.ContractEnd >= startDate && x.ContarctStart <= endDate).OrderBy(x=>x.ContarctStart).ToList();
|
||||
x.ContractEnd >= startDate && x.ContarctStart <= endDate).ToList();
|
||||
var isWorkshopStaticCheckout = _context.Workshops.FirstOrDefault(x => x.id == workshopId)!.IsStaticCheckout;
|
||||
int mandatoryDays = 0;
|
||||
double allCanToLeave = 0;
|
||||
|
||||
@@ -205,26 +205,6 @@ public class SmsService : ISmsService
|
||||
};
|
||||
return appendData;
|
||||
}
|
||||
|
||||
public async Task<SmsDetailsDto> GetSmsDetailsByMessageId(int messId, string fullName)
|
||||
{
|
||||
|
||||
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||
var response = await smsIr.GetReportAsync(messId);
|
||||
MessageReportResult messages = response.Data;
|
||||
|
||||
var appendData = new SmsDetailsDto()
|
||||
{
|
||||
Mobile = messages.Mobile,
|
||||
MessageText = messages.MessageText,
|
||||
SendUnixTime = UnixTimeStampToDateTime(messages.SendDateTime),
|
||||
DeliveryState = DeliveryStatus(messages.DeliveryState),
|
||||
DeliveryUnixTime = UnixTimeStampToDateTime(messages.DeliveryDateTime),
|
||||
DeliveryColor = DeliveryColorStatus(messages.DeliveryState),
|
||||
FullName = fullName
|
||||
};
|
||||
return appendData;
|
||||
}
|
||||
public async Task<List<ApiResultViewModel>> GetApiResult(string startDate, string endDate)
|
||||
{
|
||||
|
||||
@@ -607,14 +587,17 @@ public class SmsService : ISmsService
|
||||
|
||||
//var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" });
|
||||
|
||||
var verificationSendResult = await
|
||||
var verificationSendResult =
|
||||
smsIr.VerifySendAsync(number, 662874, new VerifySendParameter[] { new("ALARM", message) });
|
||||
Thread.Sleep(800);
|
||||
if (verificationSendResult.Message == "موفق")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ public record SetTimeProjectCommand(
|
||||
|
||||
public class SetTimeSectionTime
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int Hours { get; set; }
|
||||
public int Minutes { get; set; }
|
||||
|
||||
@@ -349,15 +349,6 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
|
||||
return OperationResult.Success();
|
||||
}
|
||||
|
||||
private void ValidateTotalTimeNotLessThanSpent(TimeSpan newTotalTime, TimeSpan currentTotalSpent)
|
||||
{
|
||||
if (newTotalTime < currentTotalSpent)
|
||||
{
|
||||
throw new BadRequestException(
|
||||
$"تایم کل سکشن نمیتواند کمتر از زمان مصرف شده ({currentTotalSpent.TotalHours:F2} ساعت) باشد");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetSectionTime(TaskSection section, SetTimeProjectSkillItem sectionItem, long? addedByUserId)
|
||||
{
|
||||
var initData = sectionItem.InitData;
|
||||
@@ -372,69 +363,18 @@ public class SetTimeProjectCommandHandler : IBaseCommandHandler<SetTimeProjectCo
|
||||
// تنظیم زمان اولیه
|
||||
section.UpdateInitialEstimatedHours(initialTime, initData.Description);
|
||||
|
||||
// مدیریت هوشمند زمانهای اضافی
|
||||
var existingAdditionalTimes = section.AdditionalTimes.ToList();
|
||||
var incomingAdditionalTimes = sectionItem.AdditionalTime ?? [];
|
||||
var currentTotalSpent = section.GetTotalTimeSpent();
|
||||
|
||||
bool hasRealChange = false;
|
||||
|
||||
// حذف آیتمهایی که دیگر در لیست نیستند
|
||||
foreach (var existingTime in existingAdditionalTimes)
|
||||
section.ClearAdditionalTimes();
|
||||
// افزودن زمانهای اضافی
|
||||
bool hasAdditionalTime = false;
|
||||
foreach (var additionalTime in sectionItem.AdditionalTime)
|
||||
{
|
||||
var stillExists = incomingAdditionalTimes.Any(x => x.Id == existingTime.Id);
|
||||
if (!stillExists)
|
||||
{
|
||||
section.RemoveAdditionalTime(existingTime.Id);
|
||||
hasRealChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
// ویرایش یا اضافه کردن آیتمهای جدید
|
||||
foreach (var additionalTime in incomingAdditionalTimes)
|
||||
{
|
||||
var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours)
|
||||
.Add(TimeSpan.FromMinutes(additionalTime.Minutes));
|
||||
|
||||
if (additionalTimeSpan <= TimeSpan.Zero)
|
||||
continue;
|
||||
|
||||
var existingAdditionalTime = existingAdditionalTimes.FirstOrDefault(x => x.Id == additionalTime.Id);
|
||||
|
||||
if (existingAdditionalTime != null)
|
||||
{
|
||||
// اگر آیتم با این ID وجود دارد، بررسی کن اگر تغییر کرده باشد
|
||||
if (existingAdditionalTime.HasChanged(additionalTimeSpan, additionalTime.Description))
|
||||
{
|
||||
var newTotalTime = section.InitialEstimatedHours
|
||||
.Add(existingAdditionalTimes
|
||||
.Where(x => x.Id != existingAdditionalTime.Id)
|
||||
.Aggregate(TimeSpan.Zero, (acc, x) => acc.Add(x.Hours))
|
||||
.Add(additionalTimeSpan));
|
||||
|
||||
ValidateTotalTimeNotLessThanSpent(newTotalTime, currentTotalSpent);
|
||||
|
||||
// ویرایش بدون حذف و ایجاد دوباره
|
||||
existingAdditionalTime.Update(additionalTimeSpan, additionalTime.Description);
|
||||
hasRealChange = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// اگر ID نداشت یا ID جدید بود، اضافه کن
|
||||
if (additionalTime.Id == null || additionalTime.Id == Guid.Empty)
|
||||
{
|
||||
var newTotalTime = section.FinalEstimatedHours.Add(additionalTimeSpan);
|
||||
ValidateTotalTimeNotLessThanSpent(newTotalTime, currentTotalSpent);
|
||||
|
||||
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||
hasRealChange = true;
|
||||
}
|
||||
}
|
||||
var additionalTimeSpan = TimeSpan.FromHours(additionalTime.Hours).Add(TimeSpan.FromMinutes(additionalTime.Minutes));
|
||||
section.AddAdditionalTime(additionalTimeSpan, additionalTime.Description, addedByUserId);
|
||||
hasAdditionalTime = true;
|
||||
}
|
||||
|
||||
// تغییر status به Incomplete فقط اگر تغییری واقعی اعمال شده باشد و در وضعیتی غیر از ReadyToStart باشد
|
||||
if (hasRealChange && section.Status != TaskSectionStatus.ReadyToStart)
|
||||
// تغییر status به Incomplete فقط اگر زمان اضافی اضافه شده باشد و در وضعیتی غیر از ReadyToStart باشد
|
||||
if (hasAdditionalTime && section.Status != TaskSectionStatus.ReadyToStart)
|
||||
{
|
||||
// اگر سکشن درحال انجام است، باید متوقف شود قبل از تغییر status
|
||||
if (section.Status == TaskSectionStatus.InProgress)
|
||||
|
||||
@@ -228,30 +228,28 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
// For projects: gather all phases, then tasks, then sections
|
||||
var phases = await _context.ProjectPhases
|
||||
.Where(ph => projectIds.Contains(ph.ProjectId))
|
||||
.Select(ph => new { ph.Id, ph.ProjectId })
|
||||
.Select(ph => ph.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var phaseIds = phases.Select(ph => ph.Id).ToList();
|
||||
var tasks = await _context.ProjectTasks
|
||||
.Where(t => phaseIds.Contains(t.PhaseId))
|
||||
.Select(t => new { t.Id, t.PhaseId })
|
||||
.Where(t => phases.Contains(t.PhaseId))
|
||||
.Select(t => t.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var taskIds = tasks.Select(t => t.Id).ToList();
|
||||
var sections = await _context.TaskSections
|
||||
.Include(s => s.Skill)
|
||||
.Where(s => taskIds.Contains(s.TaskId))
|
||||
.Where(s => tasks.Contains(s.TaskId))
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
// Convert to tuple list for AggregatePhaseStatuses
|
||||
var tasksList = tasks.Select(t => (t.Id, t.PhaseId)).ToList();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var projectPhaseIds = phases.Where(ph => ph.ProjectId == item.Id).Select(ph => ph.Id).ToList();
|
||||
|
||||
// برای هر Skill، وضعیتهای تمام Phases را تجمیع کنیم
|
||||
item.Backend = AggregatePhaseStatuses(projectPhaseIds, tasksList, sections, "Backend");
|
||||
item.Front = AggregatePhaseStatuses(projectPhaseIds, tasksList, sections, "Frontend");
|
||||
item.Design = AggregatePhaseStatuses(projectPhaseIds, tasksList, sections, "UI/UX Design");
|
||||
var relatedPhases = phases; // used for filtering tasks by project
|
||||
var relatedTasks = await _context.ProjectTasks
|
||||
.Where(t => t.PhaseId != Guid.Empty && relatedPhases.Contains(t.PhaseId))
|
||||
.Select(t => t.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var itemSections = sections.Where(s => relatedTasks.Contains(s.TaskId));
|
||||
item.Backend = GetAssignmentStatus(itemSections.FirstOrDefault(x => x.Skill?.Name == "Backend"));
|
||||
item.Front = GetAssignmentStatus(itemSections.FirstOrDefault(x => x.Skill?.Name == "Frontend"));
|
||||
item.Design = GetAssignmentStatus(itemSections.FirstOrDefault(x => x.Skill?.Name == "UI/UX Design"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,22 +259,24 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
// For phases: gather tasks, then sections
|
||||
var tasks = await _context.ProjectTasks
|
||||
.Where(t => phaseIds.Contains(t.PhaseId))
|
||||
.Select(t => new { t.Id, t.PhaseId })
|
||||
.Select(t => t.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var taskIds = tasks.Select(t => t.Id).ToList();
|
||||
var sections = await _context.TaskSections
|
||||
.Include(s => s.Skill)
|
||||
.Where(s => taskIds.Contains(s.TaskId))
|
||||
.Where(s => tasks.Contains(s.TaskId))
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
var phaseTaskIds = tasks.Where(t => t.PhaseId == item.Id).Select(t => t.Id).ToList();
|
||||
// Filter tasks for this phase
|
||||
var phaseTaskIds = await _context.ProjectTasks
|
||||
.Where(t => t.PhaseId == item.Id)
|
||||
.Select(t => t.Id)
|
||||
.ToListAsync(cancellationToken);
|
||||
var itemSections = sections.Where(s => phaseTaskIds.Contains(s.TaskId));
|
||||
|
||||
item.Backend = AggregateAssignmentStatus(itemSections.Where(x => x.Skill?.Name == "Backend"));
|
||||
item.Front = AggregateAssignmentStatus(itemSections.Where(x => x.Skill?.Name == "Frontend"));
|
||||
item.Design = AggregateAssignmentStatus(itemSections.Where(x => x.Skill?.Name == "UI/UX Design"));
|
||||
item.Backend = GetAssignmentStatus(itemSections.FirstOrDefault(x => x.Skill?.Name == "Backend"));
|
||||
item.Front = GetAssignmentStatus(itemSections.FirstOrDefault(x => x.Skill?.Name == "Frontend"));
|
||||
item.Design = GetAssignmentStatus(itemSections.FirstOrDefault(x => x.Skill?.Name == "UI/UX Design"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,57 +380,4 @@ public class GetProjectsListQueryHandler : IBaseQueryHandler<GetProjectsListQuer
|
||||
// تعیین تکلیف نشده: نه user دارد نه time
|
||||
return AssignmentStatus.Unassigned;
|
||||
}
|
||||
|
||||
private static AssignmentStatus AggregatePhaseStatuses(
|
||||
List<Guid> phaseIds,
|
||||
List<(Guid Id, Guid PhaseId)> tasks,
|
||||
List<TaskSection> sections,
|
||||
string skillName)
|
||||
{
|
||||
var phaseStatuses = new List<AssignmentStatus>();
|
||||
|
||||
foreach (var phaseId in phaseIds)
|
||||
{
|
||||
var phaseTaskIds = tasks.Where(t => t.PhaseId == phaseId).Select(t => t.Id).ToList();
|
||||
var phaseSections = sections.Where(s => phaseTaskIds.Contains(s.TaskId) && s.Skill?.Name == skillName);
|
||||
var phaseStatus = AggregateAssignmentStatus(phaseSections);
|
||||
phaseStatuses.Add(phaseStatus);
|
||||
}
|
||||
|
||||
// الآن تجمیع وضعیتهای Phases
|
||||
if (!phaseStatuses.Any())
|
||||
return AssignmentStatus.Unassigned;
|
||||
|
||||
// اگر هر یکی Unassigned باشد → Unassigned
|
||||
if (phaseStatuses.Any(s => s == AssignmentStatus.Unassigned))
|
||||
return AssignmentStatus.Unassigned;
|
||||
|
||||
// اگر Unassigned نیست و هر یکی UserOnly باشد → UserOnly
|
||||
if (phaseStatuses.Any(s => s == AssignmentStatus.UserOnly))
|
||||
return AssignmentStatus.UserOnly;
|
||||
|
||||
// فقط اگر همه Assigned باشند → Assigned
|
||||
return AssignmentStatus.Assigned;
|
||||
}
|
||||
|
||||
private static AssignmentStatus AggregateAssignmentStatus(IEnumerable<TaskSection> sections)
|
||||
{
|
||||
var sectionList = sections.ToList();
|
||||
if (!sectionList.Any())
|
||||
return AssignmentStatus.Unassigned;
|
||||
|
||||
var statuses = sectionList.Select(GetAssignmentStatus).ToList();
|
||||
|
||||
// اگر هر یکی Unassigned باشد → Unassigned (بدترین وضعیت)
|
||||
if (statuses.Any(s => s == AssignmentStatus.Unassigned))
|
||||
return AssignmentStatus.Unassigned;
|
||||
|
||||
// اگر Unassigned نیست و هر یکی UserOnly باشد → UserOnly (وضعیت متوسط)
|
||||
if (statuses.Any(s => s == AssignmentStatus.UserOnly))
|
||||
return AssignmentStatus.UserOnly;
|
||||
|
||||
// فقط اگر همه Assigned باشند → Assigned (بهترین وضعیت)
|
||||
return AssignmentStatus.Assigned;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,15 +26,4 @@ public class TaskSectionAdditionalTime : EntityBase<Guid>
|
||||
{
|
||||
Reason = reason;
|
||||
}
|
||||
|
||||
public void Update(TimeSpan hours, string? reason = null)
|
||||
{
|
||||
Hours = hours;
|
||||
Reason = reason;
|
||||
}
|
||||
|
||||
public bool HasChanged(TimeSpan newHours, string? newReason)
|
||||
{
|
||||
return Hours != newHours || Reason != newReason;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application.Enums;
|
||||
using _0_Framework.Application.Sms;
|
||||
using CompanyManagment.App.Contracts.InstitutionContract;
|
||||
using _0_Framework.Application.Sms;
|
||||
using CompanyManagment.App.Contracts.SmsResult;
|
||||
using CompanyManagment.App.Contracts.SmsResult.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -12,14 +9,12 @@ namespace ServiceHost.Areas.Admin.Controllers;
|
||||
public class SmsReportController : AdminBaseController
|
||||
{
|
||||
private readonly ISmsResultApplication _smsResultApplication;
|
||||
private readonly ISmsSettingApplication _smsSettingApplication;
|
||||
private readonly ISmsService _smsService;
|
||||
|
||||
public SmsReportController(ISmsResultApplication smsResultApplication, ISmsService smsService, ISmsSettingApplication smsSettingApplication)
|
||||
public SmsReportController(ISmsResultApplication smsResultApplication, ISmsService smsService)
|
||||
{
|
||||
_smsResultApplication = smsResultApplication;
|
||||
_smsService = smsService;
|
||||
_smsSettingApplication = smsSettingApplication;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,25 +35,11 @@ public class SmsReportController : AdminBaseController
|
||||
/// </summary>
|
||||
/// <param name="searchModel"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <param name="typeOfSmsSetting"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetExpandedList")]
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date, string typeOfSmsSetting)
|
||||
public async Task<List<SmsReportListDto>> GetSmsReportExpandList(SmsReportSearchModel searchModel, string date)
|
||||
{
|
||||
var result =await _smsResultApplication.GetSmsReportExpandList(searchModel, date, typeOfSmsSetting);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت جزئیات پیامک
|
||||
/// </summary>
|
||||
/// <param name="messId"></param>
|
||||
/// <param name="fullName"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetSmsDetails")]
|
||||
public async Task<SmsDetailsDto> GetSmsDetails(int messId, string fullName)
|
||||
{
|
||||
var result =await _smsService.GetSmsDetailsByMessageId(messId, fullName);
|
||||
var result =await _smsResultApplication.GetSmsReportExpandList(searchModel, date);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -75,207 +56,4 @@ public class SmsReportController : AdminBaseController
|
||||
return result;
|
||||
}
|
||||
|
||||
//تنظیمات پیامک خودکار
|
||||
#region SmsSettings
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - یادآور
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ReminderSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> ReminderSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - مسدودی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("BlockSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> BlockSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.BlockContractingParty);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - هشدار قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("WarningSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> WarningSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.Warning);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - اقدام قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("LegalActionSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> LegalActionSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.LegalAction);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// لیست تنظیمات پیامک - تایید قراداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("ContractConfirmSmsSettingList")]
|
||||
public async Task<List<SmsSettingDto>> ContractConfirmSmsSettingList()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetSmsSettingList(TypeOfSmsSetting.InstitutionContractConfirm);
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================Create=========================
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک یادآور
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateReminderSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateReminderSmsSetting([FromBody] CreateSmsSettingDto command)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(command.DayOfMonth, command.TimeOfDayDisplay, TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک مسدودی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateBlockSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateBlockSmsSetting([FromBody] CreateSmsSettingDto command)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(command.DayOfMonth, command.TimeOfDayDisplay, TypeOfSmsSetting.BlockContractingParty);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک هشدار قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateWarningSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateWarningSmsSetting([FromBody] CreateSmsSettingDto command)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(command.DayOfMonth, command.TimeOfDayDisplay, TypeOfSmsSetting.Warning);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک اقدام قضایی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateLegalActionSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateLegalActionSmsSetting([FromBody] CreateSmsSettingDto command)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(command.DayOfMonth, command.TimeOfDayDisplay, TypeOfSmsSetting.LegalAction);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد پیامک تایید قرارداد مالی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateContractConfirmSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> CreateContractConfirmSmsSetting([FromBody] CreateSmsSettingDto command)
|
||||
{
|
||||
var result = await _smsSettingApplication.CreateSmsSetting(command.DayOfMonth, command.TimeOfDayDisplay, TypeOfSmsSetting.InstitutionContractConfirm);
|
||||
return result;
|
||||
}
|
||||
//=====================Edit=========================
|
||||
|
||||
/// <summary>
|
||||
/// دریافت اطلاعات ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetEditData")]
|
||||
public async Task<SmsSettingDto> GetEditData(long id)
|
||||
{
|
||||
return await _smsSettingApplication.GetSmsSettingDataToEdit(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ویرایش تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("EditSmsSetting")]
|
||||
public async Task<ActionResult<OperationResult>> EditSmsSetting([FromBody] SmsSettingDto command)
|
||||
{
|
||||
var result =await _smsSettingApplication.EditSmsSetting(command);
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================Remove=========================
|
||||
|
||||
/// <summary>
|
||||
/// حذف تنظیمات پیامک
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<ActionResult<OperationResult>> RemoveSmsSetting(long id)
|
||||
{
|
||||
await _smsSettingApplication.RemoveSetting(id);
|
||||
return Ok(new OperationResult().Succcedded());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست ارسال آنی یادآور
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetInstantReminderSmsListData")]
|
||||
public async Task<List<InstantReminderSendSms>> GetInstantReminderSmsListData()
|
||||
{
|
||||
var result =await _smsSettingApplication.GetInstantReminderSmsListData(TypeOfSmsSetting.InstitutionContractDebtReminder);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست ارسال آنی مسدودی
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetInstantBlockSmsListData")]
|
||||
public async Task<List<InstantReminderSendSms>> GetInstantBlockSmsListData()
|
||||
{
|
||||
var result = await _smsSettingApplication.GetInstantReminderSmsListData(TypeOfSmsSetting.BlockContractingParty);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک آنی یادآور
|
||||
/// </summary>
|
||||
/// <param name="phoneNumbers"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("InstantReminderSmsSend")]
|
||||
public async Task<ActionResult> InstantReminderSmsSend([FromBody] List<string> phoneNumbers)
|
||||
{
|
||||
var result = _smsSettingApplication.InstantSmsSendApi(TypeOfSmsSetting.InstitutionContractDebtReminder, phoneNumbers);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ارسال پیامک آنی مسدودی
|
||||
/// </summary>
|
||||
/// <param name="phoneNumbers"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("InstantBlockSmsSend")]
|
||||
public async Task<ActionResult> InstantBlockSmsSend([FromBody] List<string> phoneNumbers)
|
||||
{
|
||||
var result = _smsSettingApplication.InstantSmsSendApi(TypeOfSmsSetting.BlockContractingParty, phoneNumbers);
|
||||
return Ok();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -796,17 +796,12 @@ public class IndexModel : PageModel
|
||||
|
||||
var firstContract = _contractApplication.GetDetails(ContractsId[0]);
|
||||
var workshop = _workshopApplication.GetDetails(firstContract.WorkshopIds);
|
||||
|
||||
|
||||
//int i = 0;
|
||||
foreach (var item in ContractsId)
|
||||
{
|
||||
var contract = _contractApplication.GetDetails(item);
|
||||
|
||||
//=============== استثنا علی خادم دهقان - میز اداری پویا========
|
||||
if (workshop.Id == 482 && contract.EmployeeId == 7175)
|
||||
workshop.IsOldContract = false;
|
||||
//==============================================================
|
||||
|
||||
|
||||
//var workingHours = _workingHoursApplication.GetByContractId(contract.Id);
|
||||
var workingHours = _workingHoursTempApplication.GetByContractIdConvertToShiftwork4(contract.Id);
|
||||
var separation = _contractApplication.contractSeparation(ConvertYear, ConvertMonth,
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
بانک ها </a>
|
||||
</li>
|
||||
<li permission="314">
|
||||
<a class="clik3" href="https://admin@(AppSetting.Value.Domain)/automatic-sms-reporting">
|
||||
<a class="clik3" asp-page="/Company/SmsResult/Index">
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
|
||||
<circle cx="6.5" cy="6.5" r="6.5" fill="white"/>
|
||||
</svg>
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
@page
|
||||
@model ServiceHost.Areas.AdminNew.Pages.Company.ExcelUpload.IndexModel
|
||||
@{
|
||||
ViewData["Title"] = "بارگذاری فایل اکسل";
|
||||
}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">بارگذاری و بررسی فایل اکسل</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label for="ExcelFile">انتخاب فایل اکسل (ستون B و C از ردیف 2 به بعد خوانده میشود):</label>
|
||||
<input type="file" class="form-control" id="ExcelFile" name="ExcelFile" accept=".xlsx,.xls" required />
|
||||
</div>
|
||||
<button type="submit" asp-page-handler="UploadExcel" class="btn btn-primary">بارگذاری و پردازش</button>
|
||||
</form>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Message))
|
||||
{
|
||||
<div class="alert alert-info mt-3" role="alert">
|
||||
@Model.Message
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (Model.HasProcessed)
|
||||
{
|
||||
<div class="row mt-4">
|
||||
<!-- دسته اول: فایلهایی که در اکسل هستند -->
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header bg-success text-white">
|
||||
<h4 class="card-title mb-0">فایلهای موجود در اکسل (@Model.FoundInExcel.Count مورد)</h4>
|
||||
</div>
|
||||
<div class="card-body" style="max-height: 600px; overflow-y: auto;">
|
||||
@if (Model.FoundInExcel.Any())
|
||||
{
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ردیف</th>
|
||||
<th>شناسه</th>
|
||||
<th>شماره بایگانی</th>
|
||||
<th>رده پرونده</th>
|
||||
<th>وضعیت</th>
|
||||
<th>عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
int index = 1;
|
||||
}
|
||||
@foreach (var item in Model.FoundInExcel)
|
||||
{
|
||||
<tr>
|
||||
<td>@index</td>
|
||||
<td>@item.ArchiveNo</td>
|
||||
<td>@item.FileClass</td>
|
||||
<td>@(item.Status == 2 ? "فعال" : "غیرفعال")</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary">ویرایش</button>
|
||||
</td>
|
||||
</tr>
|
||||
index++;
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-muted">هیچ موردی یافت نشد.</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- دسته دوم: فایلهایی که در اکسل نیستند -->
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header bg-warning text-dark">
|
||||
<h4 class="card-title mb-0">فایلهای غیرموجود در اکسل (@Model.NotFoundInExcel.Count مورد)</h4>
|
||||
</div>
|
||||
<div class="card-body" style="max-height: 600px; overflow-y: auto;">
|
||||
@if (Model.NotFoundInExcel.Any())
|
||||
{
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ردیف</th>
|
||||
<th>شناسه</th>
|
||||
<th>شماره بایگانی</th>
|
||||
<th>رده پرونده</th>
|
||||
<th>وضعیت</th>
|
||||
<th>عملیات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@{
|
||||
int index2 = 1;
|
||||
}
|
||||
@foreach (var item in Model.NotFoundInExcel)
|
||||
{
|
||||
<tr>
|
||||
<td>@index2</td>
|
||||
<td>@item.ArchiveNo</td>
|
||||
<td>@item.FileClass</td>
|
||||
<td>@(item.Status == 2 ? "فعال" : "غیرفعال")</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary">ویرایش</button>
|
||||
</td>
|
||||
</tr>
|
||||
index2++;
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-muted">هیچ موردی یافت نشد.</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
border-radius: 8px 8px 0 0;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.table thead th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: #f8f9fa;
|
||||
z-index: 10;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using Company.Domain.File1;
|
||||
using Company.Domain.RollCallAgg;
|
||||
using Company.Domain.RollCallAgg.DomainService;
|
||||
using CompanyManagment.EFCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace ServiceHost.Areas.AdminNew.Pages.Company.ExcelUpload;
|
||||
|
||||
public class ExcelRowData
|
||||
{
|
||||
public string ColumnB { get; set; }
|
||||
public string ColumnC { get; set; }
|
||||
}
|
||||
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly CompanyContext _dbContext;
|
||||
private readonly IRollCallDomainService _rollCallDomainService;
|
||||
|
||||
[BindProperty]
|
||||
public IFormFile ExcelFile { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
public List<File1> FoundInExcel { get; set; } = new List<File1>();
|
||||
public List<File1> NotFoundInExcel { get; set; } = new List<File1>();
|
||||
public List<ExcelRowData> ExcelData { get; set; } = new List<ExcelRowData>();
|
||||
public bool HasProcessed { get; set; }
|
||||
|
||||
public IndexModel(CompanyContext dbContext, IRollCallDomainService rollCallDomainService)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_rollCallDomainService = rollCallDomainService;
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostUploadExcel()
|
||||
{
|
||||
if (ExcelFile == null || ExcelFile.Length == 0)
|
||||
{
|
||||
Message = "لطفا یک فایل اکسل انتخاب کنید.";
|
||||
return Page();
|
||||
}
|
||||
|
||||
//await NewMethod();
|
||||
|
||||
// var rollcall = _dbContext.RollCalls.Where(x => x.id > 361628 && x.id < 362119).ToList();
|
||||
//
|
||||
// var diffTime = TimeSpan.FromHours(8) + TimeSpan.FromMinutes(30);
|
||||
// var NoneRollCalls = rollcall
|
||||
// .Where(x => x.RollCallModifyType == RollCallModifyType.None && x.EndDate == null).ToList();
|
||||
// foreach (var noneRollCall in NoneRollCalls)
|
||||
// {
|
||||
// noneRollCall.SetStartDate(noneRollCall.StartDate!.Value.Add(diffTime));
|
||||
// }
|
||||
// var rollcallIds = NoneRollCalls.Select(x => x.id).ToList();
|
||||
// var editedRollCall = rollcall.Where(x=>!rollcallIds.Contains(x.id) && x.RollCallModifyType != RollCallModifyType.EditByEmployer).ToList();
|
||||
//
|
||||
// foreach (var rollCall in editedRollCall)
|
||||
// {
|
||||
// rollCall.Edit(rollCall.StartDate.Value.Add(diffTime),
|
||||
// rollCall.EndDate.Value.Add(diffTime),_rollCallDomainService);
|
||||
// }
|
||||
//
|
||||
// await _dbContext.SaveChangesAsync();
|
||||
return Page();
|
||||
}
|
||||
|
||||
private async System.Threading.Tasks.Task NewMethod()
|
||||
{
|
||||
try
|
||||
{
|
||||
ExcelPackage.License.SetNonCommercialOrganization("Gozareshgir Noncommercial organization");
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
await ExcelFile.CopyToAsync(stream);
|
||||
stream.Position = 0;
|
||||
|
||||
using (var package = new ExcelPackage(stream))
|
||||
{
|
||||
var worksheet = package.Workbook.Worksheets[0];
|
||||
int rowCount = worksheet.Dimension?.Rows ?? 0;
|
||||
|
||||
// خواندن مقادیر از ستون B و C از ردیف 2 به بعد
|
||||
for (int row = 2; row <= rowCount; row++)
|
||||
{
|
||||
var columnB = worksheet.Cells[row, 2].Value?.ToString()?.Trim();
|
||||
var columnC = worksheet.Cells[row, 3].Value?.ToString()?.Trim();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(columnB) || !string.IsNullOrWhiteSpace(columnC))
|
||||
{
|
||||
ExcelData.Add(new ExcelRowData
|
||||
{
|
||||
ColumnB = columnB ?? "",
|
||||
ColumnC = columnC ?? ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ساخت HashSet برای سرچ سریع - هر جفت (B, C) رو با هم نگه داری
|
||||
var excelPairs = new HashSet<(string B, string C)>(
|
||||
ExcelData.Select(x => (
|
||||
B: (x.ColumnB ?? "").Trim(),
|
||||
C: (x.ColumnC ?? "").Trim()
|
||||
)));
|
||||
|
||||
// دریافت تمام دادههای موجود در دیتابیس
|
||||
var allFiles = _dbContext.Files.ToList();
|
||||
|
||||
// دستهبندی: فایلهایی که در اکسل هستند و نیستند
|
||||
foreach (var file in allFiles)
|
||||
{
|
||||
var fileB = file.ArchiveNo.ToString();
|
||||
var fileC = (file.FileClass ?? "").Trim();
|
||||
|
||||
// بررسی آیا جفت (B, C) این فایل در اکسل وجود دارد
|
||||
bool foundInExcel = excelPairs.Contains((fileB, fileC));
|
||||
|
||||
if (foundInExcel)
|
||||
{
|
||||
FoundInExcel.Add(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
NotFoundInExcel.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var file1 in FoundInExcel)
|
||||
{
|
||||
file1.ChangeStatus(2);
|
||||
}
|
||||
|
||||
foreach (var file1 in NotFoundInExcel)
|
||||
{
|
||||
file1.ChangeStatus(1);
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
HasProcessed = true;
|
||||
Message = $"پردازش با موفقیت انجام شد. تعداد ردیفهای اکسل: {ExcelData.Count} | فایلهای موجود در اکسل: {FoundInExcel.Count} | فایلهای غیرموجود در اکسل: {NotFoundInExcel.Count}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Message = $"خطا در پردازش فایل: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@
|
||||
بانک ها </a>
|
||||
</li>
|
||||
<li permission="314">
|
||||
<a class="clik3" href="https://admin@(AppSetting.Value.Domain)/automatic-sms-reporting">
|
||||
<a class="clik3" asp-area="Admin" asp-page="/Company/SmsResult/Index">
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" style="width: 7px;margin: 0 6px;">
|
||||
<circle cx="6.5" cy="6.5" r="6.5" fill="white" />
|
||||
</svg>
|
||||
|
||||
Reference in New Issue
Block a user