'Custom query' added to ResultsBrowser, default settings updated (IP addr.), ver. 2.25.1422

This commit is contained in:
Milan Hanajik 2020-02-18 09:27:37 +01:00
parent 860e369e35
commit fe758348ba
6 changed files with 349 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2018 Sensus Slovensko a.s. /// Copyright (c) 2018-2020 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.IO; using System.IO;
@ -116,11 +116,11 @@ namespace ResultsBrowser
Bench4 = "WR14"; Bench4 = "WR14";
Bench5 = "WR15"; Bench5 = "WR15";
Bench6 = "PT7"; Bench6 = "PT7";
ConnectionString1 = "SERVER=10.42.128.93; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;"; ConnectionString1 = "SERVER=10.42.130.69; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;";
ConnectionString2 = "SERVER=10.42.128.102; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;"; ConnectionString2 = "SERVER=10.42.129.27; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;";
ConnectionString3 = "SERVER=10.42.128.89; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;"; ConnectionString3 = "SERVER=10.42.128.61; DATABASE=st-wr13-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;";
ConnectionString4 = "SERVER=10.42.128.213; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;"; ConnectionString4 = "SERVER=10.42.130.72; DATABASE=st-wr14-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;";
ConnectionString5 = "SERVER=10.42.128.214; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;"; ConnectionString5 = "SERVER=10.42.130.71; DATABASE=st-wr15-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;";
ConnectionString6 = "SERVER=10.42.129.26; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;"; ConnectionString6 = "SERVER=10.42.129.26; DATABASE=iperlspecial-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;";
Language = "SK"; Language = "SK";
#endif #endif

39
ResultsBrowser/OraData.cs Normal file
View File

@ -0,0 +1,39 @@
using System;
namespace ResultsBrowser
{
public class OraData
{
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 PcbNr; /// VT_ZAEHLER_PD VT_FERNUM
public int TestBenchId;
public string ProgramVer;
public int MaxPruefIx;
public int BatchNr;
public int WMPosition;
public int WMTypeId;
public int WMTypeRev;
public DateTime Start;
public DateTime End;
public int HydrPruefung;
public double AdjErr;
public double AdjErrA4;
public double Q3RlErr;
public double Q3LrErr;
public double Q2RlErr;
public double Q2LrErr;
public double Q1RlErr;
public double Q1LrErr;
public int CalibFactor;
public int CalibFactorLNA;
public double Q2ErrBeforeCorrection; /// VT_IP_ZAEHLER_PINDEX_PD
public bool Q2CorrectionDone; /// VT_IP_ZAEHLER_PINDEX_PD WithQ2Correction
public int Q2CorrectionRl; /// VT_IP_ZAEHLER_PINDEX_PD Q2CORRECTIONLEFT
public int Q2CorrectionLr; /// VT_IP_ZAEHLER_PINDEX_PD Q2CORRECTIONRIGHT
public OraData() { }
}
}

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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.24.1368.0")] [assembly: AssemblyVersion("2.25.1422.0")]
[assembly: AssemblyFileVersion("2.24.1368.0")] [assembly: AssemblyFileVersion("2.25.1422.0")]

View File

@ -179,6 +179,7 @@
<DependentUpon>StatisticsOptionsDlg.cs</DependentUpon> <DependentUpon>StatisticsOptionsDlg.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="LocalSettings.cs" /> <Compile Include="LocalSettings.cs" />
<Compile Include="OraData.cs" />
<Compile Include="Output\Printers\Statistics\StatisticsPrintDocument.cs"> <Compile Include="Output\Printers\Statistics\StatisticsPrintDocument.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>

View File

@ -34,6 +34,7 @@
this.filtersFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); this.filtersFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.resultsGroupBox = new System.Windows.Forms.GroupBox(); this.resultsGroupBox = new System.Windows.Forms.GroupBox();
this.resultsListView = new System.Windows.Forms.ListView(); this.resultsListView = new System.Windows.Forms.ListView();
this.customQueryButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.histogramBtn = new System.Windows.Forms.Button(); this.histogramBtn = new System.Windows.Forms.Button();
this.statisticsBtn = new System.Windows.Forms.Button(); this.statisticsBtn = new System.Windows.Forms.Button();
@ -84,6 +85,7 @@
// //
// vSplitContainer.Panel2 // vSplitContainer.Panel2
// //
this.vSplitContainer.Panel2.Controls.Add(this.customQueryButton);
this.vSplitContainer.Panel2.Controls.Add(this.groupBox1); this.vSplitContainer.Panel2.Controls.Add(this.groupBox1);
this.vSplitContainer.Panel2.Controls.Add(this.outputGroupBox); this.vSplitContainer.Panel2.Controls.Add(this.outputGroupBox);
this.vSplitContainer.Panel2.Controls.Add(this.printerConfigBtn); this.vSplitContainer.Panel2.Controls.Add(this.printerConfigBtn);
@ -158,6 +160,16 @@
this.resultsListView.UseCompatibleStateImageBehavior = false; this.resultsListView.UseCompatibleStateImageBehavior = false;
this.resultsListView.View = System.Windows.Forms.View.Details; this.resultsListView.View = System.Windows.Forms.View.Details;
// //
// customQueryButton
//
this.customQueryButton.Location = new System.Drawing.Point(31, 437);
this.customQueryButton.Name = "customQueryButton";
this.customQueryButton.Size = new System.Drawing.Size(85, 23);
this.customQueryButton.TabIndex = 14;
this.customQueryButton.Text = "Custom query";
this.customQueryButton.UseVisualStyleBackColor = true;
this.customQueryButton.Click += new System.EventHandler(this.customQueryButton_Click);
//
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.histogramBtn); this.groupBox1.Controls.Add(this.histogramBtn);
@ -443,5 +455,6 @@
private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox outputGroupBox; private System.Windows.Forms.GroupBox outputGroupBox;
private System.Windows.Forms.Button histogramBtn; private System.Windows.Forms.Button histogramBtn;
private System.Windows.Forms.Button customQueryButton;
} }
} }

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2016-2019 Sensus Slovensko a.s. /// Copyright (c) 2016-2020 Sensus Slovensko a.s.
/// ///
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -12,6 +12,8 @@ using TBF.BenchControl.Generic;
using TBF.BenchControl.GenericDevices; using TBF.BenchControl.GenericDevices;
using ResultsBrowser.Filters; using ResultsBrowser.Filters;
using ResultsBrowser.Resources; using ResultsBrowser.Resources;
using Oracle;
using Oracle.DataAccess.Client;
namespace ResultsBrowser namespace ResultsBrowser
{ {
@ -32,6 +34,8 @@ namespace ResultsBrowser
static IList<IComponent> tbfComponents; static IList<IComponent> tbfComponents;
static IList<IDevice> tbfDevices; static IList<IDevice> tbfDevices;
OracleConnection oracleConnection; /// Oracle database connection
public ResultsBrowserWnd(string[] args) public ResultsBrowserWnd(string[] args)
{ {
InitializeComponent(); InitializeComponent();
@ -543,5 +547,288 @@ namespace ResultsBrowser
return null; return null;
} }
private void customQueryButton_Click(object sender, EventArgs e)
{
#if IPERL
try
{
bool queryOrders = true; /// true = query orders, false = query PCB numbers
//string[] queryStrings = new string[] { "3137303", "3137301", "3142304", "3137302", "3137300" }; /// 14.2.2020 queryOrders=true
//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[] { "332492620382" };
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)
{
oracleConnection = new OracleConnection("Data Source=STARA01.WORLD;User Id=deltachef;Password=deltachef;");
oracleConnection.Open();
OracleCommand cmd;
if (queryOrders)
{
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 });
}
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 });
}
else
{ /// query result query param.
oraDatas.Add(new OraData() { PO = pcbNrOrOrder, PcbNr = orderOrPcbNr, TestBenchId = testBenchId, MaxPruefIx = maxPruefIx, Prefix = prefix, SN = sn, Suffix = suffix });
}
/// Add this test bench to the list of test benches if it was still missing
if (!testBenches.Contains(testBenchId)) testBenches.Add(testBenchId);
}
dr.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)
{
Console.Write("{0} ", ++counter);
if (counter % 40 == 0) Console.WriteLine();
///
/// Read from VT_ZAEHLER_PINDEX_PD: TestId(ID_WZPRUEFREIHE))
///
OracleCommand cmd = new OracleCommand("select ID_PRUEFSTAND, ID_WZPRUEFREIHE, WT_PLATZ_NR, HYDR_PRUEFUNG from VT_ZAEHLER_PINDEX_PD where VT_FERNUM = :1 AND ANBID = 4 AND WZGUT = 1", oracleConnection);
cmd.Parameters.Add(new OracleParameter { ParameterName = "1", OracleDbType = OracleDbType.Varchar2, Value = oraD.PcbNr });
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = 0;
int testBenchId = dr.GetInt32(i++) % 100;
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 prfix = (dr.GetInt32(i++) % 100);
if (prfix == 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");
counter = 0;
foreach (var testBenchId in testBenches)
{
Console.WriteLine((testBenchId == 8) ? "WR13" : (testBenchId == 9) ? "WR15" : (testBenchId == 10) ? "WR14" : "other");
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;
}
if (!string.IsNullOrEmpty(Results.DB.ConnectionString))
{
ISession session = Results.DB.CreateSession();
foreach (var oraD in oraDatas)
{
if (oraD.TestBenchId == testBenchId)
{
Console.Write("{0} ", ++counter);
if (counter % 40 == 0) Console.WriteLine();
IList<WaterMeter> wms = session.QueryOver<WaterMeter>()
.Where(x => x.SerialNr == oraD.PcbNr)
.And(x => x.Passed)
.List();
if (wms.Count == 1)
{
oraD.CalibFactor = (int)Math.Round(wms[0].CalibFactor);
oraD.CalibFactorLNA = (int)Math.Round(wms[0].CalibFactorLNA);
}
else
{
foreach (var wm in wms)
{
if (wm.Batch.BatchNr == oraD.BatchNr)
{
oraD.CalibFactor = (int)Math.Round(wm.CalibFactor);
oraD.CalibFactorLNA = (int)Math.Round(wm.CalibFactorLNA);
break;
}
}
}
}
}
Console.WriteLine();
session.Close();
}
}
Console.WriteLine("Reading additional data from MySQL");
Console.WriteLine();
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"));
foreach (var oraD in oraDatas)
{
Console.WriteLine(string.Format("{0}; {1}; {2}; =(\"{3}\"); {4}; {5}; {7}; {8}; {9}; {10}; {11}; {12}; {13}; {14}; {15}; {16}; {17}; {18}; {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));
}
Console.WriteLine("CSV data end");
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
#endif
}
} }
} }