Fix sync utenti
This commit is contained in:
@@ -127,6 +127,19 @@ public class ManageDataService(
|
||||
}
|
||||
);
|
||||
|
||||
if (lastSync == null)
|
||||
{
|
||||
await InsertDbUsers(new UsersSyncResponseDTO
|
||||
{
|
||||
AnagClie = clienti.AnagClie,
|
||||
VtbDest = clienti.VtbDest,
|
||||
VtbCliePersRif = clienti.VtbCliePersRif,
|
||||
PtbPros = prospect.PtbPros,
|
||||
PtbProsRif = prospect.PtbProsRif
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = UpdateDbUsers(new UsersSyncResponseDTO
|
||||
{
|
||||
AnagClie = clienti.AnagClie,
|
||||
@@ -135,6 +148,7 @@ public class ManageDataService(
|
||||
PtbPros = prospect.PtbPros,
|
||||
PtbProsRif = prospect.PtbProsRif
|
||||
});
|
||||
}
|
||||
|
||||
if (lastSync != null)
|
||||
{
|
||||
@@ -325,6 +339,24 @@ public class ManageDataService(
|
||||
return returnDto;
|
||||
}
|
||||
|
||||
private async Task InsertDbUsers(UsersSyncResponseDTO response)
|
||||
{
|
||||
if (response.AnagClie != null)
|
||||
{
|
||||
await localDb.InsertAll(response.AnagClie);
|
||||
|
||||
if (response.VtbDest != null) await localDb.InsertAll(response.VtbDest);
|
||||
if (response.VtbCliePersRif != null) await localDb.InsertAll(response.VtbCliePersRif);
|
||||
}
|
||||
|
||||
if (response.PtbPros != null)
|
||||
{
|
||||
await localDb.InsertAll(response.PtbPros);
|
||||
|
||||
if (response.PtbProsRif != null) await localDb.InsertAll(response.PtbProsRif);
|
||||
}
|
||||
}
|
||||
|
||||
private Task UpdateDbUsers(UsersSyncResponseDTO response)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Authorization.Enum
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Interface.System.Network
|
||||
@using salesbook.Shared.Core.Services
|
||||
@inject AppAuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject INetworkService NetworkService
|
||||
@inject IFormFactor FormFactor
|
||||
@inject UserListState UserState
|
||||
|
||||
<HeaderLayout BackTo="Indietro" Back="true" BackOnTop="true" Title="Profilo" ShowProfile="false"/>
|
||||
|
||||
@@ -155,18 +157,10 @@
|
||||
private void UpdateDb(bool withData = false)
|
||||
{
|
||||
LocalStorage.Remove("last-user-sync");
|
||||
UserState.IsLoaded = false;
|
||||
UserState.IsLoading = false;
|
||||
|
||||
var absoluteUri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
|
||||
var pathAndQuery = absoluteUri.Segments.Length > 1 ? absoluteUri.PathAndQuery : null;
|
||||
|
||||
string path;
|
||||
|
||||
if (withData)
|
||||
path = pathAndQuery == null ? $"/sync/{DateTime.Today:yyyy-MM-dd}" : $"/sync/{DateTime.Today:yyyy-MM-dd}?path=" + System.Web.HttpUtility.UrlEncode(pathAndQuery);
|
||||
else
|
||||
path = pathAndQuery == null ? "/sync" : "/sync?path=" + System.Web.HttpUtility.UrlEncode(pathAndQuery);
|
||||
|
||||
NavigationManager.NavigateTo(path, replace: true);
|
||||
NavigationManager.NavigateTo(withData ? $"/sync/{DateTime.Today:yyyy-MM-dd}" : "/sync", replace: true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,8 +3,10 @@
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Services
|
||||
@inject ISyncDbService SyncDb
|
||||
@inject IManageDataService ManageData
|
||||
@inject PreloadService PreloadService
|
||||
|
||||
<SyncSpinner Elements="@Elements"/>
|
||||
|
||||
@@ -55,6 +57,11 @@
|
||||
var originalPath = pathQuery["path"] ?? null;
|
||||
var path = originalPath ?? "/Calendar";
|
||||
|
||||
if (path.Equals("/Calendar") && DateFilter is null)
|
||||
{
|
||||
_ = Task.Run(() => { _ = PreloadService.PreloadUsersAsync(); });
|
||||
}
|
||||
|
||||
NavigationManager.NavigateTo(path, replace: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
OnSave="() => OpenUserForm(Anag)"
|
||||
Back="true"
|
||||
BackOnTop="true"
|
||||
Title=""
|
||||
Title="@Anag.CodContact"
|
||||
ShowProfile="false"/>
|
||||
|
||||
@if (IsLoading)
|
||||
@@ -111,7 +111,7 @@ else
|
||||
<label class="tab-trigger" for="tab2" @onclick="() => SwitchTab(1)">Commesse</label>
|
||||
</li>
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab3" @onclick="() => SwitchTab(2)">Attivit<EFBFBD></label>
|
||||
<label class="tab-trigger" for="tab3" @onclick="() => SwitchTab(2)">Attività</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -219,7 +219,7 @@ else
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Tab Attivit<EFBFBD> -->
|
||||
<!-- Tab Attività -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 2 ? "block" : "none")">
|
||||
@if (ActivityIsLoading)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ else
|
||||
}
|
||||
else if (ActivityList?.Count == 0)
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna attivit<EFBFBD> presente"/>
|
||||
<NoDataAvailable Text="Nessuna attività presente"/>
|
||||
}
|
||||
else if (ActivityList != null)
|
||||
{
|
||||
@@ -309,7 +309,7 @@ else
|
||||
private string _searchTermCommesse = string.Empty;
|
||||
private List<JtbComt> _filteredCommesse = [];
|
||||
|
||||
// Paginazione e filtri per ATTIVIT<EFBFBD>
|
||||
// Paginazione e filtri per attività
|
||||
private int _currentPageActivity = 1;
|
||||
private int _selectedPageSizeActivity = 5;
|
||||
private string _searchTermActivity = string.Empty;
|
||||
@@ -381,7 +381,7 @@ else
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties per Attivit<EFBFBD>
|
||||
#region Properties per Attività
|
||||
|
||||
private int CurrentPageActivityIndex
|
||||
{
|
||||
@@ -445,7 +445,7 @@ else
|
||||
{
|
||||
_loadingCts = new CancellationTokenSource();
|
||||
|
||||
if (UserState.CodUser?.Equals(CodContact) == true)
|
||||
if (UserState.CodUser != null && UserState.CodUser.Equals(CodContact))
|
||||
{
|
||||
LoadDataFromSession();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user