Beispiel #1
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;
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        //'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        public void PopulateBuffer(XmlDocument oXML, string sSection, ref string[] vData)
        {
            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)
                {
                    dataLength = CopMvcUtil.GetInt(lTmplXML.DocumentElement.GetAttributeNode("LENGTH").InnerText);
                }

                count = CopMvcUtil.GetInt(lTmplXML.DocumentElement.GetAttributeNode("OCCURS").InnerText);
                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     len_lChild = CopMvcUtil.GetInt(lChildNode.Attributes.GetNamedItem("LENGTH").InnerText);
                                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', len_lChild - VB.len(sTemp)) + sTemp;
                                }
                                else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "C")
                                {
                                    sTemp = sTemp.Replace(".", "");
                                    sTemp = sTemp.Replace(",", "");
                                    sTemp = sTemp.Replace("$", "");

                                    sData = sData + new string('0', len_lChild - VB.len(sTemp)) + sTemp;
                                }
                                else if (lChildNode.Attributes.GetNamedItem("TYPE").InnerText == "D")
                                {
                                    if (VB.IsDate(sTemp))
                                    {
                                        DateTime Tempdate;
                                        DateTime.TryParse(sTemp, out Tempdate);
                                        lYear  = CopMvcUtil.GetString(Tempdate.Year);
                                        lMonth = CopMvcUtil.GetString(Tempdate.Month);
                                        lDay   = CopMvcUtil.GetString(Tempdate.Day);

                                        if (VB.len(lYear) < 4)
                                        {
                                            if (CopMvcUtil.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(len_lChild - VB.len(sTemp));
                                }
                                else
                                {
                                    sData = sData + sTemp + VB.space(len_lChild - VB.len(sTemp));
                                }
                            }
                        }

                        WriteDebugFile("VALUE_IF_J.txt", j.ToString());

                        string[] varray = new string[j + 1];

                        if (vData != null && vData.Length > 0)
                        {
                            if (vData.Length > varray.Length)
                            {
                                for (int i = 0; i < varray.Length; i++)
                                {
                                    varray[i] = vData[i];
                                }
                            }
                            else
                            {
                                vData.CopyTo(varray, 0);
                            }
                        }
                        varray[j] = sData;
                        vData     = varray;
                    }
                }
            }
        }