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";
|
||||
admin = helper.GetStringValue("admin");
|
||||
// prima verifico che l'utente connesso sia SA
|
||||
if (!string.IsNullOrEmpty(admin) && admin.Equals("S"))
|
||||
{
|
||||
urlBase = apiUrl + "attivazioneStored";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
urlBase = urlBase + "&id=" + model.id;
|
||||
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)
|
||||
{
|
||||
/*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 = urlBase + "?token=" + token;
|
||||
baseAddress = new Uri(urlBase);
|
||||
|
||||
string data1 = JsonConvert.SerializeObject(c);
|
||||
StringContent content = new StringContent(data1, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response2 = client.PostAsync(baseAddress, content).Result;
|
||||
if (response2.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
errore = "Errore in inserimento configurazioni. ";
|
||||
errMes = response2.Content.ReadAsStringAsync().Result;
|
||||
errore = errore + errMes;
|
||||
}*/
|
||||
}
|
||||
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
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
string e = JsonConvert.DeserializeObject<string>(data);
|
||||
|
||||
|
||||
//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);
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", "Errore in attivazione");
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
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\\";
|
||||
@ -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