Example #1
0
 private static void LogPrintJobEnd(PrintJobClientLog log, PrintingEngineResult result)
 {
     log.JobStartDateTime   = result.JobStartTime.LocalDateTime;
     log.JobEndDateTime     = result.JobEndTime.LocalDateTime;
     log.PrintStartDateTime = result.PrintStartTime.LocalDateTime;
     ExecutionServices.DataLogger.Update(log);
 }
Example #2
0
        private static PrintJobClientLog LogPrintJobStart(PluginExecutionData executionData, FileInfo file, PrintQueue printQueue, Guid jobId)
        {
            var log = new PrintJobClientLog(executionData, file, printQueue, jobId);

            ExecutionServices.DataLogger.Submit(log);
            return(log);
        }
Example #3
0
        private void ExecuteHandler()
        {
            ExecutionServices.SystemTrace.LogDebug($"Plugin exec data print queues = {_printQueues.Count}");
            foreach (var x in _printQueues)
            {
                ExecutionServices.SystemTrace.LogDebug($"Queue={x.QueueName}");
            }

            // Check to make sure we have something in the pool...
            if (_printQueues.Count == 0)
            {
                var msg = "None of the selected print queues are available.";

                ExecutionServices.SystemTrace.LogDebug(msg);
                throw new PrintQueueNotAvailableException(msg);
            }

            // Pick a print queue and log the device/server if applicable
            PrintQueueInfo queueInfo = _printQueues.GetRandom();

            LogDevice(_pluginData, queueInfo);
            LogServer(_pluginData, queueInfo);

            // Connect to the print queue
            ExecutionServices.SystemTrace.LogDebug($"Connecting to queue: {queueInfo.QueueName}");
            PrintQueue printQueue = PrintQueueController.Connect(queueInfo);

            _serverName = printQueue.HostingPrintServer.Name.TrimStart('\\');
            ExecutionServices.SystemTrace.LogDebug($"Connected to queue: {printQueue.FullName}");

            // Select a document to print
            Document document = _documentIterator.GetNext(_pluginData.Documents);
            ActivityExecutionDocumentUsageLog documentLog = new ActivityExecutionDocumentUsageLog(_pluginData, document);

            ExecutionServices.DataLogger.Submit(documentLog);

            // Download the document and log the starting information for the print job
            Guid              jobId     = SequentialGuid.NewGuid();
            FileInfo          localFile = ExecutionServices.FileRepository.GetFile(document);
            PrintJobClientLog log       = LogPrintJobStart(_pluginData, localFile, printQueue, jobId);

            // Print the job
            PrintingEngineResult result = _engine.Print(localFile, printQueue, jobId);

            _printJobId = result.UniqueFileId;

            if (result == null)
            {
                throw new FilePrintException($"Failed to print {localFile}.");
            }

            // Log the ending information
            LogPrintJobEnd(log, result);
            ExecutionServices.SystemTrace.LogDebug("Controller execution completed");
        }
Example #4
0
        private static PrintJobClientLog LogPrintJobStart(PluginExecutionData executionData, FileInfo file, PrintQueue printQueue, Guid jobId)
        {
            var log = new PrintJobClientLog(executionData, file, printQueue, jobId);

            if (ExecutionServices.SessionRuntime.AsInternal().IsCitrixEnvironment())
            {
                log.PrintType = "Citrix" + log.PrintType;
            }
            ExecutionServices.DataLogger.Submit(log);
            return(log);
        }
        private void LogPrintJobData(UniqueFile printJob, EPrintActivityData activityData)
        {
            PrintJobClientLog printJobClientLog = new PrintJobClientLog(_executionData, printJob, activityData.PrinterEmail, "ePrint", printJob.Id);

            try
            {
                ExecutionServices.DataLogger.Submit(printJobClientLog);
            }
            catch (Exception ex)
            {
                ExecutionServices.SystemTrace.LogError("Failed to log PrintJobClientLog data.", ex);
            }
        }
Example #6
0
        /// <summary>
        /// Start the activity.
        /// </summary>
        /// <param name="executionData">Serialized activity data.</param>
        public PluginExecutionResult ProcessActivity(PluginExecutionData executionData)
        {
            PrintingActivityData     data        = executionData.GetMetadata <PrintingActivityData>();
            PrintQueueInfoCollection printQueues = executionData.PrintQueues;

            // Initialize the document iterator, if it is not already created
            if (_documentIterator == null)
            {
                CollectionSelectorMode mode = data.ShuffleDocuments ? CollectionSelectorMode.ShuffledRoundRobin : CollectionSelectorMode.RoundRobin;
                _documentIterator = new DocumentCollectionIterator(mode);
            }

            // Check to make sure we have something in the pool...
            if (printQueues.Count == 0)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "None of the selected print queues are available.", "No available print queues."));
            }

            // Select a print queue and log the device/server if applicable
            PrintQueueInfo printQueueInfo = printQueues.GetRandom();

            LogDevice(executionData, printQueueInfo);
            LogServer(executionData, printQueueInfo);

            // Get the corresponding system print queue
            LogDebug(string.Format("Retrieving print queue for {0}", printQueueInfo.QueueName));
            PrintQueue printQueue;

            if (ExecutionServices.SessionRuntime.AsInternal().IsCitrixEnvironment())
            {
                printQueue = GetCitrixPrintQueue(printQueueInfo);
            }
            else
            {
                printQueue = PrintQueueController.Connect(printQueueInfo);
            }

            LogDebug(string.Format("Found queue: {0}", printQueue.FullName));

            if (data.JobThrottling)
            {
                // Make sure that there is enough room in the print queue for this job.
                if (!CheckJobCountInQueue(printQueue, data.MaxJobsInQueue))
                {
                    // Skip the activity.
                    return(new PluginExecutionResult(PluginResult.Skipped, "Print Queue cannot accept any more jobs.", "Print queue throttling."));
                }
            }

            LogDebug("Executing print controller");
            if (data.PrintJobSeparator)
            {
                PrintTag(printQueue, executionData);
            }

            // Select a document to print
            Document document = _documentIterator.GetNext(executionData.Documents);
            ActivityExecutionDocumentUsageLog documentLog = new ActivityExecutionDocumentUsageLog(executionData, document);

            ExecutionServices.DataLogger.Submit(documentLog);

            // Download the document and log the starting information for the print job
            Guid              jobId     = SequentialGuid.NewGuid();
            FileInfo          localFile = ExecutionServices.FileRepository.GetFile(document);
            PrintJobClientLog log       = LogPrintJobStart(executionData, localFile, printQueue, jobId);

            // Print the job
            var engine = new Print.PrintingEngine();

            engine.StatusChanged += (s, e) => StatusChanged?.Invoke(s, e);
            var result = engine.Print(localFile, printQueue, jobId);

            // Log the ending information
            LogPrintJobEnd(log, result);
            LogDebug("Controller execution completed");
            return(new PluginExecutionResult(PluginResult.Passed));
        }