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 SteUp.Shared.Core.Entities;
|
||||
using SteUp.Shared.Core.Enum;
|
||||
using SteUp.Shared.Core.Helpers;
|
||||
using SteUp.Shared.Core.Interface.LocalDb;
|
||||
|
||||
namespace SteUp.Data.LocalDb.EntityServices;
|
||||
|
||||
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
|
||||
.Include(x => x.Schede)
|
||||
.ThenInclude(s => s.Articoli)
|
||||
@@ -29,7 +31,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||
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
|
||||
.AsNoTracking()
|
||||
@@ -66,10 +68,45 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||
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>
|
||||
/// Cancella l'ispezione e tutte le schede collegate (e relativi articoli via cascade).
|
||||
/// </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
|
||||
.FirstOrDefaultAsync(x =>
|
||||
@@ -85,7 +122,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||
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);
|
||||
|
||||
@@ -105,7 +142,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||
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
|
||||
.AsNoTracking()
|
||||
.Include(s => s.Articoli)
|
||||
@@ -127,6 +164,17 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||
.AsNoTracking()
|
||||
.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)
|
||||
{
|
||||
var scheda = await db.Schede.FirstOrDefaultAsync(x => x.Id == schedaId);
|
||||
@@ -197,7 +245,7 @@ public class IspezioniService(AppDbContext db) : IIspezioniService
|
||||
/// <summary>
|
||||
/// Cancella tutte le schede di una ispezione senza cancellare l'ispezione.
|
||||
/// </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
|
||||
.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")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateOnly>("Data")
|
||||
b.Property<DateTime>("Data")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Rilevatore")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ActivityId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Stato")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
@@ -42,6 +45,9 @@ namespace SteUp.Data.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ActivityId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ActivityTypeId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
@@ -52,7 +58,7 @@ namespace SteUp.Data.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateOnly>("Data")
|
||||
b.Property<DateTime>("Data")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
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.System;
|
||||
using SteUp.Shared.Core.Interface.System.Network;
|
||||
using SteUp.Shared.Core.Messages.Ispezione;
|
||||
using SteUp.Shared.Core.Messages.Scanner;
|
||||
using SteUp.Shared.Core.Messages.Scheda;
|
||||
using SteUp.Shared.Core.Services;
|
||||
@@ -60,6 +61,7 @@ public static class CoreModule
|
||||
builder.Services.AddSingleton<IMessenger, WeakReferenceMessenger>();
|
||||
builder.Services.AddSingleton<NewSchedaService>();
|
||||
builder.Services.AddSingleton<OnScannerService>();
|
||||
builder.Services.AddSingleton<CompleteInspectionService>();
|
||||
}
|
||||
|
||||
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.Helpers;
|
||||
using SteUp.Shared.Core.Interface.System;
|
||||
@@ -82,7 +81,7 @@ 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(
|
||||
await File.ReadAllBytesAsync(file.FullName),
|
||||
@@ -96,64 +95,202 @@ public class AttachedService : IAttachedService
|
||||
TempPath = origUrl,
|
||||
ThumbPath = thumbUrl,
|
||||
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 inspectionDir = Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
||||
var directory = new DirectoryInfo(inspectionDir);
|
||||
return Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
||||
}
|
||||
|
||||
if (!directory.Exists) return null;
|
||||
private string GetInspectionToUploadDir(Ispezione ispezione)
|
||||
=> Path.Combine(GetInspectionBaseDir(ispezione), ToUploadFolderName);
|
||||
|
||||
var fileList = directory.GetFiles().ToList();
|
||||
private string GetInspectionFinalDir(Ispezione ispezione)
|
||||
=> GetInspectionBaseDir(ispezione);
|
||||
|
||||
var returnList = new List<AttachedDto>();
|
||||
foreach (var file in fileList)
|
||||
/// <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)
|
||||
{
|
||||
returnList.Add(await ConvertToDto(file, AttachedDto.TypeAttached.Image));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
return returnList;
|
||||
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));
|
||||
}
|
||||
|
||||
public async Task<string?> SaveInspectionFile(Ispezione ispezione, byte[] file, string fileName,
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva SEMPRE in /toUpload.
|
||||
/// </summary>
|
||||
public async Task<string?> SaveInspectionFile(
|
||||
Ispezione ispezione,
|
||||
byte[] file,
|
||||
string fileName,
|
||||
CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(ispezione);
|
||||
ArgumentNullException.ThrowIfNull(file);
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
|
||||
|
||||
var baseDir = FileSystem.AppDataDirectory;
|
||||
var inspectionDir = Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
||||
if (!Directory.Exists(inspectionDir)) Directory.CreateDirectory(inspectionDir);
|
||||
var toUploadDir = GetInspectionToUploadDir(ispezione);
|
||||
Directory.CreateDirectory(toUploadDir);
|
||||
|
||||
var filePath = Path.Combine(inspectionDir, fileName);
|
||||
var filePath = Path.Combine(toUploadDir, fileName);
|
||||
await File.WriteAllBytesAsync(filePath, file, ct);
|
||||
|
||||
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;
|
||||
var inspectionDir = Path.Combine(baseDir, $"attached_{GetInspectionKey(ispezione)}");
|
||||
ArgumentNullException.ThrowIfNull(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;
|
||||
|
||||
var filePath = Path.Combine(inspectionDir, fileName);
|
||||
var removed = false;
|
||||
|
||||
if (!File.Exists(filePath)) return false;
|
||||
if (removeAlsoFromToUpload)
|
||||
{
|
||||
var toUploadPath = Path.Combine(GetInspectionToUploadDir(ispezione), fileName);
|
||||
if (File.Exists(toUploadPath))
|
||||
{
|
||||
File.Delete(toUploadPath);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
|
||||
File.Delete(filePath);
|
||||
if (removeAlsoFromFinal)
|
||||
{
|
||||
var finalPath = Path.Combine(GetInspectionFinalDir(ispezione), fileName);
|
||||
if (File.Exists(finalPath))
|
||||
{
|
||||
File.Delete(finalPath);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Directory.EnumerateFileSystemEntries(inspectionDir).Any())
|
||||
Directory.Delete(inspectionDir);
|
||||
if (removed)
|
||||
CleanupDirectoriesIfEmpty(ispezione);
|
||||
|
||||
return true;
|
||||
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)
|
||||
|
||||
@@ -123,6 +123,8 @@ public partial class HoneywellScannerService
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
|
||||
service.OnScanFailed?.Invoke(ex);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
@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.Messages.Ispezione
|
||||
@using SteUp.Shared.Core.Messages.Scheda
|
||||
@inject INetworkService NetworkService
|
||||
@inject IDialogService Dialog
|
||||
@@ -31,11 +34,18 @@
|
||||
|
||||
@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"
|
||||
StartIcon="@Icons.Material.Filled.Add"
|
||||
IconColor="Color.Primary" Color="Color.Surface" AlignItems="AlignItems.End"
|
||||
Size="Size.Medium" IconSize="Size.Medium">
|
||||
@if (SchedaVisible)
|
||||
{
|
||||
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"/>
|
||||
}
|
||||
@@ -53,6 +63,7 @@
|
||||
{
|
||||
private bool IsVisible { get; set; } = true;
|
||||
private bool PlusVisible { get; set; } = true;
|
||||
private bool ShowCompleteInspection { get; set; }
|
||||
private bool SchedaVisible { get; set; }
|
||||
|
||||
protected override Task OnInitializedAsync()
|
||||
@@ -81,6 +92,9 @@
|
||||
_ = ModalHelper.OpenSelectShop(Dialog);
|
||||
}
|
||||
|
||||
private void CompleteInspection() =>
|
||||
Messenger.Send(new CompleteInspectionMessage());
|
||||
|
||||
private async Task NewScheda()
|
||||
{
|
||||
var ispezione = SteupDataService.InspectionPageState.Ispezione;
|
||||
@@ -95,6 +109,7 @@
|
||||
var location = NavigationManager.Uri.Remove(0, NavigationManager.BaseUri.Length);
|
||||
|
||||
SchedaVisible = new List<string> { "ispezione" }.Contains(location);
|
||||
ShowCompleteInspection = !SteupDataService.InspectionPageState.Ispezione.ActivityId.IsNullOrEmpty();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
@page "/ispezione"
|
||||
@using SteUp.Shared.Components.Layout
|
||||
@using SteUp.Shared.Components.Layout.Overlay
|
||||
@using SteUp.Shared.Components.SingleElements.Card
|
||||
@using SteUp.Shared.Core.Dto
|
||||
@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.Messages.Ispezione
|
||||
@using SteUp.Shared.Core.Messages.Scheda
|
||||
@inject NewSchedaService NewScheda
|
||||
@inject CompleteInspectionService CompleteInspection
|
||||
@inject IIspezioniService IspezioniService
|
||||
@inject IDialogService Dialog
|
||||
@inject IIntegrySteupService IntegrySteupService
|
||||
@implements IDisposable
|
||||
|
||||
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
|
||||
@@ -30,9 +36,23 @@
|
||||
</MudChip>
|
||||
</div>
|
||||
<div class="action-scheda-group">
|
||||
<MudIconButton Variant="Variant.Filled" Icon="@Icons.Material.Rounded.Add"
|
||||
@if (NetworkService.IsNetworkAvailable())
|
||||
{
|
||||
<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>
|
||||
</TitleContent>
|
||||
@@ -51,13 +71,18 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
||||
|
||||
@code {
|
||||
private List<Scheda> SchedeList { get; set; } = [];
|
||||
private Dictionary<JtbFasiDto, List<Scheda>> SchedeGrouped { get; set; } = [];
|
||||
|
||||
private bool VisibleOverlay { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
NewScheda.OnNewScheda += LoadSchede;
|
||||
CompleteInspection.OnComplete += HandleCompleteInspection;
|
||||
|
||||
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()
|
||||
{
|
||||
SchedeGrouped = SchedeList
|
||||
@@ -117,9 +184,73 @@
|
||||
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()
|
||||
{
|
||||
NewScheda.OnNewScheda -= LoadSchede;
|
||||
CompleteInspection.OnComplete -= HandleCompleteInspection;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,3 +3,9 @@
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.action-scheda-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
}
|
||||
@@ -100,6 +100,8 @@ else
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
Spinner = false;
|
||||
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.Core.BarcodeReader.Contracts
|
||||
@inject NavigationManager NavigationManager
|
||||
@@ -8,9 +9,11 @@
|
||||
<CascadingAuthenticationState>
|
||||
<Router AppAssembly="@typeof(Routes).Assembly" NotFoundPage="typeof(Pages.NotFound)">
|
||||
<Found Context="routeData">
|
||||
@if (!LoadData)
|
||||
{
|
||||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)">
|
||||
<Authorizing>
|
||||
<p>Authorizing page</p>
|
||||
<AuthorizingPage/>
|
||||
</Authorizing>
|
||||
<NotAuthorized>
|
||||
@if (context.User.Identity?.IsAuthenticated != true)
|
||||
@@ -23,6 +26,12 @@
|
||||
}
|
||||
</NotAuthorized>
|
||||
</AuthorizeRouteView>
|
||||
}
|
||||
else
|
||||
{
|
||||
<AuthorizingPage/>
|
||||
}
|
||||
|
||||
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
|
||||
</Found>
|
||||
</Router>
|
||||
@@ -38,13 +47,21 @@
|
||||
</ErrorBoundary>
|
||||
|
||||
@code {
|
||||
private bool LoadData { get; set; }
|
||||
|
||||
private ErrorBoundary? ErrorBoundary { get; set; }
|
||||
private ExceptionModal ExceptionModal { get; set; } = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
LoadData = true;
|
||||
StateHasChanged();
|
||||
|
||||
await SteupDataService.Init();
|
||||
BarcodeManager.Init();
|
||||
|
||||
LoadData = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
@using SteUp.Shared.Components.Layout.Overlay
|
||||
@using SteUp.Shared.Components.SingleElements.MessageBox
|
||||
@using SteUp.Shared.Core.Dto
|
||||
@using SteUp.Shared.Core.Entities
|
||||
@using SteUp.Shared.Core.Enum
|
||||
@using SteUp.Shared.Core.Interface.IntegryApi
|
||||
@using SteUp.Shared.Core.Interface.LocalDb
|
||||
@inject IIspezioniService IspezioniService
|
||||
@inject IIntegrySteupService IntegrySteupService
|
||||
@inject IDialogService Dialog
|
||||
|
||||
<div class="scheda-card">
|
||||
@@ -14,15 +18,23 @@
|
||||
|
||||
<div class="sub-info-section">
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
|
||||
0
|
||||
@Scheda.ImageNames.Count()
|
||||
</MudChip>
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
|
||||
0
|
||||
@Scheda.Articoli.Count
|
||||
</MudChip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="scheda-card-action">
|
||||
@if (NetworkService.IsNetworkAvailable())
|
||||
{
|
||||
<MudFab Color="Color.Info" Size="Size.Small" StartIcon="@Icons.Material.Rounded.Edit" OnClick="@UpdateScheda"/>
|
||||
<MudFab Color="Color.Error" Size="Size.Small" StartIcon="@Icons.Material.Rounded.Delete" OnClick="@DeleteScheda"/>
|
||||
<MudFab Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Rounded.CloudSync" OnClick="@ExportScheda"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit"
|
||||
Color="Color.Info" Size="Size.Small" OnClick="@UpdateScheda">
|
||||
Modifica
|
||||
@@ -31,19 +43,23 @@
|
||||
Color="Color.Error" Size="Size.Small" OnClick="@DeleteScheda">
|
||||
Cancella
|
||||
</MudButton>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
|
||||
<ConfirmDeleteMessageBox @ref="_deleteMessageBox" Message="Confermi la cancellazione della scheda corrente?"/>
|
||||
|
||||
@code{
|
||||
[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 EventCallback<Scheda> OnSchedaModified { get; set; }
|
||||
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
|
||||
|
||||
private bool VisibleOverlay { get; set; }
|
||||
|
||||
private ConfirmDeleteMessageBox _deleteMessageBox = null!;
|
||||
|
||||
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(
|
||||
PuntoVendita.CodMdep!,
|
||||
DateOnly.FromDateTime(DateTime.Today),
|
||||
DateTime.Now,
|
||||
UserSession.User.Username
|
||||
);
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
@using SteUp.Shared.Components.SingleElements.MessageBox
|
||||
@using SteUp.Shared.Core.Dto
|
||||
@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.System
|
||||
@using SteUp.Shared.Core.Interface.System.Network
|
||||
@using SteUp.Shared.Core.Messages.Scanner
|
||||
@inject INetworkService NetworkService
|
||||
@inject IDialogService Dialog
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="content">
|
||||
|
||||
<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:after="OnAfterChangeReparto" Required="true"
|
||||
RequiredError="Reparto obbligatorio">
|
||||
@@ -41,7 +41,7 @@
|
||||
</CardFormModal>
|
||||
|
||||
<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"
|
||||
@bind-Value="Scheda.ActivityTypeId" @bind-Value:after="OnAfterChangeValue"
|
||||
Required="true" RequiredError="Motivo obbligatorio">
|
||||
@@ -75,10 +75,13 @@
|
||||
}
|
||||
<MudCardContent Class="image_card">
|
||||
<MudText Typo="Typo.subtitle1"><b>@item.p.Name</b></MudText>
|
||||
@if (IsNew)
|
||||
{
|
||||
<MudIconButton Variant="Variant.Outlined"
|
||||
Icon="@Icons.Material.Rounded.Close"
|
||||
Size="Size.Small" Color="Color.Error"
|
||||
OnClick="@(() => OnRemoveAttached(item.index))"/>
|
||||
}
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
}
|
||||
@@ -87,8 +90,6 @@
|
||||
</CardFormModal>
|
||||
}
|
||||
|
||||
@if (!IsView)
|
||||
{
|
||||
<div class="container-button ripple-container">
|
||||
<MudButton Class="button-settings green-icon"
|
||||
FullWidth="true"
|
||||
@@ -99,7 +100,6 @@
|
||||
Aggiungi foto
|
||||
</MudButton>
|
||||
</div>
|
||||
}
|
||||
|
||||
<CardFormModal Title="Articoli">
|
||||
<div class="input-manual-barcode">
|
||||
@@ -113,7 +113,8 @@
|
||||
<div class="art-list">
|
||||
@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">
|
||||
<MudText Typo="Typo.subtitle2" Style="line-height: 1.1; font-weight: 700;">
|
||||
@articolo.Descrizione
|
||||
@@ -143,23 +144,23 @@
|
||||
}
|
||||
|
||||
<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">
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="24"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="168"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="730"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="1460"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="3"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="2"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="1"/>
|
||||
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="0"/>
|
||||
</MudSelectExtended>
|
||||
</CardFormModal>
|
||||
|
||||
<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"
|
||||
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</CardFormModal>
|
||||
|
||||
<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"
|
||||
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
|
||||
</CardFormModal>
|
||||
@@ -187,7 +188,7 @@
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
[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 Scheda Scheda { get; set; } = new();
|
||||
|
||||
@@ -226,6 +227,8 @@
|
||||
|
||||
private void LoadAttached()
|
||||
{
|
||||
if (Scheda.ImageNames == null) return;
|
||||
|
||||
FileLoading = true;
|
||||
StateHasChanged();
|
||||
|
||||
@@ -237,7 +240,8 @@
|
||||
CodMdep = CodMdep,
|
||||
Data = Data,
|
||||
Rilevatore = UserSession.User.Username
|
||||
}
|
||||
},
|
||||
Scheda.ImageNames
|
||||
);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
@@ -255,8 +259,39 @@
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
if (IsNew) await NewSave();
|
||||
else await Update();
|
||||
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(apiResponse);
|
||||
else await Update(apiResponse);
|
||||
|
||||
if (Scheda.ActivityId.IsValorized()) await UploadFile(Scheda.ActivityId!);
|
||||
|
||||
await AttachedService.CleanTempStorageAsync();
|
||||
|
||||
@@ -268,7 +303,7 @@
|
||||
MudDialog.Close(Scheda);
|
||||
}
|
||||
|
||||
private async Task NewSave()
|
||||
private async Task NewSave(SaveSchedaResponseDto? apiResponse)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
private async Task Update()
|
||||
private async Task Update(SaveSchedaResponseDto? apiResponse)
|
||||
{
|
||||
if (!AttachedList.IsNullOrEmpty())
|
||||
{
|
||||
@@ -324,7 +367,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
Scheda.ActivityId = apiResponse?.ActivityIdScheda;
|
||||
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()
|
||||
@@ -436,6 +505,7 @@
|
||||
var target = AttachedList![AttachedList.Count - attachedList.Count + i];
|
||||
target.TempPath = origUrl;
|
||||
target.ThumbPath = thumbUrl;
|
||||
target.ToUpload = true;
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
@@ -477,6 +547,8 @@
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
OnLoading = false;
|
||||
@@ -602,6 +674,8 @@
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
OnLoading = false;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Device;
|
||||
using SteUp.Shared.Core.BarcodeReader.Contracts;
|
||||
using SteUp.Shared.Core.Data.Contracts;
|
||||
using SteUp.Shared.Core.Dto;
|
||||
using SteUp.Shared.Core.Dto.PageState;
|
||||
using SteUp.Shared.Core.Helpers;
|
||||
using SteUp.Shared.Core.Interface.IntegryApi;
|
||||
using SteUp.Shared.Core.Interface.LocalDb;
|
||||
using SteUp.Shared.Core.Interface.System;
|
||||
using SteUp.Shared.Core.Interface.System.Network;
|
||||
|
||||
namespace SteUp.Shared.Core.Data;
|
||||
|
||||
@@ -15,12 +16,14 @@ public class SteupDataService(
|
||||
IUserSession userSession,
|
||||
IDeviceService deviceService,
|
||||
IGenericSystemService genericSystemService,
|
||||
IIspezioniService ispezioniService,
|
||||
IDbInitializer dbInitializer) : ISteupDataService
|
||||
{
|
||||
public async Task Init()
|
||||
{
|
||||
await dbInitializer.InitializeAsync();
|
||||
await LoadDataAsync();
|
||||
await CheckAndUpdateStatus();
|
||||
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()
|
||||
{
|
||||
if (!await userSession.IsLoggedIn()) return;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class AttachedDto
|
||||
|
||||
public bool SavedOnAppData { get; set; }
|
||||
public bool ToRemove { get; set; }
|
||||
public bool ToUpload { get; set; }
|
||||
|
||||
public Stream? FileContent =>
|
||||
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]
|
||||
public string CodMdep { get; set; } = string.Empty;
|
||||
public DateOnly Data { get; set; }
|
||||
public DateTime Data { get; set; }
|
||||
[Required]
|
||||
public string Rilevatore { get; set; } = string.Empty;
|
||||
|
||||
public string? ActivityId { get; set; }
|
||||
|
||||
public StatusEnum Stato { get; set; } = StatusEnum.InCorso;
|
||||
|
||||
public List<Scheda> Schede { get; set; } = [];
|
||||
|
||||
@@ -8,11 +8,12 @@ public class Scheda : EntityBase<Scheda>
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string? ActivityId { get; set; }
|
||||
public string? CodJfas { get; set; }
|
||||
|
||||
[Required]
|
||||
public string CodMdep { get; set; } = string.Empty;
|
||||
public DateOnly Data { get; set; }
|
||||
public DateTime Data { get; set; }
|
||||
[Required]
|
||||
public string Rilevatore { get; set; } = string.Empty;
|
||||
public Ispezione? Ispezione { get; set; }
|
||||
@@ -24,7 +25,7 @@ public class Scheda : EntityBase<Scheda>
|
||||
public string? ActivityTypeId { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public string? Responsabile { get; set; }
|
||||
public int Scadenza { get; set; } = 1460;
|
||||
public int Scadenza { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
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,
|
||||
Completata = 1,
|
||||
Esporta = 2
|
||||
Verifica = 2,
|
||||
Annullata = 3
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public abstract class ModalHelper
|
||||
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)
|
||||
{
|
||||
scheda = isNew && scheda == null ? new Scheda() : scheda;
|
||||
|
||||
@@ -10,9 +10,13 @@ public static class ObjectExtensions
|
||||
public static bool IsNullOrEmpty(this string? obj) =>
|
||||
string.IsNullOrEmpty(obj);
|
||||
|
||||
public static bool IsValorized(this string? obj) => !obj.IsNullOrEmpty();
|
||||
|
||||
public static bool EqualsIgnoreCase(this string obj, string other) =>
|
||||
string.Equals(obj, other, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
public static bool ContainsIgnoreCase(this string obj, string other) =>
|
||||
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.Completata => "COMPLETATA",
|
||||
StatusEnum.Esporta => "ESPORTATA",
|
||||
StatusEnum.Verifica => "VERIFICA",
|
||||
StatusEnum.Annullata => "ANNULLATA",
|
||||
_ => 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)
|
||||
{
|
||||
return enumValue switch
|
||||
{
|
||||
StatusEnum.InCorso => Color.Warning,
|
||||
StatusEnum.Completata or
|
||||
StatusEnum.Esporta => Color.Success,
|
||||
StatusEnum.InCorso or StatusEnum.Verifica => Color.Warning,
|
||||
StatusEnum.Completata => Color.Success,
|
||||
StatusEnum.Annullata => Color.Error,
|
||||
_ => Color.Default
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,4 +10,11 @@ public interface IIntegrySteupService
|
||||
Task<List<ActivityTypeDto>> RetrieveActivityType();
|
||||
Task<List<ArticoliInGrigliaDto>?> RetrieveGrigliaPlu(RetrieveGrigliaPluRequestDto request);
|
||||
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.Enum;
|
||||
|
||||
namespace SteUp.Shared.Core.Interface.LocalDb;
|
||||
|
||||
public interface IIspezioniService
|
||||
{
|
||||
// ISPEZIONI
|
||||
Task<Ispezione?> GetIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
||||
Task<Ispezione?> GetIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||
Task<List<Ispezione>> GetAllIspezioniWithSchedeAsync();
|
||||
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> 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
|
||||
Task AddSchedaAsync(string codMdep, DateOnly data, string rilevatore, Scheda scheda);
|
||||
Task<List<Scheda>> GetAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
|
||||
Task AddSchedaAsync(string codMdep, DateTime data, string rilevatore, Scheda scheda);
|
||||
Task<List<Scheda>> GetAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore);
|
||||
Task<Scheda?> GetSchedaAsync(int schedaId);
|
||||
Task<Scheda?> GetSchedaWithIspezioneAsync(int schedaId);
|
||||
Task<bool> UpdateSchedaAsync(Scheda scheda);
|
||||
Task<bool> UpdateActivityIdSchedaAsync(int schedaId, string? activityId);
|
||||
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<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);
|
||||
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 CleanTempStorageAsync(CancellationToken ct = default);
|
||||
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)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
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.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
|
||||
|
||||
#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,6 +14,7 @@
|
||||
@using MudExtensions
|
||||
@using SteUp.Shared.Core.Data.Contracts
|
||||
@using SteUp.Shared.Core.Helpers
|
||||
@using SteUp.Shared.Core.Interface.System.Network
|
||||
@using static InteractiveRenderSettings
|
||||
|
||||
@inject NavigationManager NavigationManager
|
||||
@@ -21,3 +22,4 @@
|
||||
@inject ILocalStorage LocalStorage
|
||||
@inject ISnackbar Snackbar
|
||||
@inject ISteupDataService SteupDataService
|
||||
@inject INetworkService NetworkService
|
||||
Reference in New Issue
Block a user