Esempio n. 1
0
        } // 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()
Esempio n. 2
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()
Esempio n. 3
0
        } // End GetParameterValue()


        /// <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>
        /// <returns>Status of the update operation.</returns>
        internal static bool UpdateJobExecutionStatus<JobParametersType, JobStatusType>(JobParametersType jobParameters, JobStatusType jobExecutionStatus, Constants.BrokerType brokerType)
        {
            int issuedCommandId = 0;
            return UpdateJobExecutionStatus<JobParametersType, JobStatusType>(jobParameters, jobExecutionStatus, brokerType, out issuedCommandId);
        } // End UpdateJobExecutionStatus()