/// <summary> /// 对指定的步骤进行授权。 /// </summary> /// <param name="processSign">流程标识。</param> /// <param name="employeeID">进行授权的用户ID。</param> /// <param name="employeeName">进行授权的用户名称。</param> /// <param name="stepSigns">进行授权的步骤标识列表。</param> /// <param name="toEmployeeID">授权的目标用户ID。</param> /// <param name="fromDate">授权开始时间,为2010-01-11 15:00:00格式。</param> /// <param name="toDate">授权结束时间,为2010-01-11 15:00:00格式。</param> /// <param name="msgError">调用失败时的错误消息。</param> /// <returns>如果授权成功则返回true,否则返回false。</returns> public bool AuthorizeFlow(string processSign, GUIDEx employeeID, string employeeName, string[] stepSigns, GUIDEx toEmployeeID, DateTime fromDate, DateTime toDate, out string msgError) { lock (this) { msgError = null; bool result = false; try { #region 验证参数。 if (string.IsNullOrEmpty(processSign)) { msgError = "流程标识为空。"; return result; } if (!employeeID.IsValid) { msgError = "进行授权的用户ID为空。"; return result; } if (string.IsNullOrEmpty(employeeName)) { msgError = "进行授权的用户名称为空。"; return result; } if (stepSigns == null || stepSigns.Length == 0) { msgError = "进行授权的步骤标识列表不存在或为空。"; return result; } if (!toEmployeeID.IsValid) { msgError = "授权的目标用户ID为空。"; return result; } #endregion #region 获取流程定义。 GUIDEx processID = this.flowProcessEntity.FindProcessID(processSign); if (!processID.IsValid) { msgError = "流程标识不正确。"; return result; } #endregion #region 流程步骤定义。 FlowStepEntity flowStepEntity = new FlowStepEntity(); List<FlowStep> flowStepList = flowStepEntity.FindFlowStep(processID, stepSigns); if (flowStepList == null || flowStepList.Count == 0) { msgError = "进行授权的步骤标识列表不存在或为空。"; return result; } #endregion #region 流程步骤的授权。 FlowStepAuthorize flowStepAuthorize = new FlowStepAuthorize(); FlowStepAuthorizeEntity flowStepAuthorizeEntity = new FlowStepAuthorizeEntity(); foreach (FlowStep fs in flowStepList) { flowStepAuthorize.AuthorizeID = GUIDEx.New; flowStepAuthorize.BeginDate = fromDate; flowStepAuthorize.EndDate = toDate; flowStepAuthorize.EmployeeID = employeeID; flowStepAuthorize.StepID = fs.StepID; flowStepAuthorize.TargetEmployeeID = toEmployeeID; result = flowStepAuthorizeEntity.UpdateRecord(flowStepAuthorize); } #endregion } catch (Exception e) { msgError = e.Message; } return result; } }
protected void btnSave_Click(object sender, EventArgs e) { FlowStepAuthorize data = new FlowStepAuthorize(); data.AuthorizeID = this.AuthorizeID.IsValid ? this.AuthorizeID : GUIDEx.New; data.StepID = new GUIDEx(this.ddlStepID.SelectedValue); data.EmployeeID = this.txtEmployeePickerBase.Value; data.EmployeeName = this.txtEmployeePickerBase.Text; data.TargetEmployeeID = this.txtTargetEmployeePickerBase.Value; data.TargetEmployeeName = this.txtTargetEmployeePickerBase.Text; data.BeginDate = DateTime.Parse(this.txtBeginDate.Text); data.EndDate = DateTime.Parse(this.txtEndDate.Text); if (this.presenter.UpdateData(data)) base.SaveData(); }