コード例 #1
0
            // Occurs whenever saturn 5 received from IT data get uploaded successfully
            private void OnReportDataUploadSucceed(object sender, Saturn5SendToITEventArgs e)
            {
                // Displays appropriate logs informing user that application successfully committed the data.
                this._consolesServices.OnSaturn5SendToIT_ReportDataUploadSucceed(sender, e);

                // Enables/Disables appropriate controls.
                this._controlsEnabler.OnSaturn5SendToIT_ReportDataUploadSucceed(sender, e);
            }
コード例 #2
0
            // Occurs whenever saturn 5 send to it data failed to get uploaded.
            private void OnReportDataUploadFailed(object sender, Saturn5SendToITEventArgs e)
            {
                // Displays appropriate logs informing user about failed data upload.
                this._consolesServices.OnSaturn5SendToIT_ReportDataUploadFailed(sender, e);

                // Informs user about application failed to send saturn 5 to IT and as such being unable to continue.
                MessageBox.Show("Application failed to send saturn 5 to IT and remove it from the depot stock and must be closed.", "Saturn 5 send to IT failed.", MessageBoxButtons.OK);

                // Close the application.
                this._form.Close();
            }
コード例 #3
0
            private void OnAttemptToSendToITLastSaturn5(object sender, Saturn5SendToITEventArgs e)
            {
                // Displays appropriate logs informing user about failed data upload.
                this._consolesServices.OnSaturn5SendToIT_AttemptToSendToITLastSaturn5(sender, e);

                // Informs user about application failed to send saturn 5 to IT and as such being unable to continue.
                MessageBox.Show("Unable to send to IT last Saturn 5 unit from the depot stock.", "Unable to send to IT Saturn 5.", MessageBoxButtons.OK);

                // Cancel saturn 5 send to IT operation.
                this.OnReportDataUploadCanceled(sender, e);
            }
コード例 #4
0
            // Occurs whenever saturn 5 send to it data canceled to get uploaded.
            private void OnReportDataUploadCanceled(object sender, Saturn5SendToITEventArgs e)
            {
                // Displays appropriate logs informing user that application canceled data upload
                this._consolesServices.OnSaturn5SendToIT_ReportDataUploadCanceled(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.OnSaturn5SendToIT_ReportDataUploadCanceled(sender, e);
            }
コード例 #5
0
            // Occurs whenever saturn 5 sent to it report has been provided and required to be committed.
            private void OnReportDataUploadRequired(object sender, Saturn5SendToITEventArgs e)
            {
                // Displays appropriate logs/application state/user instructions text to the user.
                this._consolesServices.OnSaturn5SendToIT_UploadingReportDataBegan(sender, e);

                // Attempt to commit saturn 5 send to IT data
                Task saturn5SendToITTask = this._saturn5Services.SendToITAsync(e.SerialNumber, e.ConsignmentNumber, e.IncidentNumber, e.MovementNote, e.Surplus);

                saturn5SendToITTask.ContinueWith((t) =>
                {
                    switch (t.Status)
                    {
                    case TaskStatus.RanToCompletion:
                        // ... execute if saturn 5 receive from IT has been committed successfully
                        this.OnReportDataUploadSucceed(sender, e);
                        break;

                    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 removal has been attempted is the last unit in the depot stock...
                        if (innerExceptions.Any(ex => ex.GetType() == typeof(AttemptToRemoveLastSaturn5Exception)))
                        {
                            // .. AttemptToSendToITLastSaturn5
                            this.OnAttemptToSendToITLastSaturn5(sender, e);
                        }
                        // Otherwise if task failed because of some other reason...
                        else
                        {
                            this.OnReportDataUploadFailed(sender, e);
                        }
                        break;

                    case TaskStatus.Canceled:
                        // ... execute if saturn 5 receive from IT has been canceled to commit
                        this.OnReportDataUploadCanceled(sender, e);
                        break;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }