Fix vari
This commit is contained in:
@@ -41,9 +41,12 @@
|
|||||||
IconColor="Color.Primary" Color="Color.Surface" AlignItems="AlignItems.End"
|
IconColor="Color.Primary" Color="Color.Surface" AlignItems="AlignItems.End"
|
||||||
Size="Size.Medium" IconSize="Size.Medium">
|
Size="Size.Medium" IconSize="Size.Medium">
|
||||||
@if (SchedaVisible)
|
@if (SchedaVisible)
|
||||||
|
{
|
||||||
|
@if (!_isCompleted)
|
||||||
{
|
{
|
||||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||||
Label="Nuova scheda" Color="Color.Surface"/>
|
Label="Nuova scheda" Color="Color.Surface"/>
|
||||||
|
}
|
||||||
|
|
||||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@DeleteInspection"
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@DeleteInspection"
|
||||||
Label="Cancella ispezione" Color="Color.Surface"/>
|
Label="Cancella ispezione" Color="Color.Surface"/>
|
||||||
@@ -73,6 +76,7 @@
|
|||||||
private bool PlusVisible { get; set; } = true;
|
private bool PlusVisible { get; set; } = true;
|
||||||
private bool ShowCompleteInspection { get; set; }
|
private bool ShowCompleteInspection { get; set; }
|
||||||
private bool SchedaVisible { get; set; }
|
private bool SchedaVisible { get; set; }
|
||||||
|
private bool _isCompleted;
|
||||||
|
|
||||||
private ConfirmMessageBox _messageBox = null!;
|
private ConfirmMessageBox _messageBox = null!;
|
||||||
|
|
||||||
@@ -138,7 +142,11 @@
|
|||||||
var location = NavigationManager.Uri.Remove(0, NavigationManager.BaseUri.Length);
|
var location = NavigationManager.Uri.Remove(0, NavigationManager.BaseUri.Length);
|
||||||
|
|
||||||
SchedaVisible = new List<string> { "ispezione" }.Contains(location);
|
SchedaVisible = new List<string> { "ispezione" }.Contains(location);
|
||||||
ShowCompleteInspection = !SteupDataService.InspectionPageState.Ispezione.ActivityId.IsNullOrEmpty();
|
|
||||||
|
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||||
|
_isCompleted = ispezione.Stato == StatusEnum.Completata;
|
||||||
|
// Concludi non ha senso su un'ispezione gia completata
|
||||||
|
ShowCompleteInspection = !ispezione.ActivityId.IsNullOrEmpty() && !_isCompleted;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,9 @@
|
|||||||
PersonaRif = scheda.Responsabile,
|
PersonaRif = scheda.Responsabile,
|
||||||
Barcodes = scheda.Articoli.ConvertAll(x => x.Barcode),
|
Barcodes = scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||||
Scandeza = (ScadenzaEnum)scheda.Scadenza,
|
Scandeza = (ScadenzaEnum)scheda.Scadenza,
|
||||||
ParentActivityId = scheda.Ispezione?.ActivityId
|
// Aggancia all'ispezione esistente: dopo la prima scheda l'id e' noto,
|
||||||
|
// così le successive non creano nuove ispezioni.
|
||||||
|
ParentActivityId = ispezione.ActivityId
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -198,6 +200,8 @@
|
|||||||
ispezione.Rilevatore,
|
ispezione.Rilevatore,
|
||||||
apiResponse.ActivityIdIspezione
|
apiResponse.ActivityIdIspezione
|
||||||
);
|
);
|
||||||
|
// Aggiorna l'id in memoria per l'iterazione successiva.
|
||||||
|
ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
|
||||||
if (scheda.ImageNames == null) continue;
|
if (scheda.ImageNames == null) continue;
|
||||||
|
|
||||||
@@ -350,14 +354,19 @@
|
|||||||
PersonaRif = x.Responsabile,
|
PersonaRif = x.Responsabile,
|
||||||
Barcodes = x.Articoli.ConvertAll(y => y.Barcode),
|
Barcodes = x.Articoli.ConvertAll(y => y.Barcode),
|
||||||
Scandeza = (ScadenzaEnum)x.Scadenza,
|
Scandeza = (ScadenzaEnum)x.Scadenza,
|
||||||
ParentActivityId = x.Ispezione?.ActivityId
|
// Aggancia all'ispezione esistente sul server (evita di crearne una nuova a ogni export).
|
||||||
|
ParentActivityId = ispezione.ActivityId
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
var apiResponse = await IntegrySteupService.SaveMultipleSchede(saveRequest);
|
var apiResponse = await IntegrySteupService.SaveMultipleSchede(saveRequest);
|
||||||
|
|
||||||
if (apiResponse != null)
|
if (apiResponse == null)
|
||||||
{
|
{
|
||||||
|
Snackbar.Add("Esportazione non riuscita. Le schede restano sul dispositivo, riprova.", Severity.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
|
||||||
await IspezioniService.UpdateActivityIdIspezioneAsync(ispezione.CodMdep, ispezione.Data,
|
await IspezioniService.UpdateActivityIdIspezioneAsync(ispezione.CodMdep, ispezione.Data,
|
||||||
@@ -378,7 +387,8 @@
|
|||||||
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Snackbar.Add("Reparto esportato", Severity.Success);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,10 +6,12 @@
|
|||||||
@using SteUp.Shared.Core.Interface.IntegryApi
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||||
@using SteUp.Shared.Core.Interface.LocalDb
|
@using SteUp.Shared.Core.Interface.LocalDb
|
||||||
@using SteUp.Shared.Core.Interface.System
|
@using SteUp.Shared.Core.Interface.System
|
||||||
|
@using Microsoft.Extensions.Logging
|
||||||
@inject IIspezioniService IspezioniService
|
@inject IIspezioniService IspezioniService
|
||||||
@inject IIntegrySteupService IntegrySteupService
|
@inject IIntegrySteupService IntegrySteupService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
@inject IFileManager FileManager
|
@inject IFileManager FileManager
|
||||||
|
@inject ILogger<SchedaCard> Logger
|
||||||
|
|
||||||
<div class="scheda-card">
|
<div class="scheda-card">
|
||||||
<div class="scheda-body-section">
|
<div class="scheda-body-section">
|
||||||
@@ -139,12 +141,17 @@
|
|||||||
PersonaRif = Scheda.Responsabile,
|
PersonaRif = Scheda.Responsabile,
|
||||||
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||||
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
||||||
ParentActivityId = Scheda.Ispezione?.ActivityId
|
// Aggancia all'ispezione esistente sul server (evita di crearne una nuova a ogni invio).
|
||||||
|
ParentActivityId = SteupDataService.InspectionPageState.Ispezione.ActivityId
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (apiResponse != null)
|
if (apiResponse == null)
|
||||||
{
|
{
|
||||||
|
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
|
||||||
@@ -155,7 +162,13 @@
|
|||||||
|
|
||||||
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
|
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
|
||||||
await OnSchedaModified.InvokeAsync(Scheda);
|
await OnSchedaModified.InvokeAsync(Scheda);
|
||||||
|
|
||||||
|
Snackbar.Add("Scheda inviata", Severity.Success);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
|
||||||
|
Logger.LogError(e, e.Message);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -176,12 +189,23 @@
|
|||||||
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
|
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
|
||||||
.Where(x => x.ToUpload).ToList();
|
.Where(x => x.ToUpload).ToList();
|
||||||
|
|
||||||
if (fileList == null) return;
|
if (fileList == null || fileList.Count == 0)
|
||||||
|
{
|
||||||
|
Snackbar.Add("Nessuna nuova foto da inviare", Severity.Info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var file in fileList)
|
foreach (var file in fileList)
|
||||||
{
|
{
|
||||||
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
|
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Snackbar.Add(fileList.Count == 1 ? "Foto inviata" : $"{fileList.Count} foto inviate", Severity.Success);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Snackbar.Add("Invio foto non riuscito, riprova.", Severity.Error);
|
||||||
|
Logger.LogError(e, e.Message);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -296,7 +296,9 @@
|
|||||||
PersonaRif = Scheda.Responsabile,
|
PersonaRif = Scheda.Responsabile,
|
||||||
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||||
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
||||||
ParentActivityId = IsNew ? null : Scheda.Ispezione?.ActivityId
|
// Aggancia la scheda all'ispezione GIA esistente sul server (se sincronizzata),
|
||||||
|
// altrimenti null e il server la crea. Evita di creare una nuova ispezione a ogni salvataggio.
|
||||||
|
ParentActivityId = SteupDataService.InspectionPageState.Ispezione.ActivityId
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -353,6 +355,9 @@
|
|||||||
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
);
|
);
|
||||||
|
// Tiene in memoria l'ActivityId dell'ispezione: il prossimo salvataggio nella stessa
|
||||||
|
// sessione lo userà come ParentActivityId invece di creare una nuova ispezione.
|
||||||
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,9 +398,12 @@
|
|||||||
await IspezioniService.UpdateSchedaAsync(Scheda);
|
await IspezioniService.UpdateSchedaAsync(Scheda);
|
||||||
|
|
||||||
if (apiResponse != null)
|
if (apiResponse != null)
|
||||||
|
{
|
||||||
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
);
|
);
|
||||||
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UploadFile(Scheda scheda)
|
private async Task UploadFile(Scheda scheda)
|
||||||
|
|||||||
Reference in New Issue
Block a user