bozza message service broadcast
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
|
||||
public static readonly string ACT_MSE_DATA_KEY = $"{BASE_HASH}:Current:MSE";
|
||||
|
||||
public static readonly string BROADCAST_M_PIPE = $"BroadCastMsg";
|
||||
public static readonly string BROADCAST_CURR_KEY = $"{BASE_HASH}:Current:BroadCast";
|
||||
|
||||
// dati conf REDIS Cache
|
||||
public static readonly string BASE_HASH = "MAPO";
|
||||
|
||||
|
||||
+35
-2
@@ -1,6 +1,8 @@
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MP.Data
|
||||
{
|
||||
@@ -27,9 +29,39 @@ namespace MP.Data
|
||||
#endregion Public Events
|
||||
|
||||
#region Public Methods
|
||||
|
||||
private Dictionary<string, int> numSent = new Dictionary<string, int>();
|
||||
public bool saveAndSendMessage(string memKey, string message)
|
||||
{
|
||||
bool answ = false;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
|
||||
// invio notifica tramite il canale richiesto
|
||||
answ = sendMessage(message);
|
||||
if (redisDb != null)
|
||||
{
|
||||
redisDb.StringSetAsync(memKey, message);
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
if (numSent.ContainsKey(memKey))
|
||||
{
|
||||
numSent[memKey]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
numSent.Add(memKey, 1);
|
||||
}
|
||||
if (enableLog || numSent[memKey] > 30)
|
||||
{
|
||||
Log.Info($"saveAndSendMessage| mKey {memKey} x {numSent[memKey]} | {message.Length} size | {ts.TotalMilliseconds} ms");
|
||||
|
||||
numSent[memKey] = 0;
|
||||
}
|
||||
return answ;
|
||||
|
||||
#if false
|
||||
|
||||
bool answ = false;
|
||||
// invio notifica tramite il canale richiesto
|
||||
answ = sendMessage(message);
|
||||
@@ -41,7 +73,8 @@ namespace MP.Data
|
||||
Log.Info($"Redis Cache Key: {memKey}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
return answ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace MP.SPEC.Components
|
||||
[Inject]
|
||||
protected MpDataService MDService { get; set; } = null!;
|
||||
|
||||
protected bool ShowSearch { get => MService.ShowSearch; set => MService.ShowSearch = value; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
@@ -36,7 +35,6 @@ namespace MP.SPEC.Components
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MService.EA_ShowSearch += MService_EA_ShowSearch;
|
||||
await forceReload();
|
||||
}
|
||||
|
||||
@@ -53,7 +51,6 @@ namespace MP.SPEC.Components
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
private string TipoSearch { get => MService.TipoSearch; set => MService.TipoSearch = value; }
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@using MP.SPEC.Components
|
||||
@*@using MP.SPEC.Components
|
||||
@using MP.SPEC.Data
|
||||
|
||||
@inject MessageService AppMService
|
||||
@@ -52,4 +52,4 @@
|
||||
searchVal = "";
|
||||
}
|
||||
|
||||
}
|
||||
}*@
|
||||
+10
-127
@@ -4,121 +4,20 @@
|
||||
{
|
||||
#region Public Events
|
||||
|
||||
public event Action EA_PageUpdated = null!;
|
||||
|
||||
public event Action EA_SearchUpdated = null!;
|
||||
|
||||
public event Action EA_ShowSearch = null!;
|
||||
|
||||
public event Action EA_StatoSearch = null!;
|
||||
public event Action EA_BroadCastMsg = null!;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public int currPage
|
||||
public string newBCMsg
|
||||
{
|
||||
get => _currPage;
|
||||
get => _newBCMsg;
|
||||
set
|
||||
{
|
||||
if (_currPage != value)
|
||||
if(_newBCMsg != value)
|
||||
{
|
||||
_currPage = value;
|
||||
if (EA_PageUpdated != null)
|
||||
{
|
||||
EA_PageUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int numRecord
|
||||
{
|
||||
get => _numRecord;
|
||||
set
|
||||
{
|
||||
if (_numRecord != value)
|
||||
{
|
||||
_numRecord = value;
|
||||
if (EA_PageUpdated != null)
|
||||
{
|
||||
EA_PageUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string SearchVal
|
||||
{
|
||||
get => searchVal;
|
||||
set
|
||||
{
|
||||
//if (searchVal != value)
|
||||
//{
|
||||
searchVal = value;
|
||||
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSearch
|
||||
{
|
||||
get => showSearch;
|
||||
set
|
||||
{
|
||||
if (showSearch != value)
|
||||
{
|
||||
showSearch = value;
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string StateSel
|
||||
{
|
||||
get => stateSel;
|
||||
set
|
||||
{
|
||||
stateSel = value;
|
||||
|
||||
if (EA_StatoSearch != null)
|
||||
{
|
||||
EA_StatoSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TipoSearch
|
||||
{
|
||||
get => tipoSearch;
|
||||
set
|
||||
{
|
||||
if (tipoSearch != value)
|
||||
{
|
||||
tipoSearch = value;
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int totalCount
|
||||
{
|
||||
get => _totalCount;
|
||||
set
|
||||
{
|
||||
if (_totalCount != value)
|
||||
{
|
||||
_totalCount = value;
|
||||
_newBCMsg = value;
|
||||
reportMsg();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,19 +26,11 @@
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void reportPaging()
|
||||
protected void reportMsg()
|
||||
{
|
||||
if (EA_PageUpdated != null)
|
||||
if (EA_BroadCastMsg != null)
|
||||
{
|
||||
EA_PageUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
protected void reportSearch()
|
||||
{
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
EA_BroadCastMsg?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,19 +38,11 @@
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private string searchVal = "";
|
||||
private bool showSearch;
|
||||
private string stateSel = "*";
|
||||
private string tipoSearch = "";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int _currPage { get; set; } = 1;
|
||||
|
||||
private int _numRecord { get; set; } = 10;
|
||||
private int _totalCount { get; set; } = 0;
|
||||
private string _newBCMsg { get; set; } = "";
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace MP.SPEC.Data
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
BroadastMsgPipe = new MessagePipe(redisConn, Constants.BROADCAST_M_PIPE);
|
||||
// leggo cache lungo periodo
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
|
||||
|
||||
@@ -1372,12 +1372,13 @@ namespace MP.SPEC.Data
|
||||
private const string redisPOdlByOdl = redisXdlData + ":POdlByOdl";
|
||||
private const string redisPOdlByPOdl = redisXdlData + ":POdlByPOdl";
|
||||
private const string redisPOdlList = redisXdlData + ":POdlList";
|
||||
private const string redisPOdlListNOOdl = redisXdlData + ":POdlListNOOdl";
|
||||
private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom";
|
||||
private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt";
|
||||
private const string redisVocabolario = redisBaseAddr + "SPEC:Cache:Vocabolario";
|
||||
private const string redisXdlData = redisBaseAddr + "SPEC:Cache:XDL";
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
public MessagePipe BroadastMsgPipe { get; set; } = null!;
|
||||
|
||||
private static ILogger<MpDataService> _logger = null!;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>6.16.2212.115</Version>
|
||||
<Version>6.16.2212.216</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace MP.SPEC.Pages
|
||||
{
|
||||
Titolo = "MP SPEC";
|
||||
Messaggio = "I nostri contattatti e siti di supporto";
|
||||
AppMService.ShowSearch = false;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace MP.SPEC.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// nascondo ricerca
|
||||
MessageService.ShowSearch = false;
|
||||
// recupero elenco JQM
|
||||
ElencoLink = await MDService.ElencoLink();
|
||||
#if false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@page "/Test"
|
||||
|
||||
<h3>Test</h3>
|
||||
|
||||
@*
|
||||
<button class="btn btn-primary" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasExample" aria-controls="offcanvasExample">
|
||||
Button with data-bs-target
|
||||
</button>
|
||||
@@ -25,8 +25,8 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
|
||||
<span class="badge bg-primary">@messaggio</span>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.SPEC;
|
||||
using MP.SPEC.Shared;
|
||||
using MP.SPEC.Components;
|
||||
using MP.Data;
|
||||
using Newtonsoft.Json;
|
||||
using MP.SPEC.Data;
|
||||
|
||||
namespace MP.SPEC.Pages
|
||||
{
|
||||
public partial class Test : IDisposable
|
||||
{
|
||||
[Inject]
|
||||
protected MpDataService MMDataService { get; set; } = null!;
|
||||
|
||||
protected string messaggio = "0";
|
||||
protected DateTime lastRec = DateTime.Now.AddMinutes(-1);
|
||||
private void BroadCastMsg_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (lastRec.AddSeconds(2) < adesso)
|
||||
{
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
{
|
||||
lastRec = adesso;
|
||||
try
|
||||
{
|
||||
var result = JsonConvert.DeserializeObject<string>(currArgs.newMessage);
|
||||
if(result != null)
|
||||
{
|
||||
messaggio = result;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
MMDataService.BroadastMsgPipe.EA_NewMessage += BroadCastMsg_EA_NewMessage;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
MMDataService.BroadastMsgPipe.EA_NewMessage += BroadCastMsg_EA_NewMessage;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
@page "/TestBtn"
|
||||
<h3>TestBtn</h3>
|
||||
|
||||
|
||||
<button class="btn btn-sm" @onclick="()=>addOne()">AGGIUNGI</button>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.SPEC;
|
||||
using MP.SPEC.Shared;
|
||||
using MP.SPEC.Components;
|
||||
using MP.SPEC.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace MP.SPEC.Pages
|
||||
{
|
||||
public partial class TestBtn
|
||||
{
|
||||
[Inject]
|
||||
protected MessageService MService { get; set; } = null!;
|
||||
|
||||
public EventCallback<string> newBcMsg { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
MService.EA_BroadCastMsg += OnNewBCMsg;
|
||||
}
|
||||
|
||||
public async void OnNewBCMsg()
|
||||
{
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
protected async Task addOne()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
sb.Append("1");
|
||||
countMsg = sb.ToString();
|
||||
}
|
||||
|
||||
public string countMsg
|
||||
{
|
||||
get
|
||||
{
|
||||
return MService.newBCMsg;
|
||||
}
|
||||
set
|
||||
{
|
||||
MService.newBCMsg = value;
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
newBcMsg.InvokeAsync(countMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2212.115</h4>
|
||||
<h4>Versione: 6.16.2212.216</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2212.115
|
||||
6.16.2212.216
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2212.115</version>
|
||||
<version>6.16.2212.216</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user