Merge remote-tracking branch 'origin/master'

This commit is contained in:
2025-12-24 18:55:19 +03:30
8 changed files with 524 additions and 458 deletions

View File

@@ -17,4 +17,9 @@
<ProjectReference Include="..\..\WorkFlow\Infrastructure\WorkFlow.Infrastructure.Config\WorkFlow.Infrastructure.Config.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
</ItemGroup>
</Project>

View File

@@ -15,19 +15,21 @@ public class JobSchedulerRegistrator
private static DateTime? _lastRunCreateTransaction;
private static DateTime? _lastRunSendMonthlySms;
private readonly ISmsService _smsService;
private readonly ILogger<JobSchedulerRegistrator> _logger;
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService)
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository, ISmsService smsService, ILogger<JobSchedulerRegistrator> logger)
{
_smsReminder = smsReminder;
_backgroundJobClient = backgroundJobClient;
_institutionContractRepository = institutionContractRepository;
_smsService = smsService;
_logger = logger;
}
public void Register()
{
_logger.LogInformation("hangfire Started");
RecurringJob.AddOrUpdate(
"InstitutionContract.CreateFinancialTransaction",
() => CreateFinancialTransaction(),

View File

@@ -17,9 +17,37 @@ using Microsoft.AspNetCore.Identity;
using MongoDB.Driver;
using PersonalContractingParty.Config;
using Query.Bootstrapper;
using Serilog;
using Serilog.Events;
using Shared.Contracts.PmUser.Queries;
using WorkFlow.Infrastructure.Config;
var logDirectory = @"C:\Logs\Hangfire\BackgroundInstitutionContract\";
if (!Directory.Exists(logDirectory))
{
Directory.CreateDirectory(logDirectory);
}
Log.Logger = new LoggerConfiguration()
//NO EF Core log
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
//NO DbCommand log
.MinimumLevel.Override("Microsoft.EntityFrameworkCore.Database.Command", LogEventLevel.Warning)
//NO Microsoft Public log
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.WriteTo.File(
path: Path.Combine(logDirectory, "institution-contract-log-.txt"),
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 30,
shared: true,
outputTemplate:
"{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}"
).CreateLogger();
var builder = WebApplication.CreateBuilder(args);
var hangfireConnectionString = builder.Configuration.GetConnectionString("HangfireDb");
builder.Services.AddHangfire(x => x.UseSqlServerStorage(hangfireConnectionString));
@@ -59,7 +87,13 @@ builder.Services.AddHttpClient();
builder.Services.AddHttpContextAccessor();
builder.Services.AddSignalR();
builder.Host.UseSerilog();
Log.Information("SERILOG STARTED SUCCESSFULLY");
var app = builder.Build();
app.MapHub<SendSmsHub>("/sendSmsHub");
app.MapHangfireDashboard();

View File

@@ -25,8 +25,8 @@
//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;",
"HangfireDb": "Data Source=185.208.175.186;Initial Catalog=hangfire_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;"
"HangfireDb": "Data Source=.;Initial Catalog=hangfire_db;Integrated Security=True;TrustServerCertificate=true;",
//"HangfireDb": "Data Source=185.208.175.186;Initial Catalog=hangfire_db;Persist Security Info=False;User ID=ir_db;Password=R2rNp[170]18[3019]#@ATt;TrustServerCertificate=true;"
},
"GoogleRecaptchaV3": {

View File

@@ -25,6 +25,7 @@ using CompanyManagment.App.Contracts.TemporaryClientRegistration;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using MongoDB.Driver;
using PersianTools.Core;
using System;
@@ -54,6 +55,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
private readonly IFinancialTransactionRepository _financialTransactionRepository;
private readonly IFinancialStatmentRepository _financialStatmentRepository;
private readonly IHubContext<SendSmsHub> _hubContext;
private readonly ILogger<InstitutionContractRepository> _logger;
private readonly InstitutionContratVerificationParty _firstParty = new()
{
@@ -69,7 +71,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
IWorkshopRepository workshopRepository, IMongoDatabase database,
IPlanPercentageRepository planPercentageRepository, ISmsService smsService,
ISmsResultRepository smsResultRepository, IFinancialTransactionRepository financialTransactionRepository,
IFinancialStatmentRepository financialStatmentRepository, IHubContext<SendSmsHub> hubContext) : base(context)
IFinancialStatmentRepository financialStatmentRepository, IHubContext<SendSmsHub> hubContext, ILogger<InstitutionContractRepository> logger) : base(context)
{
_context = context;
_employerRepository = employerRepository;
@@ -80,6 +82,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
_financialTransactionRepository = financialTransactionRepository;
_financialStatmentRepository = financialStatmentRepository;
_hubContext = hubContext;
_logger = logger;
_institutionExtensionTemp =
database.GetCollection<InstitutionContractExtensionTemp>("InstitutionContractExtensionTemp");
_institutionAmendmentTemp =
@@ -3490,7 +3493,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
if (checkAnyToExecute)
{
//اجرای تسک
_logger.LogInformation("اجرای تسک پیامک های یاد آور SendReminderSmsForBackgroundTask" + persianNow + " - " + hour + ":" + minute);
//دریافت لیست بدهکاران
var smsListData = await GetSmsListData(now, TypeOfSmsSetting.InstitutionContractDebtReminder);
string typeOfSms = "یادآور بدهی ماهانه";
@@ -4265,6 +4268,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
{
string name = item.PartyName.Length > 18 ? item.PartyName.Substring(0, 18) : item.PartyName;
string errMess = $"{name}-خطا";
_logger.LogError(errMess);
await _smsService.Alarm("09114221321", errMess);
}
@@ -4378,7 +4382,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
if (checkAnyToExecute)
{
//اجرای تسک
_logger.LogInformation("اجرای تسک ارسال یاد آور تایید قراداد مالی SendInstitutionContractConfirmSms" + persianNow + " - " + hour + ":" + minute);
//دریافت لیست قراداد های تایید نشده
var fromAmonthAgo = now.AddDays(-30);
var pendingContracts = await _context.InstitutionContractSet
@@ -4398,6 +4402,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
string typeOfSms = "یادآور تایید قرارداد مالی";
foreach (var item in pendingContracts)
{
var sendResult = await _smsService.SendInstitutionCreationVerificationLink(item.Number, item.FullName,
item.InstitutionId, item.ContractingPartyId, item.InstitutionContractId, typeOfSms);
Thread.Sleep(1000);

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application;
using _0_Framework.Application.Sms;
using Company.Domain.SmsResultAgg;
using CompanyManagment.App.Contracts.SmsResult;
@@ -10,6 +6,11 @@ using IPE.SmsIrClient;
using IPE.SmsIrClient.Models.Requests;
using IPE.SmsIrClient.Models.Results;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using SmsResult = Company.Domain.SmsResultAgg.SmsResult;
@@ -17,521 +18,531 @@ 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;
private readonly ILogger<SmsService> _logger;
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, ILogger<SmsService> logger)
{
_configuration = configuration;
_smsResultRepository = smsResultRepository;
_logger = logger;
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>();
}
// خواندن تنظیمات 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);
}
}
/// <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;
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);
//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;
//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)
{
//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.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;
var resStartStatus = verificationSendResult.Status;
var resResult = verificationSendResult.Status;
var reseExceptiont = verificationSendResult.Exception;
return false;
}
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)
{
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.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;
var resStartStatus = verificationSendResult.Status;
var resResult = verificationSendResult.Status;
var reseExceptiont = verificationSendResult.Exception;
return false;
}
}
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);
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);
}
}
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)
{
public bool SendAccountsInfo(string number, string fullName, string userName)
{
var checkLength = fullName.Length;
if (checkLength > 25)
fullName = fullName.Substring(0, 24);
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) });
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;
}
Console.WriteLine(userName + " - " + sendResult.Result.Status);
if (sendResult.IsCompletedSuccessfully)
{
return true;
}
else
{
return false;
}
}
}
public async Task<ApiResultViewModel> GetByMessageId(int messId)
{
public async Task<ApiResultViewModel> GetByMessageId(int messId)
{
SmsIr smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
var response = await smsIr.GetReportAsync(messId);
MessageReportResult messages = response.Data;
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);
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);
}
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;
}
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;
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 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 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");
}
return "";
}
private string GetToken()
{
return "";
//var smsSecrets = _configuration.GetSection("SmsSecrets");
//var tokenService = new Token();
//return tokenService.GetToken("x-api-key", "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
}
#region Mahan
#region Mahan
public async Task<double> GetCreditAmount()
{
try
{
var credit = await SmsIr.GetCreditAsync();
return (double)credit.Data;
}
catch
{
return -1;
}
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, string typeOfSms)
{
public async Task<bool> SendInstitutionCreationVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId, string typeOfSms)
{
typeOfSms = string.IsNullOrWhiteSpace(typeOfSms) ? "لینک تاییدیه ایجاد قرارداد مالی" : typeOfSms;
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 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)
});
if (verificationSendResult.Status == 1)
{
_logger.LogInformation("ارسال لینک قراداد مالی موفق بود");
}
else
{
_logger.LogError("خطا در ارسال لینک قراداد مالی");
}
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, typeOfSms,
fullName, number, contractingPartyId, institutionContractId);
await _smsResultRepository.CreateAsync(smsResult);
await _smsResultRepository.SaveChangesAsync();
return verificationSendResult.Status == 0;
}
fullName, number, contractingPartyId, institutionContractId);
await _smsResultRepository.CreateAsync(smsResult);
await _smsResultRepository.SaveChangesAsync();
_logger.LogInformation("ذخیره در دیتابیس موفق بود");
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> 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)
});
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;
}
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();
}
public _0_Framework.Application.Sms.SmsResult TaskReminderSms(string number, string taskCount)
{
throw new NotImplementedException();
}
#endregion
#endregion
#region InstitutionContractSMS
#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)
{
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);
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 == "موفق")
{
if (sendResult.Message == "موفق")
{
_logger.LogInformation("ارسال پیامک یادآور موفق بود");
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
return result;
}
_logger.LogError("خطا در ارسال یاد آور");
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
return result;
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);
public async Task<(byte status, string message, int messaeId, bool isSucceded)> MonthlyBill(string number, int tamplateId, string fullname, string amount, string id,
string aprove)
{
if (sendResult.Message == "موفق")
{
_logger.LogInformation("ارسال پیامک یادآور موفق بود");
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
return result;
}
_logger.LogError("خطا در ارسال یاد آور");
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
return result;
}
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);
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 == "موفق")
{
if (sendResult.Message == "موفق")
{
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
return result;
}
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
return result;
}
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
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);
#endregion
if (sendResult.Message == "موفق")
{
#region AlarmMessage
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, true);
return result;
}
public async Task<bool> Alarm(string number, string message)
{
var smsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
result = (sendResult.Status, sendResult.Message, sendResult.Data.MessageId, false);
return result;
}
//var bulkSendResult = smsIr.BulkSendAsync(95007079000006, "your text message", new string[] { "9120000000" });
#endregion
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;
#region AlarmMessage
return false;
}
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
#endregion
}

View File

@@ -43,6 +43,9 @@
case TypeOfSmsSetting.Warning:
<h5 class="modal-title">ایجاد پیامک هشدار قضائی</h5>
break;
case TypeOfSmsSetting.InstitutionContractConfirm:
<h5 class="modal-title">ایجاد پیامک یادآور تایید قراداد</h5>
break;
}
}

View File

@@ -41,6 +41,10 @@
case TypeOfSmsSetting.Warning:
<h5 class="modal-title">ویرایش پیامک هشدار قضائی</h5>
break;
case TypeOfSmsSetting.InstitutionContractConfirm:
<h5 class="modal-title">ویرایش پیامک یادآور تایید قراداد</h5>
break;
}
}
<button type="button" class="close" data-dismiss="modal" aria-label="بستن">
@@ -100,8 +104,8 @@
success: function (response) {
if(response.isSuccess){
$.Notification.autoHideNotify('success', 'top center', 'پیام سیستم ', response.message);
$('.close').click();
$('.close').click();
setTimeout(function () {
if(modelTypeOfSmsSetting == '@TypeOfSmsSetting.InstitutionContractDebtReminder'){
$('#institutionContractDebtReminderTab').click();
@@ -114,14 +118,16 @@
}else if(modelTypeOfSmsSetting == '@TypeOfSmsSetting.Warning'){
$('#warningTab').click();
}else if(typeOfSmsSetting == '@TypeOfSmsSetting.InstitutionContractConfirm'){
}else if(modelTypeOfSmsSetting == '@TypeOfSmsSetting.InstitutionContractConfirm'){
$('#institutionContractConfirmTab').click();
}
}, 500);
}, 700);
}else{
$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', response.message);
}