MICHELE: gestione progressivi commesse
This commit is contained in:
parent
0f3eb0e698
commit
92eca245f8
@ -16,6 +16,8 @@ namespace VirtualTask.Controllers
|
|||||||
string tenant = string.Empty;
|
string tenant = string.Empty;
|
||||||
string errMes = string.Empty;
|
string errMes = string.Empty;
|
||||||
string admin = string.Empty;
|
string admin = string.Empty;
|
||||||
|
string _sercomm = "SER_COMMES";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpClient client;
|
HttpClient client;
|
||||||
@ -127,8 +129,10 @@ namespace VirtualTask.Controllers
|
|||||||
urlBase = apiUrl + "commesseVT/add";
|
urlBase = apiUrl + "commesseVT/add";
|
||||||
urlBase = urlBase + "?token=" + token;
|
urlBase = urlBase + "?token=" + token;
|
||||||
Uri baseAddress = new Uri(urlBase);
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
|
||||||
client = new HttpClient();
|
client = new HttpClient();
|
||||||
client.BaseAddress = baseAddress;
|
client.BaseAddress = baseAddress;
|
||||||
|
model.laserial = GetNewSeriale();
|
||||||
|
|
||||||
string data = JsonConvert.SerializeObject(model);
|
string data = JsonConvert.SerializeObject(model);
|
||||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||||
@ -366,6 +370,14 @@ namespace VirtualTask.Controllers
|
|||||||
{
|
{
|
||||||
string data = response.Content.ReadAsStringAsync().Result;
|
string data = response.Content.ReadAsStringAsync().Result;
|
||||||
modelList = JsonConvert.DeserializeObject<List<Impianto>>(data);
|
modelList = JsonConvert.DeserializeObject<List<Impianto>>(data);
|
||||||
|
|
||||||
|
//per gestire primo elemento tendina (deve essere vuoto)
|
||||||
|
SelectListItem listItemFirst = new SelectListItem();
|
||||||
|
|
||||||
|
listItemFirst.Value = string.Empty;
|
||||||
|
listItemFirst.Text = " - Impianto";
|
||||||
|
selectItems.Add(listItemFirst);
|
||||||
|
|
||||||
foreach (var item in modelList)
|
foreach (var item in modelList)
|
||||||
{
|
{
|
||||||
SelectListItem listItem = new SelectListItem();
|
SelectListItem listItem = new SelectListItem();
|
||||||
@ -401,7 +413,7 @@ namespace VirtualTask.Controllers
|
|||||||
SelectListItem listItemFirst = new SelectListItem();
|
SelectListItem listItemFirst = new SelectListItem();
|
||||||
|
|
||||||
listItemFirst.Value = string.Empty;
|
listItemFirst.Value = string.Empty;
|
||||||
listItemFirst.Text = " - cliente";
|
listItemFirst.Text = " - Cliente";
|
||||||
selectItems.Add(listItemFirst);
|
selectItems.Add(listItemFirst);
|
||||||
|
|
||||||
foreach (var item in modelList)
|
foreach (var item in modelList)
|
||||||
@ -418,6 +430,60 @@ namespace VirtualTask.Controllers
|
|||||||
return selectItems;
|
return selectItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetNewSeriale()
|
||||||
|
{
|
||||||
|
int p = -1;
|
||||||
|
string seriale = string.Empty;
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
token = helper.GetStringValue("tok");
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
urlBase = apiUrl + "progressiviList";
|
||||||
|
urlBase = urlBase + "?token=" + token;
|
||||||
|
Uri baseAddress = new Uri(urlBase);
|
||||||
|
client = new HttpClient();
|
||||||
|
client.BaseAddress = baseAddress;
|
||||||
|
List<Progressivo> progressivo = new List<Progressivo>();
|
||||||
|
HttpResponseMessage response = client.GetAsync(baseAddress).Result;
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
string data = response.Content.ReadAsStringAsync().Result;
|
||||||
|
progressivo = JsonConvert.DeserializeObject<List<Progressivo>>(data);
|
||||||
|
var last = progressivo.Where(x => x.tipo_prog.Equals(_sercomm)).First();
|
||||||
|
p = last.val_prog;
|
||||||
|
p++;
|
||||||
|
seriale = Convert.ToString(p);
|
||||||
|
seriale = seriale.PadLeft(10, '0');
|
||||||
|
Progressivo update = new Progressivo();
|
||||||
|
update.val_prog = p;
|
||||||
|
update.tipo_prog = _sercomm;
|
||||||
|
update.azienda = tenant;
|
||||||
|
UpdateSeriale(update);
|
||||||
|
}
|
||||||
|
return seriale;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void UpdateSeriale(Progressivo p)
|
||||||
|
{
|
||||||
|
SessionHelper helper = new SessionHelper(this);
|
||||||
|
token = helper.GetStringValue("tok");
|
||||||
|
apiUrl = helper.GetStringValue("apiUrl");
|
||||||
|
tenant = helper.GetStringValue("tenant");
|
||||||
|
urlBase = apiUrl + "progressivo/mod";
|
||||||
|
urlBase = urlBase + "?token=" + token;
|
||||||
|
|
||||||
|
client = new HttpClient();
|
||||||
|
|
||||||
|
var stringPayload = JsonConvert.SerializeObject(p);
|
||||||
|
var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
|
||||||
|
var httpResponse = await client.PostAsync(urlBase, httpContent);
|
||||||
|
|
||||||
|
if (httpResponse.Content != null)
|
||||||
|
{
|
||||||
|
var responseContent = await httpResponse.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user