ResultsBrowser: query by BatchNr range added.

This commit is contained in:
Milan Hanajik 2015-12-21 20:32:36 +01:00
parent 21390eaba6
commit a08be1ee73
3 changed files with 215 additions and 154 deletions

View File

@ -34,7 +34,8 @@ namespace ResultsBrowser
public string LastBenchName;
public bool FilterPurchaseOrder;
public bool FilterProcedure;
public bool FilterDate;
public bool FilterBatchNr;
public bool FilterDate;
public bool ResolveManually;
/// MainWnd
@ -54,6 +55,10 @@ namespace ResultsBrowser
[XmlIgnore]
public int ProcedureHistoryCount { get { return (ProcedureHistory != null) ? ProcedureHistory.Length : 0; } }
/// BatchNr range
public string BatchFrom;
public string BatchTo;
/// Report file name history
public string[] ReportFileNameHistory;
[XmlIgnore]

View File

@ -30,6 +30,12 @@
{
this.queryButton = new System.Windows.Forms.Button();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.batchNrGroupBox = new System.Windows.Forms.GroupBox();
this.batchNrToTextBox = new System.Windows.Forms.TextBox();
this.batchNrFromTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.batchNrCheckBox = new System.Windows.Forms.CheckBox();
this.removeFromQueryButton = new System.Windows.Forms.Button();
this.addToReportButton = new System.Windows.Forms.Button();
this.resolveManuallyCheckBox = new System.Windows.Forms.CheckBox();
@ -50,18 +56,19 @@
this.configReportButton = new System.Windows.Forms.Button();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.makeReportButton = new System.Windows.Forms.Button();
this.removeFromReportButton = new System.Windows.Forms.Button();
this.reportFileGroupBox = new System.Windows.Forms.GroupBox();
this.browseFileButton = new System.Windows.Forms.Button();
this.reportFileComboBox = new System.Windows.Forms.ComboBox();
this.makeReportButton = new System.Windows.Forms.Button();
this.makeAscFileButton = new System.Windows.Forms.Button();
this.addOracleDataButton = new System.Windows.Forms.Button();
this.reportListBox = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.batchNrGroupBox.SuspendLayout();
this.procedureGroupBox.SuspendLayout();
this.fromGroupBox.SuspendLayout();
this.purchaseOrderGroupBox.SuspendLayout();
@ -78,9 +85,9 @@
//
// queryButton
//
this.queryButton.Location = new System.Drawing.Point(15, 162);
this.queryButton.Location = new System.Drawing.Point(15, 178);
this.queryButton.Name = "queryButton";
this.queryButton.Size = new System.Drawing.Size(108, 40);
this.queryButton.Size = new System.Drawing.Size(108, 29);
this.queryButton.TabIndex = 3;
this.queryButton.Text = "Query";
this.queryButton.UseVisualStyleBackColor = true;
@ -97,7 +104,7 @@
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.button1);
this.splitContainer1.Panel1.Controls.Add(this.batchNrGroupBox);
this.splitContainer1.Panel1.Controls.Add(this.removeFromQueryButton);
this.splitContainer1.Panel1.Controls.Add(this.addToReportButton);
this.splitContainer1.Panel1.Controls.Add(this.resolveManuallyCheckBox);
@ -114,6 +121,61 @@
this.splitContainer1.SplitterDistance = 220;
this.splitContainer1.TabIndex = 5;
//
// batchNrGroupBox
//
this.batchNrGroupBox.Controls.Add(this.batchNrToTextBox);
this.batchNrGroupBox.Controls.Add(this.batchNrFromTextBox);
this.batchNrGroupBox.Controls.Add(this.label4);
this.batchNrGroupBox.Controls.Add(this.label3);
this.batchNrGroupBox.Controls.Add(this.batchNrCheckBox);
this.batchNrGroupBox.Location = new System.Drawing.Point(15, 122);
this.batchNrGroupBox.Name = "batchNrGroupBox";
this.batchNrGroupBox.Size = new System.Drawing.Size(242, 50);
this.batchNrGroupBox.TabIndex = 11;
this.batchNrGroupBox.TabStop = false;
//
// batchNrToTextBox
//
this.batchNrToTextBox.Location = new System.Drawing.Point(157, 21);
this.batchNrToTextBox.Name = "batchNrToTextBox";
this.batchNrToTextBox.Size = new System.Drawing.Size(62, 20);
this.batchNrToTextBox.TabIndex = 5;
//
// batchNrFromTextBox
//
this.batchNrFromTextBox.Location = new System.Drawing.Point(56, 21);
this.batchNrFromTextBox.Name = "batchNrFromTextBox";
this.batchNrFromTextBox.Size = new System.Drawing.Size(62, 20);
this.batchNrFromTextBox.TabIndex = 4;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(131, 24);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(20, 13);
this.label4.TabIndex = 3;
this.label4.Text = "To";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(19, 24);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(30, 13);
this.label3.TabIndex = 2;
this.label3.Text = "From";
//
// batchNrCheckBox
//
this.batchNrCheckBox.AutoSize = true;
this.batchNrCheckBox.Location = new System.Drawing.Point(19, 0);
this.batchNrCheckBox.Name = "batchNrCheckBox";
this.batchNrCheckBox.Size = new System.Drawing.Size(116, 17);
this.batchNrCheckBox.TabIndex = 1;
this.batchNrCheckBox.Text = "Filter batch number";
this.batchNrCheckBox.UseVisualStyleBackColor = true;
//
// removeFromQueryButton
//
this.removeFromQueryButton.Location = new System.Drawing.Point(453, 162);
@ -137,7 +199,7 @@
// resolveManuallyCheckBox
//
this.resolveManuallyCheckBox.AutoSize = true;
this.resolveManuallyCheckBox.Location = new System.Drawing.Point(282, 129);
this.resolveManuallyCheckBox.Location = new System.Drawing.Point(282, 143);
this.resolveManuallyCheckBox.Name = "resolveManuallyCheckBox";
this.resolveManuallyCheckBox.Size = new System.Drawing.Size(158, 17);
this.resolveManuallyCheckBox.TabIndex = 7;
@ -148,9 +210,9 @@
//
this.procedureGroupBox.Controls.Add(this.procedureCheckBox);
this.procedureGroupBox.Controls.Add(this.procedureComboBox);
this.procedureGroupBox.Location = new System.Drawing.Point(15, 83);
this.procedureGroupBox.Location = new System.Drawing.Point(15, 68);
this.procedureGroupBox.Name = "procedureGroupBox";
this.procedureGroupBox.Size = new System.Drawing.Size(242, 63);
this.procedureGroupBox.Size = new System.Drawing.Size(242, 50);
this.procedureGroupBox.TabIndex = 6;
this.procedureGroupBox.TabStop = false;
//
@ -168,16 +230,16 @@
// procedureComboBox
//
this.procedureComboBox.FormattingEnabled = true;
this.procedureComboBox.Location = new System.Drawing.Point(18, 26);
this.procedureComboBox.Location = new System.Drawing.Point(18, 19);
this.procedureComboBox.Name = "procedureComboBox";
this.procedureComboBox.Size = new System.Drawing.Size(201, 21);
this.procedureComboBox.TabIndex = 0;
//
// clearButton
//
this.clearButton.Location = new System.Drawing.Point(149, 162);
this.clearButton.Location = new System.Drawing.Point(149, 178);
this.clearButton.Name = "clearButton";
this.clearButton.Size = new System.Drawing.Size(108, 40);
this.clearButton.Size = new System.Drawing.Size(108, 29);
this.clearButton.TabIndex = 4;
this.clearButton.Text = "Clear";
this.clearButton.UseVisualStyleBackColor = true;
@ -192,14 +254,14 @@
this.fromGroupBox.Controls.Add(this.fromDateTimePicker);
this.fromGroupBox.Location = new System.Drawing.Point(263, 14);
this.fromGroupBox.Name = "fromGroupBox";
this.fromGroupBox.Size = new System.Drawing.Size(242, 98);
this.fromGroupBox.Size = new System.Drawing.Size(242, 104);
this.fromGroupBox.TabIndex = 3;
this.fromGroupBox.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 65);
this.label2.Location = new System.Drawing.Point(16, 68);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(20, 13);
this.label2.TabIndex = 3;
@ -208,7 +270,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 33);
this.label1.Location = new System.Drawing.Point(16, 36);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 2;
@ -226,14 +288,14 @@
//
// toDateTimePicker
//
this.toDateTimePicker.Location = new System.Drawing.Point(68, 62);
this.toDateTimePicker.Location = new System.Drawing.Point(68, 65);
this.toDateTimePicker.Name = "toDateTimePicker";
this.toDateTimePicker.Size = new System.Drawing.Size(151, 20);
this.toDateTimePicker.TabIndex = 0;
//
// fromDateTimePicker
//
this.fromDateTimePicker.Location = new System.Drawing.Point(68, 29);
this.fromDateTimePicker.Location = new System.Drawing.Point(68, 32);
this.fromDateTimePicker.Name = "fromDateTimePicker";
this.fromDateTimePicker.Size = new System.Drawing.Size(151, 20);
this.fromDateTimePicker.TabIndex = 0;
@ -244,7 +306,7 @@
this.purchaseOrderGroupBox.Controls.Add(this.purchaseOrderComboBox);
this.purchaseOrderGroupBox.Location = new System.Drawing.Point(15, 14);
this.purchaseOrderGroupBox.Name = "purchaseOrderGroupBox";
this.purchaseOrderGroupBox.Size = new System.Drawing.Size(242, 63);
this.purchaseOrderGroupBox.Size = new System.Drawing.Size(242, 50);
this.purchaseOrderGroupBox.TabIndex = 2;
this.purchaseOrderGroupBox.TabStop = false;
//
@ -261,7 +323,7 @@
// purchaseOrderComboBox
//
this.purchaseOrderComboBox.FormattingEnabled = true;
this.purchaseOrderComboBox.Location = new System.Drawing.Point(18, 26);
this.purchaseOrderComboBox.Location = new System.Drawing.Point(18, 19);
this.purchaseOrderComboBox.Name = "purchaseOrderComboBox";
this.purchaseOrderComboBox.Size = new System.Drawing.Size(201, 21);
this.purchaseOrderComboBox.TabIndex = 0;
@ -278,7 +340,7 @@
//
// configReportButton
//
this.configReportButton.Location = new System.Drawing.Point(334, 95);
this.configReportButton.Location = new System.Drawing.Point(226, 95);
this.configReportButton.Name = "configReportButton";
this.configReportButton.Size = new System.Drawing.Size(103, 47);
this.configReportButton.TabIndex = 5;
@ -314,9 +376,10 @@
//
// splitContainer3.Panel1
//
this.splitContainer3.Panel1.Controls.Add(this.makeReportButton);
this.splitContainer3.Panel1.Controls.Add(this.removeFromReportButton);
this.splitContainer3.Panel1.Controls.Add(this.reportFileGroupBox);
this.splitContainer3.Panel1.Controls.Add(this.makeReportButton);
this.splitContainer3.Panel1.Controls.Add(this.makeAscFileButton);
this.splitContainer3.Panel1.Controls.Add(this.addOracleDataButton);
this.splitContainer3.Panel1.Controls.Add(this.configReportButton);
//
@ -327,6 +390,16 @@
this.splitContainer3.SplitterDistance = 220;
this.splitContainer3.TabIndex = 6;
//
// makeReportButton
//
this.makeReportButton.Location = new System.Drawing.Point(335, 95);
this.makeReportButton.Name = "makeReportButton";
this.makeReportButton.Size = new System.Drawing.Size(103, 47);
this.makeReportButton.TabIndex = 11;
this.makeReportButton.Text = "Make Report";
this.makeReportButton.UseVisualStyleBackColor = true;
this.makeReportButton.Click += new System.EventHandler(this.makeReportButton_Click);
//
// removeFromReportButton
//
this.removeFromReportButton.Location = new System.Drawing.Point(58, 162);
@ -366,19 +439,19 @@
this.reportFileComboBox.Size = new System.Drawing.Size(414, 21);
this.reportFileComboBox.TabIndex = 1;
//
// makeReportButton
// makeAscFileButton
//
this.makeReportButton.Location = new System.Drawing.Point(443, 95);
this.makeReportButton.Name = "makeReportButton";
this.makeReportButton.Size = new System.Drawing.Size(103, 47);
this.makeReportButton.TabIndex = 7;
this.makeReportButton.Text = "Make Report";
this.makeReportButton.UseVisualStyleBackColor = true;
this.makeReportButton.Click += new System.EventHandler(this.makeReportButton_Click);
this.makeAscFileButton.Location = new System.Drawing.Point(443, 95);
this.makeAscFileButton.Name = "makeAscFileButton";
this.makeAscFileButton.Size = new System.Drawing.Size(103, 47);
this.makeAscFileButton.TabIndex = 7;
this.makeAscFileButton.Text = "Make *.asc File";
this.makeAscFileButton.UseVisualStyleBackColor = true;
this.makeAscFileButton.Click += new System.EventHandler(this.makeAscFileButton_Click);
//
// addOracleDataButton
//
this.addOracleDataButton.Location = new System.Drawing.Point(225, 95);
this.addOracleDataButton.Location = new System.Drawing.Point(117, 95);
this.addOracleDataButton.Name = "addOracleDataButton";
this.addOracleDataButton.Size = new System.Drawing.Size(103, 47);
this.addOracleDataButton.TabIndex = 6;
@ -396,16 +469,6 @@
this.reportListBox.Size = new System.Drawing.Size(676, 400);
this.reportListBox.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(321, 173);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 10;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// MainWnd
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -421,6 +484,8 @@
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.batchNrGroupBox.ResumeLayout(false);
this.batchNrGroupBox.PerformLayout();
this.procedureGroupBox.ResumeLayout(false);
this.procedureGroupBox.PerformLayout();
this.fromGroupBox.ResumeLayout(false);
@ -462,7 +527,7 @@
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.Button addOracleDataButton;
private System.Windows.Forms.Button makeReportButton;
private System.Windows.Forms.Button makeAscFileButton;
private System.Windows.Forms.ListBox queryResultsListBox;
private System.Windows.Forms.ListBox reportListBox;
private System.Windows.Forms.GroupBox reportFileGroupBox;
@ -470,8 +535,14 @@
private System.Windows.Forms.ComboBox reportFileComboBox;
private System.Windows.Forms.Button removeFromQueryButton;
private System.Windows.Forms.Button addToReportButton;
private System.Windows.Forms.Button removeFromReportButton;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button removeFromReportButton;
private System.Windows.Forms.GroupBox batchNrGroupBox;
private System.Windows.Forms.TextBox batchNrToTextBox;
private System.Windows.Forms.TextBox batchNrFromTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.CheckBox batchNrCheckBox;
private System.Windows.Forms.Button makeReportButton;
}
}

View File

@ -36,10 +36,16 @@ namespace ResultsBrowser
ReportItems_Single = ResultItemSpec.FromStrArray(Program.LocalSettings.ReportItems_Single);
ReportItems_Compound = ResultItemSpec.FromStrArray(Program.LocalSettings.ReportItems_Compound);
purchaseOrderCheckBox.Checked = Program.LocalSettings.FilterPurchaseOrder;
purchaseOrderCheckBox.Checked = Program.LocalSettings.FilterPurchaseOrder;
procedureCheckBox.Checked = Program.LocalSettings.FilterProcedure;
filterDateCheckBox.Checked = Program.LocalSettings.FilterDate;
batchNrCheckBox.Checked = Program.LocalSettings.FilterBatchNr;
filterDateCheckBox.Checked = Program.LocalSettings.FilterDate;
resolveManuallyCheckBox.Checked = Program.LocalSettings.ResolveManually;
batchNrFromTextBox.Text = Program.LocalSettings.BatchFrom;
batchNrToTextBox.Text = Program.LocalSettings.BatchTo;
}
private void MainWnd_FormClosing(object sender, FormClosingEventArgs e)
@ -50,10 +56,17 @@ namespace ResultsBrowser
Program.LocalSettings.ReportItems_Single = ResultItemSpec.ToStrArray(ReportItems_Single);
Program.LocalSettings.ReportItems_Compound = ResultItemSpec.ToStrArray(ReportItems_Compound);
Program.LocalSettings.FilterPurchaseOrder = purchaseOrderCheckBox.Checked;
Program.LocalSettings.FilterPurchaseOrder = purchaseOrderCheckBox.Checked;
Program.LocalSettings.FilterProcedure = procedureCheckBox.Checked;
Program.LocalSettings.FilterDate = filterDateCheckBox.Checked;
Program.LocalSettings.ResolveManually = resolveManuallyCheckBox.Checked;
Program.LocalSettings.FilterBatchNr = batchNrCheckBox.Checked;
Program.LocalSettings.FilterDate = filterDateCheckBox.Checked;
Program.LocalSettings.BatchFrom = batchNrFromTextBox.Text;
Program.LocalSettings.BatchTo = batchNrToTextBox.Text;
Program.LocalSettings.ResolveManually = resolveManuallyCheckBox.Checked;
Program.LocalSettings.Save();
}
@ -95,7 +108,13 @@ namespace ResultsBrowser
private void queryButton_Click(object sender, EventArgs e)
{
if (!purchaseOrderCheckBox.Checked && !procedureCheckBox.Checked && !filterDateCheckBox.Checked) return;
if (!purchaseOrderCheckBox.Checked &&
!procedureCheckBox.Checked &&
!filterDateCheckBox.Checked &&
!batchNrCheckBox.Checked)
{
return;
}
try
{
@ -104,39 +123,41 @@ namespace ResultsBrowser
IList<TestResult> testResults;
IList<TestResult> partialTestResults;
if (procedureCheckBox.Checked)
if (batchNrCheckBox.Checked)
{
int from, to;
if (!int.TryParse(batchNrFromTextBox.Text, out from) || !int.TryParse(batchNrToTextBox.Text, out to) || from > to)
{
MessageBox.Show("Please check 'From' and 'To' values", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else
{
testResults = new List<TestResult>();
for (int batch = from; batch <= to; batch++)
{
IQueryOver<TestResult> qo = session.QueryOver<TestResult>().Where(x => (x.BatchNr == batch));
//if (procedureCheckBox.Checked) qo = qo.Where(x => (x.ProcedureName == "IPRT02AB - MI120 - Q2s"));
partialTestResults = qo.List<TestResult>();
foreach (var tr in partialTestResults) testResults.Add(tr);
}
}
}
else if (procedureCheckBox.Checked)
{
if (filterDateCheckBox.Checked)
{
if (purchaseOrderCheckBox.Checked)
{
//testResults = session.QueryOver<TestResult>()
// .WhereRestrictionOn(x => x.TimeStart)
// .IsBetween(fromDateTimePicker.Value)
// .And(toDateTimePicker.Value)
// .Where(x => (x.PurchaseOrder == purchaseOrderComboBox.Text))
// .Where(x => (x.ProcedureName == procedureComboBox.Text))
// .OrderBy(x => x.BatchNr).Desc
// .List<TestResult>();
testResults = new List<TestResult>();
//{
// int bb = 757;
// partialTestResults = session.QueryOver<TestResult>()
// .Where(x => (x.BatchNr == bb))
// //.Where(x => (x.ProcedureName == "IPRT02AB - MI120 - Q2s"))
// .List<TestResult>();
// foreach (var tr in partialTestResults) testResults.Add(tr);
//}
for (int b = 796; b <= 807; b++)
{
partialTestResults = session.QueryOver<TestResult>()
.Where(x => (x.BatchNr == b))
//.Where(x => (x.ProcedureName == "IPRT02AB - MI120 - Q2s"))
.List<TestResult>();
foreach (var tr in partialTestResults) testResults.Add(tr);
}
testResults = session.QueryOver<TestResult>()
.WhereRestrictionOn(x => x.TimeStart)
.IsBetween(fromDateTimePicker.Value)
.And(toDateTimePicker.Value)
.Where(x => (x.PurchaseOrder == purchaseOrderComboBox.Text))
.Where(x => (x.ProcedureName == procedureComboBox.Text))
.OrderBy(x => x.BatchNr).Desc
.List<TestResult>();
}
else
{
@ -215,6 +236,7 @@ namespace ResultsBrowser
private void clearButton_Click(object sender, EventArgs e)
{
DataDeposit.QueryWaterMeterResults.Clear();
queryResultsListBox.Items.Clear();
}
@ -323,7 +345,7 @@ namespace ResultsBrowser
RedrawLists();
}
private void makeReportButton_Click(object sender, EventArgs e)
private void makeAscFileButton_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(reportFileComboBox.Text))
{
@ -352,22 +374,10 @@ namespace ResultsBrowser
{
foreach (var wm in DataDeposit.ReportWaterMeterResults)
{
#if false
bool first = true;
foreach (var mtr in wm.MeterTestResults)
{
foreach (var item in ReportItems_Single)
{
if (!first) sb.Append(';');
else first = false;
sb.Append(item.Print(mtr));
}
}
#else
try
{
StringBuilder sb = new StringBuilder();
sb.Append(wm.SerialNrEx);
sb.Append(';'); sb.Append(wm.Type);
sb.Append(';'); sb.Append(wm.TypeApproval);
@ -389,7 +399,7 @@ namespace ResultsBrowser
sb.Append(';'); sb.Append("10000");
sb.Append(';'); sb.Append(wm.ProcedureName.Substring(0, 8));
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"');
#endif
report.WriteLine(sb);
}
catch (Exception exc)
@ -407,74 +417,49 @@ namespace ResultsBrowser
return (((date.Year % 100) * 100 + date.Month) * 100 + date.Day).ToString();
}
private void button1_Click(object sender, EventArgs e)
private void makeReportButton_Click(object sender, EventArgs e)
{
//DataDeposit.QueryWaterMeterResults = new List<Results.Entities.WaterMeterResult>();
//for (int sn = 20075000; sn < 20075179; sn++)
//{
// Results.Entities.WaterMeterResult wm = new Results.Entities.WaterMeterResult>();
if (string.IsNullOrEmpty(reportFileComboBox.Text))
{
MessageBox.Show("No report file selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
// OracleParameter parm = new OracleParameter();
// parm.OracleDbType = OracleDbType.Varchar2;
// parm.Value = wm.SerialNr; /// PCB Nr.
if (ReportItems_Single == null || ReportItems_Single.Count == 0)
{
MessageBox.Show("Please, configure the report first", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
// OracleCommand cmd1 = new OracleCommand("SELECT Zaehlernummer FROM VT_ZAEHLER_PD WHERE VT_Fernum = :1 AND ANBID = 4", conn);
// cmd1.Parameters.Add(parm);
using (TextWriter report = new StreamWriter(reportFileComboBox.Text, true))
{
foreach (var wm in DataDeposit.ReportWaterMeterResults)
{
try
{
StringBuilder sb = new StringBuilder();
// OracleDataReader dr = cmd1.ExecuteReader();
// if (dr.Read())
// {
// wm.SerialNrEx = dr.GetInt32(0);
// }
//const int Step = 100;
//for (int i = 0; i < DataDeposit.ReportWaterMeterResults.Count; i += Step)
//{
// try
// {
// /// Oracle database connection
// OracleConnection conn = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
// conn.Open();
// for (int j = i; j < Math.Min(j + Step, DataDeposit.ReportWaterMeterResults.Count); j++)
// {
// Results.Entities.WaterMeterResult wm = DataDeposit.ReportWaterMeterResults[j];
// IList<int> serialNrExes = new List<int>();
// {
// OracleParameter parm = new OracleParameter();
// parm.OracleDbType = OracleDbType.Varchar2;
// parm.Value = wm.SerialNr; /// PCB Nr.
// OracleCommand cmd1 = new OracleCommand("SELECT Zaehlernummer FROM VT_ZAEHLER_PD WHERE VT_Fernum = :1 AND ANBID = 4", conn);
// cmd1.Parameters.Add(parm);
// OracleDataReader dr = cmd1.ExecuteReader();
// if (dr.Read())
// {
// wm.SerialNrEx = dr.GetInt32(0);
// }
// }
// }
// conn.Close();
// }
// catch (Exception exc)
// {
// MessageBox.Show(string.Format("Error when querying Oracle database:\r\n{0}", exc.Message),
// "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
// RedrawLists();
// return;
// }
//}
sb.Append(wm.SerialNrEx);
sb.Append(";\""); sb.Append(wm.SerialNr); sb.Append('"'); /// PCB number
sb.Append(";\""); sb.Append(wm.ProcedureName); sb.Append('"'); /// Procedure name
sb.Append(';'); sb.Append((1000 * (wm.TestResult("q3") != null ? wm.TestResult("q3").Qto : 0)).ToString("F0")); /// Q3 nominal
sb.Append(';'); sb.Append((wm.MeterTestResult("adjustment") != null ? wm.MeterTestResult("adjustment").VolumeErrorPct : 99).ToString("F2"));/// Adjustment Error [%]
sb.Append(';'); sb.Append((wm.MeterTestResult("q3") != null ? wm.MeterTestResult("q1").VolumeErrorPct : 99).ToString("F2")); /// Q1 Error [%]
sb.Append(';'); sb.Append((wm.MeterTestResult("q2") != null ? wm.MeterTestResult("q2").VolumeErrorPct : 99).ToString("F2")); /// Q2 Error [%]
sb.Append(';'); sb.Append((wm.MeterTestResult("q1") != null ? wm.MeterTestResult("q3").VolumeErrorPct : 99).ToString("F2")); /// Q3 Error [%]
sb.Append(';'); sb.Append(wm.TestStart.ToShortTimeString());
sb.Append(';'); sb.Append(wm.TestEnd.ToShortTimeString());
report.WriteLine(sb);
}
catch (Exception exc)
{
string msg = exc.Message;
}
}
}
MessageBox.Show("Report saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}