Exemplo n.º 1
0
        /// <summary>
        /// Function to check the Login Credentials.
        /// </summary>
        /// <param name="objLoginProp"></param>
        /// <returns>void</returns>
        /// <createdBy></createdBy>
        /// <createdOn>Apr-13,2016</createdOn>
        public void LoginoutUser()
        {
            GridMultiSelect multiSelect = new GridMultiSelect();

            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                /// remove the role details for the logged-in user before the logout
                Application.Current.Properties["LoggedInUserRole"] = string.Empty;
                /// redirect to the dashboard page and close the login page.
                //MainWindow objMainWindow = new MainWindow();

                char[] objRolesSplit = new char[] { ',' };
                var    objRoles      = Application.Current.Properties["LoggedInUserRole"].ToString().Split(objRolesSplit);
                if (!objRoles.Contains(UserRoles.Security.GetUserRoleToCompare()))
                {
                    AutoLogOffHelper.MakeAutoLogOffEvent -= new AutoLogOffHelper.MakeAutoLogOff(LoginoutUser);
                }


                LogoutWindow objLogoutWindow = new LogoutWindow();
                foreach (System.Windows.Window window in System.Windows.Application.Current.Windows)
                {
                    if (window.DataContext == this)
                    {
                        window.Close();
                    }
                }
                objLogoutWindow.Show();
                AutoLogOffHelper.StopTimer();
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Dispose off all the resources held by previous viewmodels
        /// </summary>
        private void DisposePreviousViewModelReferences(object viewModel)
        {
            GridMultiSelect multiSelect = new GridMultiSelect();

            var type = viewModel.GetType();

            //check if viewmodel implements IDisposable interface
            bool hasIDisposableSupport = typeof(System.IDisposable).IsAssignableFrom(type);

            if (hasIDisposableSupport)
            {
                dynamic obj = viewModel;

                if (obj != null)
                {
                    obj.Dispose();
                }
            }

            var isAnyChildViewModels = ((ViewModel.ViewModelBase)viewModel).GetChildViewModels().Any();

            //if any of the child viewmodels are there
            if (isAnyChildViewModels)
            {
                var childViewModels = ((ViewModel.ViewModelBase)viewModel).GetChildViewModels();

                foreach (var item in childViewModels)
                {
                    if (item != null)
                    {
                        bool hasChildVMIDisposableSupport = typeof(System.IDisposable).IsAssignableFrom(item.GetType());

                        if (hasChildVMIDisposableSupport)
                        {
                            dynamic obj = item;

                            if (obj != null)
                            {
                                obj.Dispose();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 internal void NavigateTo(NavigationNode selected)
 {
     if (selected.Type != null)
     {
         if (typeof(Window).IsAssignableFrom(selected.Type))
         {
             Window window = (Window)Activator.CreateInstance(selected.Type);
             window.Show();
         }
         else
         {
             GridMultiSelect multiSelect = new GridMultiSelect();
             object          view        = Activator.CreateInstance(selected.Type);
             Content        = view;
             CurrentNode    = selected;
             NavigationPath = GetPath(selected);
         }
     }
 }