From 426307f19cfbd3099a8d3e43810c76cd7e056c5a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 5 Oct 2021 16:21:32 +0200 Subject: [PATCH] integrazione modulo --- NKC_WF/Controllers/DayStatsController.cs | 140 ++++++++++ NKC_WF/NKC_WF.csproj | 18 +- .../cmp_BatchStatsList.ascx.cs | 241 +----------------- NKC_WF/site/PlannerReports.aspx | 12 +- NKC_WF/site/PlannerReports.aspx.cs | 7 +- NKC_WF/site/PlannerReports.aspx.designer.cs | 13 +- 6 files changed, 180 insertions(+), 251 deletions(-) create mode 100644 NKC_WF/Controllers/DayStatsController.cs diff --git a/NKC_WF/Controllers/DayStatsController.cs b/NKC_WF/Controllers/DayStatsController.cs new file mode 100644 index 0000000..6a25154 --- /dev/null +++ b/NKC_WF/Controllers/DayStatsController.cs @@ -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"; + + /// + /// oggetto static/singleton per fare chiamate sul datalayer + /// + protected DataLayer DLMan = new DataLayer(); + + #endregion Protected Fields + + #region Private Methods + + /// + /// Metodo effettivo recupero dati + /// + /// + /// + private List getDataFilt(int id) + { + List answ = new List(); + 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; + } + + /// + /// Metodo effettivo recupero dati + /// + /// + /// + /// + private List getDataFilt(int id, string PlotType) + { + List answ = new List(); + 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"; + } + + /// + /// Recupero dati x ultimi batch stats + /// GET api/BatchStats/5 + /// + /// NUmLast + /// + public List Get(int id) + { + DateTime dtRif = DateTime.Today; + // restituisco oggetto! + return getDataFilt(id); + } + + /// + /// Recupero dati x statistiche ultimi batch + /// GET api/BatchStats/50 + /// + /// Num record da recuperare DESC + /// Tipo di grafico + /// + public List Get(int id, string PlotType) + { + List answ = new List(); + answ = getDataFilt(id, PlotType); + // restituisco oggetto! + return answ; + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/NKC_WF/NKC_WF.csproj b/NKC_WF/NKC_WF.csproj index 07f1304..b12bdfd 100644 --- a/NKC_WF/NKC_WF.csproj +++ b/NKC_WF/NKC_WF.csproj @@ -487,7 +487,8 @@ - + + @@ -1186,12 +1187,19 @@ cmp_cartDetIRK.ascx - - cmp_dailyStats.ascx + + cmp_DailyStatsList.ascx ASPXCodeBehind - - cmp_dailyStats.ascx + + cmp_DailyStatsList.ascx + + + cmp_DailyStatsPlot.ascx + ASPXCodeBehind + + + cmp_DailyStatsPlot.ascx cmp_devUtils.ascx diff --git a/NKC_WF/WebUserControls/cmp_BatchStatsList.ascx.cs b/NKC_WF/WebUserControls/cmp_BatchStatsList.ascx.cs index c9c9b40..fb511fd 100644 --- a/NKC_WF/WebUserControls/cmp_BatchStatsList.ascx.cs +++ b/NKC_WF/WebUserControls/cmp_BatchStatsList.ascx.cs @@ -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 - /// - /// BatchId selezionato - /// - protected int BatchIdSel - { - get - { - int answ = 0; - if (grView.SelectedValue != null) - { - int.TryParse(grView.SelectedValue.ToString(), out answ); - } - return answ; - } - } - - /// - /// Status corrente del batch - /// - 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 - - /// - /// modalità funzionamento controllo - /// - 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(); - } - } - - /// - /// comando reset - /// - /// - /// - protected void lbtReset_Click(object sender, EventArgs e) - { - resetSelezione(); - } - /// /// Caricamento pagina /// @@ -187,89 +87,6 @@ namespace NKC_WF.WebUserControls #region Public Methods - /// - /// Converte il codice stato in effettivo campo - /// - /// - /// - public string BStatus(object _status) - { - string answ = ComLib.BatchStatusDescr(_status); - return answ; - } - - /// - /// Codice CSS in base a status... - /// - /// - /// - 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; - } - - /// - /// Codice CSS in base a BatchType... - /// - /// - /// - 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(); } - /// - /// Determina se sia visibile previewin base a BatchType... - /// - /// - /// - 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; - } - - /// - /// Verifica se sia visualizzabile preview dato stato - /// - /// - /// - 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; - } - - /// - /// Tooltip in base a BatchType... - /// - /// - /// - public string tooltipByType(object _BatchType) - { - string answ = "-"; - - answ = traduci($"tooltipBatchType_{_BatchType}"); - return answ; - } - #endregion Public Methods } } \ No newline at end of file diff --git a/NKC_WF/site/PlannerReports.aspx b/NKC_WF/site/PlannerReports.aspx index ca9a51f..8245bed 100644 --- a/NKC_WF/site/PlannerReports.aspx +++ b/NKC_WF/site/PlannerReports.aspx @@ -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" %>
@@ -21,9 +21,17 @@
+
+
+
+
+ <%# traduci("PleaseSelectReportType") %> +
+
+
- +
diff --git a/NKC_WF/site/PlannerReports.aspx.cs b/NKC_WF/site/PlannerReports.aspx.cs index 3a066aa..13b4ff0 100644 --- a/NKC_WF/site/PlannerReports.aspx.cs +++ b/NKC_WF/site/PlannerReports.aspx.cs @@ -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; } } diff --git a/NKC_WF/site/PlannerReports.aspx.designer.cs b/NKC_WF/site/PlannerReports.aspx.designer.cs index e9394a3..58fd440 100644 --- a/NKC_WF/site/PlannerReports.aspx.designer.cs +++ b/NKC_WF/site/PlannerReports.aspx.designer.cs @@ -23,6 +23,15 @@ namespace NKC_WF.site /// protected global::NKC_WF.WebUserControls.cmp_reportSelector cmp_reportSelector; + /// + /// lblInstruction control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblInstruction; + /// /// cmp_SheetsStats control. /// @@ -42,12 +51,12 @@ namespace NKC_WF.site protected global::NKC_WF.WebUserControls.cmp_BatchStatsList cmp_BatchStatsList; /// - /// cmp_dailyStats control. + /// cmp_DailyStatsList control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::NKC_WF.WebUserControls.cmp_dailyStats cmp_dailyStats; + protected global::NKC_WF.WebUserControls.cmp_DailyStatsList cmp_DailyStatsList; } }