Пример #1
0
        private async Task loginUser()
        {
            try
            {
                RestStatus status = await RestHub.LoginUser(userName, password);

                if (status.HttpCode == System.Net.HttpStatusCode.OK)
                {
                    Hide       = Visibility.Hidden;
                    U.UserName = userName;
                    U.RoleId   = RoleId;
                    U.UserRole = (from r in Roles
                                  where r.RoleId == RoleId
                                  select r.RoleName).FirstOrDefault();
                    await UserPermissionInfo(RoleId);
                    await UserReactionsReports(RoleId);

                    ((App.Current.MainWindow as MainWindow).DataContext as MainVM).UserName = (U.UserName + " \\ " + U.UserRole).ToUpper();
                    try
                    {
                        HubClient.InitHub();
                        HubClient.NotificationReceived += HubClient_NotificationReceived;
                        ((App.Current.MainWindow as MainWindow).DataContext as MainVM).SignalRId = HubClient.signalRId;
                    }
                    catch (Exception ex)
                    {
                        AppErrorBox.ShowErrorMessage("Error while conneciton to live server . .", ex.ToString());
                    };
                }
                else
                {
                    AppInfoBox.ShowInfoMessage(status.StatusMessage);
                    LoginEnable = true;
                }
            }
            catch (Exception ex)
            {
                Log.This(ex);
            }
        }