protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            LogOn logon = new LogOn();
            bool? res   = logon.ShowDialog();

            Application.Current.MainWindow   = null;
            Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;

            if (!(bool)res)
            {
                Bootstrapper bs = new Bootstrapper();
                bs.Run();
            }
            else
            {
                MessageBox.Show(
                    "Application is exiting due to invalid credentials",
                    "Application Exit",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
                Application.Current.Shutdown(1);
            }
        }
Beispiel #2
0
        private void WinMain_Load(object sender, EventArgs e)
        {
           
            BufferFormatV2.ObjFormatType = BuffFormatType.protobuf;
            ReadBytesV2.ObjFormatType = BuffFormatType.protobuf;
            

            LogOn logon = new LogOn();
            logon.ShowDialog();

            if (!logon.IsLogOn)
            {
                Close();
                return;
            }

            Path = logon.Path;

            SocketManager.BinaryInput += new ZYSocket.ClientB.ClientBinaryInputHandler(SocketManager_BinaryInput);
            SocketManager.Disconnet += new ZYSocket.ClientB.ClientMessageInputHandler(SocketManager_Disconnet);
                     
            
            LoadingDiskInfo();            

            this.WindowState = FormWindowState.Minimized;
         

        }
Beispiel #3
0
        public void ShowLogOn()
        {
            var logon = new LogOn();

            logon.Attempts = _attempts;
            bool?res = logon.ShowDialog();

            if (!res ?? true)
            {
                Shutdown(1);
            }
            else
            {
                NaoCoopObjects.Classes.User user = Helpers.DataAccessHelper.Instance.UsersManager.ValidateUsernameAndPassword(logon.UserName, logon.Password);
                if (user != null)
                {
                    StartUp(user);
                }
                else
                {
                    if (logon.Attempts > 2)
                    {
                        MessageBox.Show("Application is exiting due to invalid credentials", "Application Exit", MessageBoxButton.OK, MessageBoxImage.Error);
                        Shutdown(1);
                    }
                    else
                    {
                        _attempts += 1;
                        ShowLogOn();
                    }
                }
            }
        }
Beispiel #4
0
        private void WinMain_Load(object sender, EventArgs e)
        {

            BufferFormatV2.ObjFormatType = BuffFormatType.XML;
            ReadBytesV2.ObjFormatType = BuffFormatType.XML;
            

            LogOn logon = new LogOn();
            logon.ShowDialog();

            if (!logon.IsLogOn)
            {
                Close();
                return;
            }

            SocketManager.BinaryInput += new ZYSocket.ClientB.ClientBinaryInputHandler(SocketManager_BinaryInput);
            SocketManager.Disconnet += new ZYSocket.ClientB.ClientMessageInputHandler(SocketManager_Disconnet);

          
            
            LoadingDiskInfo();

        }
Beispiel #5
0
        private void ShowLogOn()
        {
            var logon = new LogOn(_userName, _pass);

            logon.Attempts = _attempts;
            bool?res = logon.ShowDialog();

            if (!res ?? true)
            {
                Shutdown(1);
            }
            else
            {
                IDbManager       dbManager = ObjectPool.Instance.Resolve <IDbManager>();
                IDataCommand     db        = dbManager.GetDatabase(ApplicationSettings.Instance.Database.DefaultConnection.Name);
                List <UserModel> result    = db.Query <UserModel>("GetUser", new { Username = logon.UserName, Password = logon.Password });
                if (result.Any())
                {
                    string[] accessLevel;
                    switch (result[0].Type)
                    {
                    case 100:
                        accessLevel = new string[] {
                            AccessLevel.CAN_VIEW_ORDER
                        };
                        break;

                    case 900:
                        accessLevel = new string[] {
                            AccessLevel.CAN_VIEW_ORDER,
                            AccessLevel.CAN_VIEW_MASTER,
                            AccessLevel.CAN_VIEW_REPORT,
                            AccessLevel.CAN_VIEW_STOCK
                        };
                        break;

                    default:
                        accessLevel = new string[] {
                        };
                        break;
                    }
                    ObjectPool.Instance.Register <UserModel>().ImplementedBy(result[0]);
                    db.Close();
                    AuthorizationProvider.Initialize <DefaultAuthorizationProvider>(accessLevel);
                    Current.MainWindow = new MainWindow();
                    Current.MainWindow.Show();
                }
                else
                {
                    if (logon.Attempts > 2)
                    {
                        MessageBox.Show("Application is exiting due to invalid credentials", "Application Exit", MessageBoxButton.OK, MessageBoxImage.Error);
                        Shutdown(1);
                    }
                    else
                    {
                        _attempts += 1;
                        _userName  = logon.UserName;
                        _pass      = logon.Password;
                        ShowLogOn();
                    }
                }
            }
        }