Exemple #1
0
        private void ShowOverlay(bool reminderSet)
        {
            string posButtonTxt = WizardActivity.GetString(Resource.String.add_new_prospect);
            string message      = WizardActivity.GetString(Resource.String.successful_registration_message_prospect);

            if (reminderSet)
            {
                message = WizardActivity.GetString(Resource.String.prospect_followup_reminder_set);
            }

            _registrationFinishedFragment = new RegistrationFinishedFragment();
            Bundle arguments = new Bundle();

            arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, false);
            arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, true);
            arguments.PutString(RegistrationFinishedFragment.MessageKey, message);
            arguments.PutString(RegistrationFinishedFragment.BtnPositiveKey, posButtonTxt);
            arguments.PutString(RegistrationFinishedFragment.BtnNegativeKey, this.OverlayNegativeButtonText);
            arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey, WizardActivity.StartPoint.ToString());
            arguments.PutInt(RegistrationFinishedFragment.TitleResKey, Resource.String.prospect_registered_title);

            _registrationFinishedFragment.Arguments = arguments;

            WizardActivity.ShowOverlay(_registrationFinishedFragment, true);
        }
        /// <summary>
        /// Creates this fragment
        /// </summary>
        /// <param name="savedInstanceState">The saved state</param>
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (savedInstanceState != null)
            {
                this.registrationSuccessfulFragment = this.Activity.SupportFragmentManager.GetFragment(savedInstanceState, RegistrationSuccessfulFragment) as WizardOverlayFragment;
                this.registrationFailedFragment     = this.Activity.SupportFragmentManager.GetFragment(savedInstanceState, RegistrationSuccessfulFragment) as WizardOverlayFragment;
            }
        }
        private void RegistrationByDataCompleted(CustomerRegistrationCompletedEventArgs e)
        {
            this._registrationFinishedOverlay = new RegistrationFinishedFragment();

            Bundle arguments = new Bundle();

            arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, false);
            arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, e.Succeeded);
            arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey, this.ActivityBase.StartPointIntent.ToString());
            arguments.PutString(RegistrationFinishedFragment.BtnNegativeKey, this.OverlayNegativeButtonText);
            this._registrationFinishedOverlay.Arguments = arguments;

            this.WizardActivity.ShowOverlay(this._registrationFinishedOverlay, true);
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            this._startPointIntent = ActivityBase.StartPointIntent;
            string nationalId = string.Empty;
            string phone      = string.Empty;

            if (this.Arguments != null)
            {
                this._inWizard = this.Arguments.GetBoolean(InWizardActivity, true);
                nationalId     = this.Arguments.GetString(NationalIdKey);
                phone          = this.Arguments.GetString(PhoneKey);
            }

            if (savedInstanceState != null)
            {
                _personRegistrationInfo =
                    savedInstanceState.GetJsonObject <SalesApp.Core.BL.Models.People.Customer>(BundledRegistrationInfo);

                if (_inWizard)
                {
                    _registrationSuccessfulFragment =
                        Activity.SupportFragmentManager.GetFragment(savedInstanceState, RegistrationSuccessfulFragment)
                        as WizardOverlayFragment;
                    _registrationFailedFragment =
                        Activity.SupportFragmentManager.GetFragment(savedInstanceState, RegistrationFailedFragment) as
                        WizardOverlayFragment;
                    //startPointIntent = savedInstanceState.GetEnum<IntentStartPointTracker.IntentStartPoint>(StartPointIntentKey);
                }
                else
                {
                    _inWizard = savedInstanceState.GetBoolean(InWizardKey);
                }
            }

            if (!_inWizard)
            {
                if (_personRegistrationInfo == null)
                {
                    _personRegistrationInfo = new SalesApp.Core.BL.Models.People.Customer();
                    this._personRegistrationInfo.NationalId = nationalId;
                    this._personRegistrationInfo.Phone      = phone;
                }
            }

            _photoWidth  = Settings.Instance.CustomerPhotoWidthScale;
            _photoHeight = Settings.Instance.CustomerPhotoHeightScale;
        }
        private void RegistrationByFallbackFailed(int currentAttempt)
        {
            string posButtonTxt = this.WizardActivity.GetString(Resource.String.try_again);
            string negButtonTxt = this.WizardActivity.GetString(Resource.String.cancel_registration);

            string message = string.Format(this.WizardActivity.GetString(Resource.String.unified_sms_registration_failed_n_tries), currentAttempt);

            this._registrationFinishedOverlay = new RegistrationFinishedFragment();

            Bundle arguments = new Bundle();

            arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, true);
            arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, false);
            arguments.PutString(RegistrationFinishedFragment.MessageKey, message);
            arguments.PutString(RegistrationFinishedFragment.BtnPositiveKey, posButtonTxt);
            arguments.PutString(RegistrationFinishedFragment.BtnNegativeKey, negButtonTxt);
            arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey, this.ActivityBase.StartPointIntent.ToString());
            arguments.PutInt(RegistrationFinishedFragment.Retries, currentAttempt);
            this._registrationFinishedOverlay.Arguments = arguments;
            this.WizardActivity.ShowOverlay(this._registrationFinishedOverlay, true);
        }
        private void RegistrationByFallbackCompleted(CustomerRegistrationCompletedEventArgs e)
        {
            string posButtonTxt = this.WizardActivity.GetString(Resource.String.add_new_customer);

            this._registrationFinishedOverlay = new RegistrationFinishedFragment();
            string message =
                string.Format(this.WizardActivity.GetString(Resource.String.unified_sms_registration_failed_n_tries), 3);
            Bundle arguments = new Bundle();

            arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, true);
            arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, e.Succeeded);
            arguments.PutString(RegistrationFinishedFragment.MessageKey, message);
            arguments.PutString(RegistrationFinishedFragment.BtnPositiveKey, posButtonTxt);
            arguments.PutString(RegistrationFinishedFragment.BtnNegativeKey, this.OverlayNegativeButtonText);
            arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey,
                                this.ActivityBase.StartPointIntent.ToString());
            int maxFallbackTries = Settings.Instance.MaxFallbackRetries;

            arguments.PutInt(RegistrationFinishedFragment.Retries, maxFallbackTries);
            this._registrationFinishedOverlay.Arguments = arguments;

            this.WizardActivity.ShowOverlay(this._registrationFinishedOverlay, true);
        }
        /// <summary>
        /// Called when registration information has changed
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">The event arguments</param>
        private async void RegistrationStatusChanged(object sender, CustomerService.RegistrationStatusChangedEventArgs e)
        {
            this.registrationFailedFragment     = null;
            this.registrationSuccessfulFragment = null;

            this.Logger.Verbose(e.Response != null ? e.Response.ResponseText : "No response...");

            this.maxSmsTries = Settings.Instance.MaxFallbackRetries;

            // still trying to post via API
            if (!e.Response.Successful && e.Channel != DataChannel.Fallback)
            {
                // still trying to register customer, show progress
                string message       = this.WizardActivity.GetString(Resource.String.not_able_to_send);
                string messageDetail = string.Format(this.WizardActivity.GetString(Resource.String.retrying), e.NumberOfTries);
                this.WizardActivity.ShowWaitInfo(message, messageDetail);
            }
            else if (e.Response.RegistrationSuccessful)
            {
                this.savingProgress = SavingProgress.Succeeded;

                // make sure we show the processing fragment for some time
                // await this.FragmentShowAwaiter(this.processingShown, DateTime.Now);

                // pass boolean whether the registration was SMS to control the message to the user
                this.registrationSuccessfulFragment = new RegistrationFinishedFragment();
                Bundle arguments = new Bundle();
                arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, e.Channel == DataChannel.Fallback);
                arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, true);
                arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey, this.ActivityBase.StartPointIntent.ToString());
                this.registrationSuccessfulFragment.Arguments = arguments;
                this.WizardActivity.ShowOverlay(this.registrationSuccessfulFragment, true);
            }
            else if (e.Response.Successful && !e.Response.RegistrationSuccessful)
            {
                // if registration is not done, show error
                this.savingProgress = SavingProgress.Failed;

                // make sure we show the processing fragment for some time
                await this.FragmentShowAwaiter(this.processingShown, DateTime.Now);

                // pass boolean whether the registration was SMS to control the message to the user
                this.registrationFailedFragment = new RegistrationFinishedFragment();/*
                                                                                      * e.Channel == DataChannel.Fallback,
                                                                                      * true,
                                                                                      * this.ActivityBase.StartPointIntent);*/

                Bundle arguments = new Bundle();
                arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, e.Channel == DataChannel.Fallback);
                arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, true);
                arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey, this.ActivityBase.StartPointIntent.ToString());
                this.registrationFailedFragment.Arguments = arguments;

                this.WizardActivity.ShowOverlay(this.registrationFailedFragment, true);
            }
            else if (e.Channel == DataChannel.Fallback)
            {
                // process the case of SMS
                this.savingProgress = SavingProgress.Failed;

                // make sure we show the processing fragment for some time
                await this.FragmentShowAwaiter(this.processingShown, DateTime.Now);

                this.smsFailed++;

                // depending on how many times SMS failed, decide what to show
                string posButtonTxt;
                string negButtonTxt;
                if (this.smsFailed >= this.maxSmsTries)
                {
                    posButtonTxt = this.WizardActivity.GetString(Resource.String.add_new_customer);
                    switch (this.ActivityBase.StartPointIntent)
                    {
                    case IntentStartPointTracker.IntentStartPoint.CustomerList:
                        negButtonTxt = this.WizardActivity.GetString(Resource.String.prospect_followup_return_to_customer_list);
                        break;

                    case IntentStartPointTracker.IntentStartPoint.ProspectsList:
                        negButtonTxt = this.WizardActivity.GetString(Resource.String.prospect_followup_return_to_prospect_list);
                        break;

                    case IntentStartPointTracker.IntentStartPoint.WelcomeScreen:
                        negButtonTxt = this.WizardActivity.GetString(Resource.String.return_to_home);
                        break;

                    default:
                        negButtonTxt = this.WizardActivity.GetString(Resource.String.return_to_home);
                        break;
                    }
                }
                else
                {
                    posButtonTxt = this.WizardActivity.GetString(Resource.String.try_again);
                    negButtonTxt = this.WizardActivity.GetString(Resource.String.cancel_registration);
                }

                bool stillTryingToSendSms = this.smsFailed < this.maxSmsTries;

                // SMS must have failed otherwise if statement before would have caught it
                string message = stillTryingToSendSms
                    ? this.WizardActivity.GetString(Resource.String.sms_registration_failed)
                    : string.Format(this.WizardActivity.GetString(Resource.String.unified_sms_registration_failed_n_tries), this.smsFailed);

                this.registrationFailedFragment = new RegistrationFinishedFragment();

                /*
                 *  e.Channel == DataChannel.Fallback,
                 *  false,
                 *  message,
                 *  posButtonTxt,
                 *  negButtonTxt,
                 *  this.ActivityBase.StartPointIntent);
                 */

                Bundle arguments = new Bundle();
                arguments.PutBoolean(RegistrationFinishedFragment.WasRegistrationKey, e.Channel == DataChannel.Fallback);
                arguments.PutBoolean(RegistrationFinishedFragment.SuccessKey, false);
                arguments.PutString(RegistrationFinishedFragment.MessageKey, message);
                arguments.PutString(RegistrationFinishedFragment.BtnPositiveKey, posButtonTxt);
                arguments.PutString(RegistrationFinishedFragment.BtnNegativeKey, negButtonTxt);
                arguments.PutString(RegistrationFinishedFragment.IntentStartPointKey, this.ActivityBase.StartPointIntent.ToString());
                this.registrationFailedFragment.Arguments = arguments;

                // depending on sms retries, decide the event hadler
                if (this.smsFailed >= this.maxSmsTries)
                {
                    (this.registrationFailedFragment as RegistrationFinishedFragment).PositiveAction += delegate
                    {
                        WizardLauncher.Launch(this.Activity, WizardTypes.CustomerRegistration, ActivityBase.StartPointIntent);
                        (this.WizardActivity as Activity).Finish();
                    };

                    (this.registrationFailedFragment as RegistrationFinishedFragment).NegativeAction += this.OnCancel;
                }
                else
                {
                    (this.registrationFailedFragment as RegistrationFinishedFragment).PositiveAction += this.Save;
                    (this.registrationFailedFragment as RegistrationFinishedFragment).NegativeAction += this.OnCancel;
                }

                this.WizardActivity.ShowOverlay(this.registrationFailedFragment, true);
            }

            await this.SaveCustomerToDevice(e, this.smsFailed, this.maxSmsTries);

            this.registrationInProgress = false;
            this.savingProgress         = SavingProgress.Done;
        }