public MainWindow()
        {
            InitializeComponent();
            //DisplayUsersList();

            var menuItems = MenuListViewModel.GenerateMenuForUser(((UserIdentity)Thread.CurrentPrincipal.Identity).UserID);

            LoadMenuItems(menuItems);
        }
示例#2
0
        private void LogUserIn(User us)
        {
            // Now change the connection string to have the user id in the application name...
            ConnectionHelper.CurrentConnection.ApplicationName = string.Format("HCMIS-Warehouse-V-{0}-U-{1}", Program.HCMISVersionString, us.ID);

            // Re-register the connection string manager here.

            MyGeneration.dOOdads.BusinessEntity.RegistryConnectionString = ConnectionHelper.CurrentConnection.ToString();
            ConnectionManager.ConnectionString = ConnectionHelper.CurrentConnection.ToString();

            if (BLL.Settings.UseNewUserManagement)
            {
                // Idealy, this has to work, but we don't know the kind of code that depends on the legacy new main window object.
                var        menuItems  = MenuListViewModel.GenerateMenuForUser(((UserIdentity)Thread.CurrentPrincipal.Identity).UserID);
                MainWindow mainWindow = new MainWindow(menuItems);

                //Legacy Code ... Remove this when not in use.
                CurrentContext main = new CurrentContext();
                CurrentContext.UserId           = us.ID;
                CurrentContext.LoggedInUser     = us;
                CurrentContext.LoggedInUserName = string.Format("{0} {1}", us.FirstName, us.LastName);

                if (string.IsNullOrEmpty(CurrentContext.LoggedInUserName))
                {
                    CurrentContext.LoggedInUserName = us.UserName;
                }

                mainWindow.Show();
                this.Hide();
            }

            if (!System.Diagnostics.Debugger.IsAttached)
            {
                BLL.LogLogin newLoginLog = new LoginLog();
                newLoginLog.AddNew(us.ID, DateTimeHelper.ServerDateTime, true, Environment.MachineName, "", "",
                                   false, "", Program.HCMISVersionString);
                // Also update the last login time on the User Object
            }
        }