90 lines
3.4 KiB
C#
90 lines
3.4 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using static Core.Enum;
|
|
|
|
namespace Core
|
|
{
|
|
public class SupportRequest
|
|
{
|
|
#region Public Properties
|
|
|
|
public string CodApp { get; set; } = "";
|
|
public string CodImp { get; set; } = "";
|
|
public string CodInst { get; set; } = "";
|
|
public string ContactEmail { get; set; } = "";
|
|
public string ContactName { get; set; } = "";
|
|
public string ContactPhone { get; set; } = "";
|
|
public int idxSubLic { get; set; } = 0;
|
|
|
|
public TipologiaTicket Tipo { get; set; } = TipologiaTicket.ND;
|
|
|
|
public bool IsValid
|
|
{
|
|
get => !string.IsNullOrEmpty(MasterKey) && !string.IsNullOrEmpty(ContactEmail) && !string.IsNullOrEmpty(CodInst) && !string.IsNullOrEmpty(CodApp);
|
|
}
|
|
|
|
public string MasterKey { get; set; } = "";
|
|
public string ReqBody { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Init classe in modalità "empty"
|
|
/// </summary>
|
|
public SupportRequest()
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Istanzia un nuovo ogetto richiesta supporto
|
|
/// </summary>
|
|
/// <param name="codApp">Codice Applicazione (es EBW-UP)</param>
|
|
/// <param name="codImp">Codice Impegno (es codice chiave HW)</param>
|
|
/// <param name="codInst">Codice Cliente/Installazione</param>
|
|
/// <param name="contactEmail">Email x contatto</param>
|
|
/// <param name="contactName">Nome del richiedente/clietne</param>
|
|
/// <param name="contactPhone">Tel richiedente/cliente</param>
|
|
/// <param name="masterKey">Chiave master di comunicazione da LiMan</param>
|
|
/// <param name="ReqBody">Testo delal richiesta</param>
|
|
/// <param name="idxSubLic">Idx univoco di sublic (es x gestione utenti)</param>
|
|
/// <param name="tipo">Tipo ticket da gestire (default fileUpload)</param>
|
|
public SupportRequest(string codApp, string codImp, string codInst, string contactEmail, string contactName, string contactPhone, string masterKey, string ReqBody, int idxSubLic = 0, TipologiaTicket tipo = TipologiaTicket.FileUpload)
|
|
{
|
|
this.CodApp = CodApp;
|
|
this.CodImp = CodImp;
|
|
this.CodInst = CodInst;
|
|
this.ContactEmail = contactEmail;
|
|
this.ContactName = contactName;
|
|
this.ContactPhone = contactPhone;
|
|
this.MasterKey = masterKey;
|
|
this.ReqBody = ReqBody;
|
|
this.idxSubLic = idxSubLic;
|
|
this.Tipo = tipo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Effettua salvataggio su file di un oggetto richiesta file upload
|
|
/// </summary>
|
|
/// <param name="currReq">Oggetto richiesta (già istanziato)</param>
|
|
/// <param name="filePath">Path dove salvare il file</param>
|
|
public static bool SaveRequest(SupportRequest currReq, string filePath)
|
|
{
|
|
bool fatto = false;
|
|
try
|
|
{
|
|
string rawData = JsonConvert.SerializeObject(currReq, Formatting.Indented);
|
|
File.WriteAllText(filePath, rawData);
|
|
fatto = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.Write(ex.ToString());
|
|
}
|
|
return fatto;
|
|
}
|
|
|
|
#endregion Public Properties
|
|
}
|
|
} |