/// <summary>
        /// Reports execution results to the backend
        /// </summary>
        /// <param name="wfs"></param>
        /// <param name="Result"></param>
        /// <returns></returns>
        public bool WorkflowStepStatusSet(WorkflowStep wfs, WfResult Result)
        {
            if (wfs == null || wfs.RunId == 0)
            {
                throw new InvalidDataException("WorkflowStep object is not in the correct state");
            }


            short  status_id = DBStatus.WfValue(Result.StatusCode);
            string cmd_text  = String.Format(WORKFLOW_STEP_STATUS_SET_QUERY,
                                             wfs.WorkflowId,
                                             wfs.StepId,
                                             wfs.RunId,
                                             status_id,
                                             Result.ErrorCode);

            ExecuteNonQuery(cmd_text);

            return(true);
        }
        /// <summary>
        /// Finilizes the Workflow completion with backend.
        /// Perform Workflow History Cleanup based on retention policy.
        /// </summary>
        /// <param name="wf"></param>
        /// <param name="Result"></param>
        /// <returns></returns>
        public bool WorkflowFinalize(Workflow wf, WfResult Result)
        {
            if (wf == null || wf.RunId == 0)
            {
                throw new InvalidDataException("Workflow object can not be finalized");
            }


            short  status_id = DBStatus.WfValue(Result.StatusCode);
            string cmd_text  = String.Format(WORKFLOW_FINALIZE_QUERY,
                                             wf.WorkflowId,
                                             wf.RunId,
                                             status_id,
                                             wf.HistoryRetention,
                                             ((_debug) ? 1 : 0));

            ExecuteNonQuery(cmd_text);

            return(true);
        }