/// <summary> /// This method is used to fetch the Log Details. /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="taskId">Task Identifier</param> /// <returns>LogInfo object</returns> internal static LogInfo GetLogDetails(int jobId, int jobRunId, int taskId) { try { string logInfo = DatabaseBroker.GetLogDetails(jobId, jobRunId, taskId); return string.IsNullOrEmpty(logInfo) ? new LogInfo() : (DeserializeObject<LogInfo>(logInfo)); } catch (Exception ex) { ex.Trace().Swallow(); return new LogInfo(); } }
/// <summary> /// This Method is used to insert the Task Details in database /// </summary> /// <typeparam name="TaskType">TaskType Specific to a Job</typeparam> /// <param name="taskList">List of tasks</param> /// <param name="jobRunId">Job Run Id</param> /// <returns>return True, successful insertion of task details</returns> internal static bool InsertTaskDetails<TaskType>(Tasks<TaskType> taskList, int jobRunId) { bool result = false; DateTime startTime = DateTime.UtcNow; foreach (TaskType task in taskList) { int taskNumber = Convert.ToInt32(GetParameterValue<TaskType>(task, Constants.PropertyNameTaskNumber)); byte[] binaryData = DatabaseBroker.SerializeObjectBinary<TaskType>(task); result = DatabaseBroker.InsertTaskDetails(jobRunId, taskNumber, binaryData); } EvLog.WriteEntry(Constants.TaskInsertionTime, Convert.ToString((DateTime.UtcNow - startTime)), EventLogEntryType.Information); return result; }
/// <summary> /// Method to PersistStatus /// </summary> /// <typeparam name="JobParametersType">job parameters type</typeparam> /// <typeparam name="TaskType"> task type</typeparam> /// <param name="jobParameters">job parameters</param> /// <param name="taskId"> task id</param> /// <param name="brokerType">broker type</param> /// <param name="issuedCommandId"> command issued</param> /// <param name="taskStartTime"> task start time</param> /// <param name="isCustomProgressPercentage"> is custom progress</param> /// <returns></returns> internal static bool PersistStatus<JobParametersType, TaskType>(JobParametersType jobParameters, int taskId, Constants.BrokerType brokerType, out int issuedCommandId, DateTime? taskStartTime, bool isCustomProgressPercentage) { // Declare a local output boolean variable. bool output = false; // Get the job run id from the job parameters / settings. int jobRunId = Convert.ToInt32(GetParameterValue(jobParameters, Constants.PropertyNameJobRunId), CultureInfo.CurrentCulture); // Get the progress percentage from the job parameters / settings. double progressPercent = Convert.ToDouble(GetParameterValue<JobParametersType>(jobParameters, Constants.PropertyNameJobProgressPercent), CultureInfo.CurrentCulture); // Initialize the issued command id to 0. issuedCommandId = Constants.None; // Branch out based on the type of broker specified. switch (brokerType) { // If the broker is Database then call the UdpateJobStatus() in DatabaseBroker. case Constants.BrokerType.Database: { // Update the job status in the database by persisting the tasks and progress percent. Obtain the command id issued for the job. output = DatabaseBroker.UpdateJobStatus<TaskType>(jobRunId, progressPercent, taskId, out issuedCommandId, taskStartTime, isCustomProgressPercentage); break; } // End case Database broker type // If the broker is ConfigFile then call the respective method in ConfigFileBroker if implemented. case Constants.BrokerType.ConfigFile: { // Config file cannot be used as a broker to store the job status. throw new NotSupportedException(); } // End case Config file broker // If the broker is Queue then call the respective method in QueueBroker if implemented. case Constants.BrokerType.Queue: { // Queue cannot be used as a broker to store the job status. throw new NotSupportedException(); } // End case Queue broker } // End Switch // Return the output of the operation. return output; } // End PersistStatus()
} // End UpdateJobExecutionStatus() /// <summary> /// This method updates the job execution status. /// </summary> /// <remarks> /// Execution statuses include: Loaded, Running, Stopped, Paused. /// </remarks> /// <typeparam name="JobParametersType">The business entity type for a job.</typeparam> /// <typeparam name="JobStatusType">The task business entity type for a job.</typeparam> /// <param name="jobParameters">Job input parameters / settings obtained during Initialize()</param> /// <param name="jobExecutionStatus">Job execution status - loaded, running, stopped, paused.</param> /// <param name="brokerType">Indicates the broker to be used.</param> /// <param name="issuedCommandId">Indicates the command id issued for the job.</param> /// <returns>Status of the update operation.</returns> internal static bool UpdateJobExecutionStatus<JobParametersType, JobStatusType>(JobParametersType jobParameters, JobStatusType jobExecutionStatus, Constants.BrokerType brokerType, out int issuedCommandId) { // Declare a local output boolean variable. bool output = true; // Initialize the issued command id to 0. issuedCommandId = 0; // Get the job run id from the job parameters / settings. int jobRunId = Convert.ToInt32(GetParameterValue(jobParameters, Constants.PropertyNameJobRunId), CultureInfo.CurrentCulture); // Get the execution status id. int jobExecutionStatusId = Convert.ToInt32(jobExecutionStatus, CultureInfo.CurrentCulture); // Branch out based on the type of broker specified. switch (brokerType) { // If the broker is Database then call the UpdateJobExecutionStatus() in DatabaseBroker. case Constants.BrokerType.Database: { output = DatabaseBroker.UpdateJobExecutionStatus(jobRunId, jobExecutionStatusId, out issuedCommandId); break; } // End case Database // If the broker is ConfigFile then call the respective method in ConfigFileBroker if implemented. case Constants.BrokerType.ConfigFile: { // Config file cannot be used as a broker to store the job status. throw new NotSupportedException(); } // End case ConfigFile // If the broker is Queue then call the respective method in QueueBroker if implemented. case Constants.BrokerType.Queue: { // Queue cannot be used as a broker to store the job status. throw new NotSupportedException(); } // End case Queue } // End case // Return the output of the operation. return output; } // End UpdateJobExecutionStatus()
/// <summary> /// Updates the task log. /// </summary> /// <param name="jobId">The job id.</param> /// <param name="JobRunId">The job run id.</param> /// <param name="taskId">The task id.</param> /// <param name="taskKey">The task key.</param> /// <param name="logInfo">The log info.</param> /// <param name="isError">if set to <c>true</c> [is error].</param> /// <param name="startTime">The start time.</param> /// <param name="endTime">The end time.</param> /// <param name="errorCode">Error Code</param> /// <remarks></remarks> public static void UpdateTaskLog(int jobId, int JobRunId, int taskId, string taskKey, string logInfo, bool isError, DateTime? startTime, DateTime? endTime, string errorCode) { DatabaseBroker.UpdateTaskLog(jobId, JobRunId, taskId, taskKey, logInfo, isError, startTime, endTime, errorCode); }
/// <summary> /// This method is used to log the Error messages along with the properties of the task. /// </summary> /// <param name="jobId">Job Identifier</param> /// <param name="JobRunId">Job Run Identifier</param> /// <param name="logInfoXML">Log xml</param> /// <param name="userGuid">user id</param> /// <param name="messageType">Message Type</param> /// <param name="isXmlLog">determines if log is in xml format</param> public static void JobLog(int jobId, int jobRunId, string errorCode, string logInfo, string userGuid, bool isError, bool isXmlLog) { DatabaseBroker.JobLog(jobId, jobRunId, logInfo, userGuid, isError, errorCode, isXmlLog); }
/// <summary> /// Thsi method is used to fetch task details. /// </summary> /// <typeparam name="JobParameterType"></typeparam> /// <typeparam name="TaskType"></typeparam> /// <param name="jobParameters"></param> /// <returns></returns> internal static Tasks<TaskType> GetJobTaskDetails<JobParameterType, TaskType>(JobParameterType jobParameters) where TaskType : class, new() { return DatabaseBroker.GetJobTaskDetails<JobParameterType, TaskType>(jobParameters); }
/// <summary> /// This method will update the status of the whole Job /// </summary> /// <param name="jobId">Unique Identifier</param> /// <param name="status">StatusId</param> /// <returns></returns> internal static bool UpdateJobMasterStatus(int jobId, int status) { return (DatabaseBroker.UpdateJobStatus(jobId, status)); }
/// <summary> /// This method is used to fetch Job Details. /// </summary> /// <param name="jobID">Job Unique Identifier</param> /// <returns>Return Job Details</returns> internal static int GetJobStatus(string jobID) { return DatabaseBroker.GetJobStatus(jobID); }
/// <summary> /// This method is used to fetch Job Details. /// </summary> /// <param name="jobID">Job Unique Identifier</param> /// <returns>Return Job Details</returns> internal static JobBusinessEntity GetJobDetails(string jobID) { return DatabaseBroker.GetJobSubScriptionDetails(jobID); }
} // End UpdateJobExecutionStatus() /// <summary> /// This method updates the job final status. /// </summary> /// <param name="jobId">Job Identifier.</param> /// <param name="jobRunId">Job Instance Identifier.</param> /// <param name="jobStatus">Job status.</param> /// <returns>Status of the update operation.</returns> internal static bool UpdateJobFinalStatus(int jobId, int jobRunId, int jobStatus) { bool output = true; output = DatabaseBroker.UpdateJobFinalStatus(jobId, jobRunId, jobStatus); return output; }