RctXmlService¶
Implements IRctXmlService, converting staged RCT policy/location data into schema-validated RCT XML import files and writing them out in batches to a target folder. It depends only on IUnitOfWork for reading staged policy, location, and county data; it embeds an XSD schema as a manifest resource for validation and uses reflection-based helpers to read field values by expression for XML field formatting.
Purpose¶
- Loads staged RCT policies (with their locations) and the county reference list needed to build RCT XML.
- Builds an
RCTImportXML document graph from staged policy/location data, including client info, address, contact details, and inspector assignment. - Serializes an
RCTImportto an XML string and validates it against the embedded RCT XSD schema, routing invalid documents to an errors subfolder. - Splits large staging sets into multiple output files (batched by a configurable policy count) and writes each to the target FTP/output folder.
Context¶
- Namespace:
SAIF.Services.Rct - Assembly/package:
SAIF.Services(packaged inside theSAIF.SAIFCode.CoreNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| RctXmlService(...) | public RctXmlService(IUnitOfWork unitOfWork) |
Validates unitOfWork is non-null via Enforce.ArgumentNotNull and wires it in. |
| GetPolicyStagingData | public IEnumerable<RctPolicyStagingData> GetPolicyStagingData { get; } |
Returns all staged policies ordered by policy number, each populated with its associated staged locations, mapped to contracts. |
| GetCounties | public IEnumerable<County> GetCounties { get; } |
Returns the county reference list ordered by name, with a synthetic "Out of state" (code C7, state WA) entry appended. |
| GetXmlAndWriteXmlFilesOut | public StringDictionary GetXmlAndWriteXmlFilesOut(string path, int outputNumberOfPolicies, out int filesWritten, out int policiesWritten) |
Splits all staged policies into batches of outputNumberOfPolicies (defaulting to 5000 when 0), builds and validates the RCT XML for each batch, writes valid batches to path and invalid ones to an errors subfolder, and reports how many files/policies were written; returns an empty result immediately if the target path is null or the embedded XSD resource cannot be found. |
| WriteXmlToFtpFolder | public void WriteXmlToFtpFolder(string path, RCTImport xmlString) |
Serializes the given RCTImport and writes it to the specified file path, wrapping any I/O failure in an Exception with a descriptive message. |
| GetRctXmlMemoryString | public string GetRctXmlMemoryString(RCTImport xmlRctImport) |
Serializes an RCTImport object graph to a UTF-8 XML string with an empty default namespace, using an in-memory stream. |
| FormatPolicyXml | public RCTImport FormatPolicyXml(ReadOnlyCollection<RctPolicyStagingData> policyList, ReadOnlyCollection<County> countyList) |
Builds an RCTImport containing one Client per staged policy, populating name, address, phone/fax/email, inspector, extended fields, and location list from the policy's primary location and county reference data. |
Behavioral notes¶
- Schema validation (
ValidateRctXml) loads the embedded resourceSAIF.Services.Rct.EvolutionSAIF.xsd; if that resource is missing,GetXmlAndWriteXmlFilesOutaborts entirely and reports an error rather than writing unvalidated files. - Documents that fail XSD validation are still written out, but to an
errors\subfolder instead of the normal output path, so invalid batches are never silently dropped. GetXmlAndWriteXmlFilesOutoutput file names are timestamped (yyyyMMddHHmmss) and sequentially numbered per batch, so repeated runs within the same folder do not overwrite prior output.- The private static
ReturnValuesdictionary accumulates validation errors/warnings across calls via the sharedXmlValidationEventHandler, meaning validation messages from one call can persist into a subsequent call on the same service instance unless cleared*.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
- Services/SAIF.Services/Rct/RctXmlService.cs