Esportazione immagini anche con ispezione completata
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
@using SteUp.Shared.Core.Enum
|
@using SteUp.Shared.Core.Enum
|
||||||
@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.Messages.Ispezione
|
@using SteUp.Shared.Core.Messages.Ispezione
|
||||||
@using SteUp.Shared.Core.Messages.Scheda
|
@using SteUp.Shared.Core.Messages.Scheda
|
||||||
@inject NewSchedaService NewScheda
|
@inject NewSchedaService NewScheda
|
||||||
@@ -14,6 +15,7 @@
|
|||||||
@inject IIspezioniService IspezioniService
|
@inject IIspezioniService IspezioniService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
@inject IIntegrySteupService IntegrySteupService
|
@inject IIntegrySteupService IntegrySteupService
|
||||||
|
@inject IAttachedService AttachedService
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
|
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
|
||||||
@@ -64,9 +66,7 @@
|
|||||||
{
|
{
|
||||||
<SchedaCard Scheda="scheda" OnSchedaDeleted="OnSchedaDeleted"
|
<SchedaCard Scheda="scheda" OnSchedaDeleted="OnSchedaDeleted"
|
||||||
OnSchedaModified="OnSchedaModified"
|
OnSchedaModified="OnSchedaModified"
|
||||||
Stato="@SteupDataService.InspectionPageState.Ispezione.Stato"
|
Ispezione="@SteupDataService.InspectionPageState.Ispezione"/>
|
||||||
CodMdep="@SteupDataService.InspectionPageState.Ispezione.CodMdep"
|
|
||||||
Data="@SteupDataService.InspectionPageState.Ispezione.Data"/>
|
|
||||||
}
|
}
|
||||||
</ChildContent>
|
</ChildContent>
|
||||||
</MudExpansionPanel>
|
</MudExpansionPanel>
|
||||||
@@ -118,6 +118,49 @@
|
|||||||
|
|
||||||
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
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;
|
SteupDataService.InspectionPageState.Ispezione.Stato = StatusEnum.Completata;
|
||||||
|
|
||||||
await IntegrySteupService.CompleteInspection(ispezione.ActivityId!);
|
await IntegrySteupService.CompleteInspection(ispezione.ActivityId!);
|
||||||
|
|||||||
@@ -5,9 +5,11 @@
|
|||||||
@using SteUp.Shared.Core.Enum
|
@using SteUp.Shared.Core.Enum
|
||||||
@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
|
||||||
@inject IIspezioniService IspezioniService
|
@inject IIspezioniService IspezioniService
|
||||||
@inject IIntegrySteupService IntegrySteupService
|
@inject IIntegrySteupService IntegrySteupService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
|
@inject IAttachedService AttachedService
|
||||||
|
|
||||||
<div class="scheda-card">
|
<div class="scheda-card">
|
||||||
<div class="scheda-body-section">
|
<div class="scheda-body-section">
|
||||||
@@ -27,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="scheda-card-action">
|
<div class="scheda-card-action">
|
||||||
@if (Stato != StatusEnum.Completata)
|
@if (Ispezione.Stato != StatusEnum.Completata)
|
||||||
{
|
{
|
||||||
if (NetworkService.IsNetworkAvailable())
|
if (NetworkService.IsNetworkAvailable())
|
||||||
{
|
{
|
||||||
@@ -56,6 +58,11 @@
|
|||||||
Color="Color.Info" Size="Size.Small" OnClick="@ViewScheda">
|
Color="Color.Info" Size="Size.Small" OnClick="@ViewScheda">
|
||||||
Visualizza
|
Visualizza
|
||||||
</MudButton>
|
</MudButton>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.CloudSync"
|
||||||
|
Color="Color.Success" Size="Size.Small" OnClick="@ExportImg">
|
||||||
|
Esporta immagini
|
||||||
|
</MudButton>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -66,9 +73,7 @@
|
|||||||
Message="Confermi la cancellazione della scheda corrente?"/>
|
Message="Confermi la cancellazione della scheda corrente?"/>
|
||||||
|
|
||||||
@code{
|
@code{
|
||||||
[Parameter] public string CodMdep { get; set; } = string.Empty;
|
[Parameter] public Ispezione Ispezione { get; set; } = new();
|
||||||
[Parameter] public DateTime Data { get; set; }
|
|
||||||
[Parameter] public StatusEnum Stato { get; set; }
|
|
||||||
[Parameter] public required Scheda Scheda { get; set; }
|
[Parameter] public required Scheda Scheda { get; set; }
|
||||||
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
|
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
|
||||||
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
|
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
|
||||||
@@ -79,7 +84,7 @@
|
|||||||
|
|
||||||
private async Task UpdateScheda()
|
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);
|
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +100,14 @@
|
|||||||
if (Scheda.ActivityId != null)
|
if (Scheda.ActivityId != null)
|
||||||
await IntegrySteupService.DeleteScheda(Scheda.ActivityId);
|
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);
|
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
|
||||||
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
|
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
|
||||||
|
|
||||||
@@ -104,7 +117,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ViewScheda() =>
|
private void ViewScheda() =>
|
||||||
_ = Dialog.OpenFormScheda(CodMdep, Data, false, Scheda, true);
|
_ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true);
|
||||||
|
|
||||||
private async Task ExportScheda()
|
private async Task ExportScheda()
|
||||||
{
|
{
|
||||||
@@ -117,8 +130,8 @@
|
|||||||
LocalIdScheda = Scheda.Id,
|
LocalIdScheda = Scheda.Id,
|
||||||
ActivityTypeId = Scheda.ActivityTypeId,
|
ActivityTypeId = Scheda.ActivityTypeId,
|
||||||
CodJfas = Scheda.CodJfas,
|
CodJfas = Scheda.CodJfas,
|
||||||
CodMdep = CodMdep,
|
CodMdep = Ispezione.CodMdep,
|
||||||
DataCreazione = Data,
|
DataCreazione = Ispezione.Data,
|
||||||
Note = Scheda.Note,
|
Note = Scheda.Note,
|
||||||
PersonaRif = Scheda.Responsabile,
|
PersonaRif = Scheda.Responsabile,
|
||||||
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||||
@@ -132,7 +145,7 @@
|
|||||||
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||||
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
|
||||||
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
|
||||||
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
);
|
);
|
||||||
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
||||||
@@ -142,4 +155,18 @@
|
|||||||
StateHasChanged();
|
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!);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user