コード例 #1
0
        /// <summary>
        /// ProcessTXField
        /// </summary>
        /// <param name="CurrentField">CurrentField</param>
        /// <param name="inputData">inputData</param>
        /// <returns>string</returns>
        private string ProcessTXField(XmlNode CurrentField, XmlNode inputData)
        {
            string             result          = string.Empty;
            CobolFormatLibrary cobolLibraryObj = new CobolFormatLibrary();

            try
            {
                XmlNode namedItem  = CurrentField.Attributes.GetNamedItem("ID");
                XmlNode formatItem = CurrentField.Attributes.GetNamedItem("Format");
                XmlNode offsetItem = CurrentField.Attributes.GetNamedItem("Offset");
                if (formatItem != null && namedItem != null)
                {
                    string DataByte = cobolLibraryObj.ConvertToByteString(inputData.InnerXml, formatItem.InnerText);

                    if (offsetItem != null)
                    {
                        int offset = Convert.ToInt32(offsetItem.InnerText);
                        if (offset > 0)
                        {
                            string offsetBytes = new string('0', offset);
                            DataByte = offsetBytes + DataByte;
                        }
                    }
                    result += DataByte;
                }
            }
            catch (Exception ex)
            {
                //throw new Exception("ProcessTXField: " + ex.Message);
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// ProcessField
        /// </summary>
        /// <param name="CurrentField">CurrentField</param>
        /// <param name="DataNode">DataNode</param>
        /// <returns>XmlNode</returns>
        private XmlNode ProcessField(XmlNode CurrentField, XmlNode DataNode)
        {
            XmlNode            result;
            CobolFormatLibrary cobolLibraryObj = new CobolFormatLibrary();

            try
            {
                XmlNode namedItem  = CurrentField.Attributes.GetNamedItem("ID");
                XmlNode formatItem = CurrentField.Attributes.GetNamedItem("Format");
                XmlNode offsetItem = CurrentField.Attributes.GetNamedItem("Offset");

                if (offsetItem != null)
                {
                    int offset = Convert.ToInt32(offsetItem.InnerText);
                    m_RXHostPosPointer += offset;
                }
                int txtLen = cobolLibraryObj.GetFormatStringLength(formatItem.InnerText);
                if (m_byteStream.Length < m_RXHostPosPointer + txtLen)
                {
                    int shortTxtLen = m_byteStream.Length - m_RXHostPosPointer;
                    int moreLength  = txtLen - shortTxtLen;
                    CurrentField.InnerText = m_byteStream.Substring(m_RXHostPosPointer, shortTxtLen);

                    for (int i = 0; i < moreLength; i++)
                    {
                        CurrentField.InnerText = CurrentField.InnerText + " ";
                    }
                }
                else
                {
                    CurrentField.InnerText = m_byteStream.Substring(m_RXHostPosPointer, txtLen);
                }

                m_RXHostPosPointer += txtLen;

                XmlNode xmlNode2 = DataNode.OwnerDocument.CreateElement(namedItem.InnerText);
                xmlNode2.InnerText = CurrentField.InnerText;
                result             = xmlNode2;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(result);
        }