diff --git a/Jenkinsfile b/Jenkinsfile index e09f0f76..5698dd5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,12 +12,12 @@ pipeline { steps { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=1308']) { + withEnv(['NEXT_BUILD_NUMBER=1309']) { // env.versionNumber = VersionNumber(versionNumberString : '6.11.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '6.11.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'MAPO' } - } + } script { currentBuild.displayName = "${env.versionNumber}" if (env.BRANCH_NAME == "develop" || env.BRANCH_NAME.contains("DEMO")) { diff --git a/MP-TAB/BasePage.cs b/MP-TAB/BasePage.cs index 9e4c150c..b6f0a54b 100644 --- a/MP-TAB/BasePage.cs +++ b/MP-TAB/BasePage.cs @@ -9,11 +9,86 @@ namespace MoonProTablet { public class BasePage : UserPage { + #region Internal Fields + /// /// Oggetto datalayer specifico /// internal DataLayer DataLayerObj = new DataLayer(); + #endregion Internal Fields + + #region Protected Properties + + /// + /// Prox pagina da aprire + /// + protected string _nextPage + { + get + { + string pagina = memLayer.ML.StringSessionObj("nextPage"); + if (string.IsNullOrEmpty(pagina)) + { + pagina = "menu.aspx"; + } + return pagina; + } + } + + /// + /// Verifica (su tab config) se sia abilitata la gestione flusso RPO (Richieste - Promesse - ODL) + /// + protected bool enableRPO + { + get + { + return memLayer.ML.cdvb("enableRPO"); + } + } + + /// + /// Verifica se la macchina MAIN sia MASTER + /// + protected bool isMaster + { + get + { + bool answ = false; + answ = DataLayerObj.isMaster(idxMacchina); + return answ; + } + } + + /// + /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) + /// + protected bool isMulti + { + get + { + bool answ = false; + answ = DataLayerObj.isMulti(idxMacchina); + return answ; + } + } + + /// + /// Verifica se la macchina MAIN sia SLAVE + /// + protected bool isSlave + { + get + { + bool answ = false; + answ = DataLayerObj.isSlave(idxMacchina); + return answ; + } + } + + #endregion Protected Properties + + #region Public Properties /// /// idx macchina selezionata @@ -29,32 +104,7 @@ namespace MoonProTablet memLayer.ML.setSessionVal("IdxMacchina", value); } } - /// - /// Sotto sistema (macchina) selezionato - /// - public string subMaccSel - { - get - { - return memLayer.ML.StringSessionObj("subMaccSel"); - } - set - { - memLayer.ML.setSessionVal("subMaccSel", value); - } - } - /// - /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) - /// - protected bool isMulti - { - get - { - bool answ = false; - answ = DataLayerObj.isMulti(idxMacchina); - return answ; - } - } + /// /// idxODL corrente /// @@ -71,31 +121,24 @@ namespace MoonProTablet } /// - /// Verifica (su tab config) se sia abilitata la gestione flusso RPO (Richieste - Promesse - ODL) + /// Sotto sistema (macchina) selezionato /// - protected bool enableRPO + public string subMaccSel { get { - return memLayer.ML.cdvb("enableRPO"); + return memLayer.ML.StringSessionObj("subMaccSel"); } - } - /// - /// Prox pagina da aprire - /// - protected string _nextPage - { - get + set { - string pagina = memLayer.ML.StringSessionObj("nextPage"); - if (string.IsNullOrEmpty(pagina)) - { - pagina = "menu.aspx"; - } - return pagina; + memLayer.ML.setSessionVal("subMaccSel", value); } } + #endregion Public Properties + + #region Public Methods + /// /// effettua traduzione del lemma /// @@ -115,5 +158,7 @@ namespace MoonProTablet { return user_std.UtSn.TraduciEn(lemma); } + + #endregion Public Methods } } \ No newline at end of file diff --git a/MP-TAB/MP-TAB.csproj b/MP-TAB/MP-TAB.csproj index 93e8fa3f..b96b70e6 100644 --- a/MP-TAB/MP-TAB.csproj +++ b/MP-TAB/MP-TAB.csproj @@ -692,6 +692,7 @@ + @@ -966,6 +967,13 @@ cmp_sheetTech.ascx + + cmp_SlaveMachine.ascx + ASPXCodeBehind + + + cmp_SlaveMachine.ascx + cmp_ST_detail.ascx ASPXCodeBehind diff --git a/MP-TAB/ODL.aspx b/MP-TAB/ODL.aspx index dd41cff4..bbbd76e7 100644 --- a/MP-TAB/ODL.aspx +++ b/MP-TAB/ODL.aspx @@ -1,39 +1,41 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/WebMasterPages/Bootstrap.Master" AutoEventWireup="true" CodeBehind="ODL.aspx.cs" - Inherits="MoonProTablet.ODL" %> + Inherits="MoonProTablet.ODL" %> <%@ Register Src="WebUserControls/mod_dettMacchina.ascx" TagName="mod_dettMacchina" TagPrefix="uc1" %> <%@ Register Src="WebUserControls/mod_ODL.ascx" TagName="mod_ODL" TagPrefix="uc2" %> <%@ Register Src="~/WebUserControls/mod_directLinks.ascx" TagPrefix="uc1" TagName="mod_directLinks" %> +<%@ Register Src="~/WebUserControls/cmp_SlaveMachine.ascx" TagPrefix="uc1" TagName="cmp_SlaveMachine" %> -
-
-
- -
- - - - - - +
+
+
+ +
+ + + + + + +
+
+
+ + + + +
+
+ Fix ODL +
+
+ + +
+
+ +
-
-
- - - - -
-
- Fix ODL -
-
- -
-
- -
-
- + \ No newline at end of file diff --git a/MP-TAB/ODL.aspx.cs b/MP-TAB/ODL.aspx.cs index 48cb366b..a7391815 100644 --- a/MP-TAB/ODL.aspx.cs +++ b/MP-TAB/ODL.aspx.cs @@ -7,32 +7,22 @@ namespace MoonProTablet { public partial class ODL : BasePage { - /// - /// Valore protected idxODL - /// - protected string _idxOdlMacc; + #region Protected Fields + /// /// Valore protected idxODL /// protected string _idxOdlAltraMacc; + /// - /// IdxODL sulla macchina + /// Valore protected idxODL /// - public string idxOdlMacc - { - get - { - if (_idxOdlMacc == null) - { - _idxOdlMacc = DataLayerObj.currODL(idxMacchinaFix, true); - } - return _idxOdlMacc; - } - set - { - _idxOdlMacc = value; - } - } + protected string _idxOdlMacc; + + #endregion Protected Fields + + #region Public Properties + /// /// Verifica se la macchina NON abbia ODL (valido, > 0) /// @@ -43,6 +33,7 @@ namespace MoonProTablet return (idxOdlMacc == "" || idxOdlMacc == "0"); } } + /// /// idx macchina selezionata /// @@ -72,44 +63,28 @@ namespace MoonProTablet } /// - /// Se la machcina è MULTI --> mostro selettore + /// IdxODL sulla macchina /// - private void fixSelMacc() + public string idxOdlMacc { - divSelMacc.Visible = isMulti; - if (isMulti) + get { - // salvo selezione submacc - ddlSubMacc.DataBind(); - subMaccSel = ddlSubMacc.SelectedValue; - } - } - protected void Page_Load(object sender, EventArgs e) - { - if (!Page.IsPostBack) - { - checkAll(); - if (isMulti) + if (_idxOdlMacc == null) { - mod_dettMacchina1.doUpdate(); + _idxOdlMacc = DataLayerObj.currODL(idxMacchinaFix, true); } + return _idxOdlMacc; + } + set + { + _idxOdlMacc = value; } - mod_ODL1.eh_reqUpdate += Mod_ODL1_eh_reqUpdate; - } - /// - /// Update controlli post richiesta refresh da child - /// - /// - /// - private void Mod_ODL1_eh_reqUpdate(object sender, EventArgs e) - { - // forzo update macchina... - DataLayerObj.taMSE.forceRecalc(0, idxMacchinaFix); - // update display! - ddlSubMacc.DataBind(); - mod_dettMacchina1.doUpdate(); } + #endregion Public Properties + + #region Private Methods + private void checkAll() { // parto: nascondo tutto... @@ -174,19 +149,44 @@ namespace MoonProTablet mod_ODL1.isEnabled = !needConfProd; } - protected void lbtFixOdl_Click(object sender, EventArgs e) + private void fixDisplaySlave() { - Response.Redirect("~/fixODL"); + cmp_SlaveMachine.Visible = isSlave; + mod_ODL1.Visible = !isSlave; + divSelMacc.Visible = !isSlave; } - - protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) + /// + /// Se la machcina è MULTI --> mostro selettore + /// + private void fixSelMacc() { - // procedo... - subMaccSel = ddlSubMacc.SelectedValue; - checkAll(); + divSelMacc.Visible = isMulti; + if (isMulti) + { + // salvo selezione submacc + ddlSubMacc.DataBind(); + subMaccSel = ddlSubMacc.SelectedValue; + } } + /// + /// Update controlli post richiesta refresh da child + /// + /// + /// + private void Mod_ODL1_eh_reqUpdate(object sender, EventArgs e) + { + // forzo update macchina... + DataLayerObj.taMSE.forceRecalc(0, idxMacchinaFix); + // update display! + ddlSubMacc.DataBind(); + mod_dettMacchina1.doUpdate(); + } + + #endregion Private Methods + + #region Protected Methods protected void ddlSubMacc_DataBound(object sender, EventArgs e) { @@ -202,5 +202,33 @@ namespace MoonProTablet { } } } + + protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) + { + // procedo... + subMaccSel = ddlSubMacc.SelectedValue; + checkAll(); + } + + protected void lbtFixOdl_Click(object sender, EventArgs e) + { + Response.Redirect("~/fixODL"); + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + checkAll(); + if (isMulti) + { + mod_dettMacchina1.doUpdate(); + } + } + fixDisplaySlave(); + mod_ODL1.eh_reqUpdate += Mod_ODL1_eh_reqUpdate; + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/MP-TAB/ODL.aspx.designer.cs b/MP-TAB/ODL.aspx.designer.cs index 346b3f96..55c96416 100644 --- a/MP-TAB/ODL.aspx.designer.cs +++ b/MP-TAB/ODL.aspx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace MoonProTablet { - - - public partial class ODL { - +namespace MoonProTablet +{ + + + public partial class ODL + { + /// /// Controllo mod_dettMacchina1. /// @@ -20,7 +22,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::MoonProTablet.WebUserControls.mod_dettMacchina mod_dettMacchina1; - + /// /// Controllo divSelMacc. /// @@ -29,7 +31,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl divSelMacc; - + /// /// Controllo ddlSubMacc. /// @@ -38,7 +40,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.DropDownList ddlSubMacc; - + /// /// Controllo ods. /// @@ -47,7 +49,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.ObjectDataSource ods; - + /// /// Controllo divWarn. /// @@ -56,7 +58,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl divWarn; - + /// /// Controllo lblWarningHead. /// @@ -65,7 +67,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.Label lblWarningHead; - + /// /// Controllo lblWarningBody. /// @@ -74,7 +76,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.Label lblWarningBody; - + /// /// Controllo lblNumPz2Conf. /// @@ -83,7 +85,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.Label lblNumPz2Conf; - + /// /// Controllo divPz2Conf. /// @@ -92,7 +94,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl divPz2Conf; - + /// /// Controllo lbtFixOdl. /// @@ -101,7 +103,16 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::System.Web.UI.WebControls.LinkButton lbtFixOdl; - + + /// + /// Controllo cmp_SlaveMachine. + /// + /// + /// Campo generato automaticamente. + /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// + protected global::MoonProTablet.WebUserControls.cmp_SlaveMachine cmp_SlaveMachine; + /// /// Controllo mod_ODL1. /// @@ -110,7 +121,7 @@ namespace MoonProTablet { /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. /// protected global::MoonProTablet.WebUserControls.mod_ODL mod_ODL1; - + /// /// Controllo mod_directLinks. /// diff --git a/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx b/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx new file mode 100644 index 00000000..2f9dbeb8 --- /dev/null +++ b/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx @@ -0,0 +1,9 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_SlaveMachine.ascx.cs" Inherits="MoonProTablet.WebUserControls.cmp_SlaveMachine" %> + +
+
Slave Machine
+
+ Attenzione!
+ Editing ODL non permesso per impianti modalità Slave ODL +
+
\ No newline at end of file diff --git a/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx.cs b/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx.cs new file mode 100644 index 00000000..14b081b8 --- /dev/null +++ b/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace MoonProTablet.WebUserControls +{ + public partial class cmp_SlaveMachine : System.Web.UI.UserControl + { + protected void Page_Load(object sender, EventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx.designer.cs b/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx.designer.cs new file mode 100644 index 00000000..83530510 --- /dev/null +++ b/MP-TAB/WebUserControls/cmp_SlaveMachine.ascx.designer.cs @@ -0,0 +1,17 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da uno strumento. +// +// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se +// il codice viene rigenerato. +// +//------------------------------------------------------------------------------ + +namespace MoonProTablet.WebUserControls +{ + + + public partial class cmp_SlaveMachine + { + } +} diff --git a/MapoDb/DS_ProdTempi.xsd b/MapoDb/DS_ProdTempi.xsd index 31631391..a00d9821 100644 --- a/MapoDb/DS_ProdTempi.xsd +++ b/MapoDb/DS_ProdTempi.xsd @@ -290,6 +290,19 @@ ORDER BY idxODL DESC + + + + dbo.stp_ODL_fixMachineSlave + + + + + + + + + @@ -2379,6 +2392,78 @@ FROM v_ECP + + + + + + DELETE FROM [Macchine2Slave] WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([IdxMacchinaSlave] = @Original_IdxMacchinaSlave)) + + + + + + + + + INSERT INTO [Macchine2Slave] ([IdxMacchina], [IdxMacchinaSlave]) VALUES (@IdxMacchina, @IdxMacchinaSlave); +SELECT IdxMacchina, IdxMacchinaSlave FROM Macchine2Slave WHERE (IdxMacchina = @IdxMacchina) AND (IdxMacchinaSlave = @IdxMacchinaSlave) + + + + + + + + + SELECT IdxMacchina, IdxMacchinaSlave +FROM Macchine2Slave + + + + + + UPDATE [Macchine2Slave] SET [IdxMacchina] = @IdxMacchina, [IdxMacchinaSlave] = @IdxMacchinaSlave WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([IdxMacchinaSlave] = @Original_IdxMacchinaSlave)); +SELECT IdxMacchina, IdxMacchinaSlave FROM Macchine2Slave WHERE (IdxMacchina = @IdxMacchina) AND (IdxMacchinaSlave = @IdxMacchinaSlave) + + + + + + + + + + + + + + + + + + + dbo.stp_M2S_byMaster + + + + + + + + + + + dbo.stp_M2S_bySlave + + + + + + + + + @@ -2801,7 +2886,7 @@ FROM v_ECP - + @@ -2882,7 +2967,7 @@ FROM v_ECP - + @@ -2894,7 +2979,7 @@ FROM v_ECP - + @@ -2919,7 +3004,7 @@ FROM v_ECP - + @@ -2957,7 +3042,7 @@ FROM v_ECP - + @@ -2996,7 +3081,7 @@ FROM v_ECP - + @@ -3062,7 +3147,7 @@ FROM v_ECP - + @@ -3139,7 +3224,7 @@ FROM v_ECP - + @@ -3174,7 +3259,7 @@ FROM v_ECP - + @@ -3196,6 +3281,26 @@ FROM v_ECP + + + + + + + + + + + + + + + + + + + + @@ -3272,5 +3377,9 @@ FROM v_ECP + + + + \ No newline at end of file diff --git a/MapoDb/DS_ProdTempi.xss b/MapoDb/DS_ProdTempi.xss index 17698765..c903ecb9 100644 --- a/MapoDb/DS_ProdTempi.xss +++ b/MapoDb/DS_ProdTempi.xss @@ -6,29 +6,30 @@ --> - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MapoDb/DS_ProdTempi1.Designer.cs b/MapoDb/DS_ProdTempi1.Designer.cs index 5d3ebed0..ab00ab4d 100644 --- a/MapoDb/DS_ProdTempi1.Designer.cs +++ b/MapoDb/DS_ProdTempi1.Designer.cs @@ -70,6 +70,8 @@ namespace MapoDb { private StatoProdDataTable tableStatoProd; + private Macchine2SlaveDataTable tableMacchine2Slave; + private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -167,6 +169,9 @@ namespace MapoDb { if ((ds.Tables["StatoProd"] != null)) { base.Tables.Add(new StatoProdDataTable(ds.Tables["StatoProd"])); } + if ((ds.Tables["Macchine2Slave"] != null)) { + base.Tables.Add(new Macchine2SlaveDataTable(ds.Tables["Macchine2Slave"])); + } this.DataSetName = ds.DataSetName; this.Prefix = ds.Prefix; this.Namespace = ds.Namespace; @@ -415,6 +420,16 @@ namespace MapoDb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public Macchine2SlaveDataTable Macchine2Slave { + get { + return this.tableMacchine2Slave; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.BrowsableAttribute(true)] @@ -551,6 +566,9 @@ namespace MapoDb { if ((ds.Tables["StatoProd"] != null)) { base.Tables.Add(new StatoProdDataTable(ds.Tables["StatoProd"])); } + if ((ds.Tables["Macchine2Slave"] != null)) { + base.Tables.Add(new Macchine2SlaveDataTable(ds.Tables["Macchine2Slave"])); + } this.DataSetName = ds.DataSetName; this.Prefix = ds.Prefix; this.Namespace = ds.Namespace; @@ -722,6 +740,12 @@ namespace MapoDb { this.tableStatoProd.InitVars(); } } + this.tableMacchine2Slave = ((Macchine2SlaveDataTable)(base.Tables["Macchine2Slave"])); + if ((initTable == true)) { + if ((this.tableMacchine2Slave != null)) { + this.tableMacchine2Slave.InitVars(); + } + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -778,6 +802,8 @@ namespace MapoDb { base.Tables.Add(this.tableElencoConfermeProd); this.tableStatoProd = new StatoProdDataTable(); base.Tables.Add(this.tableStatoProd); + this.tableMacchine2Slave = new Macchine2SlaveDataTable(); + base.Tables.Add(this.tableMacchine2Slave); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -918,6 +944,12 @@ namespace MapoDb { return false; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + private bool ShouldSerializeMacchine2Slave() { + return false; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] private void SchemaChanged(object sender, global::System.ComponentModel.CollectionChangeEventArgs e) { @@ -1042,6 +1074,9 @@ namespace MapoDb { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] public delegate void StatoProdRowChangeEventHandler(object sender, StatoProdRowChangeEvent e); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public delegate void Macchine2SlaveRowChangeEventHandler(object sender, Macchine2SlaveRowChangeEvent e); + /// ///Represents the strongly named DataTable class. /// @@ -10084,6 +10119,281 @@ namespace MapoDb { } } + /// + ///Represents the strongly named DataTable class. + /// + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class Macchine2SlaveDataTable : global::System.Data.TypedTableBase { + + private global::System.Data.DataColumn columnIdxMacchina; + + private global::System.Data.DataColumn columnIdxMacchinaSlave; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveDataTable() { + this.TableName = "Macchine2Slave"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + internal Macchine2SlaveDataTable(global::System.Data.DataTable table) { + this.TableName = table.TableName; + if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { + this.CaseSensitive = table.CaseSensitive; + } + if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { + this.Locale = table.Locale; + } + if ((table.Namespace != table.DataSet.Namespace)) { + this.Namespace = table.Namespace; + } + this.Prefix = table.Prefix; + this.MinimumCapacity = table.MinimumCapacity; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected Macchine2SlaveDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : + base(info, context) { + this.InitVars(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public global::System.Data.DataColumn IdxMacchinaColumn { + get { + return this.columnIdxMacchina; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public global::System.Data.DataColumn IdxMacchinaSlaveColumn { + get { + return this.columnIdxMacchinaSlave; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Browsable(false)] + public int Count { + get { + return this.Rows.Count; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveRow this[int index] { + get { + return ((Macchine2SlaveRow)(this.Rows[index])); + } + } + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public event Macchine2SlaveRowChangeEventHandler Macchine2SlaveRowChanging; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public event Macchine2SlaveRowChangeEventHandler Macchine2SlaveRowChanged; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public event Macchine2SlaveRowChangeEventHandler Macchine2SlaveRowDeleting; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public event Macchine2SlaveRowChangeEventHandler Macchine2SlaveRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public void AddMacchine2SlaveRow(Macchine2SlaveRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveRow AddMacchine2SlaveRow(string IdxMacchina, string IdxMacchinaSlave) { + Macchine2SlaveRow rowMacchine2SlaveRow = ((Macchine2SlaveRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + IdxMacchina, + IdxMacchinaSlave}; + rowMacchine2SlaveRow.ItemArray = columnValuesArray; + this.Rows.Add(rowMacchine2SlaveRow); + return rowMacchine2SlaveRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveRow FindByIdxMacchina(string IdxMacchina) { + return ((Macchine2SlaveRow)(this.Rows.Find(new object[] { + IdxMacchina}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public override global::System.Data.DataTable Clone() { + Macchine2SlaveDataTable cln = ((Macchine2SlaveDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override global::System.Data.DataTable CreateInstance() { + return new Macchine2SlaveDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + internal void InitVars() { + this.columnIdxMacchina = base.Columns["IdxMacchina"]; + this.columnIdxMacchinaSlave = base.Columns["IdxMacchinaSlave"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + private void InitClass() { + this.columnIdxMacchina = new global::System.Data.DataColumn("IdxMacchina", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnIdxMacchina); + this.columnIdxMacchinaSlave = new global::System.Data.DataColumn("IdxMacchinaSlave", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnIdxMacchinaSlave); + this.Constraints.Add(new global::System.Data.UniqueConstraint("Constraint1", new global::System.Data.DataColumn[] { + this.columnIdxMacchina}, true)); + this.columnIdxMacchina.AllowDBNull = false; + this.columnIdxMacchina.Unique = true; + this.columnIdxMacchina.MaxLength = 50; + this.columnIdxMacchinaSlave.AllowDBNull = false; + this.columnIdxMacchinaSlave.MaxLength = 50; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveRow NewMacchine2SlaveRow() { + return ((Macchine2SlaveRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new Macchine2SlaveRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override global::System.Type GetRowType() { + return typeof(Macchine2SlaveRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.Macchine2SlaveRowChanged != null)) { + this.Macchine2SlaveRowChanged(this, new Macchine2SlaveRowChangeEvent(((Macchine2SlaveRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.Macchine2SlaveRowChanging != null)) { + this.Macchine2SlaveRowChanging(this, new Macchine2SlaveRowChangeEvent(((Macchine2SlaveRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.Macchine2SlaveRowDeleted != null)) { + this.Macchine2SlaveRowDeleted(this, new Macchine2SlaveRowChangeEvent(((Macchine2SlaveRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.Macchine2SlaveRowDeleting != null)) { + this.Macchine2SlaveRowDeleting(this, new Macchine2SlaveRowChangeEvent(((Macchine2SlaveRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public void RemoveMacchine2SlaveRow(Macchine2SlaveRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { + global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); + global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); + DS_ProdTempi ds = new DS_ProdTempi(); + global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); + any1.Namespace = "http://www.w3.org/2001/XMLSchema"; + any1.MinOccurs = new decimal(0); + any1.MaxOccurs = decimal.MaxValue; + any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any1); + global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); + any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; + any2.MinOccurs = new decimal(1); + any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; + sequence.Items.Add(any2); + global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute1.Name = "namespace"; + attribute1.FixedValue = ds.Namespace; + type.Attributes.Add(attribute1); + global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); + attribute2.Name = "tableTypeName"; + attribute2.FixedValue = "Macchine2SlaveDataTable"; + type.Attributes.Add(attribute2); + type.Particle = sequence; + global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); + if (xs.Contains(dsSchema.TargetNamespace)) { + global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); + global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); + try { + global::System.Xml.Schema.XmlSchema schema = null; + dsSchema.Write(s1); + for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { + schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); + s2.SetLength(0); + schema.Write(s2); + if ((s1.Length == s2.Length)) { + s1.Position = 0; + s2.Position = 0; + for (; ((s1.Position != s1.Length) + && (s1.ReadByte() == s2.ReadByte())); ) { + ; + } + if ((s1.Position == s1.Length)) { + return type; + } + } + } + } + finally { + if ((s1 != null)) { + s1.Close(); + } + if ((s2 != null)) { + s2.Close(); + } + } + } + xs.Add(dsSchema); + return type; + } + } + /// ///Represents strongly named DataRow class. /// @@ -15322,6 +15632,43 @@ namespace MapoDb { } } + /// + ///Represents strongly named DataRow class. + /// + public partial class Macchine2SlaveRow : global::System.Data.DataRow { + + private Macchine2SlaveDataTable tableMacchine2Slave; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + internal Macchine2SlaveRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableMacchine2Slave = ((Macchine2SlaveDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public string IdxMacchina { + get { + return ((string)(this[this.tableMacchine2Slave.IdxMacchinaColumn])); + } + set { + this[this.tableMacchine2Slave.IdxMacchinaColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public string IdxMacchinaSlave { + get { + return ((string)(this[this.tableMacchine2Slave.IdxMacchinaSlaveColumn])); + } + set { + this[this.tableMacchine2Slave.IdxMacchinaSlaveColumn] = value; + } + } + } + /// ///Row event argument class /// @@ -16103,6 +16450,40 @@ namespace MapoDb { } } } + + /// + ///Row event argument class + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public class Macchine2SlaveRowChangeEvent : global::System.EventArgs { + + private Macchine2SlaveRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveRowChangeEvent(Macchine2SlaveRow row, global::System.Data.DataRowAction action) { + this.eventRow = row; + this.eventAction = action; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } } } namespace MapoDb.DS_ProdTempiTableAdapters { @@ -17063,7 +17444,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] private void InitCommandCollection() { - this._commandCollection = new global::System.Data.SqlClient.SqlCommand[24]; + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[25]; this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[0].Connection = this.Connection; this._commandCollection[0].CommandText = "SELECT * FROM dbo.v_ODL_exp\r\nORDER BY idxODL DESC"; @@ -17100,41 +17481,41 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile this._commandCollection[4].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[5] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[5].Connection = this.Connection; - this._commandCollection[5].CommandText = "dbo.stp_ODL_getByCodArt"; + this._commandCollection[5].CommandText = "dbo.stp_ODL_fixMachineSlave"; this._commandCollection[5].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumDayPrev", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DoInsert", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[6] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[6].Connection = this.Connection; - this._commandCollection[6].CommandText = "dbo.stp_ODL_getByIdx"; + this._commandCollection[6].CommandText = "dbo.stp_ODL_getByCodArt"; this._commandCollection[6].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@onlyUnused", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[7] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[7].Connection = this.Connection; - this._commandCollection[7].CommandText = "dbo.stp_ODL_getByMacchina"; + this._commandCollection[7].CommandText = "dbo.stp_ODL_getByIdx"; this._commandCollection[7].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@onlyUnused", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[8] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[8].Connection = this.Connection; - this._commandCollection[8].CommandText = "dbo.stp_ODL_getByMacchinaCodArt"; + this._commandCollection[8].CommandText = "dbo.stp_ODL_getByMacchina"; this._commandCollection[8].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[9] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[9].Connection = this.Connection; - this._commandCollection[9].CommandText = "dbo.stp_ODL_getByMacchinaPeriodo"; + this._commandCollection[9].CommandText = "dbo.stp_ODL_getByMacchinaCodArt"; this._commandCollection[9].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dataFrom", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dataTo", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[10] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[10].Connection = this.Connection; - this._commandCollection[10].CommandText = "dbo.stp_ODL_getByMacchinaPeriodoNoNull"; + this._commandCollection[10].CommandText = "dbo.stp_ODL_getByMacchinaPeriodo"; this._commandCollection[10].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[10].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[10].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); @@ -17142,32 +17523,29 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile this._commandCollection[10].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dataTo", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[11] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[11].Connection = this.Connection; - this._commandCollection[11].CommandText = "dbo.stp_ODL_getLastByMacchina"; + this._commandCollection[11].CommandText = "dbo.stp_ODL_getByMacchinaPeriodoNoNull"; this._commandCollection[11].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[11].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[11].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[11].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dataFrom", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[11].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dataTo", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[12] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[12].Connection = this.Connection; - this._commandCollection[12].CommandText = "dbo.stp_ODL_needAppr"; + this._commandCollection[12].CommandText = "dbo.stp_ODL_getLastByMacchina"; this._commandCollection[12].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[12].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[12].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[13] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[13].Connection = this.Connection; - this._commandCollection[13].CommandText = "dbo.stp_ODL_inizioSetup"; + this._commandCollection[13].CommandText = "dbo.stp_ODL_needAppr"; this._commandCollection[13].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[13].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[14] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[14].Connection = this.Connection; - this._commandCollection[14].CommandText = "dbo.stp_ODL_inizioSetupPromessa"; + this._commandCollection[14].CommandText = "dbo.stp_ODL_inizioSetup"; this._commandCollection[14].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxPromessa", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); @@ -17175,26 +17553,26 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile this._commandCollection[14].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[15] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[15].Connection = this.Connection; - this._commandCollection[15].CommandText = "dbo.stp_ODL_inizioSetupPromessaPostuma"; + this._commandCollection[15].CommandText = "dbo.stp_ODL_inizioSetupPromessa"; this._commandCollection[15].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxPromessa", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[15].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[16] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[16].Connection = this.Connection; - this._commandCollection[16].CommandText = "dbo.stp_ODL_insertProvv"; + this._commandCollection[16].CommandText = "dbo.stp_ODL_inizioSetupPromessaPostuma"; this._commandCollection[16].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxPromessa", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumPezzi", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCAssegnato", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[16].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[17] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[17].Connection = this.Connection; - this._commandCollection[17].CommandText = "dbo.stp_ODL_insertQuery"; + this._commandCollection[17].CommandText = "dbo.stp_ODL_insertProvv"; this._commandCollection[17].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); @@ -17202,67 +17580,78 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumPezzi", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCAssegnato", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@ToAs400", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CommessaAs400", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[17].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[18] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[18].Connection = this.Connection; - this._commandCollection[18].CommandText = "dbo.stp_ODL_insPostumo"; + this._commandCollection[18].CommandText = "dbo.stp_ODL_insertQuery"; this._commandCollection[18].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumPezzi", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCAssegnato", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@ToAs400", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[18].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CommessaAs400", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[19] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[19].Connection = this.Connection; - this._commandCollection[19].CommandText = "dbo.stp_ODL_reopenOdlMacc"; + this._commandCollection[19].CommandText = "dbo.stp_ODL_insPostumo"; this._commandCollection[19].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[19].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[20] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[20].Connection = this.Connection; - this._commandCollection[20].CommandText = "dbo.stp_ODL_split"; + this._commandCollection[20].CommandText = "dbo.stp_ODL_reopenOdlMacc"; this._commandCollection[20].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@StartNewOdl", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[21] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[21].Connection = this.Connection; - this._commandCollection[21].CommandText = "dbo.stp_ODL_updateQta"; + this._commandCollection[21].CommandText = "dbo.stp_ODL_split"; this._commandCollection[21].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumPezzi", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[21].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@StartNewOdl", global::System.Data.SqlDbType.Bit, 1, global::System.Data.ParameterDirection.Input, 1, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[22] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[22].Connection = this.Connection; - this._commandCollection[22].CommandText = "dbo.stp_ODL_update"; + this._commandCollection[22].CommandText = "dbo.stp_ODL_updateQta"; this._commandCollection[22].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumPezzi", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCAssegnato", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DataInizio", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DataFine", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[22].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[23] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[23].Connection = this.Connection; - this._commandCollection[23].CommandText = "dbo.stp_ODL_updateSetup"; + this._commandCollection[23].CommandText = "dbo.stp_ODL_update"; this._commandCollection[23].CommandType = global::System.Data.CommandType.StoredProcedure; this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@NumPezzi", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCAssegnato", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DataInizio", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DataFine", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[23].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[24].Connection = this.Connection; + this._commandCollection[24].CommandText = "dbo.stp_ODL_updateSetup"; + this._commandCollection[24].CommandType = global::System.Data.CommandType.StoredProcedure; + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MatrOpr", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[24].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -17294,7 +17683,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable getByCodArt(string CodArticolo) { - this.Adapter.SelectCommand = this.CommandCollection[5]; + this.Adapter.SelectCommand = this.CommandCollection[6]; if ((CodArticolo == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; } @@ -17311,7 +17700,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable getByIdx(global::System.Nullable IdxODL, global::System.Nullable onlyUnused) { - this.Adapter.SelectCommand = this.CommandCollection[6]; + this.Adapter.SelectCommand = this.CommandCollection[7]; if ((IdxODL.HasValue == true)) { this.Adapter.SelectCommand.Parameters[1].Value = ((int)(IdxODL.Value)); } @@ -17334,7 +17723,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable getByMacchina(string IdxMacchina) { - this.Adapter.SelectCommand = this.CommandCollection[7]; + this.Adapter.SelectCommand = this.CommandCollection[8]; if ((IdxMacchina == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; } @@ -17351,7 +17740,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable getByMacchinaArticolo(string CodArticolo, string IdxMacchina) { - this.Adapter.SelectCommand = this.CommandCollection[8]; + this.Adapter.SelectCommand = this.CommandCollection[9]; if ((CodArticolo == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; } @@ -17374,35 +17763,6 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable getByMacchinaPeriodo(string IdxMacchina, global::System.Nullable dataFrom, global::System.Nullable dataTo) { - this.Adapter.SelectCommand = this.CommandCollection[9]; - if ((IdxMacchina == null)) { - this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; - } - else { - this.Adapter.SelectCommand.Parameters[1].Value = ((string)(IdxMacchina)); - } - if ((dataFrom.HasValue == true)) { - this.Adapter.SelectCommand.Parameters[2].Value = ((System.DateTime)(dataFrom.Value)); - } - else { - this.Adapter.SelectCommand.Parameters[2].Value = global::System.DBNull.Value; - } - if ((dataTo.HasValue == true)) { - this.Adapter.SelectCommand.Parameters[3].Value = ((System.DateTime)(dataTo.Value)); - } - else { - this.Adapter.SelectCommand.Parameters[3].Value = global::System.DBNull.Value; - } - DS_ProdTempi.ODLDataTable dataTable = new DS_ProdTempi.ODLDataTable(); - this.Adapter.Fill(dataTable); - return dataTable; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] - [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] - [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] - public virtual DS_ProdTempi.ODLDataTable getByMacchinaPeriodoNoNull(string IdxMacchina, global::System.Nullable dataFrom, global::System.Nullable dataTo) { this.Adapter.SelectCommand = this.CommandCollection[10]; if ((IdxMacchina == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; @@ -17431,7 +17791,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] - public virtual DS_ProdTempi.ODLDataTable getLastByMacc(string IdxMacchina) { + public virtual DS_ProdTempi.ODLDataTable getByMacchinaPeriodoNoNull(string IdxMacchina, global::System.Nullable dataFrom, global::System.Nullable dataTo) { this.Adapter.SelectCommand = this.CommandCollection[11]; if ((IdxMacchina == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; @@ -17439,6 +17799,35 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile else { this.Adapter.SelectCommand.Parameters[1].Value = ((string)(IdxMacchina)); } + if ((dataFrom.HasValue == true)) { + this.Adapter.SelectCommand.Parameters[2].Value = ((System.DateTime)(dataFrom.Value)); + } + else { + this.Adapter.SelectCommand.Parameters[2].Value = global::System.DBNull.Value; + } + if ((dataTo.HasValue == true)) { + this.Adapter.SelectCommand.Parameters[3].Value = ((System.DateTime)(dataTo.Value)); + } + else { + this.Adapter.SelectCommand.Parameters[3].Value = global::System.DBNull.Value; + } + DS_ProdTempi.ODLDataTable dataTable = new DS_ProdTempi.ODLDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_ProdTempi.ODLDataTable getLastByMacc(string IdxMacchina) { + this.Adapter.SelectCommand = this.CommandCollection[12]; + if ((IdxMacchina == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(IdxMacchina)); + } DS_ProdTempi.ODLDataTable dataTable = new DS_ProdTempi.ODLDataTable(); this.Adapter.Fill(dataTable); return dataTable; @@ -17449,7 +17838,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable getNeedAppr() { - this.Adapter.SelectCommand = this.CommandCollection[12]; + this.Adapter.SelectCommand = this.CommandCollection[13]; DS_ProdTempi.ODLDataTable dataTable = new DS_ProdTempi.ODLDataTable(); this.Adapter.Fill(dataTable); return dataTable; @@ -17460,7 +17849,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] public virtual DS_ProdTempi.ODLDataTable reopenGetLast(string IdxMacchina) { - this.Adapter.SelectCommand = this.CommandCollection[19]; + this.Adapter.SelectCommand = this.CommandCollection[20]; if ((IdxMacchina == null)) { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; } @@ -17621,11 +18010,51 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile return returnValue; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int fixMachineSlave(string IdxMacchina, global::System.Nullable NumDayPrev, global::System.Nullable DoInsert) { + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[5]; + if ((IdxMacchina == null)) { + command.Parameters[1].Value = global::System.DBNull.Value; + } + else { + command.Parameters[1].Value = ((string)(IdxMacchina)); + } + if ((NumDayPrev.HasValue == true)) { + command.Parameters[2].Value = ((int)(NumDayPrev.Value)); + } + else { + command.Parameters[2].Value = global::System.DBNull.Value; + } + if ((DoInsert.HasValue == true)) { + command.Parameters[3].Value = ((int)(DoInsert.Value)); + } + else { + command.Parameters[3].Value = global::System.DBNull.Value; + } + global::System.Data.ConnectionState previousConnectionState = command.Connection.State; + if (((command.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + command.Connection.Open(); + } + int returnValue; + try { + returnValue = command.ExecuteNonQuery(); + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + command.Connection.Close(); + } + } + return returnValue; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int inizioSetup(global::System.Nullable idxODL, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable TCRichAttr, global::System.Nullable PzPallet, string Note) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[13]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[14]; if ((idxODL.HasValue == true)) { command.Parameters[1].Value = ((int)(idxODL.Value)); } @@ -17683,7 +18112,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int inizioSetupPromessa(global::System.Nullable idxPromessa, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable TCRichAttr, global::System.Nullable PzPallet, string Note) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[14]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[15]; if ((idxPromessa.HasValue == true)) { command.Parameters[1].Value = ((int)(idxPromessa.Value)); } @@ -17741,7 +18170,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int inizioSetupPromessaPostuma(global::System.Nullable idxPromessa, global::System.Nullable MatrOpr, string IdxMacchina) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[15]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[16]; if ((idxPromessa.HasValue == true)) { command.Parameters[1].Value = ((int)(idxPromessa.Value)); } @@ -17781,7 +18210,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int insertProvv(string CodArticolo, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable NumPezzi, global::System.Nullable TCAssegnato, string Note) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[16]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[17]; if ((CodArticolo == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -17840,7 +18269,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Insert, false)] public virtual int InsertQuery(string CodArticolo, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable NumPezzi, global::System.Nullable TCAssegnato, global::System.Nullable PzPallet, global::System.Nullable ToAs400, string CommessaAs400) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[17]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[18]; if ((CodArticolo == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -17910,7 +18339,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int insPostumo(global::System.Nullable idxODL, string IdxMacchina) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[18]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[19]; if ((idxODL.HasValue == true)) { command.Parameters[1].Value = ((int)(idxODL.Value)); } @@ -17944,7 +18373,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int splitODL(global::System.Nullable idxODL, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable TCRichAttr, global::System.Nullable PzPallet, string Note, global::System.Nullable StartNewOdl) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[20]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[21]; if ((idxODL.HasValue == true)) { command.Parameters[1].Value = ((int)(idxODL.Value)); } @@ -18008,7 +18437,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int updateQta(global::System.Nullable NumPezzi, global::System.Nullable PzPallet, global::System.Nullable Original_IdxODL) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[21]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[22]; if ((NumPezzi.HasValue == true)) { command.Parameters[1].Value = ((int)(NumPezzi.Value)); } @@ -18049,7 +18478,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, false)] public virtual int UpdateQuery(string CodArticolo, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable NumPezzi, global::System.Nullable TCAssegnato, global::System.Nullable PzPallet, global::System.Nullable DataInizio, global::System.Nullable DataFine, string Note, global::System.Nullable Original_IdxODL) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[22]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[23]; if ((CodArticolo == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -18131,7 +18560,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int updateSetup(global::System.Nullable idxODL, global::System.Nullable MatrOpr, global::System.Nullable TCRichAttr, global::System.Nullable PzPallet, string Note) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[23]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[24]; if ((idxODL.HasValue == true)) { command.Parameters[1].Value = ((int)(idxODL.Value)); } @@ -28244,6 +28673,393 @@ FROM MappaStatoExpl"; } } + /// + ///Represents the connection and commands used to retrieve and save data. + /// + [global::System.ComponentModel.DesignerCategoryAttribute("code")] + [global::System.ComponentModel.ToolboxItem(true)] + [global::System.ComponentModel.DataObjectAttribute(true)] + [global::System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterDesigner, Microsoft.VSDesigner" + + ", Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public partial class Macchine2SlaveTableAdapter : global::System.ComponentModel.Component { + + private global::System.Data.SqlClient.SqlDataAdapter _adapter; + + private global::System.Data.SqlClient.SqlConnection _connection; + + private global::System.Data.SqlClient.SqlTransaction _transaction; + + private global::System.Data.SqlClient.SqlCommand[] _commandCollection; + + private bool _clearBeforeFill; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public Macchine2SlaveTableAdapter() { + this.ClearBeforeFill = true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected internal global::System.Data.SqlClient.SqlDataAdapter Adapter { + get { + if ((this._adapter == null)) { + this.InitAdapter(); + } + return this._adapter; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + internal global::System.Data.SqlClient.SqlConnection Connection { + get { + if ((this._connection == null)) { + this.InitConnection(); + } + return this._connection; + } + set { + this._connection = value; + if ((this.Adapter.InsertCommand != null)) { + this.Adapter.InsertCommand.Connection = value; + } + if ((this.Adapter.DeleteCommand != null)) { + this.Adapter.DeleteCommand.Connection = value; + } + if ((this.Adapter.UpdateCommand != null)) { + this.Adapter.UpdateCommand.Connection = value; + } + for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1)) { + if ((this.CommandCollection[i] != null)) { + ((global::System.Data.SqlClient.SqlCommand)(this.CommandCollection[i])).Connection = value; + } + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + internal global::System.Data.SqlClient.SqlTransaction Transaction { + get { + return this._transaction; + } + set { + this._transaction = value; + for (int i = 0; (i < this.CommandCollection.Length); i = (i + 1)) { + this.CommandCollection[i].Transaction = this._transaction; + } + if (((this.Adapter != null) + && (this.Adapter.DeleteCommand != null))) { + this.Adapter.DeleteCommand.Transaction = this._transaction; + } + if (((this.Adapter != null) + && (this.Adapter.InsertCommand != null))) { + this.Adapter.InsertCommand.Transaction = this._transaction; + } + if (((this.Adapter != null) + && (this.Adapter.UpdateCommand != null))) { + this.Adapter.UpdateCommand.Transaction = this._transaction; + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + protected global::System.Data.SqlClient.SqlCommand[] CommandCollection { + get { + if ((this._commandCollection == null)) { + this.InitCommandCollection(); + } + return this._commandCollection; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + public bool ClearBeforeFill { + get { + return this._clearBeforeFill; + } + set { + this._clearBeforeFill = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + private void InitAdapter() { + this._adapter = new global::System.Data.SqlClient.SqlDataAdapter(); + global::System.Data.Common.DataTableMapping tableMapping = new global::System.Data.Common.DataTableMapping(); + tableMapping.SourceTable = "Table"; + tableMapping.DataSetTable = "Macchine2Slave"; + tableMapping.ColumnMappings.Add("IdxMacchina", "IdxMacchina"); + tableMapping.ColumnMappings.Add("IdxMacchinaSlave", "IdxMacchinaSlave"); + this._adapter.TableMappings.Add(tableMapping); + this._adapter.DeleteCommand = new global::System.Data.SqlClient.SqlCommand(); + this._adapter.DeleteCommand.Connection = this.Connection; + this._adapter.DeleteCommand.CommandText = "DELETE FROM [Macchine2Slave] WHERE (([IdxMacchina] = @Original_IdxMacchina) AND (" + + "[IdxMacchinaSlave] = @Original_IdxMacchinaSlave))"; + this._adapter.DeleteCommand.CommandType = global::System.Data.CommandType.Text; + this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxMacchina", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchina", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxMacchinaSlave", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchinaSlave", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.InsertCommand = new global::System.Data.SqlClient.SqlCommand(); + this._adapter.InsertCommand.Connection = this.Connection; + this._adapter.InsertCommand.CommandText = "INSERT INTO [Macchine2Slave] ([IdxMacchina], [IdxMacchinaSlave]) VALUES (@IdxMacc" + + "hina, @IdxMacchinaSlave);\r\nSELECT IdxMacchina, IdxMacchinaSlave FROM Macchine2Sl" + + "ave WHERE (IdxMacchina = @IdxMacchina) AND (IdxMacchinaSlave = @IdxMacchinaSlave" + + ")"; + this._adapter.InsertCommand.CommandType = global::System.Data.CommandType.Text; + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchina", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchinaSlave", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchinaSlave", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand = new global::System.Data.SqlClient.SqlCommand(); + this._adapter.UpdateCommand.Connection = this.Connection; + this._adapter.UpdateCommand.CommandText = @"UPDATE [Macchine2Slave] SET [IdxMacchina] = @IdxMacchina, [IdxMacchinaSlave] = @IdxMacchinaSlave WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([IdxMacchinaSlave] = @Original_IdxMacchinaSlave)); +SELECT IdxMacchina, IdxMacchinaSlave FROM Macchine2Slave WHERE (IdxMacchina = @IdxMacchina) AND (IdxMacchinaSlave = @IdxMacchinaSlave)"; + this._adapter.UpdateCommand.CommandType = global::System.Data.CommandType.Text; + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchina", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchinaSlave", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchinaSlave", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxMacchina", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchina", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_IdxMacchinaSlave", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxMacchinaSlave", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + private void InitConnection() { + this._connection = new global::System.Data.SqlClient.SqlConnection(); + this._connection.ConnectionString = global::MapoDb.Properties.Settings.Default.MoonProConnectionString; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + private void InitCommandCollection() { + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[3]; + this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[0].Connection = this.Connection; + this._commandCollection[0].CommandText = "SELECT IdxMacchina, IdxMacchinaSlave\r\nFROM Macchine2Slave"; + this._commandCollection[0].CommandType = global::System.Data.CommandType.Text; + this._commandCollection[1] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[1].Connection = this.Connection; + this._commandCollection[1].CommandText = "dbo.stp_M2S_byMaster"; + this._commandCollection[1].CommandType = global::System.Data.CommandType.StoredProcedure; + this._commandCollection[1].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[1].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[2] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[2].Connection = this.Connection; + this._commandCollection[2].CommandText = "dbo.stp_M2S_bySlave"; + this._commandCollection[2].CommandType = global::System.Data.CommandType.StoredProcedure; + this._commandCollection[2].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[2].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Fill, true)] + public virtual int Fill(DS_ProdTempi.Macchine2SlaveDataTable dataTable) { + this.Adapter.SelectCommand = this.CommandCollection[0]; + if ((this.ClearBeforeFill == true)) { + dataTable.Clear(); + } + int returnValue = this.Adapter.Fill(dataTable); + return returnValue; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, true)] + public virtual DS_ProdTempi.Macchine2SlaveDataTable GetData() { + this.Adapter.SelectCommand = this.CommandCollection[0]; + DS_ProdTempi.Macchine2SlaveDataTable dataTable = new DS_ProdTempi.Macchine2SlaveDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_ProdTempi.Macchine2SlaveDataTable getByMaster(string IdxMacchina) { + this.Adapter.SelectCommand = this.CommandCollection[1]; + if ((IdxMacchina == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(IdxMacchina)); + } + DS_ProdTempi.Macchine2SlaveDataTable dataTable = new DS_ProdTempi.Macchine2SlaveDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_ProdTempi.Macchine2SlaveDataTable getBySlave(string IdxMacchina) { + this.Adapter.SelectCommand = this.CommandCollection[2]; + if ((IdxMacchina == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(IdxMacchina)); + } + DS_ProdTempi.Macchine2SlaveDataTable dataTable = new DS_ProdTempi.Macchine2SlaveDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(DS_ProdTempi.Macchine2SlaveDataTable dataTable) { + return this.Adapter.Update(dataTable); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(DS_ProdTempi dataSet) { + return this.Adapter.Update(dataSet, "Macchine2Slave"); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(global::System.Data.DataRow dataRow) { + return this.Adapter.Update(new global::System.Data.DataRow[] { + dataRow}); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(global::System.Data.DataRow[] dataRows) { + return this.Adapter.Update(dataRows); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Delete, true)] + public virtual int Delete(string Original_IdxMacchina, string Original_IdxMacchinaSlave) { + if ((Original_IdxMacchina == null)) { + throw new global::System.ArgumentNullException("Original_IdxMacchina"); + } + else { + this.Adapter.DeleteCommand.Parameters[0].Value = ((string)(Original_IdxMacchina)); + } + if ((Original_IdxMacchinaSlave == null)) { + throw new global::System.ArgumentNullException("Original_IdxMacchinaSlave"); + } + else { + this.Adapter.DeleteCommand.Parameters[1].Value = ((string)(Original_IdxMacchinaSlave)); + } + global::System.Data.ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State; + if (((this.Adapter.DeleteCommand.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + this.Adapter.DeleteCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.DeleteCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + this.Adapter.DeleteCommand.Connection.Close(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Insert, true)] + public virtual int Insert(string IdxMacchina, string IdxMacchinaSlave) { + if ((IdxMacchina == null)) { + throw new global::System.ArgumentNullException("IdxMacchina"); + } + else { + this.Adapter.InsertCommand.Parameters[0].Value = ((string)(IdxMacchina)); + } + if ((IdxMacchinaSlave == null)) { + throw new global::System.ArgumentNullException("IdxMacchinaSlave"); + } + else { + this.Adapter.InsertCommand.Parameters[1].Value = ((string)(IdxMacchinaSlave)); + } + global::System.Data.ConnectionState previousConnectionState = this.Adapter.InsertCommand.Connection.State; + if (((this.Adapter.InsertCommand.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + this.Adapter.InsertCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.InsertCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + this.Adapter.InsertCommand.Connection.Close(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, true)] + public virtual int Update(string IdxMacchina, string IdxMacchinaSlave, string Original_IdxMacchina, string Original_IdxMacchinaSlave) { + if ((IdxMacchina == null)) { + throw new global::System.ArgumentNullException("IdxMacchina"); + } + else { + this.Adapter.UpdateCommand.Parameters[0].Value = ((string)(IdxMacchina)); + } + if ((IdxMacchinaSlave == null)) { + throw new global::System.ArgumentNullException("IdxMacchinaSlave"); + } + else { + this.Adapter.UpdateCommand.Parameters[1].Value = ((string)(IdxMacchinaSlave)); + } + if ((Original_IdxMacchina == null)) { + throw new global::System.ArgumentNullException("Original_IdxMacchina"); + } + else { + this.Adapter.UpdateCommand.Parameters[2].Value = ((string)(Original_IdxMacchina)); + } + if ((Original_IdxMacchinaSlave == null)) { + throw new global::System.ArgumentNullException("Original_IdxMacchinaSlave"); + } + else { + this.Adapter.UpdateCommand.Parameters[3].Value = ((string)(Original_IdxMacchinaSlave)); + } + global::System.Data.ConnectionState previousConnectionState = this.Adapter.UpdateCommand.Connection.State; + if (((this.Adapter.UpdateCommand.Connection.State & global::System.Data.ConnectionState.Open) + != global::System.Data.ConnectionState.Open)) { + this.Adapter.UpdateCommand.Connection.Open(); + } + try { + int returnValue = this.Adapter.UpdateCommand.ExecuteNonQuery(); + return returnValue; + } + finally { + if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) { + this.Adapter.UpdateCommand.Connection.Close(); + } + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Update, true)] + public virtual int Update(string IdxMacchinaSlave, string Original_IdxMacchina, string Original_IdxMacchinaSlave) { + return this.Update(Original_IdxMacchina, IdxMacchinaSlave, Original_IdxMacchina, Original_IdxMacchinaSlave); + } + } + /// ///TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios /// @@ -28272,6 +29088,8 @@ FROM MappaStatoExpl"; private MappaStatoExplTableAdapter _mappaStatoExplTableAdapter; + private Macchine2SlaveTableAdapter _macchine2SlaveTableAdapter; + private bool _backupDataSetBeforeUpdate; private global::System.Data.IDbConnection _connection; @@ -28399,6 +29217,20 @@ FROM MappaStatoExpl"; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] + [global::System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.DataSource.Design.TableAdapterManagerPropertyEditor, Microso" + + "ft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3" + + "a", "System.Drawing.Design.UITypeEditor")] + public Macchine2SlaveTableAdapter Macchine2SlaveTableAdapter { + get { + return this._macchine2SlaveTableAdapter; + } + set { + this._macchine2SlaveTableAdapter = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] public bool BackupDataSetBeforeUpdate { @@ -28450,6 +29282,10 @@ FROM MappaStatoExpl"; && (this._mappaStatoExplTableAdapter.Connection != null))) { return this._mappaStatoExplTableAdapter.Connection; } + if (((this._macchine2SlaveTableAdapter != null) + && (this._macchine2SlaveTableAdapter.Connection != null))) { + return this._macchine2SlaveTableAdapter.Connection; + } return null; } set { @@ -28487,6 +29323,9 @@ FROM MappaStatoExpl"; if ((this._mappaStatoExplTableAdapter != null)) { count = (count + 1); } + if ((this._macchine2SlaveTableAdapter != null)) { + count = (count + 1); + } return count; } } @@ -28570,6 +29409,15 @@ FROM MappaStatoExpl"; allChangedRows.AddRange(updatedRows); } } + if ((this._macchine2SlaveTableAdapter != null)) { + global::System.Data.DataRow[] updatedRows = dataSet.Macchine2Slave.Select(null, null, global::System.Data.DataViewRowState.ModifiedCurrent); + updatedRows = this.GetRealUpdatedRows(updatedRows, allAddedRows); + if (((updatedRows != null) + && (0 < updatedRows.Length))) { + result = (result + this._macchine2SlaveTableAdapter.Update(updatedRows)); + allChangedRows.AddRange(updatedRows); + } + } return result; } @@ -28644,6 +29492,14 @@ FROM MappaStatoExpl"; allAddedRows.AddRange(addedRows); } } + if ((this._macchine2SlaveTableAdapter != null)) { + global::System.Data.DataRow[] addedRows = dataSet.Macchine2Slave.Select(null, null, global::System.Data.DataViewRowState.Added); + if (((addedRows != null) + && (0 < addedRows.Length))) { + result = (result + this._macchine2SlaveTableAdapter.Update(addedRows)); + allAddedRows.AddRange(addedRows); + } + } return result; } @@ -28654,6 +29510,14 @@ FROM MappaStatoExpl"; [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "16.0.0.0")] private int UpdateDeletedRows(DS_ProdTempi dataSet, global::System.Collections.Generic.List allChangedRows) { int result = 0; + if ((this._macchine2SlaveTableAdapter != null)) { + global::System.Data.DataRow[] deletedRows = dataSet.Macchine2Slave.Select(null, null, global::System.Data.DataViewRowState.Deleted); + if (((deletedRows != null) + && (0 < deletedRows.Length))) { + result = (result + this._macchine2SlaveTableAdapter.Update(deletedRows)); + allChangedRows.AddRange(deletedRows); + } + } if ((this._anagArticoliTableAdapter != null)) { global::System.Data.DataRow[] deletedRows = dataSet.AnagArticoli.Select(null, null, global::System.Data.DataViewRowState.Deleted); if (((deletedRows != null) @@ -28797,6 +29661,11 @@ FROM MappaStatoExpl"; throw new global::System.ArgumentException("Tutti gli oggetti TableAdapter gestiti da TableAdapterManager devono utilizzare l" + "a stessa stringa di connessione."); } + if (((this._macchine2SlaveTableAdapter != null) + && (this.MatchTableAdapterConnection(this._macchine2SlaveTableAdapter.Connection) == false))) { + throw new global::System.ArgumentException("Tutti gli oggetti TableAdapter gestiti da TableAdapterManager devono utilizzare l" + + "a stessa stringa di connessione."); + } global::System.Data.IDbConnection workConnection = this.Connection; if ((workConnection == null)) { throw new global::System.ApplicationException("TableAdapterManager non contiene informazioni di connessione. Impostare la propri" + @@ -28902,6 +29771,15 @@ FROM MappaStatoExpl"; adaptersWithAcceptChangesDuringUpdate.Add(this._mappaStatoExplTableAdapter.Adapter); } } + if ((this._macchine2SlaveTableAdapter != null)) { + revertConnections.Add(this._macchine2SlaveTableAdapter, this._macchine2SlaveTableAdapter.Connection); + this._macchine2SlaveTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(workConnection)); + this._macchine2SlaveTableAdapter.Transaction = ((global::System.Data.SqlClient.SqlTransaction)(workTransaction)); + if (this._macchine2SlaveTableAdapter.Adapter.AcceptChangesDuringUpdate) { + this._macchine2SlaveTableAdapter.Adapter.AcceptChangesDuringUpdate = false; + adaptersWithAcceptChangesDuringUpdate.Add(this._macchine2SlaveTableAdapter.Adapter); + } + } // //---- Perform updates ----------- // @@ -28992,6 +29870,10 @@ FROM MappaStatoExpl"; this._mappaStatoExplTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(revertConnections[this._mappaStatoExplTableAdapter])); this._mappaStatoExplTableAdapter.Transaction = null; } + if ((this._macchine2SlaveTableAdapter != null)) { + this._macchine2SlaveTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(revertConnections[this._macchine2SlaveTableAdapter])); + this._macchine2SlaveTableAdapter.Transaction = null; + } if ((0 < adaptersWithAcceptChangesDuringUpdate.Count)) { global::System.Data.Common.DataAdapter[] adapters = new System.Data.Common.DataAdapter[adaptersWithAcceptChangesDuringUpdate.Count]; adaptersWithAcceptChangesDuringUpdate.CopyTo(adapters); diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index 42d8fef3..59803c20 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -16,7 +16,12 @@ namespace MapoDb ///
public class DataLayer { - #region area table adapters + #region Public Fields + + /// + /// Oggetto MapoDb impiegato da DataLayer x i suoi accessi ai dati + /// + public MapoDb MapoDbObj = new MapoDb(); // Table adapter x DS_Applicazione public DS_applicazioneTableAdapters.AnagraficaGruppiTableAdapter taAG; @@ -78,6 +83,398 @@ namespace MapoDb public DS_ProdTempiTableAdapters.TurniMacchinaTableAdapter taTurniMacc; public DS_IntServTableAdapters.WipSetupKitTableAdapter taWKS; + #endregion Public Fields + + #region Public Constructors + + /// + /// Init classe + /// + public DataLayer() + { + initTA(); + setupConnectionStringBase(); + + // aggiunta x gestione timeout esteso (ove necessario)! + fixCommandTimeout(); + + // init oggetto MapoDb + MapoDbObj = new MapoDb(); + } + + #endregion Public Constructors + + #region Public Properties + + /// + /// Hash dati MSE + /// + /// + public static string hMSE + { + get + { + return mHash(string.Format("hMSE_DATA")); + } + } + + /// + /// Cognome Nome da MatrOpr in sessione + /// + public string CognomeNomeOpr + { + get + { + // cerco operatore... + string answ = ""; + try + { + DS_applicazione.AnagraficaOperatoriRow oper = taOp.getByMatrOpr(MatrOpr)[0]; + answ = string.Format("{0} {1}", oper.Cognome, oper.Nome); + } + catch { } + return answ; + } + } + + /// + /// Dati MSE serializzati in REDIS (get/set) + /// + public string currMSE + { + get + { + string answ = ""; + logger.lg.scriviLog("Richiesta MSE da REDIS"); + answ = memLayer.ML.getRSV(hMSE); + return answ; + } + set + { + int MSE_cacheDuration = memLayer.ML.CRI("MSE_cacheDuration"); + memLayer.ML.setRSV(hMSE, value, MSE_cacheDuration); + } + } + + /// + /// MatrOpr in sessione + /// + public int MatrOpr + { + get + { + int idx = 0; + try + { + idx = memLayer.ML.IntSessionObj("MatrOpr"); + } + catch { } + return idx; + } + set + { + memLayer.ML.setSessionVal("MatrOpr", value); + } + } + + #endregion Public Properties + + #region Private Methods + + private static T ConvertDataRowToGenericType(DataRow row) where T : class, new() + { + Type entityType = typeof(T); + T objEntity = new T(); + foreach (DataColumn column in row.Table.Columns) + { + object value = row[column.ColumnName]; + if (value == DBNull.Value) value = null; + PropertyInfo property = entityType.GetProperty(column.ColumnName, BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Public); + try + { + if (property != null && property.CanWrite) + property.SetValue(objEntity, value, null); + } + catch (Exception ex) + { + throw ex; + } + } + return objEntity; + } + + /// + /// registra su REDIS eventuale superamento numero limite di call x il metodo in oggetto + /// + /// + private static void saveCallRec(string callCountKey) + { + // conto la richiesta nel contatore REDIS + long nCall = memLayer.ML.setRCntI(mHash($"COUNT:pCall:{callCountKey}")); + //... se == nCall2Log scrivo su log e resetto + long nCall2Log = memLayer.ML.cdvi("nCall2Log"); + if (nCall >= nCall2Log) + { + // loggo + logger.lg.scriviLog($"{callCountKey}: {nCall} call received", tipoLog.INFO); + // resetto! + memLayer.ML.resetRCnt(mHash($"COUNT:pCall:{callCountKey}")); + } + } + + /// + /// verifica se sia necessario inserire un cambio di stato impianto in modalità batch + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void checkCambiaStatoBatch(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet) + { + int _logLevel = memLayer.ML.CRI("_logLevel"); + DS_applicazione.TransizioneStatiDataTable tabTransStati; + DS_applicazione.TransizioneStatiRow rigaTransStati; + switch (tipoInput) + { + case tipoInputEvento.barcode: + // effettuo cambio stato INDIPENDENTEMENTE da stato precedente + try + { + tabTransStati = MapoDbObj.taTranSt.GetUserForcedTransitions(IdxMacchina, IdxTipo); + if (tabTransStati != null) + { + if (tabTransStati.Count > 0) + { + rigaTransStati = tabTransStati[0]; + // solo se cambia stato... + if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato) + { + MapoDbObj.taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet); + // aggiorno MSE + taMSE.forceRecalc(0, IdxMacchina); + } + } + else + { + if (_logLevel > 6) + { + logger.lg.scriviLog($"Non trovata riga per: BARCODE | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}", tipoLog.INFO); + } + } + } + } + catch (Exception exc) + { + // non dovrebbe succedere... input utente da barcode dovrebbero TUTTI essere inseriti in tab transizione con famiglia 1... + logger.lg.scriviLog($"Errore controllo transizione stato x evento barcode: BARCODE | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + break; + + case tipoInputEvento.hw: + // verifico se ci sia necessità di cambio stato + try + { + tabTransStati = MapoDbObj.taTranSt.GetHwTransitions(IdxMacchina, IdxTipo); + if (tabTransStati != null) + { + if (tabTransStati.Count > 0) + { + rigaTransStati = tabTransStati[0]; + if (rigaTransStati != null) + { + // solo se cambia stato... + if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato) + { + MapoDbObj.taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet); + } + } + } + else + { + if (_logLevel > 6) + { + logger.lg.scriviLog($"Non trovata riga per: HW | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}", tipoLog.INFO); + } + } + } + } + catch (Exception exc) + { + // non trovo riga [0]... NON scrivo! + logger.lg.scriviLog($"Errore controllo transizione stato x evento barcode: HW | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + break; + } + } + + /// + /// sistemazione timeout comandi nei tableadapter + /// + private void fixCommandTimeout() + { + SetAllCommandTimeouts(taComm, memLayer.ML.CRI("sqlLongCommandTimeout")); + } + + /// + /// Recupero dati stato prod da macchina... + /// + /// + /// + /// + /// + private bool getStatoProd(string idxMacchina, ref DS_ProdTempi.StatoProdDataTable datiProdAct, DateTime dataRif) + { + bool answ = false; + try + { + // recupero con stored NUOVA... + //2020.01.31 NUOVO oggetto (NON singleton) + DataLayer man = new DataLayer(); + datiProdAct = man.taStatoProd.GetData(idxMacchina, dataRif); + if (datiProdAct.Rows.Count > 0) + { + // solo SE ho idxODL (altrimenti loggo errore) + if (datiProdAct[0].IdxOdl > 0) + { + answ = true; + } + else + { + // verifico se ho già questo errore attivo IN REDIS (altrimenti reinvio) + logger.lg.scriviLog($"pzCounterTC: Non trovato currODL x idxMacchina {idxMacchina} ", $"idxMacchina {idxMacchina} | IdxOdl {datiProdAct[0].IdxOdl} | pzTot {datiProdAct[0].PzTotODL} | dataRif {dataRif}", tipoLog.WARNING); + } + } + else + { + logger.lg.scriviLog($"pzCounterTC: Non trovate righe in currODL {idxMacchina}", $"Non trovate righe in currODL x idxMacchina {idxMacchina}: datiProdAct vuota", tipoLog.WARNING); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"[pzCounterTC] Eccezione in pzCounterTC x idxMacchina {idxMacchina}", $"[pzCounterTC] Eccezione in pzCounterTC x idxMacchina {idxMacchina}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + return answ; + } + + /// + /// Calcola l'effettivo valore da passare alla macchina a stati INGRESSI data conf Macchine2FamigliaIngressi + /// + /// + /// + /// + private string preProcInput(string idxMacchina, string valore) + { + string newVal = ""; + try + { + // variabili + int valINT = 0; + int BitFilt = 0; + int BSR = 0; + bool ExplodeBit = false; + int NumBit = 0; + int newValInt = 0; + // recupero parametri... + int.TryParse(mDatiMacchinaVal(idxMacchina, "BitFilt"), out BitFilt); + int.TryParse(mDatiMacchinaVal(idxMacchina, "BSR"), out BSR); + Boolean.TryParse(mDatiMacchinaVal(idxMacchina, "ExplodeBit"), out ExplodeBit); + int.TryParse(mDatiMacchinaVal(idxMacchina, "NumBit"), out NumBit); // non usato (x ora) + // recupero valore + valINT = int.Parse(valore, NumberStyles.HexNumber); + // filtro + newValInt = utility.bMaskInt(valINT, BitFilt); + // effettuo eventuale BitShiftRight + if (BSR > 0) + { + newValInt = newValInt >> BSR; + } + // effettuo eventuale esplosione in BIT esclusivi + if (ExplodeBit) + { + newValInt = Convert.ToInt32(1 << newValInt); + } + // riconverto a STRING HEX!!! + newVal = newValInt.ToString("X"); + } + catch + { + newVal = valore; + } + + return newVal; + } + + private void SetAllCommandTimeouts(object adapter, int timeout) + { + var commands = adapter.GetType().InvokeMember( + "CommandCollection", + BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, + null, adapter, new object[0]); + var sqlCommand = (SqlCommand[])commands; + foreach (var cmd in sqlCommand) + { + cmd.CommandTimeout = timeout; + } + } + + /// + /// cerca codice in anagrafica macchine ed eventualmente inserisce nuova macchina + /// + /// + private void verificaIdxMacchina(string IdxMacchina) + { + bool needDB = false; + if (!memLayer.ML.CRB("disable_verificaIdxMacchina")) + { + if (memLayer.ML.CRB("IOB_RedEnab")) + { + try + { + // esecuzione in REDIS...cerco status macchina... + if (mDatiMacchine(IdxMacchina).Count == 0) + { + needDB = true; + } + } + catch { } + } + // ...oppure segno richiesta DB... + else + { + needDB = true; + } + if (needDB) + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter(); + MapoDbObj.taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter(); + } + // verifico esistenza macchina + if (taMacchine.GetByIdx(IdxMacchina).Rows.Count == 0) + { + // inserisco nuova macchina... + taMacchine.Insert(IdxMacchina, "9999", IdxMacchina, "Macchina non codificata", "-", "http://", "nd", "col", 0, 0); + } + // verifico ci sia un microstato macchina... + if (MapoDbObj.taMSM.getByIdxMacchina(IdxMacchina).Rows.Count == 0) + { + // inserisco nuovo stato... + MapoDbObj.taMSM.Insert(IdxMacchina, 0, DateTime.Now, "00"); + } + } + } + } + + #endregion Private Methods + + #region Protected Methods + /// /// init dei table adapters /// @@ -194,54 +591,58 @@ namespace MapoDb taTKS.Connection.ConnectionString = connectionStringIS; } - #endregion area table adapters + #endregion Protected Methods - #region Inizializzazione + #region Public Methods /// - /// Oggetto MapoDb impiegato da DataLayer x i suoi accessi ai dati + /// Hash dati tabella AnagStati macchina /// - public MapoDb MapoDbObj = new MapoDb(); - - /// - /// Init classe - /// - public DataLayer() + /// + public static string currAnagStatiMacc() { - initTA(); - setupConnectionStringBase(); - - // aggiunta x gestione timeout esteso (ove necessario)! - fixCommandTimeout(); - - // init oggetto MapoDb - MapoDbObj = new MapoDb(); + return mHash(string.Format("Anag:StatiMacc")); } /// - /// sistemazione timeout comandi nei tableadapter + /// Hash dati Current ODL x la macchina specificata /// - private void fixCommandTimeout() + /// + /// + public static string currODLHash(string idxMacchina) { - SetAllCommandTimeouts(taComm, memLayer.ML.CRI("sqlLongCommandTimeout")); + return mHash(string.Format("CurrODL:{0}", idxMacchina)); } - private void SetAllCommandTimeouts(object adapter, int timeout) + /// + /// Hash dati Current ODL ROW x la macchina specificata + /// + /// + /// + public static string currOdlRowHash(string idxMacchina) { - var commands = adapter.GetType().InvokeMember( - "CommandCollection", - BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, - null, adapter, new object[0]); - var sqlCommand = (SqlCommand[])commands; - foreach (var cmd in sqlCommand) - { - cmd.CommandTimeout = timeout; - } + return mHash(string.Format("CurrOdlRow:{0}", idxMacchina)); } - #endregion Inizializzazione + /// + /// Hash dati CurrentParameters x la macchina specificata + /// + /// + /// + public static string currParametersHash(string idxMacchina) + { + return mHash(string.Format("CurrentParameters:{0}", idxMacchina)); + } - #region utility interne + /// + /// Hash dati Current StatoMacchina x la macchina specificata + /// + /// + /// + public static string currStatoMaccHash(string idxMacchina) + { + return mHash(string.Format("CurrStatoMacc:{0}", idxMacchina)); + } public static List DataTableToList(DataTable dt) where T : class, new() { @@ -254,89 +655,486 @@ namespace MapoDb return lstItems; } - private static T ConvertDataRowToGenericType(DataRow row) where T : class, new() + /// + /// Hash dati STATUS x la macchina specificata + /// + /// + /// + public static string dtMaccHash(string idxMacchina) { - Type entityType = typeof(T); - T objEntity = new T(); - foreach (DataColumn column in row.Table.Columns) - { - object value = row[column.ColumnName]; - if (value == DBNull.Value) value = null; - PropertyInfo property = entityType.GetProperty(column.ColumnName, BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.Public); - try - { - if (property != null && property.CanWrite) - property.SetValue(objEntity, value, null); - } - catch (Exception ex) - { - throw ex; - } - } - return objEntity; + return mHash(string.Format("DtMac:{0}", idxMacchina)); } /// - /// registra su REDIS eventuale superamento numero limite di call x il metodo in oggetto + /// Hash dati EXE TASK x la macchina specificata /// - /// - private static void saveCallRec(string callCountKey) + /// + /// + public static string exeTaskHash(string idxMacchina) { - // conto la richiesta nel contatore REDIS - long nCall = memLayer.ML.setRCntI(mHash($"COUNT:pCall:{callCountKey}")); - //... se == nCall2Log scrivo su log e resetto - long nCall2Log = memLayer.ML.cdvi("nCall2Log"); - if (nCall >= nCall2Log) - { - // loggo - logger.lg.scriviLog($"{callCountKey}: {nCall} call received", tipoLog.INFO); - // resetto! - memLayer.ML.resetRCnt(mHash($"COUNT:pCall:{callCountKey}")); - } + return mHash(string.Format("ExeTask:{0}", idxMacchina)); } - #endregion utility interne - - #region utility public esposte + /// + /// Hash dati relativi all'associazione macchina <--> IOB + /// + /// Macchina PRINCIPALE + /// + public static string hM2IOB(string IdxMacchina) + { + return mHash(string.Format("hM2IOB:{0}", IdxMacchina)); + } /// - /// Cognome Nome da MatrOpr in sessione + /// Hash dati Macchine Multi SM Ingressi /// - public string CognomeNomeOpr + /// Macchina PRINCIPALE + /// + public static string hMSMI(string IdxMacchina) { - get + return mHash(string.Format("hMSMI:{0}", IdxMacchina)); + } + + /// + /// Hash dati STATE MACHINE INGRESSI x la FAMIGLIA INGRESSI specificata (per completare poi manca singolo micro stato corrente + valore letto x definire chiave) + /// + /// + /// + public static string hSMI(int idxFamIn) + { + return mHash(string.Format("hSMI:{0}", idxFamIn)); + } + + /// + /// Hash dati BUFFER x la macchina specificata + /// + /// + /// + /// + public static string LiveBufferHash(string idxMacchina, string bufferName) + { + return mHash(string.Format("LIVE:{0}:{1}", idxMacchina, bufferName)); + } + + /// + /// Hash dati LIVE x la macchina specificata + /// + /// + /// + public static string LiveCurrValHash(string idxMacchina) + { + return mHash(string.Format("LIVE:{0}:CURR_VAL", idxMacchina)); + } + + /// + /// Hash dati MemoryMap x la macchina specificata + /// + /// + /// + public static string memMapHash(string idxMacchina) + { + return mHash(string.Format("MemMap:{0}", idxMacchina)); + } + + /// + /// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...) + /// + /// + /// + public static string mHash(string dataType) + { + return memLayer.ML.redHash(dataType); + } + + /// + /// Hash dati OPT PARAMETERS x la macchina specificata + /// + /// + /// + public static string optParHash(string idxMacchina) + { + return mHash(string.Format("OptPar:{0}", idxMacchina)); + } + + /// + /// Hash dati COUNTER x la macchina specificata + /// + /// + /// + public static string pzCountHash(string idxMacchina) + { + return mHash(string.Format("PzCount:{0}", idxMacchina)); + } + + /// + /// Hash dati STATUS x la macchina specificata. + /// - dati ODL + /// - dati articolo + /// - dati produzione corrente + /// + /// + /// + public static string stMaccHash(string idxMacchina) + { + return mHash(string.Format("StMac:{0}", idxMacchina)); + } + + /// + /// Hash x VETO dello SPLIT ODL la macchina specificata + /// + /// + /// + public static string vetoSplitOdlMaccHash(string idxMacchina) + { + return mHash($"VetoOdlMacc:{idxMacchina}"); + } + + /// + /// Aggiunge un PARAMETRO OPZIONALE all'elenco di quelli salvati (in modalità upsert) + /// + /// + /// + /// + /// + public bool addOptPar4Machine(string idxMacchina, string taskKey, string taskVal) + { + bool answ = false; + string currHash = optParHash(idxMacchina); + try { - // cerco operatore... - string answ = ""; + // leggo task attuali... + var currVal = mOptParMacchina(idxMacchina); + currVal[taskKey] = taskVal; + answ = memLayer.ML.redSaveHashDict(currHash, currVal); + } + catch { } + return answ; + } + + /// + /// Aggiunge un task all'elenco di quelli salvati (in modalità upsert) + /// + /// + /// + /// + /// + public bool addTask4Machine(string idxMacchina, taskType taskKey, string taskVal) + { + bool answ = false; + string currHash = exeTaskHash(idxMacchina); + try + { + // leggo task attuali... + var currTask = mTaskMacchina(idxMacchina); + currTask[taskKey.ToString()] = taskVal; + answ = memLayer.ML.redSaveHashDict(currHash, currTask); + logger.lg.scriviLog($"Task ADD - idxMacchina: {idxMacchina} | taskKey: {taskKey.ToString()} | taskVal: {taskVal}"); + } + catch { } + return answ; + } + + /// + /// Elenco stati macchina + /// + /// + public DS_applicazione.AnagraficaStatiDataTable AnagraficaStati() + { + DS_applicazione.AnagraficaStatiDataTable answTab = null; + // cerco in cache... + string rCall = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("hasAnagStati"); try { - DS_applicazione.AnagraficaOperatoriRow oper = taOp.getByMatrOpr(MatrOpr)[0]; - answ = string.Format("{0} {1}", oper.Cognome, oper.Nome); + rCall = memLayer.ML.getRSV(currAnagStatiMacc()); + if (!string.IsNullOrEmpty(rCall)) + { + answTab = JsonConvert.DeserializeObject(rCall); + } + else + { + //2020.01.31 nuovo obj x evitare concorrenza + MapoDb man = new MapoDb(); + answTab = man.taAnagSt.GetData(); + //answTab = MapoDbObj.taAnagSt.GetData(); + // salvo in redis... + rCall = JsonConvert.SerializeObject(answTab); + int anagrCacheDur = memLayer.ML.CRI("anagrCacheDur"); + memLayer.ML.setRSV(currAnagStatiMacc(), rCall, anagrCacheDur); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + answTab = MapoDbObj.taAnagSt.GetData(); + } + return answTab; + } + + /// + /// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE + /// + /// idx macchina + /// valore ingresso + /// data-ora evento (server) + /// sequenza dati inviati + /// + public inputComandoMapo checkMicroStato(string idxMacchina, string valore, DateTime dtEve, string contatore) + { + int _logLevel = memLayer.ML.CRI("_logLevel"); + // recupero SE IMPIEGATO REDIS i valori del Dictionary della macchina... + Dictionary datiMacc = mDatiMacchine(idxMacchina); + + if (_logLevel > 6) + { + logger.lg.scriviLog(string.Format("[ChkMiSt]{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO); + } + // formatto output + inputComandoMapo answ = new inputComandoMapo(); + DS_applicazione.TransizioneIngressiDataTable TabTransIn; + DS_applicazione.TransizioneIngressiRow rigaTransIn = null; + // verifico se esista la macchina altrimenti la creo... REDIS compliant + verificaIdxMacchina(idxMacchina); + string CodArticolo = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + try + { + // esecuzione in REDIS + CodArticolo = datiMacc["CodArticolo"]; } catch { } - return answ; } + // ...oppure dritto su DB + else + { + // esecuzione in DB... + // recupero CodArticolo corretto + try + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + // 2017.07.10 forzo init x errori "sovrapposizioni" + taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); + } + CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_4a] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + // recupero next microstato + int? valINT = 0; + try + { + valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber); + // esecuzione in REDIS... + if (memLayer.ML.CRB("IOB_RedEnab")) + { + try + { + int idxFamIn = Convert.ToInt32(datiMacc["IdxFamIn"]); + int idxMicroStato = Convert.ToInt32(datiMacc["IdxMicroStato"]); + int valIOB = Convert.ToInt32(valINT); + int idxTipoEv = 0; + int next_idxMS = idxMicroStato; + // verifico esistenza tab SMI... + string fiHASH = DataLayer.hSMI(idxFamIn); + string todoSMI = ""; + bool trovato = memLayer.ML.redHashPresentSz(fiHASH); + if (!trovato) + { + // ricarico tabella! + KeyValuePair[] valori = mTabSMI(idxFamIn); + } + // recupero singolo valore (stringa) x chiave + todoSMI = valoreSMI(idxFamIn, idxMicroStato, valIOB); + // solo se ho trovato un risultato nella tab SMI della famiglia macchina... + if (todoSMI != "") + { + // splitto e salvo valori OUT... + string[] valori = todoSMI.Split('_'); + idxTipoEv = Convert.ToInt32(valori[0]); + next_idxMS = Convert.ToInt32(valori[1]); + // creo la riga tipizzatya dai dati di redis x procedere... + DS_applicazione.TransizioneIngressiDataTable tab = new DS_applicazione.TransizioneIngressiDataTable(); + rigaTransIn = tab.NewTransizioneIngressiRow(); + rigaTransIn.IdxFamigliaIngresso = idxFamIn; + rigaTransIn.IdxMicroStato = idxMicroStato; + rigaTransIn.ValoreIngresso = valIOB; + rigaTransIn.IdxTipoEvento = idxTipoEv; + rigaTransIn.next_IdxMicroStato = next_idxMS; + } + } + catch { } + } + // ...oppure dritto su DB + else + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + // 2017.06.09 forzo init x errori "sovrapposizioni" + MapoDbObj.taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter(); + } + TabTransIn = MapoDbObj.taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT); + if (TabTransIn.Rows.Count > 0) + { + rigaTransIn = TabTransIn[0]; + } + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_5a] - - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION); + } + // effettuo update vari SU DB!!! + if (rigaTransIn != null) + { + try + { + if (_logLevel > 5) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_6a] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO); + } + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + // 2017.06.09 forzo init x errori "sovrapposizioni" + MapoDbObj.taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter(); + } + // salvo nuovo microstato... + MapoDbObj.taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina); + // controllo se c'è evento + if (rigaTransIn.IdxTipoEvento > 0) + { + if (_logLevel > 5) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_7a] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3} | contatore: {4} | valore: {5}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, contatore, valore), tipoLog.INFO); + } + string valEsteso = string.Format("[{0}] {1}", contatore.PadLeft(3, '0'), valore); + // aggiunto contatore! + answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valEsteso, 0, "-", dtEve, DateTime.Now); + // 2017.09.12 SE era in modalità redis RICARICA dati macchina... + if (memLayer.ML.CRB("IOB_RedEnab")) + { + resetDatiMacchina(idxMacchina); + } + if (_logLevel > 5) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_a] - Macchina {0} | seriale(INT) {1} | valEsteso {3} | answ {4}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine, valEsteso, answ), tipoLog.INFO); + } + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_8a] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + return answ; } /// - /// MatrOpr in sessione + /// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE /// - public int MatrOpr + /// idx macchina + /// valore ingresso + /// data-ora evento (server) + /// + public inputComandoMapo checkMicroStato(string idxMacchina, string valore, DateTime dtEve) { - get + if (memLayer.ML.CRI("_logLevel") > 6) + { + logger.lg.scriviLog(string.Format("{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO); + } + // formatto output + inputComandoMapo answ = new inputComandoMapo(); + DS_applicazione.TransizioneIngressiDataTable TabTransIn; + DS_applicazione.TransizioneIngressiRow rigaTransIn = null; + // verifico se esista la macchina altrimenti la creo... + verificaIdxMacchina(idxMacchina); + string CodArticolo = ""; + // recupero CodArticolo corretto + try + { + // 2017.07.10 forzo init x errori "sovrapposizioni" + taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); + CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_4b] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + // recupero next microstato + //int? valINT = Convert.ToInt32(valore); + int? valINT = 0; + try + { + // 2017.06.09 forzo init x errori "sovrapposizioni" + MapoDbObj.taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter(); + valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber); + TabTransIn = MapoDbObj.taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT); + if (TabTransIn.Rows.Count > 0) + { + rigaTransIn = TabTransIn[0]; + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_5b] - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION); + } + int _logLevel = memLayer.ML.CRI("_logLevel"); + // effettuo update vari + if (rigaTransIn != null) { - int idx = 0; try { - idx = memLayer.ML.IntSessionObj("MatrOpr"); + if (_logLevel > 5) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_6b] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO); + } + // salvo nuovo microstato... + MapoDbObj.taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina); + // controllo se c'è evento + if (rigaTransIn.IdxTipoEvento > 0) + { + if (_logLevel > 5) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_7b] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo), tipoLog.INFO); + } + answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valore, 0, "-", dtEve, DateTime.Now); + if (_logLevel > 5) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_b] -Macchina {0}, seriale(INT) {1}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine), tipoLog.INFO); + } + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[ChkMiSt_8b] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); } - catch { } - return idx; - } - set - { - memLayer.ML.setSessionVal("MatrOpr", value); } + return answ; + } + + /// + /// controlla se da il segnale di "microstato" deriva un evento da generare + /// + /// + /// + /// + public inputComandoMapo checkMicroStato(string idxMacchina, string valore) + { + // wrapper ad ora corrente... + return checkMicroStato(idxMacchina, valore, DateTime.Now); } /// @@ -393,6 +1191,157 @@ namespace MapoDb return answ; } + /// + /// Restituisce il valore dell'ODL corrente (ODL deve esserci per gestione contapezzi, senza ODL NO invio/gestione ODL) + /// + /// + /// + public string currODL(string idxMacchina) + { + string answ = ""; + string rCall = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("hasODL"); + try + { + rCall = memLayer.ML.getRSV(currODLHash(idxMacchina)); + if (rCall != null && rCall != "") + { + answ = rCall; + } + else + { + answ = getCurrODL(idxMacchina); + // salvo in redis... + saveCurrODL(idxMacchina, answ); + } + } + catch { } + } + return answ; + } + + /// + /// Restituisce il valore dell'ODL corrente (ODL deve esserci per gestione contapezzi, senza ODL NO invio/gestione ODL) + /// + /// + /// indica se forzare lettura da db (true) o meno + /// + public string currODL(string idxMacchina, bool forceDb) + { + string answ = ""; + // faccio comunque verifica se sia stato letto da poco il valore... x cui anche a fronte di richiesta lettura da DB per 3 sec tengo buono valore in cache redis... + string rKey = memLayer.ML.redHash($"ODL:{idxMacchina}"); + string _idxOdl = memLayer.ML.getRSV(rKey); + if (forceDb) + { + if (!string.IsNullOrEmpty(_idxOdl)) + { + answ = _idxOdl; + } + else + { + answ = getCurrODL(idxMacchina); + // salvo in redis... + saveCurrODL(idxMacchina, answ); + memLayer.ML.setRSV(rKey, answ, 3); + } + } + else + { + answ = currODL(idxMacchina); + } + return answ; + } + + /// + /// Restituisce il valore dell'intera RIGA ODL corrente (da redis o da DB se non trovata...) + /// + /// + /// + public DS_ProdTempi.ODLDataTable currODLRowTab(string idxMacchina) + { + DS_ProdTempi.ODLDataTable answTab = null; + string rCall = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("hasODL_row"); + try + { + rCall = memLayer.ML.getRSV(currOdlRowHash(idxMacchina)); + if (!string.IsNullOrEmpty(rCall)) + { + answTab = JsonConvert.DeserializeObject(rCall); + } + else + { + // istanzio un NUOVO oggetto lettura + MapoDb connDb = new MapoDb(); + answTab = connDb.currODLTab(idxMacchina); + // salvo in redis... + rCall = JsonConvert.SerializeObject(answTab); + int currOdlRowCacheDur = memLayer.ML.CRI("currOdlRowCacheDur"); + memLayer.ML.setRSV(currOdlRowHash(idxMacchina), rCall, currOdlRowCacheDur); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + // istanzio un NUOVO oggetto lettura + MapoDb connDb = new MapoDb(); + answTab = connDb.currODLTab(idxMacchina); + } + return answTab; + } + + /// + /// Restituisce il valore dell'intera RIGA stato macchina corrente (da redis o da DB se non trovata...) + /// + /// + /// + public DS_applicazione.StatoMacchineDataTable currSMTab(string idxMacchina) + { + DS_applicazione.StatoMacchineDataTable answTab = null; + string rCall = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("hasStatoMacc"); + try + { + rCall = memLayer.ML.getRSV(currStatoMaccHash(idxMacchina)); + if (!string.IsNullOrEmpty(rCall)) + { + answTab = JsonConvert.DeserializeObject(rCall); + } + else + { + // 2020.01.31 uso nuovo oggetto connessione + MapoDb man = new MapoDb(); + answTab = man.currStatoMaccTab(idxMacchina); + //answTab = MapoDbObj.currStatoMaccTab(idxMacchina); + // salvo in redis... + rCall = JsonConvert.SerializeObject(answTab); + int currStatoMaccCacheDur = memLayer.ML.CRI("currStatoMaccCacheDur"); + memLayer.ML.setRSV(currStatoMaccHash(idxMacchina), rCall, currStatoMaccCacheDur); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + answTab = MapoDbObj.currStatoMaccTab(idxMacchina); + } + return answTab; + } + /// /// Rimuove Key dell'ODL corrente x una data macchina IOB /// @@ -484,6 +1433,63 @@ namespace MapoDb return fatto; } + /// + /// Effettua split ODL + /// + /// + /// + public string forceSplitOdl(string idxMacchina) + { + string answ = "KO"; + // verifico NON CI SIA un veto a NUOVI split... 2 min di default... + string redKey = vetoSplitOdlMaccHash(idxMacchina); + string rawData = memLayer.ML.getRSV(redKey); + if (string.IsNullOrEmpty(rawData)) + { + // registro VETO x altri split... 2 minuti + memLayer.ML.setRSV(redKey, $"Inizio SPLIT-ODL {DateTime.Now}", 300); + // proseguo + DS_ProdTempi.ODLDataTable currData = null; + DateTime adesso = DateTime.Now; + // chiamo metodo redis/db... + try + { + // recupero ODL corrente + currData = currODLRowTab(idxMacchina); + if (currData.Count > 0) + { + // registro un evento di inizio attrezzaggio (idxTipoEv = 2) + int idxEvento = 2; + logger.lg.scriviLog($"Invio evento ODL-SPLIT per macchina {idxMacchina}, evento {idxEvento}, articolo {currData[0].CodArticolo}", tipoLog.INFO); + inputComandoMapo resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currData[0].CodArticolo, "ODL-SPLIT", 0, "", adesso, adesso); + // attendo 1 sec + Thread.Sleep(1000); + adesso = DateTime.Now; + // chiamo splitOdl + MapoDbObj.taODL.splitODL(currData[0].IdxODL, 0, idxMacchina, currData[0].TCRichAttr, currData[0].PzPallet, $"Nuovo ODL da forceSplitOdl", true); + // attendo 1 sec + Thread.Sleep(1000); + adesso = DateTime.Now; + // registro fine ODL (idxTipoEv = 1) + idxEvento = 1; + logger.lg.scriviLog($"Invio evento FINE ODL-SPLIT per macchina {idxMacchina}, evento {idxEvento}, articolo {currData[0].CodArticolo}", tipoLog.INFO); + resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currData[0].CodArticolo, "ODL-START"); + // chiamo refresh MSE + taMSE.forceRecalc(0, idxMacchina); + // resetto stato macchina... + memLayer.ML.redDelKey(currStatoMaccHash(idxMacchina)); + answ = "OK"; + logger.lg.scriviLog($"Effettuato reset e ricalcoli x split ODL per macchina {idxMacchina}", tipoLog.INFO); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in forceSplitOdl{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + return answ; + } + /// /// GET elenco parametri correnti x IOB /// @@ -541,6 +1547,384 @@ namespace MapoDb return writeValues; } + /// + /// restituisce valore dell'ODL attivo (iniziato e NON concluso) + /// + /// + /// + public string getCurrODL(string idxMacchina) + { + string answ = ""; + // recupero con stored NUOVA... + DS_ProdTempi.ODLDataTable tabOdl = taODL.getByMacchina(idxMacchina); + if (tabOdl.Rows.Count > 0) + { + // solo SE ho idxODL (altrimenti loggo errore) + if (tabOdl[0].IdxODL > 0) + { + answ = tabOdl[0].IdxODL.ToString(); + answ = answ == "" ? "0" : answ; + } + else + { + answ = "0"; + logger.lg.scriviLog("[currODL] Errore in currODL x idxMacchina " + idxMacchina + ": IdxODL = 0"); + } + } + else + { + // se è empty --> 0!!! + answ = "0"; + } + // ultimo controllo su idxOdl... + answ = answ == "" ? "0" : answ; + // restituisco! + return answ; + } + + /// + /// restituisce una tabella con tutte le transizioni degli ingressi per una data macchina + /// + /// + /// + public DS_applicazione.TransizioneIngressiDataTable getMatriceIngressi(string idxMacchina) + { + DS_applicazione.TransizioneIngressiDataTable answ; + try + { + answ = taTranIngr.getMatriceByIdxMacchina(idxMacchina); + } + catch + { + answ = null; + } + return answ; + } + + /// + /// Recupera (da DB) i dati della State Machine multi ingressi nel formato + /// key: IdxMacchina + /// value: IdxFamigliaIngresso + /// + /// + /// + public KeyValuePair[] getMSMI_DB(string idxMacchina) + { + DS_applicazione.MSFDDataTable tabMSMI = new DS_applicazione.MSFDDataTable(); + // 2017.09.13: inserisco gestione singleton condizionale + if (memLayer.ML.CRB("disable_singleton")) + { + // instanzio un nuovo oggetto MapoDb + MapoDb connDb = new MapoDb(); + tabMSMI = connDb.taMSFD.getMulti(idxMacchina); + } + else + { + // leggo DB da singleton + tabMSMI = MapoDbObj.taMSFD.getMulti(idxMacchina); + } + KeyValuePair[] answ = new KeyValuePair[tabMSMI.Count]; + // salvo tutti i valori StateMachineIngressi... + int i = 0; + foreach (var item in tabMSMI) + { + answ[i] = new KeyValuePair(item.IdxMacchina, item.IdxFamigliaIngresso.ToString()); + i++; + } + return answ; + } + + /// + /// restituisce il TempoCiclo effettivo (tecnico) della macchina + /// + /// + /// + public decimal getTcEffMacchina(string idxMacchina) + { + decimal tc = 0; + try + { + DS_ProdTempi.stp_repDonati_getDatiProdMacchinaPeriodoRow riga = taDatiProdMacchPer.GetData(idxMacchina, DateTime.Now.AddMinutes(-30), DateTime.Now)[0]; + if (riga.TCEffRT > 0) + { + tc = riga.TCEffRT; + } + else + { + tc = riga.TCAssegnato; + } + } + catch { } + // imposto a 99'TC + if (tc == 0) + { + tc = 99.9M; + // scrivo log per indicare mancato caricamento dati tc dichiarato e conseguente errore sul timer - 2/11/2012 EN&CV + logger.lg.scriviLog(string.Format("Impostato TC Tempo Ciclo a 99' (99.9M) causa mancato inserimento tempo ciclo dichiarato")); + } + return tc; + } + + /// + /// Restituisce il valore booleano se la macchina sia abilitata all'input + /// + /// + /// + public bool insEnab(string idxMacchina) + { + bool answ = false; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("insEnabled"); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled")); + } + catch { } + } + // ...oppure dritto su DB + else + { + if (memLayer.ML.CRB("disable_singleton")) + { + // instanzio un nuovo oggetto MapoDb + MapoDb connDb = new MapoDb(); + answ = connDb.insEnabled(idxMacchina); + } + else + { + // leggo DB da singleton + answ = MapoDbObj.insEnabled(idxMacchina); + } + } + return answ; + } + + /// + /// Restituisce il valore booleano se la macchina sia di tipo MASTER (imposta ODL x gli slave) + /// + /// + /// + public bool isMaster(string idxMacchina) + { + bool answ = false; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("isMaster"); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "Master") == "1"); + } + catch { } + } + // ...oppure dritto su DB + else + { + answ = MapoDbObj.isMulti(idxMacchina); + } + return answ; + } + + /// + /// Restituisce il valore booleano se la macchina sia di tipo MULTI (con più state machine x INGRESSI) + /// + /// + /// + public bool isMulti(string idxMacchina) + { + bool answ = false; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("isMulti"); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "Multi") == "1"); + } + catch { } + } + // ...oppure dritto su DB + else + { + answ = MapoDbObj.isMulti(idxMacchina); + } + return answ; + } + + /// + /// Restituisce il valore booleano se la macchina sia di tipo SLAVE (ODL impostato da MASTER) + /// + /// + /// + public bool isSlave(string idxMacchina) + { + bool answ = false; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("isSlave"); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "Slave") == "1"); + } + catch { } + } + // ...oppure dritto su DB + else + { + answ = MapoDbObj.isMulti(idxMacchina); + } + return answ; + } + + /// + /// Restituisce valore di una singola chiave del dizionario DatiMacchina + /// + /// + /// + /// + public string mDatiMacchinaVal(string idxMacchina, string chiave) + { + string answ = ""; + try + { + answ = mDatiMacchine(idxMacchina)[chiave]; + } + catch { } + return answ; + } + + /// + /// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato + /// + /// + /// + public Dictionary mDatiMacchine(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + Dictionary answ = new Dictionary(); + // ORA recupero da memoria redis... + try + { + string currHash = dtMaccHash(idxMacchina); + answ = memLayer.ML.redGetHashDict(currHash); + // se è vuoto... leggo da DB e popolo! + if (answ.Count == 0) + { + answ = resetDatiMacchina(idxMacchina); + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in compilazione dati Macchine x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); + } + return answ; + } + + /// + /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato + /// + /// + /// + public Dictionary mOptParMacchina(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + Dictionary answ = new Dictionary(); + // ORA recupero da memoria redis... + try + { + string currHash = optParHash(idxMacchina); + answ = memLayer.ML.redGetHashDict(currHash); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in compilazione dati OPT PARAM x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); + } + return answ; + } + + /// + /// Restitusice elenco KVP + /// key: IdxMacchina + /// value: IdxFamigliaIngresso + /// + /// + /// + public KeyValuePair[] mTabMSMI(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + KeyValuePair[] answ = new KeyValuePair[1]; + // iniziualizzo con un valore... 0/0 + answ[0] = new KeyValuePair("0", "0"); + // ORA recupero da memoria redis... + try + { + string currHash = hMSMI(idxMacchina); + answ = memLayer.ML.redGetHash(currHash); + // se è vuoto... leggo da DB e popolo! + if (answ.Length == 0) + { + answ = resetMSMI(idxMacchina); + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in compilazione Tabella Multi State Machine Ingressi x Redis:{0}{1}", Environment.NewLine, exc)); + } + return answ; + } + + /// + /// Restitusice elenco KVP dei campi della State Machine ingressi nel formato + /// key: cState_nVal (current MICRO-STATE + "_" + new Value) + /// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE + /// + /// + /// + public KeyValuePair[] mTabSMI(int idxFamIn) + { + // hard coded dimensione vettore DatiMacchine + KeyValuePair[] answ = new KeyValuePair[1]; + // iniziualizzo con un valore... 0/0 + answ[0] = new KeyValuePair("0", "0"); + // ORA recupero da memoria redis... + try + { + string currHash = hSMI(idxFamIn); + answ = memLayer.ML.redGetHash(currHash); + // se è vuoto... leggo da DB e popolo! + if (answ.Length == 0) + { + answ = resetSMI(idxFamIn); + } + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in compilazione State Machine Ingressi x Redis:{0}{1}", Environment.NewLine, exc)); + } + return answ; + } + + /// + /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato + /// + /// + /// + public Dictionary mTaskMacchina(string idxMacchina) + { + // hard coded dimensione vettore DatiMacchine + Dictionary answ = new Dictionary(); + // ORA recupero da memoria redis... + try + { + string currHash = exeTaskHash(idxMacchina); + answ = memLayer.ML.redGetHashDict(currHash); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in compilazione dati EXE TASK x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); + } + return answ; + } + /// /// Processa registrazione FL da IOB /// @@ -959,6 +2343,347 @@ namespace MapoDb return answ; } + /// + /// Restituisce il contapezzi salvato per la macchina + /// + /// + /// + public int pzCounter(string idxMacchina) + { + int answ = -1; + string rCall = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("getCounter"); + try + { + rCall = memLayer.ML.getRSV(pzCountHash(idxMacchina)); + if (rCall != "" && rCall != null) + { + int.TryParse(rCall, out answ); + } + else + { + answ = pzCounterTC(idxMacchina); + // salvo in redis... + saveCounter(idxMacchina, answ.ToString()); + } + } + catch { } + } + return answ; + } + + /// + /// Restituisce il contapezzi come CONTEGGIO da TCRilevati per la macchina + /// + /// + /// + public int pzCounterTC(string idxMacchina) + { + int answ = -1; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("getCounterTC"); + } + // variabile x controllo dati recuperati + DS_ProdTempi.StatoProdDataTable datiProdAct = null; + bool okDatiProd = false; + int taSP_ms_ant = memLayer.ML.cdvi("taStatoProd_ms_anticipo"); + DateTime dataRif = DateTime.Now.AddMilliseconds(-taSP_ms_ant); + okDatiProd = getStatoProd(idxMacchina, ref datiProdAct, dataRif); + // se NON avesse recuperato --> aspetto taSP_ms_ant e poi RICHIAMO procedura... + int maxTry = 3; + while (!okDatiProd && maxTry > 0) + { + logger.lg.scriviLog(string.Format("[pzCounterTC] Impossibile recuperare dati ODL x idxMacchina {0}", idxMacchina), tipoLog.WARNING); + // sleep... + Thread.Sleep(taSP_ms_ant * 2); + // riprovo lettura... + okDatiProd = getStatoProd(idxMacchina, ref datiProdAct, dataRif); + maxTry--; + } + + // ora proseguo SE ho trovato i dati... + if (okDatiProd) + { + if (datiProdAct != null) + { + if (datiProdAct.Count > 0) + { + if (!datiProdAct[0].IsPzTotODLNull()) + { + // ...a questo punto recupero DAVVERO i dati (o almeno ci provo...) + try + { + // controllo + answ = datiProdAct[0].PzTotODL; + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("[pzCounterTC] Eccezione in recupero PzTotODL x idxMacchina {0}{1}{2}", idxMacchina, Environment.NewLine, exc), tipoLog.EXCEPTION); + } + } + } + } + } + else + { + logger.lg.scriviLog(string.Format("[pzCounterTC] Dati ODL x idxMacchina {0} non recuperati dopo tentativi reiterati...", idxMacchina), tipoLog.WARNING); + } + return answ; + } + + /// + /// RIMUOVE un PARAMETRO OPZIONALE dall'elenco di quelli salvati + /// + /// + /// + /// + public bool remOptPar4Machine(string idxMacchina, string taskKey) + { + bool answ = false; + string currHash = optParHash(idxMacchina); + try + { + // leggo task attuali... + var currVal = mOptParMacchina(idxMacchina); + currVal.Remove(taskKey); + memLayer.ML.redDelKey(currHash); + answ = memLayer.ML.redSaveHashDict(currHash, currVal); + } + catch { } + return answ; + } + + /// + /// RIMUOVE un task dall'elenco di quelli salvati + /// + /// + /// + /// + public bool remTask4Machine(string idxMacchina, taskType taskKey) + { + bool answ = false; + string currHash = exeTaskHash(idxMacchina); + try + { + // leggo task attuali... + var currTask = mTaskMacchina(idxMacchina); + currTask.Remove(taskKey.ToString()); + memLayer.ML.redDelKey(currHash); + answ = memLayer.ML.redSaveHashDict(currHash, currTask); + logger.lg.scriviLog($"Task REM - idxMacchina: {idxMacchina} | taskKey: {taskKey.ToString()}"); + } + catch { } + return answ; + } + + /// + /// Resetta (rileggendo) i dati della macchina + /// + /// + /// + public Dictionary resetDatiMacchina(string idxMacchina) + { + string currHash = dtMaccHash(idxMacchina); + // inizio con un bel reset... + memLayer.ML.redFlushKey(currHash); + Dictionary answ = new Dictionary(); + DS_applicazione.MSFDDataTable tabMSFD = new DS_applicazione.MSFDDataTable(); + // 2018.01.08 SEMPRE senza singleton: instanzio un nuovo oggetto MapoDb + MapoDb connDb = new MapoDb(); + tabMSFD = connDb.taMSFD.getByIdxMacc(idxMacchina); + bool trovato = false; + // se ho righe... + DS_applicazione.MSFDDataTable tab = new DS_applicazione.MSFDDataTable(); + DS_applicazione.MSFDRow rigaMSFD; + if (tabMSFD.Rows.Count > 0) + { + try + { + rigaMSFD = tabMSFD[0]; + trovato = true; + } + catch + { + rigaMSFD = tab.NewMSFDRow(); + } + } + else + { + rigaMSFD = tab.NewMSFDRow(); + } + if (trovato) + { + // ora provo a compilare... + try + { + // salvo 1:1 i valori... STATO + answ.Add("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString()); + answ.Add("IdxStato", rigaMSFD.IdxStato.ToString()); + answ.Add("CodArticolo", rigaMSFD.CodArticolo); + answ.Add("insEnabled", rigaMSFD.insEnabled.ToString()); + answ.Add("sLogEnabled", rigaMSFD.sLogEnabled.ToString()); + answ.Add("pallet", rigaMSFD.pallet); + answ.Add("CodArticolo_A", rigaMSFD.CodArticolo_A); + answ.Add("CodArticolo_B", rigaMSFD.CodArticolo_B); + answ.Add("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString()); + answ.Add("PzPalletProd", rigaMSFD.PzPalletProd.ToString()); + answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString()); + answ.Add("lastVal", rigaMSFD.lastVal); + answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString()); + + //...e SETUP + answ.Add("CodMacc", rigaMSFD.codmacchina); + answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString()); + answ.Add("Multi", rigaMSFD.Multi.ToString()); + answ.Add("BitFilt", rigaMSFD.BitFilt.ToString()); + answ.Add("MaxVal", rigaMSFD.MaxVal.ToString()); + answ.Add("BSR", rigaMSFD.BSR.ToString()); + answ.Add("ExplodeBit", rigaMSFD.ExplodeBit.ToString()); + answ.Add("NumBit", rigaMSFD.NumBit.ToString()); + answ.Add("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString()); + answ.Add("simplePallet", rigaMSFD.simplePallet.ToString()); + answ.Add("palletChange", rigaMSFD.palletChange.ToString()); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Errore in compilazione dati MSFD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + // cerco dati master/slave... + string isMaster = connDb.taM2S.getByMaster(idxMacchina).Count > 0 ? "1" : "0"; + string isSlave = connDb.taM2S.getBySlave(idxMacchina).Count > 0 ? "1" : "0"; + answ.Add("Master", isMaster); + answ.Add("Slave", isSlave); + + // verifico il timeout che cambia a seconda che sia vero o falso insEnabled... + int tOutShort = memLayer.ML.cdvi("TmOut.MS.S"); + int tOutLong = memLayer.ML.cdvi("TmOut.MS.L"); + int redDtMacTOut = tOutLong; + try + { + redDtMacTOut = (answ["insEnabled"].ToLower() == "true") ? tOutShort : tOutLong; + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in calcolo timeout dati macchina: idxMacchina{idxMacchina} | TShort: {tOutShort} | TLong {tOutLong}{Environment.NewLine}{exc}"); + } + // salvo in redis! + memLayer.ML.redSaveHashDict(currHash, answ, redDtMacTOut); + } + else + { + logger.lg.scriviLog("Errore in chiamata stp_MSFD_getMacc (connDb.taMSFD.getByIdxMacc(idxMacchina))"); + } + return answ; + } + + /// + /// Resetta (rileggendo) i dati della State Machine multi ingressi nel formato + /// key: IdxMacchina + /// value: IdxFamigliaIngresso + /// + /// + /// + public KeyValuePair[] resetMSMI(string idxMacchina) + { + string currHash = hMSMI(idxMacchina); + DS_applicazione.MSFDDataTable tabMSMI = new DS_applicazione.MSFDDataTable(); + // 2017.09.13: inserisco gestione singleton condizionale + if (memLayer.ML.CRB("disable_singleton")) + { + // instanzio un nuovo oggetto MapoDb + MapoDb connDb = new MapoDb(); + tabMSMI = connDb.taMSFD.getMulti(idxMacchina); + } + else + { + // leggo DB da singleton + tabMSMI = MapoDbObj.taMSFD.getMulti(idxMacchina); + } + KeyValuePair[] answ = new KeyValuePair[tabMSMI.Count]; + // salvo tutti i valori StateMachineIngressi... + int i = 0; + foreach (var item in tabMSMI) + { + answ[i] = new KeyValuePair(item.IdxMacchina, item.IdxFamigliaIngresso.ToString()); + i++; + } + // verifico il timeout (default 60 sec...) + int tOut = (memLayer.ML.cdvi("TmOut.MSMI") <= 0) ? 60 : memLayer.ML.cdvi("TmOut.MSMI"); + // salvo in redis! + memLayer.ML.redSaveHash(currHash, answ, tOut); + return answ; + } + + /// + /// Resetta (rileggendo) i dati della State Machine ingressi nel formato + /// key: cState_nVal (current MICRO-STATE + "_" + new Value) + /// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE) + /// + /// + /// + public KeyValuePair[] resetSMI(int idxFamIn) + { + string currHash = hSMI(idxFamIn); + DS_applicazione.TransizioneIngressiDataTable tabSMI = new DS_applicazione.TransizioneIngressiDataTable(); + // 2017.09.13: inserisco gestione singleton condizionale + if (memLayer.ML.CRB("disable_singleton")) + { + // instanzio un nuovo oggetto MapoDb + MapoDb connDb = new MapoDb(); + tabSMI = connDb.taTransIngr.getByIdxFamIng(idxFamIn); + } + else + { + // leggo DB da singleton + tabSMI = MapoDbObj.taTransIngr.getByIdxFamIng(idxFamIn); + } + KeyValuePair[] answ = new KeyValuePair[tabSMI.Count]; + // salvo tutti i valori StateMachineIngressi... + int i = 0; + string key = ""; + string val = ""; + foreach (var item in tabSMI) + { + key = string.Format("{0}_{1}", item.IdxMicroStato, item.ValoreIngresso); + val = string.Format("{0}_{1}", item.IdxTipoEvento, item.next_IdxMicroStato); + answ[i] = new KeyValuePair(key, val); + i++; + } + // verifico il timeout (default 60 sec...) + int tOut = (memLayer.ML.cdvi("TmOut.SMI") <= 0) ? 60 : memLayer.ML.cdvi("TmOut.SMI"); + // salvo in redis! + memLayer.ML.redSaveHash(currHash, answ, tOut); + return answ; + } + + /// + /// rigenera la tab diario di bordo x la macchian richiesta nell'intervallo definito + /// + /// + /// + /// + public void rigeneraDiarioDiBordo(string IdxMacchina, DateTime dataInizio, DateTime dataFine) + { + // elimino da diario di bordo i valori nell'intervallo... + MapoDbObj.taDiario.DeleteByMacchinaPeriodo(IdxMacchina, dataInizio, dataFine); + // seleziono le righe eventi interessate e le processo 1 ad 1... + DS_applicazione.EventListDataTable tabEventi = MapoDbObj.taEvList.GetByMacchinaPeriodo(IdxMacchina, dataInizio, dataFine); + foreach (DS_applicazione.EventListRow rigaEv in tabEventi) + { + if (rigaEv.IdxTipo <= 12) // è barcode + { + checkCambiaStatoBatch(tipoInputEvento.barcode, IdxMacchina, rigaEv.InizioStato, rigaEv.IdxTipo, rigaEv.CodArticolo, rigaEv.Value, rigaEv.MatrOpr, rigaEv.pallet); + } + else // è hw + { + checkCambiaStatoBatch(tipoInputEvento.hw, IdxMacchina, rigaEv.InizioStato, rigaEv.IdxTipo, rigaEv.CodArticolo, rigaEv.Value, rigaEv.MatrOpr, rigaEv.pallet); + } + } + } + /// /// Processa registrazione EVENTO CONTEGGIO PEZZI x una data macchina IOB /// @@ -1105,1741 +2830,6 @@ namespace MapoDb return answ; } - /// - /// invia una mail al destinatario x linkare nuovi devices tramite URL - /// - /// - /// - /// - /// - public bool sendUserAuthEmail(string destinatario, string UserAuthKey, int idxDipendente) - { - bool fatto = false; - string smtpCli = ""; - string mittente = ""; - string oggetto = ""; - string userUrl = ""; - string baseUrl = ""; - string userWebUrl = ""; - string baseWebUrl = ""; - string corpo = ""; - try - { - // compongo la stringa - smtpCli = memLayer.ML.CRS("_smtpCli"); - mittente = memLayer.ML.CRS("_fromEmail"); - oggetto = "Link autorizzazione device per GPW"; - baseUrl = memLayer.ML.CRS("baseUrl"); - baseWebUrl = memLayer.ML.CRS("baseWebUrl"); - userUrl = string.Format("{2}jumper.aspx?UserAuthkey={0}&idxDipendente={1}", UserAuthKey, idxDipendente, baseUrl); - userWebUrl = string.Format("{2}jumper.aspx?UserAuthkey={0}&idxDipendente={1}", UserAuthKey, idxDipendente, baseWebUrl); - corpo = string.Format("Hai ricevuto questa email su richiesta tua o dell'Admin per poter procedere a registrare un (nuovo) devices con GPW:{0}
Per proseguire clicca sul link seguente(rete interna):
{0}{0}{1}{0}{0}

oppure sul link seguente (internet):
{0}{0}{2}{0}{0}

Team GPW Steamware", Environment.NewLine, userUrl, userWebUrl); - gestEmail.ge.mandaEmail(mittente, destinatario, oggetto, corpo); - fatto = true; - } - catch { } - return fatto; - } - - /// - /// Invia email di avviso che ci sono dei TC da confermare - /// - /// - /// - public bool sendWarnTcChangeReq(string destinatario) - { - bool fatto = false; - string mittente = ""; - string oggetto = ""; - string pageUrl = ""; - string corpo = ""; - try - { - // compongo la stringa - mittente = memLayer.ML.CRS("_fromEmail"); - oggetto = memLayer.ML.CRS("oggettoChgTc"); - pageUrl = string.Format("{0}{1}", memLayer.ML.CRS("baseUrlAdmin"), memLayer.ML.CRS("pageUrlApprODL")); - corpo = string.Format(memLayer.ML.CRS("corpoChgTc"), Environment.NewLine, pageUrl); - if (memLayer.ML.CRB("_useAuthSmtp")) - { - gestEmail.geAuth.mandaEmail(mittente, destinatario, oggetto, corpo); - } - else - { - gestEmail.ge.mandaEmail(mittente, destinatario, oggetto, corpo); - } - fatto = true; - } - catch { } - return fatto; - } - - /// - /// SET elenco parametri correnti x IOB - /// - /// - /// - /// - public bool setCurrObjItems(string idxMacchina, List currValues) - { - bool answ = false; - if (currValues != null) - { - string serVal = JsonConvert.SerializeObject(currValues); - memLayer.ML.setRSV(currParametersHash(idxMacchina), serVal); - } - return answ; - } - - /// - /// Salvataggio su della mappa di memoria dell'IOB x ulteriori impieghi - /// - /// - /// - /// - public bool setIobMemMap(string idxMacchina, plcMemMap currMemMap) - { - bool answ = false; - // se ho un area memoria valida... - if (currMemMap != null) - { - // salvo! - string serVal = JsonConvert.SerializeObject(currMemMap); - memLayer.ML.setRSV(memMapHash(idxMacchina), serVal); - } - return answ; - } - - /// - /// Effettua UPSERT elenco parametri correnti x IOB (se c'è UPDATE, se manca ADD) - /// - /// - /// - /// - public bool upsertCurrObjItems(string idxMacchina, List innovations) - { - bool answ = false; - if (innovations != null) - { - // leggo i valori attuali... - List actValues = getCurrObjItems(idxMacchina); - // per ogni valore passatomi faccio insert o update - foreach (var item in actValues) - { - // cerco nelle innovazioni SE CI SIA un valore act - objItem trovato = innovations.Find(obj => obj.uid == item.uid); - // se non trovato... - if (trovato == null) - { - // aggiungo - innovations.Add(item); - } - } - // serializzo e salvo - string serVal = JsonConvert.SerializeObject(innovations); - memLayer.ML.setRSV(currParametersHash(idxMacchina), serVal); - } - return answ; - } - - /// - /// Calcola l'effettivo valore da passare alla macchina a stati INGRESSI data conf Macchine2FamigliaIngressi - /// - /// - /// - /// - private string preProcInput(string idxMacchina, string valore) - { - string newVal = ""; - try - { - // variabili - int valINT = 0; - int BitFilt = 0; - int BSR = 0; - bool ExplodeBit = false; - int NumBit = 0; - int newValInt = 0; - // recupero parametri... - int.TryParse(mDatiMacchinaVal(idxMacchina, "BitFilt"), out BitFilt); - int.TryParse(mDatiMacchinaVal(idxMacchina, "BSR"), out BSR); - Boolean.TryParse(mDatiMacchinaVal(idxMacchina, "ExplodeBit"), out ExplodeBit); - int.TryParse(mDatiMacchinaVal(idxMacchina, "NumBit"), out NumBit); // non usato (x ora) - // recupero valore - valINT = int.Parse(valore, NumberStyles.HexNumber); - // filtro - newValInt = utility.bMaskInt(valINT, BitFilt); - // effettuo eventuale BitShiftRight - if (BSR > 0) - { - newValInt = newValInt >> BSR; - } - // effettuo eventuale esplosione in BIT esclusivi - if (ExplodeBit) - { - newValInt = Convert.ToInt32(1 << newValInt); - } - // riconverto a STRING HEX!!! - newVal = newValInt.ToString("X"); - } - catch - { - newVal = valore; - } - - return newVal; - } - - #region definizioni hash x REDIS - - /// - /// Hash dati MSE - /// - /// - public static string hMSE - { - get - { - return mHash(string.Format("hMSE_DATA")); - } - } - - /// - /// Hash dati tabella AnagStati macchina - /// - /// - public static string currAnagStatiMacc() - { - return mHash(string.Format("Anag:StatiMacc")); - } - - /// - /// Hash dati Current ODL x la macchina specificata - /// - /// - /// - public static string currODLHash(string idxMacchina) - { - return mHash(string.Format("CurrODL:{0}", idxMacchina)); - } - - /// - /// Hash dati Current ODL ROW x la macchina specificata - /// - /// - /// - public static string currOdlRowHash(string idxMacchina) - { - return mHash(string.Format("CurrOdlRow:{0}", idxMacchina)); - } - - /// - /// Hash dati CurrentParameters x la macchina specificata - /// - /// - /// - public static string currParametersHash(string idxMacchina) - { - return mHash(string.Format("CurrentParameters:{0}", idxMacchina)); - } - - /// - /// Hash dati Current StatoMacchina x la macchina specificata - /// - /// - /// - public static string currStatoMaccHash(string idxMacchina) - { - return mHash(string.Format("CurrStatoMacc:{0}", idxMacchina)); - } - - /// - /// Hash dati STATUS x la macchina specificata - /// - /// - /// - public static string dtMaccHash(string idxMacchina) - { - return mHash(string.Format("DtMac:{0}", idxMacchina)); - } - - /// - /// Hash dati EXE TASK x la macchina specificata - /// - /// - /// - public static string exeTaskHash(string idxMacchina) - { - return mHash(string.Format("ExeTask:{0}", idxMacchina)); - } - - /// - /// Hash dati relativi all'associazione macchina <--> IOB - /// - /// Macchina PRINCIPALE - /// - public static string hM2IOB(string IdxMacchina) - { - return mHash(string.Format("hM2IOB:{0}", IdxMacchina)); - } - - /// - /// Hash dati Macchine Multi SM Ingressi - /// - /// Macchina PRINCIPALE - /// - public static string hMSMI(string IdxMacchina) - { - return mHash(string.Format("hMSMI:{0}", IdxMacchina)); - } - - /// - /// Hash dati STATE MACHINE INGRESSI x la FAMIGLIA INGRESSI specificata (per completare poi manca singolo micro stato corrente + valore letto x definire chiave) - /// - /// - /// - public static string hSMI(int idxFamIn) - { - return mHash(string.Format("hSMI:{0}", idxFamIn)); - } - - /// - /// Hash dati BUFFER x la macchina specificata - /// - /// - /// - /// - public static string LiveBufferHash(string idxMacchina, string bufferName) - { - return mHash(string.Format("LIVE:{0}:{1}", idxMacchina, bufferName)); - } - - /// - /// Hash dati LIVE x la macchina specificata - /// - /// - /// - public static string LiveCurrValHash(string idxMacchina) - { - return mHash(string.Format("LIVE:{0}:CURR_VAL", idxMacchina)); - } - - /// - /// Hash dati MemoryMap x la macchina specificata - /// - /// - /// - public static string memMapHash(string idxMacchina) - { - return mHash(string.Format("MemMap:{0}", idxMacchina)); - } - - /// - /// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...) - /// - /// - /// - public static string mHash(string dataType) - { - return memLayer.ML.redHash(dataType); - } - - /// - /// Hash dati OPT PARAMETERS x la macchina specificata - /// - /// - /// - public static string optParHash(string idxMacchina) - { - return mHash(string.Format("OptPar:{0}", idxMacchina)); - } - - /// - /// Hash dati COUNTER x la macchina specificata - /// - /// - /// - public static string pzCountHash(string idxMacchina) - { - return mHash(string.Format("PzCount:{0}", idxMacchina)); - } - - /// - /// Hash dati STATUS x la macchina specificata. - /// - dati ODL - /// - dati articolo - /// - dati produzione corrente - /// - /// - /// - public static string stMaccHash(string idxMacchina) - { - return mHash(string.Format("StMac:{0}", idxMacchina)); - } - - /// - /// Hash x VETO dello SPLIT ODL la macchina specificata - /// - /// - /// - public static string vetoSplitOdlMaccHash(string idxMacchina) - { - return mHash($"VetoOdlMacc:{idxMacchina}"); - } - - #endregion definizioni hash x REDIS - - #region gestione MSE - - /// - /// Dati MSE serializzati in REDIS (get/set) - /// - public string currMSE - { - get - { - string answ = ""; - logger.lg.scriviLog("Richiesta MSE da REDIS"); - answ = memLayer.ML.getRSV(hMSE); - return answ; - } - set - { - int MSE_cacheDuration = memLayer.ML.CRI("MSE_cacheDuration"); - memLayer.ML.setRSV(hMSE, value, MSE_cacheDuration); - } - } - - #endregion gestione MSE - - #region gestione task macchina - - /// - /// Aggiunge un task all'elenco di quelli salvati (in modalità upsert) - /// - /// - /// - /// - /// - public bool addTask4Machine(string idxMacchina, taskType taskKey, string taskVal) - { - bool answ = false; - string currHash = exeTaskHash(idxMacchina); - try - { - // leggo task attuali... - var currTask = mTaskMacchina(idxMacchina); - currTask[taskKey.ToString()] = taskVal; - answ = memLayer.ML.redSaveHashDict(currHash, currTask); - logger.lg.scriviLog($"Task ADD - idxMacchina: {idxMacchina} | taskKey: {taskKey.ToString()} | taskVal: {taskVal}"); - } - catch { } - return answ; - } - - /// - /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato - /// - /// - /// - public Dictionary mTaskMacchina(string idxMacchina) - { - // hard coded dimensione vettore DatiMacchine - Dictionary answ = new Dictionary(); - // ORA recupero da memoria redis... - try - { - string currHash = exeTaskHash(idxMacchina); - answ = memLayer.ML.redGetHashDict(currHash); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in compilazione dati EXE TASK x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); - } - return answ; - } - - /// - /// RIMUOVE un task dall'elenco di quelli salvati - /// - /// - /// - /// - public bool remTask4Machine(string idxMacchina, taskType taskKey) - { - bool answ = false; - string currHash = exeTaskHash(idxMacchina); - try - { - // leggo task attuali... - var currTask = mTaskMacchina(idxMacchina); - currTask.Remove(taskKey.ToString()); - memLayer.ML.redDelKey(currHash); - answ = memLayer.ML.redSaveHashDict(currHash, currTask); - logger.lg.scriviLog($"Task REM - idxMacchina: {idxMacchina} | taskKey: {taskKey.ToString()}"); - } - catch { } - return answ; - } - - #endregion gestione task macchina - - #region gestione OPT PARAMETERS macchina - - /// - /// Aggiunge un PARAMETRO OPZIONALE all'elenco di quelli salvati (in modalità upsert) - /// - /// - /// - /// - /// - public bool addOptPar4Machine(string idxMacchina, string taskKey, string taskVal) - { - bool answ = false; - string currHash = optParHash(idxMacchina); - try - { - // leggo task attuali... - var currVal = mOptParMacchina(idxMacchina); - currVal[taskKey] = taskVal; - answ = memLayer.ML.redSaveHashDict(currHash, currVal); - } - catch { } - return answ; - } - - /// - /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato - /// - /// - /// - public Dictionary mOptParMacchina(string idxMacchina) - { - // hard coded dimensione vettore DatiMacchine - Dictionary answ = new Dictionary(); - // ORA recupero da memoria redis... - try - { - string currHash = optParHash(idxMacchina); - answ = memLayer.ML.redGetHashDict(currHash); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in compilazione dati OPT PARAM x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); - } - return answ; - } - - /// - /// RIMUOVE un PARAMETRO OPZIONALE dall'elenco di quelli salvati - /// - /// - /// - /// - public bool remOptPar4Machine(string idxMacchina, string taskKey) - { - bool answ = false; - string currHash = optParHash(idxMacchina); - try - { - // leggo task attuali... - var currVal = mOptParMacchina(idxMacchina); - currVal.Remove(taskKey); - memLayer.ML.redDelKey(currHash); - answ = memLayer.ML.redSaveHashDict(currHash, currVal); - } - catch { } - return answ; - } - - #endregion gestione OPT PARAMETERS macchina - - #region gestione attrezzaggi - - /// - /// Effettua split ODL - /// - /// - /// - public string forceSplitOdl(string idxMacchina) - { - string answ = "KO"; - // verifico NON CI SIA un veto a NUOVI split... 2 min di default... - string redKey = vetoSplitOdlMaccHash(idxMacchina); - string rawData = memLayer.ML.getRSV(redKey); - if (string.IsNullOrEmpty(rawData)) - { - // registro VETO x altri split... 2 minuti - memLayer.ML.setRSV(redKey, $"Inizio SPLIT-ODL {DateTime.Now}", 300); - // proseguo - DS_ProdTempi.ODLDataTable currData = null; - DateTime adesso = DateTime.Now; - // chiamo metodo redis/db... - try - { - // recupero ODL corrente - currData = currODLRowTab(idxMacchina); - if (currData.Count > 0) - { - // registro un evento di inizio attrezzaggio (idxTipoEv = 2) - int idxEvento = 2; - logger.lg.scriviLog($"Invio evento ODL-SPLIT per macchina {idxMacchina}, evento {idxEvento}, articolo {currData[0].CodArticolo}", tipoLog.INFO); - inputComandoMapo resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currData[0].CodArticolo, "ODL-SPLIT", 0, "", adesso, adesso); - // attendo 1 sec - Thread.Sleep(1000); - adesso = DateTime.Now; - // chiamo splitOdl - MapoDbObj.taODL.splitODL(currData[0].IdxODL, 0, idxMacchina, currData[0].TCRichAttr, currData[0].PzPallet, $"Nuovo ODL da forceSplitOdl", true); - // attendo 1 sec - Thread.Sleep(1000); - adesso = DateTime.Now; - // registro fine ODL (idxTipoEv = 1) - idxEvento = 1; - logger.lg.scriviLog($"Invio evento FINE ODL-SPLIT per macchina {idxMacchina}, evento {idxEvento}, articolo {currData[0].CodArticolo}", tipoLog.INFO); - resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currData[0].CodArticolo, "ODL-START"); - // chiamo refresh MSE - taMSE.forceRecalc(0, idxMacchina); - // resetto stato macchina... - memLayer.ML.redDelKey(currStatoMaccHash(idxMacchina)); - answ = "OK"; - logger.lg.scriviLog($"Effettuato reset e ricalcoli x split ODL per macchina {idxMacchina}", tipoLog.INFO); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in forceSplitOdl{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - } - return answ; - } - - #endregion gestione attrezzaggi - - #region gestione stato macchina - - /// - /// Elenco stati macchina - /// - /// - public DS_applicazione.AnagraficaStatiDataTable AnagraficaStati() - { - DS_applicazione.AnagraficaStatiDataTable answTab = null; - // cerco in cache... - string rCall = ""; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("hasAnagStati"); - try - { - rCall = memLayer.ML.getRSV(currAnagStatiMacc()); - if (!string.IsNullOrEmpty(rCall)) - { - answTab = JsonConvert.DeserializeObject(rCall); - } - else - { - //2020.01.31 nuovo obj x evitare concorrenza - MapoDb man = new MapoDb(); - answTab = man.taAnagSt.GetData(); - //answTab = MapoDbObj.taAnagSt.GetData(); - // salvo in redis... - rCall = JsonConvert.SerializeObject(answTab); - int anagrCacheDur = memLayer.ML.CRI("anagrCacheDur"); - memLayer.ML.setRSV(currAnagStatiMacc(), rCall, anagrCacheDur); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - } - else - { - answTab = MapoDbObj.taAnagSt.GetData(); - } - return answTab; - } - - /// - /// Restituisce il valore dell'intera RIGA stato macchina corrente (da redis o da DB se non trovata...) - /// - /// - /// - public DS_applicazione.StatoMacchineDataTable currSMTab(string idxMacchina) - { - DS_applicazione.StatoMacchineDataTable answTab = null; - string rCall = ""; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("hasStatoMacc"); - try - { - rCall = memLayer.ML.getRSV(currStatoMaccHash(idxMacchina)); - if (!string.IsNullOrEmpty(rCall)) - { - answTab = JsonConvert.DeserializeObject(rCall); - } - else - { - // 2020.01.31 uso nuovo oggetto connessione - MapoDb man = new MapoDb(); - answTab = man.currStatoMaccTab(idxMacchina); - //answTab = MapoDbObj.currStatoMaccTab(idxMacchina); - // salvo in redis... - rCall = JsonConvert.SerializeObject(answTab); - int currStatoMaccCacheDur = memLayer.ML.CRI("currStatoMaccCacheDur"); - memLayer.ML.setRSV(currStatoMaccHash(idxMacchina), rCall, currStatoMaccCacheDur); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - } - else - { - answTab = MapoDbObj.currStatoMaccTab(idxMacchina); - } - return answTab; - } - - #endregion gestione stato macchina - - #region gestione dati macchina - - /// - /// Restituisce il valore dell'ODL corrente (ODL deve esserci per gestione contapezzi, senza ODL NO invio/gestione ODL) - /// - /// - /// - public string currODL(string idxMacchina) - { - string answ = ""; - string rCall = ""; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("hasODL"); - try - { - rCall = memLayer.ML.getRSV(currODLHash(idxMacchina)); - if (rCall != null && rCall != "") - { - answ = rCall; - } - else - { - answ = getCurrODL(idxMacchina); - // salvo in redis... - saveCurrODL(idxMacchina, answ); - } - } - catch { } - } - return answ; - } - - /// - /// Restituisce il valore dell'ODL corrente (ODL deve esserci per gestione contapezzi, senza ODL NO invio/gestione ODL) - /// - /// - /// indica se forzare lettura da db (true) o meno - /// - public string currODL(string idxMacchina, bool forceDb) - { - string answ = ""; - // faccio comunque verifica se sia stato letto da poco il valore... x cui anche a fronte di richiesta lettura da DB per 3 sec tengo buono valore in cache redis... - string rKey = memLayer.ML.redHash($"ODL:{idxMacchina}"); - string _idxOdl = memLayer.ML.getRSV(rKey); - if (forceDb) - { - if (!string.IsNullOrEmpty(_idxOdl)) - { - answ = _idxOdl; - } - else - { - answ = getCurrODL(idxMacchina); - // salvo in redis... - saveCurrODL(idxMacchina, answ); - memLayer.ML.setRSV(rKey, answ, 3); - } - } - else - { - answ = currODL(idxMacchina); - } - return answ; - } - - /// - /// Restituisce il valore dell'intera RIGA ODL corrente (da redis o da DB se non trovata...) - /// - /// - /// - public DS_ProdTempi.ODLDataTable currODLRowTab(string idxMacchina) - { - DS_ProdTempi.ODLDataTable answTab = null; - string rCall = ""; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("hasODL_row"); - try - { - rCall = memLayer.ML.getRSV(currOdlRowHash(idxMacchina)); - if (!string.IsNullOrEmpty(rCall)) - { - answTab = JsonConvert.DeserializeObject(rCall); - } - else - { - // istanzio un NUOVO oggetto lettura - MapoDb connDb = new MapoDb(); - answTab = connDb.currODLTab(idxMacchina); - // salvo in redis... - rCall = JsonConvert.SerializeObject(answTab); - int currOdlRowCacheDur = memLayer.ML.CRI("currOdlRowCacheDur"); - memLayer.ML.setRSV(currOdlRowHash(idxMacchina), rCall, currOdlRowCacheDur); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in recupero currODLRow{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - } - else - { - // istanzio un NUOVO oggetto lettura - MapoDb connDb = new MapoDb(); - answTab = connDb.currODLTab(idxMacchina); - } - return answTab; - } - - /// - /// Restituisce il valore booleano se la macchina sia abilitata all'input - /// - /// - /// - public bool insEnab(string idxMacchina) - { - bool answ = false; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("insEnabled"); - try - { - answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "insEnabled")); - } - catch { } - } - // ...oppure dritto su DB - else - { - if (memLayer.ML.CRB("disable_singleton")) - { - // instanzio un nuovo oggetto MapoDb - MapoDb connDb = new MapoDb(); - answ = connDb.insEnabled(idxMacchina); - } - else - { - // leggo DB da singleton - answ = MapoDbObj.insEnabled(idxMacchina); - } - } - return answ; - } - - /// - /// Restituisce il valore booleano se la macchina sia di tipo MULTI (con più state machine x INGRESSI) - /// - /// - /// - public bool isMulti(string idxMacchina) - { - bool answ = false; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("isMulti"); - try - { - answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "Multi") == "1"); - } - catch { } - } - // ...oppure dritto su DB - else - { - answ = MapoDbObj.isMulti(idxMacchina); - } - return answ; - } - - /// - /// Restitusice elenco KVP dei campi DatiMacchine + StatoMacchine per l'impianto indicato - /// - /// - /// - public Dictionary mDatiMacchine(string idxMacchina) - { - // hard coded dimensione vettore DatiMacchine - Dictionary answ = new Dictionary(); - // ORA recupero da memoria redis... - try - { - string currHash = dtMaccHash(idxMacchina); - answ = memLayer.ML.redGetHashDict(currHash); - // se è vuoto... leggo da DB e popolo! - if (answ.Count == 0) - { - answ = resetDatiMacchina(idxMacchina); - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in compilazione dati Macchine x Redis - idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina)); - } - return answ; - } - - /// - /// Restituisce il contapezzi salvato per la macchina - /// - /// - /// - public int pzCounter(string idxMacchina) - { - int answ = -1; - string rCall = ""; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("getCounter"); - try - { - rCall = memLayer.ML.getRSV(pzCountHash(idxMacchina)); - if (rCall != "" && rCall != null) - { - int.TryParse(rCall, out answ); - } - else - { - answ = pzCounterTC(idxMacchina); - // salvo in redis... - saveCounter(idxMacchina, answ.ToString()); - } - } - catch { } - } - return answ; - } - - /// - /// Restituisce il contapezzi come CONTEGGIO da TCRilevati per la macchina - /// - /// - /// - public int pzCounterTC(string idxMacchina) - { - int answ = -1; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("getCounterTC"); - } - // variabile x controllo dati recuperati - DS_ProdTempi.StatoProdDataTable datiProdAct = null; - bool okDatiProd = false; - int taSP_ms_ant = memLayer.ML.cdvi("taStatoProd_ms_anticipo"); - DateTime dataRif = DateTime.Now.AddMilliseconds(-taSP_ms_ant); - okDatiProd = getStatoProd(idxMacchina, ref datiProdAct, dataRif); - // se NON avesse recuperato --> aspetto taSP_ms_ant e poi RICHIAMO procedura... - int maxTry = 3; - while (!okDatiProd && maxTry > 0) - { - logger.lg.scriviLog(string.Format("[pzCounterTC] Impossibile recuperare dati ODL x idxMacchina {0}", idxMacchina), tipoLog.WARNING); - // sleep... - Thread.Sleep(taSP_ms_ant * 2); - // riprovo lettura... - okDatiProd = getStatoProd(idxMacchina, ref datiProdAct, dataRif); - maxTry--; - } - - // ora proseguo SE ho trovato i dati... - if (okDatiProd) - { - if (datiProdAct != null) - { - if (datiProdAct.Count > 0) - { - if (!datiProdAct[0].IsPzTotODLNull()) - { - // ...a questo punto recupero DAVVERO i dati (o almeno ci provo...) - try - { - // controllo - answ = datiProdAct[0].PzTotODL; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[pzCounterTC] Eccezione in recupero PzTotODL x idxMacchina {0}{1}{2}", idxMacchina, Environment.NewLine, exc), tipoLog.EXCEPTION); - } - } - } - } - } - else - { - logger.lg.scriviLog(string.Format("[pzCounterTC] Dati ODL x idxMacchina {0} non recuperati dopo tentativi reiterati...", idxMacchina), tipoLog.WARNING); - } - return answ; - } - - /// - /// Resetta (rileggendo) i dati della macchina - /// - /// - /// - public Dictionary resetDatiMacchina(string idxMacchina) - { - string currHash = dtMaccHash(idxMacchina); - // inizio con un bel reset... - memLayer.ML.redFlushKey(currHash); - Dictionary answ = new Dictionary(); - DS_applicazione.MSFDDataTable tabMSFD = new DS_applicazione.MSFDDataTable(); - // 2018.01.08 SEMPRE senza singleton: instanzio un nuovo oggetto MapoDb - MapoDb connDb = new MapoDb(); - tabMSFD = connDb.taMSFD.getByIdxMacc(idxMacchina); - bool trovato = false; - // se ho righe... - DS_applicazione.MSFDDataTable tab = new DS_applicazione.MSFDDataTable(); - DS_applicazione.MSFDRow rigaMSFD; - if (tabMSFD.Rows.Count > 0) - { - try - { - rigaMSFD = tabMSFD[0]; - trovato = true; - } - catch - { - rigaMSFD = tab.NewMSFDRow(); - } - } - else - { - rigaMSFD = tab.NewMSFDRow(); - } - if (trovato) - { - // ora provo a compilare... - try - { - // salvo 1:1 i valori... STATO - answ.Add("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString()); - answ.Add("IdxStato", rigaMSFD.IdxStato.ToString()); - answ.Add("CodArticolo", rigaMSFD.CodArticolo); - answ.Add("insEnabled", rigaMSFD.insEnabled.ToString()); - answ.Add("sLogEnabled", rigaMSFD.sLogEnabled.ToString()); - answ.Add("pallet", rigaMSFD.pallet); - answ.Add("CodArticolo_A", rigaMSFD.CodArticolo_A); - answ.Add("CodArticolo_B", rigaMSFD.CodArticolo_B); - answ.Add("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString()); - answ.Add("PzPalletProd", rigaMSFD.PzPalletProd.ToString()); - answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString()); - answ.Add("lastVal", rigaMSFD.lastVal); - answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString()); - - //...e SETUP - answ.Add("CodMacc", rigaMSFD.codmacchina); - answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString()); - answ.Add("Multi", rigaMSFD.Multi.ToString()); - answ.Add("BitFilt", rigaMSFD.BitFilt.ToString()); - answ.Add("MaxVal", rigaMSFD.MaxVal.ToString()); - answ.Add("BSR", rigaMSFD.BSR.ToString()); - answ.Add("ExplodeBit", rigaMSFD.ExplodeBit.ToString()); - answ.Add("NumBit", rigaMSFD.NumBit.ToString()); - answ.Add("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString()); - answ.Add("simplePallet", rigaMSFD.simplePallet.ToString()); - answ.Add("palletChange", rigaMSFD.palletChange.ToString()); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in compilazione dati MSFD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - // verifico il timeout che cambia a seconda che sia vero o falso insEnabled... - int tOutShort = memLayer.ML.cdvi("TmOut.MS.S"); - int tOutLong = memLayer.ML.cdvi("TmOut.MS.L"); - int redDtMacTOut = tOutLong; - try - { - redDtMacTOut = (answ["insEnabled"].ToLower() == "true") ? tOutShort : tOutLong; - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in calcolo timeout dati macchina: idxMacchina{idxMacchina} | TShort: {tOutShort} | TLong {tOutLong}{Environment.NewLine}{exc}"); - } - // salvo in redis! - memLayer.ML.redSaveHashDict(currHash, answ, redDtMacTOut); - } - else - { - logger.lg.scriviLog("Errore in chiamata stp_MSFD_getMacc (connDb.taMSFD.getByIdxMacc(idxMacchina))"); - } - return answ; - } - - /// - /// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel Signal Log - /// - /// - /// - public bool sLogEnab(string idxMacchina) - { - bool answ = false; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("sLogEnabled"); - try - { - answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "sLogEnabled")); - } - catch { } - } - // ...oppure dritto su DB - else - { - answ = MapoDbObj.sLogEnabled(idxMacchina); - } - return answ; - } - - /// - /// Recupero dati stato prod da macchina... - /// - /// - /// - /// - /// - private bool getStatoProd(string idxMacchina, ref DS_ProdTempi.StatoProdDataTable datiProdAct, DateTime dataRif) - { - bool answ = false; - try - { - // recupero con stored NUOVA... - //2020.01.31 NUOVO oggetto (NON singleton) - DataLayer man = new DataLayer(); - datiProdAct = man.taStatoProd.GetData(idxMacchina, dataRif); - if (datiProdAct.Rows.Count > 0) - { - // solo SE ho idxODL (altrimenti loggo errore) - if (datiProdAct[0].IdxOdl > 0) - { - answ = true; - } - else - { - // verifico se ho già questo errore attivo IN REDIS (altrimenti reinvio) - logger.lg.scriviLog($"pzCounterTC: Non trovato currODL x idxMacchina {idxMacchina} ", $"idxMacchina {idxMacchina} | IdxOdl {datiProdAct[0].IdxOdl} | pzTot {datiProdAct[0].PzTotODL} | dataRif {dataRif}", tipoLog.WARNING); - } - } - else - { - logger.lg.scriviLog($"pzCounterTC: Non trovate righe in currODL {idxMacchina}", $"Non trovate righe in currODL x idxMacchina {idxMacchina}: datiProdAct vuota", tipoLog.WARNING); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"[pzCounterTC] Eccezione in pzCounterTC x idxMacchina {idxMacchina}", $"[pzCounterTC] Eccezione in pzCounterTC x idxMacchina {idxMacchina}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - return answ; - } - - #endregion gestione dati macchina - - #region gestione State Machine Ingressi - - /// - /// Recupera (da DB) i dati della State Machine multi ingressi nel formato - /// key: IdxMacchina - /// value: IdxFamigliaIngresso - /// - /// - /// - public KeyValuePair[] getMSMI_DB(string idxMacchina) - { - DS_applicazione.MSFDDataTable tabMSMI = new DS_applicazione.MSFDDataTable(); - // 2017.09.13: inserisco gestione singleton condizionale - if (memLayer.ML.CRB("disable_singleton")) - { - // instanzio un nuovo oggetto MapoDb - MapoDb connDb = new MapoDb(); - tabMSMI = connDb.taMSFD.getMulti(idxMacchina); - } - else - { - // leggo DB da singleton - tabMSMI = MapoDbObj.taMSFD.getMulti(idxMacchina); - } - KeyValuePair[] answ = new KeyValuePair[tabMSMI.Count]; - // salvo tutti i valori StateMachineIngressi... - int i = 0; - foreach (var item in tabMSMI) - { - answ[i] = new KeyValuePair(item.IdxMacchina, item.IdxFamigliaIngresso.ToString()); - i++; - } - return answ; - } - - /// - /// Restituisce valore di una singola chiave del dizionario DatiMacchina - /// - /// - /// - /// - public string mDatiMacchinaVal(string idxMacchina, string chiave) - { - string answ = ""; - try - { - answ = mDatiMacchine(idxMacchina)[chiave]; - } - catch { } - return answ; - } - - /// - /// Restitusice elenco KVP - /// key: IdxMacchina - /// value: IdxFamigliaIngresso - /// - /// - /// - public KeyValuePair[] mTabMSMI(string idxMacchina) - { - // hard coded dimensione vettore DatiMacchine - KeyValuePair[] answ = new KeyValuePair[1]; - // iniziualizzo con un valore... 0/0 - answ[0] = new KeyValuePair("0", "0"); - // ORA recupero da memoria redis... - try - { - string currHash = hMSMI(idxMacchina); - answ = memLayer.ML.redGetHash(currHash); - // se è vuoto... leggo da DB e popolo! - if (answ.Length == 0) - { - answ = resetMSMI(idxMacchina); - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in compilazione Tabella Multi State Machine Ingressi x Redis:{0}{1}", Environment.NewLine, exc)); - } - return answ; - } - - /// - /// Restitusice elenco KVP dei campi della State Machine ingressi nel formato - /// key: cState_nVal (current MICRO-STATE + "_" + new Value) - /// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE - /// - /// - /// - public KeyValuePair[] mTabSMI(int idxFamIn) - { - // hard coded dimensione vettore DatiMacchine - KeyValuePair[] answ = new KeyValuePair[1]; - // iniziualizzo con un valore... 0/0 - answ[0] = new KeyValuePair("0", "0"); - // ORA recupero da memoria redis... - try - { - string currHash = hSMI(idxFamIn); - answ = memLayer.ML.redGetHash(currHash); - // se è vuoto... leggo da DB e popolo! - if (answ.Length == 0) - { - answ = resetSMI(idxFamIn); - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Errore in compilazione State Machine Ingressi x Redis:{0}{1}", Environment.NewLine, exc)); - } - return answ; - } - - /// - /// Resetta (rileggendo) i dati della State Machine multi ingressi nel formato - /// key: IdxMacchina - /// value: IdxFamigliaIngresso - /// - /// - /// - public KeyValuePair[] resetMSMI(string idxMacchina) - { - string currHash = hMSMI(idxMacchina); - DS_applicazione.MSFDDataTable tabMSMI = new DS_applicazione.MSFDDataTable(); - // 2017.09.13: inserisco gestione singleton condizionale - if (memLayer.ML.CRB("disable_singleton")) - { - // instanzio un nuovo oggetto MapoDb - MapoDb connDb = new MapoDb(); - tabMSMI = connDb.taMSFD.getMulti(idxMacchina); - } - else - { - // leggo DB da singleton - tabMSMI = MapoDbObj.taMSFD.getMulti(idxMacchina); - } - KeyValuePair[] answ = new KeyValuePair[tabMSMI.Count]; - // salvo tutti i valori StateMachineIngressi... - int i = 0; - foreach (var item in tabMSMI) - { - answ[i] = new KeyValuePair(item.IdxMacchina, item.IdxFamigliaIngresso.ToString()); - i++; - } - // verifico il timeout (default 60 sec...) - int tOut = (memLayer.ML.cdvi("TmOut.MSMI") <= 0) ? 60 : memLayer.ML.cdvi("TmOut.MSMI"); - // salvo in redis! - memLayer.ML.redSaveHash(currHash, answ, tOut); - return answ; - } - - /// - /// Resetta (rileggendo) i dati della State Machine ingressi nel formato - /// key: cState_nVal (current MICRO-STATE + "_" + new Value) - /// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE) - /// - /// - /// - public KeyValuePair[] resetSMI(int idxFamIn) - { - string currHash = hSMI(idxFamIn); - DS_applicazione.TransizioneIngressiDataTable tabSMI = new DS_applicazione.TransizioneIngressiDataTable(); - // 2017.09.13: inserisco gestione singleton condizionale - if (memLayer.ML.CRB("disable_singleton")) - { - // instanzio un nuovo oggetto MapoDb - MapoDb connDb = new MapoDb(); - tabSMI = connDb.taTransIngr.getByIdxFamIng(idxFamIn); - } - else - { - // leggo DB da singleton - tabSMI = MapoDbObj.taTransIngr.getByIdxFamIng(idxFamIn); - } - KeyValuePair[] answ = new KeyValuePair[tabSMI.Count]; - // salvo tutti i valori StateMachineIngressi... - int i = 0; - string key = ""; - string val = ""; - foreach (var item in tabSMI) - { - key = string.Format("{0}_{1}", item.IdxMicroStato, item.ValoreIngresso); - val = string.Format("{0}_{1}", item.IdxTipoEvento, item.next_IdxMicroStato); - answ[i] = new KeyValuePair(key, val); - i++; - } - // verifico il timeout (default 60 sec...) - int tOut = (memLayer.ML.cdvi("TmOut.SMI") <= 0) ? 60 : memLayer.ML.cdvi("TmOut.SMI"); - // salvo in redis! - memLayer.ML.redSaveHash(currHash, answ, tOut); - return answ; - } - - /// - /// Restituisce il valore SPECIFICATO per la state machine ingressi - /// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE) - /// - /// - /// - /// - /// - public string valoreSMI(int idxFamIn, int idxMicroStato, int valoreIn) - { - string currHash = hSMI(idxFamIn); - string field = string.Format("{0}_{1}", idxMicroStato, valoreIn); - return memLayer.ML.redGetHashField(currHash, field); - } - - #endregion gestione State Machine Ingressi - - #endregion utility public esposte - - #region metodi spostati da MapoDB - - /// - /// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE - /// - /// idx macchina - /// valore ingresso - /// data-ora evento (server) - /// sequenza dati inviati - /// - public inputComandoMapo checkMicroStato(string idxMacchina, string valore, DateTime dtEve, string contatore) - { - int _logLevel = memLayer.ML.CRI("_logLevel"); - // recupero SE IMPIEGATO REDIS i valori del Dictionary della macchina... - Dictionary datiMacc = mDatiMacchine(idxMacchina); - - if (_logLevel > 6) - { - logger.lg.scriviLog(string.Format("[ChkMiSt]{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO); - } - // formatto output - inputComandoMapo answ = new inputComandoMapo(); - DS_applicazione.TransizioneIngressiDataTable TabTransIn; - DS_applicazione.TransizioneIngressiRow rigaTransIn = null; - // verifico se esista la macchina altrimenti la creo... REDIS compliant - verificaIdxMacchina(idxMacchina); - string CodArticolo = ""; - if (memLayer.ML.CRB("IOB_RedEnab")) - { - try - { - // esecuzione in REDIS - CodArticolo = datiMacc["CodArticolo"]; - } - catch { } - } - // ...oppure dritto su DB - else - { - // esecuzione in DB... - // recupero CodArticolo corretto - try - { - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) - { - // 2017.07.10 forzo init x errori "sovrapposizioni" - taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); - } - CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_4a] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - } - // recupero next microstato - int? valINT = 0; - try - { - valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber); - // esecuzione in REDIS... - if (memLayer.ML.CRB("IOB_RedEnab")) - { - try - { - int idxFamIn = Convert.ToInt32(datiMacc["IdxFamIn"]); - int idxMicroStato = Convert.ToInt32(datiMacc["IdxMicroStato"]); - int valIOB = Convert.ToInt32(valINT); - int idxTipoEv = 0; - int next_idxMS = idxMicroStato; - // verifico esistenza tab SMI... - string fiHASH = DataLayer.hSMI(idxFamIn); - string todoSMI = ""; - bool trovato = memLayer.ML.redHashPresentSz(fiHASH); - if (!trovato) - { - // ricarico tabella! - KeyValuePair[] valori = mTabSMI(idxFamIn); - } - // recupero singolo valore (stringa) x chiave - todoSMI = valoreSMI(idxFamIn, idxMicroStato, valIOB); - // solo se ho trovato un risultato nella tab SMI della famiglia macchina... - if (todoSMI != "") - { - // splitto e salvo valori OUT... - string[] valori = todoSMI.Split('_'); - idxTipoEv = Convert.ToInt32(valori[0]); - next_idxMS = Convert.ToInt32(valori[1]); - // creo la riga tipizzatya dai dati di redis x procedere... - DS_applicazione.TransizioneIngressiDataTable tab = new DS_applicazione.TransizioneIngressiDataTable(); - rigaTransIn = tab.NewTransizioneIngressiRow(); - rigaTransIn.IdxFamigliaIngresso = idxFamIn; - rigaTransIn.IdxMicroStato = idxMicroStato; - rigaTransIn.ValoreIngresso = valIOB; - rigaTransIn.IdxTipoEvento = idxTipoEv; - rigaTransIn.next_IdxMicroStato = next_idxMS; - } - } - catch { } - } - // ...oppure dritto su DB - else - { - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) - { - // 2017.06.09 forzo init x errori "sovrapposizioni" - MapoDbObj.taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter(); - } - TabTransIn = MapoDbObj.taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT); - if (TabTransIn.Rows.Count > 0) - { - rigaTransIn = TabTransIn[0]; - } - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_5a] - - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION); - } - // effettuo update vari SU DB!!! - if (rigaTransIn != null) - { - try - { - if (_logLevel > 5) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_6a] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO); - } - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) - { - // 2017.06.09 forzo init x errori "sovrapposizioni" - MapoDbObj.taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter(); - } - // salvo nuovo microstato... - MapoDbObj.taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina); - // controllo se c'è evento - if (rigaTransIn.IdxTipoEvento > 0) - { - if (_logLevel > 5) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_7a] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3} | contatore: {4} | valore: {5}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, contatore, valore), tipoLog.INFO); - } - string valEsteso = string.Format("[{0}] {1}", contatore.PadLeft(3, '0'), valore); - // aggiunto contatore! - answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valEsteso, 0, "-", dtEve, DateTime.Now); - // 2017.09.12 SE era in modalità redis RICARICA dati macchina... - if (memLayer.ML.CRB("IOB_RedEnab")) - { - resetDatiMacchina(idxMacchina); - } - if (_logLevel > 5) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_a] - Macchina {0} | seriale(INT) {1} | valEsteso {3} | answ {4}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine, valEsteso, answ), tipoLog.INFO); - } - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_8a] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - } - return answ; - } - - /// - /// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE - /// - /// idx macchina - /// valore ingresso - /// data-ora evento (server) - /// - public inputComandoMapo checkMicroStato(string idxMacchina, string valore, DateTime dtEve) - { - if (memLayer.ML.CRI("_logLevel") > 6) - { - logger.lg.scriviLog(string.Format("{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO); - } - // formatto output - inputComandoMapo answ = new inputComandoMapo(); - DS_applicazione.TransizioneIngressiDataTable TabTransIn; - DS_applicazione.TransizioneIngressiRow rigaTransIn = null; - // verifico se esista la macchina altrimenti la creo... - verificaIdxMacchina(idxMacchina); - string CodArticolo = ""; - // recupero CodArticolo corretto - try - { - // 2017.07.10 forzo init x errori "sovrapposizioni" - taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); - CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A; - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_4b] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - // recupero next microstato - //int? valINT = Convert.ToInt32(valore); - int? valINT = 0; - try - { - // 2017.06.09 forzo init x errori "sovrapposizioni" - MapoDbObj.taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter(); - valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber); - TabTransIn = MapoDbObj.taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT); - if (TabTransIn.Rows.Count > 0) - { - rigaTransIn = TabTransIn[0]; - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_5b] - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION); - } - int _logLevel = memLayer.ML.CRI("_logLevel"); - // effettuo update vari - if (rigaTransIn != null) - { - try - { - if (_logLevel > 5) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_6b] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO); - } - // salvo nuovo microstato... - MapoDbObj.taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina); - // controllo se c'è evento - if (rigaTransIn.IdxTipoEvento > 0) - { - if (_logLevel > 5) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_7b] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo), tipoLog.INFO); - } - answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valore, 0, "-", dtEve, DateTime.Now); - if (_logLevel > 5) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_b] -Macchina {0}, seriale(INT) {1}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine), tipoLog.INFO); - } - } - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("[ChkMiSt_8b] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - } - return answ; - } - - /// - /// controlla se da il segnale di "microstato" deriva un evento da generare - /// - /// - /// - /// - public inputComandoMapo checkMicroStato(string idxMacchina, string valore) - { - // wrapper ad ora corrente... - return checkMicroStato(idxMacchina, valore, DateTime.Now); - } - - /// - /// restituisce valore dell'ODL attivo (iniziato e NON concluso) - /// - /// - /// - public string getCurrODL(string idxMacchina) - { - string answ = ""; - // recupero con stored NUOVA... - DS_ProdTempi.ODLDataTable tabOdl = taODL.getByMacchina(idxMacchina); - if (tabOdl.Rows.Count > 0) - { - // solo SE ho idxODL (altrimenti loggo errore) - if (tabOdl[0].IdxODL > 0) - { - answ = tabOdl[0].IdxODL.ToString(); - answ = answ == "" ? "0" : answ; - } - else - { - answ = "0"; - logger.lg.scriviLog("[currODL] Errore in currODL x idxMacchina " + idxMacchina + ": IdxODL = 0"); - } - } - else - { - // se è empty --> 0!!! - answ = "0"; - } - // ultimo controllo su idxOdl... - answ = answ == "" ? "0" : answ; - // restituisco! - return answ; - } - - /// - /// restituisce una tabella con tutte le transizioni degli ingressi per una data macchina - /// - /// - /// - public DS_applicazione.TransizioneIngressiDataTable getMatriceIngressi(string idxMacchina) - { - DS_applicazione.TransizioneIngressiDataTable answ; - try - { - answ = taTranIngr.getMatriceByIdxMacchina(idxMacchina); - } - catch - { - answ = null; - } - return answ; - } - - /// - /// restituisce il TempoCiclo effettivo (tecnico) della macchina - /// - /// - /// - public decimal getTcEffMacchina(string idxMacchina) - { - decimal tc = 0; - try - { - DS_ProdTempi.stp_repDonati_getDatiProdMacchinaPeriodoRow riga = taDatiProdMacchPer.GetData(idxMacchina, DateTime.Now.AddMinutes(-30), DateTime.Now)[0]; - if (riga.TCEffRT > 0) - { - tc = riga.TCEffRT; - } - else - { - tc = riga.TCAssegnato; - } - } - catch { } - // imposto a 99'TC - if (tc == 0) - { - tc = 99.9M; - // scrivo log per indicare mancato caricamento dati tc dichiarato e conseguente errore sul timer - 2/11/2012 EN&CV - logger.lg.scriviLog(string.Format("Impostato TC Tempo Ciclo a 99' (99.9M) causa mancato inserimento tempo ciclo dichiarato")); - } - return tc; - } - - /// - /// rigenera la tab diario di bordo x la macchian richiesta nell'intervallo definito - /// - /// - /// - /// - public void rigeneraDiarioDiBordo(string IdxMacchina, DateTime dataInizio, DateTime dataFine) - { - // elimino da diario di bordo i valori nell'intervallo... - MapoDbObj.taDiario.DeleteByMacchinaPeriodo(IdxMacchina, dataInizio, dataFine); - // seleziono le righe eventi interessate e le processo 1 ad 1... - DS_applicazione.EventListDataTable tabEventi = MapoDbObj.taEvList.GetByMacchinaPeriodo(IdxMacchina, dataInizio, dataFine); - foreach (DS_applicazione.EventListRow rigaEv in tabEventi) - { - if (rigaEv.IdxTipo <= 12) // è barcode - { - checkCambiaStatoBatch(tipoInputEvento.barcode, IdxMacchina, rigaEv.InizioStato, rigaEv.IdxTipo, rigaEv.CodArticolo, rigaEv.Value, rigaEv.MatrOpr, rigaEv.pallet); - } - else // è hw - { - checkCambiaStatoBatch(tipoInputEvento.hw, IdxMacchina, rigaEv.InizioStato, rigaEv.IdxTipo, rigaEv.CodArticolo, rigaEv.Value, rigaEv.MatrOpr, rigaEv.pallet); - } - } - } - /// /// salva il segnale di "microstato" /// @@ -3079,6 +3069,24 @@ namespace MapoDb return answ; } + public int scriviRigaEventoSimulata(DateTime dataOra, string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet) + { + // verifico se esista la macchina altrimenti la creo... + verificaIdxMacchina(IdxMacchina); + // inserisco evento + int inserito = MapoDbObj.taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet); + return inserito; + } + + public int scriviRigaEventoSimulata(DateTime dataOra, string IdxMacchina, int IdxTipo, string CodArticolo, string Value) + { + // verifico se esista la macchina altrimenti la creo... + verificaIdxMacchina(IdxMacchina); + // inserisco evento + int inserito = MapoDbObj.taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-"); + return inserito; + } + /// /// scrive una riga di stato nel diario di bordo /// @@ -3114,167 +3122,6 @@ namespace MapoDb return answ; } - /// - /// verifica se sia necessario inserire un cambio di stato impianto in modalità batch - /// - /// - /// - /// - /// - /// - /// - /// - /// - private void checkCambiaStatoBatch(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet) - { - int _logLevel = memLayer.ML.CRI("_logLevel"); - DS_applicazione.TransizioneStatiDataTable tabTransStati; - DS_applicazione.TransizioneStatiRow rigaTransStati; - switch (tipoInput) - { - case tipoInputEvento.barcode: - // effettuo cambio stato INDIPENDENTEMENTE da stato precedente - try - { - tabTransStati = MapoDbObj.taTranSt.GetUserForcedTransitions(IdxMacchina, IdxTipo); - if (tabTransStati != null) - { - if (tabTransStati.Count > 0) - { - rigaTransStati = tabTransStati[0]; - // solo se cambia stato... - if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato) - { - MapoDbObj.taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet); - // aggiorno MSE - taMSE.forceRecalc(0, IdxMacchina); - } - } - else - { - if (_logLevel > 6) - { - logger.lg.scriviLog($"Non trovata riga per: BARCODE | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}", tipoLog.INFO); - } - } - } - } - catch (Exception exc) - { - // non dovrebbe succedere... input utente da barcode dovrebbero TUTTI essere inseriti in tab transizione con famiglia 1... - logger.lg.scriviLog($"Errore controllo transizione stato x evento barcode: BARCODE | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - break; - - case tipoInputEvento.hw: - // verifico se ci sia necessità di cambio stato - try - { - tabTransStati = MapoDbObj.taTranSt.GetHwTransitions(IdxMacchina, IdxTipo); - if (tabTransStati != null) - { - if (tabTransStati.Count > 0) - { - rigaTransStati = tabTransStati[0]; - if (rigaTransStati != null) - { - // solo se cambia stato... - if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato) - { - MapoDbObj.taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet); - } - } - } - else - { - if (_logLevel > 6) - { - logger.lg.scriviLog($"Non trovata riga per: HW | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}", tipoLog.INFO); - } - } - } - } - catch (Exception exc) - { - // non trovo riga [0]... NON scrivo! - logger.lg.scriviLog($"Errore controllo transizione stato x evento barcode: HW | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - break; - } - } - - /// - /// cerca codice in anagrafica macchine ed eventualmente inserisce nuova macchina - /// - /// - private void verificaIdxMacchina(string IdxMacchina) - { - bool needDB = false; - if (!memLayer.ML.CRB("disable_verificaIdxMacchina")) - { - if (memLayer.ML.CRB("IOB_RedEnab")) - { - try - { - // esecuzione in REDIS...cerco status macchina... - if (mDatiMacchine(IdxMacchina).Count == 0) - { - needDB = true; - } - } - catch { } - } - // ...oppure segno richiesta DB... - else - { - needDB = true; - } - if (needDB) - { - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) - { - taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter(); - MapoDbObj.taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter(); - } - // verifico esistenza macchina - if (taMacchine.GetByIdx(IdxMacchina).Rows.Count == 0) - { - // inserisco nuova macchina... - taMacchine.Insert(IdxMacchina, "9999", IdxMacchina, "Macchina non codificata", "-", "http://", "nd", "col", 0, 0); - } - // verifico ci sia un microstato macchina... - if (MapoDbObj.taMSM.getByIdxMacchina(IdxMacchina).Rows.Count == 0) - { - // inserisco nuovo stato... - MapoDbObj.taMSM.Insert(IdxMacchina, 0, DateTime.Now, "00"); - } - } - } - } - - #endregion metodi spostati da MapoDB - - #region scritture eventi simulati - - public int scriviRigaEventoSimulata(DateTime dataOra, string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet) - { - // verifico se esista la macchina altrimenti la creo... - verificaIdxMacchina(IdxMacchina); - // inserisco evento - int inserito = MapoDbObj.taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet); - return inserito; - } - - public int scriviRigaEventoSimulata(DateTime dataOra, string IdxMacchina, int IdxTipo, string CodArticolo, string Value) - { - // verifico se esista la macchina altrimenti la creo... - verificaIdxMacchina(IdxMacchina); - // inserisco evento - int inserito = MapoDbObj.taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-"); - return inserito; - } - public int scriviRigaStatoSimulata(DateTime dataOra, string IdxMacchina, int IdxStato, string CodArticolo, string Value, int MatrOpr, string pallet) { // verifico se esista la macchina altrimenti la creo... @@ -3293,7 +3140,184 @@ namespace MapoDb return inserito; } - #endregion scritture eventi simulati + /// + /// invia una mail al destinatario x linkare nuovi devices tramite URL + /// + /// + /// + /// + /// + public bool sendUserAuthEmail(string destinatario, string UserAuthKey, int idxDipendente) + { + bool fatto = false; + string smtpCli = ""; + string mittente = ""; + string oggetto = ""; + string userUrl = ""; + string baseUrl = ""; + string userWebUrl = ""; + string baseWebUrl = ""; + string corpo = ""; + try + { + // compongo la stringa + smtpCli = memLayer.ML.CRS("_smtpCli"); + mittente = memLayer.ML.CRS("_fromEmail"); + oggetto = "Link autorizzazione device per GPW"; + baseUrl = memLayer.ML.CRS("baseUrl"); + baseWebUrl = memLayer.ML.CRS("baseWebUrl"); + userUrl = string.Format("{2}jumper.aspx?UserAuthkey={0}&idxDipendente={1}", UserAuthKey, idxDipendente, baseUrl); + userWebUrl = string.Format("{2}jumper.aspx?UserAuthkey={0}&idxDipendente={1}", UserAuthKey, idxDipendente, baseWebUrl); + corpo = string.Format("Hai ricevuto questa email su richiesta tua o dell'Admin per poter procedere a registrare un (nuovo) devices con GPW:{0}
Per proseguire clicca sul link seguente(rete interna):
{0}{0}{1}{0}{0}

oppure sul link seguente (internet):
{0}{0}{2}{0}{0}

Team GPW Steamware", Environment.NewLine, userUrl, userWebUrl); + gestEmail.ge.mandaEmail(mittente, destinatario, oggetto, corpo); + fatto = true; + } + catch { } + return fatto; + } + + /// + /// Invia email di avviso che ci sono dei TC da confermare + /// + /// + /// + public bool sendWarnTcChangeReq(string destinatario) + { + bool fatto = false; + string mittente = ""; + string oggetto = ""; + string pageUrl = ""; + string corpo = ""; + try + { + // compongo la stringa + mittente = memLayer.ML.CRS("_fromEmail"); + oggetto = memLayer.ML.CRS("oggettoChgTc"); + pageUrl = string.Format("{0}{1}", memLayer.ML.CRS("baseUrlAdmin"), memLayer.ML.CRS("pageUrlApprODL")); + corpo = string.Format(memLayer.ML.CRS("corpoChgTc"), Environment.NewLine, pageUrl); + if (memLayer.ML.CRB("_useAuthSmtp")) + { + gestEmail.geAuth.mandaEmail(mittente, destinatario, oggetto, corpo); + } + else + { + gestEmail.ge.mandaEmail(mittente, destinatario, oggetto, corpo); + } + fatto = true; + } + catch { } + return fatto; + } + + /// + /// SET elenco parametri correnti x IOB + /// + /// + /// + /// + public bool setCurrObjItems(string idxMacchina, List currValues) + { + bool answ = false; + if (currValues != null) + { + string serVal = JsonConvert.SerializeObject(currValues); + memLayer.ML.setRSV(currParametersHash(idxMacchina), serVal); + } + return answ; + } + + /// + /// Salvataggio su della mappa di memoria dell'IOB x ulteriori impieghi + /// + /// + /// + /// + public bool setIobMemMap(string idxMacchina, plcMemMap currMemMap) + { + bool answ = false; + // se ho un area memoria valida... + if (currMemMap != null) + { + // salvo! + string serVal = JsonConvert.SerializeObject(currMemMap); + memLayer.ML.setRSV(memMapHash(idxMacchina), serVal); + } + return answ; + } + + /// + /// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel Signal Log + /// + /// + /// + public bool sLogEnab(string idxMacchina) + { + bool answ = false; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("sLogEnabled"); + try + { + answ = Convert.ToBoolean(mDatiMacchinaVal(idxMacchina, "sLogEnabled")); + } + catch { } + } + // ...oppure dritto su DB + else + { + answ = MapoDbObj.sLogEnabled(idxMacchina); + } + return answ; + } + + /// + /// Effettua UPSERT elenco parametri correnti x IOB (se c'è UPDATE, se manca ADD) + /// + /// + /// + /// + public bool upsertCurrObjItems(string idxMacchina, List innovations) + { + bool answ = false; + if (innovations != null) + { + // leggo i valori attuali... + List actValues = getCurrObjItems(idxMacchina); + // per ogni valore passatomi faccio insert o update + foreach (var item in actValues) + { + // cerco nelle innovazioni SE CI SIA un valore act + objItem trovato = innovations.Find(obj => obj.uid == item.uid); + // se non trovato... + if (trovato == null) + { + // aggiungo + innovations.Add(item); + } + } + // serializzo e salvo + string serVal = JsonConvert.SerializeObject(innovations); + memLayer.ML.setRSV(currParametersHash(idxMacchina), serVal); + } + return answ; + } + + /// + /// Restituisce il valore SPECIFICATO per la state machine ingressi + /// value: iTipoEv_nState (IdxTipoEv da trasmettere + New MICRO-STATE) + /// + /// + /// + /// + /// + public string valoreSMI(int idxFamIn, int idxMicroStato, int valoreIn) + { + string currHash = hSMI(idxFamIn); + string field = string.Format("{0}_{1}", idxMicroStato, valoreIn); + return memLayer.ML.redGetHashField(currHash, field); + } + + #endregion Public Methods } } diff --git a/MapoDb/MapoDb.cs b/MapoDb/MapoDb.cs index 735ab3c5..70b02e0e 100644 --- a/MapoDb/MapoDb.cs +++ b/MapoDb/MapoDb.cs @@ -1,3 +1,4 @@ +using MapoDb.DS_ProdTempiTableAdapters; using MapoSDK; using SteamWare; using System; @@ -6,753 +7,836 @@ using System.Data; namespace MapoDb { - - public class MapoDb - { - #region area protected - - protected string _separatore = ","; - protected string _connectionString = ""; - - /// - /// avvio i table adapter della classe - /// - private void AvviaTabAdapt() + public class MapoDb { - taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter(); - taDiario = new DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter(); - taAnagSt = new DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter(); - taAnagEv = new DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter(); - taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter(); - taTranEv = new DS_applicazioneTableAdapters.TransizioneEventiTableAdapter(); - taTranSt = new DS_applicazioneTableAdapters.TransizioneStatiTableAdapter(); - taStatoMacchine = new DS_applicazioneTableAdapters.StatoMacchineTableAdapter(); - taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter(); - taRRL = new DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter(); - taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter(); - taAnOpr = new DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter(); - taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter(); - taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter(); - taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter(); - taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); - taODL = new DS_ProdTempiTableAdapters.ODLTableAdapter(); - taTCRilevati = new DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter(); - } - /// - /// forza la connString x i vari table adapters - /// - private void setConnString() - { - _connectionString = SteamWare.memLayer.ML.confReadString("MoonProConnectionString"); - taEvList.Connection.ConnectionString = _connectionString; - taDiario.Connection.ConnectionString = _connectionString; - taAnagEv.Connection.ConnectionString = _connectionString; - taAnagSt.Connection.ConnectionString = _connectionString; - taMacchine.Connection.ConnectionString = _connectionString; - taTranEv.Connection.ConnectionString = _connectionString; - taTranSt.Connection.ConnectionString = _connectionString; - taStatoMacchine.Connection.ConnectionString = _connectionString; - taKeepAlive.Connection.ConnectionString = _connectionString; - taRRL.Connection.ConnectionString = _connectionString; - taTransIngr.Connection.ConnectionString = _connectionString; - taAnOpr.Connection.ConnectionString = _connectionString; - taDatiMacch.Connection.ConnectionString = _connectionString; - taMSM.Connection.ConnectionString = _connectionString; - taMSFD.Connection.ConnectionString = _connectionString; - taDatiMacchine.Connection.ConnectionString = _connectionString; - taODL.Connection.ConnectionString = _connectionString; - taTCRilevati.Connection.ConnectionString = _connectionString; - } - - + #region Protected Fields - /// - /// metodo privato x fornire matricola che è correntemente sulla macchina - /// - /// - /// - private int getMatrOpMacc(string idxMacchina) - { - int matr = -1; - try - { - matr = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).MatrOpr; - } - catch - { - } - return matr; - } - /// - /// metodo privato x fornire cognome-nome dalla matricola - /// - /// - /// - private string getGeneralitDaMatr(int matrOpr) - { - string cognNome = ""; - // cerco operatore... - DS_applicazione.AnagraficaOperatoriRow rigaOpr; - try - { - rigaOpr = taAnOpr.getByMatrOpr(matrOpr)[0]; - cognNome = string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome); - } - catch - { - } - return cognNome; - } + protected string _connectionString = ""; + protected string _separatore = ","; - #endregion + #endregion Protected Fields - #region area public + #region Public Fields - #region area table adapters + public DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagEv; - // area applicazione - public DS_applicazioneTableAdapters.EventListTableAdapter taEvList; - public DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiario; - public DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagEv; - public DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taAnagSt; - public DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine; - public DS_applicazioneTableAdapters.TransizioneEventiTableAdapter taTranEv; - public DS_applicazioneTableAdapters.TransizioneStatiTableAdapter taTranSt; - public DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine; - public DS_applicazioneTableAdapters.KeepAliveTableAdapter taKeepAlive; - public DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter taRRL; - public DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter taTransIngr; - public DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnOpr; - public DS_applicazioneTableAdapters.DatiMacchineTableAdapter taDatiMacch; - public DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter taMSM; - public DS_applicazioneTableAdapters.MSFDTableAdapter taMSFD; - // area tempi ciclo - public DS_ProdTempiTableAdapters.DatiMacchineTableAdapter taDatiMacchine; - public DS_ProdTempiTableAdapters.ODLTableAdapter taODL; - public DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTCRilevati; + public DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taAnagSt; - #endregion + public DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnOpr; + public DS_applicazioneTableAdapters.DatiMacchineTableAdapter taDatiMacch; - /// - /// avvio della classe - /// - public MapoDb() - { - AvviaTabAdapt(); - } + // area tempi ciclo + public DS_ProdTempiTableAdapters.DatiMacchineTableAdapter taDatiMacchine; - /// - /// restituisce la stringa di connessione al db - /// - public string getStringaConnessione() - { - return _connectionString; - } - /// - /// imposta la stringa di connessione al db - /// - public bool setStringaConnessione(string valore) - { - _connectionString = valore; - setConnString(); - return true; - } + public DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiario; - /// - /// restituisce boolean se la macchina sia abilitata x inserimento dati (tab DatiMacchine) - /// - /// - /// - public bool insEnabled(string idxMacchina) - { - bool answ = false; - try - { - answ = taDatiMacch.GetByIdx(idxMacchina)[0].insEnabled; - } - catch - { } - return answ; - } + // area applicazione + public DS_applicazioneTableAdapters.EventListTableAdapter taEvList; - /// - /// Testituisce tabella con riga dell'ODL attivo (iniziato e NON concluso) - /// - /// - /// - public DS_ProdTempi.ODLDataTable currODLTab(string idxMacchina) - { - DS_ProdTempi.ODLDataTable answ = null; - logger.lg.scriviLog("Recupero currODLTab da DB!", tipoLog.INFO); - try - { - //2020.01.31 nuovo obj x evitare singleton - DataLayer man = new DataLayer(); - answ = man.taODL.getByMacchina(idxMacchina); - //answ = DataLayer.obj.taODL.getByMacchina(idxMacchina); - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in recupero currODLTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - // restituisco! - return answ; - } - /// - /// Restituisce tabella con riga stato macchina - /// - /// - /// - public DS_applicazione.StatoMacchineDataTable currStatoMaccTab(string idxMacchina) - { - DS_applicazione.StatoMacchineDataTable answ = null; - logger.lg.scriviLog("Recupero currStatoMaccTab da DB!", tipoLog.INFO); - try - { - // 2020.01.31 creo nuovo obj x lettura - DataLayer man = new DataLayer(); - answ = man.taStatoMacchine.GetDataByIdxMacchina(idxMacchina); - //answ = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina); - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in recupero currStatoMaccTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - // restituisco! - return answ; - } - /// - /// restituisce boolean se la macchina sia abilitata x registrazione segnali in input (tab DatiMacchine) - /// - /// - /// - public bool sLogEnabled(string idxMacchina) - { - bool answ = false; - try - { - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) + public DS_applicazioneTableAdapters.KeepAliveTableAdapter taKeepAlive; + + public DS_ProdTempiTableAdapters.Macchine2SlaveTableAdapter taM2S; + + public DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine; + + public DS_applicazioneTableAdapters.MSFDTableAdapter taMSFD; + + public DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter taMSM; + + public DS_ProdTempiTableAdapters.ODLTableAdapter taODL; + + public DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter taRRL; + + public DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine; + + public DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTCRilevati; + + public DS_applicazioneTableAdapters.TransizioneEventiTableAdapter taTranEv; + + public DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter taTransIngr; + + public DS_applicazioneTableAdapters.TransizioneStatiTableAdapter taTranSt; + + #endregion Public Fields + + #region Public Constructors + + /// + /// avvio della classe + /// + public MapoDb() { - //2017.06.09 forzo inizializzazione oggetto.. - taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter(); + AvviaTabAdapt(); } - answ = taDatiMacch.GetByIdx(idxMacchina)[0].sLogEnabled; - } - catch - { } - return answ; - } - /// - /// Restituisce il valore booleano se la macchina sia di tipo MULTI (con più state machine x INGRESSI) - /// - /// - /// - public bool isMulti(string idxMacchina) - { - bool answ = false; - try - { - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) + + #endregion Public Constructors + + #region Private Methods + + /// + /// avvio i table adapter della classe + /// + private void AvviaTabAdapt() { - //2017.06.09 forzo inizializzazione oggetto.. - taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter(); - } - answ = taMSFD.getByIdxMacc(idxMacchina)[0].Multi == 1; - } - catch - { } - return answ; - } - - - /// - /// - /// - /// - /// - /// - /// mac address (inviato dalla macchina) - /// - public inputComandoMapo registraStartup(string idxMacchina, string IPv4, string agent, string macAddr) - { - if (memLayer.ML.CRI("_logLevel") > 6) - { - logger.lg.scriviLog(string.Format("{0}---------------------------{0}Richiesta registrazione (ri)avvio Macchina {1} - mac: {2}", Environment.NewLine, idxMacchina, macAddr), tipoLog.INFO); - } - // formatto output - inputComandoMapo answ = new inputComandoMapo(); - // scrivo remote reboot alive! - scriviRemoteReboot(idxMacchina, IPv4, agent, macAddr); - // scrivo PRIMO keep alive - scriviPrimoKeepAlive(idxMacchina, DateTime.Now); - - - return answ; - } - - - /// - /// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore - /// - /// - /// - public string getAnagEventi(string chiave) - { - int IdxTipo = Convert.ToInt32(chiave); - string _nomi = ""; - string _valori = ""; - DS_applicazione.AnagraficaEventiDataTable tabella = taAnagEv.GetByIdx(IdxTipo); - foreach (System.Data.DataColumn colonna in tabella.Columns) - { - _nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore); - _valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore); - } - return string.Format("{0}\n\r{1}\n\r", _nomi, _valori); - } - /// - /// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore - /// - /// - /// - public string getAnagStati(string chiave) - { - int IdxStato = Convert.ToInt32(chiave); - string _nomi = ""; - string _valori = ""; - DS_applicazione.AnagraficaStatiDataTable tabella = taAnagSt.GetByIdx(IdxStato); - foreach (System.Data.DataColumn colonna in tabella.Columns) - { - _nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore); - _valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore); - } - return string.Format("{0}\n\r{1}\n\r", _nomi, _valori); - } - /// - /// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore - /// - /// - /// - public string getAnagMacchine(string chiave) - { - string _nomi = ""; - string _valori = ""; - DS_applicazione.MacchineDataTable tabella = taMacchine.GetByIdx(chiave); - foreach (System.Data.DataColumn colonna in tabella.Columns) - { - _nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore); - _valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore); - } - return string.Format("{0}\n\r{1}\n\r", _nomi, _valori); - } - /// - /// fornisce tabella elenco eventi - /// - /// - public DS_applicazione.EventListDataTable elencoEventi() - { - return taEvList.GetData(); - } - /// - /// fornisce tabella elenco stati (DiarioDiBordo) - /// - /// - public DS_applicazione.DiarioDiBordoDataTable elencoStati() - { - return taDiario.GetData(); - } - /// - /// restituisce l'oggetto tipizzato che rappresenta i dati del setup di una macchina - /// - /// - /// - public DS_applicazione.DatiMacchineRow getDatiMacchina(string idxMacchina) - { - DS_applicazione.DatiMacchineRow answ = null; - try - { - answ = taDatiMacch.GetByIdx(idxMacchina)[0]; - } - catch - { - SteamWare.logger.lg.scriviLog(string.Format("Non sono riuscito a leggere la conf della macchina {0}", idxMacchina), SteamWare.tipoLog.ERROR); - } - return answ; - } - - - - - /// - /// cancella tutti gli eventi - /// - public void deleteAllEventi() - { - taEvList.DeleteAll(); - } - /// - /// cancella tutti gli stati - /// - public void deleteAllStati() - { - taDiario.DeleteAll(); - } - - /// - /// restituisce una riga di dati relativa ad una macchina - /// - /// - /// - public DS_applicazione.MacchineRow getRigaMacchina(string idxMacchina) - { - return taMacchine.GetByIdx(idxMacchina)[0]; - } - - public DS_applicazione.EventListDataTable elencoEventiImpianto(string idxMacchina) - { - return taEvList.GetDataByIdxMacchina(idxMacchina); - } - public DS_applicazione.DiarioDiBordoDataTable elencoStatiImpianto(string idxMacchina) - { - return taDiario.GetDataByIdxMacchina(idxMacchina); - } - public DS_applicazione.EventListDataTable elencoEventiImpiantoPeriodo(string idxMacchina, DateTime dal, DateTime al) - { - return taEvList.GetByMacchinaPeriodo(idxMacchina, dal, al); - } - public DS_applicazione.DiarioDiBordoDataTable nextEventoImpiantoFrom(string idxMacchina, DateTime prevData) - { - return taDiario.getNextByMacchInizioStato(idxMacchina, prevData); - } - public DS_applicazione.DiarioDiBordoDataTable elencoStatiImpiantoPeriodo(string idxMacchina, DateTime dal, DateTime al) - { - DS_applicazione.DiarioDiBordoDataTable answ = new DS_applicazione.DiarioDiBordoDataTable(); - try - { - answ = taDiario.GetByMacchinaPeriodo(idxMacchina, dal, al); - } - catch (Exception exc) - { - logger.lg.scriviLog(string.Format("Eccezione recupero elencoStatiImpiantoPeriodo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); - } - return answ; - } - - /// verifica che il bar code sia un barcode Operatore - /// - /// Bar code da verificare - /// true se bar code per operatore - public bool isOperatore(string codice) - { - // controlli validità bar code operatore : deve cominciare con O maiuscola - bool check = codice.StartsWith("O"); - return check; - } - - /// verifica che il bar code sia un barcode nomeMacchina - /// - /// Bar code da verificare - /// true se bar code per operatore - public bool isNomeMacchina(string codice) - { - // FARE!!! controllare quale codice ci vuole - // controlli validità bar code nomeMacchina : deve cominciare con O maiuscola - bool check = codice.StartsWith("C#"); - return check; - } - /// - /// verifica un codice se sia di tipo "comando" - /// - /// - /// - public inputComandoMapo isComando(string comando) - { - inputComandoMapo answ = new inputComandoMapo(); - answ.isValid = false; - DS_applicazione.TransizioneEventiDataTable tabTransEv = new DS_applicazione.TransizioneEventiDataTable(); - try - { - tabTransEv = taTranEv.GetDataByCodInviato(comando); - } - catch - { - } - if (tabTransEv.Rows.Count != 0) - { - answ.isValid = true; - answ.idxTipoEvento = tabTransEv[0].IdxTipoEvento; - answ.precInput = tabTransEv[0].prec_codInviato; - answ.text2show = tabTransEv[0].text2show; - try - { - answ.descrComando = tabTransEv[0].descrComando; - } - catch - { - answ.descrComando = "-"; - } - } - return answ; - } - - /// - /// restituisce una riga di dati relativa ad una macchina - /// - /// - /// - public DS_applicazione.StatoMacchineRow getRigaStatoMacchina(string idxMacchina) - { - return taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]; - } - /// - /// converte la definizioen di stato nel suo valore - /// - /// - /// - public string statoDaIdxStato(int idx) - { - return taAnagSt.GetByIdx(idx)[0].Descrizione; - } - - /// - /// scrive un evento di keepalive sulla tabella - /// - /// - /// - /// - public void scriviKeepAlive(string IdxMacchina, DateTime oraMacchina) - { - string nomeVar = string.Format("KeepAlive:{0}", IdxMacchina); - // cerco se ho keep alive in redis, - bool keyPresent = false; - DateTime adesso = DateTime.Now; - try - { - keyPresent = memLayer.ML.redKeyPresentSz(memLayer.ML.redHash(nomeVar)); - } - catch - { } - // se NON presente salvo in REDIS con TTL 10 sec e sul DB... - if (!keyPresent) - { - memLayer.ML.setRSV(memLayer.ML.redHash(nomeVar), adesso.ToString("s"), 10); - try - { - if (memLayer.ML.CRB("resetConnKA")) - { - if (memLayer.ML.CRB("forceResetKeepAlive")) - { - taKeepAlive.Connection.Close(); - taKeepAlive.Connection.Open(); - } - else - { - if (taKeepAlive.Connection.State == ConnectionState.Closed) - { - taKeepAlive.Connection.Open(); - } - } - } - if (memLayer.ML.CRI("_logLevel") > 6) - { - logger.lg.scriviLog($"Scrittura keep alive! IdxMacchina: {IdxMacchina}"); - } - // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto - if (memLayer.ML.CRB("disable_singleton")) - { - // 2017.06.09 forzo init x errori "sovrapposizioni" + taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter(); + taDiario = new DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter(); + taAnagSt = new DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter(); + taAnagEv = new DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter(); + taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter(); + taTranEv = new DS_applicazioneTableAdapters.TransizioneEventiTableAdapter(); + taTranSt = new DS_applicazioneTableAdapters.TransizioneStatiTableAdapter(); + taStatoMacchine = new DS_applicazioneTableAdapters.StatoMacchineTableAdapter(); taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter(); - } - taKeepAlive.UpdateQueryNoStartTime(DateTime.Now, oraMacchina, IdxMacchina); + taRRL = new DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter(); + taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter(); + taAnOpr = new DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter(); + taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter(); + taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter(); + taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter(); + taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); + taODL = new DS_ProdTempiTableAdapters.ODLTableAdapter(); + taTCRilevati = new DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter(); + taM2S = new DS_ProdTempiTableAdapters.Macchine2SlaveTableAdapter(); } - catch (Exception exc) + + /// + /// metodo privato x fornire cognome-nome dalla matricola + /// + /// + /// + private string getGeneralitDaMatr(int matrOpr) { - logger.lg.scriviLog($"Errore in scrittura keep alive!{Environment.NewLine}oraMacchina: {oraMacchina} - IdxMacchina: {IdxMacchina}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + string cognNome = ""; + // cerco operatore... + DS_applicazione.AnagraficaOperatoriRow rigaOpr; + try + { + rigaOpr = taAnOpr.getByMatrOpr(matrOpr)[0]; + cognNome = string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome); + } + catch + { + } + return cognNome; } - } - } - /// - /// Registra un evento di RemoteReboot sulla tabella - /// - /// - /// - /// - /// - public void scriviRemoteReboot(string IdxMacchina, string IPv4, string agent, string macAddr) - { - taRRL.Insert(IdxMacchina, IPv4, agent, DateTime.Now, macAddr); - } - /// - /// scrive un evento di start di keepalive sulla tabella - /// - /// - /// - /// - public void scriviPrimoKeepAlive(string IdxMacchina, DateTime oraMacchina) - { - // se non c'è riga macchina insert... - if (taKeepAlive.GetData().FindByIdxMacchina(IdxMacchina) == null) - { - taKeepAlive.Insert(IdxMacchina, DateTime.Now, oraMacchina, DateTime.Now); - } - else // altrimenti update! - { - taKeepAlive.UpdateQuery(DateTime.Now, oraMacchina, DateTime.Now, IdxMacchina); - } - } - - /// - /// fornisce il prossimo IdxMicroStato della macchina a stati della gestione segnali in input - /// - /// - /// - /// - /// - public hwMachineState getNextMicroStato(string IdxMacchina, int IdxMicroStato, int ValoreIngresso) - { - hwMachineState valori = new hwMachineState(); - valori.IdxTipoEvento = -1; - valori.next_IdxMicroStato = IdxMicroStato; // se non trovo un nuovo stato, resto in questo - // provo a recuperare i dati... - DS_applicazione.TransizioneIngressiRow rigaIngr; - try - { - rigaIngr = taTransIngr.GetNextStatus(IdxMacchina, IdxMicroStato, ValoreIngresso)[0]; - valori.IdxTipoEvento = rigaIngr.IdxTipoEvento; - valori.next_IdxMicroStato = rigaIngr.next_IdxMicroStato; - } - catch - { - } - return valori; - } - - /// - /// restituisce la stringa del colore della macchina (1 char, V/G/R) - /// - /// - /// - public string getColoreMacchina(string idxMacchina) - { - string colore = ""; - // cerco stato macchina... - DS_applicazione.StatoMacchineRow rigaStato; - try - { - rigaStato = taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]; - // cerco il colore... - try + /// + /// metodo privato x fornire matricola che è correntemente sulla macchina + /// + /// + /// + private int getMatrOpMacc(string idxMacchina) { - colore = taAnagSt.GetByIdx(rigaStato.IdxStato)[0].Semaforo; + int matr = -1; + try + { + matr = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).MatrOpr; + } + catch + { + } + return matr; } - catch + + /// + /// forza la connString x i vari table adapters + /// + private void setConnString() { + _connectionString = SteamWare.memLayer.ML.confReadString("MoonProConnectionString"); + taEvList.Connection.ConnectionString = _connectionString; + taDiario.Connection.ConnectionString = _connectionString; + taAnagEv.Connection.ConnectionString = _connectionString; + taAnagSt.Connection.ConnectionString = _connectionString; + taMacchine.Connection.ConnectionString = _connectionString; + taTranEv.Connection.ConnectionString = _connectionString; + taTranSt.Connection.ConnectionString = _connectionString; + taStatoMacchine.Connection.ConnectionString = _connectionString; + taKeepAlive.Connection.ConnectionString = _connectionString; + taRRL.Connection.ConnectionString = _connectionString; + taTransIngr.Connection.ConnectionString = _connectionString; + taAnOpr.Connection.ConnectionString = _connectionString; + taDatiMacch.Connection.ConnectionString = _connectionString; + taMSM.Connection.ConnectionString = _connectionString; + taMSFD.Connection.ConnectionString = _connectionString; + taDatiMacchine.Connection.ConnectionString = _connectionString; + taODL.Connection.ConnectionString = _connectionString; + taTCRilevati.Connection.ConnectionString = _connectionString; + taM2S.Connection.ConnectionString = _connectionString; } - } - catch - { - } - return colore; - } - /// - /// restituisce la stringa del pallet correntemente in lavorazione sulla macchina - /// - /// - /// - public string getPalletMacchina(string idxMacchina) - { - string pallet = ""; - try - { - pallet = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).pallet; - } - catch - { - } - return pallet; - } - /// - /// restituisce la matricola dell'operatore sulla macchina - /// - /// - /// - public int getMatrOprMacchina(string idxMacchina) - { - return getMatrOpMacc(idxMacchina); - } - /// - /// restituisce cognome nome dell'operatore data la sua matricola - /// - /// - /// - public string getCognomeNomeDaMatr(int matrOpr) - { - return getGeneralitDaMatr(matrOpr); + #endregion Private Methods + + #region Public Methods + + /// + /// Testituisce tabella con riga dell'ODL attivo (iniziato e NON concluso) + /// + /// + /// + public DS_ProdTempi.ODLDataTable currODLTab(string idxMacchina) + { + DS_ProdTempi.ODLDataTable answ = null; + logger.lg.scriviLog("Recupero currODLTab da DB!", tipoLog.INFO); + try + { + //2020.01.31 nuovo obj x evitare singleton + DataLayer man = new DataLayer(); + answ = man.taODL.getByMacchina(idxMacchina); + //answ = DataLayer.obj.taODL.getByMacchina(idxMacchina); + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero currODLTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + // restituisco! + return answ; + } + + /// + /// Restituisce tabella con riga stato macchina + /// + /// + /// + public DS_applicazione.StatoMacchineDataTable currStatoMaccTab(string idxMacchina) + { + DS_applicazione.StatoMacchineDataTable answ = null; + logger.lg.scriviLog("Recupero currStatoMaccTab da DB!", tipoLog.INFO); + try + { + // 2020.01.31 creo nuovo obj x lettura + DataLayer man = new DataLayer(); + answ = man.taStatoMacchine.GetDataByIdxMacchina(idxMacchina); + //answ = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina); + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero currStatoMaccTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + // restituisco! + return answ; + } + + /// + /// cancella tutti gli eventi + /// + public void deleteAllEventi() + { + taEvList.DeleteAll(); + } + + /// + /// cancella tutti gli stati + /// + public void deleteAllStati() + { + taDiario.DeleteAll(); + } + + /// + /// Dichiara esplicitamente produzione e tempo ciclo rilevato per il numero di pezzi indicati (real time, NON confermati) + /// + /// + /// + /// + /// + /// + /// + public void dichiaraProduzTempoCiclo(string IdxMacchina, string CodArticolo, decimal tempoRilevato, int numPz, DateTime eventTime, DateTime currentTime) + { + // calcolo dataOra reale (evento + delta(ora server - ora remota) + DateTime dataOra = eventTime.Add(DateTime.Now - currentTime); + // scrivo il dato del TC rilevato + taTCRilevati.Insert(IdxMacchina, CodArticolo, dataOra, tempoRilevato, numPz); + } + + /// + /// fornisce tabella elenco eventi + /// + /// + public DS_applicazione.EventListDataTable elencoEventi() + { + return taEvList.GetData(); + } + + public DS_applicazione.EventListDataTable elencoEventiImpianto(string idxMacchina) + { + return taEvList.GetDataByIdxMacchina(idxMacchina); + } + + public DS_applicazione.EventListDataTable elencoEventiImpiantoPeriodo(string idxMacchina, DateTime dal, DateTime al) + { + return taEvList.GetByMacchinaPeriodo(idxMacchina, dal, al); + } + + /// + /// fornisce tabella elenco stati (DiarioDiBordo) + /// + /// + public DS_applicazione.DiarioDiBordoDataTable elencoStati() + { + return taDiario.GetData(); + } + + public DS_applicazione.DiarioDiBordoDataTable elencoStatiImpianto(string idxMacchina) + { + return taDiario.GetDataByIdxMacchina(idxMacchina); + } + + public DS_applicazione.DiarioDiBordoDataTable elencoStatiImpiantoPeriodo(string idxMacchina, DateTime dal, DateTime al) + { + DS_applicazione.DiarioDiBordoDataTable answ = new DS_applicazione.DiarioDiBordoDataTable(); + try + { + answ = taDiario.GetByMacchinaPeriodo(idxMacchina, dal, al); + } + catch (Exception exc) + { + logger.lg.scriviLog(string.Format("Eccezione recupero elencoStatiImpiantoPeriodo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION); + } + return answ; + } + + /// + /// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore + /// + /// + /// + public string getAnagEventi(string chiave) + { + int IdxTipo = Convert.ToInt32(chiave); + string _nomi = ""; + string _valori = ""; + DS_applicazione.AnagraficaEventiDataTable tabella = taAnagEv.GetByIdx(IdxTipo); + foreach (System.Data.DataColumn colonna in tabella.Columns) + { + _nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore); + _valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore); + } + return string.Format("{0}\n\r{1}\n\r", _nomi, _valori); + } + + /// + /// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore + /// + /// + /// + public string getAnagMacchine(string chiave) + { + string _nomi = ""; + string _valori = ""; + DS_applicazione.MacchineDataTable tabella = taMacchine.GetByIdx(chiave); + foreach (System.Data.DataColumn colonna in tabella.Columns) + { + _nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore); + _valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore); + } + return string.Format("{0}\n\r{1}\n\r", _nomi, _valori); + } + + /// + /// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore + /// + /// + /// + public string getAnagStati(string chiave) + { + int IdxStato = Convert.ToInt32(chiave); + string _nomi = ""; + string _valori = ""; + DS_applicazione.AnagraficaStatiDataTable tabella = taAnagSt.GetByIdx(IdxStato); + foreach (System.Data.DataColumn colonna in tabella.Columns) + { + _nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore); + _valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore); + } + return string.Format("{0}\n\r{1}\n\r", _nomi, _valori); + } + + /// + /// restituisce cognome nome dell'operatore data la sua matricola + /// + /// + /// + public string getCognomeNomeDaMatr(int matrOpr) + { + return getGeneralitDaMatr(matrOpr); + } + + /// + /// restituisce cognome nome dell'operatore data la sua matricola + /// + /// + /// + public string getCognomeNomeOprMacchina(string idxMacchina) + { + string cognNome = ""; + try + { + cognNome = getGeneralitDaMatr(getMatrOpMacc(idxMacchina)); + } + catch + { + } + return cognNome; + } + + /// + /// restituisce la stringa del colore della macchina (1 char, V/G/R) + /// + /// + /// + public string getColoreMacchina(string idxMacchina) + { + string colore = ""; + // cerco stato macchina... + DS_applicazione.StatoMacchineRow rigaStato; + try + { + rigaStato = taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]; + // cerco il colore... + try + { + colore = taAnagSt.GetByIdx(rigaStato.IdxStato)[0].Semaforo; + } + catch + { + } + } + catch + { + } + return colore; + } + + /// + /// restituisce l'oggetto tipizzato che rappresenta i dati del setup di una macchina + /// + /// + /// + public DS_applicazione.DatiMacchineRow getDatiMacchina(string idxMacchina) + { + DS_applicazione.DatiMacchineRow answ = null; + try + { + answ = taDatiMacch.GetByIdx(idxMacchina)[0]; + } + catch + { + SteamWare.logger.lg.scriviLog(string.Format("Non sono riuscito a leggere la conf della macchina {0}", idxMacchina), SteamWare.tipoLog.ERROR); + } + return answ; + } + + /// + /// restituisce la matricola dell'operatore sulla macchina + /// + /// + /// + public int getMatrOprMacchina(string idxMacchina) + { + return getMatrOpMacc(idxMacchina); + } + + /// + /// fornisce il prossimo IdxMicroStato della macchina a stati della gestione segnali in input + /// + /// + /// + /// + /// + public hwMachineState getNextMicroStato(string IdxMacchina, int IdxMicroStato, int ValoreIngresso) + { + hwMachineState valori = new hwMachineState(); + valori.IdxTipoEvento = -1; + valori.next_IdxMicroStato = IdxMicroStato; // se non trovo un nuovo stato, resto in questo + // provo a recuperare i dati... + DS_applicazione.TransizioneIngressiRow rigaIngr; + try + { + rigaIngr = taTransIngr.GetNextStatus(IdxMacchina, IdxMicroStato, ValoreIngresso)[0]; + valori.IdxTipoEvento = rigaIngr.IdxTipoEvento; + valori.next_IdxMicroStato = rigaIngr.next_IdxMicroStato; + } + catch + { + } + return valori; + } + + /// + /// restituisce la stringa del pallet correntemente in lavorazione sulla macchina + /// + /// + /// + public string getPalletMacchina(string idxMacchina) + { + string pallet = ""; + try + { + pallet = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).pallet; + } + catch + { + } + return pallet; + } + + /// + /// restituisce una riga di dati relativa ad una macchina + /// + /// + /// + public DS_applicazione.MacchineRow getRigaMacchina(string idxMacchina) + { + return taMacchine.GetByIdx(idxMacchina)[0]; + } + + /// + /// restituisce una riga di dati relativa ad una macchina + /// + /// + /// + public DS_applicazione.StatoMacchineRow getRigaStatoMacchina(string idxMacchina) + { + return taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]; + } + + /// + /// restituisce la riga di transizione del comando... + /// + /// + /// + public DS_applicazione.TransizioneEventiRow getRigaTransizioneDaDescrComando(string descrComando) + { + return taTranEv.getByDescrComando(descrComando)[0]; + } + + /// + /// restituisce la stringa di connessione al db + /// + public string getStringaConnessione() + { + return _connectionString; + } + + /// + /// restituisce boolean se la macchina sia abilitata x inserimento dati (tab DatiMacchine) + /// + /// + /// + public bool insEnabled(string idxMacchina) + { + bool answ = false; + try + { + answ = taDatiMacch.GetByIdx(idxMacchina)[0].insEnabled; + } + catch + { } + return answ; + } + + /// + /// verifica un codice se sia di tipo "comando" + /// + /// + /// + public inputComandoMapo isComando(string comando) + { + inputComandoMapo answ = new inputComandoMapo(); + answ.isValid = false; + DS_applicazione.TransizioneEventiDataTable tabTransEv = new DS_applicazione.TransizioneEventiDataTable(); + try + { + tabTransEv = taTranEv.GetDataByCodInviato(comando); + } + catch + { + } + if (tabTransEv.Rows.Count != 0) + { + answ.isValid = true; + answ.idxTipoEvento = tabTransEv[0].IdxTipoEvento; + answ.precInput = tabTransEv[0].prec_codInviato; + answ.text2show = tabTransEv[0].text2show; + try + { + answ.descrComando = tabTransEv[0].descrComando; + } + catch + { + answ.descrComando = "-"; + } + } + return answ; + } + + /// + /// Restituisce il valore booleano se la macchina sia di tipo MASTER (ODL) + /// + /// + /// + public bool isMaster(string idxMacchina) + { + bool answ = false; + try + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + taM2S = new Macchine2SlaveTableAdapter(); + } + answ = taM2S.getByMaster(idxMacchina).Rows.Count > 1; + } + catch + { } + return answ; + } + + /// + /// Restituisce il valore booleano se la macchina sia di tipo MULTI (con più state machine x INGRESSI) + /// + /// + /// + public bool isMulti(string idxMacchina) + { + bool answ = false; + try + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + //2017.06.09 forzo inizializzazione oggetto.. + taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter(); + } + answ = taMSFD.getByIdxMacc(idxMacchina)[0].Multi == 1; + } + catch + { } + return answ; + } + + /// verifica che il bar code sia un barcode nomeMacchina + /// + /// Bar code da verificare + /// true se bar code per operatore + public bool isNomeMacchina(string codice) + { + // FARE!!! controllare quale codice ci vuole + // controlli validità bar code nomeMacchina : deve cominciare con O maiuscola + bool check = codice.StartsWith("C#"); + return check; + } + + /// verifica che il bar code sia un barcode Operatore + /// + /// Bar code da verificare + /// true se bar code per operatore + public bool isOperatore(string codice) + { + // controlli validità bar code operatore : deve cominciare con O maiuscola + bool check = codice.StartsWith("O"); + return check; + } + + /// + /// Restituisce il valore booleano se la macchina sia di tipo SLAVE (ODL) + /// + /// + /// + public bool isSlave(string idxMacchina) + { + bool answ = false; + try + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + taM2S = new Macchine2SlaveTableAdapter(); + } + answ = taM2S.getBySlave(idxMacchina).Rows.Count > 1; + } + catch + { } + return answ; + } + + public DS_applicazione.DiarioDiBordoDataTable nextEventoImpiantoFrom(string idxMacchina, DateTime prevData) + { + return taDiario.getNextByMacchInizioStato(idxMacchina, prevData); + } + + /// + /// + /// + /// + /// + /// + /// mac address (inviato dalla macchina) + /// + public inputComandoMapo registraStartup(string idxMacchina, string IPv4, string agent, string macAddr) + { + if (memLayer.ML.CRI("_logLevel") > 6) + { + logger.lg.scriviLog(string.Format("{0}---------------------------{0}Richiesta registrazione (ri)avvio Macchina {1} - mac: {2}", Environment.NewLine, idxMacchina, macAddr), tipoLog.INFO); + } + // formatto output + inputComandoMapo answ = new inputComandoMapo(); + // scrivo remote reboot alive! + scriviRemoteReboot(idxMacchina, IPv4, agent, macAddr); + // scrivo PRIMO keep alive + scriviPrimoKeepAlive(idxMacchina, DateTime.Now); + + return answ; + } + + /// + /// scrive un evento di keepalive sulla tabella + /// + /// + /// + /// + public void scriviKeepAlive(string IdxMacchina, DateTime oraMacchina) + { + string nomeVar = string.Format("KeepAlive:{0}", IdxMacchina); + // cerco se ho keep alive in redis, + bool keyPresent = false; + DateTime adesso = DateTime.Now; + try + { + keyPresent = memLayer.ML.redKeyPresentSz(memLayer.ML.redHash(nomeVar)); + } + catch + { } + // se NON presente salvo in REDIS con TTL 10 sec e sul DB... + if (!keyPresent) + { + memLayer.ML.setRSV(memLayer.ML.redHash(nomeVar), adesso.ToString("s"), 10); + try + { + if (memLayer.ML.CRB("resetConnKA")) + { + if (memLayer.ML.CRB("forceResetKeepAlive")) + { + taKeepAlive.Connection.Close(); + taKeepAlive.Connection.Open(); + } + else + { + if (taKeepAlive.Connection.State == ConnectionState.Closed) + { + taKeepAlive.Connection.Open(); + } + } + } + if (memLayer.ML.CRI("_logLevel") > 6) + { + logger.lg.scriviLog($"Scrittura keep alive! IdxMacchina: {IdxMacchina}"); + } + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + // 2017.06.09 forzo init x errori "sovrapposizioni" + taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter(); + } + taKeepAlive.UpdateQueryNoStartTime(DateTime.Now, oraMacchina, IdxMacchina); + } + catch (Exception exc) + { + logger.lg.scriviLog($"Errore in scrittura keep alive!{Environment.NewLine}oraMacchina: {oraMacchina} - IdxMacchina: {IdxMacchina}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + } + + /// + /// scrive un evento di start di keepalive sulla tabella + /// + /// + /// + /// + public void scriviPrimoKeepAlive(string IdxMacchina, DateTime oraMacchina) + { + // se non c'è riga macchina insert... + if (taKeepAlive.GetData().FindByIdxMacchina(IdxMacchina) == null) + { + taKeepAlive.Insert(IdxMacchina, DateTime.Now, oraMacchina, DateTime.Now); + } + else // altrimenti update! + { + taKeepAlive.UpdateQuery(DateTime.Now, oraMacchina, DateTime.Now, IdxMacchina); + } + } + + /// + /// Registra un evento di RemoteReboot sulla tabella + /// + /// + /// + /// + /// + public void scriviRemoteReboot(string IdxMacchina, string IPv4, string agent, string macAddr) + { + taRRL.Insert(IdxMacchina, IPv4, agent, DateTime.Now, macAddr); + } + + /// + /// imposta la stringa di connessione al db + /// + public bool setStringaConnessione(string valore) + { + _connectionString = valore; + setConnString(); + return true; + } + + /// + /// restituisce boolean se la macchina sia abilitata x registrazione segnali in input (tab DatiMacchine) + /// + /// + /// + public bool sLogEnabled(string idxMacchina) + { + bool answ = false; + try + { + // 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto + if (memLayer.ML.CRB("disable_singleton")) + { + //2017.06.09 forzo inizializzazione oggetto.. + taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter(); + } + answ = taDatiMacch.GetByIdx(idxMacchina)[0].sLogEnabled; + } + catch + { } + return answ; + } + + /// + /// converte la definizioen di stato nel suo valore + /// + /// + /// + public string statoDaIdxStato(int idx) + { + return taAnagSt.GetByIdx(idx)[0].Descrizione; + } + + /// + /// effettua verifica del codice barcode e restituisce un oggetto inputComandoMapo che indica come proseguire + /// + /// + /// + public inputComandoMapo tryBarcode(string barcodeValue) + { + inputComandoMapo answ = new inputComandoMapo(); + // controllo... + + return answ; + } + + #endregion Public Methods } - /// - /// restituisce cognome nome dell'operatore data la sua matricola - /// - /// - /// - public string getCognomeNomeOprMacchina(string idxMacchina) - { - string cognNome = ""; - try - { - cognNome = getGeneralitDaMatr(getMatrOpMacc(idxMacchina)); - } - catch - { - } - return cognNome; - } - - - - /// - /// restituisce la riga di transizione del comando... - /// - /// - /// - public DS_applicazione.TransizioneEventiRow getRigaTransizioneDaDescrComando(string descrComando) - { - return taTranEv.getByDescrComando(descrComando)[0]; - } - - /// - /// Dichiara esplicitamente produzione e tempo ciclo rilevato per il numero di pezzi indicati (real time, NON confermati) - /// - /// - /// - /// - /// - /// - /// - public void dichiaraProduzTempoCiclo(string IdxMacchina, string CodArticolo, decimal tempoRilevato, int numPz, DateTime eventTime, DateTime currentTime) - { - // calcolo dataOra reale (evento + delta(ora server - ora remota) - DateTime dataOra = eventTime.Add(DateTime.Now - currentTime); - // scrivo il dato del TC rilevato - taTCRilevati.Insert(IdxMacchina, CodArticolo, dataOra, tempoRilevato, numPz); - } - - /// - /// effettua verifica del codice barcode e restituisce un oggetto inputComandoMapo che indica come proseguire - /// - /// - /// - public inputComandoMapo tryBarcode(string barcodeValue) - { - inputComandoMapo answ = new inputComandoMapo(); - // controllo... - - return answ; - } - - #endregion - } } \ No newline at end of file