Ejemplo n.º 1
0
 public virtual void NavigateUserConfig()
 {
     ExceptionUtility.Try(() =>
     {
         //PresentViewController(new AquamonixNavController(UserConfigViewController.CreateInstance()), true, null);
         this.NavigateTo(UserConfigViewController.CreateInstance(this), inCurrentNavController: false);
     });
 }
Ejemplo n.º 2
0
        public static UserConfigViewController CreateInstance(UIViewController caller = null)
        {
            ExceptionUtility.Try(() =>
            {
                if (_instance != null)
                {
                    _instance.Dispose();
                    _instance = null;
                }
            });

            _instance         = new UserConfigViewController();
            _instance._caller = caller;
            //_instance.ClearAllAppDataExceptUserInfo();

            return(_instance);
        }
Ejemplo n.º 3
0
        protected override void HandleViewDidAppear(bool animated)
        {
            base.HandleViewDidAppear(animated);

            //UIApplication.SharedApplication.KeyWindow.AddSubview(ReconnectingOverlay.Instance);

            //LocationUtility.DistanceInMetersFrom(13.736717, 100.523186);

            if (_attemptAutoLogin)
            {
                var deviceListVc = DeviceListViewController.CreateInstance();

                if (User.Current == null || !User.Current.HasConfig)
                {
                    //redirect to Config VC
                    //this.NavigationController.PushViewController(ViewControllerFactory.GetViewController<UserConfigViewController>(), true);
                    NavigateUserConfig();
                }
                else
                {
                    ProgressUtility.SafeShow("Connecting", async() =>
                    {
                        var userConfigVc = UserConfigViewController.CreateInstance();

                        var response = await ServiceContainer.UserService.RequestConnection(
                            User.Current.Username,
                            User.Current.Password);

                        MainThreadUtility.InvokeOnMain(() =>
                        {
                            ProgressUtility.Dismiss();

                            //on connection error, redirect to config
                            if (response != null && response.IsSuccessful)
                            {
                                //redirect to device list
                                this.NavigateTo(deviceListVc, inCurrentNavController: false);
                                //this.PresentViewController(new AquamonixNavController(deviceListVc), true, null);
                            }
                            else
                            {
                                //this.NavigateTo(userConfigVc, inCurrentNavController: false);

                                if (response?.ErrorBody != null && response.ErrorBody.ErrorType == Aquamonix.Mobile.Lib.Domain.Responses.ErrorResponseType.AuthFailure)
                                {
                                    Caches.ClearCachesForAuthFailure();
                                }

                                //is device cache valid?
                                if (DataCache.HasDevices)
                                {
                                    //redirect to device list
                                    deviceListVc.ShowConnectionError = true;
                                    this.NavigateTo(deviceListVc, inCurrentNavController: false);
                                }
                                else
                                {
                                    //redirect to user config
                                    userConfigVc.ShowConnectionError = true;
                                    this.NavigateTo(userConfigVc, inCurrentNavController: false);
                                }
                            }
                        });
                    });
                }
            }
            else
            {
                this.PresentViewController(new StartViewController(true), false, null);
            }
        }