/// <summary>
        /// Finilize all Loop Steps on Loop Break Event
        /// </summary>
        /// <param name="WfId"></param>
        /// <param name="RunId"></param>
        /// <param name="LoopGroup"></param>
        public WfStatus WorkflowLoopBreak(int WfId, int RunId, string LoopGroup)
        {
            string cmd_text = String.Format(WORKFLOW_LOOP_BREAK_QUERY,
                                            WfId,
                                            RunId,
                                            LoopGroup);
            var ret = ExecuteScalar(cmd_text);

            if (ret == null)
            {
                return(WfStatus.Failed);
            }

            return(DBStatus.DbValue((short)ret));
        }
        /// <summary>
        /// Cancel the Batch(StepId = 0)/Step on the ExitEvent
        /// </summary>
        /// <param name="WfId"></param>
        /// <param name="StepId"></param>
        /// <param name="RunId"></param>
        /// <param name="LoopGroup"></param>
        public WfResult WorkflowExitEventCheck(int WfId, int StepId, int RunId)
        {
            string cmd_text = String.Format(WORKFLOW_EXIT_EVENT_QUERY,
                                            WfId,
                                            StepId,
                                            RunId);
            var ret = ExecuteScalar(cmd_text);

            if (ret == null)
            {
                return(WfResult.Unknown);
            }

            WfResult result;

            switch (DBStatus.DbValue((short)ret))
            {
            case WfStatus.Unknown:
            case WfStatus.Running:
                result = WfResult.Started;
                break;

            case WfStatus.Failed:
                result = WfResult.Create(WfStatus.Failed, "Canceled", 0);
                break;

            case WfStatus.Succeeded:
                result = WfResult.Create(WfStatus.Succeeded, "Canceled", 0);
                break;

            default:
                result = WfResult.Started;
                break;
            }

            return(result);
        }