Ejemplo n.º 1
0
        /// <summary>
        /// This is the overridden DoAtomicWork method.
        /// </summary>
        /// <param name="task">print Job Task</param>
        /// <param name="jobParameters">Email Job Parameters</param>
        /// <returns>If Atomic work was successful</returns>
        protected override bool DoAtomicWork(BaseJobTaskBusinessEntity task, BaseJobBEO jobParameters)
        {
            bool success         = true;
            bool isSendPerformed = false;
            SendEmailServiceRequestBEO request = null;

            if (task != null)
            {
                bool isMailSent = false;
                try
                {
                    request = (SendEmailServiceRequestBEO)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(SendEmailServiceRequestBEO));
                    string emailDocumentConfigurations = GetEmailDocumentConfigurations();
                    success = SendEmailBO.CreateTemperaryFolder(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), request.RequestedBy.UserId, request.Documents[task.TaskNumber - 1], emailDocumentConfigurations);
                    if (task.TaskNumber == request.Documents.Count)
                    {
                        isSendPerformed = true;
                        //Compress the temporary folder
                        SendEmailBO.CompressFolder(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), emailDocumentConfigurations);
                        //Construct Zip folder
                        isMailSent = SendEmailBO.ComposeAndSendEmail(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), request, emailDocumentConfigurations);
                        //Send Notification on success/failure of email job
                        SendEmailBO.SendNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), isMailSent);
                    }
                    EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_DoAtomicWork_Success + Constants.ForTaskNumber + task.TaskNumber, EventLogEntryType.Information);
                }
                catch (Exception exp)
                {
                    exp.Trace();
                    isMailSent = false;
                    //Send Notification on success/failure of email job
                    if (isSendPerformed)
                    {
                        SendEmailBO.SendNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), isMailSent);
                    }

                    //Update Delivery Status to Failed
                    DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                    EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_DoAtomicWork_Failed + Constants.ForTaskNumber + task.TaskNumber + Constants.Colon + exp.Message, EventLogEntryType.Error);

                    if (request != null && request.Documents.Count > 0)
                    {
                        DocumentIdentifierBEO documentIdentifier = request.Documents[task.TaskNumber - 1];
                        TaskLogInfo.TaskKey = SendEmailBO.GetDcnFieldValue(documentIdentifier.MatterId, documentIdentifier.CollectionId, documentIdentifier.DocumentId);
                    }
                    TaskLogInfo.AddParameters(Constants.Event_Job_DoAtomicWork_Failed + Constants.Colon + exp.Message);
                    if (task.TaskNumber == request.Documents.Count && !isSendPerformed)
                    {
                        EVJobException jobException = new EVJobException(ErrorCodes.ProblemInDoAtomicWork, exp, TaskLogInfo);
                        throw (jobException);
                    }
                    else
                    {
                        EVTaskException taskException = new EVTaskException(ErrorCodes.ProblemInDoAtomicWork, exp, TaskLogInfo);
                        throw (taskException);
                    }
                }
            }
            return(success);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the overridden Initialize() method.
        /// </summary>
        /// <param name="jobId">Job Identifier.</param>
        /// <param name="jobRunId">Job Run Identifier.</param>
        /// <param name="bootParameters">Boot Parameters.</param>
        /// <param name="createdBy">Created By Guid</param>
        /// <returns>jobParameters</returns>
        protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy)
        {
            m_UserBusinessEntity = null;
            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Start, EventLogEntryType.Information);
                //Create Folders for Temporary Storage
                this.CreateFoldersForTemperoryStorage();
                //Clean Source Directory
                this.CleanSharedSpaceForSourceDirectory();
                //Clean Zip Files
                this.CleanZipFilesInSharedSpace();
                //filling properties of the job parameter
                this.m_Job.JobId                = jobId;
                this.m_Job.JobRunId             = jobRunId;
                this.m_Job.JobName              = Constants.EmailJob;
                this.m_UserBusinessEntity       = UserBO.GetUserUsingGuid(createdBy);
                this.m_Job.JobScheduleCreatedBy = (this.m_UserBusinessEntity.DomainName.Equals(Constants.NotApplicable)) ? this.m_UserBusinessEntity.UserId : this.m_UserBusinessEntity.DomainName + Constants.PathSeperator + this.m_UserBusinessEntity.UserId;
                this.m_Job.JobTypeName          = Constants.EmailDocuments;
                // Default settings
                this.m_Job.StatusBrokerType          = BrokerType.Database;
                this.m_Job.CommitIntervalBrokerType  = BrokerType.ConfigFile;
                this.m_Job.CommitIntervalSettingType = SettingType.CommonSetting;

                if (bootParameters != null)
                {
                    this.m_Job.BootParameters = bootParameters;
                }
                else
                {
                    DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                    throw new EVException().AddDbgMsg("{0}:{1}:{2}", jobId, Constants.EmailJobInitialisation, Constants.XmlNotWellFormed).AddResMsg(ErrorCodes.XmlStringNotWellFormed);
                }
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Success, EventLogEntryType.Information);
            }
            catch (EVException ex)
            {
                //Send Email Failure notification
                SendEmailBO.SendNotification(jobId.ToString(CultureInfo.InvariantCulture), false);
                DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.ToUserString(), EventLogEntryType.Information);
                this.JobLogInfo.AddParameters(Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.ToUserString());
                EVJobException jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, this.JobLogInfo);
                throw (jobException);
            }
            catch (Exception ex)
            {
                //Send Email Failure notification
                SendEmailBO.SendNotification(jobId.ToString(CultureInfo.InvariantCulture), false);
                //Update Delivery Status to Failed
                DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                //Handle exception in initialize
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.Message, EventLogEntryType.Information);
                this.JobLogInfo.AddParameters(Constants.Event_Job_Initialize_Failed + Constants.Colon + ex.Message);
                EVJobException jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, this.JobLogInfo);
                throw (jobException);
            }
            return(m_Job);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This is the overridden Initialize() method.
 /// </summary>
 /// <param name="jobId">Job Identifier.</param>
 /// <param name="jobRunId">Job Run Identifier.</param>
 /// <param name="bootParameters">Boot Parameters.</param>
 /// <param name="createdBy">string</param>
 /// <returns>jobParameters</returns>
 protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy)
 {
     try
     {
         EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeStart, EventLogEntryType.Information);
         //Create Folders for Temporary storage
         this.CreateFoldersForTemperoryStorage();
         //Clean shared Space
         this.CleanSharedSpace();
         //filling properties of the job parameter
         this.m_Job.JobId                = jobId;
         this.m_Job.JobRunId             = jobRunId;
         this.m_Job.JobName              = Constants.PrintJobName;
         this.m_UserBusinessEntity       = UserBO.GetUserUsingGuid(createdBy);
         this.m_Job.JobScheduleCreatedBy = (this.m_UserBusinessEntity.DomainName.Equals(Constants.NA)) ? this.m_UserBusinessEntity.UserId : this.m_UserBusinessEntity.DomainName.ConcatStrings(new List <string> {
             Constants.PathSeperator, this.m_UserBusinessEntity.UserId
         });
         this.m_Job.JobTypeName = Constants.PrintJobTypeName;
         // Default settings
         this.m_Job.StatusBrokerType          = BrokerType.Database;
         this.m_Job.CommitIntervalBrokerType  = BrokerType.ConfigFile;
         this.m_Job.CommitIntervalSettingType = SettingType.CommonSetting;
         if (bootParameters != null)
         {
             this.m_Job.BootParameters = bootParameters;
             //Update the delivery status to "running" state
             DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Running);
             EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeSuccess, EventLogEntryType.Information);
         }
         else
         {
             DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
             EvLog.WriteEntry(jobId + Constants.Colon + Constants.PrintJobInitialisation, Constants.JobXmlNotWellFormed, EventLogEntryType.Information);
             throw new EVException().AddResMsg(ErrorCodes.XmlStringNotWellFormed);
         }
     }
     catch (EVException ex)
     {
         DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
         EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeFailed + " : " + ex.ToUserString() + ":" + ex.InnerException + ":" + ex.StackTrace, EventLogEntryType.Information);
         LogException(this.JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization);
     }
     catch (Exception ex)
     {
         DeliveryOptionsBO.UpdateDeliveryStatus(jobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
         //Handle exception in initialize
         EvLog.WriteEntry(Constants.JobTypeName + Constants.Hypen + jobId.ToString(CultureInfo.InvariantCulture), Constants.EventJobInitializeFailed + " : " + ex.Message, EventLogEntryType.Information);
         LogException(this.JobLogInfo, ex, LogCategory.Job, string.Empty, ErrorCodes.ProblemInJobInitialization);
     }
     return(m_Job);
 }
Ejemplo n.º 4
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)
        {
            previouslyCommittedTaskCount = 0;
            Tasks <BaseJobTaskBusinessEntity> tasks = new Tasks <BaseJobTaskBusinessEntity>();

            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Start, EventLogEntryType.Information);

                //De serialize the Boot parameters
                SendEmailServiceRequestBEO request = (SendEmailServiceRequestBEO)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(SendEmailServiceRequestBEO));
                int i = 0;

                //Construct The Task
                if (tasks.Count <= 0)
                {
                    int docCount = request.Documents.Count;
                    for (int k = 0; k < docCount; k++)
                    {
                        BaseJobTaskBusinessEntity task = new BaseJobTaskBusinessEntity
                        {
                            TaskNumber   = ++i,
                            TaskComplete = false,
                            TaskPercent  = (float)100 / docCount
                        };
                        //Construct The Task
                        tasks.Add(task);
                    }
                }
            }
            catch (Exception ex)
            {
                //Send Email Failure notification
                SendEmailBO.SendNotification(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), false);
                //Update Delivery Status to Failed
                DeliveryOptionsBO.UpdateDeliveryStatus(jobParameters.JobId.ToString(CultureInfo.InvariantCulture), (short)PrintToFileServiceStateBEO.Failed);
                EvLog.WriteEntry(Constants.JobTypeName + Constants.Hyphen + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Failed + ":" + ex.Message, EventLogEntryType.Error);
                //LogInfo logMsg = new LogInfo();
                JobLogInfo.AddParameters(Constants.Event_Job_GenerateTask_Failed + Constants.Colon + ex.Message);
                EVJobException jobException = new EVJobException(ErrorCodes.ProblemInGenerateTasks, ex, JobLogInfo);
                throw (jobException);
            }
            return(tasks);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
 }