Description attribute for enums, Output.FileWriters.Basic: FileNameFormat, SaveGoodOnly, 2 destination folders, etc.
This commit is contained in:
@@ -54,20 +54,6 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eliminate spaces conditionally, depesing on bool WriterCfg.EliminateSpaces
|
||||
/// </summary>
|
||||
/// <param name="item">Input string</param>
|
||||
/// <returns>Output string</returns>
|
||||
string ElSpaces(string item)
|
||||
{
|
||||
if (writerCfg.EliminateSpaces)
|
||||
return item.Replace(" ", string.Empty);
|
||||
else
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a file name derived from a DateTime structure.
|
||||
/// Creates directories on this path as a side effect.
|
||||
@@ -115,7 +101,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
case MonthFolders.Digit:
|
||||
directory = string.Format("{0}{1}\\", directory, time.Month.ToString());
|
||||
break;
|
||||
case MonthFolders.DigitWithLeadingZero:
|
||||
case MonthFolders.TwoDigit:
|
||||
directory = string.Format("{0}{1}\\", directory, time.Month.ToString("D2"));
|
||||
break;
|
||||
}
|
||||
@@ -125,15 +111,29 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
case DayFolders.Digit:
|
||||
directory = string.Format("{0}{1}\\", directory, time.Day.ToString());
|
||||
break;
|
||||
case DayFolders.DigitWithLeadingZero:
|
||||
case DayFolders.TwoDigit:
|
||||
directory = string.Format("{0}{1}\\", directory, time.Day.ToString("D2"));
|
||||
break;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
return string.Format("{0}{1}{2}{3}-{4}{5}.txt", directory, (time.Year % 100).ToString("D2"),
|
||||
time.Month.ToString("D2"), time.Day.ToString("D2"), time.Hour.ToString("D2"), time.Minute.ToString("D2"));
|
||||
string fileName;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(writerCfg.FileNameFormat)) throw new Exception();
|
||||
fileName = string.Format(writerCfg.FileNameFormat, time);
|
||||
}
|
||||
catch
|
||||
{
|
||||
fileName = string.Format("{1}{2}{3}-{4}{5}.txt", (time.Year % 100).ToString("D2"),
|
||||
time.Month.ToString("D2"),
|
||||
time.Day.ToString("D2"),
|
||||
time.Hour.ToString("D2"),
|
||||
time.Minute.ToString("D2"));
|
||||
}
|
||||
|
||||
return directory + fileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,14 +177,13 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
{
|
||||
if (rsltItems == null || rsltItems.Count == 0) return;
|
||||
|
||||
if (writer != null)
|
||||
foreach (var wm in batch.WaterMeters)
|
||||
{
|
||||
foreach (var wm in batch.WaterMeters) WriteWM(writer, wm);
|
||||
}
|
||||
|
||||
if (writer2 != null)
|
||||
{
|
||||
foreach (var wm in batch.WaterMeters) WriteWM(writer2, wm);
|
||||
if (!writerCfg.SaveGoodOnly || wm.Passed)
|
||||
{
|
||||
if (writer != null) WriteWM(writer, wm);
|
||||
if (writer2 != null) WriteWM(writer2, wm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
{
|
||||
None,
|
||||
Digit,
|
||||
DigitWithLeadingZero,
|
||||
TwoDigit,
|
||||
Name,
|
||||
Count
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
{
|
||||
None,
|
||||
Digit,
|
||||
DigitWithLeadingZero,
|
||||
TwoDigit,
|
||||
Count
|
||||
}
|
||||
|
||||
@@ -54,8 +54,9 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
public YearFolders YearFolders;
|
||||
public MonthFolders MonthFolders;
|
||||
public DayFolders DayFolders;
|
||||
public string FileNameFormat;
|
||||
public Separator Separator;
|
||||
public bool EliminateSpaces;
|
||||
public bool SaveGoodOnly;
|
||||
public string[] SelectedItems;
|
||||
|
||||
|
||||
@@ -69,8 +70,9 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
YearFolders = YearFolders.FourDigit;
|
||||
MonthFolders = MonthFolders.Digit;
|
||||
DayFolders = DayFolders.Digit;
|
||||
FileNameFormat = "{0:yyyyMMdd}";
|
||||
Separator = Separator.None;
|
||||
EliminateSpaces = false;
|
||||
SaveGoodOnly = false;
|
||||
}
|
||||
|
||||
public WriterCfg(IComponentFactory factory)
|
||||
@@ -81,14 +83,15 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, Elim.Spaces={5}, Separator={6}",
|
||||
return string.Format("Name={0}, Path={1}, Y={2}, M={3}, D={4}, FNameFmt={5}, Separator={6}, GoodOnly={7}",
|
||||
Name,
|
||||
DestinationPath,
|
||||
YearFolders,
|
||||
MonthFolders,
|
||||
DayFolders,
|
||||
EliminateSpaces,
|
||||
Separator);
|
||||
FileNameFormat,
|
||||
Separator,
|
||||
SaveGoodOnly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,9 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
yearFoldersComboBox.Text = config.YearFolders.ToString();
|
||||
monthFoldersComboBox.Text = config.MonthFolders.ToString();
|
||||
dayFoldersComboBox.Text = config.DayFolders.ToString();
|
||||
fileNameFmtTextBox.Text = config.FileNameFormat;
|
||||
separatorComboBox.Text = config.Separator.ToString();
|
||||
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
@@ -79,9 +81,11 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
yearFoldersComboBox.Enabled = true;
|
||||
monthFoldersComboBox.Enabled = true;
|
||||
dayFoldersComboBox.Enabled = true;
|
||||
fileNameFmtTextBox.Enabled = true;
|
||||
separatorComboBox.Enabled = true;
|
||||
selectItemsButton.Enabled = true;
|
||||
}
|
||||
goodOnlyCheckBox.Enabled = true;
|
||||
selectItemsButton.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
@@ -165,6 +169,12 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
}
|
||||
}
|
||||
|
||||
if (config.FileNameFormat != fileNameFmtTextBox.Text)
|
||||
{
|
||||
config.FileNameFormat = fileNameFmtTextBox.Text;
|
||||
flags = CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
for (Separator i = 0; i < Separator.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(separatorComboBox.Text) && (config.Separator != i))
|
||||
@@ -175,6 +185,12 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
}
|
||||
}
|
||||
|
||||
if (config.SaveGoodOnly != goodOnlyCheckBox.Checked)
|
||||
{
|
||||
config.SaveGoodOnly = goodOnlyCheckBox.Checked;
|
||||
flags = CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
if (config.SelectedItems != selectedItems)
|
||||
{
|
||||
config.SelectedItems = selectedItems;
|
||||
|
||||
+63
-27
@@ -49,12 +49,15 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
this.destination2Button = new System.Windows.Forms.Button();
|
||||
this.destination2TextBox = new System.Windows.Forms.TextBox();
|
||||
this.destination2Label = new System.Windows.Forms.Label();
|
||||
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
|
||||
this.fileNameFmtLabel = new System.Windows.Forms.Label();
|
||||
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(108, 33);
|
||||
this.nameTextBox.Location = new System.Drawing.Point(108, 31);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(146, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
@@ -62,7 +65,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(17, 36);
|
||||
this.nameLabel.Location = new System.Drawing.Point(17, 34);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
@@ -71,7 +74,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(105, 10);
|
||||
this.classNameLabel.Location = new System.Drawing.Point(105, 9);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
@@ -80,7 +83,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// destinationTextBox
|
||||
//
|
||||
this.destinationTextBox.Enabled = false;
|
||||
this.destinationTextBox.Location = new System.Drawing.Point(108, 56);
|
||||
this.destinationTextBox.Location = new System.Drawing.Point(108, 52);
|
||||
this.destinationTextBox.Name = "destinationTextBox";
|
||||
this.destinationTextBox.Size = new System.Drawing.Size(146, 20);
|
||||
this.destinationTextBox.TabIndex = 4;
|
||||
@@ -88,7 +91,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// destinationLabel
|
||||
//
|
||||
this.destinationLabel.AutoSize = true;
|
||||
this.destinationLabel.Location = new System.Drawing.Point(17, 59);
|
||||
this.destinationLabel.Location = new System.Drawing.Point(17, 55);
|
||||
this.destinationLabel.Name = "destinationLabel";
|
||||
this.destinationLabel.Size = new System.Drawing.Size(60, 13);
|
||||
this.destinationLabel.TabIndex = 3;
|
||||
@@ -100,7 +103,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
this.destinationButton.Location = new System.Drawing.Point(259, 56);
|
||||
this.destinationButton.Name = "destinationButton";
|
||||
this.destinationButton.Size = new System.Drawing.Size(30, 20);
|
||||
this.destinationButton.TabIndex = 5;
|
||||
this.destinationButton.TabIndex = 18;
|
||||
this.destinationButton.Text = "...";
|
||||
this.destinationButton.UseVisualStyleBackColor = true;
|
||||
this.destinationButton.Click += new System.EventHandler(this.destinationButton_Click);
|
||||
@@ -108,7 +111,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// separatorLabel
|
||||
//
|
||||
this.separatorLabel.AutoSize = true;
|
||||
this.separatorLabel.Location = new System.Drawing.Point(17, 177);
|
||||
this.separatorLabel.Location = new System.Drawing.Point(17, 184);
|
||||
this.separatorLabel.Name = "separatorLabel";
|
||||
this.separatorLabel.Size = new System.Drawing.Size(53, 13);
|
||||
this.separatorLabel.TabIndex = 15;
|
||||
@@ -118,7 +121,7 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
//
|
||||
this.separatorComboBox.Enabled = false;
|
||||
this.separatorComboBox.FormattingEnabled = true;
|
||||
this.separatorComboBox.Location = new System.Drawing.Point(108, 174);
|
||||
this.separatorComboBox.Location = new System.Drawing.Point(108, 181);
|
||||
this.separatorComboBox.Name = "separatorComboBox";
|
||||
this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
|
||||
this.separatorComboBox.TabIndex = 16;
|
||||
@@ -126,10 +129,10 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// selectItemsButton
|
||||
//
|
||||
this.selectItemsButton.Enabled = false;
|
||||
this.selectItemsButton.Location = new System.Drawing.Point(108, 201);
|
||||
this.selectItemsButton.Location = new System.Drawing.Point(108, 203);
|
||||
this.selectItemsButton.Name = "selectItemsButton";
|
||||
this.selectItemsButton.Size = new System.Drawing.Size(145, 23);
|
||||
this.selectItemsButton.TabIndex = 17;
|
||||
this.selectItemsButton.TabIndex = 20;
|
||||
this.selectItemsButton.Text = "Select items";
|
||||
this.selectItemsButton.UseVisualStyleBackColor = true;
|
||||
this.selectItemsButton.Click += new System.EventHandler(this.selectItemsButton_Click);
|
||||
@@ -137,56 +140,56 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
// yearFoldersLabel
|
||||
//
|
||||
this.yearFoldersLabel.AutoSize = true;
|
||||
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 105);
|
||||
this.yearFoldersLabel.Location = new System.Drawing.Point(17, 97);
|
||||
this.yearFoldersLabel.Name = "yearFoldersLabel";
|
||||
this.yearFoldersLabel.Size = new System.Drawing.Size(63, 13);
|
||||
this.yearFoldersLabel.TabIndex = 9;
|
||||
this.yearFoldersLabel.TabIndex = 7;
|
||||
this.yearFoldersLabel.Text = "Year folders";
|
||||
//
|
||||
// monthFoldersLabel
|
||||
//
|
||||
this.monthFoldersLabel.AutoSize = true;
|
||||
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 129);
|
||||
this.monthFoldersLabel.Location = new System.Drawing.Point(17, 119);
|
||||
this.monthFoldersLabel.Name = "monthFoldersLabel";
|
||||
this.monthFoldersLabel.Size = new System.Drawing.Size(71, 13);
|
||||
this.monthFoldersLabel.TabIndex = 11;
|
||||
this.monthFoldersLabel.TabIndex = 9;
|
||||
this.monthFoldersLabel.Text = "Month folders";
|
||||
//
|
||||
// dayFoldersLabel
|
||||
//
|
||||
this.dayFoldersLabel.AutoSize = true;
|
||||
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 153);
|
||||
this.dayFoldersLabel.Location = new System.Drawing.Point(17, 141);
|
||||
this.dayFoldersLabel.Name = "dayFoldersLabel";
|
||||
this.dayFoldersLabel.Size = new System.Drawing.Size(60, 13);
|
||||
this.dayFoldersLabel.TabIndex = 13;
|
||||
this.dayFoldersLabel.TabIndex = 11;
|
||||
this.dayFoldersLabel.Text = "Day folders";
|
||||
//
|
||||
// yearFoldersComboBox
|
||||
//
|
||||
this.yearFoldersComboBox.Enabled = false;
|
||||
this.yearFoldersComboBox.FormattingEnabled = true;
|
||||
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 102);
|
||||
this.yearFoldersComboBox.Location = new System.Drawing.Point(108, 94);
|
||||
this.yearFoldersComboBox.Name = "yearFoldersComboBox";
|
||||
this.yearFoldersComboBox.Size = new System.Drawing.Size(146, 21);
|
||||
this.yearFoldersComboBox.TabIndex = 10;
|
||||
this.yearFoldersComboBox.TabIndex = 8;
|
||||
//
|
||||
// monthFoldersComboBox
|
||||
//
|
||||
this.monthFoldersComboBox.Enabled = false;
|
||||
this.monthFoldersComboBox.FormattingEnabled = true;
|
||||
this.monthFoldersComboBox.Location = new System.Drawing.Point(109, 126);
|
||||
this.monthFoldersComboBox.Location = new System.Drawing.Point(108, 116);
|
||||
this.monthFoldersComboBox.Name = "monthFoldersComboBox";
|
||||
this.monthFoldersComboBox.Size = new System.Drawing.Size(146, 21);
|
||||
this.monthFoldersComboBox.TabIndex = 12;
|
||||
this.monthFoldersComboBox.TabIndex = 10;
|
||||
//
|
||||
// dayFoldersComboBox
|
||||
//
|
||||
this.dayFoldersComboBox.Enabled = false;
|
||||
this.dayFoldersComboBox.FormattingEnabled = true;
|
||||
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 150);
|
||||
this.dayFoldersComboBox.Location = new System.Drawing.Point(108, 138);
|
||||
this.dayFoldersComboBox.Name = "dayFoldersComboBox";
|
||||
this.dayFoldersComboBox.Size = new System.Drawing.Size(146, 21);
|
||||
this.dayFoldersComboBox.TabIndex = 14;
|
||||
this.dayFoldersComboBox.TabIndex = 12;
|
||||
//
|
||||
// destination2Button
|
||||
//
|
||||
@@ -194,31 +197,61 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
this.destination2Button.Location = new System.Drawing.Point(259, 79);
|
||||
this.destination2Button.Name = "destination2Button";
|
||||
this.destination2Button.Size = new System.Drawing.Size(30, 20);
|
||||
this.destination2Button.TabIndex = 8;
|
||||
this.destination2Button.TabIndex = 19;
|
||||
this.destination2Button.Text = "...";
|
||||
this.destination2Button.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// destination2TextBox
|
||||
//
|
||||
this.destination2TextBox.Enabled = false;
|
||||
this.destination2TextBox.Location = new System.Drawing.Point(108, 79);
|
||||
this.destination2TextBox.Location = new System.Drawing.Point(108, 73);
|
||||
this.destination2TextBox.Name = "destination2TextBox";
|
||||
this.destination2TextBox.Size = new System.Drawing.Size(146, 20);
|
||||
this.destination2TextBox.TabIndex = 7;
|
||||
this.destination2TextBox.TabIndex = 6;
|
||||
//
|
||||
// destination2Label
|
||||
//
|
||||
this.destination2Label.AutoSize = true;
|
||||
this.destination2Label.Location = new System.Drawing.Point(17, 82);
|
||||
this.destination2Label.Location = new System.Drawing.Point(17, 76);
|
||||
this.destination2Label.Name = "destination2Label";
|
||||
this.destination2Label.Size = new System.Drawing.Size(69, 13);
|
||||
this.destination2Label.TabIndex = 6;
|
||||
this.destination2Label.TabIndex = 5;
|
||||
this.destination2Label.Text = "Destination 2";
|
||||
//
|
||||
// fileNameFmtTextBox
|
||||
//
|
||||
this.fileNameFmtTextBox.Enabled = false;
|
||||
this.fileNameFmtTextBox.Location = new System.Drawing.Point(108, 160);
|
||||
this.fileNameFmtTextBox.Name = "fileNameFmtTextBox";
|
||||
this.fileNameFmtTextBox.Size = new System.Drawing.Size(146, 20);
|
||||
this.fileNameFmtTextBox.TabIndex = 14;
|
||||
//
|
||||
// fileNameFmtLabel
|
||||
//
|
||||
this.fileNameFmtLabel.AutoSize = true;
|
||||
this.fileNameFmtLabel.Location = new System.Drawing.Point(17, 163);
|
||||
this.fileNameFmtLabel.Name = "fileNameFmtLabel";
|
||||
this.fileNameFmtLabel.Size = new System.Drawing.Size(84, 13);
|
||||
this.fileNameFmtLabel.TabIndex = 13;
|
||||
this.fileNameFmtLabel.Text = "File name format";
|
||||
//
|
||||
// goodOnlyCheckBox
|
||||
//
|
||||
this.goodOnlyCheckBox.AutoSize = true;
|
||||
this.goodOnlyCheckBox.Location = new System.Drawing.Point(20, 207);
|
||||
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox";
|
||||
this.goodOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
|
||||
this.goodOnlyCheckBox.TabIndex = 17;
|
||||
this.goodOnlyCheckBox.Text = "Good only";
|
||||
this.goodOnlyCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// WriterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.goodOnlyCheckBox);
|
||||
this.Controls.Add(this.fileNameFmtTextBox);
|
||||
this.Controls.Add(this.fileNameFmtLabel);
|
||||
this.Controls.Add(this.destination2Button);
|
||||
this.Controls.Add(this.destination2TextBox);
|
||||
this.Controls.Add(this.destination2Label);
|
||||
@@ -265,5 +298,8 @@ namespace TBF.BenchControl.Output.FileWriters.Basic
|
||||
private System.Windows.Forms.Button destination2Button;
|
||||
private System.Windows.Forms.TextBox destination2TextBox;
|
||||
private System.Windows.Forms.Label destination2Label;
|
||||
private System.Windows.Forms.TextBox fileNameFmtTextBox;
|
||||
private System.Windows.Forms.Label fileNameFmtLabel;
|
||||
private System.Windows.Forms.CheckBox goodOnlyCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user