Merge branch 'master' into fit/master/Hassanzadeh

This commit is contained in:
mohammad.mahdi
2025-09-05 15:51:33 +03:30
9 changed files with 67 additions and 79 deletions
+9
View File
@@ -0,0 +1,9 @@
syntax="proto3";
option csharp_namespace="VizhTalk.Grpc.CDN";
package greet;
message UploadFileCommand{
bytes file = 1;
}
+13
View File
@@ -0,0 +1,13 @@
syntax="proto3";
option csharp_namespace="VizhTalk.Grpc.CDN";
package greet;
message Id{
string value = 1;
}
message UploadFileDTO{
Id id = 1;
}
+12
View File
@@ -0,0 +1,12 @@
syntax="proto3";
option csharp_namespace="VizhTalk.Grpc.CDN";
package greet;
import "DTOs.proto";
import "Commands.proto";
service CDNGrpc{
rpc UploadFile (UploadFileCommand) returns (UploadFileDTO);
}
+11 -2
View File
@@ -5,5 +5,14 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
</Project> <PackageReference Include="Google.Protobuf" Version="3.32.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.58.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Services.proto" GrpcServices="Both" />
<Protobuf Include="DTOs.proto" GrpcServices="Both" />
<Protobuf Include="Commands.proto" GrpcServices="Both" />
</ItemGroup>
</Project>
@@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VizhTalk.Grpc.Learning.Helpers
{
internal class CompressionHelper
{
public static byte[] Compress(byte[] data)
{
using var output = new MemoryStream();
using (var gzip = new GZipStream(output, CompressionMode.Compress))
{
gzip.Write(data, 0, data.Length);
}
return output.ToArray();
}
public static byte[] Decompress(byte[] compressedData)
{
using var input = new MemoryStream(compressedData);
using var gzip = new GZipStream(input, CompressionMode.Decompress);
using var output = new MemoryStream();
gzip.CopyTo(output);
return output.ToArray();
}
}
}
@@ -1,45 +0,0 @@
using System.Security.Cryptography;
using System.Text;
namespace VizhTalk.Grpc.Learning.Helpers
{
internal class EncryptionHelper
{
private const string Alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
public static string Encrypt(string input)
{
byte[] bytes = Encoding.UTF8.GetBytes(input);
// تبدیل بایت‌ها به عدد بزرگ
var number = new System.Numerics.BigInteger(bytes);
// اگر منفی شد، مثبتش کن
if (number < 0) number = -number;
// تبدیل به Base62
StringBuilder result = new StringBuilder();
while (number > 0)
{
result.Insert(0, Alphabet[(int)(number % 62)]);
number /= 62;
}
return result.ToString();
}
public static string Decrypt(string encoded)
{
System.Numerics.BigInteger number = 0;
foreach (char c in encoded)
{
number = number * 62 + Alphabet.IndexOf(c);
}
// تبدیل دوباره به بایت
byte[] bytes = number.ToByteArray();
// رشته اصلی
return Encoding.UTF8.GetString(bytes);
}
}
}
+7
View File
@@ -1,6 +1,13 @@
using Vizhtalk.CDN.Presentation.Services;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
var app = builder.Build(); var app = builder.Build();
app.MapGet("/", () => "Hello World!"); app.MapGet("/", () => "Hello World!");
app.MapGrpcService<CDNService>();
app.Run(); app.Run();
@@ -0,0 +1,12 @@
using Grpc.Core;
using VizhTalk.Grpc.CDN;
namespace Vizhtalk.CDN.Presentation.Services;
public class CDNService : CDNGrpc.CDNGrpcBase
{
public override Task<UploadFileDTO> UploadFile(UploadFileCommand request, ServerCallContext context)
{
return base.UploadFile(request, context);
}
}
@@ -7,7 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\VizhTalk.BuildingBlocks.Infrastructure\VizhTalk.BuildingBlocks.Infrastructure.csproj" /> <PackageReference Include="Grpc.AspNetCore" Version="2.57.0" />
<ProjectReference Include="..\VizhTalk.BuildingBlocks.Infrastructure\VizhTalk.BuildingBlocks.Infrastructure.csproj" />
<ProjectReference Include="..\VizhTalk.Grpc.CDN\VizhTalk.Grpc.CDN.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>