private string FormatOutMessage(CDatM1 m1, bool shouldAddHeading, string m1ID) { trace.Write(TraceLevel.Info, ">>FormatOutMessage"); string fnResult = ""; try { Dictionary <string, string> elements = ExtractM1DataToMessage(m1, m1ID); XmlDocument doc = new XmlDocument(); XmlElement raiz; if (shouldAddHeading) { raiz = doc.CreateElement("ap"); XmlAttribute attributo = doc.CreateAttribute("id"); attributo.Value = m1.GetIdentifier().ToString(); raiz.Attributes.Append(attributo); doc.AppendChild(raiz); } else { raiz = doc.DocumentElement; } foreach (KeyValuePair <string, string> nodo in elements) { if (!nodo.Key.Equals("Acst")) { raiz.AppendChild( CreateElement(doc, nodo.Key, nodo.Value)); } } fnResult = doc.InnerXml; if (m1.GetOutStepsCalculationString().Length > 0) { int nPos = fnResult.LastIndexOf("</ap>"); fnResult = fnResult.Insert(nPos, (m1.GetOutStepsCalculationString())); } trace.Write(TraceLevel.Info, fnResult); } catch (Exception error) { trace.Write(TraceLevel.Error, error.ToLogString()); fnResult = ""; } trace.Write(TraceLevel.Info, "<<FormatOutMessage"); return(fnResult); }
private Dictionary <string, string> ExtractM1DataToMessage(CDatM1 m1, string m1ID) { trace.Write(TraceLevel.Debug, ">>ExtractM1DataToMessage"); Dictionary <string, string> elements = new Dictionary <string, string>(); try { elements.Add($"{m1ID}r", m1.GetOutResult().ToString()); if (m1.GetOutResult() > 0) { elements.Add($"{m1ID}q1", m1.GetOutMinImport().ToString()); elements.Add($"{m1ID}q2", m1.GetOutMaxImport().ToString()); if (m1.GetInComputeTimeLimits()) { elements.Add($"{m1ID}t1", m1.GetOutMinTime().ToString()); elements.Add($"{m1ID}t2", m1.GetOutMaxTime().ToString()); if (m1.GetOutMinOperDate().GetStatus() != COPSDateStatus.Null) { elements.Add($"{m1ID}d1", m1.GetOutMinOperDate().CopyToChar()); } if (m1.GetOutMaxOperDate().GetStatus() != COPSDateStatus.Null) { elements.Add($"{m1ID}d2", m1.GetOutMaxOperDate().CopyToChar()); } } elements.Add($"{m1ID}t", m1.GetOutEfMaxTime().ToString()); elements.Add($"{m1ID}o", m1.GetInOperType().ToString()); if (m1.GetOutOperDateEnd().GetStatus() != COPSDateStatus.Null) { elements.Add($"{m1ID}d", m1.GetOutOperDateEnd().CopyToChar()); } if (m1.GetOutOperDateIni().GetStatus() != COPSDateStatus.Null) { elements.Add($"{m1ID}di", m1.GetOutOperDateIni().CopyToChar()); } elements.Add($"{m1ID}g", m1.GetInGroup().ToString()); elements.Add($"{m1ID}ad", m1.GetInArticleDef().ToString()); elements.Add($"{m1ID}aq", m1.GetOutAccumulateMoney().ToString()); elements.Add($"{m1ID}at", m1.GetOutAccumulateTime().ToString()); elements.Add($"{m1ID}aqag", m1.GetOutAccumulateMoneyAllGroup().ToString()); elements.Add($"{m1ID}atag", m1.GetOutAccumulateTimeAllGroup().ToString()); if (m1.GetOutOperDateIni0().GetStatus() != COPSDateStatus.Null) { elements.Add($"{m1ID}d0", m1.GetOutOperDateIni0().CopyToChar()); } elements.Add($"{m1ID}q", m1.GetOutRetImport().ToString()); if (m1.GetOutOperDateRealIni().GetStatus() != COPSDateStatus.Null) { elements.Add($"{m1ID}dr0", m1.GetOutOperDateRealIni().CopyToChar()); } elements.Add($"{m1ID}raq", m1.GetOutRealAccumulateMoney().ToString()); elements.Add($"{m1ID}rat", m1.GetOutRealAccumulateTime().ToString()); if (m1.GetOutWholeOperationWithChipCard() != 0) { elements.Add($"{m1ID}chca", m1.GetOutWholeOperationWithChipCard().ToString()); } if (m1.GetOutWholeOperationWithMobile() != 0) { elements.Add($"{m1ID}mobi", m1.GetOutWholeOperationWithMobile().ToString()); } if (m1.GetOutPostPay() != 0) { elements.Add($"{m1ID}pp", m1.GetOutPostPay().ToString()); } if (m1.GetOutIsResident() != 0) { elements.Add($"{m1ID}resi", m1.GetOutIsResident().ToString()); } if (m1.GetOutIsVIP() != 0) { elements.Add($"{m1ID}vip", m1.GetOutIsVIP().ToString()); } string strOutStepsCalculationString = m1.GetOutStepsCalculationString(); if (strOutStepsCalculationString.Length > 0) { elements.Add($"{m1ID}cst", m1.GetOutStepsCalculationString()); } } } catch (Exception error) { trace.Write(TraceLevel.Error, error.ToLogString()); } trace.Write(TraceLevel.Debug, "<<ExtractM1DataToMessage"); return(elements); }