Esempio n. 1
0
        /// <summary>
        /// This is the overridden GenerateTasks() method.
        /// </summary>
        /// <param name="jobParameters">Input settings / parameters of the job.</param>
        /// <param name="previouslyCommittedTaskCount">integer</param>
        /// <returns>List of tasks to be performed.</returns>
        protected override Tasks <BaseJobTaskBusinessEntity> GenerateTasks(BaseJobBEO jobParameters, out int previouslyCommittedTaskCount)
        {
            Tasks <BaseJobTaskBusinessEntity> tasks = new Tasks <BaseJobTaskBusinessEntity>();

            previouslyCommittedTaskCount = 0;
            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobGenerateTaskStart, EventLogEntryType.Information);
                //De serialize the Boot parameters
                PrintToFileServiceRequestBEO request = (PrintToFileServiceRequestBEO)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(PrintToFileServiceRequestBEO));
                int i = 0;
                //Construct The Task
                if (tasks.Count <= 0)
                {
                    foreach (BaseJobTaskBusinessEntity task in request.Documents.Select(t => new BaseJobTaskBusinessEntity()))
                    {
                        //Construct The Task
                        task.TaskNumber   = ++i;
                        task.TaskComplete = false;
                        task.TaskPercent  = 99.0 / request.Documents.Count;
                        tasks.Add(task);
                    }
                }
            }
            catch (EVException ex)
            {
                DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobGenerateTaskFailed + ":" + ex.ToUserString() + ":" + ex.InnerException + ":" + ex.StackTrace, EventLogEntryType.Error);
                LogException(this.JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInGenerateTasks);
            }
            catch (Exception ex)
            {
                DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobGenerateTaskFailed + ":" + ex.Message + ":" + ex.InnerException + ":" + ex.StackTrace, EventLogEntryType.Error);
                LogException(this.JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInGenerateTasks);
                throw;
            }
            return(tasks);
        }
Esempio n. 2
0
 /// <summary>
 /// This is the overridden DoAtomicWork method.
 /// </summary>
 /// <param name="task">print Job Task</param>
 /// <param name="jobParameters">print Job Parameters</param>
 /// <returns>If Atomic work was successful</returns>
 protected override bool DoAtomicWork(BaseJobTaskBusinessEntity task, BaseJobBEO jobParameters)
 {
     #region Pre-condition asserts
     task.ShouldNotBe(null);
     jobParameters.ShouldNotBe(null);
     #endregion
     PrintToFileServiceRequestBEO request = null;
     bool success = true;
     if (task != null)
     {
         try
         {
             request = (PrintToFileServiceRequestBEO)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(PrintToFileServiceRequestBEO));
             request.ShouldNotBe(null);
             string printDocumentConfigurations = GetPrintDocumentConfigurations();
             request.Documents.ShouldNotBe(null);
             request.Documents.Count.ShouldBeGreaterThan(0);
             success = PrintToFileBO.CreateTemperaryFolder(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), request.Documents[task.TaskNumber - 1],
                                                           request.Options.IncludeSeperatorSheet, task.TaskNumber, printDocumentConfigurations, request.RequestedBy.UserId, request.Options.DocumentSetId);
             if (task.TaskNumber == request.Documents.Count)
             {
                 bool isPDFCreated =
                     PrintToFileBO.MergePrintDocument(jobParameters.JobId.ToString(CultureInfo.InvariantCulture),
                                                      request.Options.IncludeSeperatorSheet, request.Options.TargetDocumentMimeType, printDocumentConfigurations, request.Options.PrinterId);
                 if (!isPDFCreated)
                 {
                     //Send Failure Notification
                     PrintToFileBO.SendPrintNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), string.Empty, false, string.Empty, string.Empty);
                 }
             }
             EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobDoAtomicWorkSuccess + Constants.ForTaskNumber + Constants.Colon + task.TaskNumber, EventLogEntryType.Information);
         }
         catch (EVException exp)
         {
             //Send Failure Notification
             string errDescription = exp.ToUserString();
             DocumentIdentifierBEO documentData = null;
             if (exp.GetErrorCode().Equals(ErrorCodes.RedactItPublishError))
             {
                 // If the file is not supported by the conversion server, we will extract the file path from the
                 //error message returned from the conversion server and will log the DCN for that failed document(s).
                 string fileName = exp.InnerException.Message.ToLower(CultureInfo.CurrentCulture).Replace(Constants.ErrorInPublishType, string.Empty).Replace(Constants.ErrorInExtension, string.Empty);
                 documentData = request.Documents.FirstOrDefault(x => x.NativeFilePath.ToLower(CultureInfo.CurrentCulture).Equals(fileName));
                 if (documentData != null && !string.IsNullOrWhiteSpace(documentData.DCN))
                 {
                     PrintToFileBO.SendPrintNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), string.Empty, false, string.Format(Constants.ErrorUnsupportedFormat, documentData.DCN), string.Empty);
                 }
                 else
                 {
                     //If conversion server is inaccessible then we will change the notification message accordingly
                     if (exp.InnerException.Message.ToLower(CultureInfo.CurrentCulture).Contains(Constants.ErrorIPCPort))
                     {
                         PrintToFileBO.SendPrintNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), string.Empty, false, Constants.ConversionServerDown, string.Empty);
                     }
                     else
                     {
                         //If some other exception came from the conversion server, we will log that message as in error message
                         PrintToFileBO.SendPrintNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), string.Empty, false, exp.InnerException.Message, string.Empty);
                     }
                 }
             }
             else
             {
                 //If no native file(s) found for that document and the total number
                 // of documents selected for this job is only one then we will log the DCN
                 errDescription = exp.GetErrorCode().Equals(ErrorCodes.NoNativeFilesFound) ? Constants.NoConversion : errDescription;
                 PrintToFileBO.SendPrintNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), string.Empty, false, errDescription, string.Empty);
             }
             DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
             EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobDoAtomicWorkFailed + " for Task Number -  : " + task.TaskNumber + exp.ToUserString() + ":" + exp.StackTrace, EventLogEntryType.Information);
             if (request != null && request.Documents.Count > 0)
             {
                 documentData             = request.Documents[task.TaskNumber - 1];
                 this.TaskLogInfo.TaskKey = documentData.DCN;
             }
             LogException(this.TaskLogInfo, exp, LogCategory.Task, string.Empty, ErrorCodes.ProblemInDoAtomicWork);
         }
         catch (Exception exp)
         {
             //Send Failure Notification
             PrintToFileBO.SendPrintNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), string.Empty, false, string.Empty, string.Empty);
             DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
             EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobDoAtomicWorkFailed + " for Task Number -  : " + task.TaskNumber + exp.Message + ":" + exp.StackTrace, EventLogEntryType.Information);
             if (request != null && request.Documents.Count > 0)
             {
                 DocumentIdentifierBEO documentIdentifier = request.Documents[task.TaskNumber - 1];
                 this.TaskLogInfo.TaskKey = documentIdentifier.DCN;
             }
             LogException(this.TaskLogInfo, exp, LogCategory.Task, string.Empty, ErrorCodes.ProblemInDoAtomicWork);
         }
     }
     #region Post-condition asserts
     task.ShouldNotBe(null);
     jobParameters.ShouldNotBe(null);
     #endregion
     return(success);
 }