Fix vari
This commit is contained in:
@@ -42,8 +42,11 @@
|
||||
Size="Size.Medium" IconSize="Size.Medium">
|
||||
@if (SchedaVisible)
|
||||
{
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||
Label="Nuova scheda" Color="Color.Surface"/>
|
||||
@if (!_isCompleted)
|
||||
{
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||
Label="Nuova scheda" Color="Color.Surface"/>
|
||||
}
|
||||
|
||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@DeleteInspection"
|
||||
Label="Cancella ispezione" Color="Color.Surface"/>
|
||||
@@ -73,6 +76,7 @@
|
||||
private bool PlusVisible { get; set; } = true;
|
||||
private bool ShowCompleteInspection { get; set; }
|
||||
private bool SchedaVisible { get; set; }
|
||||
private bool _isCompleted;
|
||||
|
||||
private ConfirmMessageBox _messageBox = null!;
|
||||
|
||||
@@ -138,7 +142,11 @@
|
||||
var location = NavigationManager.Uri.Remove(0, NavigationManager.BaseUri.Length);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,9 @@
|
||||
PersonaRif = scheda.Responsabile,
|
||||
Barcodes = scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||
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,
|
||||
apiResponse.ActivityIdIspezione
|
||||
);
|
||||
// Aggiorna l'id in memoria per l'iterazione successiva.
|
||||
ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
|
||||
if (scheda.ImageNames == null) continue;
|
||||
|
||||
@@ -350,35 +354,41 @@
|
||||
PersonaRif = x.Responsabile,
|
||||
Barcodes = x.Articoli.ConvertAll(y => y.Barcode),
|
||||
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);
|
||||
|
||||
if (apiResponse != null)
|
||||
if (apiResponse == null)
|
||||
{
|
||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
Snackbar.Add("Esportazione non riuscita. Le schede restano sul dispositivo, riprova.", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(ispezione.CodMdep, ispezione.Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
|
||||
if (!apiResponse.ActivityIdSchedaList.IsNullOrEmpty())
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(ispezione.CodMdep, ispezione.Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
|
||||
if (!apiResponse.ActivityIdSchedaList.IsNullOrEmpty())
|
||||
{
|
||||
foreach (var scheda in SchedeGrouped[jtbFasi])
|
||||
{
|
||||
foreach (var scheda in SchedeGrouped[jtbFasi])
|
||||
{
|
||||
var activityId = apiResponse.ActivityIdSchedaList!.Find(x =>
|
||||
x.LocalId != null && x.LocalId == scheda.Id
|
||||
)?.ActivityId;
|
||||
var activityId = apiResponse.ActivityIdSchedaList!.Find(x =>
|
||||
x.LocalId != null && x.LocalId == scheda.Id
|
||||
)?.ActivityId;
|
||||
|
||||
if (activityId == null) continue;
|
||||
if (activityId == null) continue;
|
||||
|
||||
scheda.ActivityId = activityId;
|
||||
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||
}
|
||||
scheda.ActivityId = activityId;
|
||||
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||
}
|
||||
}
|
||||
|
||||
Snackbar.Add("Reparto esportato", Severity.Success);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||
@using SteUp.Shared.Core.Interface.LocalDb
|
||||
@using SteUp.Shared.Core.Interface.System
|
||||
@using Microsoft.Extensions.Logging
|
||||
@inject IIspezioniService IspezioniService
|
||||
@inject IIntegrySteupService IntegrySteupService
|
||||
@inject IDialogService Dialog
|
||||
@inject IFileManager FileManager
|
||||
@inject IFileManager FileManager
|
||||
@inject ILogger<SchedaCard> Logger
|
||||
|
||||
<div class="scheda-card">
|
||||
<div class="scheda-body-section">
|
||||
@@ -139,23 +141,34 @@
|
||||
PersonaRif = Scheda.Responsabile,
|
||||
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||
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)
|
||||
{
|
||||
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
||||
|
||||
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
|
||||
await OnSchedaModified.InvokeAsync(Scheda);
|
||||
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
||||
|
||||
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
|
||||
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
|
||||
{
|
||||
@@ -176,12 +189,23 @@
|
||||
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
|
||||
.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)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
||||
@@ -296,7 +296,9 @@
|
||||
PersonaRif = Scheda.Responsabile,
|
||||
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||
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,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -393,9 +398,12 @@
|
||||
await IspezioniService.UpdateSchedaAsync(Scheda);
|
||||
|
||||
if (apiResponse != null)
|
||||
{
|
||||
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||
);
|
||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UploadFile(Scheda scheda)
|
||||
|
||||
Reference in New Issue
Block a user