generated from Integry/Template_NetMauiBlazorHybrid
Filtrati tipi attività per utente
This commit is contained in:
@@ -22,6 +22,7 @@ public class LocalDbService
|
||||
_connection.CreateTableAsync<VtbDest>();
|
||||
_connection.CreateTableAsync<StbActivityResult>();
|
||||
_connection.CreateTableAsync<StbActivityType>();
|
||||
_connection.CreateTableAsync<SrlActivityTypeUser>();
|
||||
_connection.CreateTableAsync<StbUser>();
|
||||
_connection.CreateTableAsync<VtbTipi>();
|
||||
_connection.CreateTableAsync<Nazioni>();
|
||||
@@ -33,12 +34,14 @@ public class LocalDbService
|
||||
{
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS stb_activity_result;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS stb_activity_type;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS srl_activity_type_user;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS stb_user;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS vtb_tipi;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS nazioni;");
|
||||
|
||||
await _connection.CreateTableAsync<StbActivityResult>();
|
||||
await _connection.CreateTableAsync<StbActivityType>();
|
||||
await _connection.CreateTableAsync<SrlActivityTypeUser>();
|
||||
await _connection.CreateTableAsync<StbUser>();
|
||||
await _connection.CreateTableAsync<VtbTipi>();
|
||||
await _connection.CreateTableAsync<Nazioni>();
|
||||
|
||||
@@ -29,6 +29,9 @@ public class SyncDbService(IIntegryApiService integryApiService, LocalDbService
|
||||
if (!settingsResponse.ActivityTypes.IsNullOrEmpty())
|
||||
await localDb.InsertAll(settingsResponse.ActivityTypes!);
|
||||
|
||||
if (!settingsResponse.ActivityTypeUsers.IsNullOrEmpty())
|
||||
await localDb.InsertAll(settingsResponse.ActivityTypeUsers!);
|
||||
|
||||
if (!settingsResponse.StbUsers.IsNullOrEmpty())
|
||||
await localDb.InsertAll(settingsResponse.StbUsers!);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
private bool _showWarning;
|
||||
|
||||
private DateTime _lastApiCheck = DateTime.MinValue;
|
||||
private int _delaySeconds = 3;
|
||||
private const int DelaySeconds = 60;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
var isNetworkAvailable = NetworkService.IsNetworkAvailable();
|
||||
var servicesDown = ServicesIsDown;
|
||||
|
||||
if (isNetworkAvailable && (DateTime.UtcNow - _lastApiCheck).TotalSeconds >= _delaySeconds)
|
||||
if (isNetworkAvailable && (DateTime.UtcNow - _lastApiCheck).TotalSeconds >= DelaySeconds)
|
||||
{
|
||||
servicesDown = !await IntegryApiService.SystemOk();
|
||||
_lastApiCheck = DateTime.UtcNow;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Elements["Commesse"] = false;
|
||||
Elements["Impostazioni"] = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@
|
||||
private ActivityDTO ActivityModel { get; set; } = new();
|
||||
|
||||
private List<StbActivityResult> ActivityResult { get; set; } = [];
|
||||
private List<StbActivityType> ActivityType { get; set; } = [];
|
||||
private List<SrlActivityTypeUser> ActivityType { get; set; } = [];
|
||||
private List<StbUser> Users { get; set; } = [];
|
||||
private List<JtbComt> Commesse { get; set; } = [];
|
||||
private List<AnagClie> Clienti { get; set; } = [];
|
||||
@@ -297,6 +297,8 @@
|
||||
ActivityModel.UserName = UserSession.User.Username;
|
||||
}
|
||||
|
||||
await LoadActivityType();
|
||||
|
||||
OriginalModel = ActivityModel.Clone();
|
||||
}
|
||||
|
||||
@@ -383,7 +385,15 @@
|
||||
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
||||
Clienti = await ManageData.GetClienti(new WhereCondContact {FlagStato = "A"});
|
||||
Pros = await ManageData.GetProspect();
|
||||
ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A"));
|
||||
}
|
||||
|
||||
private async Task LoadActivityType()
|
||||
{
|
||||
if (ActivityModel.UserName is null) ActivityType = [];
|
||||
|
||||
ActivityType = await ManageData.GetTable<SrlActivityTypeUser>(x =>
|
||||
x.UserName != null && x.UserName.Equals(ActivityModel.UserName)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task LoadCommesse() =>
|
||||
@@ -430,6 +440,12 @@
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private async Task OnUserChanged()
|
||||
{
|
||||
await LoadActivityType();
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private void OnAfterChangeValue()
|
||||
{
|
||||
if (!IsNew)
|
||||
|
||||
@@ -8,6 +8,9 @@ public class SettingsResponseDTO
|
||||
[JsonPropertyName("activityTypes")]
|
||||
public List<StbActivityType>? ActivityTypes { get; set; }
|
||||
|
||||
[JsonPropertyName("activityTypeUsers")]
|
||||
public List<SrlActivityTypeUser>? ActivityTypeUsers { get; set; }
|
||||
|
||||
[JsonPropertyName("activityResults")]
|
||||
public List<StbActivityResult>? ActivityResults { get; set; }
|
||||
|
||||
|
||||
56
salesbook.Shared/Core/Entity/SrlActivityTypeUser.cs
Normal file
56
salesbook.Shared/Core/Entity/SrlActivityTypeUser.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using SQLite;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Entity;
|
||||
|
||||
[Table("srl_activity_type_user")]
|
||||
public class SrlActivityTypeUser
|
||||
{
|
||||
[PrimaryKey, Column("composite_key")]
|
||||
public string CompositeKey { get; set; }
|
||||
|
||||
private string? _activityTypeId;
|
||||
|
||||
[Column("activity_type_id"), JsonPropertyName("activityTypeId"), Indexed(Name = "ActivityTypePK", Order = 1, Unique = true)]
|
||||
public string? ActivityTypeId
|
||||
{
|
||||
get => _activityTypeId;
|
||||
set
|
||||
{
|
||||
_activityTypeId = value;
|
||||
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
|
||||
UpdateCompositeKey();
|
||||
}
|
||||
}
|
||||
|
||||
private string? _flagTipologia;
|
||||
|
||||
[Column("flag_tipologia"), JsonPropertyName("flagTipologia"), Indexed(Name = "ActivityTypePK", Order = 2, Unique = true)]
|
||||
public string? FlagTipologia
|
||||
{
|
||||
get => _flagTipologia;
|
||||
set
|
||||
{
|
||||
_flagTipologia = value;
|
||||
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
|
||||
UpdateCompositeKey();
|
||||
}
|
||||
}
|
||||
|
||||
private string? _userName;
|
||||
|
||||
[Column("user_name"), JsonPropertyName("userName"), Indexed(Name = "ActivityTypePK", Order = 3, Unique = true)]
|
||||
public string? UserName
|
||||
{
|
||||
get => _userName;
|
||||
set
|
||||
{
|
||||
_userName = value;
|
||||
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
|
||||
UpdateCompositeKey();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCompositeKey() =>
|
||||
CompositeKey = $"{ActivityTypeId}::{FlagTipologia}::{UserName}";
|
||||
}
|
||||
Reference in New Issue
Block a user