Aggiunto metodo POST x salvare i dati sul controller
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using AppData;
|
||||
using Newtonsoft.Json;
|
||||
using NKC_SDK;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace NKC_WF.Controllers
|
||||
@@ -30,7 +33,7 @@ namespace NKC_WF.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <param name="showNext"></param>
|
||||
/// <returns></returns>
|
||||
// GET: api/GetNext/5
|
||||
// GET: api/Bunk/2?showNext=true
|
||||
[HttpGet]
|
||||
public ProdBunk Get(int id, bool showNext)
|
||||
{
|
||||
@@ -93,6 +96,48 @@ namespace NKC_WF.Controllers
|
||||
ComLib.resetRedisBunkData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processa una chiamata POST per l'invio di un SET di file "a nome" di un IOB, formato MapoSDK.fileEmbed
|
||||
/// PUT: api/bunk/updateBunk/2
|
||||
/// </summary>
|
||||
/// <param name="id">ID dell'IOB</param>
|
||||
/// <returns></returns>
|
||||
// POST: api/Bunk
|
||||
[HttpPost]
|
||||
public string Post()
|
||||
{
|
||||
string answ = "";
|
||||
// questa classe è derivata da Controller.Response... x cui recupero lo stream in altro modo...
|
||||
string content = "";
|
||||
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
||||
using (var reader = new StreamReader(System.Web.HttpContext.Current.Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
|
||||
{
|
||||
content = reader.ReadToEnd();
|
||||
}
|
||||
//Rest
|
||||
System.Web.HttpContext.Current.Request.InputStream.Position = 0;
|
||||
// procedo a deserializzare in blocco l'oggetto...
|
||||
try
|
||||
{
|
||||
// deserializzo.
|
||||
ProdBunk currBunk = JsonConvert.DeserializeObject<ProdBunk>(content);
|
||||
// se non nullo...
|
||||
if (currBunk != null)
|
||||
{
|
||||
foreach (var item in currBunk.SheetList)
|
||||
{
|
||||
DataLayer.man.taSHL.updateDate(item.SheetId, item.Printing.DtStart, item.Printing.DtEnd, item.Machining.DtStart, item.Machining.DtEnd, item.Unloading.DtStart, item.Unloading.DtEnd);
|
||||
}
|
||||
}
|
||||
answ = "OK";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
answ = "NO";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
// POST: api/Bunk
|
||||
[HttpPost]
|
||||
|
||||
Reference in New Issue
Block a user