private void OnExecute(Document document)
 {
     ResultSets.Clear();
     try
     {
         IEnumerable <DataTable> results;
         if (string.IsNullOrEmpty(ActiveDocumentSelectedText))
         {
             results = _sqliteService.ExecuteQuery(_activeDocument.Text, _activeDocument.DatabasePath);
         }
         else
         {
             results = _sqliteService.ExecuteQuery(ActiveDocumentSelectedText, _activeDocument.DatabasePath);
         }
         foreach (DataTable table in results)
         {
             ResultSets.Add(table);
         }
     }
     catch (Exception ex)
     {
         WpfMessageBox.ShowDialog("Execution Error", ex.Message, MessageBoxButton.OK, MessageIcon.Error);
     }
 }
Exemplo n.º 2
0
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            (_xmlSettings as IXmlSerializable).ReadXml(reader);
            int depth1 = reader.Depth + 1;

            if (reader.ReadToFirstChildElement())
            {
                while (reader.Depth >= depth1)
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Depth == depth1)
                    {
                        switch (reader.Name)
                        {
                        case "ResultSets":
                            if (ResultSets == null)
                            {
                                ResultSets = new List <IList <BindableDynamicObject> >();
                            }
                            else if (ResultSets.Count > 0)
                            {
                                ResultSets.Clear();
                            }

                            int depthResultSet = reader.Depth + 1;

                            if (reader.ReadToFirstChildElement())
                            {
                                while (reader.Depth >= depthResultSet)
                                {
                                    if (reader.NodeType == XmlNodeType.Element && reader.Depth == depthResultSet && reader.Name == "ResultSet")
                                    {
                                        List <BindableDynamicObject> resultSet = new List <BindableDynamicObject>();
                                        int depthRecord = reader.Depth + 1;

                                        if (reader.ReadToFirstChildElement())
                                        {
                                            while (reader.Depth >= depthRecord)
                                            {
                                                if (reader.NodeType == XmlNodeType.Element && reader.Depth == depthRecord && reader.Name == "Record")
                                                {
                                                    resultSet.Add(reader.ReadDynamicObject(_xmlSettings));
                                                }
                                                else
                                                {
                                                    reader.Read();
                                                }
                                            }
                                        }
                                        ResultSets.Add(resultSet);
                                    }
                                    else
                                    {
                                        reader.Read();
                                    }
                                }
                            }
                            break;

                        case "OutputParameters":
                            OutputParameters = reader.ReadDynamicObject(_xmlSettings);
                            break;

                        case "ReturnValue":
                            ReturnValue = reader.ReadValue(_xmlSettings);
                            break;

                        default:
                            reader.Read();
                            break;
                        }
                    }
                    else
                    {
                        reader.Read();
                    }
                }
            }
        }