registrazione
This commit is contained in:
parent
53f277eb2c
commit
3f5d3b3af4
@ -16,6 +16,8 @@ using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using NuGet.Common;
|
||||
using System.Security.Policy;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace VirtualTask.Controllers
|
||||
{
|
||||
@ -30,6 +32,7 @@ namespace VirtualTask.Controllers
|
||||
string urlConfirm = string.Empty;
|
||||
string time_sheet=string.Empty;
|
||||
|
||||
|
||||
HttpClient client;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IHttpContextAccessor _context;
|
||||
@ -473,80 +476,45 @@ namespace VirtualTask.Controllers
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
token = helper.GetStringValue("tok");
|
||||
string errore = string.Empty;
|
||||
|
||||
|
||||
|
||||
//STEP 1: Configurazioni - prima leggo la configurazione VIRTU per leggere i valori di default da inserire e poi inserisco
|
||||
#region lettura tabella registrazioni
|
||||
urlBase = apiUrl + "configurazioni";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
Configurazione_out modelList = new Configurazione_out();
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
admin = helper.GetStringValue("admin");
|
||||
// prima verifico che l'utente connesso sia SA
|
||||
if (!string.IsNullOrEmpty(admin) && admin.Equals("S"))
|
||||
{
|
||||
/*string data = response.Content.ReadAsStringAsync().Result;
|
||||
modelList = JsonConvert.DeserializeObject<Configurazione_out>(data);
|
||||
//var template = modelList.Where(t=>t.azienda.Equals("VIRTU")).First();
|
||||
|
||||
Configurazioni c = fillConf(modelList, model);
|
||||
urlBase = apiUrl + "configurazioni/add";
|
||||
urlBase = apiUrl + "attivazioneStored";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
baseAddress = new Uri(urlBase);
|
||||
urlBase = urlBase + "&id=" + model.id;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
string data1 = JsonConvert.SerializeObject(c);
|
||||
StringContent content = new StringContent(data1, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response2 = client.PostAsync(baseAddress, content).Result;
|
||||
if (response2.IsSuccessStatusCode)
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
string e = JsonConvert.DeserializeObject<string>(data);
|
||||
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in inserimento configurazioni. ";
|
||||
errMes = response2.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
}*/
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", "Errore in attivazione");
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in lettura configurazioni. ";
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
}
|
||||
#endregion
|
||||
#region tecnico
|
||||
//STEP 2: Tecnico
|
||||
if (string.IsNullOrEmpty(errore))
|
||||
{
|
||||
urlBase = apiUrl + "tecnici/add";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
baseAddress = new Uri(urlBase);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//STEP 3: Codici di chiusura
|
||||
//STEP 4: Progressivi
|
||||
//STEP 5: Cliente
|
||||
//STEP 6: Impianto
|
||||
//STEP 7: COMMESSE
|
||||
//STEP 8: Chiamata template
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(errore))
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
//errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", errore);
|
||||
helper.SetStringValue("errMsg", "Utente non abilitato per la funzione");
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -583,6 +551,7 @@ namespace VirtualTask.Controllers
|
||||
}
|
||||
return bAziPres;
|
||||
}
|
||||
|
||||
private bool MailSent(string receiver, string subject, string message)
|
||||
{
|
||||
//REMEMBER per una mail gmail bisogna andare nelle impostazioni
|
||||
@ -695,6 +664,88 @@ namespace VirtualTask.Controllers
|
||||
return upd;
|
||||
}
|
||||
|
||||
#region attiva utente
|
||||
private Configurazione_out readConfTemplate()
|
||||
{
|
||||
Configurazione_out co=new Configurazione_out();
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
token = helper.GetStringValue("tok");
|
||||
string errore = string.Empty;
|
||||
|
||||
urlBase = apiUrl + "configurazioni";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
co = JsonConvert.DeserializeObject<Configurazione_out>(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in inserimento configurazioni. ";
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
co.err_detail = errore;
|
||||
}
|
||||
return co;
|
||||
}
|
||||
private string insertConfigurazione(Configurazione_out co, Registrazione model)
|
||||
{
|
||||
string errore =string.Empty;
|
||||
|
||||
Configurazioni c = fillConf(co, model);
|
||||
urlBase = apiUrl + "configurazioni/add";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
string data = JsonConvert.SerializeObject(c);
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in inserimento configurazioni. ";
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
}
|
||||
|
||||
return errore;
|
||||
}
|
||||
private string insertTecnico(Registrazione model)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
token = helper.GetStringValue("tok");
|
||||
string errore =string.Empty;
|
||||
|
||||
urlBase = apiUrl + "tecnici/add";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Tecnici tec = fillTecnico(model);
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
|
||||
string data = JsonConvert.SerializeObject(tec);
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in inserimento tecnico. ";
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
}
|
||||
return errore;
|
||||
}
|
||||
private Configurazioni fillConf(Configurazione_out c, Registrazione r)
|
||||
{
|
||||
string _path = "E:\\AAAFTPAPP\\";
|
||||
@ -706,22 +757,22 @@ namespace VirtualTask.Controllers
|
||||
_out.prefisso_buoni_chia = c.prefisso_buoni_chia;
|
||||
_out.prefisso_buoni_man = c.prefisso_buoni_man;
|
||||
_out.ftp_url = _ftp + r.azienda;
|
||||
_out.ftp_usr=c.ftp_usr;
|
||||
_out.ftp_pwd=c.ftp_pwd;
|
||||
_out.ftp_usr = c.ftp_usr;
|
||||
_out.ftp_pwd = c.ftp_pwd;
|
||||
_out.ftp_port = c.ftp_port;
|
||||
|
||||
_out.abilita_naviga = c.abilita_naviga;
|
||||
_out.abilita_telefona= c.abilita_telefona;
|
||||
_out.abilita_chiamate= c.abilita_chiamate;
|
||||
_out.abilita_telefona = c.abilita_telefona;
|
||||
_out.abilita_chiamate = c.abilita_chiamate;
|
||||
_out.abilita_manutenzioni = c.abilita_manutenzioni;
|
||||
_out.abilita_barcode=c.abilita_barcode;
|
||||
_out.abilita_barcode = c.abilita_barcode;
|
||||
_out.abilita_inserimento_chiamate = c.abilita_inserimento_chiamate;
|
||||
|
||||
_out.chiamate_accetta= c.chiamate_accetta;
|
||||
_out.chiamate_accetta = c.chiamate_accetta;
|
||||
_out.chiamate_accetta_barcode = c.chiamate_accetta_barcode;
|
||||
_out.chiamate_accetta_offline = c.chiamate_accetta_offline;
|
||||
|
||||
_out.chiamate_rifiuta=c.chiamate_rifiuta;
|
||||
_out.chiamate_rifiuta = c.chiamate_rifiuta;
|
||||
_out.chiamate_rifiuta_barcode = c.chiamate_rifiuta_barcode;
|
||||
_out.chiamate_rifiuta_offline = c.chiamate_rifiuta_offline;
|
||||
_out.chiamate_chiudi_barcode = c.chiamate_chiudi_barcode;
|
||||
@ -743,31 +794,31 @@ namespace VirtualTask.Controllers
|
||||
_out.anagrafica = c.anagrafica;
|
||||
_out.stato_finale = c.stato_finale;
|
||||
_out.descrizione_intervento = c.descrizione_intervento;
|
||||
_out.composizione_impianto=c.composizione_impianto;
|
||||
_out.note_intervento=c.note_intervento;
|
||||
_out.esito_intervento= c.esito_intervento;
|
||||
_out.ora_inizio_fine=c.ora_inizio_fine;
|
||||
_out.composizione_impianto = c.composizione_impianto;
|
||||
_out.note_intervento = c.note_intervento;
|
||||
_out.esito_intervento = c.esito_intervento;
|
||||
_out.ora_inizio_fine = c.ora_inizio_fine;
|
||||
|
||||
_out.materiali=c.materiali;
|
||||
_out.diritto_chiamata=c.diritto_chiamata;
|
||||
_out.manodopera=c.manodopera;
|
||||
_out.spese_viaggio=c.spese_viaggio;
|
||||
_out.tipo_pagamento=c.tipo_pagamento;
|
||||
_out.note_pagamento=c.note_pagamento;
|
||||
_out.causale=c.causale;
|
||||
_out.materiali = c.materiali;
|
||||
_out.diritto_chiamata = c.diritto_chiamata;
|
||||
_out.manodopera = c.manodopera;
|
||||
_out.spese_viaggio = c.spese_viaggio;
|
||||
_out.tipo_pagamento = c.tipo_pagamento;
|
||||
_out.note_pagamento = c.note_pagamento;
|
||||
_out.causale = c.causale;
|
||||
|
||||
_out.time_sheet=c.time_sheet;
|
||||
_out.time_sheet_offline=c.time_sheet_offline;
|
||||
_out.costo_orario=c.costo_orario;
|
||||
_out.time_sheet = c.time_sheet;
|
||||
_out.time_sheet_offline = c.time_sheet_offline;
|
||||
_out.costo_orario = c.costo_orario;
|
||||
|
||||
_out.storico=c.storico;
|
||||
_out.storico_tecnico=c.storico_tecnico;
|
||||
_out.storico = c.storico;
|
||||
_out.storico_tecnico = c.storico_tecnico;
|
||||
_out.storico_interventi = c.storico_interventi;
|
||||
_out.storico_impianto = c.storico_impianto;
|
||||
_out.ricerca_impianti = c.ricerca_impianti;
|
||||
_out.ora_inizio_fine_automatica = c.ora_inizio_fine_automatica;
|
||||
_out.stampa_orario = c.stampa_orario;
|
||||
_out.intestazione_stampa = !string.IsNullOrEmpty(r.RagioneSociale)?r.RagioneSociale:r.azienda;
|
||||
_out.intestazione_stampa = !string.IsNullOrEmpty(r.RagioneSociale) ? r.RagioneSociale : r.azienda;
|
||||
_out.seriale_template_chi = "0000000001";
|
||||
_out.abilita_inserimento_chiamate = c.abilita_inserimento_chiamate;
|
||||
_out.abilita_data_rapp_edit = c.abilita_data_rapp_edit;
|
||||
@ -778,6 +829,65 @@ namespace VirtualTask.Controllers
|
||||
|
||||
return _out;
|
||||
}
|
||||
private Tecnici fillTecnico(Registrazione r)
|
||||
{
|
||||
Tecnici _out = new Tecnici();
|
||||
_out.tccodice = "TECNICO01";
|
||||
string nome = !string.IsNullOrEmpty(r.nome) ? r.nome.Trim() : string.Empty;
|
||||
string cognome = !string.IsNullOrEmpty(r.cognome) ? r.cognome.Trim() : string.Empty;
|
||||
|
||||
nome = nome+" "+ cognome;
|
||||
if(nome.Length>=39)
|
||||
{
|
||||
nome= nome.Substring(0, 39);
|
||||
}
|
||||
_out.tcdescri = nome;
|
||||
_out.tcpwd = r.passwd;
|
||||
_out.tcuser = r.username;
|
||||
_out.tccodazi = r.azienda;
|
||||
_out.tctelef1 = r.telefono;
|
||||
//manca indirizzo
|
||||
//manca provincia
|
||||
//manca nazione
|
||||
//manca cellulare
|
||||
//manca email
|
||||
//manca tcdoute=1
|
||||
_out.tccoor = Convert.ToDecimal("40");
|
||||
return _out;
|
||||
}
|
||||
private string insertCodChiusura(Registrazione model)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
token = helper.GetStringValue("tok");
|
||||
string errore = string.Empty;
|
||||
|
||||
urlBase = apiUrl + "chiusure/add";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Chiusure chiu = new Chiusure();
|
||||
chiu.cccodazi = model.azienda;
|
||||
chiu.cccodice = "0001";
|
||||
chiu.ccdescr = "Attività eseguita con successo";
|
||||
chiu.ccdessup = "Attività eseguita con successo";
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
|
||||
string data = JsonConvert.SerializeObject(chiu);
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in inserimento codice chiusura. ";
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
}
|
||||
return errore;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.17" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||
<PackageReference Include="X.PagedList.Mvc.Core" Version="8.4.7" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user