Beispiel #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);
        }
        /// <summary>
        /// Gets a DocumentLinkBEO
        /// </summary>
        /// <param name="matterId">Matter Id</param>
        /// <param name="collectionId">Collection Id</param>
        /// <param name="documentId">Document Id</param>
        /// <param name="baseLink">Base URL to Link back</param>
        /// <returns>Document Link Business Entity</returns>
        private static DocumentLinkBEO getDocumentLink(string matterId, string collectionId, string documentId,
                                                       string baseLink, string dcn)
        {
            var documentLink = new DocumentLinkBEO();
            var identifier   = new DocumentIdentifierBEO(matterId, collectionId, documentId);

            identifier.DCN                  = dcn;
            documentLink.DocumentFact       = identifier;
            documentLink.UrlApplicationLink = baseLink + identifier.UniqueIdentifier;
            return(documentLink);
        }
Beispiel #3
0
        /// <summary>
        /// Does atomic 1)Gets DCB document 2) Generate xml 3) Update xml file to database.
        /// </summary>
        /// <param name="task">ConvertDCBLinkTaskBusinessEntityObject</param>
        /// <param name="jobParameters">Job business entity</param>
        /// <returns></returns>
        protected override bool DoAtomicWork(ConvertDCBLinkTaskBusinessEntityObject task, BaseJobBEO jobParameters)
        {
            bool StatusFlag = true;// Function return status.

            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_DoAtomicWork_Start, EventLogEntryType.Information);
                // Perform Atomic Task
                DCBLinkCollectionBEO  dcbLinks = new DCBLinkCollectionBEO();
                DCBLinkBEO            dcbLink;
                ReviewerSearchResults searchResults = null;
                if (_documentCount > 0)
                {
                    DocumentQueryEntity documentQueryEntity = GetDocumentQueryEntity(task.DatasetId.ToString(CultureInfo.InvariantCulture), _query, _documentCount.ToString(CultureInfo.InvariantCulture));
                    documentQueryEntity.TransactionName = "ConvertDCBLinksToCaseMap - DoAtomicWork";
                    searchResults = JobSearchHandler.GetSearchResults(documentQueryEntity);
                }
                List <DCBLinkBEO> linkList = new List <DCBLinkBEO>();
                string            uuid     = string.Empty;
                int count = 0;
                foreach (DocumentResult document in searchResults.ResultDocuments)
                {
                    dcbLink = new DCBLinkBEO();
                    DocumentIdentifierBEO docIdentifier = new DocumentIdentifierBEO(document.MatterID.ToString(CultureInfo.InvariantCulture), document.CollectionID, document.DocumentID);
                    if (count == 0)
                    {
                        uuid = docIdentifier.UniqueIdentifier.Replace(docIdentifier.DocumentId, string.Empty);
                    }
                    dcbLink.NewDocumentId = docIdentifier.DocumentId;

                    List <FieldResult> fieldValues = document.Fields.Where(f => System.String.Compare(f.Name, EVSystemFields.DcbId, System.StringComparison.OrdinalIgnoreCase) == 0).ToList();
                    dcbLink.OldDocumentId = fieldValues.Any() ? fieldValues.First().Value.Replace("[", "(").Replace("]", ")") : string.Empty;
                    linkList.Add(dcbLink);
                    dcbLink.CollectionId = docIdentifier.CollectionId;
                    dcbLink.DCN          = docIdentifier.DCN;
                    if (docIdentifier.MatterId != null)
                    {
                        dcbLink.MatterId = long.Parse(docIdentifier.MatterId);
                    }

                    count++;
                }
                linkList.SafeForEach(l => dcbLinks.Links.Add(l));
                dcbLinks.UrlApplicationLink = task.LinkBackUrl;

                string        xml         = DocumentFactBusinessObject.GenerateDcbLinksXml(dcbLinks, uuid);
                UTF8Encoding  encoding    = new UTF8Encoding();
                byte[]        content     = encoding.GetBytes(xml);
                StringBuilder nameBuilder = new StringBuilder();
                nameBuilder.Append(Constants.TaskName);
                nameBuilder.Append(Constants.OnDate);
                nameBuilder.Append(startedTime.ConvertToUserTime());
                string requestName = nameBuilder.ToString();

                nameBuilder = new StringBuilder();
                nameBuilder.Append(Constants.TaskName);
                _requestDescription = nameBuilder.ToString();

                string fileType = ApplicationConfigurationManager.GetValue(Constants.FileType);
                _conversionId = CaseMapDAO.SaveConversionResults(jobParameters.JobRunId, requestName, _requestDescription, content, fileType, _createdByUserGuid);
                StatusFlag    = true;
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_DoAtomicWork_Success, EventLogEntryType.Information);
                TaskLogInfo.AddParameters(Constants.DataSetName, task.DatasetName);
            }
            catch (EVTaskException ex)
            {
                _isJobFailed = true;
                EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
                throw;
            }
            catch (Exception ex)
            {
                _isJobFailed = true;
                // Handle exception in Generate Tasks
                EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
                EVTaskException jobException = new EVTaskException(ErrorCodes.DoAtomicError, ex);
                TaskLogInfo.StackTrace = ex.Message + Constants.LineBreak + ex.StackTrace;
                TaskLogInfo.AddParameters(Constants.DataSetId, task.DatasetId.ToString(CultureInfo.InvariantCulture));
                TaskLogInfo.AddParameters(Constants.DataSetName, task.DatasetName);
                TaskLogInfo.TaskKey    = Constants.DataSetName + ":" + task.DatasetName;
                jobException.LogMessge = TaskLogInfo;
                throw (jobException);
            }
            return(StatusFlag);
        }
 /// <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);
 }