diff --git a/Common/Common.sln.DotSettings.user b/Common/Common.sln.DotSettings.user index f04ddf61..525053d6 100644 --- a/Common/Common.sln.DotSettings.user +++ b/Common/Common.sln.DotSettings.user @@ -30,6 +30,7 @@ True NewVersion True + C:\Users\Thomas Müller\AppData\Local\Temp\JetBrains\ReSharperPlatformVs17\vAny_ab6433f6\CoverageData\_Common.-1885154465\Snapshot\snapshot.utdcvr True diff --git a/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs b/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs index 5e25bb8b..6bdf24f1 100644 --- a/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs +++ b/Common/Hardware/WaterMeter/Genesis/GenesisCore/RegisterRestorer.cs @@ -1060,8 +1060,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore continue; //TODO THW check if error should be signalized } - // ATTENTION: Take the size of the read back value as this will be filled up to a chunk of 4 - // bytes and therefore the required write value may have a smaller byte list! + // ATTENTION: The size of the writtenValue and readBackValue may deviate! var dataSize = writtenValue.Length; var strRequiredRegisterValue = ""; diff --git a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs index d3f53451..70c8d404 100644 --- a/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs +++ b/Common/Production/ProductionUiCordonel/ProductionProcesses/EolProcesses/CheckRadio.cs @@ -1,12 +1,13 @@ -using System; +using LaaPackages.Features.Cordonel.Models; +using Newtonsoft.Json.Linq; +using SIRTCOM; +using System; using System.Configuration; using System.Linq; using System.Net; using System.Threading; using System.Windows.Threading; -using LaaPackages.Features.Cordonel.Models; -using Newtonsoft.Json.Linq; -using SIRTCOM; +using System.Xml.Linq; using Xylem.Common.CommonCore.Configuration; using Xylem.Common.CommonCore.Consts; using Xylem.Common.Hardware.WaterMeter.Genesis.Registers; @@ -15,6 +16,7 @@ using Xylem.Common.Logic.SoftwareAccessHelper; using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum; using Xylem.Common.Production.ProductionUiCordonel.Properties; using Xylem.Common.Production.ProductionUiCordonel.UserControls; +using Xylem.Common.Utils.Logging; using Button = System.Windows.Controls.Button; // ReSharper disable UnusedAutoPropertyAccessor.Local @@ -652,6 +654,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr /// /// - Optimized based on new documentations. /// + /// + /// - Logging path changed. + /// private void SendPamListenSemi(Int32 radioAddress, Int32 byteComPort, String strKey) { if (_dataContainer == null || _stateMachine == null) @@ -665,9 +670,27 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr _dataContainer.RadioAdress = radioAddress; _stateMachine.initialise((Byte)byteComPort); - var date = DateTime.Now.Date; - var loggingPath = $"C:\\GenesisLog\\{date:yyyy-MM-dd}\\ProductionUiCordonel\\{Meter.PcbId}_RadioCheck.log"; - _stateMachine.StartLoggin(loggingPath); + + try + { + var path = NLogHelper.GetApplicationDataPath(); + if (string.IsNullOrEmpty(path)) + { + path = NLogHelper.GetCurrentApplicationFolder(); + } + + var a = XElement.Load(path); + var baseLoggingPath = a.Elements().First(s => s.Name.LocalName == "variable").Attributes() + .First(s => s.Value == "BasePath").NextAttribute.Value; + + var loggingPath = + $"{baseLoggingPath}\\{DateTime.Now:yyyy-MM-dd}\\ProductionUiCordonel\\{Meter.PcbId}_RadioCheck.log"; + _stateMachine.StartLoggin(loggingPath); + } + catch (Exception) + { + // ignore + } LogNewStatusMsg($"{Resources.StrRadioMsgSendPam}: {radioAddress.ToString()}"); diff --git a/Common/Production/ProductionUiCordonel/ProductionUiCordonel.csproj b/Common/Production/ProductionUiCordonel/ProductionUiCordonel.csproj index 03219dad..2bfd1c05 100644 --- a/Common/Production/ProductionUiCordonel/ProductionUiCordonel.csproj +++ b/Common/Production/ProductionUiCordonel/ProductionUiCordonel.csproj @@ -259,6 +259,7 @@ 4.0 + diff --git a/Common/Production/ProductionUiCordonel/ProductionWindow.xaml.cs b/Common/Production/ProductionUiCordonel/ProductionWindow.xaml.cs index 493733e2..d6542568 100644 --- a/Common/Production/ProductionUiCordonel/ProductionWindow.xaml.cs +++ b/Common/Production/ProductionUiCordonel/ProductionWindow.xaml.cs @@ -13,6 +13,7 @@ using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Media; using System.Windows.Threading; +using System.Xml.Linq; using LaaPackages.Features.Cordonel.Models; using Newtonsoft.Json; using NLog; @@ -59,7 +60,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel private String _lastLoggingTextToAvoidRepetition; private CordonelRequirements _productionRequirements; private UserAccessWindow _userAccessWindow; - private IProcessStateDef _processStateDef; + private readonly IProcessStateDef _processStateDef; #endregion @@ -835,6 +836,9 @@ namespace Xylem.Common.Production.ProductionUiCordonel /// /// - Reduced printout. /// + /// + /// - Base logging path taken from NLogHelper as log-path setting made in GTB. + /// private void CreateFile(String headerInfo, Boolean shortReport = false, Boolean printReport = false) { var sb = new StringBuilder(); @@ -853,50 +857,64 @@ namespace Xylem.Common.Production.ProductionUiCordonel sb.AppendLine($"{Properties.Resources.StrLblOperatorNameText}: {Software.UserName}"); sb.AppendLine("------------------------------------------------------------------------"); - //TODO THW take the log path from setup (done with GTB) - var loggingPath = $"C:\\GenesisLog\\{DateTime.Now:yyyy-MM-dd}\\ProductionUiCordonel\\"; - var fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}_ExtendedReport_{genesisMeter.PcbId}.txt"; - - // Copy the header to the compressed string builder - var compressedSb = new StringBuilder(); - if (shortReport) + try { - compressedSb.Append(sb); + var path = NLogHelper.GetApplicationDataPath(); + if (string.IsNullOrEmpty(path)) + { + path = NLogHelper.GetCurrentApplicationFolder(); + } + var a = XElement.Load(path); + var baseLoggingPath = a.Elements().First(s => s.Name.LocalName == "variable").Attributes().First(s => s.Value == "BasePath").NextAttribute.Value; + + var loggingPath = $"{baseLoggingPath}\\{DateTime.Now:yyyy-MM-dd}\\ProductionUiCordonel\\"; + var fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}_ExtendedReport_{genesisMeter.PcbId}.txt"; + + // Copy the header to the compressed string builder + var compressedSb = new StringBuilder(); + if (shortReport) + { + compressedSb.Append(sb); + } + + var rtbText = new TextRange( + rtbLog.Document.ContentStart, + rtbLog.Document.ContentEnd + ); + sb.Append($"{rtbText.Text}"); + // Write the complete report to the file + File.WriteAllText(fileName, sb.ToString()); + + // Reduce sb content to compress it for printout + if (shortReport) + { + fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}" + + $"_ShortReport_{genesisMeter.PcbId}.txt"; + var sr = new StringReader(rtbText.Text); + var srLine = sr.ReadLine(); + while (srLine != null) + { + if (srLine.Contains(Properties.Resources.StrProcessStateError) || + srLine.Contains(Properties.Resources.StrProcessStateDone) || + srLine.Contains(Properties.Resources.StrProcessStateWarning) || + srLine.Contains(Properties.Resources.StrProcessStateSkipped) || + srLine.Contains(Properties.Resources.StrWarningMsgSpecialRequirementActive)) + compressedSb.AppendLine(srLine); + srLine = sr.ReadLine(); + } + + // Returns the compressed file for error report printout + File.WriteAllText(fileName, compressedSb.ToString()); + if (printReport) + { + Process.Start(fileName); + } + } + } - - var rtbText = new TextRange( - rtbLog.Document.ContentStart, - rtbLog.Document.ContentEnd - ); - sb.Append($"{rtbText.Text}"); - // Write the complete report to the file - File.WriteAllText(fileName, sb.ToString()); - - // Reduce sb content to compress it for printout - if (shortReport) + catch (Exception e) { - - fileName = $"{loggingPath}{DateTime.Now.ToString("yyyyMMddHHmmss")}" + - $"_ShortReport_{genesisMeter.PcbId}.txt"; - var sr = new StringReader(rtbText.Text); - var srLine = sr.ReadLine(); - while (srLine != null) - { - if (srLine.Contains(Properties.Resources.StrProcessStateError) || - srLine.Contains(Properties.Resources.StrProcessStateDone) || - srLine.Contains(Properties.Resources.StrProcessStateWarning) || - srLine.Contains(Properties.Resources.StrProcessStateSkipped) || - srLine.Contains(Properties.Resources.StrWarningMsgSpecialRequirementActive)) - compressedSb.AppendLine(srLine); - srLine = sr.ReadLine(); - } - - // Returns the compressed file for error report printout - File.WriteAllText(fileName, compressedSb.ToString()); - if (printReport) - { - Process.Start(fileName); - } + Console.WriteLine(e.Message); } } @@ -962,7 +980,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel } catch (Exception exception) { - Console.WriteLine(exception); + Console.WriteLine(exception.Message); } }