test change

This commit is contained in:
gozareshgir
2026-02-02 19:16:47 +03:30
parent debb54bafc
commit b65c33c43a
2 changed files with 29 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
using System.Text.RegularExpressions;
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using _0_Framework.Application;
using Microsoft.AspNetCore.SignalR;
namespace CompanyManagment.App.Contracts.Hubs;
@@ -7,6 +9,21 @@ 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)
{

View File

@@ -31,8 +31,9 @@ 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) : base(context)
public InstitutionContractSmsServiceRepository(CompanyContext context, ISmsService smsService, ILogger<InstitutionContractSmsServiceRepository> logger, ISmsResultRepository smsResultRepository, IHubContext<SendSmsHub> hubContext, IPersonalContractingPartyRepository personalContractingPartyRepository, IAuthHelper authHelper) : base(context)
{
_context = context;
_smsService = smsService;
@@ -40,6 +41,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
_smsResultRepository = smsResultRepository;
_hubContext = hubContext;
_personalContractingPartyRepository = personalContractingPartyRepository;
_authHelper = authHelper;
}
//هشدار - اقدام قضائی
@@ -937,6 +939,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
public async Task SendBlockSmsToContractingParties(List<BlockSmsListData> smsListData, string typeOfSms,
string sendMessStart, string sendMessEnd)
{
var accountId = _authHelper.CurrentAccountId();
if (smsListData.Any())
{
await _smsService.Alarm("09114221321", sendMessStart);
@@ -983,7 +986,7 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
Thread.Sleep(600);
var percent = (successProcess / (double)countList) * 100;
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(10))
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(accountId))
.SendAsync("showStatus", (int)percent);
successProcess += 1;
@@ -2096,6 +2099,9 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
string sendMessStart, string sendMessEnd)
{
//ارسال پیامک با اساس لیست
var accountId = _authHelper.CurrentAccountId();
var gr = _hubContext.Clients.Group(SendSmsHub.GetGroupName(accountId));
#region SendSMSFromList
@@ -2111,17 +2117,14 @@ public class InstitutionContractSmsServiceRepository : RepositoryBase<long, Inst
for (int i = 0; i < 100; i++)
{
var percent = (successProcess / (double)100) * 100;
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(7))
.SendAsync("showStatus", (int)percent);
await gr.SendAsync("showStatus", (int)percent);
if (i == 5)
{
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(7))
.SendAsync("error", "خطا در شماره 5");
await gr.SendAsync("error", "خطا در شماره 5");
}
if (i == 10)
{
await _hubContext.Clients.Group(SendSmsHub.GetGroupName(7))
.SendAsync("error", "خطا در شماره 10");
await gr.SendAsync("error", "خطا در شماره 10");
}
successProcess += 1;
Thread.Sleep(600);