diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index c5489b54..5188e9eb 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using System.Web.Mvc; namespace MP_IO.Controllers @@ -73,32 +74,6 @@ namespace MP_IO.Controllers return answ; } - /// - /// Chiude ODL x macchina: - /// - /// GET: IOB/closeODL/SIMUL_03?idxOdl=123 - /// - /// id macchina - /// idx dell'ODL da chiudere - /// bool esecuzione - public bool closeODL(string id, int idxOdl) - { - bool answ = false; - - // init obj DataLayer - DataLayer DataLayerObj = new DataLayer(); - try - { - // chiamata diretta sul DB... - DataLayerObj.taODL.forceClose(idxOdl, id); - answ = true; - } - catch - { } - return answ; - } - - /// /// Richiesta chiusura manuale ODL x macchina (popup utente): /// @@ -135,6 +110,30 @@ namespace MP_IO.Controllers return answ; } + /// + /// Chiude ODL x macchina: + /// + /// GET: IOB/closeODL/SIMUL_03?idxOdl=123 + /// + /// id macchina + /// idx dell'ODL da chiudere + /// bool esecuzione + public bool closeODL(string id, int idxOdl) + { + bool answ = false; + + // init obj DataLayer + DataLayer DataLayerObj = new DataLayer(); + try + { + // chiamata diretta sul DB... + DataLayerObj.taODL.forceClose(idxOdl, id); + answ = true; + } + catch + { } + return answ; + } // GET: IOB/enabled/SIMUL_03 public string enabled(string id) @@ -232,6 +231,86 @@ namespace MP_IO.Controllers return answ; } + /// + /// Sistema Dossier/Snapshot giornalieri x impianto indicato, andando a generare 1 Dossier + /// giornaliero x ogni giornata dall'ultimo registrato alla data corrente + /// es: http://url_site/MP/IO/IOB/fixDailyDossier/SIMUL_03 + /// + /// + /// + public string fixDailyDossier(string id) + { + string answ = ""; + // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il + // carattere "|" che poi trasformiamo ora in "#" + id = id.Replace("|", "#"); + // effettuo processing + try + { + DataLayer DataLayerObj = new DataLayer(); + // verifico se si possa processare, ovvero tab ConfFlux x macchina sia valorizzata... + var confDataMach = DataLayerObj.confFluxMach(id); + if (confDataMach.Count > 0) + { + // determino ultima data da processare (inizio oggi, a mezzanotte) + DateTime dtTo = DateTime.Today; + DateTime dtFrom = dtTo; + // determino data di partenza, prima da dossier esistenti + var listaDoss = DataLayerObj.dossierLastByMach(id); + if (listaDoss.Count > 0) + { + // primo giorno DOPO ultima registrazione + dtFrom = listaDoss.OrderByDescending(x => x).FirstOrDefault().AddDays(1); + } + else + { + // ...o da fluxLog acquisiti... + var listaFL = DataLayerObj.fluxLogFirstByMach(id); + if (listaFL.Count > 0) + { + // giorno successivo a prima registrazione + dtFrom = listaFL.OrderBy(x => x).FirstOrDefault().AddDays(1); + } + } + string caller = $"takeFlogSnapshot({id})"; + DateTime dtStart = dtFrom; + DateTime dtEnd = dtFrom; + int maxAdd = 5; + if (dtStart < dtTo) + { + // verifico di avere almeno 1 dossier da produrre ciclo fino ad esaurire le + // date da processare + while (dtStart < dtTo && maxAdd > 0) + { + // sistemo end + dtEnd = dtStart.AddDays(1); + // effettuo chiamata registrazione snapshot! + answ = doSaveFLSnapshot(id, dtStart, dtEnd, caller); + // incremento START... + dtStart = dtEnd; + // riduco il numero di chiamate ammesse x singolo task + maxAdd--; + } + // reset cache dossier... + DataLayerObj.dossierLastByMachReset(id); + } + else + { + answ = "NO more to add"; + } + } + else + { + answ = "NO ConfFluxData"; + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero fixDailyDossier{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + return answ; + } + /// /// Sistema ODL giornalieri x impianto indicato, andando a generare 1 ODL giornaliero x ogni /// giornata dall'ultimo ODL aperto alla data corrente @@ -253,7 +332,7 @@ namespace MP_IO.Controllers var lastOdlStarted = DataLayerObj.taODL.getLastByMacc(id); if (lastOdlStarted != null && lastOdlStarted.Count > 0) { - // calcolo data ultimo avviato e cheido dal giorno dopo... + // calcolo data ultimo avviato e chiedo dal giorno dopo... DateTime dtFrom = lastOdlStarted[0].DataInizio.AddDays(1); DateTime dtTo = DateTime.Today; if (dtTo >= dtFrom) diff --git a/MapoDb/DS_DossPar.Designer.cs b/MapoDb/DS_DossPar.Designer.cs index fea382cc..004cece7 100644 --- a/MapoDb/DS_DossPar.Designer.cs +++ b/MapoDb/DS_DossPar.Designer.cs @@ -26,6 +26,8 @@ namespace MapoDb { private DossiersDataTable tableDossiers; + private ConfFluxDataTable tableConfFlux; + private global::System.Data.SchemaSerializationMode _schemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -57,6 +59,9 @@ namespace MapoDb { if ((ds.Tables["Dossiers"] != null)) { base.Tables.Add(new DossiersDataTable(ds.Tables["Dossiers"])); } + if ((ds.Tables["ConfFlux"] != null)) { + base.Tables.Add(new ConfFluxDataTable(ds.Tables["ConfFlux"])); + } this.DataSetName = ds.DataSetName; this.Prefix = ds.Prefix; this.Namespace = ds.Namespace; @@ -85,6 +90,16 @@ namespace MapoDb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + [global::System.ComponentModel.Browsable(false)] + [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] + public ConfFluxDataTable ConfFlux { + get { + return this.tableConfFlux; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.BrowsableAttribute(true)] @@ -155,6 +170,9 @@ namespace MapoDb { if ((ds.Tables["Dossiers"] != null)) { base.Tables.Add(new DossiersDataTable(ds.Tables["Dossiers"])); } + if ((ds.Tables["ConfFlux"] != null)) { + base.Tables.Add(new ConfFluxDataTable(ds.Tables["ConfFlux"])); + } this.DataSetName = ds.DataSetName; this.Prefix = ds.Prefix; this.Namespace = ds.Namespace; @@ -194,6 +212,12 @@ namespace MapoDb { this.tableDossiers.InitVars(); } } + this.tableConfFlux = ((ConfFluxDataTable)(base.Tables["ConfFlux"])); + if ((initTable == true)) { + if ((this.tableConfFlux != null)) { + this.tableConfFlux.InitVars(); + } + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -206,6 +230,8 @@ namespace MapoDb { this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; this.tableDossiers = new DossiersDataTable(); base.Tables.Add(this.tableDossiers); + this.tableConfFlux = new ConfFluxDataTable(); + base.Tables.Add(this.tableConfFlux); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -214,6 +240,12 @@ namespace MapoDb { return false; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + private bool ShouldSerializeConfFlux() { + return false; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] private void SchemaChanged(object sender, global::System.ComponentModel.CollectionChangeEventArgs e) { @@ -272,6 +304,9 @@ namespace MapoDb { [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] public delegate void DossiersRowChangeEventHandler(object sender, DossiersRowChangeEvent e); + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public delegate void ConfFluxRowChangeEventHandler(object sender, ConfFluxRowChangeEvent e); + /// ///Represents the strongly named DataTable class. /// @@ -628,6 +663,297 @@ namespace MapoDb { } } + /// + ///Represents the strongly named DataTable class. + /// + [global::System.Serializable()] + [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] + public partial class ConfFluxDataTable : global::System.Data.TypedTableBase { + + private global::System.Data.DataColumn columnIdxMacchina; + + private global::System.Data.DataColumn columnCodFlux; + + private global::System.Data.DataColumn columnEnabDoss; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public ConfFluxDataTable() { + this.TableName = "ConfFlux"; + this.BeginInit(); + this.InitClass(); + this.EndInit(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + internal ConfFluxDataTable(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", "17.0.0.0")] + protected ConfFluxDataTable(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", "17.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", "17.0.0.0")] + public global::System.Data.DataColumn CodFluxColumn { + get { + return this.columnCodFlux; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public global::System.Data.DataColumn EnabDossColumn { + get { + return this.columnEnabDoss; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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", "17.0.0.0")] + public ConfFluxRow this[int index] { + get { + return ((ConfFluxRow)(this.Rows[index])); + } + } + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public event ConfFluxRowChangeEventHandler ConfFluxRowChanging; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public event ConfFluxRowChangeEventHandler ConfFluxRowChanged; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public event ConfFluxRowChangeEventHandler ConfFluxRowDeleting; + + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public event ConfFluxRowChangeEventHandler ConfFluxRowDeleted; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public void AddConfFluxRow(ConfFluxRow row) { + this.Rows.Add(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public ConfFluxRow AddConfFluxRow(string IdxMacchina, string CodFlux, bool EnabDoss) { + ConfFluxRow rowConfFluxRow = ((ConfFluxRow)(this.NewRow())); + object[] columnValuesArray = new object[] { + IdxMacchina, + CodFlux, + EnabDoss}; + rowConfFluxRow.ItemArray = columnValuesArray; + this.Rows.Add(rowConfFluxRow); + return rowConfFluxRow; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public ConfFluxRow FindByIdxMacchinaCodFlux(string IdxMacchina, string CodFlux) { + return ((ConfFluxRow)(this.Rows.Find(new object[] { + IdxMacchina, + CodFlux}))); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public override global::System.Data.DataTable Clone() { + ConfFluxDataTable cln = ((ConfFluxDataTable)(base.Clone())); + cln.InitVars(); + return cln; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override global::System.Data.DataTable CreateInstance() { + return new ConfFluxDataTable(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + internal void InitVars() { + this.columnIdxMacchina = base.Columns["IdxMacchina"]; + this.columnCodFlux = base.Columns["CodFlux"]; + this.columnEnabDoss = base.Columns["EnabDoss"]; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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.columnCodFlux = new global::System.Data.DataColumn("CodFlux", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnCodFlux); + this.columnEnabDoss = new global::System.Data.DataColumn("EnabDoss", typeof(bool), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnEnabDoss); + this.Constraints.Add(new global::System.Data.UniqueConstraint("Constraint1", new global::System.Data.DataColumn[] { + this.columnIdxMacchina, + this.columnCodFlux}, true)); + this.columnIdxMacchina.AllowDBNull = false; + this.columnIdxMacchina.MaxLength = 50; + this.columnCodFlux.AllowDBNull = false; + this.columnCodFlux.MaxLength = 50; + this.columnEnabDoss.AllowDBNull = false; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public ConfFluxRow NewConfFluxRow() { + return ((ConfFluxRow)(this.NewRow())); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { + return new ConfFluxRow(builder); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override global::System.Type GetRowType() { + return typeof(ConfFluxRow); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanged(e); + if ((this.ConfFluxRowChanged != null)) { + this.ConfFluxRowChanged(this, new ConfFluxRowChangeEvent(((ConfFluxRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowChanging(e); + if ((this.ConfFluxRowChanging != null)) { + this.ConfFluxRowChanging(this, new ConfFluxRowChangeEvent(((ConfFluxRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleted(e); + if ((this.ConfFluxRowDeleted != null)) { + this.ConfFluxRowDeleted(this, new ConfFluxRowChangeEvent(((ConfFluxRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { + base.OnRowDeleting(e); + if ((this.ConfFluxRowDeleting != null)) { + this.ConfFluxRowDeleting(this, new ConfFluxRowChangeEvent(((ConfFluxRow)(e.Row)), e.Action)); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public void RemoveConfFluxRow(ConfFluxRow row) { + this.Rows.Remove(row); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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_DossPar ds = new DS_DossPar(); + 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 = "ConfFluxDataTable"; + 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. /// @@ -720,6 +1046,54 @@ namespace MapoDb { } } + /// + ///Represents strongly named DataRow class. + /// + public partial class ConfFluxRow : global::System.Data.DataRow { + + private ConfFluxDataTable tableConfFlux; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + internal ConfFluxRow(global::System.Data.DataRowBuilder rb) : + base(rb) { + this.tableConfFlux = ((ConfFluxDataTable)(this.Table)); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public string IdxMacchina { + get { + return ((string)(this[this.tableConfFlux.IdxMacchinaColumn])); + } + set { + this[this.tableConfFlux.IdxMacchinaColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public string CodFlux { + get { + return ((string)(this[this.tableConfFlux.CodFluxColumn])); + } + set { + this[this.tableConfFlux.CodFluxColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public bool EnabDoss { + get { + return ((bool)(this[this.tableConfFlux.EnabDossColumn])); + } + set { + this[this.tableConfFlux.EnabDossColumn] = value; + } + } + } + /// ///Row event argument class /// @@ -753,6 +1127,40 @@ namespace MapoDb { } } } + + /// + ///Row event argument class + /// + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public class ConfFluxRowChangeEvent : global::System.EventArgs { + + private ConfFluxRow eventRow; + + private global::System.Data.DataRowAction eventAction; + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public ConfFluxRowChangeEvent(ConfFluxRow 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", "17.0.0.0")] + public ConfFluxRow Row { + get { + return this.eventRow; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public global::System.Data.DataRowAction Action { + get { + return this.eventAction; + } + } + } } } namespace MapoDb.DS_DossParTableAdapters { @@ -1227,6 +1635,370 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO } } + /// + ///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 ConfFluxTableAdapter : 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", "17.0.0.0")] + public ConfFluxTableAdapter() { + this.ClearBeforeFill = true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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", "17.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", "17.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", "17.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", "17.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", "17.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 = "ConfFlux"; + tableMapping.ColumnMappings.Add("IdxMacchina", "IdxMacchina"); + tableMapping.ColumnMappings.Add("CodFlux", "CodFlux"); + tableMapping.ColumnMappings.Add("EnabDoss", "EnabDoss"); + 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 [ConfFlux] WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([CodFl" + + "ux] = @Original_CodFlux) AND ([EnabDoss] = @Original_EnabDoss))"; + 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_CodFlux", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "CodFlux", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_EnabDoss", global::System.Data.SqlDbType.Bit, 0, global::System.Data.ParameterDirection.Input, 0, 0, "EnabDoss", 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 [Dossiers] ([IdxMacchina], [DtRif], [IdxODL], [CodArticolo], [DataType], [Valore]) VALUES (@IdxMacchina, @DtRif, @IdxODL, @CodArticolo, @DataType, @Valore); +SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FROM Dossiers WHERE (IdxDossier = SCOPE_IDENTITY())"; + 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("@DtRif", global::System.Data.SqlDbType.DateTime, 0, global::System.Data.ParameterDirection.Input, 0, 0, "DtRif", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxODL", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "IdxODL", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodArticolo", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "CodArticolo", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DataType", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "DataType", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.InsertCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Valore", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "Valore", 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 [ConfFlux] SET [IdxMacchina] = @IdxMacchina, [CodFlux] = @CodFlux, [EnabDoss] = @EnabDoss WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([CodFlux] = @Original_CodFlux) AND ([EnabDoss] = @Original_EnabDoss)); +SELECT IdxMacchina, CodFlux, EnabDoss FROM ConfFlux WHERE (CodFlux = @CodFlux) AND (IdxMacchina = @IdxMacchina)"; + 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("@CodFlux", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "CodFlux", global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@EnabDoss", global::System.Data.SqlDbType.Bit, 0, global::System.Data.ParameterDirection.Input, 0, 0, "EnabDoss", 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_CodFlux", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "CodFlux", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Original_EnabDoss", global::System.Data.SqlDbType.Bit, 0, global::System.Data.ParameterDirection.Input, 0, 0, "EnabDoss", global::System.Data.DataRowVersion.Original, false, null, "", "", "")); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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", "17.0.0.0")] + private void InitCommandCollection() { + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[1]; + this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); + this._commandCollection[0].Connection = this.Connection; + this._commandCollection[0].CommandText = "SELECT * FROM ConfFlux"; + this._commandCollection[0].CommandType = global::System.Data.CommandType.Text; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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_DossPar.ConfFluxDataTable 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", "17.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, true)] + public virtual DS_DossPar.ConfFluxDataTable GetData() { + this.Adapter.SelectCommand = this.CommandCollection[0]; + DS_DossPar.ConfFluxDataTable dataTable = new DS_DossPar.ConfFluxDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(DS_DossPar.ConfFluxDataTable dataTable) { + return this.Adapter.Update(dataTable); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + public virtual int Update(DS_DossPar dataSet) { + return this.Adapter.Update(dataSet, "ConfFlux"); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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", "17.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", "17.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_CodFlux, bool Original_EnabDoss) { + if ((Original_IdxMacchina == null)) { + throw new global::System.ArgumentNullException("Original_IdxMacchina"); + } + else { + this.Adapter.DeleteCommand.Parameters[0].Value = ((string)(Original_IdxMacchina)); + } + if ((Original_CodFlux == null)) { + throw new global::System.ArgumentNullException("Original_CodFlux"); + } + else { + this.Adapter.DeleteCommand.Parameters[1].Value = ((string)(Original_CodFlux)); + } + this.Adapter.DeleteCommand.Parameters[2].Value = ((bool)(Original_EnabDoss)); + 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", "17.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, System.DateTime DtRif, int IdxODL, string CodArticolo, string DataType, string Valore) { + if ((IdxMacchina == null)) { + throw new global::System.ArgumentNullException("IdxMacchina"); + } + else { + this.Adapter.InsertCommand.Parameters[0].Value = ((string)(IdxMacchina)); + } + this.Adapter.InsertCommand.Parameters[1].Value = ((System.DateTime)(DtRif)); + this.Adapter.InsertCommand.Parameters[2].Value = ((int)(IdxODL)); + if ((CodArticolo == null)) { + throw new global::System.ArgumentNullException("CodArticolo"); + } + else { + this.Adapter.InsertCommand.Parameters[3].Value = ((string)(CodArticolo)); + } + if ((DataType == null)) { + throw new global::System.ArgumentNullException("DataType"); + } + else { + this.Adapter.InsertCommand.Parameters[4].Value = ((string)(DataType)); + } + if ((Valore == null)) { + throw new global::System.ArgumentNullException("Valore"); + } + else { + this.Adapter.InsertCommand.Parameters[5].Value = ((string)(Valore)); + } + 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", "17.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 CodFlux, bool EnabDoss, string Original_IdxMacchina, string Original_CodFlux, bool Original_EnabDoss) { + if ((IdxMacchina == null)) { + throw new global::System.ArgumentNullException("IdxMacchina"); + } + else { + this.Adapter.UpdateCommand.Parameters[0].Value = ((string)(IdxMacchina)); + } + if ((CodFlux == null)) { + throw new global::System.ArgumentNullException("CodFlux"); + } + else { + this.Adapter.UpdateCommand.Parameters[1].Value = ((string)(CodFlux)); + } + this.Adapter.UpdateCommand.Parameters[2].Value = ((bool)(EnabDoss)); + if ((Original_IdxMacchina == null)) { + throw new global::System.ArgumentNullException("Original_IdxMacchina"); + } + else { + this.Adapter.UpdateCommand.Parameters[3].Value = ((string)(Original_IdxMacchina)); + } + if ((Original_CodFlux == null)) { + throw new global::System.ArgumentNullException("Original_CodFlux"); + } + else { + this.Adapter.UpdateCommand.Parameters[4].Value = ((string)(Original_CodFlux)); + } + this.Adapter.UpdateCommand.Parameters[5].Value = ((bool)(Original_EnabDoss)); + 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", "17.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(bool EnabDoss, string Original_IdxMacchina, string Original_CodFlux, bool Original_EnabDoss) { + return this.Update(Original_IdxMacchina, Original_CodFlux, EnabDoss, Original_IdxMacchina, Original_CodFlux, Original_EnabDoss); + } + } + /// ///TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios /// @@ -1241,6 +2013,8 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO private DossiersTableAdapter _dossiersTableAdapter; + private ConfFluxTableAdapter _confFluxTableAdapter; + private bool _backupDataSetBeforeUpdate; private global::System.Data.IDbConnection _connection; @@ -1270,6 +2044,20 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.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 ConfFluxTableAdapter ConfFluxTableAdapter { + get { + return this._confFluxTableAdapter; + } + set { + this._confFluxTableAdapter = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] public bool BackupDataSetBeforeUpdate { @@ -1293,6 +2081,10 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO && (this._dossiersTableAdapter.Connection != null))) { return this._dossiersTableAdapter.Connection; } + if (((this._confFluxTableAdapter != null) + && (this._confFluxTableAdapter.Connection != null))) { + return this._confFluxTableAdapter.Connection; + } return null; } set { @@ -1309,6 +2101,9 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO if ((this._dossiersTableAdapter != null)) { count = (count + 1); } + if ((this._confFluxTableAdapter != null)) { + count = (count + 1); + } return count; } } @@ -1329,6 +2124,15 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO allChangedRows.AddRange(updatedRows); } } + if ((this._confFluxTableAdapter != null)) { + global::System.Data.DataRow[] updatedRows = dataSet.ConfFlux.Select(null, null, global::System.Data.DataViewRowState.ModifiedCurrent); + updatedRows = this.GetRealUpdatedRows(updatedRows, allAddedRows); + if (((updatedRows != null) + && (0 < updatedRows.Length))) { + result = (result + this._confFluxTableAdapter.Update(updatedRows)); + allChangedRows.AddRange(updatedRows); + } + } return result; } @@ -1347,6 +2151,14 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO allAddedRows.AddRange(addedRows); } } + if ((this._confFluxTableAdapter != null)) { + global::System.Data.DataRow[] addedRows = dataSet.ConfFlux.Select(null, null, global::System.Data.DataViewRowState.Added); + if (((addedRows != null) + && (0 < addedRows.Length))) { + result = (result + this._confFluxTableAdapter.Update(addedRows)); + allAddedRows.AddRange(addedRows); + } + } return result; } @@ -1357,6 +2169,14 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] private int UpdateDeletedRows(DS_DossPar dataSet, global::System.Collections.Generic.List allChangedRows) { int result = 0; + if ((this._confFluxTableAdapter != null)) { + global::System.Data.DataRow[] deletedRows = dataSet.ConfFlux.Select(null, null, global::System.Data.DataViewRowState.Deleted); + if (((deletedRows != null) + && (0 < deletedRows.Length))) { + result = (result + this._confFluxTableAdapter.Update(deletedRows)); + allChangedRows.AddRange(deletedRows); + } + } if ((this._dossiersTableAdapter != null)) { global::System.Data.DataRow[] deletedRows = dataSet.Dossiers.Select(null, null, global::System.Data.DataViewRowState.Deleted); if (((deletedRows != null) @@ -1409,6 +2229,11 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" + "tring."); } + if (((this._confFluxTableAdapter != null) + && (this.MatchTableAdapterConnection(this._confFluxTableAdapter.Connection) == false))) { + throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" + + "tring."); + } global::System.Data.IDbConnection workConnection = this.Connection; if ((workConnection == null)) { throw new global::System.ApplicationException("TableAdapterManager contains no connection information. Set each TableAdapterMana" + @@ -1450,6 +2275,15 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO adaptersWithAcceptChangesDuringUpdate.Add(this._dossiersTableAdapter.Adapter); } } + if ((this._confFluxTableAdapter != null)) { + revertConnections.Add(this._confFluxTableAdapter, this._confFluxTableAdapter.Connection); + this._confFluxTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(workConnection)); + this._confFluxTableAdapter.Transaction = ((global::System.Data.SqlClient.SqlTransaction)(workTransaction)); + if (this._confFluxTableAdapter.Adapter.AcceptChangesDuringUpdate) { + this._confFluxTableAdapter.Adapter.AcceptChangesDuringUpdate = false; + adaptersWithAcceptChangesDuringUpdate.Add(this._confFluxTableAdapter.Adapter); + } + } // //---- Perform updates ----------- // @@ -1512,6 +2346,10 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO this._dossiersTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(revertConnections[this._dossiersTableAdapter])); this._dossiersTableAdapter.Transaction = null; } + if ((this._confFluxTableAdapter != null)) { + this._confFluxTableAdapter.Connection = ((global::System.Data.SqlClient.SqlConnection)(revertConnections[this._confFluxTableAdapter])); + this._confFluxTableAdapter.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/DS_DossPar.xsd b/MapoDb/DS_DossPar.xsd index c65893be..df93671a 100644 --- a/MapoDb/DS_DossPar.xsd +++ b/MapoDb/DS_DossPar.xsd @@ -111,6 +111,62 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO + + + + + + DELETE FROM [ConfFlux] WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([CodFlux] = @Original_CodFlux) AND ([EnabDoss] = @Original_EnabDoss)) + + + + + + + + + + INSERT INTO [Dossiers] ([IdxMacchina], [DtRif], [IdxODL], [CodArticolo], [DataType], [Valore]) VALUES (@IdxMacchina, @DtRif, @IdxODL, @CodArticolo, @DataType, @Valore); +SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FROM Dossiers WHERE (IdxDossier = SCOPE_IDENTITY()) + + + + + + + + + + + + + SELECT * FROM ConfFlux + + + + + + UPDATE [ConfFlux] SET [IdxMacchina] = @IdxMacchina, [CodFlux] = @CodFlux, [EnabDoss] = @EnabDoss WHERE (([IdxMacchina] = @Original_IdxMacchina) AND ([CodFlux] = @Original_CodFlux) AND ([EnabDoss] = @Original_EnabDoss)); +SELECT IdxMacchina, CodFlux, EnabDoss FROM ConfFlux WHERE (CodFlux = @CodFlux) AND (IdxMacchina = @IdxMacchina) + + + + + + + + + + + + + + + + + + + @@ -123,30 +179,30 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO - + - - - + + + - + - + @@ -156,11 +212,37 @@ SELECT IdxDossier, IdxMacchina, DtRif, IdxODL, CodArticolo, DataType, Valore FRO + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MapoDb/DS_DossPar.xss b/MapoDb/DS_DossPar.xss index 0b6e46d6..9a3823ec 100644 --- a/MapoDb/DS_DossPar.xss +++ b/MapoDb/DS_DossPar.xss @@ -4,9 +4,10 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + - + + \ No newline at end of file diff --git a/MapoDb/DS_applicazione.Designer.cs b/MapoDb/DS_applicazione.Designer.cs index aa72e55f..2d9f2296 100644 --- a/MapoDb/DS_applicazione.Designer.cs +++ b/MapoDb/DS_applicazione.Designer.cs @@ -28802,7 +28802,7 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] private void InitCommandCollection() { - this._commandCollection = new global::System.Data.SqlClient.SqlCommand[8]; + this._commandCollection = new global::System.Data.SqlClient.SqlCommand[9]; this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[0].Connection = this.Connection; this._commandCollection[0].CommandText = "SELECT * FROM dbo.FluxLog"; @@ -28850,29 +28850,36 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = this._commandCollection[4].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@searchVal", 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_FL_InsNew"; + this._commandCollection[5].CommandText = "dbo.stp_FL_getFirstByMacc"; 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("@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("@dtEvento", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[5].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodFlux", 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("@Valore", global::System.Data.SqlDbType.NVarChar, 250, 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("@Count", 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("@numMax", 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_FL_TakeSnapshot"; + this._commandCollection[6].CommandText = "dbo.stp_FL_InsNew"; 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("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MaxSec", 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("@dtEvento", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@CodFlux", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Valore", global::System.Data.SqlDbType.NVarChar, 250, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[6].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Count", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 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_FL_TakeSnapshotLast"; + this._commandCollection[7].CommandText = "dbo.stp_FL_TakeSnapshot"; 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("@DtMin", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); - this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DtMax", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[7].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@MaxSec", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 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_FL_TakeSnapshotLast"; + 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("@IdxMacchina", 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("@DtMin", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[8].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@DtMax", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -29028,6 +29035,29 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = return dataTable; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] + [global::System.ComponentModel.DataObjectMethodAttribute(global::System.ComponentModel.DataObjectMethodType.Select, false)] + public virtual DS_applicazione.FluxLogDataTable getFirstByMacc(string IdxMacchina, global::System.Nullable numMax) { + this.Adapter.SelectCommand = this.CommandCollection[5]; + if ((IdxMacchina == null)) { + this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; + } + else { + this.Adapter.SelectCommand.Parameters[1].Value = ((string)(IdxMacchina)); + } + if ((numMax.HasValue == true)) { + this.Adapter.SelectCommand.Parameters[2].Value = ((int)(numMax.Value)); + } + else { + this.Adapter.SelectCommand.Parameters[2].Value = global::System.DBNull.Value; + } + DS_applicazione.FluxLogDataTable dataTable = new DS_applicazione.FluxLogDataTable(); + this.Adapter.Fill(dataTable); + return dataTable; + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] @@ -29270,7 +29300,7 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int InsNew(string IdxMacchina, global::System.Nullable dtEvento, string CodFlux, string Valore, global::System.Nullable Count) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[5]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[6]; if ((IdxMacchina == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -29322,7 +29352,7 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int takeSnapshot(string IdxMacchina, global::System.Nullable MaxSec) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[6]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[7]; if ((IdxMacchina == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } @@ -29356,7 +29386,7 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] public virtual int TakeSnapshotLast(string IdxMacchina, global::System.Nullable DtMin, global::System.Nullable DtMax) { - global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[7]; + global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[8]; if ((IdxMacchina == null)) { command.Parameters[1].Value = global::System.DBNull.Value; } diff --git a/MapoDb/DS_applicazione.xsd b/MapoDb/DS_applicazione.xsd index cda05192..5896eb29 100644 --- a/MapoDb/DS_applicazione.xsd +++ b/MapoDb/DS_applicazione.xsd @@ -2596,6 +2596,18 @@ SELECT IdxMacchina, dtEvento, CodFlux, Valore, Cnt FROM FluxLog WHERE (CodFlux = + + + + dbo.stp_FL_getFirstByMacc + + + + + + + + @@ -4033,33 +4045,33 @@ FROM v_AlarmLog - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MapoDb/DS_applicazione.xss b/MapoDb/DS_applicazione.xss index 7c726c10..b51067ed 100644 --- a/MapoDb/DS_applicazione.xss +++ b/MapoDb/DS_applicazione.xss @@ -4,7 +4,7 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index 27550302..5ad76c51 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -1,6 +1,5 @@ using MapoSDK; using Newtonsoft.Json; -using NLog.Fluent; using StackExchange.Redis; using SteamWare; using System; @@ -48,6 +47,8 @@ namespace MapoDb public DS_UtilityTableAdapters.CommentiTableAdapter taComm; + public DS_DossParTableAdapters.ConfFluxTableAdapter taConfFlux; + public DS_ProdTempiTableAdapters.DatiConfermatiTableAdapter taDatiConf; public DS_ProdTempiTableAdapters.DatiMacchineTableAdapter taDatiMacchine; @@ -148,9 +149,6 @@ namespace MapoDb #endregion Public Fields - public MessagePipe BroadastMsgPipe { get; set; } = null; - - #region Public Constructors /// @@ -171,73 +169,6 @@ namespace MapoDb BroadastMsgPipe = new MessagePipe(connRedis, Constants.BROADCAST_M_PIPE); } - /// - /// Connessione lazy a redis... - /// - private Lazy lazyConnection = new Lazy(() => - { - string RedisConn = memLayer.ML.confReadString("RedisConnSPEC"); - if (string.IsNullOrEmpty(RedisConn)) - { - RedisConn = memLayer.ML.confReadString("RedisConn"); - } - if (string.IsNullOrEmpty(RedisConn)) - { - RedisConn = "localhost,abortConnect=false,ssl=false"; - } - return ConnectionMultiplexer.Connect(RedisConn); - }); - - /// - /// Connessione lazy a redis... - /// - private Lazy lazyConnectionAdmin = new Lazy(() => - { - string RedisConnAdmin = memLayer.ML.confReadString("RedisConnSPECAdmin"); - if (string.IsNullOrEmpty(RedisConnAdmin)) - { - RedisConnAdmin = memLayer.ML.confReadString("RedisConnAdmin"); - } - if (string.IsNullOrEmpty(RedisConnAdmin)) - { - RedisConnAdmin = "localhost,abortConnect=false,ssl=false,allowAdmin=true"; - } - return ConnectionMultiplexer.Connect(RedisConnAdmin); - }); - - /// - /// Oggetto statico connessione redis - /// - public ConnectionMultiplexer connRedis - { - get - { - return lazyConnection.Value; - } - } - - /// - /// Salva richiesta azione - /// - /// - /// - public bool ActionSetReq(DisplayAction act2save) - { - bool fatto = false; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - // cerco in redis... - string rawData = JsonConvert.SerializeObject(act2save); - // invio broadcast + salvo in redis - BroadastMsgPipe.saveAndSendMessage(Constants.redisActionReq, rawData); - fatto = true; - //await redisDb.StringSetAsync(redisActionReq, rawData); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - logger.lg.scriviLog($"ActionSetReq REDIS send to broadcast + Write cache: {ts.TotalMilliseconds}ms"); - return fatto; - } - #endregion Public Constructors #region Public Properties @@ -266,6 +197,8 @@ namespace MapoDb get => mHash($"CACHE:TabCheckArt"); } + public MessagePipe BroadastMsgPipe { get; set; } = null; + /// /// Cognome Nome da MatrOpr in sessione /// @@ -285,6 +218,17 @@ namespace MapoDb } } + /// + /// Oggetto statico connessione redis + /// + public ConnectionMultiplexer connRedis + { + get + { + return lazyConnection.Value; + } + } + /// /// Dati MSE serializzati in REDIS (get/set) /// @@ -347,6 +291,16 @@ namespace MapoDb #region Public Methods + /// + /// Hash dati ConfFlux x la macchina specificata + /// + /// + /// + public static string confFluxMaccHash(string idxMacchina) + { + return mHash($"MachineConfFlux:{idxMacchina}"); + } + /// /// Hash dati tabella AnagStati macchina /// @@ -375,15 +329,6 @@ namespace MapoDb { return mHash($"CurrOdlRow:{idxMacchina}"); } - /// - /// Hash dati PODL ROW x la macchina specificata - /// - /// - /// - public static string getPOdlRowHash(int idxPODL) - { - return mHash($"PODLRow:{idxPODL}"); - } /// /// Hash dati CurrentParameters x la macchina specificata @@ -402,7 +347,7 @@ namespace MapoDb /// public static string currStatoMaccHash(string idxMacchina) { - return mHash(string.Format("CurrStatoMacc:{0}", idxMacchina)); + return mHash($"CurrStatoMacc:{idxMacchina}"); } public static List DataTableToList(DataTable dt) where T : class, new() @@ -416,6 +361,16 @@ namespace MapoDb return lstItems; } + /// + /// Hash dati Dossier (last) x la macchina specificata + /// + /// + /// + public static string dossLastMaccHash(string idxMacchina) + { + return mHash($"MachineDossierLast:{idxMacchina}"); + } + /// /// Hash dati STATUS x la macchina specificata /// @@ -436,6 +391,26 @@ namespace MapoDb return mHash(string.Format("ExeTask:{0}", idxMacchina)); } + /// + /// Hash dati FluxLog (iniziale) x la macchina specificata + /// + /// + /// + public static string fluxLogFirstMaccHash(string idxMacchina) + { + return mHash($"MachineFluxLogFirst:{idxMacchina}"); + } + + /// + /// Hash dati PODL ROW x la macchina specificata + /// + /// + /// + public static string getPOdlRowHash(int idxPODL) + { + return mHash($"PODLRow:{idxPODL}"); + } + /// Hash dati relativi all'associazione macchina <--> IOB Macchina PRINCIPALE public static string hM2IOB(string IdxMacchina) @@ -561,6 +536,16 @@ namespace MapoDb return mHash(string.Format("StMac:{0}", idxMacchina)); } + /// + /// Hash x VETO force Start PODL la macchina specificata + /// + /// + /// + public static string vetoForceStartPOdlMaccHash(string idxMacchina) + { + return mHash($"VetoStartPOdlMacc:{idxMacchina}"); + } + /// /// Hash x VETO dello SPLIT ODL la macchina specificata /// @@ -570,14 +555,27 @@ namespace MapoDb { return mHash($"VetoOdlMacc:{idxMacchina}"); } + /// - /// Hash x VETO force Start PODL la macchina specificata + /// Salva richiesta azione /// - /// + /// /// - public static string vetoForceStartPOdlMaccHash(string idxMacchina) + public bool ActionSetReq(DisplayAction act2save) { - return mHash($"VetoStartPOdlMacc:{idxMacchina}"); + bool fatto = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + // cerco in redis... + string rawData = JsonConvert.SerializeObject(act2save); + // invio broadcast + salvo in redis + BroadastMsgPipe.saveAndSendMessage(Constants.redisActionReq, rawData); + fatto = true; + //await redisDb.StringSetAsync(redisActionReq, rawData); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + logger.lg.scriviLog($"ActionSetReq REDIS send to broadcast + Write cache: {ts.TotalMilliseconds}ms"); + return fatto; } /// @@ -717,7 +715,7 @@ namespace MapoDb //2020.01.31 nuovo obj x evitare concorrenza MapoDb man = new MapoDb(); answTab = man.taAnagSt.GetData(); - //answTab = MapoDbObj.taAnagSt.GetData(); + //resultList = MapoDbObj.taAnagSt.GetData(); // salvo in redis... rCall = JsonConvert.SerializeObject(answTab); int anagrCacheDur = memLayer.ML.CRI("anagrCacheDur"); @@ -1227,6 +1225,62 @@ namespace MapoDb return answ; } + /// + /// Restituisce l'elenco codici flusso (da confFlux) x una macchina (se presenti) Impiegata + /// anche cache redis + /// + /// + /// + public List confFluxMach(string idxMacchina) + { + List resultList = new List(); + string rawData = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("confFluxMach"); + string redKey = confFluxMaccHash(idxMacchina); + try + { + DataLayer man = new DataLayer(); + rawData = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + var redisResult = JsonConvert.DeserializeObject>(rawData); + resultList = redisResult != null ? redisResult : new List(); + } + else + { + resultList = man.taConfFlux + .GetData() + .Where(x => x.IdxMacchina == idxMacchina) + .Select(x => x.CodFlux) + .ToList(); + // salvo in redis... + rawData = JsonConvert.SerializeObject(resultList); + int IO_CacheConfFluxMin = memLayer.ML.CRI("IO_CacheConfFluxMin"); + memLayer.ML.setRSV(redKey, rawData, IO_CacheConfFluxMin * 60); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero confFluxMach{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + resultList = taConfFlux + .GetData() + .Where(x => x.IdxMacchina == idxMacchina) + .Select(x => x.CodFlux) + .ToList(); + } + if (resultList == null) + { + resultList = new List(); + } + return resultList; + } + /// /// Restituisce il valore dell'ODL corrente (ODL deve esserci per gestione contapezzi, senza /// ODL NO invio/gestione ODL) @@ -1339,48 +1393,6 @@ namespace MapoDb return answTab; } - /// - /// Restituisce il valore dell'intera RIGA PODL data chiave (da redis o da DB se non trovata...) - /// - /// IDX della PODL - /// - public DS_ProdTempi.PromesseODLDataTable getPODLRowTab(int idxPODL) - { - DS_ProdTempi.PromesseODLDataTable answTab = null; - string rCall = ""; - string rKey = getPOdlRowHash(idxPODL); - if (memLayer.ML.CRB("IOB_RedEnab")) - { - saveCallRec("hasPODL_row"); - try - { - rCall = memLayer.ML.getRSV(rKey); - if (!string.IsNullOrEmpty(rCall)) - { - answTab = JsonConvert.DeserializeObject(rCall); - } - if (answTab == null || answTab.Count == 0) - { - answTab = taPODL.getByKey(idxPODL); - - // salvo in redis... - rCall = JsonConvert.SerializeObject(answTab); - int currOdlRowCacheDur = memLayer.ML.CRI("currOdlRowCacheDur"); - memLayer.ML.setRSV(rKey, rCall, currOdlRowCacheDur); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in recupero getPODLRowTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - } - else - { - answTab = taPODL.getByKey(idxPODL); - } - return answTab; - } - /// /// Restituisce il valore dell'intera RIGA stato macchina corrente (da redis o da DB se non trovata...) /// @@ -1405,7 +1417,7 @@ namespace MapoDb // 2020.01.31 uso nuovo oggetto connessione MapoDb man = new MapoDb(); answTab = man.currStatoMaccTab(idxMacchina); - //answTab = MapoDbObj.currStatoMaccTab(idxMacchina); + //resultList = MapoDbObj.currStatoMaccTab(idxMacchina); // salvo in redis... rCall = JsonConvert.SerializeObject(answTab); int currStatoMaccCacheDur = memLayer.ML.CRI("currStatoMaccCacheDur"); @@ -1424,6 +1436,74 @@ namespace MapoDb return answTab; } + /// + /// Restituisce l'elenco delle date dei dossier x una macchina (se presenti) Impiegata anche + /// cache redis + /// + /// + /// + public List dossierLastByMach(string idxMacchina) + { + List resultList = new List(); + string rawData = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("dossierLastByMach"); + string redKey = dossLastMaccHash(idxMacchina); + try + { + DataLayer man = new DataLayer(); + rawData = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + var redisResult = JsonConvert.DeserializeObject>(rawData); + resultList = redisResult != null ? redisResult : new List(); + } + else + { + resultList = man.taDOSS + .getLastByMacc(idxMacchina) + .Select(x => x.DtRif) + .ToList(); + // salvo in redis... + rawData = JsonConvert.SerializeObject(resultList); + int IO_CacheDossLastMin = memLayer.ML.CRI("IO_CacheDossLastMin"); + memLayer.ML.setRSV(redKey, rawData, IO_CacheDossLastMin * 60); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero dossierLastByMach{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + resultList = taDOSS + .getLastByMacc(idxMacchina) + .Select(x => x.DtRif) + .ToList(); + } + if (resultList == null) + { + resultList = new List(); + } + return resultList; + } + + /// + /// Svuota la cache redis x l'elenco delle righe di confFlux x una macchina (se presenti) + /// + /// + /// + public bool dossierLastByMachReset(string idxMacchina) + { + bool answ = false; + string rawData = ""; + string redKey = dossLastMaccHash(idxMacchina); + memLayer.ML.setRSV(redKey, rawData, 1); + return answ; + } + /// /// Rimuove Key dell'ODL corrente x una data macchina IOB /// @@ -1525,15 +1605,69 @@ namespace MapoDb return fatto; } - /// Effettua force Start PODL - /// [CurrProdStatus = 1] se fosse già in essere ODL collegato --> lascia aperto - /// [CurrProdStatus = 2] se esistesse un ODL da altro PODL x diverso articolo/fase --> chiude vecchio x poi far partire nuovo - /// [CurrProdStatus = 3] se fosse chiuso ODL collegato --> duplica PODL e poi avvia nuovo ODL - /// [CurrProdStatus = 4] se fosse già in essere ODL non collegato --> lascia aperto e collego + /// + /// Restituisce l'elenco delle data-ora di confFlux x una macchina (se presenti) Impiegata + /// anche cache redis /// - /// macchina IDX PODL da - /// processare effettuare conferma qty STEP x cui - /// arrotondare la quantità prox ODL (corrente come riferimento) + /// + /// num record da recuperare + /// + public List fluxLogFirstByMach(string idxMacchina, int numMax = 10) + { + List resultList = new List(); + string rawData = ""; + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("fluxLogFirstByMach"); + string redKey = fluxLogFirstMaccHash(idxMacchina); + try + { + DataLayer man = new DataLayer(); + rawData = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + var redisResult = JsonConvert.DeserializeObject>(rawData); + resultList = redisResult != null ? redisResult : new List(); + } + else + { + resultList = man.taFL + .getFirstByMacc(idxMacchina, numMax) + .Select(x => x.dtEvento) + .ToList(); + // salvo in redis... + rawData = JsonConvert.SerializeObject(resultList); + int IO_CacheFluxLogFirstMin = memLayer.ML.CRI("IO_CacheFluxLogFirstMin"); + memLayer.ML.setRSV(redKey, rawData, IO_CacheFluxLogFirstMin * 60); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero fluxLogFirstByMach{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + resultList = taFL + .getFirstByMacc(idxMacchina, numMax) + .Select(x => x.dtEvento) + .ToList(); + } + if (resultList == null) + { + resultList = new List(); + } + return resultList; + } + + /// Effettua force Start PODL [CurrProdStatus = 1] se fosse già in essere ODL + /// collegato --> lascia aperto [CurrProdStatus = 2] se esistesse un ODL da altro PODL x + /// diverso articolo/fase --> chiude vecchio x poi far partire nuovo [CurrProdStatus = 3] se + /// fosse chiuso ODL collegato --> duplica PODL e poi avvia nuovo ODL [CurrProdStatus = 4] + /// se fosse già in essere ODL non collegato --> lascia aperto e collego macchina IDX PODL da processare + /// effettuare conferma qty STEP x cui arrotondare la + /// quantità prox ODL (corrente come riferimento) public string ForceStartPOdl(string idxMacchina, int idxPODL, bool doConfirm) { string answ = "KO"; @@ -1643,6 +1777,7 @@ namespace MapoDb // --> non tocco nulla PODL/ODL logger.lg.scriviLog($"Richiesto ForceStartPOdl, caso 1 | PODL {idxPODL} | ODL {sIdxODL} | nessun intervento", tipoLog.INFO); break; + case 2: // eventuale chiusura vecchio ODL if (currODLData.Count > 0) @@ -1656,6 +1791,7 @@ namespace MapoDb answ = saveOdlData(idxMacchina, currODLData, reqPODLData); break; + case 3: // eventuale chiusura vecchio ODL if (currODLData.Count > 0) @@ -1676,10 +1812,12 @@ namespace MapoDb answ = saveOdlData(idxMacchina, currODLData, reqPODLData); break; + case 4: // --> registro in PODL e non tocco ODL break; + default: break; } @@ -1699,121 +1837,6 @@ namespace MapoDb return answ; } - private string saveOdlData(string idxMacchina, DS_ProdTempi.ODLDataTable currODLData, DS_ProdTempi.PromesseODLDataTable reqPODLData) - { - string answ; - // recupera ODL macchina - var newOdl = currODL(idxMacchina, true); - // attendo 1000 msec - // registro fine ODL (idxTipoEv = 1) - int idxEvento = 1; - logger.lg.scriviLog($"Invio evento ODL-forced start per macchina {idxMacchina}, evento {idxEvento}, articolo {currODLData[0].CodArticolo}", tipoLog.INFO); - var resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-FORFCE-START"); - // invio eventi setup a macchina.... - string setArtVal = $"{currODLData[0].CodArticolo}"; - string setPzCommVal = $"{reqPODLData[0].NumPezzi}"; - string setCommVal = $"ODL{newOdl}"; - if (!string.IsNullOrEmpty(reqPODLData[0].KeyRichiesta)) - { - setCommVal = $"{reqPODLData[0].KeyRichiesta} ODL{newOdl}"; - } - try - { - // invio task caricamento dati ODL - addTask4Machine(idxMacchina, taskType.setArt, setArtVal); - addTask4Machine(idxMacchina, taskType.setComm, setCommVal); - addTask4Machine(idxMacchina, taskType.setPzComm, setPzCommVal); - updateMachineParameter(idxMacchina, "setArt", setArtVal); - updateMachineParameter(idxMacchina, "setComm", setCommVal); - updateMachineParameter(idxMacchina, "setPzComm", setPzCommVal); - } - catch - { } - // 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); - // se è una master richiamo fix x child... - if (isMaster(idxMacchina)) - { - string ts = ""; - string outData = ""; - taODL.fixMachineSlave(idxMacchina, 30, 1); - // ciclo su ogni slave la gestione reinvio pezzi -->calcolo gli slave... - var slaveList = taM2S.getByMaster(idxMacchina); - foreach (var machine in slaveList) - { - // invio chiusura attrezzaggio - ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now); - outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{newOdl}"; - addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData); - - // invio task caricamento dati ODL - addTask4Machine(machine.IdxMacchinaSlave, taskType.setArt, setArtVal); - addTask4Machine(machine.IdxMacchinaSlave, taskType.setComm, setCommVal); - addTask4Machine(machine.IdxMacchinaSlave, taskType.setPzComm, setPzCommVal); - - updateMachineParameter(machine.IdxMacchinaSlave, "setArt", setArtVal); - updateMachineParameter(machine.IdxMacchinaSlave, "setComm", setCommVal); - updateMachineParameter(machine.IdxMacchinaSlave, "setPzComm", setPzCommVal); - } - } - - return answ; - } - - private bool doCloseCurrODL(string idxMacchina, bool doConfirm, int qtyConf, DS_ProdTempi.ODLDataTable currODLData, DateTime adesso) - { - bool fatto = false; - // registro un evento di inizio attrezzaggio (idxTipoEv = 2) - int idxEvento = 2; - logger.lg.scriviLog($"Invio evento CHIUSURA ODL per macchina {idxMacchina}, evento {idxEvento}, articolo {currODLData[0].CodArticolo}, qty confermata {qtyConf}", tipoLog.INFO); - - // chiudo ALTRO ODL - inputComandoMapo resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-CLOSE", 0, "", adesso, adesso); - if (doConfirm) - { - // attendo 100 msec - Thread.Sleep(100); - adesso = DateTime.Now; - // chiamo conferma produzione... - try - { - string chiamata = confRett ? "confermaProdMacchinaFull" : "confermaProdMacchina"; - logger.lg.scriviLog($"Chiamata a {chiamata} con parametri {currODLData[0].IdxMacchina} |{MatrOpr} | {DateTime.Now.AddDays(-10)} | {DateTime.Now} | {qtyConf} | 0 | 1 | {DateTime.Now} | false", tipoLog.INFO); - string idxMacchinaSel = currODLData[0].IdxMacchina; - if (confRett) - { - // confermo al netto dei pezzi lasciati... - fatto = confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, 0, adesso); - } - else - { - fatto = confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, adesso); - } - if (!fatto) - { - logger.lg.scriviLog($"ERRORE in chiamata {chiamata}", tipoLog.ERROR); - } - } - catch (Exception exc) - { - logger.lg.scriviLog($"Eccezione in ConfermaProduzione{Environment.NewLine}{exc}", tipoLog.EXCEPTION); - } - } - // attendo 100 msec - Thread.Sleep(100); - // chiamo chiusura - MapoDbObj.taODL.forceClose(currODLData[0].IdxODL, idxMacchina); - // elimino eventuale ODL precedente... - string rKey = memLayer.ML.redHash($"ODL:{idxMacchina}"); - memLayer.ML.setRSV(rKey, ""); - fatto = true; - return fatto; - } - /// /// GET elenco parametri correnti x IOB /// @@ -1978,6 +2001,48 @@ namespace MapoDb return answ; } + /// + /// Restituisce il valore dell'intera RIGA PODL data chiave (da redis o da DB se non trovata...) + /// + /// IDX della PODL + /// + public DS_ProdTempi.PromesseODLDataTable getPODLRowTab(int idxPODL) + { + DS_ProdTempi.PromesseODLDataTable answTab = null; + string rCall = ""; + string rKey = getPOdlRowHash(idxPODL); + if (memLayer.ML.CRB("IOB_RedEnab")) + { + saveCallRec("hasPODL_row"); + try + { + rCall = memLayer.ML.getRSV(rKey); + if (!string.IsNullOrEmpty(rCall)) + { + answTab = JsonConvert.DeserializeObject(rCall); + } + if (answTab == null || answTab.Count == 0) + { + answTab = taPODL.getByKey(idxPODL); + + // salvo in redis... + rCall = JsonConvert.SerializeObject(answTab); + int currOdlRowCacheDur = memLayer.ML.CRI("currOdlRowCacheDur"); + memLayer.ML.setRSV(rKey, rCall, currOdlRowCacheDur); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in recupero getPODLRowTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + answTab = taPODL.getByKey(idxPODL); + } + return answTab; + } + /// /// restituisce il TempoCiclo effettivo (tecnico) della macchina /// @@ -4024,6 +4089,7 @@ namespace MapoDb taArcaGiac = new DS_ArcaTableAdapters.GiacenzeTableAdapter(); taCalFF = new DS_ProdTempiTableAdapters.CalendFesteFerieTableAdapter(); taComm = new DS_UtilityTableAdapters.CommentiTableAdapter(); + taConfFlux = new DS_DossParTableAdapters.ConfFluxTableAdapter(); taDatiConf = new DS_ProdTempiTableAdapters.DatiConfermatiTableAdapter(); taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter(); taDatiProd = new DS_ProdTempiTableAdapters.DatiProduzioneTableAdapter(); @@ -4096,6 +4162,7 @@ namespace MapoDb taArcaGiac.Connection.ConnectionString = connectionStringArca; taCalFF.Connection.ConnectionString = connectionString; taComm.Connection.ConnectionString = connectionString; + taConfFlux.Connection.ConnectionString = connectionString; taDatiConf.Connection.ConnectionString = connectionString; taDatiMacchine.Connection.ConnectionString = connectionString; taDatiProd.Connection.ConnectionString = connectionString; @@ -4149,6 +4216,44 @@ namespace MapoDb #endregion Protected Methods + #region Private Fields + + /// + /// Connessione lazy a redis... + /// + private Lazy lazyConnection = new Lazy(() => + { + string RedisConn = memLayer.ML.confReadString("RedisConnSPEC"); + if (string.IsNullOrEmpty(RedisConn)) + { + RedisConn = memLayer.ML.confReadString("RedisConn"); + } + if (string.IsNullOrEmpty(RedisConn)) + { + RedisConn = "localhost,abortConnect=false,ssl=false"; + } + return ConnectionMultiplexer.Connect(RedisConn); + }); + + /// + /// Connessione lazy a redis... + /// + private Lazy lazyConnectionAdmin = new Lazy(() => + { + string RedisConnAdmin = memLayer.ML.confReadString("RedisConnSPECAdmin"); + if (string.IsNullOrEmpty(RedisConnAdmin)) + { + RedisConnAdmin = memLayer.ML.confReadString("RedisConnAdmin"); + } + if (string.IsNullOrEmpty(RedisConnAdmin)) + { + RedisConnAdmin = "localhost,abortConnect=false,ssl=false,allowAdmin=true"; + } + return ConnectionMultiplexer.Connect(RedisConnAdmin); + }); + + #endregion Private Fields + #region Private Methods private static T ConvertDataRowToGenericType(DataRow row) where T : class, new() @@ -4282,6 +4387,56 @@ namespace MapoDb } } + private bool doCloseCurrODL(string idxMacchina, bool doConfirm, int qtyConf, DS_ProdTempi.ODLDataTable currODLData, DateTime adesso) + { + bool fatto = false; + // registro un evento di inizio attrezzaggio (idxTipoEv = 2) + int idxEvento = 2; + logger.lg.scriviLog($"Invio evento CHIUSURA ODL per macchina {idxMacchina}, evento {idxEvento}, articolo {currODLData[0].CodArticolo}, qty confermata {qtyConf}", tipoLog.INFO); + + // chiudo ALTRO ODL + inputComandoMapo resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-CLOSE", 0, "", adesso, adesso); + if (doConfirm) + { + // attendo 100 msec + Thread.Sleep(100); + adesso = DateTime.Now; + // chiamo conferma produzione... + try + { + string chiamata = confRett ? "confermaProdMacchinaFull" : "confermaProdMacchina"; + logger.lg.scriviLog($"Chiamata a {chiamata} con parametri {currODLData[0].IdxMacchina} |{MatrOpr} | {DateTime.Now.AddDays(-10)} | {DateTime.Now} | {qtyConf} | 0 | 1 | {DateTime.Now} | false", tipoLog.INFO); + string idxMacchinaSel = currODLData[0].IdxMacchina; + if (confRett) + { + // confermo al netto dei pezzi lasciati... + fatto = confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, 0, adesso); + } + else + { + fatto = confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, adesso); + } + if (!fatto) + { + logger.lg.scriviLog($"ERRORE in chiamata {chiamata}", tipoLog.ERROR); + } + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione in ConfermaProduzione{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + // attendo 100 msec + Thread.Sleep(100); + // chiamo chiusura + MapoDbObj.taODL.forceClose(currODLData[0].IdxODL, idxMacchina); + // elimino eventuale ODL precedente... + string rKey = memLayer.ML.redHash($"ODL:{idxMacchina}"); + memLayer.ML.setRSV(rKey, ""); + fatto = true; + return fatto; + } + /// /// sistemazione timeout comandi nei tableadapter /// @@ -4380,6 +4535,70 @@ namespace MapoDb return newVal; } + private string saveOdlData(string idxMacchina, DS_ProdTempi.ODLDataTable currODLData, DS_ProdTempi.PromesseODLDataTable reqPODLData) + { + string answ; + // recupera ODL macchina + var newOdl = currODL(idxMacchina, true); + // attendo 1000 msec registro fine ODL (idxTipoEv = 1) + int idxEvento = 1; + logger.lg.scriviLog($"Invio evento ODL-forced start per macchina {idxMacchina}, evento {idxEvento}, articolo {currODLData[0].CodArticolo}", tipoLog.INFO); + var resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-FORFCE-START"); + // invio eventi setup a macchina.... + string setArtVal = $"{currODLData[0].CodArticolo}"; + string setPzCommVal = $"{reqPODLData[0].NumPezzi}"; + string setCommVal = $"ODL{newOdl}"; + if (!string.IsNullOrEmpty(reqPODLData[0].KeyRichiesta)) + { + setCommVal = $"{reqPODLData[0].KeyRichiesta} ODL{newOdl}"; + } + try + { + // invio task caricamento dati ODL + addTask4Machine(idxMacchina, taskType.setArt, setArtVal); + addTask4Machine(idxMacchina, taskType.setComm, setCommVal); + addTask4Machine(idxMacchina, taskType.setPzComm, setPzCommVal); + updateMachineParameter(idxMacchina, "setArt", setArtVal); + updateMachineParameter(idxMacchina, "setComm", setCommVal); + updateMachineParameter(idxMacchina, "setPzComm", setPzCommVal); + } + catch + { } + // 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); + // se è una master richiamo fix x child... + if (isMaster(idxMacchina)) + { + string ts = ""; + string outData = ""; + taODL.fixMachineSlave(idxMacchina, 30, 1); + // ciclo su ogni slave la gestione reinvio pezzi -->calcolo gli slave... + var slaveList = taM2S.getByMaster(idxMacchina); + foreach (var machine in slaveList) + { + // invio chiusura attrezzaggio + ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now); + outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{newOdl}"; + addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData); + + // invio task caricamento dati ODL + addTask4Machine(machine.IdxMacchinaSlave, taskType.setArt, setArtVal); + addTask4Machine(machine.IdxMacchinaSlave, taskType.setComm, setCommVal); + addTask4Machine(machine.IdxMacchinaSlave, taskType.setPzComm, setPzCommVal); + + updateMachineParameter(machine.IdxMacchinaSlave, "setArt", setArtVal); + updateMachineParameter(machine.IdxMacchinaSlave, "setComm", setCommVal); + updateMachineParameter(machine.IdxMacchinaSlave, "setPzComm", setPzCommVal); + } + } + + return answ; + } + private void SetAllCommandTimeouts(object adapter, int timeout) { var commands = adapter.GetType().InvokeMember(