Cevak results printer modifications, ver. 2.2.227.

This commit is contained in:
Milan Hanajik 2016-02-23 15:16:43 +01:00
parent 087870b1ec
commit cc789ee7e0
12 changed files with 211 additions and 172 deletions

View File

@ -72,8 +72,8 @@ namespace Config.Entities
{
Procedure result = new Procedure();
result.ItemNr = ItemNr;
result.Name = Name;
result.MetersKind = MetersKind;
result.Description = Description;
result.CreationUser = CreationUser;
result.CreationTime = CreationTime;
@ -81,10 +81,15 @@ namespace Config.Entities
result.LastChgTime = LastChgTime;
result.LongDescription = LongDescription;
result.ProcedureState = ProcedureState.Active;
result.ProcedureState = ProcedureState;
result.Revision = Revision;
result.PredecessorId = Id;
result.ObtainedByCopy = ObtainedByCopy;
result.MetersKind = MetersKind;
result.Watermeters = Watermeters;
result.ProtocolTitle = ProtocolTitle;
result.DataEntry = DataEntry;
result.ResultsPrinter = ResultsPrinter;
result.ResultsWriter = ResultsWriter;

View File

@ -42,6 +42,7 @@ namespace Results
UserName = user,
ProcedureName = procedure.Name,
ProcedureDescription = procedure.Description,
WatermetersStr = procedure.Watermeters,
ProcedureRevision = procedure.Revision,
ProtocolTitle = procedure.ProtocolTitle,
StartTime = DateTime.Now,

View File

@ -14,8 +14,9 @@ namespace Results.Entities
public virtual string ProgramVersion { get; set; }
public virtual string UserName { get; set; }
public virtual string ProcedureName { get; set; }
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
public virtual string ProcedureDescription { get; set; } /// CEVAK, not mapped to DB
public virtual int ProcedureRevision { get; set; }
public virtual string WatermetersStr { get; set; } /// CEVAK, not mapped to DB
public virtual string ProtocolTitle { get; set; }
public virtual float Custom1 { get; set; }
public virtual float Custom2 { get; set; }
@ -27,7 +28,7 @@ namespace Results.Entities
public virtual IList<TestData> Tests { get; set; }
public virtual IList<WaterMeter> WaterMeters { get; set; }
public virtual IList<TestRslt> TestRslts { get; set; }
public virtual bool Compound { get; set; } /// Not mapped to DB now
public virtual bool Compound { get; set; } /// Not mapped to DB now
public Batch()
{

View File

@ -76,7 +76,7 @@ namespace TBF.BenchControl
{
if (measuredVolume <= float.Epsilon)
{
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, 0);
log.WarnFormat("ErrorFromVolumes({0},{1}) returns {2}", measuredVolume, trueVolume, 99.0);
return 99.0;
}

View File

@ -11,17 +11,34 @@ using TBF.Resources;
namespace TBF.BenchControl.ResultsPrinters.Cevak
{
enum DocumentSection
{
FirstPage,
OtherPages,
Appendix1,
Appendix2,
Count,
}
public class PrintDocumentCevak : PrintDocument
{
const string FontFamilyName = "Arial"; //"Times New Roman";
const int SpacingOne = 18;
const int SpacingOneAndHalf = (3 * SpacingOne) / 2;
const int TitleX = 100;
readonly int topMargin;
readonly int bottomMargin;
readonly int leftMargin;
readonly int TitleX;
readonly int TitleY; /// Depends on the size of the header
readonly int HdrTop; /// = TitleY + 60
readonly int BodyTop; /// = HdrTop + 160
/// Size of the printed area without margins, after taking into account 'pageOrientation'
int printHeight;
int printWidth;
/// <summary>
/// Property variable for the Font the user wishes to use
/// </summary>
@ -43,20 +60,21 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
///
/// Layout and status
///
DocumentSection documentSection;
int nrWMsOnFirstPage;
int nrWMsOnNextPage;
int nextWMNr; /// nr. of watermeter to be printed as the first one on the next page
int nrPages;
int pageNr; /// Page number to be printed at the bottom of the page
/// <summary>
/// Constructor
/// </summary>
/// <param name="textToPrint">Text to be printed</param>
public PrintDocumentCevak(Results.Entities.Batch batch,
PageOrientation pageOrientation,
int topMrgn,
int topMargin, int bottomMargin, int leftMargin,
TBF.BenchControl.BenchInfo.Polska.Component benchInfo)
{
this.batch = batch;
@ -64,9 +82,14 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape);
TitleY = topMrgn; /// Depends on the size of the header
this.topMargin = topMargin;
this.bottomMargin = bottomMargin;
this.leftMargin = leftMargin;
TitleX = leftMargin;
TitleY = topMargin; /// Depends on the size of the header
HdrTop = TitleY + 60;
BodyTop = HdrTop + 230;
BodyTop = HdrTop + 250;
if (batch.WaterMeters[0].Compound())
{
@ -77,19 +100,16 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
rsltItems = Results.ItemSpec.FromStrArray(Program.LocalSettings.RsltItems_Printer_SingleWM);
}
/// Set print area size and margins (in dots using 80 dpi)
int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
/// Check if the user selected to print in Landscape mode
/// if they did then we need to swap height/width parameters
/// Set print area size and margins (in dots using 100 dpi)
if (DefaultPageSettings.Landscape)
{
int tmp = printHeight;
printHeight = printWidth;
printWidth = tmp;
printHeight = base.DefaultPageSettings.PaperSize.Width - topMargin - bottomMargin;
printWidth = base.DefaultPageSettings.PaperSize.Height - leftMargin - leftMargin;
}
else
{
printHeight = base.DefaultPageSettings.PaperSize.Height - topMargin - bottomMargin;
printWidth = base.DefaultPageSettings.PaperSize.Width - leftMargin - leftMargin;
}
int testsCount = batch.WaterMeters[0].MeterTestRslts.Count;
@ -104,6 +124,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
pageNr = 1;
nextWMNr = 0;
documentSection = DocumentSection.FirstPage;
}
/// <summary>
@ -130,40 +151,24 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
/// Run base code
base.OnPrintPage(e);
if (File.Exists("C:\\TBF\\header.png"))
{
Image img = Image.FromFile("C:\\TBF\\header.png");
e.Graphics.DrawImage(new Bitmap(img), new Rectangle(0, 0, 827, 1169));
}
/// Set print area size and margins (in dots using 80 dpi)
int printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
int printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
int leftMargin = base.DefaultPageSettings.Margins.Left; /// X
int topMargin = base.DefaultPageSettings.Margins.Top; /// Y
/// Check if the user selected to print in Landscape mode
/// if they did then we need to swap height/width parameters
if (base.DefaultPageSettings.Landscape)
{
int tmp = printHeight;
printHeight = printWidth;
printWidth = tmp;
}
int x = leftMargin;
int y = topMargin;
/// Use the StringFormat class for the text layout of our document
StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
if (pageNr == 1)
if (documentSection != DocumentSection.OtherPages)
{
///----------
/// Header
///----------
RectangleF printArea = new RectangleF(TitleX, TitleY, 667, 40);
e.Graphics.DrawString(batch.ProtocolTitle, titleFont, Brushes.Black, printArea);
if (documentSection == DocumentSection.FirstPage)
{
RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, 40);
e.Graphics.DrawString(batch.ProtocolTitle, titleFont, Brushes.Black, printArea);
}
else
{
PrintAt(e, TitleX, TitleY, batch.ProtocolTitle);
}
string[] leftColumn = new string[]
{
@ -172,6 +177,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
"Datum a čas: ",
"Procedura: ",
"Popis procedury: ",
"Typ vodoměru: ",
"Zkoušející: ",
"Název zkušební stanice: ",
"Zkušební SW, č. verze: ",
@ -193,6 +199,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
batch.EndTime.Minute.ToString("D2")),
batch.ProcedureName,
batch.ProcedureDescription,
batch.WatermetersStr,
User.CurrentUser.Name,
benchInfo.TestBenchName,
string.Format("Test Bench Framework ver.{0}", batch.ProgramVersion),
@ -209,33 +216,73 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
/// Write aligned columns
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
{
PrintAt(e, 100, HdrTop + SpacingOne * i, leftColumn[i]);
PrintAt(e, leftMargin, HdrTop + SpacingOne * i, leftColumn[i]);
PrintAt(e, 300, HdrTop + SpacingOne * i, rightColumn[i]);
}
}
///--------
/// Body
///--------
/// This variable represents the top coordinate of the area where WM results are printed
/// and it is updated (increased by) the value returned by PrintXyzWM() - the section size.
int nextWmTop = (pageNr == 1) ? BodyTop : TitleY;
int nrWMsOnPage = (pageNr == 1) ? nrWMsOnFirstPage : nrWMsOnNextPage;
for (int wmNr = nextWMNr; wmNr < Math.Min(nextWMNr + nrWMsOnPage, batch.WaterMeters.Count); wmNr++) /// wmNr is 0-based
if (documentSection == DocumentSection.FirstPage || documentSection == DocumentSection.OtherPages)
{
nextWmTop += PrintWM(e, batch.WaterMeters[wmNr], wmNr + 1, nextWmTop);
///--------
/// Body
///--------
/// This variable represents the top coordinate of the area where WM results are printed
/// and it is updated (increased by) the value returned by PrintWM() - the section size.
int nextWmTop = (pageNr == 1) ? BodyTop : TitleY;
int nrWMsOnPage = (pageNr == 1) ? nrWMsOnFirstPage : nrWMsOnNextPage;
for (int wmNr = nextWMNr; wmNr < Math.Min(nextWMNr + nrWMsOnPage, batch.WaterMeters.Count); wmNr++) /// wmNr is 0-based
{
nextWmTop += PrintWM(e, batch.WaterMeters[wmNr], wmNr + 1, nextWmTop);
}
nextWMNr += nrWMsOnPage;
e.HasMorePages = true;
if (nextWMNr < batch.WaterMeters.Count)
{
documentSection = DocumentSection.OtherPages;
}
else
{
documentSection = DocumentSection.Appendix1;
}
///----------
/// Footer
///----------
string footerText = string.Format("str. {1}/{2}", Strings.Page, pageNr++, nrPages);
int footerWidth = (int)e.Graphics.MeasureString(footerText, font).Width;
PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - SpacingOne, footerText);
}
else
{
///-------------------------------
/// List of passed water meters
///-------------------------------
nextWMNr += nrWMsOnPage;
e.HasMorePages = (nextWMNr < batch.WaterMeters.Count);
int nextWmTop = BodyTop;
///----------
/// Footer
///----------
PrintAt(e, leftMargin, topMargin + printHeight - SpacingOne, string.Format("str. {1}/{2}", Strings.Page, pageNr++, nrPages));
foreach (var wm in batch.WaterMeters)
{
if (wm.Passed)
{
PrintAt(e, leftMargin, nextWmTop, string.Format("Vodoměr {0}: s/n {1}", wm.WMPosition, wm.SerialNr));
nextWmTop += SpacingOne;
}
}
if (documentSection == DocumentSection.Appendix1)
{
documentSection = DocumentSection.Appendix2;
e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
}
}
}
@ -251,7 +298,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
{
/// Determin column widths
float[] columnPos = new float[rsltItems.Count + 1];
columnPos[0] = 100.0f;
columnPos[0] = (float)leftMargin;
for (int i = 0; i < rsltItems.Count; i++)
{
@ -288,10 +335,10 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
int tableRightX = (int)columnPos[rsltItems.Count] - 20;
string wmText = string.Format("Vodoměr {0}", printedWMNr);
PrintAt(e, 100, top, wmText);
PrintAt(e, leftMargin, top, wmText);
if (!string.IsNullOrEmpty(wm.SerialNr))
{
PrintAt(e, 100 + (int)e.Graphics.MeasureString(wmText, font).Width, top,
PrintAt(e, leftMargin + (int)e.Graphics.MeasureString(wmText, font).Width, top,
string.Format(" s/n = {0}", wm.SerialNr));
}

View File

@ -48,7 +48,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
{
TBF.BenchControl.BenchInfo.Polska.Component benchInfo =
BenchControl.Sequences.ProcessData.BenchInfo as TBF.BenchControl.BenchInfo.Polska.Component;
new PrintDocumentCevak(batch, printerCfg.PageOrientation, printerCfg.TopMargin, benchInfo).Print();
new PrintDocumentCevak(batch, printerCfg.PageOrientation, printerCfg.TopMargin, printerCfg.BottomMargin, printerCfg.LeftMargin, benchInfo).Print();
}
}

View File

@ -20,6 +20,8 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
///
public PageOrientation PageOrientation;
public int TopMargin;
public int BottomMargin;
public int LeftMargin;
public bool SupressPrinting; /// Bypass printing when true
/// Private parameterless constructor invoked by all other (public) constructors
@ -29,6 +31,8 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
ParentName = string.Empty;
PageOrientation = PageOrientation.Portrait;
TopMargin = 100;
BottomMargin = 100;
LeftMargin = 100;
SupressPrinting = false;
}
@ -40,11 +44,13 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
public string ToString(int i)
{
return string.Format("Name={0}, Orientation={1}, TopMargin={2}, SupressPrinting={3}",
return string.Format("Name={0}, Orientation={1}, Margins T={2} B={3} L={4}, SupressPrinting={5}",
Name,
PageOrientation,
TopMargin,
SupressPrinting ? "yes" : "no"
BottomMargin,
LeftMargin,
SupressPrinting ? "yes" : "no"
);
}
}

View File

@ -39,12 +39,16 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
this.orientationComboBox = new System.Windows.Forms.ComboBox();
this.topMarginTextBox = new System.Windows.Forms.TextBox();
this.topMarginLabel = new System.Windows.Forms.Label();
this.leftMarginTextBox = new System.Windows.Forms.TextBox();
this.leftMarginLabel = new System.Windows.Forms.Label();
this.bottomMarginTextBox = new System.Windows.Forms.TextBox();
this.bottomMarginLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// nameTextBox
//
this.nameTextBox.Enabled = false;
this.nameTextBox.Location = new System.Drawing.Point(142, 57);
this.nameTextBox.Location = new System.Drawing.Point(142, 40);
this.nameTextBox.Name = "nameTextBox";
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
this.nameTextBox.TabIndex = 2;
@ -52,7 +56,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
// nameLabel
//
this.nameLabel.AutoSize = true;
this.nameLabel.Location = new System.Drawing.Point(24, 60);
this.nameLabel.Location = new System.Drawing.Point(16, 43);
this.nameLabel.Name = "nameLabel";
this.nameLabel.Size = new System.Drawing.Size(35, 13);
this.nameLabel.TabIndex = 1;
@ -61,7 +65,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
// classNameLabel
//
this.classNameLabel.AutoSize = true;
this.classNameLabel.Location = new System.Drawing.Point(139, 33);
this.classNameLabel.Location = new System.Drawing.Point(139, 16);
this.classNameLabel.Name = "classNameLabel";
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
this.classNameLabel.TabIndex = 0;
@ -71,17 +75,17 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
//
this.supressPrintingCheckBox.AutoSize = true;
this.supressPrintingCheckBox.Enabled = false;
this.supressPrintingCheckBox.Location = new System.Drawing.Point(142, 144);
this.supressPrintingCheckBox.Location = new System.Drawing.Point(142, 167);
this.supressPrintingCheckBox.Name = "supressPrintingCheckBox";
this.supressPrintingCheckBox.Size = new System.Drawing.Size(101, 17);
this.supressPrintingCheckBox.TabIndex = 7;
this.supressPrintingCheckBox.TabIndex = 11;
this.supressPrintingCheckBox.Text = "Supress printing";
this.supressPrintingCheckBox.UseVisualStyleBackColor = true;
//
// orientationLabel
//
this.orientationLabel.AutoSize = true;
this.orientationLabel.Location = new System.Drawing.Point(24, 86);
this.orientationLabel.Location = new System.Drawing.Point(16, 67);
this.orientationLabel.Name = "orientationLabel";
this.orientationLabel.Size = new System.Drawing.Size(84, 13);
this.orientationLabel.TabIndex = 3;
@ -91,7 +95,7 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
//
this.orientationComboBox.Enabled = false;
this.orientationComboBox.FormattingEnabled = true;
this.orientationComboBox.Location = new System.Drawing.Point(142, 83);
this.orientationComboBox.Location = new System.Drawing.Point(142, 64);
this.orientationComboBox.Name = "orientationComboBox";
this.orientationComboBox.Size = new System.Drawing.Size(130, 21);
this.orientationComboBox.TabIndex = 4;
@ -99,24 +103,62 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
// topMarginTextBox
//
this.topMarginTextBox.Enabled = false;
this.topMarginTextBox.Location = new System.Drawing.Point(142, 110);
this.topMarginTextBox.Location = new System.Drawing.Point(142, 89);
this.topMarginTextBox.Name = "topMarginTextBox";
this.topMarginTextBox.Size = new System.Drawing.Size(130, 20);
this.topMarginTextBox.Size = new System.Drawing.Size(80, 20);
this.topMarginTextBox.TabIndex = 6;
//
// topMarginLabel
//
this.topMarginLabel.AutoSize = true;
this.topMarginLabel.Location = new System.Drawing.Point(24, 113);
this.topMarginLabel.Location = new System.Drawing.Point(16, 92);
this.topMarginLabel.Name = "topMarginLabel";
this.topMarginLabel.Size = new System.Drawing.Size(109, 13);
this.topMarginLabel.TabIndex = 5;
this.topMarginLabel.Text = "Top margin [1/100 in]";
this.topMarginLabel.Text = "Top margin [0.25 mm]";
//
// leftMarginTextBox
//
this.leftMarginTextBox.Enabled = false;
this.leftMarginTextBox.Location = new System.Drawing.Point(142, 137);
this.leftMarginTextBox.Name = "leftMarginTextBox";
this.leftMarginTextBox.Size = new System.Drawing.Size(80, 20);
this.leftMarginTextBox.TabIndex = 10;
//
// leftMarginLabel
//
this.leftMarginLabel.AutoSize = true;
this.leftMarginLabel.Location = new System.Drawing.Point(16, 140);
this.leftMarginLabel.Name = "leftMarginLabel";
this.leftMarginLabel.Size = new System.Drawing.Size(108, 13);
this.leftMarginLabel.TabIndex = 9;
this.leftMarginLabel.Text = "Left margin [0.25 mm]";
//
// bottomMarginTextBox
//
this.bottomMarginTextBox.Enabled = false;
this.bottomMarginTextBox.Location = new System.Drawing.Point(142, 113);
this.bottomMarginTextBox.Name = "bottomMarginTextBox";
this.bottomMarginTextBox.Size = new System.Drawing.Size(80, 20);
this.bottomMarginTextBox.TabIndex = 8;
//
// bottomMarginLabel
//
this.bottomMarginLabel.AutoSize = true;
this.bottomMarginLabel.Location = new System.Drawing.Point(16, 116);
this.bottomMarginLabel.Name = "bottomMarginLabel";
this.bottomMarginLabel.Size = new System.Drawing.Size(123, 13);
this.bottomMarginLabel.TabIndex = 7;
this.bottomMarginLabel.Text = "Bottom margin [0.25 mm]";
//
// PrinterCfgCtrl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.bottomMarginTextBox);
this.Controls.Add(this.bottomMarginLabel);
this.Controls.Add(this.leftMarginTextBox);
this.Controls.Add(this.leftMarginLabel);
this.Controls.Add(this.topMarginTextBox);
this.Controls.Add(this.topMarginLabel);
this.Controls.Add(this.orientationComboBox);
@ -143,5 +185,9 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
private System.Windows.Forms.ComboBox orientationComboBox;
private System.Windows.Forms.TextBox topMarginTextBox;
private System.Windows.Forms.Label topMarginLabel;
private System.Windows.Forms.TextBox leftMarginTextBox;
private System.Windows.Forms.Label leftMarginLabel;
private System.Windows.Forms.TextBox bottomMarginTextBox;
private System.Windows.Forms.Label bottomMarginLabel;
}
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2016 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
@ -57,6 +57,8 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
nameTextBox.Text = config.Name;
orientationComboBox.Text = config.PageOrientation.ToString();
topMarginTextBox.Text = config.TopMargin.ToString();
bottomMarginTextBox.Text = config.BottomMargin.ToString();
leftMarginTextBox.Text = config.LeftMargin.ToString();
supressPrintingCheckBox.Checked = config.SupressPrinting;
}
@ -65,6 +67,8 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
nameTextBox.Enabled = true;
orientationComboBox.Enabled = true;
topMarginTextBox.Enabled = true;
bottomMarginTextBox.Enabled = true;
leftMarginTextBox.Enabled = true;
supressPrintingCheckBox.Enabled = true;
}
@ -85,6 +89,18 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(bottomMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "'Bottom margin' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
if (!int.TryParse(leftMarginTextBox.Text, out dummy) || dummy < 0 || dummy > 200)
{
message += Environment.NewLine + "Left margin' should be between 0 and 200";
flags |= CfgUpdateFlags.Error;
}
return flags;
}
@ -97,6 +113,8 @@ namespace TBF.BenchControl.ResultsPrinters.Cevak
config.Name = nameTextBox.Text;
config.PageOrientation = GetOrientation(orientationComboBox.Text);
config.TopMargin = int.Parse(topMarginTextBox.Text);
config.BottomMargin = int.Parse(bottomMarginTextBox.Text);
config.LeftMargin = int.Parse(leftMarginTextBox.Text);
config.SupressPrinting = supressPrintingCheckBox.Checked;
return flags;

View File

@ -117,11 +117,6 @@ namespace TBF
private void downButton_Click(object sender, EventArgs e)
{
if (DialogResult.Yes == MessageBox.Show("Chcete naplnit 'Publish' a 'Evaluate' vsetkych testov?", "Otazka", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
{
UpgradeAllTests();
return;
}
proceduresCtrl.MoveDownSelected();
}
@ -174,84 +169,5 @@ namespace TBF
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
private void UpgradeAllTests()
{
NHibernate.ISession session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
IList<Config.Entities.Procedure> procedures = session.CreateQuery("FROM Procedure ORDER BY ItemNr")
.List<Config.Entities.Procedure>();
///IList<TBF.BenchControl.Generic.IComponent> components = TBF.BenchControl.TbfComponents.LoadComponentsFromDB(session);
///
int successful = 0;
int failed = 0;
string lastMsg = string.Empty;
int N = procedures.Count;
for (int i = 0; i < N; i++)
{
Config.Entities.Procedure proc = procedures[i];
Text = string.Format("{0} ({1}/{2})", proc.Name, i+1, N);
NHibernate.ITransaction transaction = session.BeginTransaction();
try
{
IList<Config.Entities.Test> tests = session.QueryOver<Config.Entities.Test>()
.Where(x => (x.Procedure == proc))
.OrderBy(x => x.ItemNr).Desc
.List<Config.Entities.Test>();
foreach (var test in tests)
{
bool publish;
bool evaluate;
if (test.Name.ToLower().Equals("rfid") ||
test.Name.ToLower().Equals("q1") ||
test.Name.ToLower().Equals("q2") ||
test.Name.ToLower().Equals("q3"))
{
publish = true;
evaluate = true;
}
else if (test.Name.ToLower().Equals("adjustment") ||
test.Name.ToLower().Equals("q2adj"))
{
publish = true;
evaluate = false;
}
else
{
publish = false;
evaluate = false;
}
bool testChanged = false;
if (test.Publish != publish) { test.Publish = publish; testChanged = true; }
if (test.Evaluate != evaluate) { test.Evaluate = evaluate; testChanged = true; }
if (testChanged)
{
/// Do nothing, changing the test objects before Commit() is sufficient
}
}
transaction.Commit();
successful++;
}
catch (Exception exc)
{
transaction.Rollback();
lastMsg = exc.Message;
failed++;
}
}
MessageBox.Show(string.Format("Successful: {0}, Failed: {1}\r\nMessage: {2}", successful, failed, lastMsg), "Result",
MessageBoxButtons.OK, (failed > 0) ? MessageBoxIcon.Error : MessageBoxIcon.Information);
}
}
}

View File

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

View File

@ -195,7 +195,6 @@ namespace TBF.UiControls
Procedure originalProcedure = SelectedItems[0].Tag as Procedure;
Procedure modifiedProcedure = originalProcedure.Clone();
modifiedProcedure.ItemNr = originalProcedure.ItemNr;
modifiedProcedure.Revision = originalProcedure.Revision + 1;
modifiedProcedure.ObtainedByCopy = false;