Пример #1
0
        ///<summary>Optionally set hasConnectionLost true to keep the calling thread here until a connection to the Middle Tier connection can be established
        ///in the event of a web connection failure. Set hasConnectionLost to false if a throw is desired when a connection cannot be made.</summary>
        public static DataTable ProcessGetTableLow(DtoGetTableLow dto, bool hasConnectionLost = true)
        {
            string result = SendAndReceive(dto, hasConnectionLost);

            try {
                return(XmlConverter.XmlToTable(result));
            }
            catch (Exception ex) {
                throw ProcessExceptionDeserialize(result, ex);
            }
        }
Пример #2
0
        public static DataTable ProcessGetTableLow(DtoGetTableLow dto)
        {
            string result = SendAndReceive(dto);

            try {
                return(XmlConverter.XmlToTable(result));
            }
            catch {
                DtoException exception = (DtoException)DataTransferObject.Deserialize(result);
                throw new Exception(exception.Message);
            }
        }
Пример #3
0
        public void ReadXml(XmlReader reader)
        {
            reader.ReadToFollowing("TypeName");
            reader.ReadStartElement("TypeName");
            TypeName = reader.ReadString();
            reader.ReadEndElement();            //TypeName
            while (reader.NodeType != XmlNodeType.Element)
            {
                reader.Read();                //gets rid of whitespace if in debug mode.
            }
            reader.ReadStartElement("Obj");
            while (reader.NodeType != XmlNodeType.Element)
            {
                reader.Read();
            }
            string strObj = reader.ReadOuterXml();

            //now get the reader to the correct location
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.Read();
            }
            reader.ReadEndElement();            //Obj
            while (reader.NodeType == XmlNodeType.Whitespace)
            {
                reader.Read();
            }
            if (reader.Name == "IsNull")           //Older versions that haven't updated to 17.3 yet may not have this element.
            {
                reader.ReadStartElement("IsNull");
                IsNull = (reader.ReadString().ToLower() == "true");
                reader.ReadEndElement();                //IsNull
            }
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                reader.Read();
            }
            reader.ReadEndElement();            //DtoObject
            //Now, process what we read.
            Type type = null;

            if (TypeName == "System.Drawing.Color")
            {
                type = typeof(int);
            }
            else
            {
                type = ConvertNameToType(TypeName);
            }
            XmlSerializer serializer = null;

            if (!type.IsInterface)
            {
                serializer = new XmlSerializer(type);
            }
            XmlTextReader reader2 = new XmlTextReader(new StringReader(strObj));

            if (TypeName == "System.Drawing.Color")
            {
                Obj = Color.FromArgb((int)serializer.Deserialize(reader2));
            }
            else if (TypeName == "System.Data.DataTable")
            {
                if (!IsNull)
                {
                    Obj = XmlConverter.XmlToTable(strObj);
                }
            }
            else if (type.IsInterface)
            {
                //We should only ever get here if the interface was null when serialized.
            }
            else
            {
                Obj = serializer.Deserialize(reader2);
            }
            if (IsNull)
            {
                Obj = null;
            }
            //Convert.ChangeType(serializer.Deserialize(reader2),type);
        }