<Fix>: Restore parent UniDataStorageWriter in Previous results editor, increase revision to 3.9.3145.105

Cause:

- Previous results opens the ResultsWriter configuration through GetControl(null).
- The component entity list is therefore unavailable.
- The DropDownList could not display the saved ParentName because it was not present in its Items collection.

Solution:

1. Restored the saved parent writer
   - Adds the configured ParentName to the list when it is not already available.
   - Selects the restored UniDataStorageWriter in parentComboBox.

2. Preserved standard configuration behavior
   - All available UDSW components are still loaded when component entities are provided.
   - Previous results can now display and use the previously configured parent writer.

3. Improved source formatting
   - Removed inappropriate line wrapping from ResultsWriterCfgCtrl.cs.

4. Increased revision
   - Updated revision to 3.9.3145.105.
This commit is contained in:
2026-09-08 13:20:55 +02:00
parent 6d2477be4a
commit d2d41df155
2 changed files with 78 additions and 183 deletions
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.9.3145.104")]
[assembly: AssemblyFileVersion("3.9.3145.104")]
[assembly: AssemblyVersion("3.9.3145.105")]
[assembly: AssemblyFileVersion("3.9.3145.105")]
@@ -9,14 +9,12 @@ using Common;
using Config.Entities;
using TBF.Rig.Generic;
using TBF.Rig.Output.DataStorage.UniDataStorageWriter;
using TBF.Rig.Output.DataStorage.UniDataStorageWriter.Interfaces;
using TBF.Rig.Output.DataStorage.UniDataStorageWriter.Formatters;
using TBF.Rig.Output.DataStorage.UniDataStorageWriter.Interfaces;
namespace TBF.Rig.Output.DB.ResultsWriter
{
public partial class ResultsWriterCfgCtrl :
Configs.ConfigCtrlUtils,
IComponentCfgCtrl
public partial class ResultsWriterCfgCtrl : Configs.ConfigCtrlUtils, IComponentCfgCtrl
{
public bool ShowMore
{
@@ -32,25 +30,18 @@ namespace TBF.Rig.Output.DB.ResultsWriter
get { return config as IComponentCfg; }
set
{
config =
value as ResultsWriterCfg;
config = value as ResultsWriterCfg;
Redraw();
}
}
public ResultsWriterCfgCtrl(
IList<Component> cmpntEntities)
public ResultsWriterCfgCtrl(IList<Component> cmpntEntities)
{
InitializeComponent();
this.cmpntEntities =
cmpntEntities;
this.cmpntEntities = cmpntEntities;
}
private void ResultsWriterCfgCtrl_Load(
object sender,
EventArgs e)
private void ResultsWriterCfgCtrl_Load(object sender, EventArgs e)
{
if (config == null)
return;
@@ -69,52 +60,36 @@ namespace TBF.Rig.Output.DB.ResultsWriter
config.UpdateRuntimeModel();
classNameLabel.Text =
config.Factory.ClassName;
nameTextBox.Text =
config.Name;
enabledCheckBox.Checked =
config.Enabled;
storageNameTextBox.Text =
config.StorageName;
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
enabledCheckBox.Checked = config.Enabled;
storageNameTextBox.Text = config.StorageName;
parentComboBox.Items.Clear();
parentComboBox.Items.Add(
string.Empty);
parentComboBox.Items.Add(string.Empty);
if (cmpntEntities != null)
{
foreach (Component cmpnt
in cmpntEntities)
foreach (Component cmpnt in cmpntEntities)
{
if (cmpnt == null)
continue;
if (cmpnt.ClassName != null &&
cmpnt.ClassName.IndexOf(
"UniDataStorageWriter") >= 0)
{
parentComboBox.Items.Add(
cmpnt.Name);
}
if (cmpnt.ClassName != null && cmpnt.ClassName.IndexOf("UniDataStorageWriter") >= 0)
parentComboBox.Items.Add(cmpnt.Name);
}
}
parentComboBox.Text =
config.ParentName;
if (!string.IsNullOrWhiteSpace(config.ParentName) && !parentComboBox.Items.Contains(config.ParentName))
parentComboBox.Items.Add(config.ParentName);
selectedItemsLabel.Text =
string.Format(
"{0} selected item(s)",
config.SelectedItems != null
? config.SelectedItems.Count
: 0);
parentComboBox.SelectedItem = config.ParentName;
resultsConfigChanged =
false;
selectedItemsLabel.Text = string.Format(
"{0} selected item(s)",
config.SelectedItems != null ? config.SelectedItems.Count : 0);
resultsConfigChanged = false;
}
public void Unlock()
@@ -127,35 +102,23 @@ namespace TBF.Rig.Output.DB.ResultsWriter
previewRequestButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(
ref string message)
public CfgUpdateFlags VerifyCfg(ref string message)
{
if (string.IsNullOrEmpty(
nameTextBox.Text))
if (string.IsNullOrEmpty(nameTextBox.Text))
{
message =
"Component name is empty.";
message = "Component name is empty.";
return CfgUpdateFlags.Error;
}
if (enabledCheckBox.Checked &&
string.IsNullOrEmpty(
parentComboBox.Text))
if (enabledCheckBox.Checked && string.IsNullOrEmpty(parentComboBox.Text))
{
message =
"Parent UniDataStorageWriter is not selected.";
message = "Parent UniDataStorageWriter is not selected.";
return CfgUpdateFlags.Error;
}
if (enabledCheckBox.Checked &&
string.IsNullOrEmpty(
storageNameTextBox.Text))
if (enabledCheckBox.Checked && string.IsNullOrEmpty(storageNameTextBox.Text))
{
message =
"Storage name is empty.";
message = "Storage name is empty.";
return CfgUpdateFlags.Error;
}
@@ -164,101 +127,64 @@ namespace TBF.Rig.Output.DB.ResultsWriter
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags =
CfgUpdateFlags.None;
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (config == null)
return CfgUpdateFlags.Error;
if (config.Name !=
nameTextBox.Text)
if (config.Name != nameTextBox.Text)
{
config.Name =
nameTextBox.Text;
flags |=
CfgUpdateFlags.AnyChange |
CfgUpdateFlags.RestartRqrd;
config.Name = nameTextBox.Text;
flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd;
}
if (config.ParentName !=
parentComboBox.Text)
if (config.ParentName != parentComboBox.Text)
{
config.ParentName =
parentComboBox.Text;
flags |=
CfgUpdateFlags.AnyChange |
CfgUpdateFlags.RestartRqrd;
config.ParentName = parentComboBox.Text;
flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd;
}
flags |=
UpdateDifferent(
ref config.Enabled,
enabledCheckBox.Checked,
CfgUpdateFlags.AnyChange |
CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(
ref config.Enabled,
enabledCheckBox.Checked,
CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
flags |=
UpdateDifferent(
ref config.StorageName,
storageNameTextBox.Text,
CfgUpdateFlags.AnyChange |
CfgUpdateFlags.RestartRqrd);
flags |= UpdateDifferent(
ref config.StorageName,
storageNameTextBox.Text,
CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
if (resultsConfigChanged)
{
config.UpdateSerializableModel();
flags |=
CfgUpdateFlags.AnyChange |
CfgUpdateFlags.RestartRqrd;
resultsConfigChanged =
false;
flags |= CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd;
resultsConfigChanged = false;
}
return flags;
}
private void configureResultsButton_Click(
object sender,
EventArgs e)
private void configureResultsButton_Click(object sender, EventArgs e)
{
if (config == null)
return;
string payloadTemplatePath =
ResolvePayloadTemplatePath();
string payloadTemplatePath = ResolvePayloadTemplatePath();
using (ResultsWriterResultsDlg dlg =
new ResultsWriterResultsDlg())
using (ResultsWriterResultsDlg dlg = new ResultsWriterResultsDlg())
{
dlg.SelectedItems =
CloneSelectedItems(
config.SelectedItems);
dlg.SelectedItems = CloneSelectedItems(config.SelectedItems);
dlg.PayloadTemplatePath = payloadTemplatePath;
dlg.PayloadTemplatePath =
payloadTemplatePath;
if (dlg.ShowDialog(this) ==
DialogResult.OK)
if (dlg.ShowDialog(this) == DialogResult.OK)
{
config.SelectedItems =
new List<Results.WMeterRsltItemSpec>(
dlg.SelectedItems);
config.SelectedItems = new List<Results.WMeterRsltItemSpec>(dlg.SelectedItems);
config.UpdateSerializableModel();
resultsConfigChanged = true;
resultsConfigChanged =
true;
selectedItemsLabel.Text =
string.Format(
"{0} selected item(s)",
config.SelectedItems != null
? config.SelectedItems.Count
: 0);
selectedItemsLabel.Text = string.Format(
"{0} selected item(s)",
config.SelectedItems != null ? config.SelectedItems.Count : 0);
}
}
}
@@ -266,31 +192,22 @@ namespace TBF.Rig.Output.DB.ResultsWriter
/// <summary>
/// Generates a five-test XML dry-run and never calls the database.
/// </summary>
private void previewRequestButton_Click(
object sender,
EventArgs e)
private void previewRequestButton_Click(object sender, EventArgs e)
{
if (config == null)
return;
Results.Entities.Batch batch =
CreateSimulationBatch();
Results.Entities.Batch batch = CreateSimulationBatch();
try
{
config.UpdateSerializableModel();
config.UpdateRuntimeModel();
ResultsWriter writer =
new ResultsWriter(
config);
ResultsWriter writer = new ResultsWriter(config);
writer.InitializeParent();
XmlPayloadBuildResult preview =
writer.GeneratePreviewPayload(
batch,
5);
XmlPayloadBuildResult preview = writer.GeneratePreviewPayload(batch, 5);
MessageBox.Show(
string.Format(
@@ -313,60 +230,41 @@ namespace TBF.Rig.Output.DB.ResultsWriter
private string ResolvePayloadTemplatePath()
{
WriterCfg writerCfg =
ResolveParentWriterCfg();
WriterCfg writerCfg = ResolveParentWriterCfg();
if (writerCfg == null ||
!writerCfg.UsesXmlPayload())
{
if (writerCfg == null || !writerCfg.UsesXmlPayload())
return null;
}
return writerCfg.PayloadTemplatePath;
}
private WriterCfg ResolveParentWriterCfg()
{
string parentName =
parentComboBox.Text;
string parentName = parentComboBox.Text;
if (string.IsNullOrWhiteSpace(
parentName))
{
if (string.IsNullOrWhiteSpace(parentName))
return null;
}
IComponent parent =
TbfComponents.FindComponent(
parentName);
TBF.Rig.Output.DataStorage.UniDataStorageWriter.Writer writer =
parent as
TBF.Rig.Output.DataStorage
.UniDataStorageWriter.Writer;
IComponent parent = TbfComponents.FindComponent(parentName);
Writer writer = parent as Writer;
if (writer == null)
return null;
return writer.Cfg
as WriterCfg;
return writer.Cfg as WriterCfg;
}
private IList<Results.WMeterRsltItemSpec> CloneSelectedItems(
IList<Results.WMeterRsltItemSpec> source)
private IList<Results.WMeterRsltItemSpec> CloneSelectedItems(IList<Results.WMeterRsltItemSpec> source)
{
List<Results.WMeterRsltItemSpec> result =
new List<Results.WMeterRsltItemSpec>();
List<Results.WMeterRsltItemSpec> result = new List<Results.WMeterRsltItemSpec>();
if (source == null)
return result;
foreach (Results.WMeterRsltItemSpec item
in source)
foreach (Results.WMeterRsltItemSpec item in source)
{
if (item != null)
result.Add(
item.Clone());
result.Add(item.Clone());
}
return result;
@@ -374,8 +272,7 @@ namespace TBF.Rig.Output.DB.ResultsWriter
private Results.Entities.Batch CreateSimulationBatch()
{
Results.Entities.Batch batch =
new Results.Entities.Batch();
Results.Entities.Batch batch = new Results.Entities.Batch();
batch.BatchNr = 999999;
batch.ProcedureName = "ResultsWriter XML preview";
@@ -383,17 +280,15 @@ namespace TBF.Rig.Output.DB.ResultsWriter
batch.EndTime = DateTime.Now;
batch.TestBenchName = "SIMULATION-BENCH";
Results.Entities.WaterMeter wm =
new Results.Entities.WaterMeter();
Results.Entities.WaterMeter wm = new Results.Entities.WaterMeter();
wm.Batch = batch;
wm.WMPosition = 1;
wm.SerialNr = "SIM000001";
batch.WaterMeters.Add(
wm);
batch.WaterMeters.Add(wm);
return batch;
}
}
}
}