Example #1
0
        /// <summary>
        /// Used for reading a list of possible values that a user can select from in a drop-down box.
        /// The xml format should have a collection of nodes with two sub-nodes each (code and description)
        /// This proceedure assumes that there are always two sub-nodes. The first is the ID and the second
        /// is the description.
        /// </summary>
        /// <param name="fileName">Absoulute path to the xml file</param>
        /// <param name="nErrorCode">0 for success, error code if failure</param>
        /// <returns>Collection of results (Code & Description)</returns>
        public static List <MLHC_ListItem> ReadXmlList(string strFileName, ref int nErrorCode)
        {
            var xmlValues = new List <MLHC_ListItem>();

            nErrorCode = 0;
            MLHC_ListItem result; // store individual result to add to returned list

            // Open XML file and test output
            FileStream xmlFile = new FileStream(strFileName, FileMode.Open);

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreWhitespace = true;

            using (XmlReader xmlReader = XmlReader.Create(xmlFile, settings))
            {
                while (xmlReader.Read())
                {
                    // If at the error tag (will be before any other nodes)
                    if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "ERROR")
                    {
                        // Read next node to get error value
                        xmlReader.Read();
                        nErrorCode = Int32.Parse(xmlReader.Value);
                    }
                    // If in any other start node and no error
                    else if (nErrorCode == 0 && xmlReader.NodeType == XmlNodeType.Element &&
                             xmlReader.Name != "ROOT")
                    {
                        result = new MLHC_ListItem();

                        // Skip to first text node and read value into id
                        while (xmlReader.Read() && xmlReader.NodeType != XmlNodeType.Text)
                        {
                            ;
                        }
                        result.Code = xmlReader.Value;

                        // Skip to next text node and read value into description
                        while (xmlReader.Read() && xmlReader.NodeType != XmlNodeType.Text)
                        {
                            ;
                        }
                        result.Description = HttpUtility.UrlDecode(xmlReader.Value);

                        xmlValues.Add(result);
                    }
                }
            }
            xmlFile.Close();
            return(xmlValues);
        }
Example #2
0
        /// <summary>
        /// Gets a list of all office values available
        /// </summary>
        /// <returns>List of offices for drop-down list control</returns>
        public List <MLHC_ListItem> GetOffices()
        {
            var offices = new List <MLHC_ListItem>();

            foreach (EscrowOffice office in m_escrowOffices)
            {
                MLHC_ListItem item = new MLHC_ListItem();
                item.Code        = office.strOfficeID;
                item.Description = office.strOfficeName;
                offices.Add(item);
            }

            return(offices);
        }
Example #3
0
        /// <summary>
        /// Gets a list of escrow officers at a given office
        /// </summary>
        /// <param name="strOfficeID">OfficeID to load escrow officers from</param>
        /// <returns>List of escrow officers for drop-down list control</returns>
        public List <MLHC_ListItem> GetOfficers(string strOfficeID)
        {
            var officers = new List <MLHC_ListItem>();

            foreach (EscrowOfficer officer in m_escrowOfficers)
            {
                if (officer.strOfficeID == strOfficeID)
                {
                    MLHC_ListItem item = new MLHC_ListItem();

                    item.Code        = officer.strUserID;
                    item.Description = officer.strUserName;
                    officers.Add(item);
                }
            }

            return(officers);
        }