203 lines
6.3 KiB
C#
203 lines
6.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
|
|
// <Auto-Generated>
|
|
// This is here so CodeMaid doesn't reorganize this document
|
|
// </Auto-Generated>
|
|
namespace WebDoorCreator.Data.DbModels
|
|
{
|
|
/// <summary>
|
|
/// Tabella dati operation CONCRETE collegate alla porta
|
|
/// </summary>
|
|
[Table("DoorOp")]
|
|
public class DoorOpModel
|
|
{
|
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public int DoorOpId { get; set; }
|
|
|
|
/// <summary>
|
|
/// porta di riferimento
|
|
/// </summary>
|
|
public int DoorId { get; set; } = 0;
|
|
/// <summary>
|
|
/// Tipo astratto di riferimento
|
|
/// </summary>
|
|
public string ObjectId { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Descrizione
|
|
/// </summary>
|
|
public string Description { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Data inserimento ordine
|
|
/// </summary>
|
|
public DateTime DateIns { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// Codice utente che ha creato
|
|
/// </summary>
|
|
public string UserIdIns { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Data (ultima) modifica ordine
|
|
/// </summary>
|
|
public DateTime DateMod { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// Codice utente che ha creato
|
|
/// </summary>
|
|
public string UserIdMod { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Oggetto Json per specifica configurazione ammessa
|
|
/// </summary>
|
|
public string JsoncConfigVal { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Oggetto Json per salvare i VALORI selezionati
|
|
/// </summary>
|
|
public string JsoncActVal { get; set; } = "";
|
|
|
|
|
|
/// <summary>
|
|
/// Id dell'utente che ha preso conferma del template
|
|
/// </summary>
|
|
public string userConfirm { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Data e ora in cui è stata presa conferma del template
|
|
/// </summary>
|
|
public DateTime? DtConfirm { get; set; }
|
|
|
|
|
|
[ForeignKey("DoorId")]
|
|
public virtual DoorModel? DoorNav { get; set; }
|
|
|
|
//[ForeignKey("DoorOpTypId")]
|
|
//public virtual DoorOpTypeModel? DoorOpTypeNav { get; set; }
|
|
|
|
|
|
[NotMapped]
|
|
public Dictionary<string, string> CurrVals
|
|
{
|
|
get
|
|
{
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
if (!string.IsNullOrEmpty(JsoncActVal))
|
|
{
|
|
try
|
|
{
|
|
var deserialized = JsonConvert.DeserializeObject<Dictionary<string, string>>(JsoncActVal);
|
|
answ = deserialized ?? new Dictionary<string, string>();
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
JsoncActVal = JsonConvert.SerializeObject(value);
|
|
}
|
|
}
|
|
[NotMapped]
|
|
public Dictionary<string, List<string>> GraphicParams
|
|
{
|
|
get
|
|
{
|
|
Dictionary<string, List<string>> answ = new Dictionary<string, List<string>>();
|
|
if (!string.IsNullOrEmpty(JsoncConfigVal))
|
|
{
|
|
try
|
|
{
|
|
var deserialized = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(JsoncConfigVal);
|
|
answ = deserialized ?? new Dictionary<string, List<string>>();
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
JsoncConfigVal = JsonConvert.SerializeObject(value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Comparazione tra il dizionario currVal corrente e quello ricevuto
|
|
/// </summary>
|
|
/// <param name="newDict">Dizionario x comparazione</param>
|
|
/// <returns></returns>
|
|
public bool JsonActValEquals(Dictionary<string, string> newDict)
|
|
{
|
|
string JsonNewVal = JsonConvert.SerializeObject(newDict);
|
|
bool answ = JsoncActVal.Equals(JsonNewVal);
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Comparazione tra il dizionario configurazioni corrente e quello ricevuto
|
|
/// </summary>
|
|
/// <param name="newDict">Dizionario x comparazione</param>
|
|
/// <returns></returns>
|
|
public bool JsoncConfigValEquals(Dictionary<string, List<string>> newDict)
|
|
{
|
|
string JsonNewVal = JsonConvert.SerializeObject(newDict);
|
|
bool answ = JsoncConfigVal.Equals(JsonNewVal);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clone oggetto
|
|
/// </summary>
|
|
/// <param name="userName"></param>
|
|
/// <param name="doorId"></param>
|
|
/// <returns></returns>
|
|
public DoorOpModel ObjClone(string userName, int doorId)
|
|
{
|
|
DoorOpModel answ = new DoorOpModel();
|
|
DateTime adesso = DateTime.Now;
|
|
if (doorId == 0)
|
|
{
|
|
answ = new DoorOpModel()
|
|
{
|
|
DateIns = adesso,
|
|
DateMod = adesso,
|
|
UserIdIns = userName,
|
|
UserIdMod = userName,
|
|
ObjectId = ObjectId,
|
|
DoorId = DoorId,
|
|
JsoncConfigVal = JsoncConfigVal,
|
|
JsoncActVal = JsoncActVal,
|
|
userConfirm = userConfirm,
|
|
DtConfirm = DtConfirm
|
|
};
|
|
}
|
|
else
|
|
{
|
|
answ = new DoorOpModel()
|
|
{
|
|
DateIns = adesso,
|
|
DateMod = adesso,
|
|
UserIdIns = userName,
|
|
UserIdMod = userName,
|
|
ObjectId = ObjectId,
|
|
DoorId = doorId,
|
|
JsoncConfigVal = JsoncConfigVal,
|
|
JsoncActVal = JsoncActVal,
|
|
userConfirm = userConfirm,
|
|
DtConfirm = DtConfirm
|
|
};
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
}
|
|
}
|