diff --git a/LiMan.DB/Controllers/DbController.cs b/LiMan.DB/Controllers/DbController.cs
index c315665..60c433a 100644
--- a/LiMan.DB/Controllers/DbController.cs
+++ b/LiMan.DB/Controllers/DbController.cs
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration;
using NLog;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
@@ -277,6 +278,74 @@ namespace LiMan.DB.Controllers
//Log.Info("Dispose di GWMSController");
}
+ ///
+ /// Elenco files attach da registrare
+ ///
+ /// Identificativo del ticket
+ /// Directory di salvataggio dei file
+ /// lista risultati della funzione di upload
+ ///
+ public bool FileAdd(int idxTicket, string baseDir, List fileUploaded)
+ {
+ bool fatto = false;
+ if (fileUploaded == null || fileUploaded.Count == 0)
+ {
+ Log.Error("Errore FileAdd: fileUploaded è vuoto/nullo");
+ }
+ else
+ {
+ using (LMDbContext localDbCtx = new LMDbContext(_configuration))
+ {
+ // verifico Ticket sia esistente
+ var currTicket = localDbCtx
+ .DbSetTicket
+ .Where(x => x.IdxTicket == idxTicket)
+ .FirstOrDefault();
+
+ if (currTicket != null)
+ {
+ var newFiles = fileUploaded
+ .Select(x => new FileAttachModel()
+ {
+ IdxTicket = idxTicket,
+ OriginalName = x.FileName,
+ StorageName = x.StoredFileName,
+ DtEvent = DateTime.Now,
+ FullStoragePath = Path.Combine(baseDir, x.StoredFileName)
+ }).ToList();
+
+ localDbCtx
+ .DbSetFileAttach
+ .AddRange(newFiles);
+
+ localDbCtx.SaveChanges();
+
+ fatto = true;
+ }
+ }
+ }
+ return fatto;
+ }
+
+ ///
+ /// Elenco file registrati dato ticket id
+ ///
+ /// Identificativo del ticket
+ ///
+ public List FileGetFilt(int idxTicket)
+ {
+ List dbResult = new List();
+ using (LMDbContext localDbCtx = new LMDbContext(_configuration))
+ {
+ // recupero locenza...
+ dbResult = localDbCtx
+ .DbSetFileAttach
+ .Where(x => x.IdxTicket == idxTicket)
+ .ToList();
+ }
+ return dbResult;
+ }
+
public List GetApplicativiFilt(bool OnlyActive, string CodApp, string CodInst, bool hideData)
{
List dbResult = new List();
@@ -775,7 +844,8 @@ namespace LiMan.DB.Controllers
ContactPhone = currRequest.ContactPhone,
ReqBody = currRequest.ReqBody,
Status = Enum.StatoRichiesta.Richiesta,
- Tipo = Enum.TipoLicenza.UserKey
+ Tipo = Enum.TipoLicenza.UserKey,
+ TType = currRequest.Tipo
};
localDbCtx
@@ -790,7 +860,7 @@ namespace LiMan.DB.Controllers
return fatto;
}
- public List TicketGetFilt(bool onlyOpen, string CodApp, string CodInst, string MasterKey, int maxNum)
+ public List TicketGetFilt(bool onlyOpen, TipologiaTicket Tipo, string CodApp, string CodInst, string MasterKey, int maxNum)
{
List dbResult = new List();
using (LMDbContext localDbCtx = new LMDbContext(_configuration))
@@ -805,7 +875,7 @@ namespace LiMan.DB.Controllers
{
dbResult = localDbCtx
.DbSetTicket
- .Where(x => x.IdxLic == currLic.IdxLic)
+ .Where(x => x.IdxLic == currLic.IdxLic && (x.TType == Tipo || Tipo == TipologiaTicket.ND))
.OrderByDescending(x => x.DtReq)
.Take(maxNum)
.Select(x => new TicketDTO
@@ -823,7 +893,7 @@ namespace LiMan.DB.Controllers
SupplAnsw = x.SupplAnsw,
SupplEmail = x.SupplEmail,
SupplUserCode = x.SupplUserCode,
- Tipo= x.Tipo
+ Tipo = x.Tipo
})
.ToList();
}
diff --git a/LiMan.DB/DBModels/FileAttachModel.cs b/LiMan.DB/DBModels/FileAttachModel.cs
new file mode 100644
index 0000000..97c748e
--- /dev/null
+++ b/LiMan.DB/DBModels/FileAttachModel.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using static LiMan.DB.Enum;
+
+#nullable disable
+
+namespace LiMan.DB.DBModels
+{
+ //
+ // This is here so CodeMaid doesn't reorganize this document
+ //
+ //[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))]
+ [Table("FileAttach")]
+ public partial class FileAttachModel
+ {
+ #region Public Properties
+
+ [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+ public int IdxFileAttach { get; set; }
+
+ ///
+ /// Id del ticket cui è collegato
+ ///
+ public int IdxTicket { get; set; }
+
+ ///
+ /// DataOra evento
+ ///
+ public DateTime DtEvent { get; set; } = DateTime.Now;
+
+ ///
+ /// Codice univoco della sub licenza (opzionale)
+ ///
+ public string OriginalName { get; set; } = "";
+
+ ///
+ /// Nome con cui è salvato il file localmente
+ ///
+ public string StorageName { get; set; } = "";
+
+ ///
+ /// Path completo del file
+ ///
+ public string FullStoragePath { get; set; } = "";
+
+ [ForeignKey("IdxTicket")]
+ public virtual TicketModel TicketNav { get; set; }
+
+ #endregion Public Properties
+ }
+}
\ No newline at end of file
diff --git a/LiMan.DB/DBModels/TicketModel.cs b/LiMan.DB/DBModels/TicketModel.cs
index ee3f55a..ad03fbf 100644
--- a/LiMan.DB/DBModels/TicketModel.cs
+++ b/LiMan.DB/DBModels/TicketModel.cs
@@ -1,5 +1,5 @@
-using System;
-using System.Collections.Generic;
+using Core;
+using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static LiMan.DB.Enum;
@@ -11,7 +11,6 @@ namespace LiMan.DB.DBModels
//
// This is here so CodeMaid doesn't reorganize this document
//
- //[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))]
[Table("TicketLog")]
public partial class TicketModel
{
@@ -22,6 +21,11 @@ namespace LiMan.DB.DBModels
public DateTime DtReq { get; set; } = DateTime.Now;
+ ///
+ /// Tipologia di ticket
+ ///
+ public TipologiaTicket TType { get; set; } = TipologiaTicket.Licenze;
+
///
/// Tipologia di licenza gestita
///
diff --git a/LiMan.DB/Enum.cs b/LiMan.DB/Enum.cs
index 7c7feec..1ed38f6 100644
--- a/LiMan.DB/Enum.cs
+++ b/LiMan.DB/Enum.cs
@@ -51,6 +51,8 @@ namespace LiMan.DB
CheckSumKey
}
+
+
#endregion Public Enums
}
}
\ No newline at end of file
diff --git a/LiMan.DB/LMDbContext.cs b/LiMan.DB/LMDbContext.cs
index 27a1305..3b2ee9d 100644
--- a/LiMan.DB/LMDbContext.cs
+++ b/LiMan.DB/LMDbContext.cs
@@ -49,6 +49,7 @@ namespace LiMan.DB
#region Public Properties
public virtual DbSet DbSetApp { get; set; }
+ public virtual DbSet DbSetFileAttach { get; set; }
public virtual DbSet DbSetInst { get; set; }
public virtual DbSet DbSetLicenze { get; set; }
public virtual DbSet DbSetLogCall { get; set; }
@@ -57,7 +58,7 @@ namespace LiMan.DB
public virtual DbSet DbSetTicket { get; set; }
#endregion Public Properties
-
+
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);