コード例 #1
0
ファイル: Form_Repository.cs プロジェクト: srmchem/TEAM
        private void ButtonGenerateDatabaseSamples(object sender, EventArgs e)
        {
            if (backgroundWorkerSampleData.IsBusy != true)
            {
                // create a new instance of the alert form
                _alertSampleDataCreationInDatabase = new Form_Alert();
                // event handler for the Cancel button in AlertForm
                _alertSampleDataCreationInDatabase.Show();
                _alertSampleDataCreationInDatabase.ShowLogButton(false);

                backgroundWorkerSampleData.RunWorkerAsync();
            }
        }
コード例 #2
0
ファイル: Form_Repository.cs プロジェクト: srmchem/TEAM
        private void buttonClick_GenerateMetadata(object sender, EventArgs e)
        {
            if (backgroundWorkerMetadata.IsBusy != true)
            {
                // Create a new instance of the alert form, disabling most stuff.
                _alertSampleJsonMetadata = new Form_Alert();
                _alertSampleJsonMetadata.ShowLogButton(false);
                _alertSampleJsonMetadata.ShowCancelButton(false);
                _alertSampleJsonMetadata.ShowProgressBar(false);
                _alertSampleJsonMetadata.ShowProgressLabel(false);
                _alertSampleJsonMetadata.Show();

                // Start the asynchronous operation to create / move the sample Json files.
                backgroundWorkerMetadata.RunWorkerAsync();
            }
        }
コード例 #3
0
        private void displayEventLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (backgroundWorkerEventLog.IsBusy != true)
            {
                // create a new instance of the alert form
                _alertEventLog      = new Form_Alert();
                _alertEventLog.Text = "Event Log";
                _alertEventLog.ShowLogButton(false);
                _alertEventLog.ShowCancelButton(false);
                _alertEventLog.ShowProgressBar(false);
                _alertEventLog.ShowProgressLabel(false);
                _alertEventLog.Show();

                // Start the asynchronous operation.
                backgroundWorkerEventLog.RunWorkerAsync();
            }
        }
コード例 #4
0
ファイル: Form_Repository.cs プロジェクト: srmchem/TEAM
        /// <summary>
        /// /// Run a SQL command against the provided database connection, capture any errors and report feedback to the Sample data screen.
        /// </summary>
        /// <param name="connString"></param>
        /// <param name="createStatement"></param>
        /// <param name="worker"></param>
        /// <param name="progressCounter"></param>
        /// <param name="targetForm"></param>
        private static void RunSqlCommandSampleDataForm(string connString, string createStatement, BackgroundWorker worker, int progressCounter, Form_Alert targetForm)
        {
            using (var connectionVersion = new SqlConnection(connString))
            {
                var commandVersion = new SqlCommand(createStatement, connectionVersion);

                try
                {
                    connectionVersion.Open();
                    commandVersion.ExecuteNonQuery();

                    worker.ReportProgress(progressCounter);
                    targetForm.SetTextLogging(createStatement);
                }
                catch (Exception ex)
                {
                    string errorMessage = $"An error has occurred with the following query: \r\n\r\n{createStatement}.\r\n\r\nThe error message is {ex}.";
                    GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, errorMessage));

                    targetForm.SetTextLogging(errorMessage + "\r\n\r\n");
                    targetForm.SetTextLogging("This occurred with the following query: " + createStatement + "\r\n\r\n");
                }
            }
        }