コード例 #1
0
ファイル: ViewModelBase.cs プロジェクト: Debadatt/LGSE
 public async void IsCheckPermissions()
 {
     if (Client.IsLogged == false)
     {
         await LogOut();
     }
     else if (!Client.IsPermission)
     {
         await page.DisplayAlert("Access Permission", ResponceCode.customErrorFunction(403, null), "Ok");
     }
 }
コード例 #2
0
ファイル: SplashViewModel.cs プロジェクト: Debadatt/LGSE
 private async void NavigationSync()
 {
     networkAccess = Connectivity.NetworkAccess;
     if (networkAccess == NetworkAccess.Internet)
     {
         await AllSyncService.DataAsync();
     }
     else
     {
         await page.DisplayAlert("Alert", ResponceCode.customErrorFunction(651, null), "Ok");
     }
 }
コード例 #3
0
 public void OnSubmit()
 {
     Validate();
     if (IsValid)
     {
         networkAccess = Connectivity.NetworkAccess;
         if (networkAccess == NetworkAccess.Internet)
         {
             IsBusy = true;
             this.OnSubmitExcute();
         }
         else
         {
             Message = ResponceCode.customErrorFunction(651, null);
         }
     }
 }
コード例 #4
0
        private async Task GetStatusAsync()
        {
            try
            {
                // StatusService service = new StatusService();
                statusList.Clear();

                var GetStatus = await manager.GetPropertyStatusItemsAsync();

                if (GetStatus.Count == 0)
                {
                    networkAccess = Connectivity.NetworkAccess;
                    if (networkAccess == NetworkAccess.Internet)
                    {
                        Client.IsPermission = true;
                        GetStatus           = await manager.GetPropertyStatusItemsAsync(true);

                        //Check Permissions 401 && 403
                        IsCheckPermissions();
                    }
                    else
                    {
                        await page.DisplayAlert("Status Not available", ResponceCode.customErrorFunction(651, null), "Ok");
                    }
                }
                foreach (var item in GetStatus)
                {
                    statusList.Add(item);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                IsStatus = (statusList.Count == 0 ? false : true);
            }
        }
コード例 #5
0
 private async Task CallHistoryPage()
 {
     try
     {
         networkAccess = Connectivity.NetworkAccess;
         if (networkAccess == NetworkAccess.Internet)
         {
             await Application.Current.MainPage.Navigation.PushAsync(new PropertyHistoryPage(PropertyModel));
         }
         else
         {
             await page.DisplayAlert("Alert", ResponceCode.customErrorFunction(651, null), "Ok");
         }
     }
     catch (Exception ex)
     {
         Debug.Write(ex.Message);
     }
     finally
     {
         IsBusy = false;
     }
 }
コード例 #6
0
ファイル: LoginViewModel.cs プロジェクト: Debadatt/LGSE
        public async void OnSubmitExecute()
        {
            //#if OFFLINE_SYNC_ENABLED
            try
            {
                AccountService userService = new AccountService();
                LoginModel     loginModel  = new LoginModel();
                loginModel.Email    = _userName.Value;
                loginModel.Password = Password.Value;
                TokenModel tokenModel = await userService.AuthorizeUser(loginModel);

                if (tokenModel != null)
                {
                    if (tokenModel.message != null || string.IsNullOrEmpty(tokenModel.userId))
                    {
                        //  Client.IsLogged = false;
                        Message = tokenModel.message;
                    }
                    else
                    {
                        Client.IsUserMatched = true;
                        Client.IsRoleMatched = true;

                        if (tokenModel.username != Client.username && !string.IsNullOrEmpty(Client.username))
                        {
                            Client.IsUserMatched = false;
                        }

                        Client.IsLogged     = true;
                        Client.IsPermission = true;
                        Client.token        = tokenModel.token;
                        Client.username     = tokenModel.username;
                        Client.userId       = tokenModel.userId;

                        Client.PendingCount = 0;
                        RoleService role = new RoleService();
                        ObservableCollection <RoleModel> RoleList = new ObservableCollection <RoleModel>();
                        RoleList = await role.GetUserRole();

                        if (RoleList.Count == 1)
                        {
                            foreach (var item in RoleList)
                            {
                                await AccountService.UpdatePreferredRole(item.Id);

                                if (item.RoleName != Client.roleName && !string.IsNullOrEmpty(Client.roleName))
                                {
                                    Client.IsRoleMatched = false;
                                }
                                Client.roleId   = item.Id;
                                Client.roleName = item.RoleName;
                            }
                            if (Client.IsUserMatched == false || Client.IsRoleMatched == false)
                            {
                                ClearedDataSync();
                            }
                            SetApplicationData(true);
                            //await System.Threading.Tasks.Task.Run(() =>
                            // {
                            DataSync();
                            //}).ConfigureAwait(false);

                            await Application.Current.MainPage.Navigation.PushAsync(new IncidentOverviewPage());
                        }
                        else if (RoleList.Count > 1)
                        {
                            await Application.Current.MainPage.Navigation.PushAsync(new RolePage(RoleList));
                        }
                        else
                        {
                            Message = ResponceCode.customErrorFunction(651, null);
                        }
                    }
                }
                else
                {
                    Message = tokenModel.message;
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
            //#else
            //              Message = "Please check Network connection.";
            //#endif
        }