Cause: - ResultsWriter required a generic way to generate customer-specific XML result data from TBF measurement results. - The customer reference XML contains example runtime values and repeated result structures, so it cannot be used directly as the generated output. - TBF result variables must be explicitly mapped to destinations in the customer XML structure. - The generated XML result data must support two output targets: - direct creation of an XML file, - delivery of the XML payload to a Microsoft SQL stored procedure. - Preview generation must allow the XML structure and configured mappings to be verified without executing the production database write. - Increase revision to 3.9.3145.100. Solution: 1. Added XML reference analysis - Creates a clean base XML structure. - Extracts the repeating result prototype. - Prevents sample runtime values from the customer reference XML from leaking into generated results. 2. Added configurable TBF-to-XML result mapping - Allows explicit mapping of TBF result variables to customer XML destinations. - Supports one-time and repeating XML destinations. - Keeps the mapping independent of the semantic meaning of customer XML attribute names. 3. Added XML destination viewer and configurator - Shows the current mapping. - Highlights repeating destinations. - Identifies already used one-time destinations. 4. Added runtime XML result generation - Uses the configured TBF-to-XML mappings. - Uses measurement procedure result data. - Builds the output from the clean base XML and repeating XML prototype. - Generates repeated result records according to the executed measurement procedure. 5. Added simulation-based Preview request - Generates a complete XML payload using simulation values. - Allows XML structure and mapping verification before production execution. - Does not execute the production stored procedure. 6. Added direct XML file output support to UniDataStorageWriter - Supports File / .xml as a physical output target. - Creates the generated XML result file in the configured output directory. 7. Added Microsoft SQL stored-procedure XML output - Supports Microsoft SQL / StoredProcedure as a physical output target. - Passes the generated XML payload through the configured stored procedure parameter. 8. Added optional XML payload archiving - Allows generated XML payloads to be stored in the configured Payload archive. - Can be used together with the Microsoft SQL stored-procedure output. 9. Kept ResultsWriter independent of the physical output target - ResultsWriter generates the result payload. - UniDataStorageWriter decides how and where the payload is physically written. - The same ResultsWriter XML generation mechanism is therefore used for both XML file and MSSQL outputs. 10. Increased revision - Updated revision to 3.9.3145.100.
148 lines
4.9 KiB
C#
148 lines
4.9 KiB
C#
///
|
|
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
|
///
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using TBF.Rig.Generic;
|
|
|
|
namespace TBF.Rig.Output.DataStorage.UniDataStorageWriter
|
|
{
|
|
/// <summary>
|
|
/// Provides factory services for the
|
|
/// <see cref="UniDataStorageWriter"/> component.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The factory is responsible for creating runtime
|
|
/// <see cref="Writer"/> instances and their corresponding
|
|
/// <see cref="WriterCfg"/> configuration objects.
|
|
///
|
|
/// The concrete storage technology is not selected by the factory.
|
|
/// Technology-specific writer selection is performed later by
|
|
/// <see cref="Writer"/> according to the active configuration.
|
|
///
|
|
/// Consequently, database write modes such as INSERT, UPDATE and
|
|
/// stored procedure execution do not require separate component
|
|
/// factories.
|
|
/// </remarks>
|
|
public class Factory : IComponentFactory
|
|
{
|
|
/// <summary>
|
|
/// Gets the component class name used by the TBF component framework.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The namespace prefix is removed for backward compatibility with
|
|
/// existing component configurations.
|
|
/// </remarks>
|
|
public string ClassName
|
|
{
|
|
get { return GetType().Namespace.Substring(8); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the component class name.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// The value of <see cref="ClassName"/>.
|
|
/// </returns>
|
|
public override string ToString()
|
|
{
|
|
return ClassName;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a default runtime instance of the
|
|
/// <see cref="Writer"/> component.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// A new <see cref="Writer"/> configured with a default
|
|
/// <see cref="WriterCfg"/> instance.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// The dummy component is primarily used by the component framework
|
|
/// for discovery and configuration purposes.
|
|
/// </remarks>
|
|
public IComponent DummyComponent()
|
|
{
|
|
return new Writer(
|
|
new WriterCfg("UniDataStorageWriter", this));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a runtime <see cref="Writer"/> from an existing
|
|
/// component configuration.
|
|
/// </summary>
|
|
/// <param name="cfg">
|
|
/// Component configuration expected to be a
|
|
/// <see cref="WriterCfg"/> instance.
|
|
/// </param>
|
|
/// <param name="components">
|
|
/// Collection of already created components supplied by the
|
|
/// component framework.
|
|
/// </param>
|
|
/// <returns>
|
|
/// A new <see cref="Writer"/> instance using the supplied configuration.
|
|
/// </returns>
|
|
/// <exception cref="ArgumentException">
|
|
/// Thrown when <paramref name="cfg"/> is not a valid
|
|
/// <see cref="WriterCfg"/> instance.
|
|
/// </exception>
|
|
/// <remarks>
|
|
/// The <paramref name="components"/> collection is currently not
|
|
/// required by <see cref="Writer"/>, but remains part of the factory
|
|
/// contract defined by <see cref="IComponentFactory"/>.
|
|
/// </remarks>
|
|
public IComponent GetComponent(
|
|
IComponentCfg cfg,
|
|
IList<IComponent> components)
|
|
{
|
|
WriterCfg writerCfg = cfg as WriterCfg;
|
|
|
|
if (writerCfg == null)
|
|
{
|
|
throw new ArgumentException(
|
|
"Invalid config for UniDataStorageWriter");
|
|
}
|
|
|
|
return new Writer(writerCfg);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates the default configuration for the
|
|
/// <see cref="UniDataStorageWriter"/> component.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// A new default <see cref="WriterCfg"/> instance.
|
|
/// </returns>
|
|
public IComponentCfg DefaultConfig()
|
|
{
|
|
return new WriterCfg(
|
|
"UniDataStorageWriter",
|
|
this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a <see cref="WriterCfg"/> instance from a persisted
|
|
/// component database entity.
|
|
/// </summary>
|
|
/// <param name="component">
|
|
/// Persisted component entity containing serialized configuration data.
|
|
/// </param>
|
|
/// <returns>
|
|
/// Deserialized component configuration compatible with
|
|
/// <see cref="Writer"/>.
|
|
/// </returns>
|
|
/// <remarks>
|
|
/// Configuration deserialization is delegated to
|
|
/// <see cref="ComponentCfgBase.CreateFromDbEntity"/>.
|
|
/// </remarks>
|
|
public IComponentCfg CmpntCfgFromCmpntEntity(
|
|
Config.Entities.Component component)
|
|
{
|
|
return ComponentCfgBase.CreateFromDbEntity(
|
|
WriterCfg.Serializer,
|
|
component,
|
|
this);
|
|
}
|
|
}
|
|
} |