Exemple #1
0
        /// <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()
Exemple #2
0
 /// <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));
 }