Пример #1
0
        private void tspStart_Click(object sender, EventArgs e)
        {
            ///判定每个节点是否选择了签批用户
            ///步骤:1.找到该工作流实例对应工作模板中的所有节点,在handle表中判定是否有对应签批用户信息,有的话进行下一步check,否则提示直接返回

            StringBuilder stbMain = new StringBuilder();
            stbMain.Append(" ComboBoxValue  WHERE COMBVALUE IN( ");
            stbMain.Append(" SELECT WFT_CURRENT_STEP_ID  FROM WF_TEMPLATES_STEP ");
            stbMain.AppendFormat(" WHERE  WFT_ID='{0}' ", this.WfTemplatesID);
            stbMain.Append(" AND DEL_FLAG='N' AND  WFT_CURRENT_STEP_ID NOT  IN  (SELECT Current_STEP_ID  FROM WF_APP_HANDLE ");
            stbMain.AppendFormat(" WHERE  WFA_ID='{0}' AND DEL_FLAG='N'))", this.WfAppID);

            DataTable dt = CommonFuns.getDataTableBySql(" COMBID,COMBTEXT", "", stbMain.ToString());

            if (dt == null || dt.Rows.Count == 0)
            {
                //说明每个节点都设定了签批人员
            }
            else
            {
                StringBuilder stb = new StringBuilder("以下步骤:");
                foreach (DataRow dr in dt.Rows)
                {
                    stb.Append("【" + dr["COMBTEXT"].ToString() + "】");
                }
                stb.Append(",没有设定签批人员,请设定完毕后再进行工作流的启用动作!");
                MessageBox.Show(stb.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            string contentMsg;
            string nowDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string loginID = CommonFuns.NewInstance.LoginInfo.LoginID;
            IWFTemplatesStepService _wfService = ServiceContainer.GetService<WFTemplatesStepService>();
            WF_APP app = WorkFlow.NewInstance.GetWFappByWFID(this.WfAppID);
            FlowStepHandle flowstep = new FlowStepHandle();
            if (flowstep.ShowDialog() == DialogResult.OK)
            {
                contentMsg = flowstep.ContentMsg;
                if (app == null)
                {
                    MessageBox.Show("获取流程实例异常", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }
                else
                {
                    if (app.STATUS == DataType.WFDetailSTATUS.Activated.ToString())
                    {
                        MessageBox.Show("当前工作流已经启用,无需再一次启用!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        return;
                    }
                    else
                    {
                        app.LASTUPDATEUSER = loginID;
                        app.LASTUPDATEDATE = nowDate;
                        app.START_DATE = nowDate;
                        app.STATUS = DataType.WFDetailSTATUS.Activated.ToString();
                        try
                        {
                            app.Update();

                            this.txtStatus.Text = "已激活";

                            ///新增拟制节点完成信息
                            WF_DETAIL detail = new HYPDM.Entities.WF_DETAIL();
                            WF_TEMPLATES_STEP step = WorkFlow.NewInstance.GetWFStartStepByWFID(app.WFT_ID);
                            detail.Current_STEP_ID = step.WFT_CURRENT_STEP_ID;
                            // detail.CURRENT_STEP_NAME = _wfService.GetWFStep(WorkFlow.NewInstance.GetWFStepInfoByStepID(detail.CURRENT_STEP_ID).WFT_CURRENT_STEP_ID).COMBTEXT;

                            detail.MSG = contentMsg;
                            detail.DEL_FLAG = "N";
                            detail.IS_Through = "Y";
                            detail.COMPLEMENTDATE = nowDate;
                            detail.RECIVEDATE = nowDate;
                            detail.WFD_ID = Guid.NewGuid().ToString();
                            detail.WFA_ID = app.WFA_ID;
                            detail.WFT_STEP_ID = step.WFT_STEP_ID;
                            try
                            {
                                detail.Save();

                                ///新增WF_DETAIL记录,指向下一工作流信息
                                // wfah.Current_STEP_ID = WorkFlow.NewInstance.GetWFStepInfoByStepID(wftStepID).WFT_CURRENT_STEP_ID;
                                WF_DETAIL detailNew = new HYPDM.Entities.WF_DETAIL();
                                detailNew.Current_STEP_ID = WorkFlow.NewInstance.GetWFStartStepByWFID(app.WFT_ID).WFT_NEXT_STEP_ID;
                                //_wfService.GetWFStep(detailNew.Current_STEP_ID).COMBTEXT;
                                // WorkFlow.NewInstance.GetWFStepInfoByStepID(detail.Current_STEP_ID).WFT_NEXT_STEP_ID;
                                // detailNew.CURRENT_STEP_NAME = _wfService.GetWFStep(detailNew.CURRENT_STEP_ID).COMBTEXT;
                                detailNew.MSG = "";
                                //  detailNew.Current_STEP_ID = WorkFlow.NewInstance.GetWFStepInfoByStepID(wftStepID).WFT_CURRENT_STEP_ID;
                                detailNew.IS_Through = "";
                                detailNew.DEL_FLAG = "N";
                                detailNew.COMPLEMENTDATE = "";
                                detailNew.RECIVEDATE = detail.COMPLEMENTDATE;
                                detailNew.WFD_ID = Guid.NewGuid().ToString();
                                detailNew.WFA_ID = detail.WFA_ID;
                                detailNew.WFT_STEP_ID = WorkFlow.NewInstance.GetWftStepIDByStepIDAndAppID(detailNew.WFA_ID, detailNew.Current_STEP_ID);
                                detailNew.Save();

                                ///更新表WF_APP_HANDLE
                                WF_APP_HANDLE item = WorkFlow.NewInstance.GetWfAppHandleItem(detail.WFA_ID, detail.Current_STEP_ID, loginID);
                                item.DEL_FLAG = "N";
                                item.LASTUPDATEDATE = nowDate;
                                item.LASTUPDATEUSER = loginID;
                                item.IS_THROUGH = "Y";
                                item.MSG = contentMsg;
                                item.Update();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("信息存储异常,错误信息如下:" + "\n" + ex.Message.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                                return;
                            }

                            MessageBox.Show("当前工作流启用成功!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                            this.tspStart.Enabled = false;
                            this.btnModify.Enabled = false;
                            this.txtSubject.ReadOnly = true;
                            this.btnSubmit.Enabled = false;
                            this.gpFlowDetail.Enabled = false;
                            this.tspDelete.Enabled = false;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("当前工作流启用失败,错误信息如下:" + "\n" + ex.Message.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void tspStart_Click(object sender, EventArgs e)
        {
            ///判定每个节点是否选择了签批用户
            ///步骤:1.找到该工作流实例对应工作模板中的所有节点,在handle表中判定是否有对应签批用户信息,有的话进行下一步check,否则提示直接返回

            StringBuilder stbMain = new StringBuilder();

            stbMain.Append(" ComboBoxValue  WHERE COMBVALUE IN( ");
            stbMain.Append(" SELECT WFT_CURRENT_STEP_ID  FROM WF_TEMPLATES_STEP ");
            stbMain.AppendFormat(" WHERE  WFT_ID='{0}' ", this.WfTemplatesID);
            stbMain.Append(" AND DEL_FLAG='N' AND  WFT_CURRENT_STEP_ID NOT  IN  (SELECT Current_STEP_ID  FROM WF_APP_HANDLE ");
            stbMain.AppendFormat(" WHERE  WFA_ID='{0}' AND DEL_FLAG='N'))", this.WfAppID);

            DataTable dt = CommonFuns.getDataTableBySql(" COMBID,COMBTEXT", "", stbMain.ToString());

            if (dt == null || dt.Rows.Count == 0)
            {
                //说明每个节点都设定了签批人员
            }
            else
            {
                StringBuilder stb = new StringBuilder("以下步骤:");
                foreach (DataRow dr in dt.Rows)
                {
                    stb.Append("【" + dr["COMBTEXT"].ToString() + "】");
                }
                stb.Append(",没有设定签批人员,请设定完毕后再进行工作流的启用动作!");
                MessageBox.Show(stb.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            string contentMsg;
            string nowDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string loginID = CommonFuns.NewInstance.LoginInfo.LoginID;
            IWFTemplatesStepService _wfService = ServiceContainer.GetService <WFTemplatesStepService>();
            WF_APP         app      = WorkFlow.NewInstance.GetWFappByWFID(this.WfAppID);
            FlowStepHandle flowstep = new FlowStepHandle();

            if (flowstep.ShowDialog() == DialogResult.OK)
            {
                contentMsg = flowstep.ContentMsg;
                if (app == null)
                {
                    MessageBox.Show("获取流程实例异常", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }
                else
                {
                    if (app.STATUS == DataType.WFDetailSTATUS.Activated.ToString())
                    {
                        MessageBox.Show("当前工作流已经启用,无需再一次启用!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        return;
                    }
                    else
                    {
                        app.LASTUPDATEUSER = loginID;
                        app.LASTUPDATEDATE = nowDate;
                        app.START_DATE     = nowDate;
                        app.STATUS         = DataType.WFDetailSTATUS.Activated.ToString();
                        try
                        {
                            app.Update();

                            this.txtStatus.Text = "已激活";

                            ///新增拟制节点完成信息
                            WF_DETAIL         detail = new HYPDM.Entities.WF_DETAIL();
                            WF_TEMPLATES_STEP step   = WorkFlow.NewInstance.GetWFStartStepByWFID(app.WFT_ID);
                            detail.Current_STEP_ID = step.WFT_CURRENT_STEP_ID;
                            // detail.CURRENT_STEP_NAME = _wfService.GetWFStep(WorkFlow.NewInstance.GetWFStepInfoByStepID(detail.CURRENT_STEP_ID).WFT_CURRENT_STEP_ID).COMBTEXT;

                            detail.MSG            = contentMsg;
                            detail.DEL_FLAG       = "N";
                            detail.IS_Through     = "Y";
                            detail.COMPLEMENTDATE = nowDate;
                            detail.RECIVEDATE     = nowDate;
                            detail.WFD_ID         = Guid.NewGuid().ToString();
                            detail.WFA_ID         = app.WFA_ID;
                            detail.WFT_STEP_ID    = step.WFT_STEP_ID;
                            try
                            {
                                detail.Save();

                                ///新增WF_DETAIL记录,指向下一工作流信息
                                // wfah.Current_STEP_ID = WorkFlow.NewInstance.GetWFStepInfoByStepID(wftStepID).WFT_CURRENT_STEP_ID;
                                WF_DETAIL detailNew = new HYPDM.Entities.WF_DETAIL();
                                detailNew.Current_STEP_ID = WorkFlow.NewInstance.GetWFStartStepByWFID(app.WFT_ID).WFT_NEXT_STEP_ID;
                                //_wfService.GetWFStep(detailNew.Current_STEP_ID).COMBTEXT;
                                // WorkFlow.NewInstance.GetWFStepInfoByStepID(detail.Current_STEP_ID).WFT_NEXT_STEP_ID;
                                // detailNew.CURRENT_STEP_NAME = _wfService.GetWFStep(detailNew.CURRENT_STEP_ID).COMBTEXT;
                                detailNew.MSG = "";
                                //  detailNew.Current_STEP_ID = WorkFlow.NewInstance.GetWFStepInfoByStepID(wftStepID).WFT_CURRENT_STEP_ID;
                                detailNew.IS_Through     = "";
                                detailNew.DEL_FLAG       = "N";
                                detailNew.COMPLEMENTDATE = "";
                                detailNew.RECIVEDATE     = detail.COMPLEMENTDATE;
                                detailNew.WFD_ID         = Guid.NewGuid().ToString();
                                detailNew.WFA_ID         = detail.WFA_ID;
                                detailNew.WFT_STEP_ID    = WorkFlow.NewInstance.GetWftStepIDByStepIDAndAppID(detailNew.WFA_ID, detailNew.Current_STEP_ID);
                                detailNew.Save();


                                ///更新表WF_APP_HANDLE
                                WF_APP_HANDLE item = WorkFlow.NewInstance.GetWfAppHandleItem(detail.WFA_ID, detail.Current_STEP_ID, loginID);
                                item.DEL_FLAG       = "N";
                                item.LASTUPDATEDATE = nowDate;
                                item.LASTUPDATEUSER = loginID;
                                item.IS_THROUGH     = "Y";
                                item.MSG            = contentMsg;
                                item.Update();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("信息存储异常,错误信息如下:" + "\n" + ex.Message.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                                return;
                            }

                            MessageBox.Show("当前工作流启用成功!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                            this.tspStart.Enabled     = false;
                            this.btnModify.Enabled    = false;
                            this.txtSubject.ReadOnly  = true;
                            this.btnSubmit.Enabled    = false;
                            this.gpFlowDetail.Enabled = false;
                            this.tspDelete.Enabled    = false;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("当前工作流启用失败,错误信息如下:" + "\n" + ex.Message.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                            return;
                        }
                    }
                }
            }
        }