示例#1
0
        /// <summary>
        /// Initializes data
        /// </summary>
        private void Init()
        {
            try
            {
                LogHelper.LogDebug();

                // get current dispatcher for work with UI
                _dispatcher = Dispatcher.CurrentDispatcher;

                // load config files
                API.LoadConfig(ConfigData.FilePath_InnerConfig);  // local config or 1st config
                API.LoadConfig(ConfigData.FilePath_RemoteConfig); // remote config or 2nd config

                // removes old print jobs of the available printers
                RemoveJobs();

                // establish call-backs
                PrintHelper.SkipMethod = SkipDocument;
                PrintHelper.AddWatcher = AddWatcher;

                // subscribe to the file monitor event
                fileMonitor.FileFound += fileMonitor_FileFound;

                // create list of (virtual) printers to be excluded from the track process
                List <string> allp = new List <string> {
                    ConfigData.PrinterName, ConfigData.PrinterName2
                };

                // set up local watcher
                localPrintEventWatcher = new PrintEventWatcher(Environment.MachineName, Environment.MachineName, false, allp, "0.001");
                localPrintEventWatcher.PrintJobPaused    += LocalPrintEventWatcherPrintJobPaused;
                localPrintEventWatcher.PrintJobStarted   += LocalPrintEventWatcherPrintJobStarted;
                localPrintEventWatcher.PrintJobCompleted += LocalPrintEventWatcherPrintJobCompleted;
                localPrintEventWatcher.PrintJobCancelled += LocalPrintEventWatcherPrintJobCancelled;

                // set up allowed printers to skip
                localPrintEventWatcher.AllowedPrintersToSkip = new List <string>();
                localPrintEventWatcher.AllowedPrintersToSkip.Add(ConfigData.PrinterName);
                localPrintEventWatcher.AllowedPrintersToSkip.Add(ConfigData.PrinterName2);

                // initialize watcher
                localPrintEventWatcher.Init();

                // update available printers
                UpdateAvailablePrinters();

                // init print job watchers
                _watchers               = new PrintJobWatchers();
                _watchers.IssueFound   += _watchers_IssueFound;
                _watchers.JobCompleted += _watchers_JobCompleted;
            }
            catch (Exception ex)
            {
                WPFNotifier.Error(ex);
                _timerRetry.Start();
            }

            // set default printer
            SetDefaultPrinter();
        }
示例#2
0
        /// <summary>
        /// Initializes data
        /// </summary>
        private void Init()
        {
            try
            {
                LogHelper.LogDebug();



                // load config files
                API.LoadConfig(ConfigData.FilePath_InnerConfig);  // local config or 1st config
                API.LoadConfig(ConfigData.FilePath_RemoteConfig); // remote config or 2nd config

                RemoveJobs();

                // establish call-backs
                //PrintHelper.SkipMethod = SkipDocument;

                PrintHelper.SkipMethod = SkipDocument;
                PrintHelper.AddWatcher = AddWatcherX;

                // subscribe to the file monitor event
                fileMonitor.FileFound += fileMonitor_FileFound;

                // (virtual) printers to be excluded from the track process
                List <string> allp = new List <string> {
                    ConfigData.PrinterName, ConfigData.PrinterName2
                };

                // init local watcher
                //if (Environment.MachineName == "S77")
                //localWatcher = new PrintEventWatcher(Environment.MachineName, Environment.MachineName, false, allp);
                //else
                //localWatcher = new PrintEventWatcher("ADSERVER", Environment.MachineName, false, allp);
                localWatcher = new PrintEventWatcher(Environment.MachineName, Environment.MachineName, false, allp, "0.000000001");
                //localWatcher = new PrintEventWatcher("W10", Environment.MachineName, false, allp);
                localWatcher.PrintJobPaused    += LocalWatcherPrintJobPaused;
                localWatcher.PrintJobStarted   += LocalWatcherPrintJobStarted;
                localWatcher.PrintJobCompleted += LocalWatcherPrintJobCompleted;
                localWatcher.PrintJobCancelled += LocalWatcherPrintJobCancelled;
                localWatcher.Init();

                /*
                 * if (Environment.MachineName != "S77")
                 * {
                 *  serverWatcher = new PrintEventWatcher("ADSERVER", Environment.MachineName, true, new List<string>(), "0.00001");
                 *  serverWatcher.PrintJobPaused += LocalWatcherPrintJobPaused;
                 *  serverWatcher.PrintJobStarted += LocalWatcherPrintJobStarted;
                 *  serverWatcher.PrintJobCompleted += LocalWatcherPrintJobCompleted;
                 *  serverWatcher.PrintJobCancelled += LocalWatcherPrintJobCancelled;
                 *  serverWatcher.Init();
                 * }*/

                // update available printers
                UpdateAvailablePrinters();

                // init print job watchers
                _watchers               = new PrintJobWatchers();
                _watchers.IssueFound   += _watchers_IssueFound;
                _watchers.JobCompleted += _watchers_JobCompleted;
            }
            catch (Exception ex)
            {
                Notifier.Error(ex);
                _timerRetry.Start();
                //Environment.Exit(-1);
            }

            // set default printer
            SetDefaultPrinter();
        }