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.
123 lines
3.6 KiB
C#
123 lines
3.6 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace TBF.Rig.Output.DataStorage.UniDataStorageWriter.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// Request for write operation.
|
|
/// Contains batch of write items.
|
|
/// </summary>
|
|
public class DataWriteRequest
|
|
{
|
|
public DataWriteRequest()
|
|
{
|
|
InsertItems = new List<InsertWriteItem>();
|
|
UpdateItems = new List<UpdateWriteItem>();
|
|
StoredProcedureParameters = new List<StoredProcedureWriteParameter>();
|
|
Payload = string.Empty;
|
|
OutputFileName = string.Empty;
|
|
Mode = WriteMode.Insert;
|
|
}
|
|
|
|
public WriteMode Mode { get; set; }
|
|
|
|
public List<InsertWriteItem> InsertItems { get; private set; }
|
|
|
|
public List<UpdateWriteItem> UpdateItems { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Parameters passed to a stored procedure when Mode is StoredProcedure.
|
|
/// The stored procedure name itself is resolved from WriterCfg.WriteTemplates.
|
|
/// </summary>
|
|
public List<StoredProcedureWriteParameter> StoredProcedureParameters { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Optional complete payload generated by a higher-level component.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// File-oriented payload writers use this field when the complete
|
|
/// serialized document is already available and must be written without
|
|
/// converting it back to individual column/value pairs.
|
|
/// </remarks>
|
|
public string Payload { get; set; }
|
|
|
|
/// <summary>
|
|
/// Optional output file name suggested by the caller.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The physical output directory is still defined by
|
|
/// <see cref="WriterCfg.DataSource"/>. Writers may generate a safe default
|
|
/// file name when this value is empty.
|
|
/// </remarks>
|
|
public string OutputFileName { get; set; }
|
|
}
|
|
|
|
public enum WriteMode
|
|
{
|
|
Insert,
|
|
Update,
|
|
Upsert,
|
|
Append,
|
|
StoredProcedure
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generic parameter types supported by the Microsoft SQL stored procedure writer.
|
|
/// </summary>
|
|
public enum StoredProcedureParameterType
|
|
{
|
|
String,
|
|
Xml,
|
|
Int32,
|
|
Int64,
|
|
Decimal,
|
|
Boolean,
|
|
DateTime
|
|
}
|
|
|
|
public class InsertWriteItem
|
|
{
|
|
public string ColumnName { get; set; }
|
|
public string Value { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{ColumnName} = {Value}";
|
|
}
|
|
}
|
|
|
|
public class UpdateWriteItem
|
|
{
|
|
public string WhereParameterName { get; set; }
|
|
public string WhereValue { get; set; }
|
|
|
|
public string SetParameterName { get; set; }
|
|
public string SetValue { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"WHERE {WhereParameterName} = {WhereValue} -> SET {SetParameterName} = {SetValue}";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// One parameter passed to a stored procedure.
|
|
/// Value is object so the writer can preserve the requested SQL data type.
|
|
/// </summary>
|
|
public class StoredProcedureWriteParameter
|
|
{
|
|
public string ParameterName { get; set; }
|
|
public object Value { get; set; }
|
|
public StoredProcedureParameterType ParameterType { get; set; }
|
|
|
|
public StoredProcedureWriteParameter()
|
|
{
|
|
ParameterType = StoredProcedureParameterType.String;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{ParameterName} ({ParameterType}) = {Value}";
|
|
}
|
|
}
|
|
}
|