Gestione log eccezione x metodi controller

This commit is contained in:
Samuele Locatelli
2023-08-04 15:40:48 +02:00
parent 513fa79e82
commit c3d49dff05
4 changed files with 39 additions and 19 deletions
+10 -6
View File
@@ -41,8 +41,10 @@ namespace NKC_WF.Controllers
// aggiungo LA SUA ENV NUM!!!!
answ.EnvNum = envNum;
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/BatchProc | get{Environment.NewLine}{exc}");
}
}
// altrimenti NULL!
else
@@ -72,8 +74,10 @@ namespace NKC_WF.Controllers
{
answ = JsonConvert.DeserializeObject<batchRequest>(redVal);
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/BatchProc | get(id) {id}{Environment.NewLine}{exc}");
}
}
return answ;
}
@@ -589,10 +593,10 @@ namespace NKC_WF.Controllers
Log.Instance.Error(answ);
}
}
catch
catch(Exception exc)
{
answ = "NO";
Log.Instance.Error("api/BatchProc | try/catch | NO");
Log.Instance.Error($"EXCEPTION api/BatchProc{Environment.NewLine}{exc}");
}
// se tutto OK --> tolgo ultimo batch
if (answ == "OK")
+11 -5
View File
@@ -1,6 +1,7 @@
using AppData;
using Newtonsoft.Json;
using NKC_SDK;
using System;
using System.IO;
using System.Web.Http;
@@ -37,8 +38,10 @@ namespace NKC_WF.Controllers
{
answ = ComLib.prodGetFirstBunk(CodPost);
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/Bunk | get{Environment.NewLine}{exc}");
}
return answ;
}
@@ -65,8 +68,10 @@ namespace NKC_WF.Controllers
answ = ComLib.prodGetBunk(id, CodPost);
}
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/Bunk | get(int {id}, bool {showNext}, string {machine}) {Environment.NewLine}{exc}");
}
return answ;
}
@@ -128,8 +133,9 @@ namespace NKC_WF.Controllers
}
answ = "OK";
}
catch
catch(Exception exc)
{
Log.Instance.Error($"EXCEPTION api/Bunk | Post(){Environment.NewLine}{exc}");
answ = "NO";
}
return answ;
+9 -4
View File
@@ -1,6 +1,7 @@
using AppData;
using Newtonsoft.Json;
using NKC_SDK;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -49,8 +50,10 @@ namespace NKC_WF.Controllers
{
answ = ComLib.prodMachStateDataGet(machine);
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/MachineStat | get{Environment.NewLine}{exc}");
}
// se vuoto metto 1 finto...
if (answ == null)
@@ -75,8 +78,10 @@ namespace NKC_WF.Controllers
{
answ = ComLib.prodMachStateDataGet(id);
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/MachineStat | get({id}){Environment.NewLine}{exc}");
}
return answ;
}
+9 -4
View File
@@ -1,6 +1,7 @@
using AppData;
using Newtonsoft.Json;
using NKC_SDK;
using System;
using System.IO;
using System.Web.Http;
@@ -39,8 +40,10 @@ namespace NKC_WF.Controllers
{
answ = ComLib.prodGetSheetWorkList(machineName);
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/Sheet | get{Environment.NewLine}{exc}");
}
return answ;
}
@@ -58,8 +61,10 @@ namespace NKC_WF.Controllers
{
answ = ComLib.prodGetSheetWorkList(id);
}
catch
{ }
catch (Exception exc)
{
Log.Instance.Error($"EXCEPTION api/Sheet | get({id}){Environment.NewLine}{exc}");
}
return answ;
}