コード例 #1
0
        private void DoLogin(string scanCode)
        {
            Employee employee = EmployeeManager.LookupByScanCode(scanCode);

            if (employee == null)
            {
                // The debug version will have an exception here if escape-exit is used
                try
                {
                    PosDialogWindow.ShowDialog(Types.Strings.LoginLoginIncorrect, Types.Strings.Error);
                    return;
                }
                catch
                {
                    return;
                }
            }

            // Check if logged-in somewhere else
            if (PosHelper.IsLocked(TableName.Employee, employee.Id))
            {
#if !DEMO
                BroadcastClientSocket.SendRemoteLogout(employee.Id);
#endif
                PosHelper.Unlock(TableName.Employee, employee.Id);
            }

            // Check if clock-in is required
            if (!employee.IsClockedIn())
            {
                if (!DoClockIn(employee) && !employee.HasPermission(Permissions.SystemMaintenance))
                {
                    return;
                }
            }

            // Proceed with login
            IsLoggedIn = true;

            // Clear dead-locks
            Lock.DeleteAllEmployeeLocks(employee.Id);

            // Lock the employee to prevent simultaneous logins
            PosHelper.Lock(TableName.Employee, employee.Id, employee.Id);

#if !DEMO
            // Tell other clients, that this employee just logged in
            BroadcastClientSocket.SendMessage("LOGIN " + employee.Id);
#endif
            StartAutoLogoutTimer();
            if (Login != null)
            {
                Login.Invoke(this, new UserLoginEventArgs(employee));
            }
        }
コード例 #2
0
 public static void ClearTicket()
 {
     LoginControl.StartAutoLogoutTimer();
     PosHelper.Unlock(ActiveTicket);
     IsActiveTicketLocked = false;
     ActiveTicket         = null;
     ActiveItem           = null;
     ActiveCategory       = null;
     ActiveTicketItem     = null;
     PseudoEmployee       = null;
     if (TicketCleared != null)
     {
         TicketCleared.Invoke(null, new EventArgs());
     }
 }
コード例 #3
0
        private void EditPartyInfo()
        {
            if (PosHelper.IsLocked(TableName.Party, CurrentTicket.PartyId))
            {
                PosDialogWindow.ShowDialog(
                    Types.Strings.ThePartyInformationForThisTicketIsCurrentlyBeingModifiedSomewhereElse,
                    Types.Strings.PartyInformationLocked);
                return;
            }
            PosHelper.Lock(TableName.Party, CurrentTicket.PartyId, SessionManager.ActiveEmployee.Id);

            PosDialogWindow  window  = PartyEditControl.CreateInDefaultWindow();
            PartyEditControl control = window.DockedControl as PartyEditControl;

            control.Initialize(ParentTicket.PartyId);
            window.ShowDialog(ParentWindow);

            control.ActiveParty.Update();
            PosHelper.Unlock(TableName.Party, CurrentTicket.PartyId);
        }
コード例 #4
0
        void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;

            // Stop the auto-logoof timer
            LoginControl.StopAutoLogoutTimer();

            // Close all database connections
            DataModelBase.CloseAll();

#if !DEMO
            // Send the exception to the upgrade server
            Updater.StartCrashReport(e.Exception);
#endif
            // Save the exception, serialized to the AppData folder
            try
            {
                DateTime now           = DateTime.Now;
                string   rootDirectory =
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                    Path.DirectorySeparatorChar + "TemPOS";
                if (!Directory.Exists(rootDirectory))
                {
                    Directory.CreateDirectory(rootDirectory);
                }
                string path = rootDirectory + Path.DirectorySeparatorChar + "crashdata-" +
                              now.Year + now.Month.ToString("D2") + now.Day.ToString("D2") + "-" +
                              now.Hour.ToString("D2") + now.Minute.ToString("D2") + now.Second.ToString("D2") +
                              ".bin";
                using (FileStream fileStream = new FileStream(path, FileMode.CreateNew))
                {
                    byte[] serialData = e.Exception.SerializeObject();
                    using (BinaryWriter writer = new BinaryWriter(fileStream))
                    {
                        writer.Write(serialData);
                    }
                }
            }
            catch { }

            // Display the exception message
            DisplayExceptionDialog(e.Exception);

            // Remove employee table lock (that prevents simultaneous login)
            if (SessionManager.ActiveEmployee != null)
            {
                PosHelper.Unlock(TableName.Employee, SessionManager.ActiveEmployee.Id);
            }

            // Close this app
            if (_mainWindow != null)
            {
                _mainWindow.AllowClose = true;
                _mainWindow.Close();
            }

            // Disable user control crap
            if (ConfigurationManager.UseKeyboardHook)
            {
                UserControlManager.Disable();
            }

            UserControlManager.ShowTaskbar(true);
#if !DEBUG
            if (PastRestartPoint)
            {
                // Restart application
                Process.Start(Application.ResourceAssembly.Location, "/RESTART");
                App.SwitchToDefaultDesktopOnClose = false;
            }
            else
            {
                App.SwitchToDefaultDesktopOnClose = true;
            }
#else
            App.SwitchToDefaultDesktopOnClose = true;
#endif
            // Shutdown current application
            Application.Current.Shutdown();
            Process.GetCurrentProcess().Kill();
        }