Exemplo n.º 1
0
        /// <summary>
        /// 开启工作流
        /// </summary>
        /// <param name="isSubmit"></param>
        /// <returns></returns>
        bool StartWorkflow(bool isSubmit)
        {
            bool isSuccess = true;
            bool isOK = DataEdit1.CheckData();//验证子项
            if (!isOK)
            {
                return false;
            }
            string sWorkflowNumber = CreateWorkFlowNumber();

            DataTable dt = DataEdit1.GetResultDt(sWorkflowNumber);
            if (null == dt || dt.Rows.Count == 0)
            {
                return false;
            }
            else
            {
                bool isSetVariable= SetWorkflowVariable(sWorkflowNumber, isSubmit);
                if (!isSetVariable)
                {
                    return false;
                }

                bool isNeedApprove = DataEdit1.IsNeedApprove();
                string sSate = CAWorkflowStatus.InProgress;
                Common comm = new Common();
                comm.BatchAddToListByDatatable(dt, "POTypeChangeItems");
                if (isSubmit&&!isNeedApprove)//不需要审批
                {
                    List<string> lisSucPONOs = new List<string>();
                    bool isAllUpdated = DataEdit1.UpdateToSAP(sWorkflowNumber, ref lisSucPONOs);
                    if (isAllUpdated)//全部更新成功。
                    {
                        comm.UpdateOSPSuccess(sWorkflowNumber);
                        sSate = CAWorkflowStatus.Completed;
                        //string sPONO = comm.GetPONOs(dt);
                    }
                    else
                    {
                        WorkflowContext context = WorkflowContext.Current;
                        context.UpdateWorkflowVariable("IsSubmit", false);
                        context.UpdateWorkflowVariable("IsResubmit", true);
                        context.UpdateWorkflowVariable("EditTitle", "Please complete POTypeChange:" + sWorkflowNumber);
                    }
                    if (lisSucPONOs.Count > 0)
                    {
                        comm.SendNoticeMail(lisSucPONOs.ToString(), CurrentEmployee.DisplayName, sWorkflowNumber);
                    }
                }

                SetListValue(sWorkflowNumber, sSate);
                return isSuccess;
            }
        }
Exemplo n.º 2
0
        ///tss =CS-Nom
        ///cs= norm-CS
        /// <summary>
        /// 执行工作流
        /// </summary>
        /// <param name="isSubmit"></param>
        /// <returns></returns>
        bool RunWorkflow(bool isSubmit)
        {
            WorkflowDataFields fields = WorkflowContext.Current.DataFields;
            string sWorkflowNO = fields["Title"].ToString();
            bool isSuccess = true;

            DataTable dt = DataEdit1.GetResultDt(sWorkflowNO);
            if (null == dt || dt.Rows.Count == 0)
            {
                DisplayMessage("No avaliable data!");
                return false;
            }
            else
            {

                bool isSetVariable = SetWorkflowVariable(sWorkflowNO, isSubmit);
                if (!isSetVariable)
                {
                    return false;
                }

                Common comm = new Common();
                comm.DeleteData(sWorkflowNO);//删除老数据
                comm.BatchAddToListByDatatable(dt, "POTypeChangeItems");//添加新数据
                WorkflowContext context = WorkflowContext.Current;
                string sSate = CAWorkflowStatus.InProgress;

                bool IsNeedApprove = DataEdit1.IsNeedApprove();
                if (isSubmit && !IsNeedApprove)//不需要审批
                {
                    List<string> lisSucPONOs = new List<string>();
                    bool isAllUpdated = DataEdit1.UpdateToSAP(sWorkflowNO, ref lisSucPONOs);
                    if (isAllUpdated)//全部更新成功。
                    {
                        comm.UpdateOSPSuccess(sWorkflowNO);
                        sSate = CAWorkflowStatus.Completed;
                    }
                    else
                    {
                        context.UpdateWorkflowVariable("IsSubmit", false);
                        context.UpdateWorkflowVariable("IsResubmit", false);
                        context.UpdateWorkflowVariable("EditTitle", "Please complete POTypeChange:" + sWorkflowNO);
                    }
                    if (lisSucPONOs.Count > 0)
                    {
                        comm.SendNoticeMail(lisSucPONOs.ToString(), CurrentEmployee.DisplayName, sWorkflowNO);
                    }
                }
                SetListValue(sSate);
                return isSuccess;
            }
        }