예제 #1
0
            // Occurs whenever validation of the value provided by the user failed, and the user didn't agree to retry.
            private void OnProvidedShortIdValidationFailed(object sender, UserWithSaturn5ShortIdEventArgs e)
            {
                // Displays appropriate logs informing user about empty short id input being provided.
                this._consolesServices.OnAllocateSaturn5ByShortId_ProvidedShortIdValidationFailed(sender, e);

                // Close the application.
                this._form.Close();
            }
예제 #2
0
            // Occurs whenever user pressed enter when appropriate for this UI task validation box is enable,
            // and right before a validation of provided by the user value will begin.
            private void OnProvidedShortIdValidationBegan(object sender, UserWithSaturn5ShortIdEventArgs e)
            {
                // Subscribe to appropriate cancellation method
                this.ChangeCancelationMethodForShortIdInput(e);

                // Displays appropriate logs informing user about empty short id input being provided.
                this._consolesServices.OnAllocateSaturn5ByShortId_ProvidedShortIdValidationBegan(sender, e);
            }
예제 #3
0
            // Occurs whenever app canceled to obtain saturn 5 data from provided valid short id.
            private void OnCancelToRetrieveSaturn5Data(object sender, UserWithSaturn5ShortIdEventArgs e)
            {
                // Displays appropriate logs informing user that application canceled obtaining saturn 5 data.
                this._consolesServices.OnRetrievingSaturn5DataByShortIdCanceled(sender, new Saturn5ShortIdEventArgs(e.ShortId));
                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_CancelToRetrieveSaturn5Data(sender, e);
            }
예제 #4
0
            // Occurs whenever validation of the value provided by the user has been canceled.
            private void OnProvidedShortIdValidationCanceled(object sender, UserWithSaturn5ShortIdEventArgs e)
            {
                // Stop listening for short idtext box input.
                this.StopListenForShortIdInput();

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

                // Displays appropriate logs informing
                this._consolesServices.OnAllocateSaturn5ByShortId_ProvidedShortIdValidationCanceled(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);
            }
예제 #5
0
            // Occurs whenever app fails to obtain saturn 5 data from provided valid short id.
            private void OnFailToRetrieveSaturn5Data(object sender, UserWithSaturn5ShortIdEventArgs e)
            {
                // Displays appropriate logs informing user that application failed to obtaining saturn 5 data .
                this._consolesServices.OnRetrievingSaturn5DataByShortIdFailed(sender, new Saturn5ShortIdEventArgs(e.ShortId));

                // Ask user what to do in case of failure
                DialogResult result = MessageBox.Show($"Application failed to obtain saturn 5 data using provided barcode: {e.ShortId} {Environment.NewLine}Would You like to Retry or Cancel the operation?", "Failed to obtain saturn 5 data.", MessageBoxButtons.RetryCancel);

                switch (result)
                {
                case DialogResult.Cancel:
                    this.OnCancelToRetrieveSaturn5Data(sender, e);
                    break;

                case DialogResult.Retry:
                    this.OnValidShortIdProvided(sender, e);
                    break;
                }
            }
예제 #6
0
            // Occurs whenever user provided valid short id into the appropriate preBrief text box
            private void OnValidShortIdProvided(object sender, UserWithSaturn5ShortIdEventArgs e)
            {
                // Stop listening for saturn 5 short id
                this.StopListenForShortIdInput();

                // Displays appropriate logs informing user about valid short id being provided.
                this._consolesServices.OnAllocateSaturn5ByShortId_ValidShortIdProvided(sender, new Saturn5ShortIdEventArgs(e.ShortId));

                // Disables saturn short id input text box
                this._controlsEnabler.OnAllocateSaturn5ByShortId_ValidShortIdProvided(sender, e);

                // Displays appropriate logs informing user that application began to obtaining Saturn5 data based on the provided short id
                this._consolesServices.OnRetrievingSaturn5DataByShortIdBegan(sender, new Saturn5ShortIdEventArgs(e.ShortId));

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

                // Attempt to obtain saturn 5 data...
                Task <Saturn5> getSaturn5Task = this._saturn5Services.GetByShortIdAsync(e.ShortId);

                getSaturn5Task.ContinueWith((t) =>
                {
                    switch (t.Status)
                    {
                    case TaskStatus.RanToCompletion:
                        // ... execute if succeed to obtain saturn 5 data.
                        this.OnSuccessfullyRetrievedSaturn5Data(sender, new UserWithSaturn5EventArgs(e.User, t.Result));
                        break;

                    case TaskStatus.Faulted:
                        // ... execute if failed to obtain saturn 5 data.
                        this.OnFailToRetrieveSaturn5Data(sender, e);
                        break;

                    case TaskStatus.Canceled:
                        // ... execute if attempt to obtain saturn 5 data has been canceled.
                        this.OnCancelToRetrieveSaturn5Data(sender, e);
                        break;
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
예제 #7
0
            private void StopListenForShortIdInput()
            {
                if (this.tbxPreBriefSaturn5Barcode.InvokeRequired)
                {
                    Action d = new Action(StopListenForShortIdInput);
                    if (!this.tbxPreBriefSaturn5Barcode.IsDisposed)
                    {
                        this.tbxPreBriefSaturn5Barcode.Invoke(d);
                    }
                }
                else if (!this.tbxPreBriefSaturn5Barcode.IsDisposed)
                {
                    this.AwaitingShortIdCanceled   -= this.OnAwaitingShortIdCanceled;
                    this.ValidatingShortIdCanceled -= this.OnProvidedShortIdValidationCanceled;
                    this.tbxPreBriefSaturn5Barcode.InputValidationBegan      -= this.OnProvidedShortIdValidationBegan;
                    this.tbxPreBriefSaturn5Barcode.InputValidationFailed     -= this.OnProvidedShortIdValidationFailed;
                    this.tbxPreBriefSaturn5Barcode.InputValidationCanceled   -= this.OnProvidedShortIdValidationCanceled;
                    this.tbxPreBriefSaturn5Barcode.ValidInputValueProvided   -= this.OnValidShortIdProvided;
                    this.tbxPreBriefSaturn5Barcode.EmptyInputValueProvided   -= this.OnEmptyShortIdProvided;
                    this.tbxPreBriefSaturn5Barcode.InvalidInputValueProvided -= this.OnInvalidShortIdProvided;

                    this._shortIdValidationCancelationArgs = null;
                }
            }
예제 #8
0
            private void ChangeCancelationMethodForShortIdInput(UserWithSaturn5ShortIdEventArgs e)
            {
                if (this.tbxPreBriefSaturn5Barcode.InvokeRequired)
                {
                    Action <UserWithSaturn5ShortIdEventArgs> d = new Action <UserWithSaturn5ShortIdEventArgs>(ChangeCancelationMethodForShortIdInput);
                    if (!this.tbxPreBriefSaturn5Barcode.IsDisposed)
                    {
                        this.tbxPreBriefSaturn5Barcode.Invoke(d, e);
                    }
                }
                else if (!this.tbxPreBriefSaturn5Barcode.IsDisposed)
                {
                    this._shortIdValidationCancelationArgs = e;

                    this.AwaitingShortIdCanceled -= this.OnAwaitingShortIdCanceled;
                    //this.AwaitingShortIdCanceled += this.OnAwaitingShortIdCanceled;

                    this.ValidatingShortIdCanceled -= this.OnProvidedShortIdValidationCanceled;
                    this.ValidatingShortIdCanceled += this.OnProvidedShortIdValidationCanceled;

                    this.tbxPreBriefSaturn5Barcode.InputValidationCanceled -= this.OnProvidedShortIdValidationCanceled;
                    this.tbxPreBriefSaturn5Barcode.InputValidationCanceled += this.OnProvidedShortIdValidationCanceled;
                }
            }
예제 #9
0
 // Occurs whenever user will provide invalid short id.
 private void OnInvalidShortIdProvided(object sender, UserWithSaturn5ShortIdEventArgs e)
 {
     // Displays appropriate logs informing user about invalid short id being provided.
     this._consolesServices.OnAllocateSaturn5ByShortId_InvalidShortIdProvided(sender, e);
 }
예제 #10
0
 // Occurs whenever user will provide empty value in place of valid short id number.
 private void OnEmptyShortIdProvided(object sender, UserWithSaturn5ShortIdEventArgs e)
 {
     // Displays appropriate logs informing user about empty short id number input being provided.
     this._consolesServices.OnAllocateSaturn5ByShortId_EmptyShortIdProvided(sender, e);
 }