add test page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
|
||||
1
src/GreenHome.Api/My_StaticFiles/calltest.html
Normal file
1
src/GreenHome.Api/My_StaticFiles/calltest.html
Normal file
@@ -0,0 +1 @@
|
||||
TY09192530212#ghback.nabaksoft.ir/calltest.amr
|
||||
1
src/GreenHome.Api/My_StaticFiles/smsTest.html
Normal file
1
src/GreenHome.Api/My_StaticFiles/smsTest.html
Normal file
@@ -0,0 +1 @@
|
||||
TT09192530212#سلام خوبی
|
||||
@@ -5,6 +5,7 @@ using GreenHome.Infrastructure;
|
||||
using GreenHome.Sms.Ippanel;
|
||||
using GreenHome.VoiceCall.Avanak;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Scalar.AspNetCore;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -98,17 +99,21 @@ using (var scope = app.Services.CreateScope())
|
||||
// Configure the HTTP request pipeline.
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference();
|
||||
|
||||
// HTTPS Redirection فقط در Production
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseHttpsRedirection();
|
||||
}
|
||||
|
||||
app.UseCors(CorsPolicy);
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(
|
||||
Path.Combine(builder.Environment.ContentRootPath, "My_StaticFiles")),
|
||||
RequestPath = "/My_StaticFiles"
|
||||
});
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
@@ -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)
|
||||
|
||||
1977
src/Test/Untitled-1.cpp
Normal file
1977
src/Test/Untitled-1.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user