public void Load()
        {
            var environment = GetEnvironment();

            var task = Task.Run(async() =>
            {
                try
                {
                    AppSettings       = await ConfigurationManager.Instance.GetAsync();
                    NavigationManager = new NavigationManager(this);
                    InitializeNaviagtionMenuMap();
                    Calendar = new System.Globalization.GregorianCalendar();

                    if (environment == Constants.Production)
                    {
                        new Services.ServicesProvider().LoadServices(this);
                        var loginModel = PersistenceProvider.GetCredentials();

                        var data = new object[]
                        {
                            PersistenceProvider.GetEncryptedToken(),
                            PersistenceProvider.GetToken(),
                            loginModel.ServerName
                        };
                        AuthorizationManager.SetAuthorization(data);

                        var validated = AuthorizationManager.CheckAuthorization();

                        if (validated)
                        {
                            OnLogin();
                        }
                        else
                        {
                            PersistenceProvider.ClearToken();
                            LockMenu();
                            NavigationManager.GoToLogin();
                        }
                    }
                    else
                    {
                        new Services.Mock.ServicesProvider().LoadServices(this);

                        RunOnUiThread(() =>
                        {
                            PersistenceProvider.ClearToken();
                            LockMenu();
                            NavigationManager.GoToLogin();
                        });
                    }
                }
                catch (Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
                    });
                }
            });
        }
Esempio n. 2
0
        //protected internal virtual void ConfigureQuery(ListQueryParameterObject query, Authorization.Resources resource)
        //{
        //    AuthorizationManager.ConfigureQuery(query, resource,"");
        //}

        protected internal virtual void CheckAuthorization(Permissions permission, Authorization.Resources resource, string resourceId)
        {
            AuthorizationManager.CheckAuthorization(permission, resource, resourceId);
        }