Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
0
        void MessageSocket_Connected(object sender, EventArgs e)
        {
            int?terminalNumber = NetworkTools.GetLastLanByte();

            if (terminalNumber != null)
            {
                BroadcastClientSocket.SendMessage("AppStarted " + terminalNumber.Value);
            }
            else
            {
                BroadcastClientSocket.SendMessage("AppStarted");
            }
        }
        private void SaveOptions()
        {
#if !DEMO
            StoreSetting.Set("AutoUpdate",
                             (radioButtonAutoUpdateIsEnabled.IsSelected ? 1 : 0));
            LocalSetting.Values.String["UpdateServerPort"] = textBoxPort.Text;
            LocalSetting.Values.String["UpdateServer"]     = textBoxServer.Text;
            LocalSetting.Update();

            // Need to notify other clients of this information so they can update
            // their LocalSetting values
            BroadcastClientSocket.SendMessage("UpdateServerInfo " +
                                              LocalSetting.Values.String["UpdateServer"] + " " +
                                              LocalSetting.Values.String["UpdateServerPort"]);
#endif
        }