From d42ad8c5cfc5e3d838f39130a190b85e44eb78fc Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Wed, 12 Jan 2022 07:56:56 +0100 Subject: [PATCH] GenericTest and RecordProessing modifications for Laser in Nanjing, ver. 3.0.1 --- GenericTest/ActivityEventArgs.cs | 4 +- GenericTest/GenericTest.csproj | 9 +- GenericTest/GenericTestDlg.Designer.cs | 34 +-- GenericTest/GenericTestDlg.cs | 211 ++++++++---------- GenericTest/LocalSettings.cs | 14 +- GenericTest/Properties/AssemblyInfo.cs | 4 +- GenericTest/Resources/Strings.Designer.cs | 36 +++ GenericTest/Resources/Strings.resx | 12 + GenericTest/Resources/Strings.sk.resx | 12 + RecordProcessing/Properties/AssemblyInfo.cs | 4 +- RecordProcessing/RecordProcessing.cs | 4 +- RecordProcessing/RecordProcessing.csproj | 3 +- .../Records/LaserNanjingRecord.cs | 91 ++++++++ RecordProcessing/Records/RFTestRecord.cs | 3 - SharedDatabase/TracingDB.cs | 39 ++-- 15 files changed, 304 insertions(+), 176 deletions(-) create mode 100644 RecordProcessing/Records/LaserNanjingRecord.cs diff --git a/GenericTest/ActivityEventArgs.cs b/GenericTest/ActivityEventArgs.cs index dab34a7b2..d8f2569d9 100644 --- a/GenericTest/ActivityEventArgs.cs +++ b/GenericTest/ActivityEventArgs.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2022 Sensus Slovensko a.s. /// using System; using System.Drawing; @@ -11,7 +11,7 @@ namespace GenericTest Undefined = 0, /// Undefined (only used in OnActivity(..) when start/stop info message is issued) SNisMissing, /// S/N is missing in the parsed record SNisInvalid, /// S/N in the parsed record is invalid - NoRecordAtAll, /// No record with this S/N in tracing DB + NoRefRecordOrNoMatchingWorkflow, /// No record with this S/N in tracing DB or no matching workflow for this record VerificationIsDisabled, /// ... NoVerificationForThisProcess, VerificationPassed, /// Verification of a previous record passed diff --git a/GenericTest/GenericTest.csproj b/GenericTest/GenericTest.csproj index 37942f364..d1282e1b2 100644 --- a/GenericTest/GenericTest.csproj +++ b/GenericTest/GenericTest.csproj @@ -20,17 +20,22 @@ full false bin\Debug\ - TRACE;DEBUG;RF_TEST_400_900 + TRACE;DEBUG;LASER_NANJING prompt 4 + false pdbonly true bin\Release\ - TRACE;RF_TEST_400_900 + TRACE;LASER_NANJING prompt 4 + false + + + GenericTest.Program diff --git a/GenericTest/GenericTestDlg.Designer.cs b/GenericTest/GenericTestDlg.Designer.cs index e7092e92c..d08c1ee3f 100644 --- a/GenericTest/GenericTestDlg.Designer.cs +++ b/GenericTest/GenericTestDlg.Designer.cs @@ -35,12 +35,12 @@ this.vertSplitContainer = new System.Windows.Forms.SplitContainer(); this.resultsGroupBox = new System.Windows.Forms.GroupBox(); this.activityListView = new System.Windows.Forms.ListView(); + this.logoutButton = new System.Windows.Forms.Button(); this.startButton = new System.Windows.Forms.Button(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.filteredSensorValueLabel = new System.Windows.Forms.Label(); this.sensorNameLabel = new System.Windows.Forms.Label(); this.immediateSensorValueLabel = new System.Windows.Forms.Label(); - this.logoutButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.horizSplitContainer)).BeginInit(); this.horizSplitContainer.Panel1.SuspendLayout(); this.horizSplitContainer.Panel2.SuspendLayout(); @@ -63,7 +63,7 @@ this.settingsButton.Name = "settingsButton"; this.settingsButton.Size = new System.Drawing.Size(90, 30); this.settingsButton.TabIndex = 0; - this.settingsButton.Text = "Nastavenia"; + this.settingsButton.Text = "Settings"; this.settingsButton.UseVisualStyleBackColor = true; this.settingsButton.Click += new System.EventHandler(this.settingsButton_Click); // @@ -130,7 +130,7 @@ this.vertSplitContainer.Panel2.Controls.Add(this.startButton); this.vertSplitContainer.Panel2.Controls.Add(this.stopButton); this.vertSplitContainer.Size = new System.Drawing.Size(1033, 151); - this.vertSplitContainer.SplitterDistance = 939; + this.vertSplitContainer.SplitterDistance = 942; this.vertSplitContainer.SplitterWidth = 1; this.vertSplitContainer.TabIndex = 2; // @@ -140,7 +140,7 @@ this.resultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.resultsGroupBox.Location = new System.Drawing.Point(0, 0); this.resultsGroupBox.Name = "resultsGroupBox"; - this.resultsGroupBox.Size = new System.Drawing.Size(939, 151); + this.resultsGroupBox.Size = new System.Drawing.Size(942, 151); this.resultsGroupBox.TabIndex = 1; this.resultsGroupBox.TabStop = false; this.resultsGroupBox.Text = "Aktivita"; @@ -152,11 +152,22 @@ this.activityListView.Location = new System.Drawing.Point(3, 16); this.activityListView.Name = "activityListView"; this.activityListView.Scrollable = false; - this.activityListView.Size = new System.Drawing.Size(933, 132); + this.activityListView.Size = new System.Drawing.Size(936, 132); this.activityListView.TabIndex = 0; this.activityListView.UseCompatibleStateImageBehavior = false; this.activityListView.View = System.Windows.Forms.View.Details; // + // logoutButton + // + this.logoutButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.logoutButton.Location = new System.Drawing.Point(1, 116); + this.logoutButton.Name = "logoutButton"; + this.logoutButton.Size = new System.Drawing.Size(90, 30); + this.logoutButton.TabIndex = 13; + this.logoutButton.Text = "Logout"; + this.logoutButton.UseVisualStyleBackColor = true; + this.logoutButton.Click += new System.EventHandler(this.logoutButton_Click); + // // startButton // this.startButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); @@ -164,7 +175,7 @@ this.startButton.Name = "startButton"; this.startButton.Size = new System.Drawing.Size(90, 30); this.startButton.TabIndex = 1; - this.startButton.Text = "Štart"; + this.startButton.Text = "Start"; this.startButton.UseVisualStyleBackColor = true; this.startButton.Click += new System.EventHandler(this.startButton_Click); // @@ -221,17 +232,6 @@ this.immediateSensorValueLabel.TabIndex = 1; this.immediateSensorValueLabel.Text = "60.7 °C"; // - // logoutButton - // - this.logoutButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.logoutButton.Location = new System.Drawing.Point(1, 116); - this.logoutButton.Name = "logoutButton"; - this.logoutButton.Size = new System.Drawing.Size(90, 30); - this.logoutButton.TabIndex = 13; - this.logoutButton.Text = "Logout"; - this.logoutButton.UseVisualStyleBackColor = true; - this.logoutButton.Click += new System.EventHandler(this.logoutButton_Click); - // // GenericTestDlg // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/GenericTest/GenericTestDlg.cs b/GenericTest/GenericTestDlg.cs index ff30593bf..28fab8daa 100644 --- a/GenericTest/GenericTestDlg.cs +++ b/GenericTest/GenericTestDlg.cs @@ -1,11 +1,12 @@ /// -/// Copyright (c) 2019 Sensus Slovensko a.s. +/// Copyright (c) 2019-2022 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.IO.Ports; +using System.Linq; using System.Threading; using System.Windows.Forms; using log4net; @@ -33,46 +34,46 @@ namespace GenericTest #if RF_TEST public RecordProcessing.RecordType RcrdType = RecordType.RF_Test; - public const string WorkflowStep = "RF_Power"; + public const string WorkflowStep = "rf_power"; public const string DfltWorkplaceName = "RF Test"; #elif RF_TEST_400_900 public RecordProcessing.RecordType RcrdType = RecordType.RF_Test_400_900; - public const string WorkflowStep = "RF_Power"; + public const string WorkflowStep = "rf_power"; public const string DfltWorkplaceName = "RF Test"; #elif COMM_TEST public RecordProcessing.RecordType RcrdType = RecordType.CommTest; - public const string WorkflowStep = "Comm_Test"; + public const string WorkflowStep = "comm_test"; public const string DfltWorkplaceName = "Comm Test"; #elif FLOWTUBE_TEST_HE public RecordProcessing.RecordType RcrdType = RecordType.FlowtubeTestHe; - public const string WorkflowStep = "Helium_Test"; + public const string WorkflowStep = "helium_test"; public const string DfltWorkplaceName = "Helium Test"; #elif FLOWTUBE_TEST_AIR public RecordProcessing.RecordType RcrdType = RecordType.FlowtubeTestAir; - public const string WorkflowStep = "Helium_Test"; + public const string WorkflowStep = "helium_test"; public const string DfltWorkplaceName = "Helium Test"; +#elif LASER_NANJING + public RecordProcessing.RecordType RcrdType = RecordType.LaserNanjing; + public const string WorkflowStep = "laser"; + public const string DfltWorkplaceName = "Laser 1"; #else public RecordProcessing.RecordType RcrdType = RecordType.None; - public const string WorkflowStep = "Generic_Test"; + public const string WorkflowStep = "generic_test"; public const string DfltWorkplaceName = "Generic Test"; #endif const int ActivityMsgsCount = 7; - ActivityEventArgs[] activityEvents; /// Activity messages displayed in the main window + ActivityEventArgs[] activityEvents; /// Activity messages displayed in the main window - NHibernate.ISession dbSession; /// MySQL database session - static OracleConnection oracleConn; /// Oracle database connection (server is in Stara Tura) + NHibernate.ISession dbSession; /// MySQL database session + static OracleConnection oracleConn; /// Oracle database connection (server is in Stara Tura) #if RF_TEST_400_900 - static OracleConnection oracleConn2; /// Oracle database connection for Flexnet ID (server is in Ludwigshafen) + static OracleConnection oracleConn2; /// Oracle database connection for Flexnet ID (server is in Ludwigshafen) #endif - - IList processes; /// Processes from the database - Dictionary processDictionary; /// Maps a process Id to a process - Dictionary> workstepsDictionary; /// Maps a process Id to worksteps with name "RF_Power" (Count = 0 or 1) - static Dictionary verificationInfos; - /// Maps process Id to verification info - DateTime lastUpdateOfProcesses; + + IList workflowSummaries; /// Workflows from the database with last step verification information + DateTime lastUpdateOfWorkflows; RecordProcessing.RecordProcessing recordProcessing; @@ -94,13 +95,29 @@ namespace GenericTest /// public GenericTestDlg() { - /// Open a modeless form that is closed after initialization and loading the main window - new Thread(() => Application.Run(new Common.Forms.ModelessForm("Načítavanie procesov z databázy"))).Start(); - InitializeComponent(); + try + { + string culture = Program.LocalSettings.Language.Replace('_', '-'); + System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture); + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture); + } + catch (Exception exc) + { + string msg = exc.Message; + MessageBox.Show("Selected language is not supported.\nUsing English.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); + System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en"); + System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); + } + + Localize(); UpdateTitle(); + /// Open a modeless form that is closed after initialization and loading the main window + new Thread(() => Application.Run(new Common.Forms.ModelessForm("Loading workflows from a database"))).Start(); + + activityEvents = new ActivityEventArgs[ActivityMsgsCount]; activityListView.Columns.Add(Strings.Time, 60); #if FLOWTUBE_TEST_AIR || FLOWTUBE_TEST_HE @@ -123,6 +140,15 @@ namespace GenericTest ReadProcesses_RegisterWorkplace_Etc(); } + void Localize() + { + messageLabel.Text = string.IsNullOrEmpty(Program.LocalSettings.Workplace) ? "Laser" : Program.LocalSettings.Workplace; + startButton.Text = Strings.Start; + stopButton.Text = Strings.Stop; + settingsButton.Text = Strings.Settings; + logoutButton.Text = Strings.Logout; + } + private void GenericTestDlg_Load(object sender, EventArgs e) { Settings2UI(); @@ -569,8 +595,8 @@ namespace GenericTest try { dbSession = TracingDB.CreateSession(Program.LocalSettings.ConnectionString); - processes = TracingDB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos); - lastUpdateOfProcesses = DateTime.Now; + workflowSummaries = TracingDB.ReadWorkflowSummariesFromDB(dbSession, WorkflowStep); + lastUpdateOfWorkflows = DateTime.Now; } catch (Exception exc) { @@ -733,6 +759,13 @@ namespace GenericTest Program.LocalSettings.ArchiveFolder, true); break; + case RecordType.LaserNanjing: + recordProcessing = new RecordProcessing.RecordProcessing(RecordType.LaserNanjing, + RecordPostproc.Move, + Program.LocalSettings.TestResultsFolder, false, "*.csv", + Program.LocalSettings.ArchiveFolder, true); + break; + case RecordType.None: default: recordProcessing = null; @@ -798,7 +831,9 @@ namespace GenericTest } #endif - if (Program.LocalSettings.DoCheckSNsValidity && (Program.LocalSettings.ValidSNPrefixes != null) && !Program.LocalSettings.ValidSNPrefixes.Contains(testerRecord.SN.Substring(0, 3))) + if (Program.LocalSettings.DoCheckSNsValidity && + (Program.LocalSettings.ValidSNPrefixes != null) + && !Program.LocalSettings.ValidSNPrefixes.Contains(testerRecord.SN.Substring(0, 3))) { /// PCB number did not pass a validity check (is not on a list of valid PCB numbers) verifState = VerifState.SNisInvalid; @@ -810,9 +845,6 @@ namespace GenericTest /// A valid serial number is available => proceed /// ITransaction transaction = null; - string proc = null; - string order = null; - bool readingFromTracingDBFailed = false; /// Reading form tracing DB failed (equipment error) bool savingToTracingDBFailed = false; /// Writing to tracoing DB failed (equipment error) bool verificationFailed = false; /// Reading/writing from/to tracing DB OK, but verification failed (product error) @@ -824,110 +856,55 @@ namespace GenericTest transaction = dbSession.BeginTransaction(); /// Get a process of the last reference record with this PCB number - proc = TracingDB.GetWorkflow(dbSession, testerRecord.SN, 1, out order); + var refRecord = TracingDB.FindReferenceRecord(dbSession, testerRecord.SN, 1); + WorkflowSummary wSum = (refRecord == null) ? null : + workflowSummaries.FirstOrDefault(x => x.Workflow.Name == refRecord.Workflow); - /// Check if a record from the previous workplace exists - if (proc == null) + if (refRecord == null || wSum == null) { - /// Any previous reference record with this s/n is missing => process cannot be determined - verifState = VerifState.NoRecordAtAll; - } - else if (!Program.LocalSettings.DoCheckPreviousTracingRecords) - { - /// The process was determined but checking previous records is disbled => everything is OK so far - verifState = VerifState.VerificationIsDisabled; + verifState = VerifState.NoRefRecordOrNoMatchingWorkflow; + verificationFailed = true; + savingToTracingDBFailed = false; } else { - /// Process is known AND the system is checking previous records => verify previous step - - /// Get an appropriate verification info - ScanVerificationInfo verInfo; - bool verInfoObtained = verificationInfos.TryGetValue(proc.Id, out verInfo); - if (!verInfoObtained && (DateTime.Now - lastUpdateOfProcesses) > new TimeSpan(0, 5, 0)) + if (!Program.LocalSettings.DoCheckPreviousTracingRecords) { - /// No verification info was obtained and more then 5 minutes elapsed => read processes again - processes = TracingDB.ReadWorkflowsFromDB(dbSession, WorkflowStep, out processDictionary, out workstepsDictionary, out verificationInfos); - lastUpdateOfProcesses = DateTime.Now; - verInfoObtained = verificationInfos.TryGetValue(proc.Id, out verInfo); - } - - if (!verInfoObtained) - { - /// No verification info for the process obtained from the reference record found - verifState = VerifState.NoVerificationForThisProcess; + /// The process was determined but checking previous records is disbled => everything is OK so far + verifState = VerifState.VerificationIsDisabled; + verificationFailed = false; } else { - if (verInfo.VerifyReferencePart) - { - /// Fetch all GOOD reference records with given code - IList refRecords = dbSession.QueryOver() - .Where(rr => ((rr.Code1 == testerRecord.SN) && (rr.Result == 0))) - .And(rr => (rr.Workstep == verInfo.Workstep)) - .JoinQueryOver(rr => rr.Workstep) - .Where(ws => (ws.ReferencePart.Id == verInfo.Part.Id)) - .List(); + /// Process is known AND the system is checking previous records => verify previous step - verifState = (refRecords.Count > 0) ? VerifState.VerificationPassed : VerifState.VerificationFailed; - } - else - { - IList records = dbSession.QueryOver() - .Where(rec => (rec.Code == testerRecord.SN)) - .And(rec => (rec.Part == verInfo.Part)) - .List(); - - verifState = (records.Count > 0) ? VerifState.VerificationPassed : VerifState.VerificationFailed; - } + StepRecord prevStep = refRecord.StepRecords.FirstOrDefault(x => (x.Workstep == wSum.PreviousWorkstepName && x.Result == 0)); + verificationFailed = (prevStep == null); + verifState = (prevStep != null) ? VerifState.VerificationPassed : VerifState.VerificationFailed; } - } - verificationFailed = verifState == VerifState.NoRecordAtAll || - verifState == VerifState.NoVerificationForThisProcess || - verifState == VerifState.VerificationFailed; - /// - savingToTracingDBFailed = true; - if ((proc != null) && (verifState != VerifState.NoRecordAtAll)) - { - IList worksteps; - if (workstepsDictionary.TryGetValue(proc.Id, out worksteps) && (worksteps.Count == 1)) - { - /// Save a new reference record to the production tracing DB - dbSession.SaveOrUpdate(new ReferenceRecord(order, proc, worksteps[0], testerRecord.SN, - GlobalData.GetCurrentUserName(), - Program.LocalSettings.Workplace, - verificationFailed ? 2 : ((testerRecord.Status == Status.Passed) ? 0 : 1))); - } - else - { - /// Save a reference record with WORKSTEP=null to the production tracing DB - dbSession.SaveOrUpdate(new ReferenceRecord(order, proc, null, testerRecord.SN, - GlobalData.GetCurrentUserName(), - Program.LocalSettings.Workplace, - verificationFailed ? 2 : ((testerRecord.Status == Status.Passed) ? 0 : 1))); - } - } - else - { - /// Save a reference record with PORDER=null, PROCESS=null and WORKSTEP=null to the production tracing DB - savingToTracingDBFailed = true; - dbSession.SaveOrUpdate(new ReferenceRecord(null, null, null, testerRecord.SN, - GlobalData.GetCurrentUserName(), - Program.LocalSettings.Workplace, - (testerRecord.Status == Status.Passed) ? 0 : 1)); - } + /// result: 0=OK, 1=test failed, 2=OK but previous step is missing, 3=failed and previous step is missing + int result = ((testerRecord.Status == Status.Passed) ? 0 : 1) + ((verifState == VerifState.VerificationFailed) ? 2 : 0); + string workplace = Program.LocalSettings.Workplace; + string user = "user"; + /// + StepRecord stepRecord = new StepRecord(refRecord, wSum.WorkstepName, workplace, user, result); + refRecord.Timestamp = stepRecord.Timestamp; + refRecord.StepRecords.Add(stepRecord); + dbSession.SaveOrUpdate(stepRecord); + dbSession.SaveOrUpdate(refRecord); - transaction.Commit(); - savingToTracingDBFailed = false; + transaction.Commit(); + + savingToTracingDBFailed = false; + } } catch (Exception) { - readingFromTracingDBFailed = !savingToTracingDBFailed; if ((transaction != null) && !transaction.WasCommitted) transaction.Rollback(); + savingToTracingDBFailed = true; } - /// /// Write the test result to Oracle DB /// @@ -955,8 +932,8 @@ namespace GenericTest /// bool printingFailed = false; if (Program.LocalSettings.DoPrintLabels && testerRecord.CanPrintRecord() - && (!Program.LocalSettings.DoPrintGoodLabelsOnly || !(readingFromTracingDBFailed || savingToTracingDBFailed || verificationFailed - || savingToOracleDBFailed || (testerRecord.Status != Status.Passed)))) + && (!Program.LocalSettings.DoPrintGoodLabelsOnly || + !(savingToTracingDBFailed || verificationFailed || savingToOracleDBFailed || testerRecord.Status != Status.Passed))) { /// Conditions for printing results are satisfied @@ -1005,11 +982,7 @@ namespace GenericTest /// Display the test result and related activity on the screen. /// Process the most severe errors first. /// - if (readingFromTracingDBFailed) - { - OnActivity(null, new ActivityEventArgs(testerRecord.SN, Strings.Reading_from_Tracing_DB_failed, ActivityCode.Failed, Color.Orange, 5000, Color.Wheat)); - } - else if (verificationFailed) + if (verificationFailed) { /// Verification is enabled, but a record from the previous workplace is missing OnActivity(null, new ActivityEventArgs(testerRecord.SN, Strings.Previous_workflow_step_is_missing_or_failed, ActivityCode.Failed, Color.Blue, 5000, Color.LightBlue)); diff --git a/GenericTest/LocalSettings.cs b/GenericTest/LocalSettings.cs index df8a32672..a8bc2ed2a 100644 --- a/GenericTest/LocalSettings.cs +++ b/GenericTest/LocalSettings.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2019-2021 Sensus Slovensko a.s. +/// Copyright (c) 2019-2022 Sensus Slovensko a.s. /// using System; using System.IO; @@ -13,7 +13,7 @@ namespace GenericTest /// /// Class to be serialized to an XML file... /// - [XmlRootAttribute("GenericTesterTracer")] + [XmlRootAttribute("GenericTest")] public class LocalSettings { static XmlSerializer serializer = XmlSerializer.FromTypes(new[] { typeof(LocalSettings) })[0]; @@ -25,6 +25,7 @@ namespace GenericTest public string Workplace; public bool IsUserLoginRequired; + public string Language; public string ConnectionString; public string UsersDBConnString; @@ -64,18 +65,19 @@ namespace GenericTest { /// Default settings Workplace = GenericTestDlg.DfltWorkplaceName; + Language = "en"; - ConnectionString = "SERVER=10.42.128.24; DATABASE=sledovanie2019; UID=vyroba2019; PASSWORD=qwerty; CHARSET=utf8"; - UsersDBConnString = "SERVER=10.42.128.24; DATABASE=st_wr_shared_config; UID=u9305784; PASSWORD=p89344390; CHARSET=utf8;"; + ConnectionString = "SERVER=10.116.192.200; DATABASE=nanjingshared; UID=nanjingshared; PASSWORD=C1ern4V0d4; CHARSET=utf8;"; + UsersDBConnString = "SERVER=10.116.192.200; DATABASE=nanjingshared; UID=nanjingshared; PASSWORD=C1ern4V0d4; CHARSET=utf8;"; TestResultsFolder = "C:\\FTS\\HookSpool\\Filemover"; ArchiveFolder = "C:\\FTS\\HookSpool\\Filemover"; DoCheckSNsValidity = false; ValidSNPrefixes = "297,298,299,300,301,302"; DoCheckPreviousTracingRecords = true; - DoSaveTestResultToOracle = true; + DoSaveTestResultToOracle = false; OracleMode = Mode.Production; DoPrintLabels = true; - DoPrintGoodLabelsOnly = true; + DoPrintGoodLabelsOnly = false; MaximizeWindowOnError = false; MainWndMaximized = false; diff --git a/GenericTest/Properties/AssemblyInfo.cs b/GenericTest/Properties/AssemblyInfo.cs index ee9d271ee..0c436c6c1 100644 --- a/GenericTest/Properties/AssemblyInfo.cs +++ b/GenericTest/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.1.134.0")] -[assembly: AssemblyFileVersion("2.1.134.0")] +[assembly: AssemblyVersion("3.0.1")] +[assembly: AssemblyFileVersion("3.0.1")] diff --git a/GenericTest/Resources/Strings.Designer.cs b/GenericTest/Resources/Strings.Designer.cs index af895a215..be38d5533 100644 --- a/GenericTest/Resources/Strings.Designer.cs +++ b/GenericTest/Resources/Strings.Designer.cs @@ -105,6 +105,15 @@ namespace GenericTest.Resources { } } + /// + /// Looks up a localized string similar to Logout. + /// + internal static string Logout { + get { + return ResourceManager.GetString("Logout", resourceCulture); + } + } + /// /// Looks up a localized string similar to Message. /// @@ -258,6 +267,15 @@ namespace GenericTest.Resources { } } + /// + /// Looks up a localized string similar to Settings. + /// + internal static string Settings { + get { + return ResourceManager.GetString("Settings", resourceCulture); + } + } + /// /// Looks up a localized string similar to Something failed. /// @@ -267,6 +285,24 @@ namespace GenericTest.Resources { } } + /// + /// Looks up a localized string similar to Start. + /// + internal static string Start { + get { + return ResourceManager.GetString("Start", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Stop. + /// + internal static string Stop { + get { + return ResourceManager.GetString("Stop", resourceCulture); + } + } + /// /// Looks up a localized string similar to Test failed {0}. /// diff --git a/GenericTest/Resources/Strings.resx b/GenericTest/Resources/Strings.resx index c2bd6499c..c8fff783a 100644 --- a/GenericTest/Resources/Strings.resx +++ b/GenericTest/Resources/Strings.resx @@ -132,6 +132,9 @@ Error + + Logout + Message @@ -183,9 +186,18 @@ Serial number is missing + + Settings + Something failed + + Start + + + Stop + Test failed {0} diff --git a/GenericTest/Resources/Strings.sk.resx b/GenericTest/Resources/Strings.sk.resx index ef3ee0a39..732d14cea 100644 --- a/GenericTest/Resources/Strings.sk.resx +++ b/GenericTest/Resources/Strings.sk.resx @@ -132,6 +132,9 @@ Chyba + + Odhlásiť + Správa @@ -180,9 +183,18 @@ Sériové číslo chýba + + Nastavenia + Niečo sa nepodarilo + + Štart + + + Stop + Test neprešiel {0} diff --git a/RecordProcessing/Properties/AssemblyInfo.cs b/RecordProcessing/Properties/AssemblyInfo.cs index c2c7f7282..664a50b5b 100644 --- a/RecordProcessing/Properties/AssemblyInfo.cs +++ b/RecordProcessing/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("RFPowerCommon")] +[assembly: AssemblyTitle("RecordProcessing")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RFPowerCommon")] +[assembly: AssemblyProduct("RecordProcessing")] [assembly: AssemblyCopyright("Copyright © 2018")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/RecordProcessing/RecordProcessing.cs b/RecordProcessing/RecordProcessing.cs index 4f08545b4..19fcafda5 100644 --- a/RecordProcessing/RecordProcessing.cs +++ b/RecordProcessing/RecordProcessing.cs @@ -20,6 +20,7 @@ namespace RecordProcessing CommTest, /// Communication test of water meter FlowtubeTestHe, /// Flowtube test with Helium FlowtubeTestAir, /// Flowtube test with air + LaserNanjing, /// Laser markig in Xylem Nanjing Count } @@ -226,7 +227,8 @@ namespace RecordProcessing case RecordType.CommTest: record = CommTestRecord.FromFile(fileName); break; case RecordType.FlowtubeTestHe: record = FlowtubeTestHeRecord.FromFile(fileName); break; case RecordType.FlowtubeTestAir: record = FlowtubeTestAirRecord.FromFile(fileName); break; - default: record = null; break; + case RecordType.LaserNanjing: record = LaserNanjingRecord.FromFile(fileName); break; + default: record = null; break; } /// Process data extracted from the file diff --git a/RecordProcessing/RecordProcessing.csproj b/RecordProcessing/RecordProcessing.csproj index 6ff83b27f..38272f0f7 100644 --- a/RecordProcessing/RecordProcessing.csproj +++ b/RecordProcessing/RecordProcessing.csproj @@ -8,7 +8,7 @@ {67BD7A8F-0FED-4FDE-B875-78D5A2BC9B2C} Library Properties - RFPowerCommon + RecordProcessing RFPowerCommon v4.7.2 512 @@ -61,6 +61,7 @@ + Component diff --git a/RecordProcessing/Records/LaserNanjingRecord.cs b/RecordProcessing/Records/LaserNanjingRecord.cs new file mode 100644 index 000000000..069971627 --- /dev/null +++ b/RecordProcessing/Records/LaserNanjingRecord.cs @@ -0,0 +1,91 @@ +/// +/// Copyright (c) 2022 Sensus Slovensko a.s. +/// +using System; +using System.Globalization; +using System.IO; +using System.Text; +using log4net; + +namespace RecordProcessing.Records +{ + public class LaserNanjingRecord : IRecord + { + static readonly ILog log = LogManager.GetLogger(typeof(LaserNanjingRecord)); + + public bool CanSaveRecordToOracle() { return false; } + public bool SaveRecordToOracle(Oracle.DataAccess.Client.OracleConnection oraConn) { return false; } + public bool CanPrintRecord() { return false; } + public bool PrintRecord() { return false; } + + public static string Path; + + public string FileName { get { return fileName; } } + public string SN { get { return sn; } set { sn = value; } } + public DateTime TimeStamp { get { return timeStamp; } } + public Status Status { get { return status; } } + public string Remark { get { return string.Empty; } } + public string ResultStr { get { return string.Empty; } } + + string fileName; + string sn; + DateTime timeStamp; + Status status; + string remark; + + public LaserNanjingRecord() + { + sn = null; + status = Status.Interrupted; + } + + /// + /// Load a record from an xml-file + /// + /// xml-filename + /// Record or null + public static LaserNanjingRecord FromFile(string fileName) + { + try + { + string bareFileName = System.IO.Path.GetFileName(fileName).Replace(".csv", ""); + LaserNanjingRecord record = new LaserNanjingRecord(); + record.fileName = bareFileName; + record.timeStamp = DateTime.Now; + + using (StreamReader iStream = new StreamReader(fileName)) + { + string firstLine = iStream.ReadLine(); + while (true) + { + string nextLine = iStream.ReadLine(); + + if (nextLine == null) break; + + string[] fields = nextLine.Split(','); + if (fields.Length >= 6) + { + record.sn = fields[1]; + record.status = (fields[5] == "OK") ? Status.Passed : Status.Failed; + } + } + + + log.InfoFormat("Succesfully parsed: {0}", record); + return record; + } + } + catch (Exception exc) + { + log.ErrorFormat("Cannot open or parse file {0}: {1}", fileName, exc.Message); + return null; + } + } + + + public override string ToString() + { + return string.Format("File={0} Housing s/n={1}, Rslt={2}", fileName, sn, status); + } + } +} diff --git a/RecordProcessing/Records/RFTestRecord.cs b/RecordProcessing/Records/RFTestRecord.cs index 069932c17..64d54740f 100644 --- a/RecordProcessing/Records/RFTestRecord.cs +++ b/RecordProcessing/Records/RFTestRecord.cs @@ -2,15 +2,12 @@ /// Copyright (c) 2019 Sensus Slovensko a.s. /// using System; -using System.Collections.Generic; using System.Globalization; using System.IO; using System.Xml; using Gma.QrCodeNet.Encoding; using log4net; -using NHibernate; using Oracle.DataAccess.Client; -using System.Drawing; namespace RecordProcessing.Records { diff --git a/SharedDatabase/TracingDB.cs b/SharedDatabase/TracingDB.cs index 563df643c..11abee923 100644 --- a/SharedDatabase/TracingDB.cs +++ b/SharedDatabase/TracingDB.cs @@ -205,17 +205,13 @@ namespace SharedDatabase } } - /// /// Updates processes, processDictionary and workstepsDictionary /// /// DB session - public static IList ReadWorkflowsFromDB(ISession session, - string thisWorkstepName, - out Dictionary workflowDict, - out Dictionary> workflowStepsDict, - out Dictionary verifInfos, - bool readDeactivatedWorkflows = false) + public static IList ReadWorkflowSummariesFromDB(ISession session, + string workstepPattern, + bool readDeactivatedWorkflows = false) { IList workflows; if (readDeactivatedWorkflows) @@ -234,30 +230,31 @@ namespace SharedDatabase )).List(); } - workflowDict = new Dictionary(); - workflowStepsDict = new Dictionary>(); - verifInfos = new Dictionary(); + var listOfWFSummaries = new List(); foreach (var wf in workflows) { - IList steps = session.QueryOver() - .Where(ws => ((ws.Workflow == wf) && (ws.Name == thisWorkstepName))) - .List(); - workflowDict.Add(wf.Id, wf); - workflowStepsDict.Add(wf.Id, steps); + var wSum = new WorkflowSummary(wf); - ScanVerificationInfo info; - if ((steps.Count == 1) && ((info = TracingDB.AnalyzeProcess(session, wf, steps[0])) != null)) + var workstep = wf.Worksteps.FirstOrDefault(x => x.Name.ToLower().Contains(workstepPattern.ToLower())); + if (workstep != null) { - verifInfos.Add(wf.Id, info); - log.WarnFormat("Workflow {0} :: Verified step={1} part={2} verify ref. part={3}", wf, info.Workstep, info.Part, info.VerifyReferencePart); + wSum.WorkstepName = workstep.Name; + int previousStepNr = workstep.WorkstepNr - 1; + var previousStep = (previousStepNr < 1) ? null : wf.Worksteps.FirstOrDefault(x => x.WorkstepNr == previousStepNr); + if (previousStep != null) wSum.PreviousWorkstepName = previousStep.Name; } + var part1 = wf.Parts.FirstOrDefault(x => x.StepNumber == 1); + var part2 = wf.Parts.FirstOrDefault(x => x.StepNumber == 2); + if (part1 != null) wSum.Part1Name = part1.Name; + if (part2 != null) wSum.Part2Name = part2.Name; + + listOfWFSummaries.Add(wSum); } - return workflows; + return listOfWFSummaries; } - /// /// Finds a workstep and a part to be verified (typically a previous workstep and one of its parts). /// Updates this.verifiedWorkstep, this.verifiedPart and this.verifyReferencePart.