189 lines
7.2 KiB
C#
189 lines
7.2 KiB
C#
///
|
|
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
using TracingDB.Entities;
|
|
using Results.Resources;
|
|
using Config.Entities;
|
|
using System.Drawing;
|
|
using System.Windows.Forms.DataVisualization.Charting;
|
|
|
|
namespace Results.Forms
|
|
{
|
|
public partial class MoreWMResultsDlg : Form
|
|
{
|
|
public MoreWMResultsDlg(Results.Entities.WaterMeter wm, IList<ReferenceRecord> refRecords)
|
|
{
|
|
InitializeComponent();
|
|
|
|
Localize();
|
|
|
|
ShowAllResults(wm);
|
|
ShowChart(wm);
|
|
|
|
if (refRecords == null)
|
|
{
|
|
tabControl1.SelectTab(1);
|
|
tabControl1.TabPages.RemoveAt(2);
|
|
}
|
|
else
|
|
{
|
|
tabControl1.SelectTab(2);
|
|
ShowTracingResults(wm, refRecords);
|
|
}
|
|
}
|
|
|
|
|
|
void Localize()
|
|
{
|
|
Text = Strings.Water_meter_results;
|
|
tabControl1.TabPages[0].Text = Strings.All_results;
|
|
tabControl1.TabPages[1].Text = Strings.Graphs;
|
|
tabControl1.TabPages[2].Text = Strings.Production_tracing_results;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Display all results for this water meter in the 1st tab page
|
|
/// </summary>
|
|
/// <param name="wMtr">Water meter entity</param>
|
|
void ShowAllResults(Results.Entities.WaterMeter wMtr)
|
|
{
|
|
// string message;
|
|
// Color commonBackColor = wMtr.GetColorOfResults(false, out message); /// Ony message is used later on
|
|
//#if ORACLE_DB
|
|
// oneWMResultsCtrl.Caption = string.Format("{0} ({1}) {2}", (string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr), (wMtr.Pruefindex % 100), message);
|
|
//#else
|
|
// oneWMResultsCtrl.Caption = string.Format("s/n = {0}", string.IsNullOrEmpty(wMtr.SerialNr) ? string.Empty : wMtr.SerialNr);
|
|
//#endif
|
|
|
|
// IList<Results.WMeterRsltItemSpec> items = Results.WMeterRsltItemSpec.AllItems;
|
|
|
|
// // Header
|
|
// oneWMResultsCtrl.Columns.Add(wMtr.WMPosition.ToString(), 100);
|
|
// int i = 1;
|
|
// foreach (var str in wMtr.GetAllDecoratedTestNames())
|
|
// {
|
|
// oneWMResultsCtrl.Columns.Add(str, 100);
|
|
// i++;
|
|
// }
|
|
|
|
// foreach (var item in items)
|
|
// {
|
|
// ListViewItem lvi = new ListViewItem(item.Name);
|
|
|
|
// foreach (var mtr in wMtr.MeterTestRslts)
|
|
// {
|
|
// if (mtr != null && mtr.IsPilotRslt() && mtr.TestDone && mtr.Publish() != Publish.Never &&
|
|
// mtr.Publish() != Publish.Internal)
|
|
// {
|
|
// string str = item.Print(wMtr, mtr.Name());
|
|
|
|
// string[] texts = str.Split(new char[] { '|' });
|
|
// if (texts.Length == 1)
|
|
// {
|
|
// lvi.SubItems.Add(str);
|
|
// }
|
|
// else if (texts.Length == 2)
|
|
// {
|
|
// Color color = texts[1].Equals("Green") ? Color.Green : (texts[1].Equals("Red") ? Color.Red : Color.White);
|
|
// lvi.UseItemStyleForSubItems = false;
|
|
// lvi.SubItems.Add(texts[0]);
|
|
// lvi.SubItems[lvi.SubItems.Count - 1].BackColor = color;
|
|
// }
|
|
// else
|
|
// {
|
|
// lvi.SubItems.Add(string.Empty);
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// oneWMResultsCtrl.Items.Add(lvi);
|
|
// }
|
|
}
|
|
|
|
|
|
void ShowChart(Results.Entities.WaterMeter wm)
|
|
{
|
|
//chart.ChartAreas[0].AxisX.LabelStyle.Format = "dd.MM.yy";
|
|
//chart.ChartAreas[0].AxisX.Interval = 1;
|
|
//chart.ChartAreas[0].AxisX.IntervalType = ;
|
|
|
|
tabControl1.TabPages[1].Controls.Add(Results.Output.WMChart.GetChart(wm, false));
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Display tracing results in the 3rd tab page
|
|
/// </summary>
|
|
/// <param name="wm">Water meter entity</param>
|
|
/// <param name="refRecords">ReferenceRecord-s from tracing DB</param>
|
|
void ShowTracingResults(Results.Entities.WaterMeter wm, IList<ReferenceRecord> refRecords)
|
|
{
|
|
tracingResultsListView.Columns.Add(Strings.Date_and_time, 110);
|
|
tracingResultsListView.Columns.Add(Strings.Step, 100);
|
|
tracingResultsListView.Columns.Add(Strings.Workplace, 100);
|
|
tracingResultsListView.Columns.Add(Strings.Name, 100);
|
|
tracingResultsListView.Columns.Add(Strings.Result, 70);
|
|
tracingResultsListView.Columns.Add(Strings.Part, 90);
|
|
tracingResultsListView.Columns.Add(Strings.Code, 150);
|
|
tracingResultsListView.Columns.Add(Strings.Workflow, 450);
|
|
|
|
if (refRecords == null || refRecords.Count == 0)
|
|
{
|
|
messageLabel.Text = "V sledovaní výroby nie sú žiadne záznamy";
|
|
}
|
|
else
|
|
{
|
|
Process proc = refRecords[0].Process;
|
|
bool[] isMissing = new bool[proc.Worksteps.Count];
|
|
for (int i = 0; i < isMissing.Length; i++) isMissing[i] = true;
|
|
|
|
foreach (var rr in refRecords)
|
|
{
|
|
tracingResultsListView.Items.Add(new ListViewItem(new string[]
|
|
{
|
|
rr.TimeStamp.ToString("dd.MM.yyyy HH:mm"),
|
|
(rr.Workstep != null) ? rr.Workstep.Name : string.Empty,
|
|
rr.Workplace,
|
|
rr.UserName,
|
|
rr.Result == 0 ? "OK" : "NOK",
|
|
(rr.Workstep != null && rr.Workstep.ReferencePart != null) ? rr.Workstep.ReferencePart.Name : string.Empty,
|
|
rr.Code,
|
|
(rr.Process != null) ? rr.Process.Name : string.Empty,
|
|
}));
|
|
|
|
for (int i = 0; i < isMissing.Length; i++)
|
|
{
|
|
if (proc.Worksteps[i] == rr.Workstep) isMissing[i] = false;
|
|
}
|
|
}
|
|
|
|
string missingWorkplace = null;
|
|
for (int i = 0; i < isMissing.Length; i++)
|
|
{
|
|
if (isMissing[i])
|
|
{
|
|
if (missingWorkplace == null)
|
|
{
|
|
missingWorkplace = proc.Worksteps[i].Name;
|
|
messageLabel.Text = string.Format("Chýba záznam z pracoviska {0}", missingWorkplace);
|
|
}
|
|
else
|
|
{
|
|
messageLabel.Text = string.Format("Chýba záznam z pracoviska {0} aj z nasledujúcich pracovísk", missingWorkplace);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (missingWorkplace == null)
|
|
{
|
|
messageLabel.Text = "Všetko je OK";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|