Browsing previous results : SerialNr can be used as a search criterion.
This commit is contained in:
@@ -29,6 +29,7 @@ namespace Results.Forms
|
||||
public int PopupResultsWidth;
|
||||
public int PopupResultsHeight;
|
||||
public int[] RsltsClmnWidths;
|
||||
public IList<string> SerialNrs;
|
||||
|
||||
|
||||
///
|
||||
@@ -126,7 +127,8 @@ namespace Results.Forms
|
||||
int displayedControlsCount = 0;
|
||||
for (int i = 0; i < results.Batch.WaterMeters.Count; i++)
|
||||
{
|
||||
if ((!results.Batch.WaterMeters[i].Disabled) || ShowDisabledPositions)
|
||||
if ((ShowDisabledPositions || !results.Batch.WaterMeters[i].Disabled) &&
|
||||
(SerialNrs == null || SerialNrs.Contains(results.Batch.WaterMeters[i].SerialNr)))
|
||||
{
|
||||
displayedControlsCount++;
|
||||
}
|
||||
@@ -167,7 +169,8 @@ namespace Results.Forms
|
||||
firstEnabledControl = null;
|
||||
for (int i = 0; i < results.Batch.WaterMeters.Count; i++)
|
||||
{
|
||||
if (!results.Batch.WaterMeters[i].Disabled || ShowDisabledPositions)
|
||||
if ((ShowDisabledPositions || !results.Batch.WaterMeters[i].Disabled) &&
|
||||
(SerialNrs == null || SerialNrs.Contains(results.Batch.WaterMeters[i].SerialNr)))
|
||||
{
|
||||
/// Create one water meter position / control
|
||||
wmRsltsCtrl[ix] = (TestsArrangement == TestsArrangement.Rows)
|
||||
@@ -216,7 +219,8 @@ namespace Results.Forms
|
||||
int ctrlIx = 0;
|
||||
for (int wmNr0 = 0; wmNr0 < results.Batch.WaterMeters.Count; wmNr0++)
|
||||
{
|
||||
if (!results.Batch.WaterMeters[wmNr0].Disabled || ShowDisabledPositions)
|
||||
if ((ShowDisabledPositions || !results.Batch.WaterMeters[wmNr0].Disabled) &&
|
||||
(SerialNrs == null || SerialNrs.Contains(results.Batch.WaterMeters[wmNr0].SerialNr)))
|
||||
{
|
||||
if (ctrlIx < wmRsltsCtrl.Length) wmRsltsCtrl[ctrlIx++].Update(results.Batch.WaterMeters[wmNr0]);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/// Copyright (c) 2016-2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using Common;
|
||||
using TBF.Resources;
|
||||
@@ -22,18 +23,19 @@ namespace TBF.UI.ResultsMI
|
||||
public int PassedCount;
|
||||
public int FailedCount;
|
||||
public bool Sent;
|
||||
public IList<string> SerialNrs;
|
||||
|
||||
PreviousResultCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e, string ver, string proc, string pOrd, int passCnt, int failCnt, bool sent, PreviousResultsMode mode)
|
||||
public PreviousResultCtrl(PreviousResultsDlg parent, int bnr, DateTime s, DateTime e,
|
||||
string ver, string proc, string pOrd, int passCnt, int failCnt,
|
||||
bool sent, PreviousResultsMode mode, IList<string> serialNrs = null)
|
||||
: this()
|
||||
{
|
||||
this.parent = parent;
|
||||
this.mode = mode;
|
||||
|
||||
BatchNr = bnr;
|
||||
StarTime = s;
|
||||
EndTime = e;
|
||||
@@ -43,6 +45,8 @@ namespace TBF.UI.ResultsMI
|
||||
PassedCount = passCnt;
|
||||
FailedCount = failCnt;
|
||||
Sent = sent;
|
||||
this.mode = mode;
|
||||
SerialNrs = serialNrs;
|
||||
|
||||
batchNrLabel.Text = BatchNr.ToString();
|
||||
startTimeLabel.Text = StarTime.ToString(Constants.DateTimeFormat);
|
||||
@@ -90,18 +94,18 @@ namespace TBF.UI.ResultsMI
|
||||
|
||||
private void showButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
parent.OnShowResults(this, new PreviousResultIdEventArgs(BatchNr));
|
||||
parent.OnShowResults(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs));
|
||||
}
|
||||
|
||||
private void sendReloadButton_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (mode == PreviousResultsMode.Show)
|
||||
{
|
||||
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr));
|
||||
parent.OnSendAgain(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs));
|
||||
}
|
||||
else if (mode == PreviousResultsMode.Reload)
|
||||
{
|
||||
parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr));
|
||||
parent.OnReload(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs));
|
||||
}
|
||||
#if TURA_IPERL || TURA_IPERL_NEW || TURA_SPECIAL
|
||||
else if (mode == PreviousResultsMode.Fix)
|
||||
@@ -116,7 +120,7 @@ namespace TBF.UI.ResultsMI
|
||||
|
||||
Program.MainWnd.UpdateUser();
|
||||
|
||||
parent.OnReloadAndFix(this, new PreviousResultIdEventArgs(BatchNr));
|
||||
parent.OnReloadAndFix(this, new PreviousResultIdEventArgs(BatchNr, SerialNrs));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TBF.UI.ResultsMI
|
||||
{
|
||||
public class PreviousResultIdEventArgs : EventArgs
|
||||
{
|
||||
public int BatchNr;
|
||||
public IList<string> SerialNrs; /// null = Show all serial numbers
|
||||
|
||||
public PreviousResultIdEventArgs(int batchNr)
|
||||
{
|
||||
BatchNr = batchNr;
|
||||
}
|
||||
}
|
||||
public PreviousResultIdEventArgs(int batchNr, IList<string> serialNrs)
|
||||
{
|
||||
BatchNr = batchNr;
|
||||
SerialNrs = serialNrs;
|
||||
}
|
||||
|
||||
public PreviousResultIdEventArgs(int batchNr)
|
||||
: this(batchNr, null)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
-7
@@ -42,6 +42,8 @@
|
||||
this.fromLabel = new System.Windows.Forms.Label();
|
||||
this.toDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.snTextBox = new System.Windows.Forms.TextBox();
|
||||
this.snLabel = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.vertSplitContainer)).BeginInit();
|
||||
this.vertSplitContainer.Panel1.SuspendLayout();
|
||||
this.vertSplitContainer.Panel2.SuspendLayout();
|
||||
@@ -139,6 +141,8 @@
|
||||
//
|
||||
// filterGroupBox
|
||||
//
|
||||
this.filterGroupBox.Controls.Add(this.snLabel);
|
||||
this.filterGroupBox.Controls.Add(this.snTextBox);
|
||||
this.filterGroupBox.Controls.Add(this.reloadButton);
|
||||
this.filterGroupBox.Controls.Add(this.procedureTextBox);
|
||||
this.filterGroupBox.Controls.Add(this.procedureLabel);
|
||||
@@ -156,7 +160,7 @@
|
||||
//
|
||||
// reloadButton
|
||||
//
|
||||
this.reloadButton.Location = new System.Drawing.Point(1005, 23);
|
||||
this.reloadButton.Location = new System.Drawing.Point(1009, 23);
|
||||
this.reloadButton.Name = "reloadButton";
|
||||
this.reloadButton.Size = new System.Drawing.Size(37, 23);
|
||||
this.reloadButton.TabIndex = 0;
|
||||
@@ -166,7 +170,7 @@
|
||||
//
|
||||
// procedureTextBox
|
||||
//
|
||||
this.procedureTextBox.Location = new System.Drawing.Point(460, 25);
|
||||
this.procedureTextBox.Location = new System.Drawing.Point(472, 25);
|
||||
this.procedureTextBox.Name = "procedureTextBox";
|
||||
this.procedureTextBox.Size = new System.Drawing.Size(523, 20);
|
||||
this.procedureTextBox.TabIndex = 22;
|
||||
@@ -174,7 +178,7 @@
|
||||
// procedureLabel
|
||||
//
|
||||
this.procedureLabel.AutoSize = true;
|
||||
this.procedureLabel.Location = new System.Drawing.Point(378, 30);
|
||||
this.procedureLabel.Location = new System.Drawing.Point(412, 30);
|
||||
this.procedureLabel.Name = "procedureLabel";
|
||||
this.procedureLabel.Size = new System.Drawing.Size(56, 13);
|
||||
this.procedureLabel.TabIndex = 21;
|
||||
@@ -183,7 +187,7 @@
|
||||
// toLabel
|
||||
//
|
||||
this.toLabel.AutoSize = true;
|
||||
this.toLabel.Location = new System.Drawing.Point(216, 31);
|
||||
this.toLabel.Location = new System.Drawing.Point(151, 31);
|
||||
this.toLabel.Name = "toLabel";
|
||||
this.toLabel.Size = new System.Drawing.Size(16, 13);
|
||||
this.toLabel.TabIndex = 20;
|
||||
@@ -192,7 +196,7 @@
|
||||
// fromLabel
|
||||
//
|
||||
this.fromLabel.AutoSize = true;
|
||||
this.fromLabel.Location = new System.Drawing.Point(44, 31);
|
||||
this.fromLabel.Location = new System.Drawing.Point(16, 31);
|
||||
this.fromLabel.Name = "fromLabel";
|
||||
this.fromLabel.Size = new System.Drawing.Size(27, 13);
|
||||
this.fromLabel.TabIndex = 19;
|
||||
@@ -202,7 +206,7 @@
|
||||
//
|
||||
this.toDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||
this.toDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||
this.toDateTimePicker.Location = new System.Drawing.Point(252, 25);
|
||||
this.toDateTimePicker.Location = new System.Drawing.Point(174, 25);
|
||||
this.toDateTimePicker.Name = "toDateTimePicker";
|
||||
this.toDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||
this.toDateTimePicker.TabIndex = 18;
|
||||
@@ -211,11 +215,27 @@
|
||||
//
|
||||
this.fromDateTimePicker.CustomFormat = "dd.MM.yyyy";
|
||||
this.fromDateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
|
||||
this.fromDateTimePicker.Location = new System.Drawing.Point(89, 25);
|
||||
this.fromDateTimePicker.Location = new System.Drawing.Point(53, 25);
|
||||
this.fromDateTimePicker.Name = "fromDateTimePicker";
|
||||
this.fromDateTimePicker.Size = new System.Drawing.Size(82, 20);
|
||||
this.fromDateTimePicker.TabIndex = 17;
|
||||
//
|
||||
// snTextBox
|
||||
//
|
||||
this.snTextBox.Location = new System.Drawing.Point(295, 25);
|
||||
this.snTextBox.Name = "snTextBox";
|
||||
this.snTextBox.Size = new System.Drawing.Size(100, 20);
|
||||
this.snTextBox.TabIndex = 23;
|
||||
//
|
||||
// snLabel
|
||||
//
|
||||
this.snLabel.AutoSize = true;
|
||||
this.snLabel.Location = new System.Drawing.Point(269, 29);
|
||||
this.snLabel.Name = "snLabel";
|
||||
this.snLabel.Size = new System.Drawing.Size(23, 13);
|
||||
this.snLabel.TabIndex = 24;
|
||||
this.snLabel.Text = "s/n";
|
||||
//
|
||||
// PreviousResultsDlg
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -260,5 +280,7 @@
|
||||
private System.Windows.Forms.Label procedureLabel;
|
||||
private System.Windows.Forms.TextBox procedureTextBox;
|
||||
private System.Windows.Forms.Button reloadButton;
|
||||
private System.Windows.Forms.Label snLabel;
|
||||
private System.Windows.Forms.TextBox snTextBox;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,8 @@ namespace TBF.UI.ResultsMI
|
||||
ISession session;
|
||||
int currentBatchNr;
|
||||
|
||||
IList<Batch> batches; /// A list of batches selected from all batches using criteria from/to date and procedure name
|
||||
IList<Batch> batches; /// A list of batches selected from all batches using criteria entered in UI
|
||||
IList<string> serialNrs; /// Display only watermeters with these serial numbers (null = display all)
|
||||
int lastDisplayedIx; /// Index of the last displayed batch from the list 'batches'
|
||||
const int LinesCount = 25; /// Number of batches displayed on one screen
|
||||
|
||||
@@ -65,7 +66,6 @@ namespace TBF.UI.ResultsMI
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
private void PreviousResultsDlg_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
@@ -92,7 +92,7 @@ namespace TBF.UI.ResultsMI
|
||||
log.ErrorFormat("Opening Results DB failed: {0}", exc.Message);
|
||||
}
|
||||
|
||||
var batches = GetFilteredBatches();
|
||||
batches = GetFilteredBatches(out lastDisplayedIx, out serialNrs);
|
||||
UpdateButtons();
|
||||
Redraw();
|
||||
}
|
||||
@@ -108,37 +108,65 @@ namespace TBF.UI.ResultsMI
|
||||
procedureLabel.Text = Strings.Procedure;
|
||||
}
|
||||
|
||||
IList<Batch> GetFilteredBatches()
|
||||
/// <summary>
|
||||
/// Returns a list of batches selected using criteria entered in UI
|
||||
/// </summary>
|
||||
/// <returns>List of batches</returns>
|
||||
IList<Batch> GetFilteredBatches(out int lastIx, out IList<string> serialNrs)
|
||||
{
|
||||
IList<Batch> rslt;
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(procedureTextBox.Text))
|
||||
if (string.IsNullOrEmpty(procedureTextBox.Text) && string.IsNullOrEmpty(snTextBox.Text))
|
||||
{
|
||||
batches = session.QueryOver<Batch>()
|
||||
.Where(x => (x.StartTime >= fromDateTimePicker.Value))
|
||||
.And(x => (x.StartTime <= toDateTimePicker.Value.AddDays(1)))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.List();
|
||||
rslt = session.QueryOver<Batch>()
|
||||
.Where(x => (x.StartTime >= fromDateTimePicker.Value))
|
||||
.And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.List();
|
||||
}
|
||||
else if (string.IsNullOrEmpty(snTextBox.Text))
|
||||
{
|
||||
rslt = session.QueryOver<Batch>()
|
||||
.Where(x => (x.StartTime >= fromDateTimePicker.Value))
|
||||
.And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
|
||||
.And(x => (x.ProcedureName == procedureTextBox.Text))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.List();
|
||||
}
|
||||
else if (string.IsNullOrEmpty(procedureTextBox.Text))
|
||||
{
|
||||
rslt = session.QueryOver<Batch>()
|
||||
.Where(x => (x.StartTime >= fromDateTimePicker.Value))
|
||||
.And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.JoinQueryOver<WaterMeter>(b => b.WaterMeters)
|
||||
.Where(wm => (wm.SerialNr == snTextBox.Text))
|
||||
.List<Batch>();
|
||||
}
|
||||
else
|
||||
{
|
||||
batches = session.QueryOver<Batch>()
|
||||
.Where(x => (x.ProcedureName == procedureTextBox.Text))
|
||||
.And(x => (x.StartTime >= fromDateTimePicker.Value))
|
||||
.And(x => (x.StartTime <= toDateTimePicker.Value.AddDays(1)))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.List();
|
||||
rslt = session.QueryOver<Batch>()
|
||||
.Where(x => (x.StartTime >= fromDateTimePicker.Value))
|
||||
.And(x => (x.StartTime < toDateTimePicker.Value.AddDays(1)))
|
||||
.And(x => (x.ProcedureName == procedureTextBox.Text))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.JoinQueryOver<WaterMeter>(b => b.WaterMeters)
|
||||
.Where(wm => (wm.SerialNr == snTextBox.Text))
|
||||
.List<Batch>();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
batches = new List<Batch>();
|
||||
rslt = new List<Batch>();
|
||||
log.ErrorFormat("Reading batches from Results DB failed: {0}", exc.Message);
|
||||
}
|
||||
|
||||
lastDisplayedIx = batches.Count - 1;
|
||||
serialNrs = string.IsNullOrEmpty(snTextBox.Text) ? null : new List<string> { snTextBox.Text };
|
||||
lastIx = rslt.Count - 1;
|
||||
|
||||
return batches;
|
||||
return rslt;
|
||||
}
|
||||
|
||||
public void OnReload(object sender, PreviousResultIdEventArgs data)
|
||||
@@ -300,6 +328,7 @@ namespace TBF.UI.ResultsMI
|
||||
MinWidth = Program.LocalSettings.ResultsConfigMinWidth,
|
||||
MinHeight = Program.LocalSettings.ResultsConfigMinHeight,
|
||||
RsltsClmnWidths = Program.LocalSettings.RsltsClmnWidths,
|
||||
SerialNrs = data.SerialNrs,
|
||||
};
|
||||
|
||||
dlg.Show();
|
||||
@@ -309,19 +338,10 @@ namespace TBF.UI.ResultsMI
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawBatches(int from, int to)
|
||||
{
|
||||
batches = session.QueryOver<Batch>()
|
||||
.WhereRestrictionOn(x => x.BatchNr)
|
||||
.IsBetween(Math.Max(1, from))
|
||||
.And(Math.Min(to, currentBatchNr - 1))
|
||||
.OrderBy(x => x.BatchNr).Asc
|
||||
.List<Batch>();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Redraws list of batches.
|
||||
/// Uses member variables 'batches' and 'lastDisplayedIx'
|
||||
/// </summary>
|
||||
void Redraw()
|
||||
{
|
||||
SuspendLayout();
|
||||
@@ -353,7 +373,8 @@ namespace TBF.UI.ResultsMI
|
||||
passedCount,
|
||||
failedCount,
|
||||
b.RsltsSent,
|
||||
mode));
|
||||
mode,
|
||||
serialNrs));
|
||||
}
|
||||
|
||||
ResumeLayout();
|
||||
@@ -388,7 +409,7 @@ namespace TBF.UI.ResultsMI
|
||||
|
||||
private void reloadButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
batches = GetFilteredBatches();
|
||||
batches = GetFilteredBatches(out lastDisplayedIx, out serialNrs);
|
||||
UpdateButtons();
|
||||
Redraw();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user