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>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<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.Sms.Ippanel;
|
||||||
using GreenHome.VoiceCall.Avanak;
|
using GreenHome.VoiceCall.Avanak;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.FileProviders;
|
||||||
using Scalar.AspNetCore;
|
using Scalar.AspNetCore;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -98,17 +99,21 @@ using (var scope = app.Services.CreateScope())
|
|||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
app.MapOpenApi();
|
app.MapOpenApi();
|
||||||
app.MapScalarApiReference();
|
app.MapScalarApiReference();
|
||||||
|
|
||||||
// HTTPS Redirection فقط در Production
|
|
||||||
if (!app.Environment.IsDevelopment())
|
if (!app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseCors(CorsPolicy);
|
app.UseCors(CorsPolicy);
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.UseStaticFiles(new StaticFileOptions
|
||||||
|
{
|
||||||
|
FileProvider = new PhysicalFileProvider(
|
||||||
|
Path.Combine(builder.Environment.ContentRootPath, "My_StaticFiles")),
|
||||||
|
RequestPath = "/My_StaticFiles"
|
||||||
|
});
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
@@ -112,13 +112,18 @@ public sealed class DeviceTokenService : IDeviceTokenService
|
|||||||
|
|
||||||
await dbContext.SaveChangesAsync(cancellationToken);
|
await dbContext.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
// ارسال کد توکن از طریق پیامک
|
// ارسال کد توکن از طریق پیامک الگویی
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await smsService.SendWebserviceSmsAsync(new WebserviceSmsRequest
|
await smsService.SendPatternSmsAsync(new PatternSmsRequest
|
||||||
{
|
{
|
||||||
Recipient = request.DevicePhoneNumber,
|
Recipients = new List<string> { request.DevicePhoneNumber },
|
||||||
Message = $"0911925302120#{tokenCode}"
|
PatternCode = "gfukab9r0nca0pt", // TODO: کد الگوی پیامک را اینجا قرار دهید
|
||||||
|
Variables = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "tel", "09192530212" },
|
||||||
|
{ "verifyCode", verificationCode }
|
||||||
|
}
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
catch (Exception smsEx)
|
catch (Exception smsEx)
|
||||||
@@ -194,21 +199,28 @@ public sealed class DeviceTokenService : IDeviceTokenService
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
// رمزگذاری ساده تنظیمات: DeviceName|UploadIntervalMin به Base64
|
// آمادهسازی پارامترها برای ارسال پیامک الگویی
|
||||||
var deviceId = settings.Device.Id;
|
var deviceId = settings.Device.Id + "01";
|
||||||
var uploadInterval = settings.UploadIntervalMin;
|
var uploadInterval = rnd.Next(1, 9) + "" + settings.UploadIntervalMin;
|
||||||
string smsConfig = (settings.MinimumSmsIntervalMinutes != 0 ? "1" : rnd.Next(2, 9).ToString())
|
var smsInterval = settings.MinimumSmsIntervalMinutes > 0 ? "1" + settings.MinimumSmsIntervalMinutes : "0" + rnd.Next(1, 9);
|
||||||
+ settings.MinimumSmsIntervalMinutes;
|
var sysNumber = rnd.Next(139, 97654); // عدد رندوم SysNumber
|
||||||
var plainText = $"{deviceId}01|{rnd.Next(1,9)}{uploadInterval}|{smsConfig}|{rnd.Next(139,97654)}|{rnd.Next(1,9)}{(int)settings.SimCardType}";
|
var simType = rnd.Next(1, 9).ToString() + ((int?)settings.SimCardType)?.ToString() ?? "1"; // مقدار عددی enum
|
||||||
var encodedSettings = plainText; //Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(plainText));
|
|
||||||
|
|
||||||
// ارسال تنظیمات کدشده از طریق پیامک
|
// ارسال تنظیمات از طریق پیامک الگویی
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await smsService.SendWebserviceSmsAsync(new WebserviceSmsRequest
|
await smsService.SendPatternSmsAsync(new PatternSmsRequest
|
||||||
{
|
{
|
||||||
Recipient = request.DevicePhoneNumber,
|
Recipients = new List<string> { request.DevicePhoneNumber },
|
||||||
Message = $"{encodedSettings}"
|
PatternCode = "kx3kfqri7g09r02", // TODO: کد الگوی پیامک را اینجا قرار دهید
|
||||||
|
Variables = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "deviceId", deviceId },
|
||||||
|
{ "uploadInterval", uploadInterval },
|
||||||
|
{ "smsInterval", smsInterval.ToString() },
|
||||||
|
{ "SysNumber", sysNumber.ToString() },
|
||||||
|
{ "SimType", simType }
|
||||||
|
}
|
||||||
}, cancellationToken);
|
}, cancellationToken);
|
||||||
}
|
}
|
||||||
catch (Exception smsEx)
|
catch (Exception smsEx)
|
||||||
@@ -234,7 +246,7 @@ public sealed class DeviceTokenService : IDeviceTokenService
|
|||||||
{
|
{
|
||||||
Success = true,
|
Success = true,
|
||||||
Message = "تنظیمات با موفقیت ارسال شد",
|
Message = "تنظیمات با موفقیت ارسال شد",
|
||||||
EncodedSettings = encodedSettings
|
EncodedSettings = null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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