Ejemplo n.º 1
0
 public Issuance()
 {
     //nothing
     this.driver = null;
     this.issuance_date = new DateTime();
 }
Ejemplo n.º 2
0
        /*
         *  <xml>
         *      <result>value(true or false)</result>
         *      <driver>
         *          <id>value</id>
         *          <no>value</no>
         *          <fn>value</fn>
         *          <mn>value</mn>
         *          <ln>value</ln>
         *          <add>value</add>
         *          <res>value</res>
         *          <sex>value</sex>
         *          <nat>value</nat>
         *          <bd>value</bd>
         *          <stat>value</stat>
         *      </driver>
         *  </xml>
         * */
        public static Driver processLicenseResult(string xml_str)
        {
            TextReader str_reader = new StringReader(xml_str);

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreComments = true;
            settings.IgnoreWhitespace = true;

            try
            {
                XmlReader reader = XmlReader.Create(str_reader, settings);
                Driver result;
                //xml tag
                reader.Read();
                //result tag
                reader.Read();
                //if found
                if (String.Compare(reader.ReadString(), "true") == 0)
                {
                    result = new Driver();
                    //driver tag
                    reader.Read();
                    //id tag
                    reader.Read();

                    //get driver information values
                    try
                    {
                        result.DriverId = reader.ReadElementContentAsInt();
                    }
                    catch (Exception err)
                    {
                        string msg = err.Message;
                        result.DriverId = -1;
                    }
                    result.LicenceNumber = reader.ReadElementContentAsString();
                    result.FirstName = reader.ReadElementContentAsString();
                    result.MiddleName = reader.ReadElementContentAsString();
                    result.LastName = reader.ReadElementContentAsString();
                    result.Address = reader.ReadElementContentAsString();
                    result.Restrictions = reader.ReadElementContentAsString();

                    try
                    {
                        result.Gender = reader.ReadElementContentAsInt();
                    }
                    catch (Exception err)
                    {
                        //default male if walay gibutang
                        string msg = err.Message;
                        result.Gender = 1;
                    }
                    result.Nationality = reader.ReadElementContentAsString();
                    try
                    {
                        result.BirthDate = DateTime.Parse(reader.ReadElementContentAsString());
                    }
                    catch (Exception err)
                    {
                        string msg = err.Message;
                        result.BirthDate = new DateTime();
                    }
                    try
                    {
                        result.LicenseStatus = reader.ReadElementContentAsInt();
                    }
                    catch (Exception err)
                    {
                        string msg = err.Message;
                        result.LicenseStatus = -1;
                    }
                }
                //if not found or result is false
                else
                {
                    result = null;
                }
                str_reader.Close();
                return result;
            }
            catch (Exception err)
            {
                string error_msg = "";
                str_reader.Close();
                error_msg = err.Message;
                return null;
            }
        }