ResultsBrowser CustomQuery changes, ver. 2.25.1440

This commit is contained in:
Milan Hanajik
2020-03-31 11:12:19 +02:00
parent c77779b8c7
commit 68ce0578e2
12 changed files with 1177 additions and 214 deletions
+39
View File
@@ -0,0 +1,39 @@
using System;
namespace ResultsBrowser
{
/// <summary>
/// Custom query search criteria
/// </summary>
public enum CQCriteria
{
Undefined = 0,
ListOfOrders,
ListOfPcbNumbers,
RangeOfSerialNumbers,
ListOfSerialNumbers,
WZTypeIdAndTimePeriod,
ProducedWithinTimePeriod,
Count,
}
/// <summary>
/// Custom query selection item (combo box items)
/// </summary>
public class CQSelectionItem
{
public CQCriteria CQCriteria;
string queryTypeText;
public CQSelectionItem(CQCriteria queryType, string queryTypeText)
{
this.CQCriteria = queryType;
this.queryTypeText = queryTypeText;
}
public override string ToString()
{
return queryTypeText;
}
}
}
+87
View File
@@ -0,0 +1,87 @@
namespace ResultsBrowser.Forms
{
partial class AddItemForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.itemTextBox = new System.Windows.Forms.TextBox();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// itemTextBox
//
this.itemTextBox.Location = new System.Drawing.Point(33, 33);
this.itemTextBox.Name = "itemTextBox";
this.itemTextBox.Size = new System.Drawing.Size(186, 20);
this.itemTextBox.TabIndex = 0;
//
// okButton
//
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
this.okButton.Location = new System.Drawing.Point(258, 20);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 1;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(258, 49);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 2;
this.cancelButton.Text = "Zrušiť";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// AddItemForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(354, 85);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.itemTextBox);
this.Name = "AddItemForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Pridať položku zoznamu";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox itemTextBox;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ResultsBrowser.Forms
{
public partial class AddItemForm : Form
{
public string ItemText;
public AddItemForm()
{
InitializeComponent();
}
private void okButton_Click(object sender, EventArgs e)
{
ItemText = itemTextBox.Text;
DialogResult = DialogResult.OK;
Close();
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,297 @@
namespace ResultsBrowser.Forms
{
partial class CustomQuerySpecificationForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.queryTypeComboBox = new System.Windows.Forms.ComboBox();
this.queryTypeLabel = new System.Windows.Forms.Label();
this.inputListTextBox = new System.Windows.Forms.TextBox();
this.addToListButton = new System.Windows.Forms.Button();
this.clearListButton = new System.Windows.Forms.Button();
this.inputListGroupBox = new System.Windows.Forms.GroupBox();
this.importFromFileButton = new System.Windows.Forms.Button();
this.timePeriodGroupBox = new System.Windows.Forms.GroupBox();
this.toLabel = new System.Windows.Forms.Label();
this.toDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.fromLabel = new System.Windows.Forms.Label();
this.fromDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.parameterGroupBox = new System.Windows.Forms.GroupBox();
this.parameterValueTextBox = new System.Windows.Forms.TextBox();
this.parameterNameLabel = new System.Windows.Forms.Label();
this.okButton = new System.Windows.Forms.Button();
this.cancelButton = new System.Windows.Forms.Button();
this.destinationFileGroupBox = new System.Windows.Forms.GroupBox();
this.destinationFileButton = new System.Windows.Forms.Button();
this.destinationFileTextBox = new System.Windows.Forms.TextBox();
this.inputListGroupBox.SuspendLayout();
this.timePeriodGroupBox.SuspendLayout();
this.parameterGroupBox.SuspendLayout();
this.destinationFileGroupBox.SuspendLayout();
this.SuspendLayout();
//
// queryTypeComboBox
//
this.queryTypeComboBox.FormattingEnabled = true;
this.queryTypeComboBox.Location = new System.Drawing.Point(136, 27);
this.queryTypeComboBox.Name = "queryTypeComboBox";
this.queryTypeComboBox.Size = new System.Drawing.Size(566, 21);
this.queryTypeComboBox.TabIndex = 1;
this.queryTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.queryTypeComboBox_SelectedIndexChanged);
//
// queryTypeLabel
//
this.queryTypeLabel.AutoSize = true;
this.queryTypeLabel.Location = new System.Drawing.Point(24, 30);
this.queryTypeLabel.Name = "queryTypeLabel";
this.queryTypeLabel.Size = new System.Drawing.Size(96, 13);
this.queryTypeLabel.TabIndex = 0;
this.queryTypeLabel.Text = "Typ vyhľadávania:";
//
// inputListTextBox
//
this.inputListTextBox.Location = new System.Drawing.Point(115, 21);
this.inputListTextBox.Multiline = true;
this.inputListTextBox.Name = "inputListTextBox";
this.inputListTextBox.Size = new System.Drawing.Size(566, 79);
this.inputListTextBox.TabIndex = 3;
//
// addToListButton
//
this.addToListButton.Location = new System.Drawing.Point(22, 21);
this.addToListButton.Name = "addToListButton";
this.addToListButton.Size = new System.Drawing.Size(75, 23);
this.addToListButton.TabIndex = 0;
this.addToListButton.Text = "Pridať";
this.addToListButton.UseVisualStyleBackColor = true;
this.addToListButton.Click += new System.EventHandler(this.addToListButton_Click);
//
// clearListButton
//
this.clearListButton.Location = new System.Drawing.Point(22, 77);
this.clearListButton.Name = "clearListButton";
this.clearListButton.Size = new System.Drawing.Size(75, 23);
this.clearListButton.TabIndex = 2;
this.clearListButton.Text = "Vymazať";
this.clearListButton.UseVisualStyleBackColor = true;
this.clearListButton.Click += new System.EventHandler(this.clearListButton_Click);
//
// inputListGroupBox
//
this.inputListGroupBox.Controls.Add(this.importFromFileButton);
this.inputListGroupBox.Controls.Add(this.inputListTextBox);
this.inputListGroupBox.Controls.Add(this.clearListButton);
this.inputListGroupBox.Controls.Add(this.addToListButton);
this.inputListGroupBox.Location = new System.Drawing.Point(21, 60);
this.inputListGroupBox.Name = "inputListGroupBox";
this.inputListGroupBox.Size = new System.Drawing.Size(692, 114);
this.inputListGroupBox.TabIndex = 2;
this.inputListGroupBox.TabStop = false;
this.inputListGroupBox.Text = "Vstupný zoznam";
//
// importFromFileButton
//
this.importFromFileButton.Location = new System.Drawing.Point(22, 49);
this.importFromFileButton.Name = "importFromFileButton";
this.importFromFileButton.Size = new System.Drawing.Size(75, 23);
this.importFromFileButton.TabIndex = 1;
this.importFromFileButton.Text = "Zo súboru";
this.importFromFileButton.UseVisualStyleBackColor = true;
this.importFromFileButton.Click += new System.EventHandler(this.importFromFileButton_Click);
//
// timePeriodGroupBox
//
this.timePeriodGroupBox.Controls.Add(this.toLabel);
this.timePeriodGroupBox.Controls.Add(this.toDateTimePicker);
this.timePeriodGroupBox.Controls.Add(this.fromLabel);
this.timePeriodGroupBox.Controls.Add(this.fromDateTimePicker);
this.timePeriodGroupBox.Location = new System.Drawing.Point(21, 180);
this.timePeriodGroupBox.Name = "timePeriodGroupBox";
this.timePeriodGroupBox.Size = new System.Drawing.Size(692, 40);
this.timePeriodGroupBox.TabIndex = 3;
this.timePeriodGroupBox.TabStop = false;
this.timePeriodGroupBox.Text = "Časový interval";
//
// toLabel
//
this.toLabel.AutoSize = true;
this.toLabel.Location = new System.Drawing.Point(416, 16);
this.toLabel.Name = "toLabel";
this.toLabel.Size = new System.Drawing.Size(19, 13);
this.toLabel.TabIndex = 2;
this.toLabel.Text = "do";
//
// toDateTimePicker
//
this.toDateTimePicker.Location = new System.Drawing.Point(456, 13);
this.toDateTimePicker.Name = "toDateTimePicker";
this.toDateTimePicker.Size = new System.Drawing.Size(225, 20);
this.toDateTimePicker.TabIndex = 3;
//
// fromLabel
//
this.fromLabel.AutoSize = true;
this.fromLabel.Location = new System.Drawing.Point(128, 17);
this.fromLabel.Name = "fromLabel";
this.fromLabel.Size = new System.Drawing.Size(19, 13);
this.fromLabel.TabIndex = 0;
this.fromLabel.Text = "od";
//
// fromDateTimePicker
//
this.fromDateTimePicker.Location = new System.Drawing.Point(168, 13);
this.fromDateTimePicker.Name = "fromDateTimePicker";
this.fromDateTimePicker.Size = new System.Drawing.Size(225, 20);
this.fromDateTimePicker.TabIndex = 1;
//
// parameterGroupBox
//
this.parameterGroupBox.Controls.Add(this.parameterValueTextBox);
this.parameterGroupBox.Controls.Add(this.parameterNameLabel);
this.parameterGroupBox.Location = new System.Drawing.Point(21, 226);
this.parameterGroupBox.Name = "parameterGroupBox";
this.parameterGroupBox.Size = new System.Drawing.Size(692, 40);
this.parameterGroupBox.TabIndex = 4;
this.parameterGroupBox.TabStop = false;
this.parameterGroupBox.Text = "Parameter";
//
// parameterValueTextBox
//
this.parameterValueTextBox.Location = new System.Drawing.Point(325, 14);
this.parameterValueTextBox.Name = "parameterValueTextBox";
this.parameterValueTextBox.Size = new System.Drawing.Size(68, 20);
this.parameterValueTextBox.TabIndex = 1;
//
// parameterNameLabel
//
this.parameterNameLabel.AutoSize = true;
this.parameterNameLabel.Location = new System.Drawing.Point(128, 17);
this.parameterNameLabel.Name = "parameterNameLabel";
this.parameterNameLabel.Size = new System.Drawing.Size(0, 13);
this.parameterNameLabel.TabIndex = 0;
//
// okButton
//
this.okButton.Location = new System.Drawing.Point(498, 335);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(89, 33);
this.okButton.TabIndex = 6;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// cancelButton
//
this.cancelButton.Location = new System.Drawing.Point(613, 335);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(89, 33);
this.cancelButton.TabIndex = 7;
this.cancelButton.Text = "Zrušiť";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// destinationFileGroupBox
//
this.destinationFileGroupBox.Controls.Add(this.destinationFileButton);
this.destinationFileGroupBox.Controls.Add(this.destinationFileTextBox);
this.destinationFileGroupBox.Location = new System.Drawing.Point(21, 272);
this.destinationFileGroupBox.Name = "destinationFileGroupBox";
this.destinationFileGroupBox.Size = new System.Drawing.Size(692, 50);
this.destinationFileGroupBox.TabIndex = 5;
this.destinationFileGroupBox.TabStop = false;
this.destinationFileGroupBox.Text = "Výsledky zapísať do súboru";
//
// destinationFileButton
//
this.destinationFileButton.Location = new System.Drawing.Point(22, 18);
this.destinationFileButton.Name = "destinationFileButton";
this.destinationFileButton.Size = new System.Drawing.Size(75, 23);
this.destinationFileButton.TabIndex = 0;
this.destinationFileButton.Text = "Vybrať";
this.destinationFileButton.UseVisualStyleBackColor = true;
this.destinationFileButton.Click += new System.EventHandler(this.destinationFileButton_Click);
//
// destinationFileTextBox
//
this.destinationFileTextBox.Location = new System.Drawing.Point(115, 20);
this.destinationFileTextBox.Name = "destinationFileTextBox";
this.destinationFileTextBox.Size = new System.Drawing.Size(566, 20);
this.destinationFileTextBox.TabIndex = 1;
//
// CustomQuerySpecificationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(731, 381);
this.Controls.Add(this.destinationFileGroupBox);
this.Controls.Add(this.cancelButton);
this.Controls.Add(this.okButton);
this.Controls.Add(this.parameterGroupBox);
this.Controls.Add(this.timePeriodGroupBox);
this.Controls.Add(this.inputListGroupBox);
this.Controls.Add(this.queryTypeLabel);
this.Controls.Add(this.queryTypeComboBox);
this.Name = "CustomQuerySpecificationForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Špecifikácia vyhľadávania vodomerov";
this.inputListGroupBox.ResumeLayout(false);
this.inputListGroupBox.PerformLayout();
this.timePeriodGroupBox.ResumeLayout(false);
this.timePeriodGroupBox.PerformLayout();
this.parameterGroupBox.ResumeLayout(false);
this.parameterGroupBox.PerformLayout();
this.destinationFileGroupBox.ResumeLayout(false);
this.destinationFileGroupBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ComboBox queryTypeComboBox;
private System.Windows.Forms.Label queryTypeLabel;
private System.Windows.Forms.TextBox inputListTextBox;
private System.Windows.Forms.Button addToListButton;
private System.Windows.Forms.Button clearListButton;
private System.Windows.Forms.GroupBox inputListGroupBox;
private System.Windows.Forms.Button importFromFileButton;
private System.Windows.Forms.GroupBox timePeriodGroupBox;
private System.Windows.Forms.Label toLabel;
private System.Windows.Forms.DateTimePicker toDateTimePicker;
private System.Windows.Forms.Label fromLabel;
private System.Windows.Forms.DateTimePicker fromDateTimePicker;
private System.Windows.Forms.GroupBox parameterGroupBox;
private System.Windows.Forms.TextBox parameterValueTextBox;
private System.Windows.Forms.Label parameterNameLabel;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.GroupBox destinationFileGroupBox;
private System.Windows.Forms.Button destinationFileButton;
private System.Windows.Forms.TextBox destinationFileTextBox;
}
}
@@ -0,0 +1,141 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Text;
using System.Windows.Forms;
namespace ResultsBrowser.Forms
{
public partial class CustomQuerySpecificationForm : Form
{
public CQCriteria CQCriteria;
public string InputList { get { return inputListSB.ToString(); } }
public int IntParameter { get { return intParameter; } }
public DateTime From { get { return fromDateTimePicker.Value.Date; } }
public DateTime To { get { return toDateTimePicker.Value.Date.AddDays(1).AddTicks(-1); } }
public string DestinationFile
{
get
{
return String.IsNullOrEmpty(destinationFileTextBox.Text)
? string.Format("vysledky_hladania_{0:ddMMyyyy_HHmm}.csv", DateTime.Now)
: destinationFileTextBox.Text;
}
}
StringBuilder inputListSB;
int intParameter;
public CustomQuerySpecificationForm()
{
InitializeComponent();
inputListSB = new StringBuilder();
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ListOfOrders, "Všetky vodomery s číslami objednávok podľa zadaného zoznamu"));
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ListOfPcbNumbers, "Všetky vodomery s číslami PCB podľa zadaného zoznamu"));
//queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.RangeOfSerialNumbers, "Všetky vodomery so sériovými číslami v zadanom rozsahu"));
//queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ListOfSerialNumbers, "Všetky vodomery so sériovými číslami podľa zadaného zoznamu"));
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.WZTypeIdAndTimePeriod, "Všetky vodomery so zadaným WZTypeID vyrobené v zadanom časovom období"));
queryTypeComboBox.Items.Add(new CQSelectionItem(CQCriteria.ProducedWithinTimePeriod, "Všetky vodomery vyrobené v zadanom časovom období"));
queryTypeComboBox.Text = "Všetky vodomery vyrobené v zadanom časovom období";
destinationFileTextBox.Text = string.Format("vysledky_hladania_{0:ddMMyyyy_HHmm}.csv", DateTime.Now);
}
private void queryTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
CQCriteria = CQCriteria.Undefined;
/// Determine selected criteria
foreach (var item in queryTypeComboBox.Items)
{
if (item.ToString() == queryTypeComboBox.Text)
{
CQCriteria = (item as CQSelectionItem).CQCriteria;
break;
}
}
if (CQCriteria == CQCriteria.Undefined)
{
/// No criteria selected
inputListGroupBox.Enabled = false;
return;
}
/// Update UI elements visibility
inputListGroupBox.Enabled = (CQCriteria == CQCriteria.ListOfOrders) ||
(CQCriteria == CQCriteria.ListOfPcbNumbers) ||
(CQCriteria == CQCriteria.ListOfSerialNumbers);
timePeriodGroupBox.Enabled = (CQCriteria == CQCriteria.WZTypeIdAndTimePeriod) ||
(CQCriteria == CQCriteria.ProducedWithinTimePeriod);
if (CQCriteria == CQCriteria.WZTypeIdAndTimePeriod)
{
parameterGroupBox.Enabled = true;
parameterNameLabel.Text = "WZ Type ID";
}
else
{
parameterGroupBox.Enabled = false;
parameterNameLabel.Text = string.Empty;
}
}
private void addToListButton_Click(object sender, EventArgs e)
{
AddItemForm dlg = new AddItemForm();
if (dlg.ShowDialog() == DialogResult.OK)
{
if (inputListSB.Length != 0)
{
inputListSB.Append(",");
}
inputListSB.Append(dlg.ItemText);
inputListTextBox.Text = inputListSB.ToString();
}
}
private void importFromFileButton_Click(object sender, EventArgs e)
{
MessageBox.Show("Zatiaľ nie je naimplementované");
}
private void clearListButton_Click(object sender, EventArgs e)
{
inputListSB.Clear();
inputListTextBox.Text = String.Empty;
}
private void okButton_Click(object sender, EventArgs e)
{
if (parameterGroupBox.Enabled && !int.TryParse(parameterValueTextBox.Text, out intParameter))
{
MessageBox.Show("Parameter je neplatný!");
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void destinationFileButton_Click(object sender, EventArgs e)
{
SaveFileDialog dlg = new SaveFileDialog { FileName = destinationFileTextBox.Text };
if (dlg.ShowDialog() == DialogResult.OK)
{
destinationFileTextBox.Text = dlg.FileName;
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+1 -1
View File
@@ -7,7 +7,7 @@ namespace ResultsBrowser
public string PO; /// VT_ZAEHLER_PD AUFTRAGSNUMMER
public string Prefix; /// VT_ZAEHLER_PD PREFIX
public int SN; /// VT_ZAEHLER_PD ZAEHLERNUMMER
public string Suffix; /// VT_ZAEHLER_PD SUFFIX
//public string Suffix; /// VT_ZAEHLER_PD SUFFIX
public string PcbNr; /// VT_ZAEHLER_PD VT_FERNUM
public int TestBenchId;
public string ProgramVer;
+2 -2
View File
@@ -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.25.1428.0")]
[assembly: AssemblyFileVersion("2.25.1428.0")]
[assembly: AssemblyVersion("2.25.1440.0")]
[assembly: AssemblyFileVersion("2.25.1440.0")]
+19
View File
@@ -130,6 +130,18 @@
<Compile Include="Forms\AddFilterDlg.Designer.cs">
<DependentUpon>AddFilterDlg.cs</DependentUpon>
</Compile>
<Compile Include="Forms\AddItemForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\AddItemForm.Designer.cs">
<DependentUpon>AddItemForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\CustomQuerySpecificationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\CustomQuerySpecificationForm.Designer.cs">
<DependentUpon>CustomQuerySpecificationForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\DatabaseSettingsDlg.cs">
<SubType>Form</SubType>
</Compile>
@@ -186,6 +198,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="FiltersConfig.cs" />
<Compile Include="CQCriteria.cs" />
<Compile Include="Resources\Strings1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@@ -221,6 +234,12 @@
<EmbeddedResource Include="Forms\AddFilterDlg.resx">
<DependentUpon>AddFilterDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\AddItemForm.resx">
<DependentUpon>AddItemForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\CustomQuerySpecificationForm.resx">
<DependentUpon>CustomQuerySpecificationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\DatabaseSettingsDlg.resx">
<DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</EmbeddedResource>
+15
View File
@@ -33,6 +33,7 @@
this.filtersGroupBox = new System.Windows.Forms.GroupBox();
this.filtersFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.resultsGroupBox = new System.Windows.Forms.GroupBox();
this.consoleTextBox = new System.Windows.Forms.TextBox();
this.resultsListView = new System.Windows.Forms.ListView();
this.customQueryButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
@@ -141,6 +142,7 @@
//
// resultsGroupBox
//
this.resultsGroupBox.Controls.Add(this.consoleTextBox);
this.resultsGroupBox.Controls.Add(this.resultsListView);
this.resultsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.resultsGroupBox.Location = new System.Drawing.Point(0, 0);
@@ -150,6 +152,17 @@
this.resultsGroupBox.TabStop = false;
this.resultsGroupBox.Text = "Query results";
//
// consoleTextBox
//
this.consoleTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.consoleTextBox.Location = new System.Drawing.Point(3, 16);
this.consoleTextBox.Multiline = true;
this.consoleTextBox.Name = "consoleTextBox";
this.consoleTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.consoleTextBox.Size = new System.Drawing.Size(834, 409);
this.consoleTextBox.TabIndex = 1;
this.consoleTextBox.Visible = false;
//
// resultsListView
//
this.resultsListView.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -418,6 +431,7 @@
this.hSplitContainer.ResumeLayout(false);
this.filtersGroupBox.ResumeLayout(false);
this.resultsGroupBox.ResumeLayout(false);
this.resultsGroupBox.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.outputGroupBox.ResumeLayout(false);
this.testBenchesGroupBox.ResumeLayout(false);
@@ -456,5 +470,6 @@
private System.Windows.Forms.GroupBox outputGroupBox;
private System.Windows.Forms.Button histogramBtn;
private System.Windows.Forms.Button customQueryButton;
private System.Windows.Forms.TextBox consoleTextBox;
}
}
+301 -211
View File
@@ -551,214 +551,280 @@ namespace ResultsBrowser
private void customQueryButton_Click(object sender, EventArgs e)
{
#if IPERL
Forms.CustomQuerySpecificationForm dlg = new Forms.CustomQuerySpecificationForm();
if (dlg.ShowDialog() != DialogResult.OK) return;
/// dlg contains custom query specification now
resultsListView.Visible = false;
consoleTextBox.Visible = true;
try
{
bool queryOrders = true; /// true = query orders, false = query PCB numbers
//string[] queryStrings = new string[] { "3137300", "3137301", "3137302", "3137303" }; /// 14.2.2020 queryOrders=true 2500 meters
//string[] queryStrings = new string[] { "505494150362", "505494151325", "505494150008", "505494150955", "505494152128" }; /// 18.2.2020 queryOrders=false
string[] queryStrings = new string[] { "3129109", "3129111", "3129113", "3129108", "3129110", "3129112", "3129114", "3129115", "3129107" }; /// 24.2.2020 queryOrders=true
//string[] queryStrings = new string[] { "332491531667", "332491751060", "332491640866" };
int counter;
IList<OraData> oraDatas = new List<OraData>(); /// List of water meters
IList<int> testBenches = new List<int>(); /// List of test benches used to produce water meters
///
/// Get list of water meters satisfying (custom) criteria
///
Console.WriteLine("Collecting water meters");
foreach (var orderOrPcbNr in queryStrings)
if (dlg.CQCriteria == CQCriteria.ListOfOrders || dlg.CQCriteria == CQCriteria.ListOfPcbNumbers || dlg.CQCriteria == CQCriteria.ProducedWithinTimePeriod)
{
oracleConnection = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
oracleConnection.Open();
string[] queryStrings = dlg.InputList.Split(new char[] { ',' });
OracleCommand cmd;
if (queryOrders)
//string[] queryStrings = new string[] { "3137300", "3137301", "3137302", "3137303" }; /// 14.2.2020 queryOrders=true 2500 meters
//string[] queryStrings = new string[] { "505494150362", "505494151325", "505494150008", "505494150955", "505494152128" }; /// 18.2.2020 queryOrders=false
//string[] queryStrings = new string[] { "3129109", "3129111", "3129113", "3129108", "3129110", "3129112", "3129114", "3129115", "3129107" }; /// 24.2.2020 queryOrders=true
//string[] queryStrings = new string[] { "332491531667", "332491751060", "332491640866" };
///
/// Get list of water meters satisfying (custom) criteria
///
consoleTextBox.Text += "Collecting water meters\r\n";
foreach (var queryParam in queryStrings)
{
cmd = new OracleCommand("select VT_FERNUM, MAX_PRUEFINDEX, PREFIX, ZAEHLERNUMMER, SUFFIX from VT_ZAEHLER_PD where AUFTRAGSNUMMER = :1 AND ANBID = 4 order by ZAEHLERNUMMER", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = orderOrPcbNr });
}
else
{
cmd = new OracleCommand("select AUFTRAGSNUMMER, MAX_PRUEFINDEX, PREFIX, ZAEHLERNUMMER, SUFFIX from VT_ZAEHLER_PD where VT_FERNUM = :1 AND ANBID = 4 order by ZAEHLERNUMMER", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = orderOrPcbNr });
}
oracleConnection = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
oracleConnection.Open();
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
string pcbNrOrOrder = dr.GetString(i++);
int maxPruefIx = dr.GetInt32(i++);
int testBenchId = maxPruefIx / 100;
maxPruefIx = maxPruefIx % 100;
string prefix = dr.GetString(i++);
int sn = dr.GetInt32(i++);
string suffix = dr.GetString(i++);
if (sn == -1) continue;
/// Create 'OraData' object and add it to 'oraDatas' list
if (queryOrders)
{ /// query param. query result
oraDatas.Add(new OraData() { PO = orderOrPcbNr, PcbNr = pcbNrOrOrder, TestBenchId = testBenchId, MaxPruefIx = maxPruefIx, Prefix = prefix, SN = sn, Suffix = suffix });
OracleCommand cmd;
if (dlg.CQCriteria == CQCriteria.ListOfOrders)
{
cmd = new OracleCommand("select VT_FERNUM, MAX_PRUEFINDEX, PREFIX, ZAEHLERNUMMER from VT_ZAEHLER_PD where AUFTRAGSNUMMER = :1 AND ANBID = 4 order by ZAEHLERNUMMER", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = queryParam });
}
else if (dlg.CQCriteria == CQCriteria.ListOfPcbNumbers)
{
cmd = new OracleCommand("select AUFTRAGSNUMMER, MAX_PRUEFINDEX, PREFIX, ZAEHLERNUMMER from VT_ZAEHLER_PD where VT_FERNUM = :1 AND ANBID = 4 order by ZAEHLERNUMMER", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = queryParam });
}
else if (dlg.CQCriteria == CQCriteria.ProducedWithinTimePeriod)
{
cmd = new OracleCommand("select VT_FERNUM, MAX_PRUEFINDEX, PREFIX, ZAEHLERNUMMER, AUFTRAGSNUMMER from VT_ZAEHLER_PD where ANBID = 4 and MARK_DATE >= :1 and MARK_DATE <= :2", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.TimeStamp, Value = dlg.From });
cmd.Parameters.Add(new OracleParameter { ParameterName = "2", OracleDbType = OracleDbType.TimeStamp, Value = dlg.To });
}
else
{ /// query result query param.
oraDatas.Add(new OraData() { PO = pcbNrOrOrder, PcbNr = orderOrPcbNr, TestBenchId = testBenchId, MaxPruefIx = maxPruefIx, Prefix = prefix, SN = sn, Suffix = suffix });
{
return;
}
/// Add this test bench to the list of test benches if it was still missing
if (!testBenches.Contains(testBenchId)) testBenches.Add(testBenchId);
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
string queryResult = dr.GetString(i++);
int maxPruefIx = dr.GetInt32(i++);
int testBenchId = maxPruefIx / 100;
maxPruefIx = maxPruefIx % 100;
string prefix = dr.GetString(i++);
int sn = dr.GetInt32(i++);
if (sn == -1) continue;
/// Create 'OraData' object and add it to 'oraDatas' list
if (dlg.CQCriteria == CQCriteria.ListOfOrders)
{ /// query param. query result
oraDatas.Add(new OraData() { PO = queryParam, PcbNr = queryResult, TestBenchId = testBenchId, MaxPruefIx = maxPruefIx, Prefix = prefix, SN = sn });
}
else if (dlg.CQCriteria == CQCriteria.ListOfPcbNumbers)
{ /// query result query param.
oraDatas.Add(new OraData() { PO = queryResult, PcbNr = queryParam, TestBenchId = testBenchId, MaxPruefIx = maxPruefIx, Prefix = prefix, SN = sn });
}
else if (dlg.CQCriteria == CQCriteria.ProducedWithinTimePeriod)
{
string purchaseOrder2 = dr.GetString(i++);
oraDatas.Add(new OraData() { PO = purchaseOrder2, PcbNr = queryResult, TestBenchId = testBenchId, MaxPruefIx = maxPruefIx, Prefix = prefix, SN = sn });
}
else
{
/// This should never happen
MessageBox.Show("Uppps");
return;
}
/// Add this test bench to the list of test benches if it was still missing
if (!testBenches.Contains(testBenchId)) testBenches.Add(testBenchId);
}
dr.Close();
}
dr.Close();
consoleTextBox.Text += "End collecting water meters\r\n";
///
/// Get required information about each water meter
///
consoleTextBox.Text += "Reading additional data from Oracle\r\n";
counter = 0;
foreach (var oraD in oraDatas)
{
consoleTextBox.Text += string.Format("{0} ", ++counter);
if (counter % 25 == 0) consoleTextBox.Text += Environment.NewLine;
///
/// Read from VT_ZAEHLER_PINDEX_PD: TestId(ID_WZPRUEFREIHE))
///
OracleCommand cmd = new OracleCommand("select ID_WZPRUEFREIHE, WT_PLATZ_NR, HYDR_PRUEFUNG from VT_ZAEHLER_PINDEX_PD where VT_FERNUM = :1 AND PRUEFINDEX = :2 AND ANBID = 4 AND WZGUT = 1", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
cmd.Parameters.Add(new OracleParameter { ParameterName = "2", OracleDbType = OracleDbType.Int32, Value = oraD.MaxPruefIx + 100 * oraD.TestBenchId });
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
oraD.BatchNr = dr.GetInt32(i++);
oraD.WMPosition = dr.GetInt32(i++);
oraD.HydrPruefung = dr.GetInt32(i++);
}
dr.Close();
///
/// Read from VT_IP_ZAEHLER_PINDEX_PD: Q2CorrectionRl, Q2CorrectionLr
///
cmd = new OracleCommand("select PRUEFINDEX, WITHQ2CORRECTION, ERRQ2, Q2CORRECTIONLEFT, Q2CORRECTIONRIGHT from VT_IP_ZAEHLER_PINDEX_PD where VT_FERNUM = :1 AND ANBID = 4", oracleConnection);
/// pruefindex, Q2_correction_RL, Q2_correction_LR, Q2_error_before_correction
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
int pruefindex = (dr.GetInt32(i++) % 100);
if (pruefindex == oraD.MaxPruefIx)
{
oraD.Q2CorrectionDone = (dr.GetInt32(i++) != 0);
oraD.Q2ErrBeforeCorrection = dr.GetDouble(i++);
oraD.Q2CorrectionRl = dr.GetInt32(i++);
oraD.Q2CorrectionLr = dr.GetInt32(i++);
}
}
dr.Close();
///
/// Read data from VT_PRUEFREIHE_PD
///
cmd = new OracleCommand("select ID_WZTYP, REV_WZTYP, STARTDATUMZEIT, ENDDATUMZEIT, PROGRAMMVERSION from VT_PRUEFREIHE_PD where ID_PRUEFSTAND = :1 AND ID_WzPruefreihe = :2 AND ANBID = 4", oracleConnection);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 18000 + oraD.TestBenchId });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = oraD.BatchNr });
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
oraD.WMTypeId = dr.GetInt32(i++);
oraD.WMTypeRev = dr.GetInt32(i++);
oraD.Start = dr.GetDateTime(i++);
oraD.End = dr.GetDateTime(i++);
oraD.ProgramVer = dr.GetString(i++);
}
dr.Close();
///
/// Read data from VT_PRUEFREIHE_IST_PD
///
/// testID, flow, rel.err., passed
cmd = new OracleCommand("select PRUEFUNGSNR, Q_WZ, Q_FEHLER, Q_BEST from VT_PRUEFREIHE_IST_PD where VT_FERNUM = :1 AND PRUEFINDEX = :2 AND ANBID = 4", oracleConnection);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 100 * oraD.TestBenchId + oraD.MaxPruefIx });
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
int testId = dr.GetInt32(i++); /// PRUEFUNGSNR
double flow = dr.GetDouble(i++); /// Q_WZ
double error = dr.GetDouble(i++); /// Q_FEHLER
bool testPassed = (dr.GetInt32(i++) != 0);
/// SUEZ specific
switch (testId)
{
case -2:
oraD.AdjErrA4 = error;
break;
case -1:
oraD.AdjErr = error;
break;
case 5:
oraD.Q3LrErr = error;
break;
case 10:
oraD.Q3RlErr = error;
break;
default:
break;
}
}
dr.Close();
} /// end of foreach (var oraD in OraDatas)
consoleTextBox.Text += "End reading additional data from Oracle\r\n";
oracleConnection.Close();
}
Console.WriteLine("Collecting water meters completed");
Console.WriteLine();
///
/// Get required information about each water meter
///
Console.WriteLine("Reading additional data from Oracle");
int counter = 0;
foreach (var oraD in oraDatas)
else if (dlg.CQCriteria == CQCriteria.WZTypeIdAndTimePeriod)
{
Console.Write("{0} ", ++counter);
if (counter % 40 == 0) Console.WriteLine();
}
else
{
MessageBox.Show("Query is not supported yet");
return;
}
///
/// Read from VT_ZAEHLER_PINDEX_PD: TestId(ID_WZPRUEFREIHE))
///
OracleCommand cmd = new OracleCommand("select ID_WZPRUEFREIHE, WT_PLATZ_NR, HYDR_PRUEFUNG from VT_ZAEHLER_PINDEX_PD where VT_FERNUM = :1 AND PRUEFINDEX = :2 AND ANBID = 4 AND WZGUT = 1", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
cmd.Parameters.Add(new OracleParameter { ParameterName = "2", OracleDbType = OracleDbType.Int32, Value = oraD.MaxPruefIx + 100 * oraD.TestBenchId });
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
oraD.BatchNr = dr.GetInt32(i++);
oraD.WMPosition = dr.GetInt32(i++);
oraD.HydrPruefung = dr.GetInt32(i++);
}
dr.Close();
///
/// Read from VT_IP_ZAEHLER_PINDEX_PD: Q2CorrectionRl, Q2CorrectionLr
///
cmd = new OracleCommand("select PRUEFINDEX, WITHQ2CORRECTION, ERRQ2, Q2CORRECTIONLEFT, Q2CORRECTIONRIGHT from VT_IP_ZAEHLER_PINDEX_PD where VT_FERNUM = :1 AND ANBID = 4", oracleConnection);
/// pruefindex, Q2_correction_RL, Q2_correction_LR, Q2_error_before_correction
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
int pruefindex = (dr.GetInt32(i++) % 100);
if (pruefindex == oraD.MaxPruefIx)
{
oraD.Q2CorrectionDone = (dr.GetInt32(i++) != 0);
oraD.Q2ErrBeforeCorrection = dr.GetDouble(i++);
oraD.Q2CorrectionRl = dr.GetInt32(i++);
oraD.Q2CorrectionLr = dr.GetInt32(i++);
}
}
dr.Close();
///
/// Read data from VT_PRUEFREIHE_PD
///
cmd = new OracleCommand("select ID_WZTYP, REV_WZTYP, STARTDATUMZEIT, ENDDATUMZEIT, PROGRAMMVERSION from VT_PRUEFREIHE_PD where ID_PRUEFSTAND = :1 AND ID_WzPruefreihe = :2 AND ANBID = 4", oracleConnection);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 18000 + oraD.TestBenchId });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = oraD.BatchNr });
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
oraD.WMTypeId = dr.GetInt32(i++);
oraD.WMTypeRev = dr.GetInt32(i++);
oraD.Start = dr.GetDateTime(i++);
oraD.End = dr.GetDateTime(i++);
oraD.ProgramVer = dr.GetString(i++);
}
dr.Close();
///
/// Read data from VT_PRUEFREIHE_IST_PD
///
/// testID, flow, rel.err., passed
cmd = new OracleCommand("select PRUEFUNGSNR, Q_WZ, Q_FEHLER, Q_BEST from VT_PRUEFREIHE_IST_PD where VT_FERNUM = :1 AND PRUEFINDEX = :2 AND ANBID = 4", oracleConnection);
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
cmd.Parameters.Add(new OracleParameter { OracleDbType = OracleDbType.Int32, Value = 100 * oraD.TestBenchId + oraD.MaxPruefIx });
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
int testId = dr.GetInt32(i++); /// PRUEFUNGSNR
double flow = dr.GetDouble(i++); /// Q_WZ
double error = dr.GetDouble(i++); /// Q_FEHLER
bool testPassed = (dr.GetInt32(i++) != 0);
/// SUEZ specific
switch (testId)
{
case -2:
oraD.AdjErrA4 = error;
break;
case -1:
oraD.AdjErr = error;
break;
case 5:
oraD.Q3LrErr = error;
break;
case 10:
oraD.Q3RlErr = error;
break;
default:
break;
}
}
dr.Close();
} /// end of foreach (var oraD in OraDatas)
Console.WriteLine();
Console.WriteLine("Reading additional data from Oracle completed");
Console.WriteLine();
oracleConnection.Close();
Console.WriteLine("Reading additional data from MySQL");
consoleTextBox.Text += "Reading additional data from MySQL\r\n";
counter = 0;
foreach (var testBenchId in testBenches)
{
Console.WriteLine((testBenchId == 8) ? "WR13" : (testBenchId == 9) ? "WR15" : (testBenchId == 10) ? "WR14" : "other");
if (testBenchId == 4)
{
/// Skip WR9
continue;
}
consoleTextBox.Text += string.Format("{0}\r\n", GetBenchName(testBenchId));
#if false
/// Local database copies
switch (testBenchId)
{
case 8:
Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr13-r; UID=root; PASSWORD=kraken; CharSet=utf8;";
break;
case 9:
Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr15-r; UID=root; PASSWORD=kraken; CharSet=utf8;";
break;
case 10:
Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr14-r; UID=root; PASSWORD=kraken; CharSet=utf8;";
break;
default:
Results.DB.ConnectionString = string.Empty;
break;
case 5: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr10-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 6: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr11-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 8: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr13-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 9: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr15-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 10: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr14-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 11: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr18-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 12: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr19-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 13: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr20-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
case 14: Results.DB.ConnectionString = "SERVER=localhost; DATABASE=st-wr21-r; UID=root; PASSWORD=kraken; CharSet=utf8;"; break;
default: Results.DB.ConnectionString = string.Empty; break;
}
#else
/// Test bench databases
switch (testBenchId)
{
case 5: Results.DB.ConnectionString = "SERVER=10.42.130.69; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 6: Results.DB.ConnectionString = "SERVER=10.42.129.27; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 8: Results.DB.ConnectionString = "SERVER=10.42.128.61; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 9: Results.DB.ConnectionString = "SERVER=10.42.130.71; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 10: Results.DB.ConnectionString = "SERVER=10.42.130.72; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 11: Results.DB.ConnectionString = "SERVER=10.42.130.165; DATABASE=st-wr18-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 12: Results.DB.ConnectionString = "SERVER=10.42.128.159; DATABASE=st-wr19-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 13: Results.DB.ConnectionString = "SERVER=10.42.130.76; DATABASE=st-wr20-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
case 14: Results.DB.ConnectionString = "SERVER=10.42.128.201; DATABASE=st-wr21-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CharSet=utf8;"; break;
default: Results.DB.ConnectionString = string.Empty; break;
}
#endif
if (!string.IsNullOrEmpty(Results.DB.ConnectionString))
{
ISession session = Results.DB.CreateSession();
ISession session = null;
foreach (var oraD in oraDatas)
{
if (oraD.TestBenchId == testBenchId)
{
Console.Write("{0} ", ++counter);
if (counter % 40 == 0) Console.WriteLine();
if (session == null)
{
/// The first water meter produced on this test bench => create a database session
session = Results.DB.CreateSession();
}
consoleTextBox.Text += string.Format("{0} ", ++counter);
if (counter % 25 == 0) consoleTextBox.Text += "\r\n";
IList<WaterMeter> wms = session.QueryOver<WaterMeter>()
.Where(x => x.SerialNr == oraD.PcbNr)
@@ -785,52 +851,76 @@ namespace ResultsBrowser
}
}
Console.WriteLine();
consoleTextBox.Text += Environment.NewLine;
session.Close();
if (session != null) session.Close();
}
}
Console.WriteLine("Reading additional data from MySQL");
Console.WriteLine();
consoleTextBox.Text += "End reading additional data from MySQL\r\n";
Console.WriteLine("CSV data begin");
Console.WriteLine(string.Format("PO; prefix; S/N; PcbNr; Bench; Batch; Start; Start; End; End; Pos; AdjA0; AdjA4; Q3RL; Q3LR; CalF; CAlF_LNA; HP; Q2cRL; Q2cLR"));
//Console.WriteLine(string.Format("s/n;PCB nr.;bench;batch;position;Err. at 640 l/h;Err. LNA at 640 l/h;Err. Q3 RL;Err. Q3 LR;Cal.f.;Cal.f.LNA;Q2 corr.f. RL;Q2 corr.f. LR"));
foreach (var oraD in oraDatas)
consoleTextBox.Text += "CSV data begin\r\n";
using (TextWriter writer = new StreamWriter(dlg.DestinationFile))
{
Console.WriteLine(string.Format("{0}; {1}; {2}; =(\"{3}\"); {4}; {5}; {7}; {8}; {9}; {10};{11};{12};{13};{14};{15};{16};{17};{18};{19};{20}",
//Console.WriteLine(string.Format("{2};=(\"{3}\"); {4};{5};{11};{12};{13};{14};{15};{16};{17};{19};{20}",
/* 0 */ oraD.PO,
/* 1 */ oraD.Prefix,
/* 2 */ oraD.SN,
/* 3 */ oraD.PcbNr,
/* 4 */ (oraD.TestBenchId == 8) ? "WR13" : (oraD.TestBenchId == 9) ? "WR15" : (oraD.TestBenchId == 10) ? "WR14" : "other",
/* 5 */ oraD.BatchNr,
/* 6 */ oraD.ProgramVer,
/* 7 */ oraD.Start.ToShortDateString(),
/* 8 */ oraD.Start.ToShortTimeString(),
/* 9 */ oraD.End.ToShortDateString(),
/* 10 */ oraD.End.ToShortTimeString(),
/* 11 */ oraD.WMPosition,
/* 12 */ oraD.AdjErr.ToString("F2"),
/* 13 */ oraD.AdjErrA4.ToString("F2"),
/* 14 */ oraD.Q3RlErr.ToString("F2"),
/* 15 */ oraD.Q3LrErr.ToString("F2"),
/* 16 */ oraD.CalibFactor,
/* 17 */ oraD.CalibFactorLNA,
/* 18 */ oraD.HydrPruefung,
/* 19 */ oraD.Q2CorrectionRl,
/* 20 */ oraD.Q2CorrectionLr,
/* 21 */ oraD.WMTypeId,
/* 22 */ oraD.WMTypeRev));
writer.WriteLine(string.Format("PO; prefix; S/N; PcbNr; Bench; Batch; Start; Start; End; End; Pos; AdjA0; AdjA4; Q3RL; Q3LR; CalF; CAlF_LNA; HP; Q2cRL; Q2cLR"));
//Console.WriteLine(string.Format("s/n;PCB nr.;bench;batch;position;Err. at 640 l/h;Err. LNA at 640 l/h;Err. Q3 RL;Err. Q3 LR;Cal.f.;Cal.f.LNA;Q2 corr.f. RL;Q2 corr.f. LR"));
foreach (var oraD in oraDatas)
{
writer.WriteLine(string.Format("{0}; {1}; {2}; =(\"{3}\"); {4}; {5}; {7}; {8}; {9}; {10};{11};{12};{13};{14};{15};{16};{17};{18};{19};{20}",
//Console.WriteLine(string.Format("{2};=(\"{3}\"); {4};{5};{11};{12};{13};{14};{15};{16};{17};{19};{20}",
/* 0 */ oraD.PO,
/* 1 */ oraD.Prefix,
/* 2 */ oraD.SN,
/* 3 */ oraD.PcbNr,
/* 4 */ GetBenchName(oraD.TestBenchId),
/* 5 */ oraD.BatchNr,
/* 6 */ oraD.ProgramVer,
/* 7 */ oraD.Start.ToShortDateString(),
/* 8 */ oraD.Start.ToShortTimeString(),
/* 9 */ oraD.End.ToShortDateString(),
/* 10 */ oraD.End.ToShortTimeString(),
/* 11 */ oraD.WMPosition,
/* 12 */ oraD.AdjErr.ToString("F2"),
/* 13 */ oraD.AdjErrA4.ToString("F2"),
/* 14 */ oraD.Q3RlErr.ToString("F2"),
/* 15 */ oraD.Q3LrErr.ToString("F2"),
/* 16 */ oraD.CalibFactor,
/* 17 */ oraD.CalibFactorLNA,
/* 18 */ oraD.HydrPruefung,
/* 19 */ oraD.Q2CorrectionRl,
/* 20 */ oraD.Q2CorrectionLr,
/* 21 */ oraD.WMTypeId,
/* 22 */ oraD.WMTypeRev));
}
}
Console.WriteLine("CSV data end");
consoleTextBox.Text += "CSV data end\r\n";
MessageBox.Show(string.Format("Výsledky boli zapísané do súboru\r\n{0}", dlg.DestinationFile));
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
#else
MessageBox.Show("Not implemented");
#endif
}
}
string GetBenchName(int testBenchId)
{
switch (testBenchId)
{
case 4: return "WR9";
case 5: return "WR10";
case 6: return "WR11";
case 8: return "WR13";
case 9: return "WR15";
case 10: return "WR14";
case 11: return "WR18";
case 12: return "WR19";
case 13: return "WR20";
case 14: return "WR21";
default: return string.Empty;
}
}
}
}