Ejemplo n.º 1
0
        public static void ShutdownApplication(bool showTaskbar = true)
        {
            IsAppShuttingDown = true;
            LocalSetting.Update();
#if !DEMO
            if (LocalSetting.Values.String["StartBroadcastServer"] != null)
            {
                BroadcastServerSocket.Stop();
            }
            BroadcastClientSocket.Stop();
#endif
            if (TaskManagerServiceHelper.IsStarted)
            {
                TaskManagerServiceHelper.IsTaskManagerDisabled = false;
            }

            if (ConfigurationManager.UseKeyboardHook)
            {
                UserControlManager.Disable();
            }
            if (showTaskbar)
            {
                UserControlManager.ShowTaskbar(true);
            }
            Logger.WriteLog("Exiting application");
            Logger.CloseLog();
            TemPOS.MainWindow.Singleton.AllowClose = true;
            TemPOS.MainWindow.Singleton.Dispatcher.Invoke((Action)(() =>
            {
                TemPOS.MainWindow.Singleton.Closed += SingletonClosed;
                TemPOS.MainWindow.Singleton.Close();
            }));
        }
Ejemplo n.º 2
0
 private void DoSetTemposLibrary(string[] tokens)
 {
     if (tokens.Length == 1)
     {
         PrintLine(ConfigurationManager.UseKeyboardHook ?
                   Types.Strings.ShellKeyboardLockStatusOn : Types.Strings.ShellKeyboardLockStatusOff);
         return;
     }
     if ((tokens[1].ToLower().Equals("on")) ||
         (tokens[1].ToLower().Equals("true")))
     {
         if (!ConfigurationManager.UseKeyboardHook)
         {
             ConfigurationManager.SetUseKeyboardHook(true);
             UserControlManager.Enable();
         }
         PrintLine(Types.Strings.ShellKeyboardLockStatusOn);
     }
     else if ((tokens[1].ToLower().Equals("off")) ||
              (tokens[1].ToLower().Equals("false")))
     {
         if (ConfigurationManager.UseKeyboardHook)
         {
             ConfigurationManager.SetUseKeyboardHook(false);
             UserControlManager.Disable();
         }
         PrintLine(Types.Strings.ShellKeyboardLockStatusOff);
     }
 }
        private void radioButtonIsNotKeyboardRestricted_SelectionGained(object sender, EventArgs e)
        {
            if (!IsInitialized)
            {
                return;
            }
            ConfigurationManager.SetUseKeyboardHook(false);
#if !DEBUG
            UserControlManager.Disable();
            UserControlManager.Enable(false);
#endif
            radioButtonIsKeyboardRestricted.IsSelected = false;
        }
Ejemplo n.º 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();
        }