diff --git a/IOB-MAN/App.config b/IOB-MAN/App.config index ba05e8ed..f813a921 100644 --- a/IOB-MAN/App.config +++ b/IOB-MAN/App.config @@ -13,6 +13,7 @@ + diff --git a/IOB-MAN/IOB-MAN.csproj b/IOB-MAN/IOB-MAN.csproj index fdb08748..b4159d6f 100644 --- a/IOB-MAN/IOB-MAN.csproj +++ b/IOB-MAN/IOB-MAN.csproj @@ -243,6 +243,10 @@ Settings.settings True + + + Always + PreserveNewest diff --git a/IOB-MAN/IOBManPanel.Designer.cs b/IOB-MAN/IOBManPanel.Designer.cs index 9e515e87..8231d3d8 100644 --- a/IOB-MAN/IOBManPanel.Designer.cs +++ b/IOB-MAN/IOBManPanel.Designer.cs @@ -57,6 +57,8 @@ this.dgvManagedItems = new System.Windows.Forms.DataGridView(); this.UI_Timer = new System.Windows.Forms.Timer(this.components); this.forceCheckTimer = new System.Windows.Forms.Timer(this.components); + this.cbLogLevelMin = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); this.panel1.SuspendLayout(); this.menuStrip1.SuspendLayout(); @@ -70,8 +72,8 @@ this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnClose.BackColor = System.Drawing.SystemColors.WindowText; this.btnClose.ForeColor = System.Drawing.Color.Yellow; - this.btnClose.Location = new System.Drawing.Point(10, 129); - this.btnClose.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnClose.Location = new System.Drawing.Point(12, 165); + this.btnClose.Margin = new System.Windows.Forms.Padding(2); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(96, 26); this.btnClose.TabIndex = 70; @@ -92,7 +94,7 @@ this.lblVers, this.tsProgBar, this.tsslNumProc}); - this.statusStrip1.Location = new System.Drawing.Point(0, 413); + this.statusStrip1.Location = new System.Drawing.Point(0, 469); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 10, 0); this.statusStrip1.Size = new System.Drawing.Size(689, 22); @@ -128,7 +130,7 @@ this.panel1.Controls.Add(this.menuStrip1); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.panel1.Margin = new System.Windows.Forms.Padding(2); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(689, 31); this.panel1.TabIndex = 83; @@ -180,8 +182,8 @@ // this.btnMaximixeAll.BackColor = System.Drawing.SystemColors.Highlight; this.btnMaximixeAll.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.btnMaximixeAll.Location = new System.Drawing.Point(11, 57); - this.btnMaximixeAll.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnMaximixeAll.Location = new System.Drawing.Point(12, 95); + this.btnMaximixeAll.Margin = new System.Windows.Forms.Padding(2); this.btnMaximixeAll.Name = "btnMaximixeAll"; this.btnMaximixeAll.Size = new System.Drawing.Size(96, 26); this.btnMaximixeAll.TabIndex = 81; @@ -193,8 +195,8 @@ // this.btnMinimizeAll.BackColor = System.Drawing.SystemColors.Highlight; this.btnMinimizeAll.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.btnMinimizeAll.Location = new System.Drawing.Point(11, 87); - this.btnMinimizeAll.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnMinimizeAll.Location = new System.Drawing.Point(12, 125); + this.btnMinimizeAll.Margin = new System.Windows.Forms.Padding(2); this.btnMinimizeAll.Name = "btnMinimizeAll"; this.btnMinimizeAll.Size = new System.Drawing.Size(96, 26); this.btnMinimizeAll.TabIndex = 80; @@ -211,16 +213,18 @@ this.tableLayoutPanel1.Controls.Add(this.dgvManagedItems, 0, 0); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 31); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(2); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(689, 382); + this.tableLayoutPanel1.Size = new System.Drawing.Size(689, 438); this.tableLayoutPanel1.TabIndex = 85; // // panel2 // this.panel2.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.panel2.Controls.Add(this.label1); + this.panel2.Controls.Add(this.cbLogLevelMin); this.panel2.Controls.Add(this.btnStartSel); this.panel2.Controls.Add(this.btnMoreTOut); this.panel2.Controls.Add(this.txtTOutAutoCheck); @@ -233,9 +237,9 @@ this.panel2.Controls.Add(this.btnMaximixeAll); this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; this.panel2.Location = new System.Drawing.Point(571, 2); - this.panel2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.panel2.Margin = new System.Windows.Forms.Padding(2); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(116, 378); + this.panel2.Size = new System.Drawing.Size(116, 434); this.panel2.TabIndex = 85; // // btnStartSel @@ -243,8 +247,8 @@ this.btnStartSel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnStartSel.BackColor = System.Drawing.Color.Green; this.btnStartSel.ForeColor = System.Drawing.Color.Yellow; - this.btnStartSel.Location = new System.Drawing.Point(9, 159); - this.btnStartSel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnStartSel.Location = new System.Drawing.Point(11, 195); + this.btnStartSel.Margin = new System.Windows.Forms.Padding(2); this.btnStartSel.Name = "btnStartSel"; this.btnStartSel.Size = new System.Drawing.Size(96, 26); this.btnStartSel.TabIndex = 88; @@ -254,7 +258,7 @@ // // btnMoreTOut // - this.btnMoreTOut.Location = new System.Drawing.Point(81, 306); + this.btnMoreTOut.Location = new System.Drawing.Point(81, 326); this.btnMoreTOut.Name = "btnMoreTOut"; this.btnMoreTOut.Size = new System.Drawing.Size(25, 23); this.btnMoreTOut.TabIndex = 87; @@ -265,7 +269,7 @@ // // txtTOutAutoCheck // - this.txtTOutAutoCheck.Location = new System.Drawing.Point(11, 306); + this.txtTOutAutoCheck.Location = new System.Drawing.Point(11, 326); this.txtTOutAutoCheck.Name = "txtTOutAutoCheck"; this.txtTOutAutoCheck.Size = new System.Drawing.Size(64, 20); this.txtTOutAutoCheck.TabIndex = 86; @@ -277,7 +281,7 @@ this.chkAutoRestart.AutoSize = true; this.chkAutoRestart.Checked = true; this.chkAutoRestart.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkAutoRestart.Location = new System.Drawing.Point(11, 275); + this.chkAutoRestart.Location = new System.Drawing.Point(11, 295); this.chkAutoRestart.Name = "chkAutoRestart"; this.chkAutoRestart.Size = new System.Drawing.Size(85, 17); this.chkAutoRestart.TabIndex = 85; @@ -290,8 +294,8 @@ this.btnOpenAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnOpenAll.BackColor = System.Drawing.SystemColors.ButtonFace; this.btnOpenAll.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; - this.btnOpenAll.Location = new System.Drawing.Point(10, 12); - this.btnOpenAll.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnOpenAll.Location = new System.Drawing.Point(11, 50); + this.btnOpenAll.Margin = new System.Windows.Forms.Padding(2); this.btnOpenAll.Name = "btnOpenAll"; this.btnOpenAll.Size = new System.Drawing.Size(96, 26); this.btnOpenAll.TabIndex = 84; @@ -303,8 +307,8 @@ // this.btnRestartAll.BackColor = System.Drawing.SystemColors.ControlDarkDark; this.btnRestartAll.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.btnRestartAll.Location = new System.Drawing.Point(11, 244); - this.btnRestartAll.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnRestartAll.Location = new System.Drawing.Point(11, 264); + this.btnRestartAll.Margin = new System.Windows.Forms.Padding(2); this.btnRestartAll.Name = "btnRestartAll"; this.btnRestartAll.Size = new System.Drawing.Size(96, 26); this.btnRestartAll.TabIndex = 83; @@ -316,8 +320,8 @@ // this.btnCloseAll.BackColor = System.Drawing.SystemColors.ControlDarkDark; this.btnCloseAll.ForeColor = System.Drawing.SystemColors.ControlLightLight; - this.btnCloseAll.Location = new System.Drawing.Point(11, 214); - this.btnCloseAll.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.btnCloseAll.Location = new System.Drawing.Point(11, 234); + this.btnCloseAll.Margin = new System.Windows.Forms.Padding(2); this.btnCloseAll.Name = "btnCloseAll"; this.btnCloseAll.Size = new System.Drawing.Size(96, 26); this.btnCloseAll.TabIndex = 82; @@ -338,7 +342,7 @@ this.dgvManagedItems.Name = "dgvManagedItems"; this.dgvManagedItems.ReadOnly = true; this.dgvManagedItems.RowHeadersWidth = 51; - this.dgvManagedItems.Size = new System.Drawing.Size(563, 376); + this.dgvManagedItems.Size = new System.Drawing.Size(563, 432); this.dgvManagedItems.TabIndex = 76; this.dgvManagedItems.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvManagedItems_CellDoubleClick); this.dgvManagedItems.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvManagedItems_CellFormatting); @@ -352,19 +356,43 @@ this.forceCheckTimer.Interval = 5000; this.forceCheckTimer.Tick += new System.EventHandler(this.forceCheckTimer_Tick); // + // cbLogLevelMin + // + this.cbLogLevelMin.FormattingEnabled = true; + this.cbLogLevelMin.Items.AddRange(new object[] { + "Warn", + "Info", + "Debug", + "Trace"}); + this.cbLogLevelMin.Location = new System.Drawing.Point(11, 18); + this.cbLogLevelMin.Name = "cbLogLevelMin"; + this.cbLogLevelMin.Size = new System.Drawing.Size(97, 21); + this.cbLogLevelMin.TabIndex = 89; + this.cbLogLevelMin.Text = "Info"; + this.cbLogLevelMin.SelectedIndexChanged += new System.EventHandler(this.cbLogLevelMin_SelectedIndexChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(11, 4); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(79, 13); + this.label1.TabIndex = 90; + this.label1.Text = "LOG level (min)"; + // // IOBManPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; - this.ClientSize = new System.Drawing.Size(689, 435); + this.ClientSize = new System.Drawing.Size(689, 491); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.panel1); this.Controls.Add(this.statusStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.IsMdiContainer = true; this.MainMenuStrip = this.menuStrip1; - this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "IOBManPanel"; this.Text = "IOB MANAGER"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.IOBManPanel_FormClosing); @@ -411,6 +439,8 @@ private System.Windows.Forms.Button btnStartSel; private System.Windows.Forms.Timer UI_Timer; private System.Windows.Forms.Timer forceCheckTimer; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox cbLogLevelMin; } } diff --git a/IOB-MAN/IOBManPanel.cs b/IOB-MAN/IOBManPanel.cs index 7b79bf47..4bfa5ebf 100644 --- a/IOB-MAN/IOBManPanel.cs +++ b/IOB-MAN/IOBManPanel.cs @@ -109,6 +109,11 @@ namespace IOB_MAN /// protected string TargetExe = ""; + /// + /// File target x conf NLog + /// + protected string TargetNLogConf = ""; + /// /// Name dell'exe da chiamare /// @@ -149,8 +154,14 @@ namespace IOB_MAN { InitializeComponent(); synchronizationContext = SynchronizationContext.Current; + preInit(); loadConfig(); + + // fix log... + cbLogLevelMin.SelectedValue = "Info"; + setLogLevel("Info"); + initTimers(); initControls(); updateStatus(); @@ -893,6 +904,7 @@ namespace IOB_MAN uiPeriod = utils.CRI("uiPeriod"); forceCheckPeriodMult = utils.CRI("forceCheckPeriodMult"); TargetExe = utils.CRS("targetExe"); + TargetNLogConf = utils.CRS("TargetNLogConf"); TargetName = utils.CRS("appNameExt"); if (string.IsNullOrEmpty(TargetExe)) { @@ -1226,5 +1238,26 @@ namespace IOB_MAN } #endregion Public Methods + + private void cbLogLevelMin_SelectedIndexChanged(object sender, EventArgs e) + { + // aggiornato livelo di log --> chiamo procedura x riscrivere il file conf di NLog + setLogLevel($"{cbLogLevelMin.SelectedItem}"); + } + + private void setLogLevel(string selectedValue) + { + // leggo il file loglevel in resources + string rawData = File.ReadAllText($@"{Application.StartupPath}\Resources\NLog.template.config"); + + // sostituzione livello mINIMO da selezione + rawData = rawData.Replace("{{minLevel}}", selectedValue); + + // scrivo conf x programma IOB-MAN + File.WriteAllText($@"{Application.StartupPath}\NLog.config", rawData); + + // scrivo conf x IOB-WIN gestiti + File.WriteAllText(TargetNLogConf, rawData); + } } } \ No newline at end of file diff --git a/IOB-MAN/NLog.config b/IOB-MAN/NLog.config index 7a0f3aa1..350bebf8 100644 --- a/IOB-MAN/NLog.config +++ b/IOB-MAN/NLog.config @@ -6,36 +6,34 @@ throwExceptions="false" internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"> - - - - - - - - - - - - - - - - + + + + + + + + + + diff --git a/IOB-MAN/Resources/NLog._demo.config b/IOB-MAN/Resources/NLog._demo.config new file mode 100644 index 00000000..b144b03e --- /dev/null +++ b/IOB-MAN/Resources/NLog._demo.config @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IOB-MAN/Resources/NLog.template.config b/IOB-MAN/Resources/NLog.template.config new file mode 100644 index 00000000..216df569 --- /dev/null +++ b/IOB-MAN/Resources/NLog.template.config @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + diff --git a/IOB-WIN-NEXT/IobOpcUa.cs b/IOB-WIN-NEXT/IobOpcUa.cs index 3a2d6da8..9fbd782b 100644 --- a/IOB-WIN-NEXT/IobOpcUa.cs +++ b/IOB-WIN-NEXT/IobOpcUa.cs @@ -759,7 +759,7 @@ namespace IOB_WIN_NEXT } else { - lgInfo("WatchDog disabilitato"); + lgDebug("WatchDog disabilitato"); } // log opzionale! @@ -1095,7 +1095,7 @@ namespace IOB_WIN_NEXT } else { - lgError("IMPOSSIBILE effettuare disconnessione OpcUa: UA_ref non disponibile..."); + lgDebug("IMPOSSIBILE effettuare disconnessione OpcUa: UA_ref non disponibile..."); } } else diff --git a/IOB-WIN-NEXT/IobOpcUaEwon.cs b/IOB-WIN-NEXT/IobOpcUaEwon.cs index ff91d289..a631161f 100644 --- a/IOB-WIN-NEXT/IobOpcUaEwon.cs +++ b/IOB-WIN-NEXT/IobOpcUaEwon.cs @@ -148,7 +148,7 @@ namespace IOB_WIN_NEXT } else { - lgInfo("WatchDog disabilitato"); + lgDebug("WatchDog disabilitato"); } // controllo se sono poweroff e se non ho dati buoni da > 2 minuti --> disconnetto