Beispiel #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //preferenceHandler = new PreferenceHandler();
            var menuController = (MyMenuController)Storyboard.InstantiateViewController("MyMenuController");

            // create a slideout navigation controller with the top navigation controller and the menu view controller
            NavController = new NavController();
            Boolean     IsLogged   = PreferenceHandler.IsLoggedIn();
            UserDetails userDetail = PreferenceHandler.GetUserDetails();

            if (string.IsNullOrEmpty(PreferenceHandler.GetDomainKey()))
            {
                var ConfigurationController = Storyboard.InstantiateViewController("ConfigurationController") as ConfigurationController;
                NavController.PushViewController(ConfigurationController, true);
            }
            else
            {
                InvokeApi.SetDomainUrl(PreferenceHandler.GetDomainKey());
                if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
                {
                    var ConfigurationController = Storyboard.InstantiateViewController("ConfigurationController") as ConfigurationController;
                    NavController.PushViewController(ConfigurationController, true);
                }
                else
                {
                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(PreferenceHandler.GetConfig());
                    B2CConfigManager.GetInstance().Initialize(config);
                    if (IsLogged)
                    {
                        if (userDetail.RoleId == 2)
                        {
                            var FeedbackViewController = Storyboard.InstantiateViewController("FeedbackViewController") as FeedbackViewController;
                            NavController.PushViewController(FeedbackViewController, false);
                        }
                        else
                        {
                            var MapViewController = (MapViewController)Storyboard.InstantiateViewController("MapViewController");
                            NavController.PushViewController(MapViewController, false);
                        }
                    }
                    else
                    {
                        var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController");
                        NavController.PushViewController(ViewController, false);
                    }
                }
            }
            SidebarController                = new SidebarNavigation.SidebarController(this, NavController, menuController);
            SidebarController.MenuWidth      = (IsLogged ? 250 : 0);
            SidebarController.ReopenOnRotate = false;
            SidebarController.MenuLocation   = SidebarNavigation.MenuLocations.Left;
        }
Beispiel #2
0
        protected override void OnResume()
        {
            base.OnResume();

            Task startupWork = new Task(() =>
            {
                Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
                Task.Delay(3000);  // Simulate a bit of startup work.
                Log.Debug(TAG, "Working in the background - important stuff.");
            });

            startupWork.ContinueWith(async t =>
            {
                Log.Debug(TAG, "Work is finished.");


                if (string.IsNullOrEmpty(PreferenceHandler.GetDomainKey()))
                {
                    StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                    Finish();
                }
                else
                {
                    InvokeApi.SetDomainUrl(PreferenceHandler.GetDomainKey());
                    if (string.IsNullOrEmpty(PreferenceHandler.GetConfig()))
                    {
                        StartActivity(new Intent(Application.Context, typeof(ConfigActivity)));
                        Finish();
                    }
                    else
                    {
                        var config = JsonConvert.DeserializeObject <B2CConfiguration>(PreferenceHandler.GetConfig());
                        B2CConfigManager.GetInstance().Initialize(config);
                        if (PreferenceHandler.IsLoggedIn())
                        {
                            await Utils.Utils.RefreshToken(this);
                            Intent intent = new Intent(Application.Context, typeof(AdminDashboardActivity));
                            intent.PutExtra(MainActivity.KEY_USER_ROLE, (int)Constants.USER_ROLE.ADMIN);
                            StartActivity(intent);
                            Finish();
                        }
                        else
                        {
                            StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
                            Finish();
                        }
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            startupWork.Start();
        }
Beispiel #3
0
        private async void SubmitButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textConfigURL.Text))
            {
                Utils.Utils.ShowToast(this, "Enter Server Url.");
            }
            else
            {
                string domain = textConfigURL.Text;
                PreferenceHandler.SetDomainKey(domain);
                InvokeApi.SetDomainUrl(domain);
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.SetTitle("Loading...");
                dialog.Show();
                var response = await InvokeApi.Invoke(Constants.API_GET_MOBILE_CONFIGURATION, string.Empty, HttpMethod.Get);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string strContent = await response.Content.ReadAsStringAsync();

                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(strContent);
                    dialog.Dismiss();
                    if (string.IsNullOrEmpty(config.B2cAuthorizeURL) || string.IsNullOrEmpty(config.B2cChangePasswordPolicy) || string.IsNullOrEmpty(config.B2cChangePasswordURL) || string.IsNullOrEmpty(config.B2cClientId) ||
                        string.IsNullOrEmpty(config.B2cClientSecret) || string.IsNullOrEmpty(config.B2cRedirectUrl) || string.IsNullOrEmpty(config.B2cSignInPolicy) || string.IsNullOrEmpty(config.B2cSignUpPolicy) ||
                        string.IsNullOrEmpty(config.B2cTenant) || string.IsNullOrEmpty(config.B2cTokenURL) || string.IsNullOrEmpty(config.B2cTokenURLIOS))
                    {
                        Utils.Utils.ShowToast(this, "Invalid Configuration details");
                    }
                    else
                    {
                        B2CConfigManager.GetInstance().Initialize(config);
                        PreferenceHandler.SetConfig(strContent);
                        Intent intent = new Intent(Application.Context, typeof(LoginActivity));
                        StartActivity(intent);
                        Finish();
                    }
                }
                else
                {
                    Utils.Utils.ShowToast(this, response.ReasonPhrase);
                    dialog.Dismiss();
                }
            }
        }
Beispiel #4
0
        private async void ButtonSubmit_TouchUpInside(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextFieldConfig.Text))
            {
                IOSUtil.ShowMessage("Enter Domain Url.", null, this);
            }
            else
            {
                string domain = TextFieldConfig.Text;
                PreferenceHandler.SetDomainKey(domain);
                InvokeApi.SetDomainUrl(domain);
                var response = await InvokeApi.Invoke(Constants.API_GET_MOBILE_CONFIGURATION, string.Empty, HttpMethod.Get);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string strContent = await response.Content.ReadAsStringAsync();

                    var config = JsonConvert.DeserializeObject <B2CConfiguration>(strContent);
                    if (string.IsNullOrEmpty(config.B2cAuthorizeURL) || string.IsNullOrEmpty(config.B2cChangePasswordPolicy) || string.IsNullOrEmpty(config.B2cChangePasswordURL) || string.IsNullOrEmpty(config.B2cClientId) ||
                        string.IsNullOrEmpty(config.B2cClientSecret) || string.IsNullOrEmpty(config.B2cRedirectUrl) || string.IsNullOrEmpty(config.B2cSignInPolicy) || string.IsNullOrEmpty(config.B2cSignUpPolicy) ||
                        string.IsNullOrEmpty(config.B2cTenant) || string.IsNullOrEmpty(config.B2cTokenURL) || string.IsNullOrEmpty(config.B2cTokenURLIOS))
                    {
                        IOSUtil.ShowMessage("Invalid Configuration details", null, this);
                        PreferenceHandler.SetDomainKey(string.Empty);
                    }
                    else
                    {
                        B2CConfigManager.GetInstance().Initialize(config);
                        PreferenceHandler.SetConfig(strContent);
                        var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController");
                        NavController.PushViewController(ViewController, false);
                    }
                }
                else
                {
                    IOSUtil.ShowMessage(response.ReasonPhrase, null, this);
                    PreferenceHandler.SetDomainKey(string.Empty);
                }
            }
        }