2016-08-03 07:59:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows.Forms;
|
2016-08-15 14:54:12 +00:00
|
|
|
|
using Results.Entities;
|
|
|
|
|
|
using NHibernate;
|
2016-08-03 07:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
namespace TBF.Forms
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class UpgradeSelectionDlg : Form
|
|
|
|
|
|
{
|
2016-08-15 14:54:12 +00:00
|
|
|
|
int batchFrom;
|
|
|
|
|
|
int batchTo;
|
|
|
|
|
|
|
2016-08-03 07:59:55 +00:00
|
|
|
|
public UpgradeSelectionDlg()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2016-08-15 14:54:12 +00:00
|
|
|
|
batchFrom = 1;
|
|
|
|
|
|
batchTo = Program.LocalSettings.BatchNr - 1;
|
|
|
|
|
|
|
|
|
|
|
|
textBox1.Text = batchFrom.ToString();
|
|
|
|
|
|
textBox2.Text = batchTo.ToString();
|
2016-08-03 07:59:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void pressureRepresentationButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2016-08-15 14:54:12 +00:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
batchFrom = int.Parse(textBox1.Text);
|
|
|
|
|
|
batchTo = int.Parse(textBox2.Text);
|
|
|
|
|
|
if (batchFrom < 1 || batchFrom > batchTo) throw new Exception();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show("Wrong 'From batch #' or 'To batch #'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-08-03 07:59:55 +00:00
|
|
|
|
if (MessageBox.Show("Are you sure ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
2016-08-15 14:54:12 +00:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ISession session = Results.DB.CreateSession();
|
|
|
|
|
|
|
|
|
|
|
|
IList<Batch> bFrom = session.QueryOver<Batch>().Where(x => (x.BatchNr == batchFrom)).List<Batch>();
|
|
|
|
|
|
IList<Batch> bTo = session.QueryOver<Batch>().Where(x => (x.BatchNr == batchTo)).List<Batch>();
|
|
|
|
|
|
|
|
|
|
|
|
if (bFrom.Count != 1) throw new Exception("No start batch");
|
|
|
|
|
|
if (bTo.Count != 1) throw new Exception("No end batch");
|
|
|
|
|
|
|
|
|
|
|
|
IList<TestRslt> testResults = session.QueryOver<TestRslt>()
|
|
|
|
|
|
.WhereRestrictionOn(x => x.StartTime)
|
|
|
|
|
|
.IsBetween(bFrom[0].StartTime)
|
|
|
|
|
|
.And(bTo[0].EndTime)
|
|
|
|
|
|
.List<TestRslt>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var tr in testResults)
|
|
|
|
|
|
{
|
|
|
|
|
|
Text = string.Format("Batch # = {0}", tr.Batch.BatchNr);
|
|
|
|
|
|
|
|
|
|
|
|
float factor1 = 0.01f;
|
|
|
|
|
|
|
2016-10-18 16:48:20 +00:00
|
|
|
|
tr.PressUpMean *= factor1;
|
2016-08-15 14:54:12 +00:00
|
|
|
|
tr.PressUpStart *= factor1;
|
|
|
|
|
|
tr.PressUpEnd *= factor1;
|
|
|
|
|
|
tr.PressUpMin *= factor1;
|
|
|
|
|
|
tr.PressUpMax *= factor1;
|
|
|
|
|
|
|
2016-10-18 16:48:20 +00:00
|
|
|
|
tr.PressDownMean *= factor1;
|
2016-08-15 14:54:12 +00:00
|
|
|
|
tr.PressDownStart *= factor1;
|
|
|
|
|
|
tr.PressDownEnd *= factor1;
|
|
|
|
|
|
tr.PressDownMin *= factor1;
|
|
|
|
|
|
tr.PressDownMax *= factor1;
|
|
|
|
|
|
|
2016-10-18 16:48:20 +00:00
|
|
|
|
tr.AmbPressMean *= 0.001f;
|
2016-08-15 14:54:12 +00:00
|
|
|
|
|
|
|
|
|
|
session.SaveOrUpdate(tr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
session.Flush();
|
|
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("Upgrade completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(string.Format("Upgrade failed:\r\n{0}", exc.Message),
|
|
|
|
|
|
"Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
}
|
2016-08-03 07:59:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|