//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' public void PopulateXML(string sSection, object vData, XmlDocument oTmplXML, ref XmlDocument oDataXML) { string[] lData = null; int iCounter = 0; int lStrLen = 0, lTotalStrLen = 0, lStrLenSum = 0; XmlNode lChildNode = null; int lPercision = 0; XmlDocument lobjXML = new XmlDocument(); lobjXML.LoadXml(xUtil.ispXmlGetRecordXml(oTmplXML, sSection, 0)); if (VB.IsArray(vData)) { string[] tempData = (string[])vData; lData = new string[tempData.Length]; for (int i = 0; i < tempData.Length; i++) { lData[i] = tempData[i]; } } else { lData = new string[1]; lData[0] = vData.ToString(); } iCounter = lData.Length; for (int i = 0; i < iCounter; i++) { lStrLenSum = 1; lTotalStrLen = VB.len(lData[i]); lData[i] = lData[i] + VB.space(Util.GetInt(lobjXML.DocumentElement.Attributes.GetNamedItem("LENGTH").InnerText) - VB.len(lData[i])); for (int j = 0; j < lobjXML.DocumentElement.ChildNodes.Count; j++) { lChildNode = lobjXML.DocumentElement.ChildNodes.Item(j); lChildNode.InnerText = string.Empty; } if (lTotalStrLen > 0) { for (int j = 0; j < lobjXML.DocumentElement.ChildNodes.Count; j++) { lChildNode = lobjXML.DocumentElement.ChildNodes.Item(j); lStrLen = Util.GetInt(lChildNode.Attributes.GetNamedItem("LENGTH").InnerText); lChildNode.InnerText = VB.mid(lData[i], lStrLenSum, lStrLen).Trim(); if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "N" && VB.IsNumeric(lChildNode.InnerText)) { if (lChildNode.Attributes.GetNamedItem("PERCISION") != null) { lPercision = Util.GetInt(lChildNode.Attributes.GetNamedItem("PERCISION").InnerText); lChildNode.InnerText = Util.GetString(VB.CDbl(VB.Left(lChildNode.InnerText, lStrLen - lPercision) + "." + VB.Right(lChildNode.InnerText, lPercision))); } else { lChildNode.InnerText = Util.GetString(VB.CDbl(lChildNode.InnerText)); } } else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "D") { if (VB.CSng(lChildNode.InnerText) == 0) { lChildNode.InnerText = string.Empty; } else { lChildNode.InnerText = VB.FormatDate(lChildNode.InnerText); } } else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "C") { if (VB.instr(1, lChildNode.InnerText, "-") != 0) { lChildNode.InnerText = lChildNode.InnerText.Replace("-", ""); lChildNode.InnerText = "-" + lChildNode.InnerText; } if (VB.CSng(lChildNode.InnerText) == 0) { lChildNode.InnerText = string.Empty; } else { if (VB.instr(1, lChildNode.InnerText, "-") != 0) { lChildNode.InnerText = VB.Left(lChildNode.InnerText, lStrLen - 2) + "." + VB.Right(lChildNode.InnerText, 2); } lChildNode.InnerText = VB.FormatCurrency(lChildNode.InnerText, 2); } } else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "P" && VB.IsNumeric(lChildNode.InnerText)) { if (VB.CSng(lChildNode.InnerText) == 0) { lChildNode.InnerText = string.Empty; } else { lChildNode.InnerText = CopMvcUtil.GetString(VB.Clng(lChildNode.InnerText)); } } lStrLenSum = lStrLenSum + lStrLen; } } if ((lTotalStrLen == 0 && i == 0) || lTotalStrLen != 0) { if (i == 0) { xUtil.ispXmlReplaceNode(ref oDataXML, sSection, i, lobjXML, sSection, i); } else { xUtil.ispAppendNodeXml(ref oDataXML, "*", 0, lobjXML, sSection, 0); } } } }
//''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' public void PopulateBuffer(XmlDocument oXML, string sSection, object vData, ref string gsDebugUp) //Overloaded { string liSectCounter = string.Empty; XmlDocument lTmplXML = new XmlDocument(); lTmplXML.LoadXml(xUtil.ispXmlGetRecordXml(oXML, sSection, 0)); liSectCounter = xUtil.ispXmlGetRecCount(oXML, sSection, ""); if (lTmplXML.DocumentElement.GetAttributeNode("OCCURS") != null) { int count = 0; string sTemp = string.Empty; string sData = string.Empty; string lYear = string.Empty, lMonth = string.Empty, lDay = string.Empty; int dataLength = 0; if (lTmplXML.DocumentElement.GetAttributeNode("LENGTH") != null) { int.TryParse(lTmplXML.DocumentElement.GetAttributeNode("LENGTH").InnerText, out dataLength); } int.TryParse(lTmplXML.DocumentElement.GetAttributeNode("OCCURS").InnerText, out count); if (count > 0) { for (int j = 0; j < count; j++) { sTemp = string.Empty; sData = string.Empty; int sectcounter = 0; int.TryParse(liSectCounter, out sectcounter); if (j >= sectcounter) { sData = sData + VB.space(dataLength); } else { for (int k = 0; k < lTmplXML.DocumentElement.ChildNodes.Count; k++) { XmlNode lChildNode = lTmplXML.DocumentElement.ChildNodes.Item(k); int.TryParse(lChildNode.Attributes.GetNamedItem("LENGTH").InnerText, out dataLength); sTemp = oXML.DocumentElement.GetElementsByTagName(sSection).Item(j).ChildNodes.Item(k).InnerText.Trim().ToUpper(); if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "N") { sData = sData + new string('0', dataLength - VB.len(sTemp)) + sTemp; } else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "C") { if (VB.IsNumeric(sTemp)) { sTemp = sTemp.Replace(".", ""); sTemp = sTemp.Replace(",", ""); sTemp = sTemp.Replace("$", ""); sTemp = VB.mid(VB.FormatCurrency(sTemp, 2), 0); } sData = sData + new string('0', dataLength - VB.len(sTemp)) + sTemp; sData = sData + sTemp + VB.space(dataLength - VB.len(sTemp)); } else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "D") { if (VB.IsDate(sTemp)) { DateTime Tempdate; DateTime.TryParse(sTemp, out Tempdate); lYear = Util.GetString(Tempdate.Year); lMonth = Util.GetString(Tempdate.Month); lDay = Util.GetString(Tempdate.Day); if (VB.len(lYear) < 4) { if (Util.GetInt(lYear) < 20) { lYear = "20" + lYear; } else { lYear = "19" + lYear; } if (VB.len(lMonth) < 2) { lMonth = "0" + lMonth; } if (VB.len(lDay) < 2) { lDay = "0" + lDay; } sTemp = lYear + lMonth + lDay; } else { sTemp = string.Empty; } sData = sData + sTemp + VB.space(dataLength - VB.len(sTemp)); } else { sData = sData + sTemp + VB.space(dataLength - VB.len(sTemp)); } } } if (VB.IsArray(vData)) { string[] tempData = (string[])vData; string[] varray = new string[tempData.Length]; tempData.CopyTo(varray, 0); gsDebugUp = gsDebugUp + sData; varray[j] = sData; vData = varray; } else { gsDebugUp = gsDebugUp + sData; vData = sData; } } } } } }