Esempio n. 1
0
            // Occurs whenever saturn 5 confirmation completed successfully.
            private void OnSucceed(object sender, UserWithDamagedSaturn5EventArgs e)
            {
                // Informs user about success of the saturn 5 confirmation
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_Succeed(sender, e);
                this._consolesServices.OnBackToIdle(sender, e);

                // Enable appropriate controls.
                this._controlsEnabler.OnConfirmBackInDamageSaturn5BySerialNumber_Succeed(sender, e);
            }
Esempio n. 2
0
            // Occurs whenever attempt to commit damage data upload has been completed successfully
            private void OnUploadingSaturn5ReportingDamageDataSucceed(object sender, UserWithDamagedSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user about valid serial number being provided.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ReportingDamageDataSucceed(sender, e);

                // Disables saturn 5 serial number input text box
                this._controlsEnabler.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ReportingDamageDataSucceed(sender, e);

                // Proceed withing UITask
                this.OnDataUploadRequired(sender, e);
            }
Esempio n. 3
0
            // Occurs whenever saturn 5 confirmation process has been canceled.
            private void OnCanceled(object sender, UserWithDamagedSaturn5EventArgs e)
            {
                // Print appropriate logs.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_Canceled(sender, e);
                this._consolesServices.OnBackToIdle(sender, e);

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

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

                // Enable appropriate controls.
                this._controlsEnabler.OnConfirmBackInDamageSaturn5BySerialNumber_Canceled(sender, e);
            }
Esempio n. 4
0
            // Occurs whenever UITask is ready/require data upload to proceed.
            private void OnDataUploadRequired(object sender, UserWithDamagedSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application began uploading the saturn 5 confirmation data.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_UploadingSaturn5ConfirmationDataBegan(sender, e);

                // Attempt to confirm saturn 5 unit in depot by serial number, ...
                Task confirmBackInSaturn5BySerialNumberTask = this._deBriefServices.ConfirmInDepotSaturn5BySerialNumberAsync(e.Saturn5.SerialNumber, _throwOnLastSeenWithStarUser);

                // ... once finished...
                confirmBackInSaturn5BySerialNumberTask.ContinueWith((t) =>
                {
                    switch (t.Status)
                    {
                    // ... if confirmed saturn 5 unit back in depot successfully...
                    case TaskStatus.RanToCompletion:
                        // ...OnSucceed.
                        this.OnSucceed(sender, e);
                        break;

                    // ... if failed to confirmed saturn 5 unit back in depot ...
                    case TaskStatus.Faulted:
                        // Get flatten collection of exceptions which caused task to fail.
                        IList <Exception> connectTaskExceptions = t.Exception.Flatten().InnerExceptions;

                        // If task failed because saturn5 attempted to be confirm back in depot is currently allocated to star user..
                        if (connectTaskExceptions.Any((ex) => { return(ex.GetType() == typeof(AttemptToConfirmStarUserSaturn5Exception)); }))
                        {
                            // execute appropriate method to give user a choice to proceeding or canceling the UITAsk.
                            this.OnAttemptToConfirmStarUserSaturn5(sender, e);
                        }
                        // .. otherwise if failed to obtain saturn 5 data for any other reason.
                        else
                        {
                            this.OnFailed(sender, e);
                        }
                        break;

                    // .. if canceled attempt to confirmed saturn 5 unit back in depot ...
                    case TaskStatus.Canceled:
                        // .. OnCanceled
                        this.OnCanceled(sender, e);
                        break;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
Esempio n. 5
0
            // Occurs whenever saturn 5 confirmation failed.
            private void OnFailed(object sender, UserWithDamagedSaturn5EventArgs e)
            {
                // Print operation failure logs.
                this._consolesServices.OnConfirmBackInDamageSaturn5BySerialNumber_Failed(sender, e);

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

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

                // Otherwise close the application.
                this._form.Close();
            }
Esempio n. 6
0
            private void OnAttemptToConfirmStarUserSaturn5(object sender, UserWithDamagedSaturn5EventArgs e)
            {
                // Ask user what to do
                DialogResult result = MessageBox.Show($"You are attempting to confirm back Saturn5 unit currently allocated to one of the STAR USERs: {e.User.Username} - {e.User.FirstName}  {e.User.Surname}. Are you sure you want to do that?", "Attempt to confirm Star User allocated Saturn5.", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                // If user pressed 'Yes' button, reattempt to confirm back in saturn 5 unit
                {
                    this._throwOnLastSeenWithStarUser = false;
                    this.OnDataUploadRequired(sender, e);
                }
                // .. otherwise ..
                else
                {
                    // .. cancel attempt confirm back in saturn 5 unit
                    this.OnCanceled(sender, e);
                }
            }