示例#1
0
            // Occurs whenever UI task is expecting valid saturn 5 damage report to be provided.
            private void OnReportDataUploadRequired(object sender, UserWithSaturn5DamageReportEventArgs e)
            {
                // Displays appropriate logs informing user that application began uploading the saturn 5 confirmation data.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ReportingDamageDataBegan(sender, e);

                // Report the damage based on the DamageReportCreationForm
                Task reportingDamageTask = this._saturn5Services.ReportDamageAsync(e.Saturn5.SerialNumber, e.User.Username, e.Description);

                reportingDamageTask.ContinueWith((t) =>
                {
                    switch (t.Status)
                    {
                    case TaskStatus.RanToCompletion:
                        // ... execute if successfully reported the damage
                        // Get just reported damage:
                        Saturn5Issue damage = this._saturn5Services.GetLastUnresolvedDamage(e.Saturn5.SerialNumber);
                        this.OnUploadingSaturn5ReportingDamageDataSucceed(sender, new UserWithDamagedSaturn5EventArgs(e.User, e.Saturn5, damage));
                        break;

                    case TaskStatus.Faulted:
                        // ... execute if failed to report the damage
                        this.OnUploadingSaturn5ReportingDamageDataFailed(sender, e);
                        break;

                    case TaskStatus.Canceled:
                        // ... execute if attempt to report the damage has been canceled.
                        this.OnUploadingSaturn5ReportingDamageDataCanceled(sender, e);
                        break;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
示例#2
0
            // Occurs whenever attempt to commit damage data upload failed
            private void OnUploadingSaturn5ReportingDamageDataFailed(object sender, UserWithSaturn5DamageReportEventArgs e)
            {
                // Print operation failure logs.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ReportingDamageDataFailed(sender, e);

                // Ask user what to do in case of failure
                DialogResult result = MessageBox.Show($"Failed to report Saturn 5 unit damage. Would You like to retry? Or would you like to cancel and close the application.", "Failed to report Saturn 5 unit damage.", MessageBoxButtons.RetryCancel);

                if (result == DialogResult.Retry)
                {
                    // If user pressed 'Retry' button, reattempt to connect with database.
                    this.OnReportDataUploadRequired(sender, e);
                    return;
                }

                // Otherwise close the application.
                this._form.Close();
            }
示例#3
0
            // Occurs whenever attempt to commit damage data upload has been canceled
            private void OnUploadingSaturn5ReportingDamageDataCanceled(object sender, UserWithSaturn5DamageReportEventArgs e)
            {
                // Displays appropriate logs informing user that application canceled obtaining user data.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ReportingDamageDataCanceled(sender, e);
                this._consolesServices.OnBackToIdle(sender, e);

                // Clears the content of all of the main form text boxes displaying User/Satur5 etc. data.
                this._dataDisplayServices.ClearAllDataDisplayTextBoxes(sender, e);

                // Clears info boxes
                this._dataDisplayServices.ClearInfoBoxes(sender, e);

                // Enables/Disables appropriate controls.
                this._controlsEnabler.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ReportingDamageDataCanceled(sender, e);
            }