Esempio n. 1
0
        private void tspDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("主题为【" + this.txtSubject.Text + "】" + "\n" + "的工作流实例即将被删除!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
            {
                WF_APP app = WorkFlow.NewInstance.GetWFappByWFID(this.wfAppID);
                app.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                app.LASTUPDATEUSER = CommonFuns.NewInstance.LoginInfo.LoginID;
                app.DEL_FLAG       = "Y";
                try
                {
                    app.Update();
                    this.txtSubject.ReadOnly = false;
                    this.txtSubject.Text     = "";
                    this.btnSubmit.Enabled   = true;
                    this.btnModify.Enabled   = true;
                    this.txtSubject.Focus();
                    this.txtSubject.Focus();
                    this.gpFlowDetail.Controls.Clear();
                    this.tspDelete.Enabled = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("删除失败:" + "\n" + ex.Message.ToString(), "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    return;
                }
            }


            // this.WfAppID
        }
Esempio n. 2
0
        private void DataStore()
        {
            string nowDate = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            //string loginID = CommonFuns.NewInstance.LoginInfo.LoginID;
            //1.detail中存放两笔资料,一笔当前状态的更新   2  下一节点的记录新增 ,如果当前没有完成整个节点的审批,那么不需要进行此项工作
            //2.往handle中更新当前处理人的处理状态及意见

            ///1  更新表WF_APP_HANDLE:往handle中更新当前处理人的处理状态及意见
            WF_APP_HANDLE item = WorkFlow.NewInstance.GetWfAppHandleItem(APP.WFA_ID, wipWFAppDetai.Current_STEP_ID, loginID);

            if (item != null)
            {
                if (item.IS_THROUGH != null && item.IS_THROUGH.Trim() != "")
                {
                    MessageBox.Show("您已经审批过,无需再一次审批!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }
            }
            else
            {
                MessageBox.Show("获取当前用户处理节点信息异常!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }
            item.DEL_FLAG       = "N";
            item.LASTUPDATEDATE = nowDate;
            item.LASTUPDATEUSER = loginID;
            item.MSG            = contentMsg;
            item.COMPLEMENTDATE = nowDate;
            if (isThrough == true)
            {
                item.IS_THROUGH = "Y";
            }
            else
            {
                item.IS_THROUGH = "N";
            }
            item.Update();


            //2 判定当前节点是否还有人员没有审批完成
            Boolean blAllThrough       = true;
            Boolean isUpdateDetail     = true;
            IList <WF_APP_HANDLE> list = WorkFlow.NewInstance.GetWfAppStepHandleList(APP.WFA_ID, wipWFAppDetai.Current_STEP_ID);

            foreach (WF_APP_HANDLE handleItem in list)  //判定该流程节点是否通过
            {
                if (handleItem.IS_THROUGH == "N")
                {
                    blAllThrough = false; //只要有一个人员的签批为未通过,则整个节点就为未通过
                    break;
                }
            }
            foreach (WF_APP_HANDLE handleItem in list) //判定该节点是否还有没有完成的签批用户
            {
                if (handleItem.IS_THROUGH == null || handleItem.IS_THROUGH == "")
                {
                    isUpdateDetail = false;
                    break;
                }
            }
            if (isUpdateDetail) //需要更新detail信息,说明此节点的所有用户已经审批完成,而且全部通过审批
            {
                ///A更新当前节点的处理信息
                WF_DETAIL detail = new HYPDM.Entities.WF_DETAIL();

                detail = WorkFlow.NewInstance.GetDetailByWFAppidAndStepID(wipWFAppDetai.WFA_ID, wipWFAppDetai.Current_STEP_ID);

                if (detail == null)
                {
                    MessageBox.Show("获取当前节点信息异常!", "工作流实例建立向导提示您:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }
                detail.Current_STEP_ID = wipWFAppDetai.Current_STEP_ID;
                detail.MSG             = contentMsg; //可加可不加
                //detail.IS_Through = "Y";
                detail.IS_Through     = blAllThrough == true ? "Y" : "N";
                detail.COMPLEMENTDATE = nowDate;
                detail.WFA_ID         = wipWFAppDetai.WFA_ID;
                detail.Update();

                //判定整个工作流是否已经完成,如果已经完成,更新整个工作流状态为Complete

                WF_APP            wfapp = WorkFlow.NewInstance.GetWFappByWFID(wipWFAppDetai.WFA_ID);
                WF_TEMPLATES_STEP step  = WorkFlow.NewInstance.GetWFEndStepByWFID(wfapp.WFT_ID); //end step
                if (wipWFAppDetai.WFT_STEP_ID == step.WFT_STEP_ID)                               //判定是否最终节点
                {
                    ///B将该工作流的状态设为完成Complete
                    wfapp.LASTUPDATEDATE = nowDate;
                    wfapp.LASTUPDATEUSER = loginID;
                    wfapp.STATUS         = DataType.WFDetailSTATUS.Complete.ToString();
                    wfapp.Update();
                }
                else
                {
                    //如果不是跟节点,且目前节点已经审批完成,需要添加下节点信息,WIP信息

                    // if (isThrough) //如果本用户签批通过,在detail信息表中新增wip信息
                    if (blAllThrough || isThrough)
                    {
                        ///新增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.GetStepInfoByWftIDAndCurrentStepID(APP.WFT_ID, detail.Current_STEP_ID).WFT_NEXT_STEP_ID;
                        detailNew.MSG             = "";
                        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();
                    }
                }
            }

            if (!blAllThrough)  //说明有用户选择没有通过的选项
            {
                ///1.如果没有通过工作流审批,A.将WF_APP中工作流实例信息的状态变为:UNActivate,未激活,返回拟制状态
                ///                     B.将WF_APP_HANDLE表中对应的处理人del_flag设为Y
                ///                     C.将WF_DETAIL表中对应的信息del_falg设为Y
                ///
                ///如果有审批人员在此节点审批不通过,则将此工作流实例设为Return(退回、拟制状态)
                //A.将WF_APP中工作流实例信息的状态变为:Return,未激活,返回拟制状态
                WF_APP wfapp = WorkFlow.NewInstance.GetWFappByWFID(wipWFAppDetai.WFA_ID);
                wfapp.LASTUPDATEDATE = nowDate;
                wfapp.LASTUPDATEUSER = loginID;
                wfapp.STATUS         = DataType.WFDetailSTATUS.Return.ToString();
                wfapp.Update();

                // B.将WF_APP_HANDLE表中对应的处理人del_flag设为Y
                IList <WF_APP_HANDLE> handleUsers = WorkFlow.NewInstance.GetAllHandleList(wipWFAppDetai.WFA_ID);
                foreach (WF_APP_HANDLE handle in handleUsers)
                {
                    handle.LASTUPDATEDATE = nowDate;
                    handle.LASTUPDATEUSER = loginID;
                    handle.DEL_FLAG       = "Y";
                    handle.Update();
                }
                IList <WF_APP_USER> users = WorkFlow.NewInstance.GetAllUserList(wipWFAppDetai.WFA_ID);
                foreach (WF_APP_USER user in users)
                {
                    WF_APP_HANDLE wfah = new HYPDM.Entities.WF_APP_HANDLE();
                    wfah.WFAH_ID         = Guid.NewGuid().ToString();
                    wfah.LASTUPDATEDATE  = "";
                    wfah.LASTUPDATEUSER  = "";
                    wfah.CREATEDATE      = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    wfah.CREATEUSER      = CommonFuns.NewInstance.LoginInfo.LoginID;
                    wfah.DEL_FLAG        = "N";
                    wfah.WFA_ID          = user.WFA_ID;
                    wfah.Current_STEP_ID = WorkFlow.NewInstance.GetWFStepInfoByStepID(user.WFT_STEP_ID).WFT_CURRENT_STEP_ID;
                    wfah.OBJECTTYPE      = user.OBJECTTYPE.ToString();
                    wfah.OBJECTVALUE     = user.OBJECTVALUE.ToString();
                    wfah.WFT_STEP_ID     = user.WFT_STEP_ID;
                    wfah.IS_THROUGH      = "";
                    wfah.Save();
                }
                //C.将WF_DETAIL表中对应的信息del_falg设为Y
                IList <WF_DETAIL> detailList = WorkFlow.NewInstance.GetWfDetailList(wipWFAppDetai.WFA_ID);
                foreach (WF_DETAIL detail in detailList)
                {
                    detail.DEL_FLAG = "Y";
                    detail.Update();
                }
                /////
            }
        }
Esempio n. 3
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;
                        }
                    }
                }
            }
        }