private static void pqm_OnJobStatusChange(object sender, PrintJobChangeEventArgs e)
        {
            if ((e.JobStatus & JOBSTATUS.JOB_STATUS_SPOOLING) == JOBSTATUS.JOB_STATUS_SPOOLING && e.JobInfo != null)
            {
                var hWnd     = WindowHelper.GetActiveWindowHandle();
                var appTitle = WindowHelper.GetWindowText(hWnd);
                var appName  = WindowHelper.GetAppDescription(WindowHelper.GetAppPath(hWnd));

                var printEvent = new PrintEventData()
                {
                    JobName       = e.JobInfo.JobName,
                    JobSize       = e.JobInfo.JobSize,
                    EventDateTime = DateTime.Now,
                    Pages         = e.JobInfo.NumberOfPages,
                    PrinterName   = ((PrintQueueHook)sender).SpoolerName
                };

                EventHandler <PrintEventArgs> handler = OnPrintEvent;

                if (handler != null)
                {
                    handler(null, new PrintEventArgs()
                    {
                        EventData = printEvent
                    });
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Invoke user callback as soon as a relevent event is fired
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void pqm_OnJobStatusChange(object sender, PrintJobChangeEventArgs e)
        {
            // if ((e.JobStatus & JOBSTATUS.JOB_STATUS_PAUSED) == JOBSTATUS.JOB_STATUS_PAUSED && e.JobInfo != null)
            {
                var hWnd     = WindowHelper.GetActiveWindowHandle();
                var appTitle = WindowHelper.GetWindowText(hWnd);
                // var appName = WindowHelper.GetAppDescription(WindowHelper.GetAppPath(hWnd));

                GetWindowThreadProcessId(hWnd, out int procId);

                dynamic printEvent = null;
//				try
//				{
                printEvent = new PrintEventData()
                {
                    AppTitle      = appTitle,
                    UnicJobId     = e.UnicIdentOfJob,
                    SpoolerName   = ((PrintQueueHook)sender).SpoolerName,
                    JobName       = e.JobInfo?.JobName,
                    JobSize       = e.JobInfo?.JobSize,
                    EventDateTime = DateTime.Now,
                    Pages         = e.JobInfo?.NumberOfPages,
                    PrinterName   = ((PrintQueueHook)sender).SpoolerName,
                    FileName      = e.JobInfo?.Name,
                    Ji            = e.JobInfo,
                    ProcessId     = procId,
                    JobDetail     = e.JobDetail
                };
//				}
//				catch (Exception ex)
//				{
//
//				}
                // var d = PausePrintJob(((PrintQueueHook) sender).SpoolerName, e.JobId.ToString());
                // Console.ForegroundColor = ConsoleColor.Yellow;
                // Registry.GetValue<Logger>().Debug(d?"HOOK: job paused":"HOOK: job NOT PAUSED");
                // Console.ForegroundColor = ConsoleColor.White;
                //
                // if(d == true)
                OnPrintEvent?.Invoke(sender, new PrintEventArgs()
                {
                    JobId     = e.JobId,
                    EventData = printEvent
                });                         //Поставлено на паузу
            }


            // e.JobInfo?.Pause();
        }
Exemple #3
0
        /// <summary>
        ///     Invoke user callback as soon as a relevent event is fired
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pqm_OnJobStatusChange(object sender, PrintJobChangeEventArgs e)
        {
            if ((e.JobStatus & JOBSTATUS.JOB_STATUS_SPOOLING) == JOBSTATUS.JOB_STATUS_SPOOLING &&
                e.JobInfo != null)
            {
                var    hWnd     = WindowHelper.GetActiveWindowHandle();
                string appTitle = WindowHelper.GetWindowText(hWnd);
                string appName  = WindowHelper.GetAppDescription(WindowHelper.GetAppPath(hWnd));

                var printEvent = new PrintEventData
                {
                    JobName       = e.JobInfo.JobName,
                    JobSize       = e.JobInfo.JobSize,
                    EventDateTime = DateTime.Now,
                    Pages         = e.JobInfo.NumberOfPages,
                    PrinterName   = ((PrintQueueHook)sender).SpoolerName
                };

                Task.Run(() => OnPrintEvent?.Invoke(null, new PrintEventArgs {
                    EventData = printEvent
                }));
            }
        }