diff --git a/SteUp.Shared/Components/Pages/IspezionePage.razor b/SteUp.Shared/Components/Pages/IspezionePage.razor
index ab72537..9df680e 100644
--- a/SteUp.Shared/Components/Pages/IspezionePage.razor
+++ b/SteUp.Shared/Components/Pages/IspezionePage.razor
@@ -7,6 +7,7 @@
@using SteUp.Shared.Core.Enum
@using SteUp.Shared.Core.Interface.IntegryApi
@using SteUp.Shared.Core.Interface.LocalDb
+@using SteUp.Shared.Core.Interface.System
@using SteUp.Shared.Core.Messages.Ispezione
@using SteUp.Shared.Core.Messages.Scheda
@inject NewSchedaService NewScheda
@@ -14,6 +15,7 @@
@inject IIspezioniService IspezioniService
@inject IDialogService Dialog
@inject IIntegrySteupService IntegrySteupService
+@inject IAttachedService AttachedService
@implements IDisposable
@@ -64,9 +66,7 @@
{
+ Ispezione="@SteupDataService.InspectionPageState.Ispezione"/>
}
@@ -118,6 +118,49 @@
var ispezione = SteupDataService.InspectionPageState.Ispezione;
+ foreach (var scheda in ispezione.Schede.Where(x => x.ActivityId == null))
+ {
+ var apiResponse = await IntegrySteupService.SaveScheda(
+ new SaveRequestDto
+ {
+ LocalIdScheda = scheda.Id,
+ ActivityTypeId = scheda.ActivityTypeId,
+ CodJfas = scheda.CodJfas,
+ CodMdep = ispezione.CodMdep,
+ DataCreazione = ispezione.Data,
+ Note = scheda.Note,
+ PersonaRif = scheda.Responsabile,
+ Barcodes = scheda.Articoli.ConvertAll(x => x.Barcode),
+ Scandeza = (ScadenzaEnum)scheda.Scadenza,
+ ParentActivityId = scheda.Ispezione?.ActivityId
+ }
+ );
+
+ if (apiResponse == null) continue;
+
+ scheda.ActivityId = apiResponse.ActivityIdScheda;
+ await IspezioniService.UpdateSchedaAsync(scheda);
+
+ await IspezioniService.UpdateActivityIdIspezioneAsync(
+ ispezione.CodMdep,
+ ispezione.Data,
+ ispezione.Rilevatore,
+ apiResponse.ActivityIdIspezione
+ );
+
+ if (scheda.ImageNames == null) continue;
+
+ var fileList = (await AttachedService.GetInspectionFiles(ispezione, scheda.ImageNames))?
+ .Where(x => x.ToUpload).ToList();
+
+ if (fileList == null) continue;
+
+ foreach (var file in fileList)
+ {
+ await IntegrySteupService.UploadFile(scheda.ActivityId!, file.FileBytes!, file.Name!);
+ }
+ }
+
SteupDataService.InspectionPageState.Ispezione.Stato = StatusEnum.Completata;
await IntegrySteupService.CompleteInspection(ispezione.ActivityId!);
diff --git a/SteUp.Shared/Components/SingleElements/Card/SchedaCard.razor b/SteUp.Shared/Components/SingleElements/Card/SchedaCard.razor
index b4a6c2a..c20ffc1 100644
--- a/SteUp.Shared/Components/SingleElements/Card/SchedaCard.razor
+++ b/SteUp.Shared/Components/SingleElements/Card/SchedaCard.razor
@@ -5,9 +5,11 @@
@using SteUp.Shared.Core.Enum
@using SteUp.Shared.Core.Interface.IntegryApi
@using SteUp.Shared.Core.Interface.LocalDb
+@using SteUp.Shared.Core.Interface.System
@inject IIspezioniService IspezioniService
@inject IIntegrySteupService IntegrySteupService
@inject IDialogService Dialog
+@inject IAttachedService AttachedService
@@ -27,7 +29,7 @@
- @if (Stato != StatusEnum.Completata)
+ @if (Ispezione.Stato != StatusEnum.Completata)
{
if (NetworkService.IsNetworkAvailable())
{
@@ -56,6 +58,11 @@
Color="Color.Info" Size="Size.Small" OnClick="@ViewScheda">
Visualizza
+
+
+ Esporta immagini
+
}
@@ -66,9 +73,7 @@
Message="Confermi la cancellazione della scheda corrente?"/>
@code{
- [Parameter] public string CodMdep { get; set; } = string.Empty;
- [Parameter] public DateTime Data { get; set; }
- [Parameter] public StatusEnum Stato { get; set; }
+ [Parameter] public Ispezione Ispezione { get; set; } = new();
[Parameter] public required Scheda Scheda { get; set; }
[Parameter] public EventCallback OnSchedaModified { get; set; }
[Parameter] public EventCallback OnSchedaDeleted { get; set; }
@@ -79,7 +84,7 @@
private async Task UpdateScheda()
{
- var modal = await Dialog.OpenFormScheda(CodMdep, Data, false, Scheda);
+ var modal = await Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda);
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
}
@@ -95,6 +100,14 @@
if (Scheda.ActivityId != null)
await IntegrySteupService.DeleteScheda(Scheda.ActivityId);
+ if (Scheda.ImageNames != null)
+ {
+ foreach (var fileName in Scheda.ImageNames)
+ {
+ AttachedService.RemoveInspectionFile(Ispezione, fileName);
+ }
+ }
+
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
@@ -104,7 +117,7 @@
}
private void ViewScheda() =>
- _ = Dialog.OpenFormScheda(CodMdep, Data, false, Scheda, true);
+ _ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true);
private async Task ExportScheda()
{
@@ -117,8 +130,8 @@
LocalIdScheda = Scheda.Id,
ActivityTypeId = Scheda.ActivityTypeId,
CodJfas = Scheda.CodJfas,
- CodMdep = CodMdep,
- DataCreazione = Data,
+ CodMdep = Ispezione.CodMdep,
+ DataCreazione = Ispezione.Data,
Note = Scheda.Note,
PersonaRif = Scheda.Responsabile,
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
@@ -132,7 +145,7 @@
Scheda.ActivityId = apiResponse.ActivityIdScheda;
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
- await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
+ await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
UserSession.User.Username, apiResponse.ActivityIdIspezione
);
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
@@ -142,4 +155,18 @@
StateHasChanged();
}
+ private async Task ExportImg()
+ {
+ if (Scheda.ImageNames == null) return;
+
+ var fileList = (await AttachedService.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
+ .Where(x => x.ToUpload).ToList();
+
+ if (fileList == null) return;
+
+ foreach (var file in fileList)
+ {
+ await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
+ }
+ }
}
\ No newline at end of file