private void ExecuteQuery()
        {
            SQL.DataAccess dataAccess       = new SQL.DataAccess();
            string         queryString      = new TextRange(ResourceContent.Document.ContentStart, ResourceContent.Document.ContentEnd).Text;
            var            property         = MainModel.Instance.SelectedProfile.Properties.Where(p => p.Key == "cs").FirstOrDefault();
            string         connectionString = property == null? string.Empty : property.Value;

            if (queryString.StartsWith("-- SQL"))
            {
                string result = dataAccess.ExecuteQuery(connectionString, queryString);
                PreviewHtml.NavigateToString(result);
            }

            if (queryString.StartsWith("-- MD"))
            {
                var result = Markdown.ToHtml(queryString);
                PreviewHtml.NavigateToString(result);
            }
        }
Пример #2
0
        private void ExecuteQuery(bool openWindow)
        {
            SQL.DataAccess dataAccess       = new SQL.DataAccess();
            string         queryString      = new TextRange(ResourceContent.Document.ContentStart, ResourceContent.Document.ContentEnd).Text;
            var            property         = MainModel.Instance.SelectedProfile.Properties.Where(p => p.Key == "cs").FirstOrDefault();
            string         connectionString = property == null? string.Empty : property.Value;

            if (queryString.StartsWith("-- SQL"))
            {
                if (string.IsNullOrEmpty(connectionString))
                {
                    MessageBox.Show("Please define a property named cs with the value of your connectionString in your current environment or change the environment from " + MainModel.Instance.SelectedProfile.Name, "No connection string defined!");
                    return;
                }
                string result = dataAccess.ExecuteQuery(connectionString, queryString);
                string theme  = File.ReadAllText("Resources/Theme/Default/style.css");
                string view   = "<style>" + theme + "</style>" + result;
                File.WriteAllText("Results.html", view);
                if (openWindow)
                {
                    Process.Start("Results.html");
                }
                PreviewHtml.NavigateToString(view);
                if (string.IsNullOrEmpty(MainModel.Instance.JsonRepresentation))
                {
                    PreviewJson.NavigateToString("Parse Error");
                }
                else
                {
                    PreviewJson.NavigateToString(MainModel.Instance.JsonRepresentation);
                }
                PreviewHtml.NavigateToString(result);
            }

            if (queryString.StartsWith("-- MD"))
            {
                var result = Markdown.ToHtml(queryString);
                PreviewHtml.NavigateToString(result);
            }
        }