Statistics : First working version, ver. 2.18.1104

This commit is contained in:
Milan Hanajik 2018-12-19 12:23:41 +01:00
parent 76042756b1
commit 6b803444f0
13 changed files with 406 additions and 15 deletions

View File

@ -0,0 +1,64 @@
namespace Statistics.Forms
{
partial class ModelessForm
{
/// <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.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(47, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// ModelessForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(191, 56);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "ModelessForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ModelessForm";
this.Load += new System.EventHandler(this.ModelessForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Statistics.Forms
{
public partial class ModelessForm : Form
{
/// <summary>
/// Called from the state machine when an operation forces a modeless dialog close.
/// </summary>
public static void CloseForm()
{
if (CloseFormHandler == null) return;
try { CloseFormHandler(null, null); }
catch (Exception) { }
}
public static event EventHandler<EventArgs> CloseFormHandler;
void OnCloseForm(object sender, EventArgs args)
{
DialogResult = DialogResult.Cancel;
Close();
}
public string Title;
public string Message;
public Color BackgroundColor;
public Color TextColor;
public Font TextFont;
public string FontFamily;
public int FontSize;
public FontStyle FontStyle;
/// <summary>
/// Constructor to be used by the application
/// </summary>
/// <param name="title">Window title</param>
/// <param name="message">Displayed message</param>
public ModelessForm()
{
InitializeComponent();
ControlBox = false;
CloseFormHandler += delegate(object sender, EventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnCloseForm), sender, args); }
else OnCloseForm(sender, args);
};
}
private void ModelessForm_Load(object sender, EventArgs e)
{
if (Title != null) Text = Title;
if (Message != null) label1.Text = Message;
if (BackgroundColor != null) BackColor = BackgroundColor;
if (TextColor != null) ForeColor = TextColor;
if (FontFamily != null) label1.Font = new Font(FontFamily, FontSize, FontStyle);
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
Width = (int)textWidth + 120; /// Form width calculated from the text width
Height += (int)textHeight; /// Form height calculated from the text height
}
}
}

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>

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.18.1088.0")]
[assembly: AssemblyFileVersion("2.18.1088.0")]
[assembly: AssemblyVersion("2.18.1104.0")]
[assembly: AssemblyFileVersion("2.18.1104.0")]

View File

@ -78,6 +78,15 @@ namespace Statistics.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to searching....
/// </summary>
internal static string searching_ {
get {
return ResourceManager.GetString("searching_", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Statistics.
/// </summary>

View File

@ -123,6 +123,9 @@
<data name="From" xml:space="preserve">
<value>From</value>
</data>
<data name="searching_" xml:space="preserve">
<value>searching...</value>
</data>
<data name="Statistics" xml:space="preserve">
<value>Statistics</value>
</data>

View File

@ -123,6 +123,9 @@
<data name="From" xml:space="preserve">
<value>Od</value>
</data>
<data name="searching_" xml:space="preserve">
<value>hľadám...</value>
</data>
<data name="Statistics" xml:space="preserve">
<value>Štatistiky</value>
</data>

View File

@ -49,6 +49,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -59,6 +60,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Forms\ModelessForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ModelessForm.designer.cs">
<DependentUpon>ModelessForm.cs</DependentUpon>
</Compile>
<Compile Include="Resources\Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
@ -85,6 +92,9 @@
<Compile Include="UserControls\StatisticsCtrl.Designer.cs">
<DependentUpon>StatisticsCtrl.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Forms\ModelessForm.resx">
<DependentUpon>ModelessForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>

View File

@ -14,6 +14,8 @@ using Results;
using Results.Entities;
using Statistics.Resources;
using Statistics.UserControls;
using System.Threading;
using System.Globalization;
namespace Statistics
{
@ -21,7 +23,7 @@ namespace Statistics
{
static string[] testBenchNames = new string[] { "WR10", "WR11", "WR13", "WR14", "WR15", "PT7" };
///
#if false
#if true
static string[] connectionStrings = new string[] {
"SERVER=10.42.128.197; DATABASE=st-wr10-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR10
"SERVER=10.42.128.98; DATABASE=st-wr11-r; UID=vysledky; PASSWORD=GAqx76QUB6NbnpZP; CHARSET=utf8;", /// WR11
@ -120,7 +122,7 @@ namespace Statistics
}
public void UpdateRequest(int benchId, MidId midId)
public IList<TestRslt> UpdateRequest(int benchId, MidId midId)
{
if (benchId >= sessionFactories.Length || sessionFactories[benchId] == null || (midId == MidId.WaterMeters))
{
@ -132,9 +134,22 @@ namespace Statistics
{
MessageBox.Show(string.Format("Cannot load statistics of {0}", (benchId < testBenchNames.Length) ? testBenchNames[benchId] : "XY"));
}
return;
return null;
}
Thread thread = new Thread(() => Application.Run(new Forms.ModelessForm()
{
Title = string.Empty,
Message = Strings.searching_,
BackgroundColor = Color.LightGreen,
FontFamily = "Arial",
FontSize = 14,
FontStyle = FontStyle.Regular,
}));
thread.CurrentCulture = CultureInfo.CurrentCulture;
thread.CurrentUICulture = CultureInfo.CurrentUICulture;
thread.Start();
try
{
ISession session = sessionFactories[benchId].OpenSession();
@ -151,11 +166,15 @@ namespace Statistics
foreach (var tr in listOfRslts) testRslts.Add(tr);
}
Forms.ModelessForm.CloseForm();
session.Close();
return testRslts;
}
catch (Exception exc)
{
Forms.ModelessForm.CloseForm();
MessageBox.Show(string.Format("Error loading statistics of {0}\r\n{1}", (benchId < testBenchNames.Length) ? testBenchNames[benchId] : "XY", exc.Message));
return null;
}
}
}

View File

@ -6,6 +6,7 @@ using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Results.Entities;
using Statistics.Resources;
namespace Statistics.UserControls
@ -46,9 +47,9 @@ namespace Statistics.UserControls
}
public void UpdateRequest(int benchId)
public IList<TestRslt> UpdateRequest(int benchId)
{
Parent.UpdateRequest(benchId, MidId);
return Parent.UpdateRequest(benchId, MidId);
}

View File

@ -28,27 +28,94 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.updateButton = new System.Windows.Forms.Button();
this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.exportButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// updateButton
//
this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.updateButton.Location = new System.Drawing.Point(255, 11);
this.updateButton.Location = new System.Drawing.Point(3, 7);
this.updateButton.Name = "updateButton";
this.updateButton.Size = new System.Drawing.Size(122, 43);
this.updateButton.Size = new System.Drawing.Size(101, 43);
this.updateButton.TabIndex = 4;
this.updateButton.Text = "Update";
this.updateButton.Text = "Update data";
this.updateButton.UseVisualStyleBackColor = true;
this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
//
// chart1
//
chartArea1.Name = "ChartArea1";
this.chart1.ChartAreas.Add(chartArea1);
this.chart1.Dock = System.Windows.Forms.DockStyle.Fill;
legend1.Name = "Legend1";
this.chart1.Legends.Add(legend1);
this.chart1.Location = new System.Drawing.Point(0, 0);
this.chart1.Name = "chart1";
series1.ChartArea = "ChartArea1";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
series1.Color = System.Drawing.Color.ForestGreen;
series1.Legend = "Legend1";
series1.Name = "Error";
this.chart1.Series.Add(series1);
this.chart1.Size = new System.Drawing.Size(470, 381);
this.chart1.TabIndex = 5;
this.chart1.Text = "chart1";
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.chart1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.exportButton);
this.splitContainer1.Panel2.Controls.Add(this.updateButton);
this.splitContainer1.Size = new System.Drawing.Size(577, 381);
this.splitContainer1.SplitterDistance = 470;
this.splitContainer1.SplitterWidth = 1;
this.splitContainer1.TabIndex = 6;
//
// exportButton
//
this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.exportButton.Location = new System.Drawing.Point(3, 56);
this.exportButton.Name = "exportButton";
this.exportButton.Size = new System.Drawing.Size(101, 43);
this.exportButton.TabIndex = 5;
this.exportButton.Text = "Export";
this.exportButton.UseVisualStyleBackColor = true;
this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
//
// StatisticsCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.updateButton);
this.Controls.Add(this.splitContainer1);
this.Name = "StatisticsCtrl";
this.Size = new System.Drawing.Size(388, 242);
this.Size = new System.Drawing.Size(577, 381);
((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -56,5 +123,8 @@
#endregion
private System.Windows.Forms.Button updateButton;
private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button exportButton;
}
}

View File

@ -6,6 +6,8 @@ using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using Results.Entities;
namespace Statistics.UserControls
{
@ -17,11 +19,33 @@ namespace Statistics.UserControls
public StatisticsCtrl()
{
InitializeComponent();
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dd.MM.yy";
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Days;
}
private void updateButton_Click(object sender, EventArgs e)
{
if (BenchesCtrl != null) BenchesCtrl.UpdateRequest(Id);
if (BenchesCtrl != null)
{
IList<TestRslt> results = BenchesCtrl.UpdateRequest(Id);
if (results != null)
{
foreach (var r in results)
{
chart1.Series["Error"].Points.AddXY(r.StartTime, r.ErrorMaster);
}
return;
}
}
chart1.Series["Error"].Points.Clear();
}
private void exportButton_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.18.1103.0")]
[assembly: AssemblyFileVersion("2.18.1103.0")]
[assembly: AssemblyVersion("2.18.1104.0")]
[assembly: AssemblyFileVersion("2.18.1104.0")]