示例#1
0
        } // End UpdateJobExecutionStatus()

        /// <summary>
        /// This method updates the job execution status.
        /// </summary>
        /// <remarks>
        /// Execution statuses include: Loaded, Running, Stopped, Paused.
        /// </remarks>
        /// <param name="jobId">Job Id.</param>
        /// <param name="jobRunId">Job Run Id.</param>
        /// <param name="jobStatus">Job Status.</param>
        /// <returns>Status of the update operation.</returns>
        internal static bool UpdateJobFinalStatus(int jobId, int jobRunId, int jobStatus)
        {
            // Declare a local output variable.
            bool output = Constants.Failure;
            int  returnFlag;
            bool result = false;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager();

            // Create a new instance of the DB manager.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureUpdateJobFinalStatus);

            // Add input and output parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, jobId);
            db.AddInParameter(dbCommand, Constants.InputParameterJobRunId, DbType.Int32, jobRunId);
            db.AddInParameter(dbCommand, Constants.InputParameterStatusId, DbType.Int32, jobStatus);
            db.AddInParameter(dbCommand, Constants.OutputParameterResultFlag, DbType.Int32, 4);

            // Execute the stored procedure.
            db.ExecuteNonQuery(dbCommand);
            result = Int32.TryParse(db.GetParameterValue(dbCommand, Constants.OutputParameterResultFlag).ToString(), NumberStyles.Integer, null, out returnFlag);
            if (result)
            {
                if (returnFlag > Constants.None)
                {
                    output = Constants.Success;
                } // End If
            }

            // Return the output of the operation.
            return(output);
        } // End UpdateJobExecutionStatus()
示例#2
0
        } // End UpdateJobExecutionStatus()

        #endregion



        #region OtherMethods
        /// <summary>
        /// This method is used to Get the Details of a Job SubScription Details.
        /// </summary>
        /// <param name="JobID">Unique Identifier for a job</param>
        /// <returns>JobBusinessEntity</returns>
        public static JobBusinessEntity GetJobSubScriptionDetails(string jobID)
        {
            bool result; int returnFlag;
            JobBusinessEntity jobBEO;
            // Create a new instance of the DB manager.
            EVDbManager DBManager = new EVDbManager();

            DbCommand dbCommand = DBManager.GetStoredProcCommand(Constants.GetJobSubscriptionDetails);

            DBManager.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, Convert.ToInt32(jobID));
            DBManager.AddOutParameter(dbCommand, Constants.JobReturnFlagOutParameter, DbType.Int32, 4);

            DataSet dsJobs = DBManager.ExecuteDataSet(dbCommand);

            jobBEO = new JobBusinessEntity();
            result = Int32.TryParse(DBManager.GetParameterValue(dbCommand, Constants.JobReturnFlagOutParameter).ToString(), NumberStyles.Integer, null, out returnFlag);
            if (result)
            {
                if (dsJobs != null && dsJobs.Tables.Count > 0 && dsJobs.Tables[0].Rows.Count > 0)
                {
                    DataRow job = dsJobs.Tables[0].Rows[0];
                    jobBEO.Type       = !Convert.IsDBNull(job[Constants.PropertyNameSubscriptionTypeId]) ? Convert.ToInt32(job[Constants.PropertyNameSubscriptionTypeId]) : 0;
                    jobBEO.TypeName   = !Convert.IsDBNull(job[Constants.PropertyNameSubscriptionTypeName]) ? job[Constants.PropertyNameSubscriptionTypeName].ToString() : string.Empty;
                    jobBEO.FolderID   = Convert.ToInt64(job[Constants.PropertyNameFolderId]);
                    jobBEO.FolderName = job[Constants.PropertyNameFolderName].ToString();
                    jobBEO.Visibility = Convert.ToBoolean(job[Constants.PropertyNameVisibility]);
                    jobBEO.Priority   = Convert.ToInt32(job[Constants.PropertyNamePriority]);
                    jobBEO.Name       = !Convert.IsDBNull(job[Constants.PropertyNameJobName]) ? job[Constants.PropertyNameJobName].ToString() : string.Empty;
                }
            }
            return(jobBEO);
        }
示例#3
0
        /// <summary>
        /// This method will be used to save the log information
        /// </summary>
        /// <param name="jobId">Job Identifier</param>
        /// <param name="jobRunId">Job Run Id</param>
        /// <param name="jobLog">JobLog</param>
        /// <param name="user">User Id</param>
        /// <param name="isError">Is Error</param>
        /// <param name="errorCode">Error Code</param>
        /// <param name="isXmlLog">Is Xml</param>
        /// <returns>true if, information saved successfully, otherwise return false.</returns>
        public static bool JobLog(int jobId, int jobRunId, string jobLog, string user, bool isError, string errorCode, bool isXmlLog)
        {
            //Variable Decleration
            DbCommand   dbCommand;
            int         result;
            bool        returnflag;
            EVDbManager DBManager = new EVDbManager();

            // Instantiate the stored procedure to update the job status.
            dbCommand = DBManager.GetStoredProcCommand(Constants.EvImDalSpSaveJobLog);
            // Add parameters to Command object
            DBManager.AddInParameter(dbCommand, Constants.ParamInJobId, DbType.Int64, jobId);
            DBManager.AddInParameter(dbCommand, Constants.ParamInJobRunId, DbType.Int32, jobRunId);
            DBManager.AddInParameter(dbCommand, Constants.ParamInJobLog, DbType.String, jobLog);
            DBManager.AddInParameter(dbCommand, Constants.ImportsParamInCreatedBy, DbType.String, user);
            DBManager.AddInParameter(dbCommand, Constants.ParamInIsError, DbType.Boolean, isError);
            DBManager.AddInParameter(dbCommand, Constants.ImportsParamInErrorCode, DbType.String, errorCode);
            DBManager.AddInParameter(dbCommand, Constants.ParamInIsxml, DbType.Boolean, isXmlLog);
            DBManager.AddOutParameter(dbCommand, Constants.ParamOutReturnFlag, DbType.Int32, 4);

            DBManager.ExecuteNonQuery(dbCommand);
            result = Convert.ToInt32(DBManager.GetParameterValue(dbCommand, Constants.ParamOutReturnFlag), CultureInfo.CurrentCulture);

            returnflag = result >= 0;
            DBManager  = null;
            dbCommand  = null;
            return(returnflag);
        }
示例#4
0
        /// <summary>
        /// Updates the task log.
        /// </summary>
        /// <param name="jobId">The job id.</param>
        /// <param name="jobRunId">The job run id.</param>
        /// <param name="taskNumber">The task number.</param>
        /// <param name="taskKey">The task key.</param>
        /// <param name="taskLog">The task log.</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="erroCode">ErrorCode</param>
        public static bool UpdateTaskLog(int jobId, int jobRunId, int taskNumber, string taskKey,
                                         string taskLog, bool isError, DateTime?startTime, DateTime?endTime, string errorCode)
        {
            //Variable Decleration
            DbCommand   dbCommand;
            int         result;
            bool        returnflag;
            EVDbManager DBManager = new EVDbManager();

            // Set command object and SP
            dbCommand = DBManager.GetStoredProcCommand(Constants.EvJobUpdateTaskDetails);
            // Add parameters to Command object
            DBManager.AddInParameter(dbCommand, Constants.ParamInJobId, DbType.Int64, jobId);
            DBManager.AddInParameter(dbCommand, Constants.ParamInJobRunId, DbType.Int32, jobRunId);
            DBManager.AddInParameter(dbCommand, Constants.InputParameterTaskId, DbType.Int32, taskNumber);
            DBManager.AddInParameter(dbCommand, Constants.InputParameterTaskKey, DbType.String, taskKey);
            DBManager.AddInParameter(dbCommand, Constants.InputParameterTaskLog, DbType.String, taskLog);
            DBManager.AddInParameter(dbCommand, Constants.InputParameterIsError, DbType.Boolean, isError);
            DBManager.AddInParameter(dbCommand, Constants.InputParameterTaskStartTime, DbType.DateTime, startTime);
            DBManager.AddInParameter(dbCommand, Constants.InputParameterTaskEndTime, DbType.DateTime, endTime);
            DBManager.AddInParameter(dbCommand, Constants.ImportsParamInErrorCode, DbType.String, errorCode);

            DBManager.AddOutParameter(dbCommand, Constants.OutputParameterRowsUpdated, DbType.Int32, 4);
            DBManager.ExecuteNonQuery(dbCommand);
            result = Convert.ToInt32(DBManager.GetParameterValue(dbCommand, Constants.OutputParameterRowsUpdated), CultureInfo.CurrentCulture);

            returnflag = result >= 0;
            DBManager  = null;
            dbCommand  = null;
            return(returnflag);
        }
示例#5
0
        } // End UpdateJobNextRun()

        /// <summary>
        /// This method adds a job to the load queue to be picked up by the job loader.
        /// </summary>
        /// <param name="jobId">Job Identifier.</param>
        /// <param name="jobTypeId">Job Type Identifier.</param>
        /// <param name="jobRunDuration">Job Run Duration.</param>
        /// <param name="serverId">Server Identifier.</param>
        /// <param name="jobRunId">Job Run Identifier.</param>
        /// <param name="jobLoadTime"> Job Load Time</param>
        /// <param name="jobParameters"> Job Parameters</param>
        /// <returns>Status of the operation.</returns>
        internal static bool AddJobToLoadQueue(int jobId, int jobTypeId, int jobRunDuration, Guid serverId, out int jobRunId, string jobParameters, DateTime jobLoadTime)
        {
            // Declare a local output variable.
            bool output = Constants.Success;

            // Initialize job run id to 0.
            jobRunId = 0;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager(Constants.ConfigKeyDatabaseToUse);

            // Instantiate the stored procedure to obtain the jobs from load queue.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureInsertIntoLoadQueue);

            // Add input and output parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, jobId);
            db.AddInParameter(dbCommand, Constants.InputParameterJobTypeId, DbType.Int32, jobTypeId);
            db.AddInParameter(dbCommand, Constants.InputParameterJobDurationMinutes, DbType.Int32, jobRunDuration);
            db.AddInParameter(dbCommand, Constants.InputParameterJobServerId, DbType.Guid, serverId);
            db.AddInParameter(dbCommand, Constants.InputJobParameters, DbType.Xml, jobParameters);
            db.AddInParameter(dbCommand, Constants.InputJobLoadTime, DbType.DateTime, jobLoadTime);
            db.AddOutParameter(dbCommand, Constants.OutputParameterJobRunId, DbType.Int32, 4);

            if (db.ExecuteNonQuery(dbCommand) <= Constants.None)
            {
                output = Constants.Failure;
            }

            // Get the job run id returned.
            jobRunId = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterJobRunId));

            // Return the output of the operation.
            return(output);
        } // End AddJobToLoadQueue()
示例#6
0
        /// <summary>
        /// Get Task Details.
        /// </summary>
        /// <typeparam name="JobParametersType">JobParametersType</typeparam>
        /// <typeparam name="TaskType">TaskType</typeparam>
        /// <param name="jobParameters">jobParameters</param>
        /// <returns>Tasks<TaskType></returns>
        public static Tasks <TaskType> GetJobTaskDetails <JobParametersType, TaskType>(JobParametersType jobParameters) where TaskType : class, new()
        {
            Tasks <TaskType> tasks = new Tasks <TaskType>();
            int         jobRunId   = Convert.ToInt32(Helper.GetParameterValue(jobParameters, Constants.PropertyNameJobRunId), CultureInfo.CurrentCulture);
            EVDbManager db         = new EVDbManager();
            // Instantiate the stored procedure to update the job status.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureGetTaskDetails);

            // Add input parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobRunId, DbType.Int32, jobRunId);
            db.AddInParameter(dbCommand, Constants.InputParamertTaskDetailsRequired, DbType.Boolean, false);

            // Execute the stored procedure and obtain the result set from the database into a dataset.
            DataSet  dsResult = db.ExecuteDataSet(dbCommand);
            TaskType task;

            if (dsResult != null && dsResult.Tables.Count > 0 && dsResult.Tables[Constants.First].Rows.Count > 0)
            {
                Helper.SetParameterValue <JobParametersType, double>(jobParameters, Constants.PropertyNameJobProgressPercent, Convert.ToDouble(dsResult.Tables[Constants.First].Rows[Constants.First][Constants.TableOpenJobsColumnProgressPercent], CultureInfo.CurrentCulture));
                foreach (DataRow drResult in dsResult.Tables[Constants.First].Rows)
                {
                    byte[] binaryData = (byte[])drResult[Constants.TableOpenJobsColumnTaskDetails];
                    task = DeserializeObjectBinary <TaskType>(binaryData);
                    Helper.SetParameterValue <TaskType, int>(task, Constants.PropertyNameTaskNumber, Convert.ToInt32(drResult[Constants.TableOpenJobsColumnTaskId], CultureInfo.CurrentCulture));
                    Helper.SetParameterValue <TaskType, bool>(task, Constants.PropertyNameTaskComplete, Convert.ToBoolean(drResult[Constants.TableOpenJobsColumnIsComplete], CultureInfo.CurrentCulture));
                    Helper.SetParameterValue <TaskType, bool>(task, Constants.PropertyNameIsTaskError, Convert.ToBoolean(drResult[Constants.TableOpenJobsColumnIsError], CultureInfo.CurrentCulture));
                    tasks.Add(task);
                }
            }
            // Return the list of tasks.
            return(tasks);
        }
示例#7
0
        /// <summary>
        ///  Used to insert Task Details in database
        /// </summary>
        /// <typeparam name="TaskType">TaskType</typeparam>
        /// <param name="taskList">List of Tasks</param>
        /// <param name="jobRunId">Job Run Id</param>
        /// <returns></returns>
        public static bool InsertTaskDetails(int jobRunId, int taskNumber, byte[] taskBinary)
        {
            // Declare a local output variable.
            bool        output    = Constants.Success;
            EVDbManager db        = new EVDbManager();
            DbCommand   dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureInsertIntoTaskDetails);

            // Add input and output parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobRunId, DbType.Int32, jobRunId);
            db.AddInParameter(dbCommand, Constants.InputParameterTaskId, DbType.Int32, taskNumber);
            db.AddInParameter(dbCommand, Constants.InputParameterTaskDetails, DbType.Binary, taskBinary);
            db.AddOutParameter(dbCommand, Constants.OutputParameterRowsUpdated, DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            // Get the issued command id returned.
            int iRowsUpdated = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterRowsUpdated), CultureInfo.CurrentCulture);

            // Execute the stored procedure.
            if (iRowsUpdated <= Constants.None)
            {
                output = Constants.Failure;
            } // End If
            db        = null;
            dbCommand = null;
            return(output);
        }
示例#8
0
        public static bool UpdateTaskCompletionStatus(int jobRunId)
        {
            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager();
            // Instantiate the stored procedure to update the job status.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureUpdateTaskCompletionStatus);

            db.AddInParameter(dbCommand, Constants.InputParameterJobRunId, DbType.Int32, jobRunId);
            db.AddOutParameter(dbCommand, Constants.OutputParameterRowsUpdated, DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            int iRowsUpdated = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterRowsUpdated), CultureInfo.CurrentCulture);

            return(iRowsUpdated > 0 ? Constants.Success : Constants.Failure);
        }
示例#9
0
        /// <summary>
        /// Update the Job Status for all the tasks.
        /// </summary>
        /// <typeparam name="TaskType">TaskType</typeparam>
        /// <param name="jobRunId">jobRunId</param>
        /// <param name="progressPercent">progressPercent</param>
        /// <param name="taskId">taskId</param>
        /// <param name="issuedCommandId">issuedCommandId</param>
        /// <param name="taskStartTime">taskStartTime</param>
        /// <returns></returns>
        internal static bool UpdateJobStatus <TaskType>(int jobRunId, double progressPercent, int taskId, out int issuedCommandId, DateTime?taskStartTime, bool isCustomProgressPercentage)
        {
            // Initialize the issued command id to 0.
            issuedCommandId = Constants.None;

            // Serialize the tasks to XML.
            string statusXml = string.Empty;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager();
            // Instantiate the stored procedure to update the job status.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureUpdateOpenJobs);

            // Add input and output parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobRunId, DbType.Int32, jobRunId);
            db.AddInParameter(dbCommand, Constants.InputParameterProgressPercent, DbType.Double, progressPercent);
            db.AddInParameter(dbCommand, Constants.InputParameterTaskId, DbType.Int32, taskId);
            db.AddInParameter(dbCommand, Constants.InputParameterCurrentStatusId, DbType.Int32, (int)JobController.JobStatus.Running);
            db.AddInParameter(dbCommand, Constants.InputParameterProgressUpdateSource, DbType.String, isCustomProgressPercentage ? "J" : "F");

            if (taskStartTime != null)
            {
                db.AddInParameter(dbCommand, Constants.InputparamTaskStartTime, DbType.DateTime, taskStartTime);
            }
            db.AddOutParameter(dbCommand, Constants.OutputParameterIssuedCommandId, DbType.Int32, 4);
            db.AddOutParameter(dbCommand, Constants.OutputParameterRowsUpdated, DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            int iRowsUpdated = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterRowsUpdated), CultureInfo.CurrentCulture);

            if (0 == iRowsUpdated)
            {
                issuedCommandId = Constants.Running;
                return(Constants.Success);
            }

            if (iRowsUpdated < 0)
            {
                issuedCommandId = Constants.Running;
                return(Constants.Failure);
            }

            // Get the issued command id returned.
            issuedCommandId = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterIssuedCommandId), CultureInfo.CurrentCulture);

            // Return the output of the operation.
            return(Constants.Success);
        }
示例#10
0
        /// <summary>
        /// This method is used to Issue the command to a running job
        /// </summary>
        /// <param name="jobRunID">Unique Job ID</param>
        /// <param name="statusId">Job Status</param>
        /// <returns>bool</returns>
        public static bool UpdateJobStatus(int jobId, int statusId)
        {
            // Declare a local output variable.
            bool output = Constants.Success;
            int  returnFlag;
            // Create a new instance of the DB manager.
            EVDbManager db        = new EVDbManager();
            DbCommand   dbCommand = db.GetStoredProcCommand(Constants.UpdateJobStatusProcedure);

            db.AddInParameter(dbCommand, Constants.ParameterInputJobId, DbType.Int32, jobId);
            db.AddInParameter(dbCommand, Constants.InputParameterJobStatus, DbType.Int32, statusId);
            db.AddOutParameter(dbCommand, Constants.OutputParameterReturnFlag, DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            output    = Int32.TryParse(db.GetParameterValue(dbCommand, Constants.OutputParameterReturnFlag).ToString(), NumberStyles.Integer, null, out returnFlag);
            dbCommand = null;
            return(output);
        }
示例#11
0
        /// <summary>
        /// This method is used to Get the Status of a Job of the given JobID
        /// </summary>
        /// <param name="jobId">Unique Identifier for a job</param>
        /// <returns>int</returns>
        public static int GetJobStatus(string jobId)
        {
            int         status = 0; int returnFlag;
            EVDbManager DBManager = new EVDbManager();

            DbCommand dbCommand = DBManager.GetStoredProcCommand("EV_JOB_Get_Status");

            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterJobId, DbType.Int32, Convert.ToInt32(jobId));
            DBManager.AddOutParameter(dbCommand, "@out_iStatus", DbType.Int32, 4);
            DBManager.AddOutParameter(dbCommand, "@out_iFlag", DbType.Int32, 4);
            DBManager.ExecuteNonQuery(dbCommand);
            bool result = Int32.TryParse((DBManager.GetParameterValue(dbCommand, "@out_iFlag")).ToString(), NumberStyles.Integer, null, out returnFlag);

            if (result)
            {
                if (returnFlag == 1)
                {
                    status = Convert.ToInt32(DBManager.GetParameterValue(dbCommand, "@out_iStatus"));
                }
            }
            return(status);
        }
示例#12
0
        /// <summary>
        /// This method updates the job execution status.
        /// </summary>
        /// <remarks>
        /// Execution statuses include: Loaded, Running, Stopped, Paused.
        /// </remarks>
        /// <param name="jobRunId">Job Run Id.</param>
        /// <param name="jobExecutionStatusId">Job Execution Status Id.</param>
        /// <param name="issuedCommandId">Indicates the command id issued for the job.</param>
        /// <returns>Status of the update operation.</returns>
        internal static bool UpdateJobExecutionStatus(int jobRunId, int jobExecutionStatusId, out int issuedCommandId)
        {
            // Initialize the issued command id to 0.
            issuedCommandId = 0;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager();

            // Create a new instance of the DB manager.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureUpdateOpenJobs);

            // Add input and output parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobRunId, DbType.Int32, jobRunId);
            db.AddInParameter(dbCommand, Constants.InputParameterCurrentStatusId, DbType.Int32, jobExecutionStatusId);
            db.AddOutParameter(dbCommand, Constants.OutputParameterIssuedCommandId, DbType.Int32, 4);
            db.AddOutParameter(dbCommand, Constants.OutputParameterRowsUpdated, DbType.Int32, 4);
            // Execute the stored procedure.
            db.ExecuteNonQuery(dbCommand);
            int iRowsUpdated = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterRowsUpdated), CultureInfo.CurrentCulture);

            if (0 == iRowsUpdated)
            {
                issuedCommandId = Constants.Running;
                return(Constants.Success);
            }

            if (iRowsUpdated < 0)
            {
                issuedCommandId = Constants.Running;
                return(Constants.Failure);
            }

            // Get the issued command id returned.
            issuedCommandId = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterIssuedCommandId), CultureInfo.CurrentCulture);

            // Return the output of the operation.
            return(Constants.Success);
        } // End UpdateJobExecutionStatus()
示例#13
0
        } // End GetJobsToLoad()

        /// <summary>
        /// This method can be used to update the next run date for a job with recurring schedule.
        /// </summary>
        /// <param name="jobId">Job Identifier.</param>
        /// <param name="nextRunDate">Next run date for a job.</param>
        /// <returns>Status of the update operation.</returns>
        internal static bool UpdateJobNextRun(int jobId, DateTime nextRunDate)
        {
            // Declare a local output variable.
            bool output = Constants.Success;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager(Constants.ConfigKeyDatabaseToUse);

            // Instantiate the stored procedure to obtain the jobs from load queue.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureUpdateJobNextRun);

            // Add input parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, jobId);
            db.AddInParameter(dbCommand, Constants.InputParameterNextRunDate, DbType.DateTime, nextRunDate);

            // Execute the stored procedure to update the next run date for the specified job.
            if (db.ExecuteNonQuery(dbCommand) <= Constants.None)
            {
                output = Constants.Failure;
            }

            // Return the output of the operation.
            return(output);
        } // End UpdateJobNextRun()
示例#14
0
        /// <summary>
        /// Get Job Task Log Details.
        /// </summary>
        /// <param name="jobId">Job Identifier</param>
        /// <param name="jobRunId">Job Run Identifier</param>
        /// <param name="taskId">Task Identifier</param>
        /// <returns>LogInfo Xml</returns>
        public static string GetLogDetails(int jobId, int jobRunId, int taskId)
        {
            EVDbManager DBManager = new EVDbManager();
            DbCommand   dbCommand = DBManager.GetStoredProcCommand(Constants.GetLogDetailsProcedure);

            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterJobId, DbType.Int32, jobId);
            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterJobRunId, DbType.Int32, jobRunId);
            DBManager.AddInParameter(dbCommand, Constants.JobInputParameterTaskId, DbType.Int32, taskId);
            DBManager.AddOutParameter(dbCommand, Constants.ParamOutTotalNoOfRecord, DbType.Int32, 4);
            JobBusinessEntity jobBeo = new JobBusinessEntity();
            DataSet           dsJobs = DBManager.ExecuteDataSet(dbCommand);
            int totalNoOfRecords     = Convert.ToInt32(DBManager.GetParameterValue(dbCommand, Constants.ParamOutTotalNoOfRecord), CultureInfo.CurrentCulture);

            if (totalNoOfRecords == -1)
            {
                return(string.Empty);
            }
            if (dsJobs != null && dsJobs.Tables.Count > 0 && dsJobs.Tables[0].Rows.Count > 0)
            {
                return(Convert.IsDBNull(dsJobs.Tables[0].Rows[0][Constants.LogInformation]) ? string.Empty : Convert.ToString(dsJobs.Tables[0].Rows[0][Constants.LogInformation]));
            }

            return(string.Empty);
        }
示例#15
0
        /// <summary>
        /// This method can be used to retrieve the list jobs to be loaded based on their schedule.
        /// </summary>
        /// <returns>List of jobs to be loaded.</returns>
        internal static List <JobSchedule> GetJobsToLoad()
        {
            // Create an instance of the JobScheduleMonitorBEO.
            List <JobSchedule> jobsToLoad = null;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager(Constants.ConfigKeyDatabaseToUse);

            // Instantiate the stored procedure to obtain the jobs from load queue.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureGetJobsToLoad);

            // Add input parameters.
            // RK - Changed the sp to work for both the functions. Need to send DBNull.Value for JobID.
            // Arun - This is incorrect. I've no idea why this SP needs JobId!
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, DBNull.Value);

            // Execute the stored procedure and obtain the result set from the database into a dataset.
            DataSet dsResult = db.ExecuteDataSet(dbCommand);

            // If there are jobs to load then obtain the schedules.
            if (dsResult != null && dsResult.Tables.Count > Constants.None)
            {
                // Create an instance of job schedules list.
                jobsToLoad = new List <JobSchedule>();

                // Declare a job schedule object to represent a current job schedule.
                JobSchedule currentJob;

                // Declare a job schedule object to represent the previous job schedule while processing in a loop.
                JobSchedule previousJob = null;

                // Declare an integer to store the current job id.
                int currentJobId = Constants.None;

                // For each job that has to be loaded process the schedule information.
                foreach (DataRow drResult in dsResult.Tables[Constants.First].Rows)
                {
                    // Create an instance of the current job schedule.
                    currentJob = new JobSchedule();

                    // Get the current job id.
                    currentJobId = Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnJobId]);

                    // If this is the first job or if this is a different job from the previous job then create a new instance for the current job.
                    if ((previousJob == null) || (previousJob.JobId != currentJobId))
                    {
                        // Set the job id.
                        currentJob.JobId = currentJobId;

                        // Set the job name.
                        currentJob.JobName = Convert.ToString(drResult[Constants.TableJobMasterColumnJobName]);

                        // Set the job server id.
                        currentJob.JobServerId = !Convert.IsDBNull(drResult[Constants.TableJobMasterColumnJobServerId]) ? new Guid(Convert.ToString(drResult[Constants.TableJobMasterColumnJobServerId])) : Guid.Empty;

                        // Set the job server id.
                        currentJob.BootParameters = !Convert.IsDBNull(drResult[Constants.TableJobMasterColumnJobParameters]) ? Convert.ToString(drResult[Constants.TableJobMasterColumnJobParameters]) : string.Empty;

                        // Set the job type id.
                        currentJob.JobTypeId = Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnJobTypeId]);

                        // Set the job type name.
                        currentJob.JobTypeName = Convert.ToString(drResult[Constants.TableJobTypeMasterColumnJobRunId]);

                        // Set the job start date.
                        currentJob.JobStartDate = Convert.ToDateTime(drResult[Constants.TableJobScheduleMasterColumnJobStartDate]);

                        // Set the hourly repeat interval. If the value is null set it to 0.
                        currentJob.Hourly = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnHourly]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnHourly]) : Constants.None;

                        // Set the daily repeat interval. If the value is null set it to 0.
                        currentJob.Daily = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnDaily]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnDaily]) : Constants.None;

                        // Set the requested recurrence count for the job. If the value is null set it to 0.
                        currentJob.RequestedRecurrenceCount = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnRequestedRecurrenceCount]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnRequestedRecurrenceCount]) : Constants.None;

                        // Set the requested occurence count for the job. If the value is null set it to 0.
                        currentJob.ActualOccurenceCount = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnActualOccurrenceCount]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnActualOccurrenceCount]) : 0;

                        // Set the job next run date.
                        currentJob.NextRunDate = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnNextRunDate]) ? Convert.ToDateTime(drResult[Constants.TableJobScheduleMasterColumnNextRunDate]) : Constants.MinDate;

                        // Set the job run duration.
                        currentJob.JobRunDuration = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnDurationMinutes]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnDurationMinutes]) : Constants.MinutesInOneYear;

                        // Set the previous job instance to current job.
                        previousJob = currentJob;
                    }
                    else
                    {
                        // If this is not the first job and if this is the same job as the previous job set the current job instance to the previous job.
                        currentJob = previousJob;
                    } // End if

                    // Create an instance of the job schedule details.
                    JobScheduleDetails jobScheduleDetails = new JobScheduleDetails
                    {
                        WeekMonthIndicator =
                            Convert.ToString(
                                drResult[
                                    Constants.
                                    TableJobScheduleDetailsColumnWeekMonthIndicator
                                ]),
                        DayDateIndicator =
                            Convert.ToString(
                                drResult[
                                    Constants.
                                    TableJobScheduleDetailsColumnDayDateIndicator
                                ])
                    };

                    // Set the week / month indicator.

                    // Set the day / date indicator.

                    // Set the date value.
                    if (!Convert.IsDBNull(drResult[Constants.TableJobScheduleDetailsColumnDate]))
                    {
                        jobScheduleDetails.DateValue = Convert.ToDateTime(drResult[Constants.TableJobScheduleDetailsColumnDate]);
                    }

                    // Set the repeat every interval.
                    jobScheduleDetails.RepeatEvery = !Convert.IsDBNull(drResult[Constants.TableJobScheduleDetailsColumnRepeatEvery]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleDetailsColumnRepeatEvery]) : 0;


                    // Add the schedule details to the current job.
                    if (currentJob.ScheduleDetails == null)
                    {
                        currentJob.ScheduleDetails = new List <JobScheduleDetails>();
                    }

                    // Add the current schedule information to the current job.
                    currentJob.ScheduleDetails.Add(jobScheduleDetails);

                    // Add the current job to the jobs to load list.
                    jobsToLoad.Add(currentJob);
                } // End for each
            }     // End if

            // Return the list of jobs to load.
            return(jobsToLoad);
        } // End GetJobsToLoad()
        } // End UpdateJobNextRun()

        /// <summary>
        /// This method adds a job to the load queue to be picked up by the job loader.
        /// </summary>
        /// <param name="jobId">Job Identifier.</param>
        /// <param name="jobTypeId">Job Type Identifier.</param>
        /// <param name="jobRunDuration">Job Run Duration.</param>
        /// <param name="serverId">Server Identifier.</param>
        /// <param name="jobRunId">Job Run Identifier.</param>
        /// <param name="jobLoadTime"> Job Load Time</param>
        /// <param name="jobParameters"> Job Parameters</param>
        /// <returns>Status of the operation.</returns>
        internal static bool AddJobToLoadQueue(int jobId, int jobTypeId, int jobRunDuration, Guid serverId, out int jobRunId, string jobParameters, DateTime jobLoadTime)
        {
            // Declare a local output variable.
            bool output = Constants.Success;

            // Initialize job run id to 0.
            jobRunId = 0;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager(Constants.ConfigKeyDatabaseToUse);

            // Instantiate the stored procedure to obtain the jobs from load queue.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureInsertIntoLoadQueue);

            // Add input and output parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, jobId);
            db.AddInParameter(dbCommand, Constants.InputParameterJobTypeId, DbType.Int32, jobTypeId);
            db.AddInParameter(dbCommand, Constants.InputParameterJobDurationMinutes, DbType.Int32, jobRunDuration);
            db.AddInParameter(dbCommand, Constants.InputParameterJobServerId, DbType.Guid, serverId);
            db.AddInParameter(dbCommand, Constants.InputJobParameters, DbType.Xml, jobParameters);
            db.AddInParameter(dbCommand, Constants.InputJobLoadTime, DbType.DateTime, jobLoadTime);
            db.AddOutParameter(dbCommand, Constants.OutputParameterJobRunId, DbType.Int32, 4);

            if (db.ExecuteNonQuery(dbCommand) <= Constants.None)
            {
                output = Constants.Failure;
            }

            // Get the job run id returned.
            jobRunId = Convert.ToInt32(db.GetParameterValue(dbCommand, Constants.OutputParameterJobRunId));

            // Return the output of the operation.
            return output;
        } // End AddJobToLoadQueue()
        /// <summary>
        /// This method can be used to retrieve the list jobs to be loaded based on their schedule.
        /// </summary>
        /// <returns>List of jobs to be loaded.</returns>
        internal static List<JobSchedule> GetJobsToLoad()
        {
            // Create an instance of the JobScheduleMonitorBEO.
            List<JobSchedule> jobsToLoad = null;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager(Constants.ConfigKeyDatabaseToUse);

            // Instantiate the stored procedure to obtain the jobs from load queue.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureGetJobsToLoad);
            // Add input parameters. 
            // RK - Changed the sp to work for both the functions. Need to send DBNull.Value for JobID.
            // Arun - This is incorrect. I've no idea why this SP needs JobId!
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, DBNull.Value);

            // Execute the stored procedure and obtain the result set from the database into a dataset.
            DataSet dsResult = db.ExecuteDataSet(dbCommand);

            // If there are jobs to load then obtain the schedules.
            if (dsResult != null && dsResult.Tables.Count > Constants.None)
            {

                // Create an instance of job schedules list.
                jobsToLoad = new List<JobSchedule>();

                // Declare a job schedule object to represent a current job schedule.
                JobSchedule currentJob;

                // Declare a job schedule object to represent the previous job schedule while processing in a loop.
                JobSchedule previousJob = null;

                // Declare an integer to store the current job id.
                int currentJobId = Constants.None;

                // For each job that has to be loaded process the schedule information.
                foreach (DataRow drResult in dsResult.Tables[Constants.First].Rows)
                {
                    // Create an instance of the current job schedule.
                    currentJob = new JobSchedule();

                    // Get the current job id.
                    currentJobId = Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnJobId]);

                    // If this is the first job or if this is a different job from the previous job then create a new instance for the current job.
                    if ((previousJob == null) || (previousJob.JobId != currentJobId))
                    {
                        // Set the job id.
                        currentJob.JobId = currentJobId;

                        // Set the job name.
                        currentJob.JobName = Convert.ToString(drResult[Constants.TableJobMasterColumnJobName]);

                        // Set the job server id.
                        currentJob.JobServerId = !Convert.IsDBNull(drResult[Constants.TableJobMasterColumnJobServerId]) ? new Guid(Convert.ToString(drResult[Constants.TableJobMasterColumnJobServerId])) : Guid.Empty;

                        // Set the job server id.
                        currentJob.BootParameters = !Convert.IsDBNull(drResult[Constants.TableJobMasterColumnJobParameters]) ? Convert.ToString(drResult[Constants.TableJobMasterColumnJobParameters]) : string.Empty;

                        // Set the job type id.
                        currentJob.JobTypeId = Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnJobTypeId]);

                        // Set the job type name.
                        currentJob.JobTypeName = Convert.ToString(drResult[Constants.TableJobTypeMasterColumnJobRunId]);

                        // Set the job start date.
                        currentJob.JobStartDate = Convert.ToDateTime(drResult[Constants.TableJobScheduleMasterColumnJobStartDate]);

                        // Set the hourly repeat interval. If the value is null set it to 0.
                        currentJob.Hourly = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnHourly]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnHourly]) : Constants.None;

                        // Set the daily repeat interval. If the value is null set it to 0.
                        currentJob.Daily = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnDaily]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnDaily]) : Constants.None;

                        // Set the requested recurrence count for the job. If the value is null set it to 0.
                        currentJob.RequestedRecurrenceCount = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnRequestedRecurrenceCount]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnRequestedRecurrenceCount]) : Constants.None;

                        // Set the requested occurence count for the job. If the value is null set it to 0.
                        currentJob.ActualOccurenceCount = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnActualOccurrenceCount]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnActualOccurrenceCount]) : 0;

                        // Set the job next run date.
                        currentJob.NextRunDate = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnNextRunDate]) ? Convert.ToDateTime(drResult[Constants.TableJobScheduleMasterColumnNextRunDate]) : Constants.MinDate;

                        // Set the job run duration.
                        currentJob.JobRunDuration = !Convert.IsDBNull(drResult[Constants.TableJobScheduleMasterColumnDurationMinutes]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleMasterColumnDurationMinutes]) : Constants.MinutesInOneYear;

                        // Set the previous job instance to current job.
                        previousJob = currentJob;
                    }
                    else
                    {
                        // If this is not the first job and if this is the same job as the previous job set the current job instance to the previous job.
                        currentJob = previousJob;
                    } // End if

                    // Create an instance of the job schedule details.
                    JobScheduleDetails jobScheduleDetails = new JobScheduleDetails
                                                                {
                                                                    WeekMonthIndicator =
                                                                        Convert.ToString(
                                                                            drResult[
                                                                                Constants.
                                                                                    TableJobScheduleDetailsColumnWeekMonthIndicator
                                                                                ]),
                                                                    DayDateIndicator =
                                                                        Convert.ToString(
                                                                            drResult[
                                                                                Constants.
                                                                                    TableJobScheduleDetailsColumnDayDateIndicator
                                                                                ])
                                                                };

                    // Set the week / month indicator.

                    // Set the day / date indicator.

                    // Set the date value.
                    if (!Convert.IsDBNull(drResult[Constants.TableJobScheduleDetailsColumnDate]))
                        jobScheduleDetails.DateValue = Convert.ToDateTime(drResult[Constants.TableJobScheduleDetailsColumnDate]);

                    // Set the repeat every interval.
                    jobScheduleDetails.RepeatEvery = !Convert.IsDBNull(drResult[Constants.TableJobScheduleDetailsColumnRepeatEvery]) ? Convert.ToInt32(drResult[Constants.TableJobScheduleDetailsColumnRepeatEvery]) : 0;


                    // Add the schedule details to the current job.
                    if (currentJob.ScheduleDetails == null)
                    {
                        currentJob.ScheduleDetails = new List<JobScheduleDetails>();
                    }

                    // Add the current schedule information to the current job.
                    currentJob.ScheduleDetails.Add(jobScheduleDetails);

                    // Add the current job to the jobs to load list.
                    jobsToLoad.Add(currentJob);
                } // End for each
            } // End if

            // Return the list of jobs to load.
            return jobsToLoad;
        } // End GetJobsToLoad()
        } // End GetJobsToLoad()

        /// <summary>
        /// This method can be used to update the next run date for a job with recurring schedule.
        /// </summary>
        /// <param name="jobId">Job Identifier.</param>
        /// <param name="nextRunDate">Next run date for a job.</param>
        /// <returns>Status of the update operation.</returns>
        internal static bool UpdateJobNextRun(int jobId, DateTime nextRunDate)
        {
            // Declare a local output variable.
            bool output = Constants.Success;

            // Create a new instance of the DB manager.
            EVDbManager db = new EVDbManager(Constants.ConfigKeyDatabaseToUse);

            // Instantiate the stored procedure to obtain the jobs from load queue.
            DbCommand dbCommand = db.GetStoredProcCommand(Constants.StoredProcedureUpdateJobNextRun);

            // Add input parameters.
            db.AddInParameter(dbCommand, Constants.InputParameterJobId, DbType.Int32, jobId);
            db.AddInParameter(dbCommand, Constants.InputParameterNextRunDate, DbType.DateTime, nextRunDate);

            // Execute the stored procedure to update the next run date for the specified job.
            if (db.ExecuteNonQuery(dbCommand) <= Constants.None)
            {
                output = Constants.Failure;
            }

            // Return the output of the operation.
            return output;
        } // End UpdateJobNextRun()
        /// <summary>
        /// Gets the reconversion document beos for job id.
        /// </summary>
        /// <param name="matterId">The matter id.</param>
        /// <param name="jobId">The job id.</param>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public static IEnumerable<ReconversionDocumentBEO> GetReconversionDocumentBeosForJobId(long matterId, long jobId,
                                                                                               string filters)
        {

            IDataReader dataReader = null;

            if (!string.IsNullOrEmpty(filters))
            {
                //user can filter the conversion results then do select all
                //filters has filter key : value with comma a delimiter
                var documentVaultManager = new DocumentVaultManager();
                documentVaultManager.Init(matterId);
                dataReader = documentVaultManager.GetConversionResultsDataReader(matterId, jobId, null, null, filters);
            }
            else
            {
                var evDbManager = new EVDbManager(matterId);
                const string sqlCommand =
                    @"SELECT dm.DocID,dm.DocTitle,dm.DocReferenceID, dm.CollectionID, ps.DCN ,T.DocText
                FROM [dbo].[DOC_ProcessSet] AS ps 
                INNER JOIN [dbo].[DOC_DocumentMaster] AS dm ON ps.[DocID] = dm.[DocID] 
                LEFT OUTER JOIN  dbo.DOC_DocumentText T ON DM.DocID = T.DocID AND T.TextTypeID = 2 
                WHERE ps.JobID = @JobID 
                ORDER BY  DM.DocTitle";
                var dbCommand = evDbManager.CreateTextCommand(sqlCommand);
                dbCommand.CommandTimeout = 0;
                evDbManager.AddInParameter(dbCommand, "JobID", DbType.Int64, jobId);
                dataReader = evDbManager.ExecuteDataReader(dbCommand);
            }

            Debug.Assert(dataReader!=null);
            ReconversionDocumentBEO reconversionDocumentBeo = null;
            while (dataReader.Read())
            {
                string docRefId = dataReader["DocReferenceID"].ToString();
                string collectionId = dataReader["CollectionID"].ToString();
                string dcn = dataReader["DCN"].ToString();

                //new document (need to check this due to that multiple rows are returned in case of one document with multiple file path associated)
                if (reconversionDocumentBeo == null ||
                    !docRefId.Equals(reconversionDocumentBeo.DocumentId) ||
                    !collectionId.Equals(reconversionDocumentBeo.CollectionId) ||
                    !dcn.Equals(reconversionDocumentBeo.DCNNumber))
                {

                    if (reconversionDocumentBeo != null)
                    {
                        //query sorts the results in DCN order
                        //accumulate the file list of the document (DCN) then yield
                        //Example:(DCN File1),(DCN,File2) and (DCN001, File3)
                        //yield DCN,<File1,File2,File3> 
                        yield return reconversionDocumentBeo;
                    }
                    reconversionDocumentBeo = new ReconversionDocumentBEO()
                                                  {
                                                      DocumentId = docRefId,
                                                      CollectionId = collectionId,
                                                      DCNNumber = dcn
                                                  };
                }
                reconversionDocumentBeo.FileList.Add(dataReader[Constants.ColumnDocText].ToString());
                //add file path to list of file path for the document

            }
            dataReader.Close();
            if (reconversionDocumentBeo != null) yield return reconversionDocumentBeo;
        }
示例#20
0
        /// <summary>
        /// Gets the reconversion document beos for job id.
        /// </summary>
        /// <param name="matterId">The matter id.</param>
        /// <param name="jobId">The job id.</param>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public static IEnumerable <ReconversionDocumentBEO> GetReconversionDocumentBeosForJobId(long matterId, long jobId,
                                                                                                string filters)
        {
            IDataReader dataReader = null;

            if (!string.IsNullOrEmpty(filters))
            {
                //user can filter the conversion results then do select all
                //filters has filter key : value with comma a delimiter
                var documentVaultManager = new DocumentVaultManager();
                documentVaultManager.Init(matterId);
                dataReader = documentVaultManager.GetConversionResultsDataReader(matterId, jobId, null, null, filters);
            }
            else
            {
                var          evDbManager = new EVDbManager(matterId);
                const string sqlCommand  =
                    @"SELECT dm.DocID,dm.DocTitle,dm.DocReferenceID, dm.CollectionID, ps.DCN ,T.DocText
                FROM [dbo].[DOC_ProcessSet] AS ps 
                INNER JOIN [dbo].[DOC_DocumentMaster] AS dm ON ps.[DocID] = dm.[DocID] 
                LEFT OUTER JOIN  dbo.DOC_DocumentText T ON DM.DocID = T.DocID AND T.TextTypeID = 2 
                WHERE ps.JobID = @JobID 
                ORDER BY  DM.DocTitle";
                var dbCommand = evDbManager.CreateTextCommand(sqlCommand);
                dbCommand.CommandTimeout = 0;
                evDbManager.AddInParameter(dbCommand, "JobID", DbType.Int64, jobId);
                dataReader = evDbManager.ExecuteDataReader(dbCommand);
            }

            Debug.Assert(dataReader != null);
            ReconversionDocumentBEO reconversionDocumentBeo = null;

            while (dataReader.Read())
            {
                string docRefId     = dataReader["DocReferenceID"].ToString();
                string collectionId = dataReader["CollectionID"].ToString();
                string dcn          = dataReader["DCN"].ToString();

                //new document (need to check this due to that multiple rows are returned in case of one document with multiple file path associated)
                if (reconversionDocumentBeo == null ||
                    !docRefId.Equals(reconversionDocumentBeo.DocumentId) ||
                    !collectionId.Equals(reconversionDocumentBeo.CollectionId) ||
                    !dcn.Equals(reconversionDocumentBeo.DCNNumber))
                {
                    if (reconversionDocumentBeo != null)
                    {
                        //query sorts the results in DCN order
                        //accumulate the file list of the document (DCN) then yield
                        //Example:(DCN File1),(DCN,File2) and (DCN001, File3)
                        //yield DCN,<File1,File2,File3>
                        yield return(reconversionDocumentBeo);
                    }
                    reconversionDocumentBeo = new ReconversionDocumentBEO()
                    {
                        DocumentId   = docRefId,
                        CollectionId = collectionId,
                        DCNNumber    = dcn
                    };
                }
                reconversionDocumentBeo.FileList.Add(dataReader[Constants.ColumnDocText].ToString());
                //add file path to list of file path for the document
            }
            dataReader.Close();
            if (reconversionDocumentBeo != null)
            {
                yield return(reconversionDocumentBeo);
            }
        }
示例#21
0
 public void Dispose()
 {
     _db = null;
 }