Beispiel #1
0
        public void ParseSQLiteResult(ref SQLiteResult AResult)
        {
            // Fehlerflag
            try {
                XElement Status = AResult.XML.Root.Element("Status");
                AResult.Error = Convert.ToBoolean(Status.Attribute("Error").Value);
                if (AResult.Error)
                {
                    AResult.ErrorMessage = Status.Attribute("ErrorMessage").Value;
                }
            } catch {
                AResult.Error        = true;
                AResult.ErrorMessage = "Client Error: Cannot parse error";
            }
            if (AResult.Error)
            {
                return;
            }

            // RowCount/FieldCount
            try {
                XElement Status = AResult.XML.Root.Element("Status");
                AResult.RowCount   = Convert.ToInt32(Status.Attribute("RowCount").Value);
                AResult.FieldCount = Convert.ToInt32(Status.Attribute("FieldCount").Value);
            } catch {
                AResult.Error        = true;
                AResult.ErrorMessage = "Client Error: Cannot parse row/field count";
            }
            if (AResult.Error)
            {
                return;
            }

            // Field Names
            try {
                XElement Fields = AResult.XML.Root.Element("Fields");
                IEnumerable <XElement> Field = from Element in Fields.Elements()
                                               select Element;

                AResult.Names = new string[AResult.FieldCount];
                for (int i = 0; i < AResult.FieldCount; i++)
                {
                    AResult.Names[i] = Field.ElementAt(i).Attribute("Name").Value;
                }
            } catch {
                AResult.Error        = true;
                AResult.ErrorMessage = "Client Error: Cannot parse row/field count";
            }
            if (AResult.Error)
            {
                return;
            }

            // Value/Type Names
            try {
                XElement Rows = AResult.XML.Root.Element("Rows");
                IEnumerable <XElement> Row = from Element in Rows.Elements()
                                             select Element;
                IEnumerable <XElement> Cols;

                AResult.Value = new string[AResult.RowCount, AResult.FieldCount];
                AResult.Type  = new string[AResult.RowCount, AResult.FieldCount];
                for (int r = 0; r < AResult.RowCount; r++)
                {
                    Cols = from Element in Row.ElementAt(r).Elements()
                           select Element;
                    for (int c = 0; c < AResult.FieldCount; c++)
                    {
                        AResult.Value[r, c] = Cols.ElementAt(c).Attribute("Value").Value;
                        AResult.Type[r, c]  = Cols.ElementAt(c).Attribute("Type").Value;
                    }
                }
            } catch {
                AResult.Error        = true;
                AResult.ErrorMessage = "Client Error: Cannot parse row/field count";
            }
            if (AResult.Error)
            {
                return;
            }
        }