private static string CreateMessageSpec(CBC_OECD cbcMessage) { var messageSpec = new StringBuilder(); messageSpec.AppendFormat("<div><table {0}>", GetTableAttributes()); messageSpec.Append("<tr>"); messageSpec.Append("<td colspan=\"12\">"); messageSpec.AppendFormat("<table {0}>", GetTableAttributes()); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Transmitting Country</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.TransmittingCountry, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Message Type</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.MessageType, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Language</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.Language, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Warning</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.Warning, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Contact</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.Contact, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Message Ref Id</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.MessageRefId, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Message Type Indicator</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1}>{0}</td>", cbcMessage.MessageSpec.MessageTypeIndic, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Reporting Period</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1} class=\"sdate\">{0}</td>", cbcMessage.MessageSpec.ReportingPeriod, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<tr>"); messageSpec.AppendFormat("<th nowrap {0}>Timestamp</th>", GetColumnAttributes()); messageSpec.AppendFormat("<td nowrap {1} class=\"sdate\">{0}</td>", cbcMessage.MessageSpec.Timestamp, GetColumnAttributes()); messageSpec.Append("</tr>"); messageSpec.Append("<table>"); messageSpec.Append("<td>"); messageSpec.Append("</tr>"); return(messageSpec.ToString()); }
public static ReportData Convert(CBC_OECD model) { return(new ReportData { Version = SupportedSchema.OECD_101, Message = GetMessage(model.MessageSpec), Reports = model.CbcBody.SelectOrEmpty(GetReport).ToArray(), }); }
private void StartWork() { // xsd.exe CbcXML_v2.0.xsd /Classes oecdcbctypes_v5.0.xsd /Classes isocbctypes_v1.1.xsd var cbc_oecd = new CBC_OECD(); ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial; using (var package = new ExcelPackage(xlsxFile)) { gloabalDocSpec = new DocSpec_Type { DocTypeIndic = GetOECDDocTypeIndicEnumType(GetExcelStringValue(package, "CoverPage", "B24")), // (S: CoverPage; Cells: B24) DocRefId = GetExcelStringValue(package, "CoverPage", "B25"), // "ZA2018DOCBAW", // (S: CoverPage; Cells: B25) CorrDocRefId = "", CorrMessageRefId = "" }; cbc_oecd.version = "2.0"; cbc_oecd.MessageSpec = GetMessageSpec(package); cbc_oecd.CbcBody = GetCbcBodies(package).ToArray(); } var xml = ""; XmlSerializer xsSubmit = new XmlSerializer(typeof(CBC_OECD)); using (var sww = new StringWriter()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; using (XmlWriter writer = XmlWriter.Create(sww, settings)) { xsSubmit.Serialize(writer, cbc_oecd); xml = sww.ToString(); // Your XML } } using (StreamWriter file = new StreamWriter(xmlFilePath)) { file.Write(xml); } }
private void StartWork() { // xsd.exe CbcXML_v1.0.1.xsd /Classes oecdtypes_v4.1.xsd /Classes isocbctypes_v1.0.1.xsd var cbc_oecd = new CBC_OECD(); ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial; using (var package = new ExcelPackage(xlsxFile)) { gloabalDocSpec = new DocSpec_Type { DocTypeIndic = EnumLookup.GetOECDDocTypeIndicEnumType(GetExcelStringValue(package, "CoverPage", "B24")), // (S: CoverPage; Cells: B24) DocRefId = GetExcelStringValue(package, "CoverPage", "B25"), // "ZA2018DOCBAW", // (S: CoverPage; Cells: B25) CorrDocRefId = "", CorrMessageRefId = "" }; cbc_oecd.version = "1.0"; cbc_oecd.MessageSpec = GetMessageSpec(package); cbc_oecd.CbcBody = GetCbcBodies(package).ToArray(); } }