integrazione modulo

This commit is contained in:
Samuele Locatelli
2021-10-05 16:21:32 +02:00
parent 1f103cd87f
commit 426307f19c
6 changed files with 180 additions and 251 deletions
+140
View File
@@ -0,0 +1,140 @@
using AppData;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Http;
namespace NKC_WF.Controllers
{
public class BatchStatsController : ApiController
{
#region Protected Fields
protected string dateFormat = "yyyyMMdd";
/// <summary>
/// oggetto static/singleton per fare chiamate sul datalayer
/// </summary>
protected DataLayer DLMan = new DataLayer();
#endregion Protected Fields
#region Private Methods
/// <summary>
/// Metodo effettivo recupero dati
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
private List<chartJsTVal> getDataFilt(int id)
{
List<chartJsTVal> answ = new List<chartJsTVal>();
var tabDati = DLMan.taBStats.getLast(id);
// ciclo
foreach (var item in tabDati.OrderBy(x => x.Takt))
{
// prendo valore default = NumParts
answ.Add(new chartJsTVal() { x = item.Takt, y = item.NumParts });
}
// restituisco
return answ;
}
/// <summary>
/// Metodo effettivo recupero dati
/// </summary>
/// <param name="id"></param>
/// <param name="maxHour"></param>
/// <returns></returns>
private List<chartJsTVal> getDataFilt(int id, string PlotType)
{
List<chartJsTVal> answ = new List<chartJsTVal>();
var tabDati = DLMan.taBStats.getLast(id);
DateTime startTime = DateTime.Now.AddYears(1);
// ciclo
foreach (var item in tabDati.OrderBy(x => x.Takt))
{
//// converto in data il valore takt... primi 8 char
//DateTime dataRif = DateTime.Today;
//DateTime.TryParseExact(item.Takt.Substring(0, 8), dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dataRif);
decimal value = 0;
switch (PlotType)
{
case "Yeld":
value = item.AvgYeld * 100;
break;
case "NumMat":
value = item.NumMat;
break;
case "NumSheets":
value = item.NumSheets;
break;
case "NumModel":
value = item.NumModel;
break;
case "NumKit":
value = item.NumKit;
break;
case "NumPainted":
value = item.NumPainted;
break;
case "NumParts":
default:
value = item.NumParts;
break;
}
answ.Add(new chartJsTVal() { x = item.Takt, y = value });
}
// restituisco
return answ;
}
#endregion Private Methods
#region Public Methods
// GET api/TempRil
public string Get()
{
return "NA";
}
/// <summary>
/// Recupero dati x ultimi batch stats
/// GET api/BatchStats/5
/// </summary>
/// <param name="id">NUmLast</param>
/// <returns></returns>
public List<chartJsTVal> Get(int id)
{
DateTime dtRif = DateTime.Today;
// restituisco oggetto!
return getDataFilt(id);
}
/// <summary>
/// Recupero dati x statistiche ultimi batch
/// GET api/BatchStats/50
/// </summary>
/// <param name="id">Num record da recuperare DESC</param>
/// <param name="PlotType">Tipo di grafico</param>
/// <returns></returns>
public List<chartJsTVal> Get(int id, string PlotType)
{
List<chartJsTVal> answ = new List<chartJsTVal>();
answ = getDataFilt(id, PlotType);
// restituisco oggetto!
return answ;
}
#endregion Public Methods
}
}
+13 -5
View File
@@ -487,7 +487,8 @@
<Content Include="WebUserControls\cmp_BP_bunkList.ascx" />
<Content Include="WebUserControls\cmp_BP_sheetList.ascx" />
<Content Include="WebUserControls\cmp_cartDetIRK.ascx" />
<Content Include="WebUserControls\cmp_dailyStats.ascx" />
<Content Include="WebUserControls\cmp_DailyStatsList.ascx" />
<Content Include="WebUserControls\cmp_DailyStatsPlot.ascx" />
<Content Include="WebUserControls\cmp_devUtils.ascx" />
<Content Include="WebUserControls\cmp_errDescr.ascx" />
<Content Include="WebUserControls\cmp_errorDetail.ascx" />
@@ -1186,12 +1187,19 @@
<Compile Include="WebUserControls\cmp_cartDetIRK.ascx.designer.cs">
<DependentUpon>cmp_cartDetIRK.ascx</DependentUpon>
</Compile>
<Compile Include="WebUserControls\cmp_dailyStats.ascx.cs">
<DependentUpon>cmp_dailyStats.ascx</DependentUpon>
<Compile Include="WebUserControls\cmp_DailyStatsList.ascx.cs">
<DependentUpon>cmp_DailyStatsList.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="WebUserControls\cmp_dailyStats.ascx.designer.cs">
<DependentUpon>cmp_dailyStats.ascx</DependentUpon>
<Compile Include="WebUserControls\cmp_DailyStatsList.ascx.designer.cs">
<DependentUpon>cmp_DailyStatsList.ascx</DependentUpon>
</Compile>
<Compile Include="WebUserControls\cmp_DailyStatsPlot.ascx.cs">
<DependentUpon>cmp_DailyStatsPlot.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="WebUserControls\cmp_DailyStatsPlot.ascx.designer.cs">
<DependentUpon>cmp_DailyStatsPlot.ascx</DependentUpon>
</Compile>
<Compile Include="WebUserControls\cmp_devUtils.ascx.cs">
<DependentUpon>cmp_devUtils.ascx</DependentUpon>
@@ -1,11 +1,5 @@
using AppData;
using NKC_SDK;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NKC_WF.WebUserControls
{
@@ -13,45 +7,6 @@ namespace NKC_WF.WebUserControls
{
#region Protected Properties
/// <summary>
/// BatchId selezionato
/// </summary>
protected int BatchIdSel
{
get
{
int answ = 0;
if (grView.SelectedValue != null)
{
int.TryParse(grView.SelectedValue.ToString(), out answ);
}
return answ;
}
}
/// <summary>
/// Status corrente del batch
/// </summary>
protected BatchStatus CurrBatchStatus
{
get
{
return ComLib.BStatus(BatchIdSel);
}
}
protected int currSelRow
{
get
{
return grView.SelectedIndex;
}
set
{
grView.SelectedIndex = value;
}
}
protected int ShowLast
{
get
@@ -68,22 +23,8 @@ namespace NKC_WF.WebUserControls
#endregion Protected Properties
#region Public Properties
/// <summary>
/// modalità funzionamento controllo
/// </summary>
public BatchListMode listMode { get; set; } = BatchListMode.Standard;
#endregion Public Properties
#region Private Methods
private void Cmp_batchDetail_eh_doRefresh(object sender, EventArgs e)
{
resetSelezione();
}
private void Cmp_numRow_eh_doRefresh(object sender, EventArgs e)
{
// recupero num righe ed aggiorno...
@@ -91,13 +32,6 @@ namespace NKC_WF.WebUserControls
grView.DataBind();
}
private void resetSelezione()
{
grView.SelectedIndex = -1;
grView.DataBind();
raiseReset();
}
private void updateGraph()
{
cmp_BatchStatsPlot.PlotType = ddlType.SelectedValue;
@@ -114,20 +48,10 @@ namespace NKC_WF.WebUserControls
doUpdate();
}
protected void chkShowSplit_CheckedChanged(object sender, EventArgs e)
{
// deseleziono...
resetSelezione();
}
protected void ddlPlaces_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
{
doUpdate();
@@ -137,30 +61,6 @@ namespace NKC_WF.WebUserControls
{
}
protected void lbRedoEval_Click(object sender, EventArgs e)
{
LinkButton lbt = (LinkButton)sender;
if (!string.IsNullOrEmpty(lbt.CommandArgument))
{
// eseguo richiesta reset
DLMan.taBL.redoPartValid(lbt.CommandArgument);
// eventualmente mando primo batch da validare...
bool newValidSent = ComLib.sendFirstValidationBatch();
// refresh!
resetSelezione();
}
}
/// <summary>
/// comando reset
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
/// <summary>
/// Caricamento pagina
/// </summary>
@@ -187,89 +87,6 @@ namespace NKC_WF.WebUserControls
#region Public Methods
/// <summary>
/// Converte il codice stato in effettivo campo
/// </summary>
/// <param name="_status"></param>
/// <returns></returns>
public string BStatus(object _status)
{
string answ = ComLib.BatchStatusDescr(_status);
return answ;
}
/// <summary>
/// Codice CSS in base a status...
/// </summary>
/// <param name="_status"></param>
/// <returns></returns>
public string cssByStatus(object _status)
{
string answ = "text-muted";
int status = -1;
int.TryParse(_status.ToString(), out status);
switch (status)
{
case 1:
answ = "font-weight-bold text-info";
break;
case 2:
answ = "font-weight-bold text-primary";
break;
case 3:
answ = "font-weight-bold text-warning";
break;
case 4:
answ = "font-weight-bold text-danger";
break;
case 5:
answ = "font-weight-bold text-success";
break;
case 6:
answ = "font-weight-bold text-secondary";
break;
default:
break;
}
return answ;
}
/// <summary>
/// Codice CSS in base a BatchType...
/// </summary>
/// <param name="_BatchType"></param>
/// <returns></returns>
public string cssIconByType(object _BatchType)
{
string answ = "fa fa-circle-thin";
int status = -1;
int.TryParse(_BatchType.ToString(), out status);
switch (status)
{
case 0:
answ = "fa fa-file-text-o";
break;
case 1:
answ = "fa fa-file-text";
break;
case 2:
answ = "fa fa-scissors";
break;
default:
break;
}
return answ;
}
public void doUpdate()
{
divGraph.Visible = chkPlotGraph.Checked;
@@ -281,62 +98,6 @@ namespace NKC_WF.WebUserControls
grView.DataBind();
}
/// <summary>
/// Determina se sia visibile previewin base a BatchType...
/// </summary>
/// <param name="_BatchType"></param>
/// <returns></returns>
public bool hasPreviewByType(object _BatchType)
{
bool answ = false;
int status = -1;
int.TryParse(_BatchType.ToString(), out status);
switch (status)
{
case 0:
case 2:
answ = true;
break;
case 1:
default:
answ = false;
break;
}
return answ;
}
/// <summary>
/// Verifica se sia visualizzabile preview dato stato
/// </summary>
/// <param name="_status"></param>
/// <returns></returns>
public bool isPreviewVisible(object _status)
{
bool answ = false;
int status = -1;
int.TryParse(_status.ToString(), out status);
// solo stati 4 (nesting done), 5 (approvato), 6 (eliminazione logica)
if (status > 3 && status < 7)
{
answ = true;
}
return answ;
}
/// <summary>
/// Tooltip in base a BatchType...
/// </summary>
/// <param name="_BatchType"></param>
/// <returns></returns>
public string tooltipByType(object _BatchType)
{
string answ = "-";
answ = traduci($"tooltipBatchType_{_BatchType}");
return answ;
}
#endregion Public Methods
}
}
+10 -2
View File
@@ -3,7 +3,7 @@
<%@ Register Src="~/WebUserControls/cmp_SheetsStats.ascx" TagPrefix="uc1" TagName="cmp_SheetsStats" %>
<%@ Register Src="~/WebUserControls/cmp_reportSelector.ascx" TagPrefix="uc1" TagName="cmp_reportSelector" %>
<%@ Register Src="~/WebUserControls/cmp_BatchStatsList.ascx" TagPrefix="uc1" TagName="cmp_BatchStatsList" %>
<%@ Register Src="~/WebUserControls/cmp_dailyStats.ascx" TagPrefix="uc1" TagName="cmp_dailyStats" %>
<%@ Register Src="~/WebUserControls/cmp_DailyStatsList.ascx" TagPrefix="uc1" TagName="cmp_DailyStatsList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div class="my-4 mx-2">
@@ -21,9 +21,17 @@
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-3"></div>
<div class="col-9">
<div class="text-info text-center">
<asp:Label runat="server" ID="lblInstruction"><i class="fa fa-arrow-up" aria-hidden="true"></i> <%# traduci("PleaseSelectReportType") %> <i class="fa fa-arrow-up" aria-hidden="true"></i></asp:Label>
</div>
</div>
</div>
<uc1:cmp_SheetsStats runat="server" ID="cmp_SheetsStats" />
<uc1:cmp_BatchStatsList runat="server" id="cmp_BatchStatsList" />
<uc1:cmp_dailyStats runat="server" id="cmp_dailyStats" />
<uc1:cmp_DailyStatsList runat="server" id="cmp_DailyStatsList" />
</div>
</div>
</div>
+5 -2
View File
@@ -73,9 +73,11 @@ namespace NKC_WF.site
private void updateDisplay()
{
lblInstruction.DataBind();
lblInstruction.Visible = false;
cmp_SheetsStats.Visible = false;
cmp_BatchStatsList.Visible = false;
cmp_dailyStats.Visible = false;
cmp_DailyStatsList.Visible = false;
switch (cmp_reportSelector.SelReport)
{
case ReportType.BatchStats:
@@ -87,11 +89,12 @@ namespace NKC_WF.site
break;
case ReportType.DailyReport:
cmp_dailyStats.Visible = true;
cmp_DailyStatsList.Visible = true;
break;
case ReportType.ND:
default:
lblInstruction.Visible = true;
break;
}
}
+11 -2
View File
@@ -23,6 +23,15 @@ namespace NKC_WF.site
/// </remarks>
protected global::NKC_WF.WebUserControls.cmp_reportSelector cmp_reportSelector;
/// <summary>
/// lblInstruction control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblInstruction;
/// <summary>
/// cmp_SheetsStats control.
/// </summary>
@@ -42,12 +51,12 @@ namespace NKC_WF.site
protected global::NKC_WF.WebUserControls.cmp_BatchStatsList cmp_BatchStatsList;
/// <summary>
/// cmp_dailyStats control.
/// cmp_DailyStatsList control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::NKC_WF.WebUserControls.cmp_dailyStats cmp_dailyStats;
protected global::NKC_WF.WebUserControls.cmp_DailyStatsList cmp_DailyStatsList;
}
}