Gestiti salvataggi rest
This commit is contained in:
15
.idea/.idea.SteUp/.idea/.gitignore
generated
vendored
15
.idea/.idea.SteUp/.idea/.gitignore
generated
vendored
@@ -1,15 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Rider ignored files
|
|
||||||
/modules.xml
|
|
||||||
/projectSettingsUpdater.xml
|
|
||||||
/.idea.SteUp.iml
|
|
||||||
/contentModel.xml
|
|
||||||
# Ignored default folder with query files
|
|
||||||
/queries/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
1
.idea/.idea.SteUp/.idea/.name
generated
1
.idea/.idea.SteUp/.idea/.name
generated
@@ -1 +0,0 @@
|
|||||||
SteUp
|
|
||||||
6
.idea/.idea.SteUp/.idea/AndroidProjectSystem.xml
generated
6
.idea/.idea.SteUp/.idea/AndroidProjectSystem.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="AndroidProjectSystem">
|
|
||||||
<option name="providerId" value="RiderAndroidProjectSystem" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
10
.idea/.idea.SteUp/.idea/deploymentTargetSelector.xml
generated
10
.idea/.idea.SteUp/.idea/deploymentTargetSelector.xml
generated
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetSelector">
|
|
||||||
<selectionStates>
|
|
||||||
<SelectionState runConfigName="SteUp.Maui">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
</SelectionState>
|
|
||||||
</selectionStates>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
4
.idea/.idea.SteUp/.idea/encodings.xml
generated
4
.idea/.idea.SteUp/.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
|
||||||
</project>
|
|
||||||
8
.idea/.idea.SteUp/.idea/indexLayout.xml
generated
8
.idea/.idea.SteUp/.idea/indexLayout.xml
generated
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="UserContentModel">
|
|
||||||
<attachedFolders />
|
|
||||||
<explicitIncludes />
|
|
||||||
<explicitExcludes />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.annotation.annotation">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.annotation/1.9.1.5/jar/androidx.annotation.annotation.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.annotation.annotation-jvm">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.annotation.jvm/1.9.1.5/jar/androidx.annotation.annotation-jvm.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.arch.core.core-common">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.arch.core.common/2.2.0.18/jar/androidx.arch.core.core-common.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.collection.collection">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.collection/1.5.0.3/jar/androidx.collection.collection.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.collection.collection-jvm">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.collection.jvm/1.5.0.3/jar/androidx.collection.collection-jvm.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.collection.collection-ktx">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.collection.ktx/1.5.0.3/jar/androidx.collection.collection-ktx.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.concurrent.concurrent-futures">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.concurrent.futures/1.3.0.1/jar/androidx.concurrent.concurrent-futures.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.constraintlayout.constraintlayout-core">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.constraintlayout.core/1.1.1.3/jar/androidx.constraintlayout.constraintlayout-core.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.lifecycle.lifecycle-common">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.lifecycle.common/2.9.2.1/jar/androidx.lifecycle.lifecycle-common.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.lifecycle.lifecycle-common-java8">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.lifecycle.common.java8/2.9.2.1/jar/androidx.lifecycle.lifecycle-common-java8.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.lifecycle.lifecycle-common-jvm">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.lifecycle.common.jvm/2.9.2.1/jar/androidx.lifecycle.lifecycle-common-jvm.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="androidx.resourceinspection.resourceinspection-annotation">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.resourceinspection.annotation/1.0.1.22/jar/androidx.resourceinspection.resourceinspection-annotation.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
6
.idea/.idea.SteUp/.idea/vcs.xml
generated
6
.idea/.idea.SteUp/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using SteUp.Shared.Core.Entities;
|
using SteUp.Shared.Core.Entities;
|
||||||
|
using SteUp.Shared.Core.Enum;
|
||||||
|
using SteUp.Shared.Core.Helpers;
|
||||||
using SteUp.Shared.Core.Interface.LocalDb;
|
using SteUp.Shared.Core.Interface.LocalDb;
|
||||||
|
|
||||||
namespace SteUp.Data.LocalDb.EntityServices;
|
namespace SteUp.Data.LocalDb.EntityServices;
|
||||||
|
|
||||||
public class IspezioniService(AppDbContext db) : IIspezioniService
|
public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||||
{
|
{
|
||||||
public Task<Ispezione?> GetIspezioneAsync(string codMdep, DateOnly data, string rilevatore) =>
|
public Task<Ispezione?> GetIspezioneAsync(string codMdep, DateTime data, string rilevatore) =>
|
||||||
db.Ispezioni
|
db.Ispezioni
|
||||||
.Include(x => x.Schede)
|
.Include(x => x.Schede)
|
||||||
.ThenInclude(s => s.Articoli)
|
.ThenInclude(s => s.Articoli)
|
||||||
@@ -29,7 +31,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Ispezione> GetOrCreateIspezioneAsync(string codMdep, DateOnly data, string rilevatore)
|
public async Task<Ispezione> GetOrCreateIspezioneAsync(string codMdep, DateTime data, string rilevatore)
|
||||||
{
|
{
|
||||||
var existing = await db.Ispezioni
|
var existing = await db.Ispezioni
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
@@ -65,11 +67,46 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateStatoIspezioneAsync(string codMdep, DateTime data, string rilevatore, StatusEnum stato)
|
||||||
|
{
|
||||||
|
var ispezione = await db.Ispezioni
|
||||||
|
.FirstOrDefaultAsync(x =>
|
||||||
|
x.CodMdep == codMdep &&
|
||||||
|
x.Data == data &&
|
||||||
|
x.Rilevatore == rilevatore);
|
||||||
|
|
||||||
|
if (ispezione is null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ispezione.Stato = stato;
|
||||||
|
db.Ispezioni.Update(ispezione);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateActivityIdIspezioneAsync(string codMdep, DateTime data, string rilevatore,
|
||||||
|
string? activityId)
|
||||||
|
{
|
||||||
|
var ispezione = await db.Ispezioni
|
||||||
|
.FirstOrDefaultAsync(x =>
|
||||||
|
x.CodMdep == codMdep &&
|
||||||
|
x.Data == data &&
|
||||||
|
x.Rilevatore == rilevatore);
|
||||||
|
|
||||||
|
if (ispezione is null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ispezione.ActivityId = activityId;
|
||||||
|
db.Ispezioni.Update(ispezione);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancella l'ispezione e tutte le schede collegate (e relativi articoli via cascade).
|
/// Cancella l'ispezione e tutte le schede collegate (e relativi articoli via cascade).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<bool> DeleteIspezioneAsync(string codMdep, DateOnly data, string rilevatore)
|
public async Task<bool> DeleteIspezioneAsync(string codMdep, DateTime data, string rilevatore)
|
||||||
{
|
{
|
||||||
var ispezione = await db.Ispezioni
|
var ispezione = await db.Ispezioni
|
||||||
.FirstOrDefaultAsync(x =>
|
.FirstOrDefaultAsync(x =>
|
||||||
@@ -85,7 +122,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddSchedaAsync(string codMdep, DateOnly data, string rilevatore, Scheda scheda)
|
public async Task AddSchedaAsync(string codMdep, DateTime data, string rilevatore, Scheda scheda)
|
||||||
{
|
{
|
||||||
await GetOrCreateIspezioneAsync(codMdep, data, rilevatore);
|
await GetOrCreateIspezioneAsync(codMdep, data, rilevatore);
|
||||||
|
|
||||||
@@ -105,7 +142,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<Scheda>> GetAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore) =>
|
public Task<List<Scheda>> GetAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore) =>
|
||||||
db.Schede
|
db.Schede
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(s => s.Articoli)
|
.Include(s => s.Articoli)
|
||||||
@@ -127,6 +164,17 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(x => x.Id == schedaId);
|
.FirstOrDefaultAsync(x => x.Id == schedaId);
|
||||||
|
|
||||||
|
public async Task<bool> UpdateActivityIdSchedaAsync(int schedaId, string? activityId)
|
||||||
|
{
|
||||||
|
var scheda = await db.Schede.FirstOrDefaultAsync(x => x.Id == schedaId);
|
||||||
|
if (scheda is null) return false;
|
||||||
|
|
||||||
|
scheda.ActivityId = activityId;
|
||||||
|
db.Schede.Update(scheda);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> DeleteSchedaAsync(int schedaId)
|
public async Task<bool> DeleteSchedaAsync(int schedaId)
|
||||||
{
|
{
|
||||||
var scheda = await db.Schede.FirstOrDefaultAsync(x => x.Id == schedaId);
|
var scheda = await db.Schede.FirstOrDefaultAsync(x => x.Id == schedaId);
|
||||||
@@ -197,7 +245,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancella tutte le schede di una ispezione senza cancellare l'ispezione.
|
/// Cancella tutte le schede di una ispezione senza cancellare l'ispezione.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<int> DeleteAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore)
|
public async Task<int> DeleteAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore)
|
||||||
{
|
{
|
||||||
var schede = await db.Schede
|
var schede = await db.Schede
|
||||||
.Where(s =>
|
.Where(s =>
|
||||||
|
|||||||
148
SteUp.Data/Migrations/20260226155235_ModDataIspezione.Designer.cs
generated
Normal file
148
SteUp.Data/Migrations/20260226155235_ModDataIspezione.Designer.cs
generated
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SteUp.Data.LocalDb;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SteUp.Data.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260226155235_ModDataIspezione")]
|
||||||
|
partial class ModDataIspezione
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Ispezione", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("CodMdep")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Data")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Rilevatore")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Stato")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("CodMdep", "Data", "Rilevatore");
|
||||||
|
|
||||||
|
b.ToTable("Ispezioni");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Scheda", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ActivityTypeId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("CodJfas")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("CodMdep")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Data")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("DescrizioneReparto")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ImageNames")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Note")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Responsabile")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Rilevatore")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Scadenza")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CodMdep", "Data", "Rilevatore");
|
||||||
|
|
||||||
|
b.ToTable("Schede");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.SchedaArticolo", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Barcode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Descrizione")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("SchedaId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SchedaId", "Barcode")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("SchedaArticoli");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Scheda", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SteUp.Shared.Core.Entities.Ispezione", "Ispezione")
|
||||||
|
.WithMany("Schede")
|
||||||
|
.HasForeignKey("CodMdep", "Data", "Rilevatore")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Ispezione");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.SchedaArticolo", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SteUp.Shared.Core.Entities.Scheda", "Scheda")
|
||||||
|
.WithMany("Articoli")
|
||||||
|
.HasForeignKey("SchedaId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Scheda");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Ispezione", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Schede");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Scheda", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Articoli");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
SteUp.Data/Migrations/20260226155235_ModDataIspezione.cs
Normal file
22
SteUp.Data/Migrations/20260226155235_ModDataIspezione.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SteUp.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ModDataIspezione : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
154
SteUp.Data/Migrations/20260227102100_AddActivityId.Designer.cs
generated
Normal file
154
SteUp.Data/Migrations/20260227102100_AddActivityId.Designer.cs
generated
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using SteUp.Data.LocalDb;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SteUp.Data.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(AppDbContext))]
|
||||||
|
[Migration("20260227102100_AddActivityId")]
|
||||||
|
partial class AddActivityId
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder.HasAnnotation("ProductVersion", "10.0.3");
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Ispezione", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("CodMdep")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Data")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Rilevatore")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ActivityId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Stato")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("CodMdep", "Data", "Rilevatore");
|
||||||
|
|
||||||
|
b.ToTable("Ispezioni");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Scheda", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ActivityId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ActivityTypeId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("CodJfas")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("CodMdep")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Data")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("DescrizioneReparto")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ImageNames")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Note")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Responsabile")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Rilevatore")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("Scadenza")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CodMdep", "Data", "Rilevatore");
|
||||||
|
|
||||||
|
b.ToTable("Schede");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.SchedaArticolo", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Barcode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Descrizione")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int>("SchedaId")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("SchedaId", "Barcode")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("SchedaArticoli");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Scheda", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SteUp.Shared.Core.Entities.Ispezione", "Ispezione")
|
||||||
|
.WithMany("Schede")
|
||||||
|
.HasForeignKey("CodMdep", "Data", "Rilevatore")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Ispezione");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.SchedaArticolo", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SteUp.Shared.Core.Entities.Scheda", "Scheda")
|
||||||
|
.WithMany("Articoli")
|
||||||
|
.HasForeignKey("SchedaId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Scheda");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Ispezione", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Schede");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SteUp.Shared.Core.Entities.Scheda", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Articoli");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
38
SteUp.Data/Migrations/20260227102100_AddActivityId.cs
Normal file
38
SteUp.Data/Migrations/20260227102100_AddActivityId.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace SteUp.Data.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddActivityId : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ActivityId",
|
||||||
|
table: "Schede",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ActivityId",
|
||||||
|
table: "Ispezioni",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ActivityId",
|
||||||
|
table: "Schede");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ActivityId",
|
||||||
|
table: "Ispezioni");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,12 +22,15 @@ namespace SteUp.Data.Migrations
|
|||||||
b.Property<string>("CodMdep")
|
b.Property<string>("CodMdep")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<DateOnly>("Data")
|
b.Property<DateTime>("Data")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Rilevatore")
|
b.Property<string>("Rilevatore")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("ActivityId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("Stato")
|
b.Property<int>("Stato")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
@@ -42,6 +45,9 @@ namespace SteUp.Data.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("ActivityId")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("ActivityTypeId")
|
b.Property<string>("ActivityTypeId")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
@@ -52,7 +58,7 @@ namespace SteUp.Data.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<DateOnly>("Data")
|
b.Property<DateTime>("Data")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("DescrizioneReparto")
|
b.Property<string>("DescrizioneReparto")
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ 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 SteUp.Shared.Core.Interface.System.Network;
|
using SteUp.Shared.Core.Interface.System.Network;
|
||||||
|
using SteUp.Shared.Core.Messages.Ispezione;
|
||||||
using SteUp.Shared.Core.Messages.Scanner;
|
using SteUp.Shared.Core.Messages.Scanner;
|
||||||
using SteUp.Shared.Core.Messages.Scheda;
|
using SteUp.Shared.Core.Messages.Scheda;
|
||||||
using SteUp.Shared.Core.Services;
|
using SteUp.Shared.Core.Services;
|
||||||
@@ -60,6 +61,7 @@ public static class CoreModule
|
|||||||
builder.Services.AddSingleton<IMessenger, WeakReferenceMessenger>();
|
builder.Services.AddSingleton<IMessenger, WeakReferenceMessenger>();
|
||||||
builder.Services.AddSingleton<NewSchedaService>();
|
builder.Services.AddSingleton<NewSchedaService>();
|
||||||
builder.Services.AddSingleton<OnScannerService>();
|
builder.Services.AddSingleton<OnScannerService>();
|
||||||
|
builder.Services.AddSingleton<CompleteInspectionService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterDbServices()
|
public void RegisterDbServices()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Extensions.Logging.Abstractions;
|
using SteUp.Shared.Core.Dto;
|
||||||
using SteUp.Shared.Core.Dto;
|
|
||||||
using SteUp.Shared.Core.Entities;
|
using SteUp.Shared.Core.Entities;
|
||||||
using SteUp.Shared.Core.Helpers;
|
using SteUp.Shared.Core.Helpers;
|
||||||
using SteUp.Shared.Core.Interface.System;
|
using SteUp.Shared.Core.Interface.System;
|
||||||
@@ -82,10 +81,10 @@ public class AttachedService : IAttachedService
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<AttachedDto> ConvertToDto(FileInfo file, AttachedDto.TypeAttached type)
|
private async Task<AttachedDto> ConvertToDto(FileInfo file, AttachedDto.TypeAttached type, bool isFromToUpload)
|
||||||
{
|
{
|
||||||
var (origUrl, thumbUrl) = await SaveAndCreateThumbAsync(
|
var (origUrl, thumbUrl) = await SaveAndCreateThumbAsync(
|
||||||
await File.ReadAllBytesAsync(file.FullName),
|
await File.ReadAllBytesAsync(file.FullName),
|
||||||
file.Name
|
file.Name
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -96,64 +95,202 @@ public class AttachedService : IAttachedService
|
|||||||
TempPath = origUrl,
|
TempPath = origUrl,
|
||||||
ThumbPath = thumbUrl,
|
ThumbPath = thumbUrl,
|
||||||
Type = type,
|
Type = type,
|
||||||
SavedOnAppData = true
|
SavedOnAppData = true,
|
||||||
|
ToUpload = isFromToUpload
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<AttachedDto>?> GetInspectionFiles(Ispezione ispezione)
|
private const string ToUploadFolderName = "toUpload";
|
||||||
|
|
||||||
|
private string GetInspectionBaseDir(Ispezione ispezione)
|
||||||
{
|
{
|
||||||
var baseDir = FileSystem.AppDataDirectory;
|
var baseDir = FileSystem.AppDataDirectory;
|
||||||
var inspectionDir = Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
return Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
||||||
var directory = new DirectoryInfo(inspectionDir);
|
|
||||||
|
|
||||||
if (!directory.Exists) return null;
|
|
||||||
|
|
||||||
var fileList = directory.GetFiles().ToList();
|
|
||||||
|
|
||||||
var returnList = new List<AttachedDto>();
|
|
||||||
foreach (var file in fileList)
|
|
||||||
{
|
|
||||||
returnList.Add(await ConvertToDto(file, AttachedDto.TypeAttached.Image));
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string?> SaveInspectionFile(Ispezione ispezione, byte[] file, string fileName,
|
private string GetInspectionToUploadDir(Ispezione ispezione)
|
||||||
|
=> Path.Combine(GetInspectionBaseDir(ispezione), ToUploadFolderName);
|
||||||
|
|
||||||
|
private string GetInspectionFinalDir(Ispezione ispezione)
|
||||||
|
=> GetInspectionBaseDir(ispezione);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ritorna i file dell'ispezione filtrati per nome.
|
||||||
|
/// Per default include sia "final" sia "toUpload" (utile per UI).
|
||||||
|
/// </summary>
|
||||||
|
public async Task<List<AttachedDto>?> GetInspectionFiles(
|
||||||
|
Ispezione ispezione,
|
||||||
|
List<string> fileNameFilter,
|
||||||
|
bool includeToUpload,
|
||||||
|
CancellationToken ct)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(ispezione);
|
||||||
|
ArgumentNullException.ThrowIfNull(fileNameFilter);
|
||||||
|
|
||||||
|
var baseDir = GetInspectionBaseDir(ispezione);
|
||||||
|
if (!Directory.Exists(baseDir)) return null;
|
||||||
|
|
||||||
|
var result = new List<AttachedDto>();
|
||||||
|
|
||||||
|
var finalDir = GetInspectionFinalDir(ispezione);
|
||||||
|
if (Directory.Exists(finalDir))
|
||||||
|
{
|
||||||
|
var finalFiles = new DirectoryInfo(finalDir)
|
||||||
|
.GetFiles("*", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
|
foreach (var file in finalFiles)
|
||||||
|
{
|
||||||
|
if (file.Directory?.Name == ToUploadFolderName)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!fileNameFilter.Contains(file.Name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ct.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
result.Add(await ConvertToDto(
|
||||||
|
file,
|
||||||
|
AttachedDto.TypeAttached.Image,
|
||||||
|
isFromToUpload: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!includeToUpload) return result;
|
||||||
|
|
||||||
|
var toUploadDir = GetInspectionToUploadDir(ispezione);
|
||||||
|
if (!Directory.Exists(toUploadDir)) return result;
|
||||||
|
|
||||||
|
var toUploadFiles = new DirectoryInfo(toUploadDir)
|
||||||
|
.GetFiles("*", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
|
foreach (var file in toUploadFiles)
|
||||||
|
{
|
||||||
|
if (!fileNameFilter.Contains(file.Name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ct.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
result.Add(await ConvertToDto(
|
||||||
|
file,
|
||||||
|
AttachedDto.TypeAttached.Image,
|
||||||
|
isFromToUpload: true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Salva SEMPRE in /toUpload.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string?> SaveInspectionFile(
|
||||||
|
Ispezione ispezione,
|
||||||
|
byte[] file,
|
||||||
|
string fileName,
|
||||||
CancellationToken ct)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(ispezione);
|
ArgumentNullException.ThrowIfNull(ispezione);
|
||||||
ArgumentNullException.ThrowIfNull(file);
|
ArgumentNullException.ThrowIfNull(file);
|
||||||
ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
|
ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
|
||||||
|
|
||||||
var baseDir = FileSystem.AppDataDirectory;
|
var toUploadDir = GetInspectionToUploadDir(ispezione);
|
||||||
var inspectionDir = Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
Directory.CreateDirectory(toUploadDir);
|
||||||
if (!Directory.Exists(inspectionDir)) Directory.CreateDirectory(inspectionDir);
|
|
||||||
|
|
||||||
var filePath = Path.Combine(inspectionDir, fileName);
|
var filePath = Path.Combine(toUploadDir, fileName);
|
||||||
await File.WriteAllBytesAsync(filePath, file, ct);
|
await File.WriteAllBytesAsync(filePath, file, ct);
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RemoveInspectionFile(Ispezione ispezione, string fileName)
|
public Task<bool> MoveInspectionFileFromToUploadToFinal(
|
||||||
|
Ispezione ispezione,
|
||||||
|
string fileName,
|
||||||
|
bool overwrite,
|
||||||
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
var baseDir = FileSystem.AppDataDirectory;
|
ArgumentNullException.ThrowIfNull(ispezione);
|
||||||
var inspectionDir = Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
|
||||||
|
|
||||||
if (!Directory.Exists(inspectionDir)) return false;
|
ct.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var toUploadDir = GetInspectionToUploadDir(ispezione);
|
||||||
|
var finalDir = GetInspectionFinalDir(ispezione);
|
||||||
|
|
||||||
|
if (!Directory.Exists(toUploadDir)) return Task.FromResult(false);
|
||||||
|
|
||||||
|
var sourcePath = Path.Combine(toUploadDir, fileName);
|
||||||
|
if (!File.Exists(sourcePath)) return Task.FromResult(false);
|
||||||
|
|
||||||
|
Directory.CreateDirectory(finalDir);
|
||||||
|
|
||||||
|
var destPath = Path.Combine(finalDir, fileName);
|
||||||
|
|
||||||
|
if (File.Exists(destPath))
|
||||||
|
{
|
||||||
|
if (!overwrite) return Task.FromResult(false);
|
||||||
|
File.Delete(destPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Move(sourcePath, destPath);
|
||||||
|
|
||||||
|
// Pulizia: se /toUpload resta vuota la elimino
|
||||||
|
CleanupDirectoriesIfEmpty(ispezione);
|
||||||
|
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rimuove un file cercandolo prima in /toUpload e poi in final (o viceversa).
|
||||||
|
/// Default: prova a cancellare ovunque.
|
||||||
|
/// </summary>
|
||||||
|
public bool RemoveInspectionFile(
|
||||||
|
Ispezione ispezione,
|
||||||
|
string fileName,
|
||||||
|
bool removeAlsoFromFinal,
|
||||||
|
bool removeAlsoFromToUpload)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(ispezione);
|
||||||
if (string.IsNullOrWhiteSpace(fileName)) return false;
|
if (string.IsNullOrWhiteSpace(fileName)) return false;
|
||||||
|
|
||||||
var filePath = Path.Combine(inspectionDir, fileName);
|
var removed = false;
|
||||||
|
|
||||||
if (!File.Exists(filePath)) return false;
|
if (removeAlsoFromToUpload)
|
||||||
|
{
|
||||||
File.Delete(filePath);
|
var toUploadPath = Path.Combine(GetInspectionToUploadDir(ispezione), fileName);
|
||||||
|
if (File.Exists(toUploadPath))
|
||||||
|
{
|
||||||
|
File.Delete(toUploadPath);
|
||||||
|
removed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!Directory.EnumerateFileSystemEntries(inspectionDir).Any())
|
if (removeAlsoFromFinal)
|
||||||
Directory.Delete(inspectionDir);
|
{
|
||||||
|
var finalPath = Path.Combine(GetInspectionFinalDir(ispezione), fileName);
|
||||||
|
if (File.Exists(finalPath))
|
||||||
|
{
|
||||||
|
File.Delete(finalPath);
|
||||||
|
removed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
if (removed)
|
||||||
|
CleanupDirectoriesIfEmpty(ispezione);
|
||||||
|
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CleanupDirectoriesIfEmpty(Ispezione ispezione)
|
||||||
|
{
|
||||||
|
var baseDir = GetInspectionBaseDir(ispezione);
|
||||||
|
var toUploadDir = GetInspectionToUploadDir(ispezione);
|
||||||
|
|
||||||
|
// 1) se /toUpload esiste e vuota => delete
|
||||||
|
if (Directory.Exists(toUploadDir) && !Directory.EnumerateFileSystemEntries(toUploadDir).Any())
|
||||||
|
Directory.Delete(toUploadDir);
|
||||||
|
|
||||||
|
// 2) se base dir vuota (attenzione: dopo delete toUpload) => delete
|
||||||
|
if (Directory.Exists(baseDir) && !Directory.EnumerateFileSystemEntries(baseDir).Any())
|
||||||
|
Directory.Delete(baseDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default)
|
public async Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default)
|
||||||
|
|||||||
@@ -123,6 +123,8 @@ public partial class HoneywellScannerService
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
|
||||||
service.OnScanFailed?.Invoke(ex);
|
service.OnScanFailed?.Invoke(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
@using CommunityToolkit.Mvvm.Messaging
|
@using CommunityToolkit.Mvvm.Messaging
|
||||||
|
@using SteUp.Shared.Core.Entities
|
||||||
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||||
@using SteUp.Shared.Core.Interface.System.Network
|
@using SteUp.Shared.Core.Interface.System.Network
|
||||||
|
@using SteUp.Shared.Core.Messages.Ispezione
|
||||||
@using SteUp.Shared.Core.Messages.Scheda
|
@using SteUp.Shared.Core.Messages.Scheda
|
||||||
@inject INetworkService NetworkService
|
@inject INetworkService NetworkService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
@@ -31,17 +34,24 @@
|
|||||||
|
|
||||||
@if (PlusVisible)
|
@if (PlusVisible)
|
||||||
{
|
{
|
||||||
<MudFabMenu ButtonClass="custom-plus-button" MenuClass="custom-menu-fab" OnClick="@OnOpenMenu" StartIcon="@Icons.Material.Filled.Add"
|
<MudFabMenu ButtonClass="custom-plus-button" MenuClass="custom-menu-fab" OnClick="@OnOpenMenu"
|
||||||
IconColor="Color.Primary" Color="Color.Surface" AlignItems="AlignItems.End"
|
StartIcon="@Icons.Material.Filled.Add"
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
if (ShowCompleteInspection)
|
||||||
|
{
|
||||||
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@CompleteInspection"
|
||||||
|
Label="Concludi ispezione" Color="Color.Surface"/>
|
||||||
|
}
|
||||||
|
|
||||||
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewScheda"
|
||||||
Label="Nuova scheda" Color="Color.Surface"/>
|
Label="Nuova scheda" Color="Color.Surface"/>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewActivity"
|
<MudFabMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewActivity"
|
||||||
Label="Nuova ispezione" Color="Color.Surface"/>
|
Label="Nuova ispezione" Color="Color.Surface"/>
|
||||||
}
|
}
|
||||||
</MudFabMenu>
|
</MudFabMenu>
|
||||||
@@ -53,6 +63,7 @@
|
|||||||
{
|
{
|
||||||
private bool IsVisible { get; set; } = true;
|
private bool IsVisible { get; set; } = true;
|
||||||
private bool PlusVisible { get; set; } = true;
|
private bool PlusVisible { get; set; } = true;
|
||||||
|
private bool ShowCompleteInspection { get; set; }
|
||||||
private bool SchedaVisible { get; set; }
|
private bool SchedaVisible { get; set; }
|
||||||
|
|
||||||
protected override Task OnInitializedAsync()
|
protected override Task OnInitializedAsync()
|
||||||
@@ -81,6 +92,9 @@
|
|||||||
_ = ModalHelper.OpenSelectShop(Dialog);
|
_ = ModalHelper.OpenSelectShop(Dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CompleteInspection() =>
|
||||||
|
Messenger.Send(new CompleteInspectionMessage());
|
||||||
|
|
||||||
private async Task NewScheda()
|
private async Task NewScheda()
|
||||||
{
|
{
|
||||||
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||||
@@ -95,6 +109,7 @@
|
|||||||
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();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
@page "/ispezione"
|
@page "/ispezione"
|
||||||
@using SteUp.Shared.Components.Layout
|
@using SteUp.Shared.Components.Layout
|
||||||
|
@using SteUp.Shared.Components.Layout.Overlay
|
||||||
@using SteUp.Shared.Components.SingleElements.Card
|
@using SteUp.Shared.Components.SingleElements.Card
|
||||||
@using SteUp.Shared.Core.Dto
|
@using SteUp.Shared.Core.Dto
|
||||||
@using SteUp.Shared.Core.Entities
|
@using SteUp.Shared.Core.Entities
|
||||||
|
@using SteUp.Shared.Core.Enum
|
||||||
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||||
@using SteUp.Shared.Core.Interface.LocalDb
|
@using SteUp.Shared.Core.Interface.LocalDb
|
||||||
|
@using SteUp.Shared.Core.Messages.Ispezione
|
||||||
@using SteUp.Shared.Core.Messages.Scheda
|
@using SteUp.Shared.Core.Messages.Scheda
|
||||||
@inject NewSchedaService NewScheda
|
@inject NewSchedaService NewScheda
|
||||||
|
@inject CompleteInspectionService CompleteInspection
|
||||||
@inject IIspezioniService IspezioniService
|
@inject IIspezioniService IspezioniService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
|
@inject IIntegrySteupService IntegrySteupService
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
|
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
|
||||||
@@ -30,9 +36,23 @@
|
|||||||
</MudChip>
|
</MudChip>
|
||||||
</div>
|
</div>
|
||||||
<div class="action-scheda-group">
|
<div class="action-scheda-group">
|
||||||
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Rounded.Add"
|
@if (NetworkService.IsNetworkAvailable())
|
||||||
Color="Color.Warning" Size="Size.Medium"
|
{
|
||||||
OnClick="@(() => CreateNewScheda(group.Key))"/>
|
<MudFab StartIcon="@Icons.Material.Rounded.Add"
|
||||||
|
Color="Color.Warning" Size="Size.Small"
|
||||||
|
OnClick="@(() => CreateNewScheda(group.Key))"/>
|
||||||
|
|
||||||
|
<MudFab StartIcon="@Icons.Material.Rounded.CloudSync" Label="Esporta reparto"
|
||||||
|
Color="Color.Success" Size="Size.Small"
|
||||||
|
OnClick="@(() => ExportReparto(group.Key))"/>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<MudFab StartIcon="@Icons.Material.Rounded.Add"
|
||||||
|
Label="@($"Nuova scheda su {group.Key.Descrizione}")"
|
||||||
|
Color="Color.Warning" Size="Size.Medium"
|
||||||
|
OnClick="@(() => CreateNewScheda(group.Key))"/>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TitleContent>
|
</TitleContent>
|
||||||
@@ -51,13 +71,18 @@
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private List<Scheda> SchedeList { get; set; } = [];
|
private List<Scheda> SchedeList { get; set; } = [];
|
||||||
private Dictionary<JtbFasiDto, List<Scheda>> SchedeGrouped { get; set; } = [];
|
private Dictionary<JtbFasiDto, List<Scheda>> SchedeGrouped { get; set; } = [];
|
||||||
|
|
||||||
|
private bool VisibleOverlay { get; set; }
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
NewScheda.OnNewScheda += LoadSchede;
|
NewScheda.OnNewScheda += LoadSchede;
|
||||||
|
CompleteInspection.OnComplete += HandleCompleteInspection;
|
||||||
|
|
||||||
LoadSchede();
|
LoadSchede();
|
||||||
}
|
}
|
||||||
@@ -77,6 +102,48 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void HandleCompleteInspection()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
VisibleOverlay = true;
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
|
||||||
|
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||||
|
|
||||||
|
SteupDataService.InspectionPageState.Ispezione.Stato = StatusEnum.Completata;
|
||||||
|
|
||||||
|
await IntegrySteupService.CompleteInspection(ispezione.ActivityId!);
|
||||||
|
await IspezioniService.UpdateStatoIspezioneAsync(
|
||||||
|
ispezione.CodMdep,
|
||||||
|
ispezione.Data,
|
||||||
|
ispezione.Rilevatore,
|
||||||
|
StatusEnum.Completata
|
||||||
|
);
|
||||||
|
|
||||||
|
await InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
VisibleOverlay = false;
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
|
||||||
|
await InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
VisibleOverlay = false;
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
|
||||||
|
OnError(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void GroupSchede()
|
private void GroupSchede()
|
||||||
{
|
{
|
||||||
SchedeGrouped = SchedeList
|
SchedeGrouped = SchedeList
|
||||||
@@ -114,12 +181,76 @@
|
|||||||
new Scheda { Reparto = jtbFasi }
|
new Scheda { Reparto = jtbFasi }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (modal is {Canceled: false}) LoadSchede();
|
if (modal is { Canceled: false }) LoadSchede();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ExportReparto(JtbFasiDto jtbFasi)
|
||||||
|
{
|
||||||
|
VisibleOverlay = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||||
|
|
||||||
|
var saveRequest = SchedeGrouped[jtbFasi].ConvertAll(x =>
|
||||||
|
{
|
||||||
|
return new SaveRequestDto
|
||||||
|
{
|
||||||
|
LocalIdScheda = x.Id,
|
||||||
|
ActivityTypeId = x.ActivityTypeId,
|
||||||
|
CodJfas = x.CodJfas,
|
||||||
|
CodMdep = ispezione.CodMdep,
|
||||||
|
DataCreazione = ispezione.Data,
|
||||||
|
Note = x.Note,
|
||||||
|
PersonaRif = x.Responsabile,
|
||||||
|
Barcodes = x.Articoli.ConvertAll(y => y.Barcode),
|
||||||
|
Scandeza = (ScadenzaEnum)x.Scadenza,
|
||||||
|
ParentActivityId = x.Ispezione?.ActivityId
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
var apiResponse = await IntegrySteupService.SaveMultipleSchede(saveRequest);
|
||||||
|
|
||||||
|
if (apiResponse != null)
|
||||||
|
{
|
||||||
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
|
||||||
|
await IspezioniService.UpdateActivityIdIspezioneAsync(ispezione.CodMdep, ispezione.Data,
|
||||||
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
|
);
|
||||||
|
|
||||||
|
if (apiResponse.ActivityIdSchedaList.IsNullOrEmpty()) return;
|
||||||
|
|
||||||
|
foreach (var scheda in SchedeGrouped[jtbFasi])
|
||||||
|
{
|
||||||
|
scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||||
|
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||||
|
|
||||||
|
var activityId = apiResponse.ActivityIdSchedaList!.Find(x =>
|
||||||
|
x.LocalId != null && x.LocalId == scheda.Id
|
||||||
|
)?.ActivityId;
|
||||||
|
|
||||||
|
if (activityId == null) return;
|
||||||
|
|
||||||
|
scheda.ActivityId = activityId;
|
||||||
|
await IspezioniService.UpdateActivityIdSchedaAsync(scheda.Id, scheda.ActivityId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VisibleOverlay = false;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnError(string? errorMessage)
|
||||||
|
{
|
||||||
|
if (errorMessage == null) return;
|
||||||
|
|
||||||
|
_ = ModalHelper.ShowError(Dialog, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
NewScheda.OnNewScheda -= LoadSchede;
|
NewScheda.OnNewScheda -= LoadSchede;
|
||||||
|
CompleteInspection.OnComplete -= HandleCompleteInspection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1.5rem;
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-scheda-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
}
|
}
|
||||||
@@ -100,6 +100,8 @@ else
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
|
||||||
Spinner = false;
|
Spinner = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@using SteUp.Shared.Components.Layout.Spinner
|
||||||
|
<SpinnerLayout FullScreen="true"/>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@using SteUp.Shared.Components.Pages.Utility
|
||||||
@using SteUp.Shared.Components.SingleElements.Modal.ExceptionModal
|
@using SteUp.Shared.Components.SingleElements.Modal.ExceptionModal
|
||||||
@using SteUp.Shared.Core.BarcodeReader.Contracts
|
@using SteUp.Shared.Core.BarcodeReader.Contracts
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@@ -8,21 +9,29 @@
|
|||||||
<CascadingAuthenticationState>
|
<CascadingAuthenticationState>
|
||||||
<Router AppAssembly="@typeof(Routes).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
<Router AppAssembly="@typeof(Routes).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
|
@if (!LoadData)
|
||||||
<Authorizing>
|
{
|
||||||
<p>Authorizing page</p>
|
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
|
||||||
</Authorizing>
|
<Authorizing>
|
||||||
<NotAuthorized>
|
<AuthorizingPage/>
|
||||||
@if (context.User.Identity?.IsAuthenticated != true)
|
</Authorizing>
|
||||||
{
|
<NotAuthorized>
|
||||||
NavigationManager.NavigateTo("/login");
|
@if (context.User.Identity?.IsAuthenticated != true)
|
||||||
}
|
{
|
||||||
else
|
NavigationManager.NavigateTo("/login");
|
||||||
{
|
}
|
||||||
<p role="alert">You are not authorized to access this resource.</p>
|
else
|
||||||
}
|
{
|
||||||
</NotAuthorized>
|
<p role="alert">You are not authorized to access this resource.</p>
|
||||||
</AuthorizeRouteView>
|
}
|
||||||
|
</NotAuthorized>
|
||||||
|
</AuthorizeRouteView>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<AuthorizingPage/>
|
||||||
|
}
|
||||||
|
|
||||||
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
|
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
|
||||||
</Found>
|
</Found>
|
||||||
</Router>
|
</Router>
|
||||||
@@ -38,13 +47,21 @@
|
|||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private bool LoadData { get; set; }
|
||||||
|
|
||||||
private ErrorBoundary? ErrorBoundary { get; set; }
|
private ErrorBoundary? ErrorBoundary { get; set; }
|
||||||
private ExceptionModal ExceptionModal { get; set; } = null!;
|
private ExceptionModal ExceptionModal { get; set; } = null!;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
LoadData = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
await SteupDataService.Init();
|
await SteupDataService.Init();
|
||||||
BarcodeManager.Init();
|
BarcodeManager.Init();
|
||||||
|
|
||||||
|
LoadData = false;
|
||||||
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
@using SteUp.Shared.Components.Layout.Overlay
|
@using SteUp.Shared.Components.Layout.Overlay
|
||||||
@using SteUp.Shared.Components.SingleElements.MessageBox
|
@using SteUp.Shared.Components.SingleElements.MessageBox
|
||||||
|
@using SteUp.Shared.Core.Dto
|
||||||
@using SteUp.Shared.Core.Entities
|
@using SteUp.Shared.Core.Entities
|
||||||
|
@using SteUp.Shared.Core.Enum
|
||||||
|
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||||
@using SteUp.Shared.Core.Interface.LocalDb
|
@using SteUp.Shared.Core.Interface.LocalDb
|
||||||
@inject IIspezioniService IspezioniService
|
@inject IIspezioniService IspezioniService
|
||||||
|
@inject IIntegrySteupService IntegrySteupService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
|
|
||||||
<div class="scheda-card">
|
<div class="scheda-card">
|
||||||
@@ -14,36 +18,48 @@
|
|||||||
|
|
||||||
<div class="sub-info-section">
|
<div class="sub-info-section">
|
||||||
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
|
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
|
||||||
0
|
@Scheda.ImageNames.Count()
|
||||||
</MudChip>
|
</MudChip>
|
||||||
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
|
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
|
||||||
0
|
@Scheda.Articoli.Count
|
||||||
</MudChip>
|
</MudChip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="scheda-card-action">
|
<div class="scheda-card-action">
|
||||||
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit"
|
@if (NetworkService.IsNetworkAvailable())
|
||||||
Color="Color.Info" Size="Size.Small" OnClick="@UpdateScheda">
|
{
|
||||||
Modifica
|
<MudFab Color="Color.Info" Size="Size.Small" StartIcon="@Icons.Material.Rounded.Edit" OnClick="@UpdateScheda"/>
|
||||||
</MudButton>
|
<MudFab Color="Color.Error" Size="Size.Small" StartIcon="@Icons.Material.Rounded.Delete" OnClick="@DeleteScheda"/>
|
||||||
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Delete"
|
<MudFab Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Rounded.CloudSync" OnClick="@ExportScheda"/>
|
||||||
Color="Color.Error" Size="Size.Small" OnClick="@DeleteScheda">
|
}
|
||||||
Cancella
|
else
|
||||||
</MudButton>
|
{
|
||||||
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit"
|
||||||
|
Color="Color.Info" Size="Size.Small" OnClick="@UpdateScheda">
|
||||||
|
Modifica
|
||||||
|
</MudButton>
|
||||||
|
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Delete"
|
||||||
|
Color="Color.Error" Size="Size.Small" OnClick="@DeleteScheda">
|
||||||
|
Cancella
|
||||||
|
</MudButton>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
||||||
<ConfirmDeleteMessageBox @ref="_deleteMessageBox" Message="Confermi la cancellazione della scheda corrente?"/>
|
<ConfirmDeleteMessageBox @ref="_deleteMessageBox" Message="Confermi la cancellazione della scheda corrente?"/>
|
||||||
|
|
||||||
@code{
|
@code{
|
||||||
[Parameter] public string CodMdep { get; set; } = string.Empty;
|
[Parameter] public string CodMdep { get; set; } = string.Empty;
|
||||||
[Parameter] public DateOnly Data { get; set; }
|
[Parameter] public DateTime Data { 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; }
|
||||||
|
|
||||||
|
private bool VisibleOverlay { get; set; }
|
||||||
|
|
||||||
private ConfirmDeleteMessageBox _deleteMessageBox = null!;
|
private ConfirmDeleteMessageBox _deleteMessageBox = null!;
|
||||||
|
|
||||||
private async Task UpdateScheda()
|
private async Task UpdateScheda()
|
||||||
@@ -63,4 +79,40 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ExportScheda()
|
||||||
|
{
|
||||||
|
VisibleOverlay = true;
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
var apiResponse = await IntegrySteupService.SaveScheda(
|
||||||
|
new SaveRequestDto
|
||||||
|
{
|
||||||
|
LocalIdScheda = Scheda.Id,
|
||||||
|
ActivityTypeId = Scheda.ActivityTypeId,
|
||||||
|
CodJfas = Scheda.CodJfas,
|
||||||
|
CodMdep = CodMdep,
|
||||||
|
DataCreazione = 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)
|
||||||
|
{
|
||||||
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||||
|
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
|
||||||
|
|
||||||
|
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||||
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
|
);
|
||||||
|
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
VisibleOverlay = false;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
SteupDataService.InspectionPageState.Ispezione = await IspezioniService.GetOrCreateIspezioneAsync(
|
SteupDataService.InspectionPageState.Ispezione = await IspezioniService.GetOrCreateIspezioneAsync(
|
||||||
PuntoVendita.CodMdep!,
|
PuntoVendita.CodMdep!,
|
||||||
DateOnly.FromDateTime(DateTime.Today),
|
DateTime.Now,
|
||||||
UserSession.User.Username
|
UserSession.User.Username
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
@using SteUp.Shared.Components.SingleElements.MessageBox
|
@using SteUp.Shared.Components.SingleElements.MessageBox
|
||||||
@using SteUp.Shared.Core.Dto
|
@using SteUp.Shared.Core.Dto
|
||||||
@using SteUp.Shared.Core.Entities
|
@using SteUp.Shared.Core.Entities
|
||||||
|
@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.Interface.System
|
||||||
@using SteUp.Shared.Core.Interface.System.Network
|
|
||||||
@using SteUp.Shared.Core.Messages.Scanner
|
@using SteUp.Shared.Core.Messages.Scanner
|
||||||
@inject INetworkService NetworkService
|
@inject INetworkService NetworkService
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
<CardFormModal Title="Reparto" Loading="SteupDataService.Reparti.IsNullOrEmpty()">
|
<CardFormModal Title="Reparto" Loading="SteupDataService.Reparti.IsNullOrEmpty()">
|
||||||
<MudSelectExtended ReadOnly="IsView" T="JtbFasiDto?" Variant="Variant.Text"
|
<MudSelectExtended T="JtbFasiDto?" Variant="Variant.Text"
|
||||||
@bind-Value="Scheda.Reparto" ToStringFunc="@(x => x?.Descrizione)"
|
@bind-Value="Scheda.Reparto" ToStringFunc="@(x => x?.Descrizione)"
|
||||||
@bind-Value:after="OnAfterChangeReparto" Required="true"
|
@bind-Value:after="OnAfterChangeReparto" Required="true"
|
||||||
RequiredError="Reparto obbligatorio">
|
RequiredError="Reparto obbligatorio">
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</CardFormModal>
|
</CardFormModal>
|
||||||
|
|
||||||
<CardFormModal Title="Motivo" Loading="SteupDataService.TipiAttività.IsNullOrEmpty()">
|
<CardFormModal Title="Motivo" Loading="SteupDataService.TipiAttività.IsNullOrEmpty()">
|
||||||
<MudSelectExtended ReadOnly="@(IsView || Scheda.CodJfas.IsNullOrEmpty())" T="string?"
|
<MudSelectExtended ReadOnly="@Scheda.CodJfas.IsNullOrEmpty()" T="string?"
|
||||||
Variant="Variant.Text"
|
Variant="Variant.Text"
|
||||||
@bind-Value="Scheda.ActivityTypeId" @bind-Value:after="OnAfterChangeValue"
|
@bind-Value="Scheda.ActivityTypeId" @bind-Value:after="OnAfterChangeValue"
|
||||||
Required="true" RequiredError="Motivo obbligatorio">
|
Required="true" RequiredError="Motivo obbligatorio">
|
||||||
@@ -75,10 +75,13 @@
|
|||||||
}
|
}
|
||||||
<MudCardContent Class="image_card">
|
<MudCardContent Class="image_card">
|
||||||
<MudText Typo="Typo.subtitle1"><b>@item.p.Name</b></MudText>
|
<MudText Typo="Typo.subtitle1"><b>@item.p.Name</b></MudText>
|
||||||
<MudIconButton Variant="Variant.Outlined"
|
@if (IsNew)
|
||||||
Icon="@Icons.Material.Rounded.Close"
|
{
|
||||||
Size="Size.Small" Color="Color.Error"
|
<MudIconButton Variant="Variant.Outlined"
|
||||||
OnClick="@(() => OnRemoveAttached(item.index))"/>
|
Icon="@Icons.Material.Rounded.Close"
|
||||||
|
Size="Size.Small" Color="Color.Error"
|
||||||
|
OnClick="@(() => OnRemoveAttached(item.index))"/>
|
||||||
|
}
|
||||||
</MudCardContent>
|
</MudCardContent>
|
||||||
</MudCard>
|
</MudCard>
|
||||||
}
|
}
|
||||||
@@ -87,19 +90,16 @@
|
|||||||
</CardFormModal>
|
</CardFormModal>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!IsView)
|
<div class="container-button ripple-container">
|
||||||
{
|
<MudButton Class="button-settings green-icon"
|
||||||
<div class="container-button ripple-container">
|
FullWidth="true"
|
||||||
<MudButton Class="button-settings green-icon"
|
StartIcon="@Icons.Material.Rounded.AttachFile"
|
||||||
FullWidth="true"
|
Size="Size.Medium"
|
||||||
StartIcon="@Icons.Material.Rounded.AttachFile"
|
OnClick="@OpenAddAttached"
|
||||||
Size="Size.Medium"
|
Variant="Variant.Outlined">
|
||||||
OnClick="@OpenAddAttached"
|
Aggiungi foto
|
||||||
Variant="Variant.Outlined">
|
</MudButton>
|
||||||
Aggiungi foto
|
</div>
|
||||||
</MudButton>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
<CardFormModal Title="Articoli">
|
<CardFormModal Title="Articoli">
|
||||||
<div class="input-manual-barcode">
|
<div class="input-manual-barcode">
|
||||||
@@ -113,7 +113,8 @@
|
|||||||
<div class="art-list">
|
<div class="art-list">
|
||||||
@foreach (var articolo in Scheda.Articoli)
|
@foreach (var articolo in Scheda.Articoli)
|
||||||
{
|
{
|
||||||
<MudChip T="string" OnClose="@(() => RemoveArt(articolo.Barcode))" style="height: auto;">
|
<MudChip T="string" OnClose="@(() => RemoveArt(articolo.Barcode))"
|
||||||
|
style="height: auto;">
|
||||||
<MudStack Direction="Column" Spacing="0" class="py-1">
|
<MudStack Direction="Column" Spacing="0" class="py-1">
|
||||||
<MudText Typo="Typo.subtitle2" Style="line-height: 1.1; font-weight: 700;">
|
<MudText Typo="Typo.subtitle2" Style="line-height: 1.1; font-weight: 700;">
|
||||||
@articolo.Descrizione
|
@articolo.Descrizione
|
||||||
@@ -143,23 +144,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<CardFormModal Title="Scadenza">
|
<CardFormModal Title="Scadenza">
|
||||||
<MudSelectExtended FullWidth="true" ReadOnly="@IsView" T="int" Variant="Variant.Text"
|
<MudSelectExtended FullWidth="true" T="int" Variant="Variant.Text"
|
||||||
@bind-Value="@Scheda.Scadenza" @bind-Value:after="OnAfterChangeValue">
|
@bind-Value="@Scheda.Scadenza" @bind-Value:after="OnAfterChangeValue">
|
||||||
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="24"/>
|
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="3"/>
|
||||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="168"/>
|
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="2"/>
|
||||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="730"/>
|
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="1"/>
|
||||||
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="1460"/>
|
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="0"/>
|
||||||
</MudSelectExtended>
|
</MudSelectExtended>
|
||||||
</CardFormModal>
|
</CardFormModal>
|
||||||
|
|
||||||
<CardFormModal Title="Responsabile">
|
<CardFormModal Title="Responsabile">
|
||||||
<MudTextField FullWidth="true" ReadOnly="IsView" T="string?" Variant="Variant.Text"
|
<MudTextField FullWidth="true" T="string?" Variant="Variant.Text"
|
||||||
@bind-Value="Scheda.Responsabile" @bind-Value:after="OnAfterChangeValue"
|
@bind-Value="Scheda.Responsabile" @bind-Value:after="OnAfterChangeValue"
|
||||||
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||||
</CardFormModal>
|
</CardFormModal>
|
||||||
|
|
||||||
<CardFormModal Title="Note">
|
<CardFormModal Title="Note">
|
||||||
<MudTextField ReadOnly="IsView" T="string?" Variant="Variant.Text" Lines="3"
|
<MudTextField T="string?" Variant="Variant.Text" Lines="3"
|
||||||
@bind-Value="Scheda.Note" @bind-Value:after="OnAfterChangeValue"
|
@bind-Value="Scheda.Note" @bind-Value:after="OnAfterChangeValue"
|
||||||
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||||
</CardFormModal>
|
</CardFormModal>
|
||||||
@@ -187,7 +188,7 @@
|
|||||||
@code {
|
@code {
|
||||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||||
[Parameter] public required string CodMdep { get; set; }
|
[Parameter] public required string CodMdep { get; set; }
|
||||||
[Parameter] public required DateOnly Data { get; set; }
|
[Parameter] public required DateTime Data { get; set; }
|
||||||
[Parameter] public bool IsNew { get; set; }
|
[Parameter] public bool IsNew { get; set; }
|
||||||
[Parameter] public Scheda Scheda { get; set; } = new();
|
[Parameter] public Scheda Scheda { get; set; } = new();
|
||||||
|
|
||||||
@@ -214,7 +215,7 @@
|
|||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||||
|
|
||||||
OnScannerService.OnNewScanSuccessful += HandleNewScanSuccessful;
|
OnScannerService.OnNewScanSuccessful += HandleNewScanSuccessful;
|
||||||
OnScannerService.OnErrorScan += OnErrorScan;
|
OnScannerService.OnErrorScan += OnErrorScan;
|
||||||
|
|
||||||
@@ -226,6 +227,8 @@
|
|||||||
|
|
||||||
private void LoadAttached()
|
private void LoadAttached()
|
||||||
{
|
{
|
||||||
|
if (Scheda.ImageNames == null) return;
|
||||||
|
|
||||||
FileLoading = true;
|
FileLoading = true;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
@@ -237,7 +240,8 @@
|
|||||||
CodMdep = CodMdep,
|
CodMdep = CodMdep,
|
||||||
Data = Data,
|
Data = Data,
|
||||||
Rilevatore = UserSession.User.Username
|
Rilevatore = UserSession.User.Username
|
||||||
}
|
},
|
||||||
|
Scheda.ImageNames
|
||||||
);
|
);
|
||||||
|
|
||||||
await InvokeAsync(() =>
|
await InvokeAsync(() =>
|
||||||
@@ -254,9 +258,40 @@
|
|||||||
{
|
{
|
||||||
VisibleOverlay = true;
|
VisibleOverlay = true;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
|
SaveSchedaResponseDto? apiResponse = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!IsView)
|
||||||
|
{
|
||||||
|
apiResponse = await IntegrySteupService.SaveScheda(
|
||||||
|
new SaveRequestDto
|
||||||
|
{
|
||||||
|
LocalIdScheda = Scheda.Id,
|
||||||
|
ActivityTypeId = Scheda.ActivityTypeId,
|
||||||
|
CodJfas = Scheda.CodJfas,
|
||||||
|
CodMdep = CodMdep,
|
||||||
|
DataCreazione = Data,
|
||||||
|
Note = Scheda.Note,
|
||||||
|
PersonaRif = Scheda.Responsabile,
|
||||||
|
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
|
||||||
|
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
|
||||||
|
ParentActivityId = IsNew ? null : Scheda.Ispezione?.ActivityId
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
|
||||||
|
await ModalHelper.ShowError(Dialog, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
if (IsNew) await NewSave();
|
if (IsNew) await NewSave(apiResponse);
|
||||||
else await Update();
|
else await Update(apiResponse);
|
||||||
|
|
||||||
|
if (Scheda.ActivityId.IsValorized()) await UploadFile(Scheda.ActivityId!);
|
||||||
|
|
||||||
await AttachedService.CleanTempStorageAsync();
|
await AttachedService.CleanTempStorageAsync();
|
||||||
|
|
||||||
@@ -268,7 +303,7 @@
|
|||||||
MudDialog.Close(Scheda);
|
MudDialog.Close(Scheda);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task NewSave()
|
private async Task NewSave(SaveSchedaResponseDto? apiResponse)
|
||||||
{
|
{
|
||||||
if (!AttachedList.IsNullOrEmpty())
|
if (!AttachedList.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
@@ -291,10 +326,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (apiResponse != null)
|
||||||
|
{
|
||||||
|
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||||
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
|
);
|
||||||
|
Scheda.ActivityId = apiResponse.ActivityIdScheda;
|
||||||
|
}
|
||||||
|
|
||||||
await IspezioniService.AddSchedaAsync(CodMdep, Data, UserSession.User.Username, Scheda);
|
await IspezioniService.AddSchedaAsync(CodMdep, Data, UserSession.User.Username, Scheda);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Update()
|
private async Task Update(SaveSchedaResponseDto? apiResponse)
|
||||||
{
|
{
|
||||||
if (!AttachedList.IsNullOrEmpty())
|
if (!AttachedList.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
@@ -324,7 +367,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Scheda.ActivityId = apiResponse?.ActivityIdScheda;
|
||||||
await IspezioniService.UpdateSchedaAsync(Scheda);
|
await IspezioniService.UpdateSchedaAsync(Scheda);
|
||||||
|
|
||||||
|
if (apiResponse != null)
|
||||||
|
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
|
||||||
|
UserSession.User.Username, apiResponse.ActivityIdIspezione
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UploadFile(string activityId)
|
||||||
|
{
|
||||||
|
if (AttachedList.IsNullOrEmpty()) return;
|
||||||
|
|
||||||
|
var ispezione = new Ispezione
|
||||||
|
{
|
||||||
|
CodMdep = CodMdep,
|
||||||
|
Data = Data,
|
||||||
|
Rilevatore = UserSession.User.Username
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var file in AttachedList!.Where(x => x.ToUpload))
|
||||||
|
{
|
||||||
|
if (file.FileBytes == null || file.Name == null) continue;
|
||||||
|
|
||||||
|
await IntegrySteupService.UploadFile(activityId, file.FileBytes, file.Name);
|
||||||
|
await AttachedService.MoveInspectionFileFromToUploadToFinal(ispezione, file.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Cancel()
|
private async Task Cancel()
|
||||||
@@ -436,6 +505,7 @@
|
|||||||
var target = AttachedList![AttachedList.Count - attachedList.Count + i];
|
var target = AttachedList![AttachedList.Count - attachedList.Count + i];
|
||||||
target.TempPath = origUrl;
|
target.TempPath = origUrl;
|
||||||
target.ThumbPath = thumbUrl;
|
target.ThumbPath = thumbUrl;
|
||||||
|
target.ToUpload = true;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -456,7 +526,7 @@
|
|||||||
Snackbar.Add("Selezionare prima il reparto", Severity.Error);
|
Snackbar.Add("Selezionare prima il reparto", Severity.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnLoading = true;
|
OnLoading = true;
|
||||||
TextLoading = "Download articoli in griglia";
|
TextLoading = "Download articoli in griglia";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
@@ -477,25 +547,27 @@
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
|
||||||
await InvokeAsync(() =>
|
await InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
OnLoading = false;
|
OnLoading = false;
|
||||||
TextLoading = null;
|
TextLoading = null;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
OnError(e.Message);
|
OnError(e.Message);
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var modal = await ModalHelper.OpenSelectArt(Dialog, articoli);
|
var modal = await ModalHelper.OpenSelectArt(Dialog, articoli);
|
||||||
|
|
||||||
await InvokeAsync(() =>
|
await InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
OnLoading = false;
|
OnLoading = false;
|
||||||
TextLoading = null;
|
TextLoading = null;
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -581,17 +653,17 @@
|
|||||||
{
|
{
|
||||||
OnLoading = false;
|
OnLoading = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
if (art != null)
|
if (art != null)
|
||||||
{
|
{
|
||||||
RecalcDirty(true);
|
RecalcDirty(true);
|
||||||
|
|
||||||
Scheda.Articoli.Add(new SchedaArticolo
|
Scheda.Articoli.Add(new SchedaArticolo
|
||||||
{
|
{
|
||||||
Barcode = art.Barcode,
|
Barcode = art.Barcode,
|
||||||
Descrizione = art.Descrizione
|
Descrizione = art.Descrizione
|
||||||
});
|
});
|
||||||
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -602,12 +674,14 @@
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
|
||||||
await InvokeAsync(() =>
|
await InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
OnLoading = false;
|
OnLoading = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
OnError(e.Message);
|
OnError(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,7 +701,7 @@
|
|||||||
{
|
{
|
||||||
var index = Scheda.Articoli.FindIndex(x => x.Barcode.Equals(barcode));
|
var index = Scheda.Articoli.FindIndex(x => x.Barcode.Equals(barcode));
|
||||||
if (index < 0) return;
|
if (index < 0) return;
|
||||||
|
|
||||||
RecalcDirty(true);
|
RecalcDirty(true);
|
||||||
Scheda.Articoli.RemoveAt(index);
|
Scheda.Articoli.RemoveAt(index);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Device;
|
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Device;
|
||||||
using SteUp.Shared.Core.BarcodeReader.Contracts;
|
|
||||||
using SteUp.Shared.Core.Data.Contracts;
|
using SteUp.Shared.Core.Data.Contracts;
|
||||||
using SteUp.Shared.Core.Dto;
|
using SteUp.Shared.Core.Dto;
|
||||||
using SteUp.Shared.Core.Dto.PageState;
|
using SteUp.Shared.Core.Dto.PageState;
|
||||||
|
using SteUp.Shared.Core.Helpers;
|
||||||
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 SteUp.Shared.Core.Interface.System.Network;
|
||||||
|
|
||||||
namespace SteUp.Shared.Core.Data;
|
namespace SteUp.Shared.Core.Data;
|
||||||
|
|
||||||
@@ -15,12 +16,14 @@ public class SteupDataService(
|
|||||||
IUserSession userSession,
|
IUserSession userSession,
|
||||||
IDeviceService deviceService,
|
IDeviceService deviceService,
|
||||||
IGenericSystemService genericSystemService,
|
IGenericSystemService genericSystemService,
|
||||||
|
IIspezioniService ispezioniService,
|
||||||
IDbInitializer dbInitializer) : ISteupDataService
|
IDbInitializer dbInitializer) : ISteupDataService
|
||||||
{
|
{
|
||||||
public async Task Init()
|
public async Task Init()
|
||||||
{
|
{
|
||||||
await dbInitializer.InitializeAsync();
|
await dbInitializer.InitializeAsync();
|
||||||
await LoadDataAsync();
|
await LoadDataAsync();
|
||||||
|
await CheckAndUpdateStatus();
|
||||||
RegisterAppVersion();
|
RegisterAppVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +34,48 @@ public class SteupDataService(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CheckAndUpdateStatus()
|
||||||
|
{
|
||||||
|
var ispezioni = await ispezioniService.GetAllIspezioniWithSchedeAsync();
|
||||||
|
var listActivityId = ispezioni
|
||||||
|
.Where(x => x.ActivityId != null)
|
||||||
|
.Select(x => x.ActivityId!)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (!listActivityId.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
var stati = await integrySteupService.RetrieveStatoIspezioni(
|
||||||
|
new RetrieveStatoIspezioniRequestDto
|
||||||
|
{
|
||||||
|
ActivityIdList = listActivityId
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (stati != null)
|
||||||
|
{
|
||||||
|
foreach (var stato in stati)
|
||||||
|
{
|
||||||
|
var ispezione = ispezioni.Find(x =>
|
||||||
|
x.ActivityId != null &&
|
||||||
|
x.ActivityId.EqualsIgnoreCase(stato.ActivityId)
|
||||||
|
);
|
||||||
|
|
||||||
|
var newStatus = StatusEnumHelper.ConvertToStatusEnum(stato.ActivityResultId);
|
||||||
|
|
||||||
|
if (ispezione != null && ispezione.Stato != newStatus)
|
||||||
|
{
|
||||||
|
await ispezioniService.UpdateStatoIspezioneAsync(
|
||||||
|
ispezione.CodMdep,
|
||||||
|
ispezione.Data,
|
||||||
|
ispezione.Rilevatore,
|
||||||
|
newStatus
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task LoadDataAsync()
|
private async Task LoadDataAsync()
|
||||||
{
|
{
|
||||||
if (!await userSession.IsLoggedIn()) return;
|
if (!await userSession.IsLoggedIn()) return;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class AttachedDto
|
|||||||
|
|
||||||
public bool SavedOnAppData { get; set; }
|
public bool SavedOnAppData { get; set; }
|
||||||
public bool ToRemove { get; set; }
|
public bool ToRemove { get; set; }
|
||||||
|
public bool ToUpload { get; set; }
|
||||||
|
|
||||||
public Stream? FileContent =>
|
public Stream? FileContent =>
|
||||||
FileBytes is null ? null : new MemoryStream(FileBytes);
|
FileBytes is null ? null : new MemoryStream(FileBytes);
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace SteUp.Shared.Core.Dto;
|
||||||
|
|
||||||
|
public class RetrieveStatoIspezioniRequestDto
|
||||||
|
{
|
||||||
|
[JsonPropertyName("activityIdList")]
|
||||||
|
public required List<string> ActivityIdList { get; set; }
|
||||||
|
}
|
||||||
37
SteUp.Shared/Core/Dto/SaveRequestDto.cs
Normal file
37
SteUp.Shared/Core/Dto/SaveRequestDto.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using SteUp.Shared.Core.Enum;
|
||||||
|
|
||||||
|
namespace SteUp.Shared.Core.Dto;
|
||||||
|
|
||||||
|
public class SaveRequestDto
|
||||||
|
{
|
||||||
|
[JsonPropertyName("localIdScheda")]
|
||||||
|
public int? LocalIdScheda { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("codMdep")]
|
||||||
|
public string? CodMdep { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("note")]
|
||||||
|
public string? Note { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("parentActivityId")]
|
||||||
|
public string? ParentActivityId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("activityTypeId")]
|
||||||
|
public string? ActivityTypeId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("codJfas")]
|
||||||
|
public string? CodJfas { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("personaRif")]
|
||||||
|
public string? PersonaRif { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("scandeza")]
|
||||||
|
public ScadenzaEnum Scandeza { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("dataCreazione")]
|
||||||
|
public DateTime? DataCreazione { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("barcodes")]
|
||||||
|
public List<string>? Barcodes { get; set; }
|
||||||
|
}
|
||||||
24
SteUp.Shared/Core/Dto/SaveSchedaResponseDto.cs
Normal file
24
SteUp.Shared/Core/Dto/SaveSchedaResponseDto.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace SteUp.Shared.Core.Dto;
|
||||||
|
|
||||||
|
public class SaveSchedaResponseDto
|
||||||
|
{
|
||||||
|
[JsonPropertyName("activityIdIspezione")]
|
||||||
|
public string? ActivityIdIspezione { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("activityIdScheda")]
|
||||||
|
public string? ActivityIdScheda { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("activityIdSchedaList")]
|
||||||
|
public List<SchedaActivityId>? ActivityIdSchedaList { get; set; }
|
||||||
|
|
||||||
|
public class SchedaActivityId
|
||||||
|
{
|
||||||
|
[JsonPropertyName("localId")]
|
||||||
|
public int? LocalId { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("activityId")]
|
||||||
|
public string? ActivityId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
SteUp.Shared/Core/Dto/StbActivityDto.cs
Normal file
12
SteUp.Shared/Core/Dto/StbActivityDto.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace SteUp.Shared.Core.Dto;
|
||||||
|
|
||||||
|
public class StbActivityDto
|
||||||
|
{
|
||||||
|
[JsonPropertyName("activityId")]
|
||||||
|
public string ActivityId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonPropertyName("activityResultId")]
|
||||||
|
public string ActivityResultId { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
@@ -7,10 +7,12 @@ public class Ispezione : EntityBase<Ispezione>
|
|||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public string CodMdep { get; set; } = string.Empty;
|
public string CodMdep { get; set; } = string.Empty;
|
||||||
public DateOnly Data { get; set; }
|
public DateTime Data { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Rilevatore { get; set; } = string.Empty;
|
public string Rilevatore { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string? ActivityId { get; set; }
|
||||||
|
|
||||||
public StatusEnum Stato { get; set; } = StatusEnum.InCorso;
|
public StatusEnum Stato { get; set; } = StatusEnum.InCorso;
|
||||||
|
|
||||||
public List<Scheda> Schede { get; set; } = [];
|
public List<Scheda> Schede { get; set; } = [];
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ public class Scheda : EntityBase<Scheda>
|
|||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
public string? ActivityId { get; set; }
|
||||||
public string? CodJfas { get; set; }
|
public string? CodJfas { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string CodMdep { get; set; } = string.Empty;
|
public string CodMdep { get; set; } = string.Empty;
|
||||||
public DateOnly Data { get; set; }
|
public DateTime Data { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Rilevatore { get; set; } = string.Empty;
|
public string Rilevatore { get; set; } = string.Empty;
|
||||||
public Ispezione? Ispezione { get; set; }
|
public Ispezione? Ispezione { get; set; }
|
||||||
@@ -24,7 +25,7 @@ public class Scheda : EntityBase<Scheda>
|
|||||||
public string? ActivityTypeId { get; set; }
|
public string? ActivityTypeId { get; set; }
|
||||||
public string? Note { get; set; }
|
public string? Note { get; set; }
|
||||||
public string? Responsabile { get; set; }
|
public string? Responsabile { get; set; }
|
||||||
public int Scadenza { get; set; } = 1460;
|
public int Scadenza { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public JtbFasiDto? Reparto
|
public JtbFasiDto? Reparto
|
||||||
|
|||||||
9
SteUp.Shared/Core/Enum/ScadenzaEnum.cs
Normal file
9
SteUp.Shared/Core/Enum/ScadenzaEnum.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace SteUp.Shared.Core.Enum;
|
||||||
|
|
||||||
|
public enum ScadenzaEnum
|
||||||
|
{
|
||||||
|
Bassa2Mesi = 0,
|
||||||
|
Media1Mese = 1,
|
||||||
|
Alta1Settimana = 2,
|
||||||
|
Altissima24Ore = 3
|
||||||
|
}
|
||||||
@@ -4,5 +4,6 @@ public enum StatusEnum
|
|||||||
{
|
{
|
||||||
InCorso = 0,
|
InCorso = 0,
|
||||||
Completata = 1,
|
Completata = 1,
|
||||||
Esporta = 2
|
Verifica = 2,
|
||||||
|
Annullata = 3
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ public abstract class ModalHelper
|
|||||||
return await modal.Result;
|
return await modal.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<DialogResult?> OpenFormScheda(IDialogService dialog, string codMdep, DateOnly data,
|
public static async Task<DialogResult?> OpenFormScheda(IDialogService dialog, string codMdep, DateTime data,
|
||||||
bool isNew = false, Scheda? scheda = null)
|
bool isNew = false, Scheda? scheda = null)
|
||||||
{
|
{
|
||||||
scheda = isNew && scheda == null ? new Scheda() : scheda;
|
scheda = isNew && scheda == null ? new Scheda() : scheda;
|
||||||
|
|||||||
@@ -10,9 +10,13 @@ public static class ObjectExtensions
|
|||||||
public static bool IsNullOrEmpty(this string? obj) =>
|
public static bool IsNullOrEmpty(this string? obj) =>
|
||||||
string.IsNullOrEmpty(obj);
|
string.IsNullOrEmpty(obj);
|
||||||
|
|
||||||
|
public static bool IsValorized(this string? obj) => !obj.IsNullOrEmpty();
|
||||||
|
|
||||||
public static bool EqualsIgnoreCase(this string obj, string other) =>
|
public static bool EqualsIgnoreCase(this string obj, string other) =>
|
||||||
string.Equals(obj, other, StringComparison.InvariantCultureIgnoreCase);
|
string.Equals(obj, other, StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
|
||||||
public static bool ContainsIgnoreCase(this string obj, string other) =>
|
public static bool ContainsIgnoreCase(this string obj, string other) =>
|
||||||
obj.Contains(other, StringComparison.InvariantCultureIgnoreCase);
|
obj.Contains(other, StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
|
||||||
|
public static int Count<T>(this List<T>? obj) => obj?.Count ?? 0;
|
||||||
}
|
}
|
||||||
@@ -11,18 +11,30 @@ public static class StatusEnumHelper
|
|||||||
{
|
{
|
||||||
StatusEnum.InCorso => "IN CORSO",
|
StatusEnum.InCorso => "IN CORSO",
|
||||||
StatusEnum.Completata => "COMPLETATA",
|
StatusEnum.Completata => "COMPLETATA",
|
||||||
StatusEnum.Esporta => "ESPORTATA",
|
StatusEnum.Verifica => "VERIFICA",
|
||||||
|
StatusEnum.Annullata => "ANNULLATA",
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(enumValue), enumValue, null)
|
_ => throw new ArgumentOutOfRangeException(nameof(enumValue), enumValue, null)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StatusEnum ConvertToStatusEnum(string stringValue)
|
||||||
|
{
|
||||||
|
return stringValue switch
|
||||||
|
{
|
||||||
|
"COMPLETATA" => StatusEnum.Completata,
|
||||||
|
"ANNULLATA" => StatusEnum.Annullata,
|
||||||
|
"VERIFICA" => StatusEnum.Verifica,
|
||||||
|
_ => StatusEnum.InCorso
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static Color GetColor(this StatusEnum enumValue)
|
public static Color GetColor(this StatusEnum enumValue)
|
||||||
{
|
{
|
||||||
return enumValue switch
|
return enumValue switch
|
||||||
{
|
{
|
||||||
StatusEnum.InCorso => Color.Warning,
|
StatusEnum.InCorso or StatusEnum.Verifica => Color.Warning,
|
||||||
StatusEnum.Completata or
|
StatusEnum.Completata => Color.Success,
|
||||||
StatusEnum.Esporta => Color.Success,
|
StatusEnum.Annullata => Color.Error,
|
||||||
_ => Color.Default
|
_ => Color.Default
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,11 @@ public interface IIntegrySteupService
|
|||||||
Task<List<ActivityTypeDto>> RetrieveActivityType();
|
Task<List<ActivityTypeDto>> RetrieveActivityType();
|
||||||
Task<List<ArticoliInGrigliaDto>?> RetrieveGrigliaPlu(RetrieveGrigliaPluRequestDto request);
|
Task<List<ArticoliInGrigliaDto>?> RetrieveGrigliaPlu(RetrieveGrigliaPluRequestDto request);
|
||||||
Task<ArticoliInGrigliaDto?> RetrieveArtFromBarcode(string barcode);
|
Task<ArticoliInGrigliaDto?> RetrieveArtFromBarcode(string barcode);
|
||||||
|
Task<List<StbActivityDto>?> RetrieveStatoIspezioni(RetrieveStatoIspezioniRequestDto request);
|
||||||
|
|
||||||
|
//Save
|
||||||
|
Task<SaveSchedaResponseDto?> SaveScheda(SaveRequestDto request);
|
||||||
|
Task<SaveSchedaResponseDto?> SaveMultipleSchede(List<SaveRequestDto> request);
|
||||||
|
Task CompleteInspection(string activityId);
|
||||||
|
Task UploadFile(string activityId, byte[] file, string fileName);
|
||||||
}
|
}
|
||||||
@@ -1,23 +1,27 @@
|
|||||||
using SteUp.Shared.Core.Entities;
|
using SteUp.Shared.Core.Entities;
|
||||||
|
using SteUp.Shared.Core.Enum;
|
||||||
|
|
||||||
namespace SteUp.Shared.Core.Interface.LocalDb;
|
namespace SteUp.Shared.Core.Interface.LocalDb;
|
||||||
|
|
||||||
public interface IIspezioniService
|
public interface IIspezioniService
|
||||||
{
|
{
|
||||||
// ISPEZIONI
|
// ISPEZIONI
|
||||||
Task<Ispezione?> GetIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
Task<Ispezione?> GetIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||||
Task<List<Ispezione>> GetAllIspezioniWithSchedeAsync();
|
Task<List<Ispezione>> GetAllIspezioniWithSchedeAsync();
|
||||||
Task AddIspezioneAsync(Ispezione ispezione);
|
Task AddIspezioneAsync(Ispezione ispezione);
|
||||||
Task<Ispezione> GetOrCreateIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
Task<Ispezione> GetOrCreateIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||||
Task<bool> UpdateIspezioneAsync(Ispezione ispezione);
|
Task<bool> UpdateIspezioneAsync(Ispezione ispezione);
|
||||||
Task<bool> DeleteIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
Task<bool> UpdateStatoIspezioneAsync(string codMdep, DateTime data, string rilevatore, StatusEnum stato);
|
||||||
|
Task<bool> UpdateActivityIdIspezioneAsync(string codMdep, DateTime data, string rilevatore, string? activityId);
|
||||||
|
Task<bool> DeleteIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||||
|
|
||||||
// SCHEDE
|
// SCHEDE
|
||||||
Task AddSchedaAsync(string codMdep, DateOnly data, string rilevatore, Scheda scheda);
|
Task AddSchedaAsync(string codMdep, DateTime data, string rilevatore, Scheda scheda);
|
||||||
Task<List<Scheda>> GetAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
Task<List<Scheda>> GetAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||||
Task<Scheda?> GetSchedaAsync(int schedaId);
|
Task<Scheda?> GetSchedaAsync(int schedaId);
|
||||||
Task<Scheda?> GetSchedaWithIspezioneAsync(int schedaId);
|
Task<Scheda?> GetSchedaWithIspezioneAsync(int schedaId);
|
||||||
Task<bool> UpdateSchedaAsync(Scheda scheda);
|
Task<bool> UpdateSchedaAsync(Scheda scheda);
|
||||||
|
Task<bool> UpdateActivityIdSchedaAsync(int schedaId, string? activityId);
|
||||||
Task<bool> DeleteSchedaAsync(int schedaId);
|
Task<bool> DeleteSchedaAsync(int schedaId);
|
||||||
Task<int> DeleteAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
Task<int> DeleteAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||||
}
|
}
|
||||||
@@ -8,13 +8,21 @@ public interface IAttachedService
|
|||||||
Task<AttachedDto?> SelectImageFromCamera();
|
Task<AttachedDto?> SelectImageFromCamera();
|
||||||
Task<List<AttachedDto>?> SelectImageFromGallery();
|
Task<List<AttachedDto>?> SelectImageFromGallery();
|
||||||
|
|
||||||
Task<List<AttachedDto>?> GetInspectionFiles(Ispezione ispezione);
|
Task<List<AttachedDto>?> GetInspectionFiles(Ispezione ispezione, List<string> fileNameFilter,
|
||||||
|
bool includeToUpload = true, CancellationToken ct = default);
|
||||||
|
|
||||||
Task<string?> SaveInspectionFile(Ispezione ispezione, byte[] file, string fileName, CancellationToken ct = default);
|
Task<string?> SaveInspectionFile(Ispezione ispezione, byte[] file, string fileName, CancellationToken ct = default);
|
||||||
bool RemoveInspectionFile(Ispezione ispezione, string fileName);
|
|
||||||
|
bool RemoveInspectionFile(Ispezione ispezione, string fileName, bool removeAlsoFromFinal = true,
|
||||||
|
bool removeAlsoFromToUpload = true);
|
||||||
|
|
||||||
|
Task<bool> MoveInspectionFileFromToUploadToFinal(Ispezione ispezione, string fileName, bool overwrite = true,
|
||||||
|
CancellationToken ct = default);
|
||||||
|
|
||||||
Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default);
|
Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default);
|
||||||
Task CleanTempStorageAsync(CancellationToken ct = default);
|
Task CleanTempStorageAsync(CancellationToken ct = default);
|
||||||
Task OpenFile(string fileName, string filePath);
|
Task OpenFile(string fileName, string filePath);
|
||||||
|
|
||||||
Task<(string originalUrl, string thumbUrl)> SaveAndCreateThumbAsync(byte[] bytes, string fileName, CancellationToken ct = default);
|
Task<(string originalUrl, string thumbUrl)> SaveAndCreateThumbAsync(byte[] bytes, string fileName,
|
||||||
|
CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||||
|
|
||||||
|
namespace SteUp.Shared.Core.Messages.Ispezione;
|
||||||
|
|
||||||
|
public class CompleteInspectionMessage(object? value = null) : ValueChangedMessage<object?>(value);
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
|
|
||||||
|
namespace SteUp.Shared.Core.Messages.Ispezione;
|
||||||
|
|
||||||
|
public class CompleteInspectionService
|
||||||
|
{
|
||||||
|
public event Action? OnComplete;
|
||||||
|
|
||||||
|
public CompleteInspectionService(IMessenger messenger)
|
||||||
|
{
|
||||||
|
messenger.Register<CompleteInspectionMessage>(this, (_, _) => { OnComplete?.Invoke(); });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ public class IntegryApiService(
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
using System.Net.Http.Headers;
|
||||||
|
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
||||||
using SteUp.Shared.Core.Dto;
|
using SteUp.Shared.Core.Dto;
|
||||||
using SteUp.Shared.Core.Interface.IntegryApi;
|
using SteUp.Shared.Core.Interface.IntegryApi;
|
||||||
|
|
||||||
@@ -31,5 +32,39 @@ public class IntegrySteupService(IIntegryApiRestClient integryApiRestClient) : I
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public Task<List<StbActivityDto>?> RetrieveStatoIspezioni(RetrieveStatoIspezioniRequestDto request) =>
|
||||||
|
integryApiRestClient.AuthorizedPost<List<StbActivityDto>?>($"{BaseRequest}/retrieveStatoIspezioni", request);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Save
|
||||||
|
|
||||||
|
public Task<SaveSchedaResponseDto?> SaveScheda(SaveRequestDto request) =>
|
||||||
|
integryApiRestClient.AuthorizedPost<SaveSchedaResponseDto?>($"{BaseRequest}/saveScheda", request);
|
||||||
|
|
||||||
|
public Task<SaveSchedaResponseDto?> SaveMultipleSchede(List<SaveRequestDto> request) =>
|
||||||
|
integryApiRestClient.AuthorizedPost<SaveSchedaResponseDto?>($"{BaseRequest}/saveMultipleSchede", request);
|
||||||
|
|
||||||
|
public Task CompleteInspection(string activityId) =>
|
||||||
|
integryApiRestClient.AuthorizedPost<object>(
|
||||||
|
$"{BaseRequest}/complete",
|
||||||
|
new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "activityId", activityId }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public Task UploadFile(string activityId, byte[] file, string fileName)
|
||||||
|
{
|
||||||
|
var queryParams = new Dictionary<string, object> { { "activityId", activityId } };
|
||||||
|
|
||||||
|
using var content = new MultipartFormDataContent();
|
||||||
|
var fileContent = new ByteArrayContent(file);
|
||||||
|
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
|
||||||
|
content.Add(fileContent, "file", fileName);
|
||||||
|
|
||||||
|
return integryApiRestClient.Post<object>($"{BaseRequest}/uploadAttachment", content, queryParams!);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,10 +14,12 @@
|
|||||||
@using MudExtensions
|
@using MudExtensions
|
||||||
@using SteUp.Shared.Core.Data.Contracts
|
@using SteUp.Shared.Core.Data.Contracts
|
||||||
@using SteUp.Shared.Core.Helpers
|
@using SteUp.Shared.Core.Helpers
|
||||||
|
@using SteUp.Shared.Core.Interface.System.Network
|
||||||
@using static InteractiveRenderSettings
|
@using static InteractiveRenderSettings
|
||||||
|
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IUserSession UserSession
|
@inject IUserSession UserSession
|
||||||
@inject ILocalStorage LocalStorage
|
@inject ILocalStorage LocalStorage
|
||||||
@inject ISnackbar Snackbar
|
@inject ISnackbar Snackbar
|
||||||
@inject ISteupDataService SteupDataService
|
@inject ISteupDataService SteupDataService
|
||||||
|
@inject INetworkService NetworkService
|
||||||
Reference in New Issue
Block a user