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);
        }
Beispiel #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);
        }
        /// <summary>
        /// Logs the exception message into database..
        /// </summary>
        /// <param name="logInfo">Log information</param>
        /// <param name="exp">exception received</param>
        /// <param name="category">To identify the job or task to log the message</param>
        /// <param name="errocode">error code</param>
        /// <param name="taskKey">taskKey</param>
        private static void LogException(LogInfo logInfo, Exception exp, LogCategory category, string errorCode,
                                         string taskKey)
        {
            if (category == LogCategory.Job)
            {
                var jobException = new EVJobException(errorCode, exp, logInfo);
                throw (jobException);
            }
            logInfo.TaskKey = taskKey;
            var taskException = new EVTaskException(errorCode, exp, logInfo);

            throw (taskException);
        }
Beispiel #4
0
        /// <summary>
        /// Handles the exception.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="customMessage">The custom message.</param>
        /// <param name="ex">The ex.</param>
        /// <param name="errorCode">Error Code</param>
        private void HandleException(LogCategory category, string customMessage, Exception ex, string errorCode)
        {
            if (category == LogCategory.Job)
            {
                JobLogInfo.AddParameters(customMessage);
                EVJobException jobException = new EVJobException(errorCode, ex, JobLogInfo);
                throw (jobException);
            }
            TaskLogInfo.AddParameters(customMessage);
            EVTaskException taskException = new EVTaskException(errorCode, ex, TaskLogInfo);

            throw (taskException);
        }
        /// <summary>
        /// Handles the exception.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="ex">The ex.</param>
        /// <param name="taskKey">string</param>
        /// <param name="errorCode">Error Code</param>
        private void HandleException(LogCategory category, Exception ex, string taskKey, string errorCode)
        {
            if (category == LogCategory.Job)
            {
                JobLogInfo.AddParameters(ex.Message);
                var jobException = new EVJobException(errorCode, ex, JobLogInfo);
                throw jobException;
            }
            TaskLogInfo.AddParameters(ex.Message);
            TaskLogInfo.TaskKey = taskKey;
            var taskException = new EVTaskException(errorCode, ex, TaskLogInfo);

            throw taskException;
        }
 /// <summary>
 /// Logs the exception message into database..
 /// </summary>
 /// <param name="logMsg">LogInfo</param>
 /// <param name="exp">exception received</param>
 /// <param name="category">To identify the job or task to log the message</param>
 /// <param name="taskKey">Key to identify the Task, need for task log only</param>
 /// <param name="errorCode">string</param>
 private static void LogException(LogInfo logMsg, Exception exp, LogCategory category, string taskKey, string errorCode)
 {
     if (category == LogCategory.Job)
     {
         EVJobException jobException = new EVJobException(errorCode, exp, logMsg);
         throw (jobException);
     }
     else
     {
         logMsg.TaskKey = taskKey;
         EVTaskException jobException = new EVTaskException(errorCode, exp, logMsg);
         throw (jobException);
     }
 }
Beispiel #7
0
        /// <summary>
        ///     Logs the exception message.
        /// </summary>
        /// <param name="jobId">Job Identifier</param>
        /// <param name="exp">exception received</param>
        /// <param name="msg">message to be logged</param>
        /// <param name="category">To identify the job or task to log the message</param>
        /// <param name="taskKey">Key value pair to identify the Task, need for task log only</param>
        /// <param name="errorCode">string</param>
        private void LogException(int jobId, Exception exp, string msg, LogCategory category, string taskKey,
                                  string errorCode)
        {
            if (category == LogCategory.Job)
            {
                JobLogInfo.AddParameters(jobId + msg);
                var jobException = new EVJobException(errorCode, exp, JobLogInfo);
                throw (jobException);
            }
            TaskLogInfo.AddParameters(jobId + msg);
            TaskLogInfo.TaskKey = taskKey;
            var taskException = new EVTaskException(errorCode, exp, TaskLogInfo);

            throw (taskException);
        }
Beispiel #8
0
        /// <summary>
        /// Initializes Job BEO
        /// </summary>
        /// <param name="jobId">Job Identifier</param>
        /// <param name="jobRunId">Job Run Identifier</param>
        /// <param name="bootParameters">Boot parameters</param>
        /// <param name="createdBy">Job created by</param>
        /// <returns>Job Business Entity</returns>
        protected override BaseJobBEO Initialize(int jobId, int jobRunId, string bootParameters, string createdBy)
        {
            BaseJobBEO jobBeo = new BaseJobBEO();

            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_Initialize_Start, EventLogEntryType.Information);
                //Initialize the JobBEO object
                jobBeo.JobId    = jobId;
                jobBeo.JobRunId = jobRunId;
                jobBeo.JobName  = Constants.JobTypeName + " " + DateTime.UtcNow;
                //fetch UserEntity
                UserBusinessEntity userBusinessEntity = UserBO.GetUserUsingGuid(createdBy);
                jobBeo.JobScheduleCreatedBy = (userBusinessEntity.DomainName.Equals("N/A")) ? userBusinessEntity.UserId : userBusinessEntity.DomainName + "\\" + userBusinessEntity.UserId;
                userBusinessEntity          = null;
                jobBeo.JobTypeName          = Constants.JobTypeName;
                // Default settings
                jobBeo.StatusBrokerType          = BrokerType.Database;
                jobBeo.CommitIntervalBrokerType  = BrokerType.ConfigFile;
                jobBeo.CommitIntervalSettingType = SettingType.CommonSetting;

                if (bootParameters != null)
                {
                    jobBeo.BootParameters = bootParameters;
                }
                else
                {
                    throw new EVException().AddDbgMsg("{0}:{1}:{2}", jobId, Constants.Event_Job_Initialize_Start, Constants.XmlNotWellFormed).
                          AddResMsg(ErrorCodes.XmlStringNotWellFormed);
                }
                Tracer.Info("{0} - {1}:{2}", Constants.JobTypeName, jobId, Constants.Event_Job_Initialize_Success);
            }
            catch (EVJobException ex)
            {
                _isJobFailed = true;
                ex.AddDbgMsg("{0}:{1}", Constants.JobTypeName, MethodInfo.GetCurrentMethod().Name);
                throw;
            }
            catch (Exception ex)
            {
                _isJobFailed = true;
                ex.AddDbgMsg("{0}:{1}", Constants.JobTypeName, MethodInfo.GetCurrentMethod().Name);
                JobLogInfo.AddParameters("Problem in" + Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name);
                EVJobException jobException = new EVJobException(ErrorCodes.InitializeError, ex, JobLogInfo);
                throw (jobException);
            }
            return(jobBeo);
        }
Beispiel #9
0
        /// <summary>
        /// Generates Concvert DCB Link tasks
        /// </summary>
        /// <param name="jobParameters">Job BEO</param>
        /// <param name="previouslyCommittedTaskCount"> </param>
        /// <returns>List of Job Tasks (BEOs)</returns>
        protected override Tasks <ConvertDCBLinkTaskBusinessEntityObject> GenerateTasks(BaseJobBEO jobParameters, out int previouslyCommittedTaskCount)
        {
            Tasks <ConvertDCBLinkTaskBusinessEntityObject> tasks = null;

            try
            {
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Start, EventLogEntryType.Information);
                previouslyCommittedTaskCount = 0;
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobId, MethodInfo.GetCurrentMethod().Name, EventLogEntryType.Information);
                tasks = GetTaskList <BaseJobBEO, ConvertDCBLinkTaskBusinessEntityObject>(jobParameters);
                previouslyCommittedTaskCount = tasks.Count;
                if (tasks.Count <= 0)
                {
                    ConvertDCBLinkTaskBusinessEntityObject convertDcbLinkTask = new ConvertDCBLinkTaskBusinessEntityObject();
                    convertDcbLinkTask = (ConvertDCBLinkTaskBusinessEntityObject)XmlUtility.DeserializeObject(jobParameters.BootParameters, typeof(ConvertDCBLinkTaskBusinessEntityObject));
                    _query             = ApplicationConfigurationManager.GetValue(Constants.SearchQuery);
                    _createdByUserGuid = convertDcbLinkTask.CreateByUserGuid;
                    string pageSize = "1";
                    DocumentQueryEntity docQueryEntity = GetDocumentQueryEntity(convertDcbLinkTask.DatasetId.ToString(CultureInfo.InvariantCulture), _query, pageSize);
                    docQueryEntity.TransactionName = "ConvertDCBLinksToCaseMap - GenerateTasks";
                    ReviewerSearchResults searchResults = JobSearchHandler.GetSearchResults(docQueryEntity);
                    if (searchResults.TotalRecordCount > 0)
                    {
                        convertDcbLinkTask.TaskNumber   = 1;
                        convertDcbLinkTask.TaskPercent  = 100;
                        convertDcbLinkTask.TaskComplete = false;
                    }
                    _documentCount = searchResults.TotalHitCount;
                    tasks.Add(convertDcbLinkTask);
                }
                EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_GenerateTask_Success, EventLogEntryType.Information);
            }
            catch (EVJobException ex)
            {
                _isJobFailed = true;
                EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
                throw;
            }
            catch (Exception ex)
            {
                _isJobFailed = true;
                EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
                EVJobException jobException = new EVJobException(ErrorCodes.GenerateTasksError, ex, JobLogInfo);
                throw (jobException);
            }
            return(tasks);
        }
        /// <summary>
        /// Logs the exception message into database..
        /// </summary>
        /// <param name="logInfo">Log information</param>
        /// <param name="exp">exception received</param>
        /// <param name="category">To identify the job or task to log the message</param>
        /// <param name="errorCode"> </param>
        /// <param name="taskKey">taskKey</param>
        private static void LogException(LogInfo logInfo, Exception exp, LogCategory category, string errorCode, string taskKey)
        {
            switch (category)
            {
            case LogCategory.Job:
            {
                EVJobException jobException = new EVJobException(errorCode, exp, logInfo);
                throw (jobException);
            }

            default:
            {
                logInfo.TaskKey = taskKey;
                EVTaskException taskException = new EVTaskException(errorCode, exp, logInfo);
                throw (taskException);
            }
            }
        }
Beispiel #11
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);
        }
 /// <summary>
 /// Before job shuts down, Update the log.
 /// </summary>
 /// <param name="jobParameters">Job Business Object</param>
 protected override void Shutdown(BaseJobBEO jobParameters)
 {
     try
     {
         CleanSharedSpace();
     }
     catch (EVJobException ex)
     {
         EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
         throw;
     }
     catch (Exception ex)
     {
         // Handle exception in Generate Tasks
         EvLog.WriteEntry(Constants.JobTypeName + MethodInfo.GetCurrentMethod().Name, ex.Message, EventLogEntryType.Error);
         EVJobException jobException = new EVJobException(ErrorCodes.ProblemInJobExecution, ex, JobLogInfo);
         throw (jobException);
     }
 }
Beispiel #13
0
 /// <summary>
 /// Initializes Job BEO
 /// </summary>
 /// <param name="jobId">Alert Job Identifier</param>
 /// <param name="jobRunId">Alert Job Run Identifier</param>
 /// <param name="bootParameters">Boot parameters</param>
 /// <param name="createdByGuid">Alert Job created by Guid</param>
 /// <returns>Alert Job Business Entity</returns>
 protected override SearchAlertsJobBEO Initialize(int jobId, int jobRunId, string bootParameters,
                                                  string createdByGuid)
 {
     try
     {
         // Set Job level properties to Alert Job business entity object.
         m_SearchAlertsJobBeo.JobId          = jobId;
         m_SearchAlertsJobBeo.JobRunId       = jobRunId;
         m_SearchAlertsJobBeo.JobTypeName    = Constants.LOG_SOURCE;
         m_SearchAlertsJobBeo.BootParameters = bootParameters;
         m_SearchAlertsJobBeo.JobName        = Constants.LOG_SOURCE;
         m_UserBusinessEntity = UserBO.GetUserUsingGuid(createdByGuid);
         m_SearchAlertsJobBeo.JobScheduleCreatedBy = (m_UserBusinessEntity.DomainName.Equals(Constants.NA))
             ? m_UserBusinessEntity.UserId
             : m_UserBusinessEntity.DomainName + Constants.BackSlash + m_UserBusinessEntity.UserId;
         // job start time need to be reduced by an offset to calculate start time
         // That's because at the beginning, Scheduler increments the start time by an offset for next run.
         var jobStartTimeoffsetFinal = Constants.INTEGER_INITIALIZE_VALUE;
         var jobStartTimeoffset      = ApplicationConfigurationManager.GetValue(Constants.JOB_START_TIME_OFFSET);
         Int32.TryParse(jobStartTimeoffset, out jobStartTimeoffsetFinal);
         m_SearchAlertsJobBeo.JobScheduleNextRunDate =
             m_Helper.GetSearchAlertJobRunStartTime(m_SearchAlertsJobBeo.JobId).AddHours(jobStartTimeoffsetFinal);
     }
     catch (EVException ex)
     {
         HandleEVException(ex, MethodBase.GetCurrentMethod().Name, null);
         var jobException = new EVJobException(ex.GetErrorCode(), ex, JobLogInfo);
         throw (jobException);
     }
     catch (Exception ex)
     {
         // Handle exception in initialize
         LogMessage(ex.Message, MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error, null);
         var jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, JobLogInfo);
         throw (jobException);
     }
     // return Alert Job Business Entity
     return(m_SearchAlertsJobBeo);
 }
Beispiel #14
0
 /// <summary>
 /// Before job shuts down, shall update job next run
 /// </summary>
 /// <param name="jobParameters">Job Business Object</param>
 protected override void Shutdown(BaseJobBEO jobParameters)
 {
     try
     {
         EvLog.WriteEntry(Constants.JobTypeName + " - " + jobParameters.JobId.ToString(CultureInfo.InvariantCulture), Constants.Event_Job_ShutDown, EventLogEntryType.Information);
         #region Notification section
         //get job details
         JobBusinessEntity jobDetails = JobMgmtBO.GetJobDetails(jobParameters.JobId.ToString(CultureInfo.InvariantCulture));
         if (jobDetails != null && jobDetails.NotificationId > 0)
         {
             string defaultMessage = string.Empty;
             defaultMessage            = _isJobFailed ? string.Format(Constants.NotificationErrorMessageFormat, !string.IsNullOrEmpty(_requestDescription) ? _requestDescription : Constants.TaskName) : string.Format(Constants.NotificationSuccessMessageFormat, _requestDescription, _documentCount, ApplicationConfigurationManager.GetValue(Constants.CaseMapUrl), _conversionId.ToString());
             CustomNotificationMessage = defaultMessage;
         }
         #endregion
         JobLogInfo.AddParameters(Constants.CreatedBy, jobParameters.JobScheduleCreatedBy);
         JobLogInfo.AddParameters(Constants.DocumentIncludedInXml, Convert.ToString(_documentCount));
         JobLogInfo.AddParameters(Constants.TaskStartTime, Convert.ToString(startedTime));
         JobLogInfo.AddParameters(Constants.TaskEndTime, Convert.ToString(DateTime.UtcNow));
     }
     catch (EVJobException ex)
     {
         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);
         EVJobException jobException = new EVJobException(ErrorCodes.DoAtomicError, ex);
         JobLogInfo.AddParameters(Constants.JobRunId, jobParameters.JobRunId.ToString(CultureInfo.InvariantCulture));
         jobException.LogMessge = JobLogInfo;
         throw (jobException);
     }
 }
Beispiel #15
0
        /// <summary>
        /// Generate Search Alerts Tasks
        /// </summary>
        /// <param name="jobParameters"></param>
        /// <param name="previouslyCommittedTaskCount"></param>
        /// <returns></returns>
        protected override Tasks <SearchAlertsTaskBEO> GenerateTasks(SearchAlertsJobBEO jobParameters,
                                                                     out int previouslyCommittedTaskCount)
        {
            previouslyCommittedTaskCount = 0;
            try
            {
                //It is always try because GetTaskList is not calling.
                // Fix un notified errors - this is self correction of alerts if previous runs failed to update next run date.
                // If not fixed, one failure in chain can stop that specific alert for ever.
                try
                {
                    FixUnnotifiedAlerts();
                }
                catch (Exception ex)
                {
                    LogMessage(Constants.UNNOTIFIED_MESSAGE + ex.Message.Trim(),
                               MethodBase.GetCurrentMethod().Name, EventLogEntryType.FailureAudit, null);
                }
                // Not calling GetTaskList() as no existing tasks are expected.
                // Job can't be paused as it's not seen in job schedule screen.
                // Get tasks from helper function - each Alert is a task
                var searchAlertTasks = m_Helper.GetActiveAlerts
                                           (DateTime.UtcNow.AddSeconds(
                                               Convert.ToInt32(
                                                   ApplicationConfigurationManager.GetValue(Constants.OFFSET_DURATION_IN_SECONDS).Trim())),
                                           m_SearchAlertsJobBeo.JobScheduleNextRunDate);

                var taskCounter = 0;
                foreach (var alertTask in searchAlertTasks)
                {
                    alertTask.TaskNumber = taskCounter++;
                }

                #region Find last alert's timestamp.

                // Find last date in the current job's iteration (in all alerts).
                // Please note alerts in specified time window are the tasks.
                // Check to verify if there are any tasks/alerts.
                if (searchAlertTasks.Count > Constants.INTEGER_INITIALIZE_VALUE)
                {
                    // To sort Tasks list can't be used. So convert to List
                    var tasks = searchAlertTasks.ToList();

                    // Sort
                    var orderedTasks = from p in tasks
                                       orderby p.SearchAlert.NextRunDate descending
                                       select p;

                    // Check if there are any elements
                    if (orderedTasks.Count() > Constants.INTEGER_INITIALIZE_VALUE)
                    {
                        // First item is the last alert in the iteration.Set it to Job BEO.
                        m_SearchAlertsJobBeo.HighestDateInIteration = orderedTasks.First().SearchAlert.NextRunDate;
                    }
                }
                return(searchAlertTasks);
            }
            catch (EVException ex)
            {
                HandleEVException(ex, MethodBase.GetCurrentMethod().Name, null);
                var jobException = new EVJobException(ex.GetErrorCode(), ex, JobLogInfo);
                throw (jobException);
            }
            catch (Exception ex)
            {
                // Handle exception in Generate Tasks
                LogMessage(ex.Message, MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error, null);
                var jobException = new EVJobException(ErrorCodes.ProblemInJobInitialization, ex, JobLogInfo);
                throw (jobException);
            }

            #endregion Find last alert's timestamp.
        }