ancora scrittura redis
This commit is contained in:
@@ -16,6 +16,8 @@ namespace SMGen.Core
|
||||
public static readonly string BASE_HASH = "SMGEN";
|
||||
public static readonly string BASE_PATH = Directory.GetCurrentDirectory();
|
||||
|
||||
public static readonly string FILES_TO_PROC = $"{BASE_HASH}:Files:Pending";
|
||||
|
||||
public const string redisBaseAddr = "SMGEN";
|
||||
public const string rKeyFiles = $"{redisBaseAddr}:Files";
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace SMGen.Core
|
||||
namespace SMGen
|
||||
{
|
||||
public class Enum
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using SMGen.Data.Data;
|
||||
using SMGen.Data.DbModels;
|
||||
|
||||
namespace SMGen.Data.Controllers
|
||||
@@ -115,5 +116,7 @@ namespace SMGen.Data.Controllers
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SMGen.Data.Data
|
||||
{
|
||||
public class FilesClass
|
||||
{
|
||||
public string origFileName { get; set; } = "";
|
||||
public string DLoadFileName { get; set; } = "";
|
||||
public bool isOk { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -33,4 +33,8 @@
|
||||
<Folder Include="SqlScripts\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SMGen.Core\SMGen.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -4,12 +4,13 @@ using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
using SMGen.Core;
|
||||
using SMGen.UI;
|
||||
using SMGen;
|
||||
using SMGen.Data.Controllers;
|
||||
using SMGen.Data.DbModels;
|
||||
using StackExchange.Redis;
|
||||
using System.Diagnostics;
|
||||
using SMGen.UI.Data;
|
||||
using SMGen.Data;
|
||||
using SMGen.Data.Data;
|
||||
|
||||
namespace SMGen.Data.Services
|
||||
{
|
||||
@@ -87,10 +88,12 @@ namespace SMGen.Data.Services
|
||||
var dbResult = await dbController.AnagEventinInsert(newEvList);
|
||||
return dbResult;
|
||||
}
|
||||
public async Task<bool> FilesLoadRedis(List<FilesClass> filesList)
|
||||
|
||||
public async Task<bool> FilesLoadRedis(Dictionary<string, bool> filesDict)
|
||||
{
|
||||
bool fatto = false;
|
||||
string currKey = $"{Constants.rKeyFiles}";
|
||||
string currKey = $"{Constants.FILES_TO_PROC}";
|
||||
#if false
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string? rawData = await redisDb.StringGetAsync(currKey);
|
||||
@@ -101,11 +104,37 @@ namespace SMGen.Data.Services
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"FilesLoad | REDIS in: {ts.TotalMilliseconds} ms");
|
||||
Log.Debug($"FilesLoad | REDIS in: {ts.TotalMilliseconds} ms");
|
||||
#endif
|
||||
foreach (var item in filesDict)
|
||||
{
|
||||
await RedHashUpsert(currKey, item.Key, item.Value);
|
||||
}
|
||||
|
||||
fatto = true;
|
||||
|
||||
return fatto;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Effettua upsert in HasList redis
|
||||
/// </summary>
|
||||
/// <param name="currKey">Chiave redis della Hashlist</param>
|
||||
/// <param name="chiave">Chiave nella HashList</param>
|
||||
/// <param name="valore">Valore da salvare</param>
|
||||
/// <returns>Num record nella HashList</returns>
|
||||
protected async Task<long> RedHashUpsert(RedisKey currKey, string chiave, bool valore)
|
||||
{
|
||||
long numReq = 0;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
await redisDb.HashSetAsync(currKey, chiave, valore);
|
||||
numReq = await redisDb.HashLengthAsync(currKey);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"RedHashUpsert | {currKey} | in: {ts.TotalMilliseconds} ms");
|
||||
return numReq;
|
||||
}
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,7 +5,9 @@ VisualStudioVersion = 17.6.33815.320
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMGen", "SMGen\SMGen.csproj", "{1224887B-2A4F-433C-ADB6-51683E2ADBA7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMGen.Data", "SMGen.Data\SMGen.Data.csproj", "{CF2D0A2F-DED0-4D5D-8C31-099B3C3ED16D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SMGen.Data", "SMGen.Data\SMGen.Data.csproj", "{CF2D0A2F-DED0-4D5D-8C31-099B3C3ED16D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMGen.Core", "SMGen.Core\SMGen.Core.csproj", "{43E583E7-B94B-4FC6-8473-4AC6A93F76B9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{CF2D0A2F-DED0-4D5D-8C31-099B3C3ED16D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CF2D0A2F-DED0-4D5D-8C31-099B3C3ED16D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CF2D0A2F-DED0-4D5D-8C31-099B3C3ED16D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{43E583E7-B94B-4FC6-8473-4AC6A93F76B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{43E583E7-B94B-4FC6-8473-4AC6A93F76B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{43E583E7-B94B-4FC6-8473-4AC6A93F76B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43E583E7-B94B-4FC6-8473-4AC6A93F76B9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -405,6 +405,11 @@ namespace SMGen.Pages
|
||||
{
|
||||
Log.Error($"Generato errore durante caricamento file: {Environment.NewLine}{ex}");
|
||||
}
|
||||
|
||||
if(filesStatus != null && filesStatus.Count > 0)
|
||||
{
|
||||
await SMGDService.FilesLoadRedis(filesStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void ForceReload(int newNum)
|
||||
|
||||
@@ -6,8 +6,17 @@ using SMGen.Data;
|
||||
using SMGen.Data.Controllers;
|
||||
using SMGen.Data.Services;
|
||||
using Microsoft.AspNetCore.Authentication.Negotiate;
|
||||
using StackExchange.Redis;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
ConfigurationManager configuration = builder.Configuration;
|
||||
|
||||
// REDIS setup
|
||||
string connStringRedis = configuration.GetConnectionString("Redis");
|
||||
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
||||
// avvio oggetto shared x redis...
|
||||
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
// Add services to the container.
|
||||
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
|
||||
.AddNegotiate();
|
||||
@@ -21,6 +30,7 @@ builder.Services.AddAuthorization(options =>
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddSingleton<SMGDataService>();
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SMGen.Core\SMGen.Core.csproj" />
|
||||
<ProjectReference Include="..\SMGen.Data\SMGen.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -12,3 +12,5 @@
|
||||
@using EgwCoreLib.Razor
|
||||
@using EgwCoreLib.Razor.Data
|
||||
@using SMGen.Data
|
||||
@using SMGen.Core
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
}
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Redis": "nkcredis.steamware.net:6379, DefaultDatabase=11, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false, password=BtN9Py1wtLfLRvmzWnOPJ7RytDM+CLiVsJ/16zduNTlV8IOPGNrtzJSXPUnImA5PqmUMhKaUqo9NdHIG",
|
||||
"Redis": "localhost:6379, DefaultDatabase=13, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false, password=BtN9Py1wtLfLRvmzWnOPJ7RytDM+CLiVsJ/16zduNTlV8IOPGNrtzJSXPUnImA5PqmUMhKaUqo9NdHIG",
|
||||
"SMGen.DB": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=SMGen.UI;"
|
||||
},
|
||||
"ServerConf": {
|
||||
|
||||
Reference in New Issue
Block a user