Beispiel #1
0
        private void btnCreateNewLoggingTask_Click(object sender, EventArgs e)
        {
            try
            {
                var liveServer = ddLoggingServer.SelectedItem as ExternalDatabaseServer;

                string target = "";

                string toCreate = cbxDataLoadTasks.Text;

                if (liveServer != null)
                {
                    target = liveServer.Server + "." + liveServer.Database;
                }

                if (string.IsNullOrEmpty(target))
                {
                    MessageBox.Show("You must select a logging server");
                    return;
                }

                if (Activator.YesNo("Create a new dataset and new data task called \"" + toCreate + "\" in " + target, "Create new logging task"))
                {
                    if (liveServer != null)
                    {
                        LoggingDatabaseChecker checker = new LoggingDatabaseChecker(liveServer);
                        checker.Check(this);

                        new LogManager(liveServer)
                        .CreateNewLoggingTaskIfNotExists(toCreate);
                    }

                    MessageBox.Show("Done");

                    RefreshTasks();
                }

                RefreshUIFromDatabase();
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }
        }
Beispiel #2
0
        public static void Show(string message, Exception exception, bool isModalDialog = true)
        {
            var longMessage = "";

            //if the API user is not being silly and passing a message that is the exception anyway!
            if (message.StartsWith(exception.Message))
            {
                if (exception.InnerException != null)
                {
                    longMessage = ExceptionHelper.ExceptionToListOfInnerMessages(exception.InnerException);
                }
            }
            else
            {
                longMessage = ExceptionHelper.ExceptionToListOfInnerMessages(exception);
            }

            if (message.Trim().Contains("\n"))
            {
                var split = message.Trim().Split('\n');
                message = split[0];

                longMessage = string.Join(Environment.NewLine, split.Skip(1)) + Environment.NewLine + Environment.NewLine + longMessage;
            }

            //if there's still no body to the error make the title the body and put a generic title in
            if (string.IsNullOrWhiteSpace(longMessage))
            {
                longMessage = message;
                message     = "Error";
            }

            ExceptionViewer ev = new ExceptionViewer(message, longMessage, exception);

            if (isModalDialog)
            {
                ev.ShowDialog();
            }
            else
            {
                ev.Show();
            }
        }
Beispiel #3
0
        private void RefreshTasks()
        {
            ExternalDatabaseServer liveserver = ddLoggingServer.SelectedItem as ExternalDatabaseServer;
            var server = DataAccessPortal.GetInstance().ExpectServer(liveserver, DataAccessContext.Logging);

            if (liveserver != null)
            {
                cbxDataLoadTasks.Items.Clear();

                try
                {
                    LogManager lm = new LogManager(server);
                    cbxDataLoadTasks.Items.AddRange(lm.ListDataTasks());
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show(e);
                }
            }
        }
        private void btnSelectToClipboard_Click(object sender, EventArgs e)
        {
            try
            {
                //this is used only to generate the SQL preview of how to resolve primary key collisions so no username/password is required - hence the null,null
                PrimaryKeyCollisionResolver resolver = new PrimaryKeyCollisionResolver(_table);

                if (sender == btnCopyPreview)
                {
                    System.Windows.Forms.Clipboard.SetText(resolver.GeneratePreviewSQL());
                }

                if (sender == btnCopyDetection)
                {
                    System.Windows.Forms.Clipboard.SetText(resolver.GenerateCollisionDetectionSQL());
                }
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }
        }