add test page

This commit is contained in:
2025-12-29 00:00:20 +03:30
parent b69691c84f
commit 3ca7b7df9a
6 changed files with 2017 additions and 21 deletions

View File

@@ -112,13 +112,18 @@ public sealed class DeviceTokenService : IDeviceTokenService
await dbContext.SaveChangesAsync(cancellationToken);
// ارسال کد توکن از طریق پیامک
// ارسال کد توکن از طریق پیامک الگویی
try
{
await smsService.SendWebserviceSmsAsync(new WebserviceSmsRequest
await smsService.SendPatternSmsAsync(new PatternSmsRequest
{
Recipient = request.DevicePhoneNumber,
Message = $"0911925302120#{tokenCode}"
Recipients = new List<string> { request.DevicePhoneNumber },
PatternCode = "gfukab9r0nca0pt", // TODO: کد الگوی پیامک را اینجا قرار دهید
Variables = new Dictionary<string, string>
{
{ "tel", "09192530212" },
{ "verifyCode", verificationCode }
}
}, cancellationToken);
}
catch (Exception smsEx)
@@ -194,21 +199,28 @@ public sealed class DeviceTokenService : IDeviceTokenService
};
}
Random rnd = new Random();
// رمزگذاری ساده تنظیمات: DeviceName|UploadIntervalMin به Base64
var deviceId = settings.Device.Id;
var uploadInterval = settings.UploadIntervalMin;
string smsConfig = (settings.MinimumSmsIntervalMinutes != 0 ? "1" : rnd.Next(2, 9).ToString())
+ settings.MinimumSmsIntervalMinutes;
var plainText = $"{deviceId}01|{rnd.Next(1,9)}{uploadInterval}|{smsConfig}|{rnd.Next(139,97654)}|{rnd.Next(1,9)}{(int)settings.SimCardType}";
var encodedSettings = plainText; //Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(plainText));
// آماده‌سازی پارامترها برای ارسال پیامک الگویی
var deviceId = settings.Device.Id + "01";
var uploadInterval = rnd.Next(1, 9) + "" + settings.UploadIntervalMin;
var smsInterval = settings.MinimumSmsIntervalMinutes > 0 ? "1" + settings.MinimumSmsIntervalMinutes : "0" + rnd.Next(1, 9);
var sysNumber = rnd.Next(139, 97654); // عدد رندوم SysNumber
var simType = rnd.Next(1, 9).ToString() + ((int?)settings.SimCardType)?.ToString() ?? "1"; // مقدار عددی enum
// ارسال تنظیمات کدشده از طریق پیامک
// ارسال تنظیمات از طریق پیامک الگویی
try
{
await smsService.SendWebserviceSmsAsync(new WebserviceSmsRequest
await smsService.SendPatternSmsAsync(new PatternSmsRequest
{
Recipient = request.DevicePhoneNumber,
Message = $"{encodedSettings}"
Recipients = new List<string> { request.DevicePhoneNumber },
PatternCode = "kx3kfqri7g09r02", // TODO: کد الگوی پیامک را اینجا قرار دهید
Variables = new Dictionary<string, string>
{
{ "deviceId", deviceId },
{ "uploadInterval", uploadInterval },
{ "smsInterval", smsInterval.ToString() },
{ "SysNumber", sysNumber.ToString() },
{ "SimType", simType }
}
}, cancellationToken);
}
catch (Exception smsEx)
@@ -234,7 +246,7 @@ public sealed class DeviceTokenService : IDeviceTokenService
{
Success = true,
Message = "تنظیمات با موفقیت ارسال شد",
EncodedSettings = encodedSettings
EncodedSettings = null
};
}
catch (Exception ex)