// Occurs whenever UI task is expecting valid saturn 5 damage fault to be provided.
            private void OnAwaitingFaultReport(object sender, UserWithSaturn5EventArgs e)
            {
                // Display appropriate logs informing user that application is await to provide fault report.
                this._consolesServices.OnConfirmBackInFaultySaturn5BySerialNumber_AwaitingFaultReport(sender, e);

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

                // Open fault report creation form ..
                FaultReportCreationForm faultReportCreationForm = new FaultReportCreationForm(this._app, e.Saturn5);

                faultReportCreationForm.FormClosed += (s, args) =>
                {
                    // If FaultReportCreationForm has been closed by user pressing save button...
                    if (faultReportCreationForm.Commit)
                    {
                        this.OnReportDataUploadRequired(sender, new UserWithSaturn5FaultReportEventArgs(e.User, e.Saturn5, faultReportCreationForm.Description));
                    }
                    else
                    {
                        // .. execute UITask cancellation ..
                        this.OnAwaitingFaultReportCanceled(sender, e);
                    }
                };

                faultReportCreationForm.ShowDialog(this._form);
            }
Exemplo n.º 2
0
            // Occurs whenever Saturn5 data got successfully retrieved.
            private void OnSuccessfullyRetrievedSaturn5Data(object sender, UserWithSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application completed obtaining saturn 5 data.
                this._consolesServices.OnRetrievingUserAndSaturn5DataCompleted(sender, e);

                // Set text boxes according to the current state of the UITask.
                this._dataDisplayServices.OnRetrievingUserAndSaturn5DataCompleted(sender, e);

                // Displays appropriate logs informing user that application began uploading the saturn 5 allocation data.
                this._consolesServices.OnAllocateSaturn5ByShortId_UploadingSaturn5AllocationDataBegan(sender, e);

                // Attempt to allocate saturn 5 by short id ...
                Task allocateSaturn5ByShortIdTask = this._preBriefServices.AllocateSaturn5ByShortIdAsync(e.Saturn5.ShortId, e.User.Username);

                // ... once finished...
                allocateSaturn5ByShortIdTask.ContinueWith((t) =>
                {
                    switch (t.Status)
                    {
                    // ... if allocated saturn 5 successfully...
                    case TaskStatus.RanToCompletion:
                        // ...OnSucceed.
                        this.OnSucceed(sender, new UserWithSaturn5EventArgs(e.User, e.Saturn5));
                        break;

                    // ... if failed to allocate saturn 5...
                    case TaskStatus.Faulted:
                        // ... get flatten collection of exception responsible for the task failure.
                        IReadOnlyCollection <Exception> innerExceptions = t.Exception.Flatten().InnerExceptions;

                        // If task failed because saturn 5 unit which allocation has been attempted is damaged...
                        if (innerExceptions.Any(ex => ex.GetType() == typeof(AttemptToAllocateDamagedSaturn5Exception)))
                        {
                            // .. OnAttemptToAllocateDamagedSaturn5
                            this.OnAttemptToAllocateDamagedSaturn5(sender, e);
                        }
                        // Otherwise if task failed because saturn 5 unit which allocation has been attempted is faulty...
                        else if (innerExceptions.Any(ex => ex.GetType() == typeof(AttemptToAllocateFaultySaturn5Exception)))
                        {
                            // .. OnAttemptToAllocateFaultySaturn5
                            this.OnAttemptToAllocateFaultySaturn5(sender, e);
                        }
                        // Otherwise if task failed because of some other reason...
                        else
                        {
                            // .. OnFailed
                            this.OnFailed(sender, e);
                        }
                        break;

                    // .. if canceled to allocate saturn 5
                    case TaskStatus.Canceled:
                        // .. OnCanceled
                        this.OnCanceled(sender, e);
                        break;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
Exemplo n.º 3
0
            // Occurs whenever saturn 5 allocation completed successfully.
            private void OnSucceed(object sender, UserWithSaturn5EventArgs e)
            {
                // Informs user about success of the saturn 5 allocation
                this._consolesServices.OnAllocateSaturn5ByShortId_Succeed(sender, e);
                this._consolesServices.OnBackToIdle(sender, e);

                // Enable appropriate controls.
                this._controlsEnabler.OnAllocateSaturn5ByShortId_Succeed(sender, e);
            }
            // Occurs whenever saturn 5 confirmation completed successfully.
            private void OnSucceed(object sender, UserWithSaturn5EventArgs e)
            {
                // Informs user about success of the saturn 5 confirmation
                this._consolesServices.OnConfirmBackInSaturn5BySerialNumber_Succeed(sender, e);
                this._consolesServices.OnBackToIdle(sender, e);

                // Enable appropriate controls.
                this._controlsEnabler.OnConfirmBackInSaturn5BySerialNumber_Succeed(sender, e);
            }
Exemplo n.º 5
0
            // Occurs when canceled whilst application was attempting to retrieve user data.
            private void OnSuccessfullyRetrievedUserData(object sender, UserWithSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application completed obtaining user and saturn 5 data.
                this._consolesServices.OnRetrievingUserAndSaturn5DataCompleted(sender, e);

                // Set text boxes according to the current state of the UITask.
                this._dataDisplayServices.OnRetrievingUserAndSaturn5DataCompleted(sender, e);

                // Proceed withing UITask
                this.OnAwaitingFaultReport(sender, new Saturn5EventArgs(e.Saturn5));
            }
Exemplo n.º 6
0
            // Occures whenever saturn 5 allocation process has been canceled.
            private void OnCanceled(object sender, UserWithSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application canceled allocating saturn 5
                this._consolesServices.OnAllocateSaturn5ByShortId_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.OnAllocateSaturn5ByShortId_Canceled(sender, e);
            }
Exemplo n.º 7
0
            // Occurs whenever saturn5 unit provided for allocation has been found to be marked as faulty.
            private void OnAttemptToAllocateFaultySaturn5(object sender, UserWithSaturn5EventArgs e)
            {
                // Inform user that saturn 5 unit provided by then for allocation is faulty and cannot be allocated.
                this._consolesServices.OnAllocateSaturn5ByShortId_AttemptToAllocateFaultySaturn5(sender, new Saturn5EventArgs(e.Saturn5));
                DialogResult result = MessageBox.Show($"Saturn 5 serial number: {e.Saturn5.SerialNumber} has been marked as faulty and cannot be allocated to the user. Would you like to try to allocate different Saturn 5 unit (Yes) or cancel (No)?", "Unable to allocate damage Saturn 5 unit.", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    this.OnAwaitingShortId(sender, new UserEventArgs(e.User));
                }
                else
                {
                    this.OnCanceled(sender, e);
                }
            }
            // Occurs whenever saturn 5 confirmation process has been canceled.
            private void OnCanceled(object sender, UserWithSaturn5EventArgs e)
            {
                // Print appropriate logs.
                this._consolesServices.OnConfirmBackInSaturn5BySerialNumber_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.OnConfirmBackInSaturn5BySerialNumber_Canceled(sender, e);
            }
            private void OnAwaitingFaultReportCanceled(object sender, UserWithSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application canceled obtaining user data.
                this._consolesServices.OnConfirmBackInFaultySaturn5BySerialNumber_AwaitingFaultReportCanceled(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.OnConfirmBackInFaultySaturn5BySerialNumber_AwaitingFaultReportCanceled(sender, e);
            }
            // Occurs whenever UITask is ready/require data upload to proceed.
            private void OnDataUploadRequired(object sender, UserWithSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application began uploading the saturn 5 confirmation data.
                this._consolesServices.OnConfirmBackInSaturn5BySerialNumber_UploadingSaturn5ConfirmationDataBegan(sender, e);

                // Attempt to confirm saturn 5 unit in depot by serial number, ...
                Task confirmBackInSaturn5BySerialNumberTask = this._deBriefServices.ConfirmInDepotSaturn5BySerialNumberAsync(e.Saturn5.SerialNumber, this._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());
            }
Exemplo n.º 11
0
            // Occurs whenever saturn 5 allocation failed from some other reason then unit being faulty or damaged.
            private void OnFailed(object sender, UserWithSaturn5EventArgs e)
            {
                // Print operation failure logs.
                this._consolesServices.OnAllocateSaturn5ByShortId_Failed(sender, e);

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

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

                // Otherwise close the application.
                this._form.Close();
            }
            // Occurs whenever saturn 5 confirmation failed.
            private void OnFailed(object sender, UserWithSaturn5EventArgs e)
            {
                // Print operation failure logs.
                this._consolesServices.OnConfirmBackInSaturn5BySerialNumber_Failed(sender, e);

                // Ask user what to do in case of failure
                DialogResult result = MessageBox.Show($"Failed to confirm back in Saturn 5 unit. Would You like to retry? Or would you like to cancel and close the application.", "Failed to 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();
            }
            private void OnAttemptToConfirmStarUserSaturn5(object sender, UserWithSaturn5EventArgs 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);
                }
            }
            // Occurs whenever Saturn5 data got successfully retrieved.
            private void OnSuccessfullyRetrievedSaturn5Data(object sender, UserWithSaturn5EventArgs e)
            {
                // Displays appropriate logs informing user that application completed obtaining saturn 5 data.
                this._consolesServices.OnRetrievingUserAndSaturn5DataCompleted(sender, e);

                // Set text boxes according to the current state of the UITask.
                this._dataDisplayServices.OnRetrievingUserAndSaturn5DataCompleted(sender, e);

                // Displays appropriate logs informing user that application began uploading the saturn 5 emergency allocation data.
                this._consolesServices.OnEmergencyAllocateSaturn5BySerialNumber_UploadingSaturn5AllocationDataBegan(sender, e);

                // Attempt to emergency allocate saturn 5 by serial number, ...
                Task emergencyAllocateSaturn5BySerialNumberTask = this._preBriefServices.EmergencyAllocateSaturn5BySerialNumberAsync(e.Saturn5.SerialNumber, e.User.Username);

                // ... once finished...
                emergencyAllocateSaturn5BySerialNumberTask.ContinueWith((t) =>
                {
                    switch (t.Status)
                    {
                    // ... if allocated saturn 5 successfully...
                    case TaskStatus.RanToCompletion:
                        // ...OnSucceed.
                        this.OnSucceed(sender, new UserWithSaturn5EventArgs(e.User, e.Saturn5));
                        break;

                    // ... if failed to allocate saturn 5...
                    case TaskStatus.Faulted:
                        // .. OnFailed
                        this.OnFailed(sender, e);
                        break;

                    // .. if canceled to allocate saturn 5
                    case TaskStatus.Canceled:
                        // .. OnCanceled
                        this.OnCanceled(sender, e);
                        break;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
Exemplo n.º 15
0
            public void OnRetrievingUserAndSaturn5DataCompleted(object sender, UserWithSaturn5EventArgs e)
            {
                this.OnRetrievingUserDataCompleted(sender, new UserEventArgs(e.User));

                this.OnRetrievingSaturn5DataCompleted(sender, new Saturn5EventArgs(e.Saturn5));
            }