Ejemplo n.º 1
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        if (!BeforeSubmit())
        {
            return;
        }

        int    wfInstanceId = 0; //process instance id
        string id           = ViewState["FormID"].ToString();

        InstructionInfo dataInfo = SaveFormData();

        Countersign1.SaveData(true);//会签数据保存

        if (dataInfo != null)
        {
            UploadAttachments1.SaveAttachment(FormId);
            Countersign1.SaveAndSubmit();//会签数据保存

            #region 工作流参数
            NameValueCollection dataFields = SetWFParams();
            if (dataFields == null)
            {
                return;
            }
            #endregion
            WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId;
            WorkflowHelper.StartProcess(@"K2Workflow\ERP_Instruction", FormId, dataFields, ref wfInstanceId);
            if (wfInstanceId > 0)
            {
                if (SaveWorkFlowInstance("1", DateTime.Now, wfInstanceId.ToString()))
                {
                    SaveWorkItem();
                    if (!AfterWorkflowStart(wfInstanceId))
                    {
                        return;
                    }
                    DisplayMessage.ExecuteJs("alert('提交成功');");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
                    return;
                }
            }
        }

        Alert("提交失败");

        //WorkflowHelper.ApproveProcess
        //insert data to business object
    }
Ejemplo n.º 2
0
    //批准
    protected void Agree_Click(object sender, EventArgs e)
    {
        string           id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);
            Countersign1.SaveAndSubmit();
            //
            string action    = "同意";
            bool   isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action);
            string Opinion   = "";
            if (GetApproveOpinion(nodeName.Value) == null || GetApproveOpinion(nodeName.Value) == "")
            {
                Opinion = "同意";
            }
            else
            {
                Opinion = GetApproveOpinion(nodeName.Value);
            }
            string ApproveResult    = "同意";
            string OpinionType      = "";
            string IsSign           = "0";
            string DelegateUserName = "";
            string DelegateUserCode = "";

            if (isSuccess && !(bool)ViewState["IsSubmit"])
            {
                var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record()
                {
                    ApprovalID        = Guid.NewGuid().ToString(),
                    WFTaskID          = int.Parse(taskID.Value),
                    FormID            = id,
                    InstanceID        = workFlowInstance.InstanceId,
                    Opinion           = Opinion,
                    ApproveAtTime     = DateTime.Now,
                    ApproveByUserCode = CurrentEmployee.EmployeeCode,
                    ApproveByUserName = CurrentEmployee.EmployeeName,
                    ApproveResult     = ApproveResult,
                    OpinionType       = OpinionType,
                    CurrentActiveName = nodeName.Value,
                    ISSign            = IsSign,
                    CurrentActiveID   = nodeID.Value,
                    DelegateUserName  = DelegateUserName,
                    DelegateUserCode  = DelegateUserCode,
                    CreateAtTime      = DateTime.Now,
                    CreateByUserCode  = CurrentEmployee.EmployeeCode,
                    CreateByUserName  = CurrentEmployee.EmployeeName,
                    UpdateAtTime      = DateTime.Now,
                    UpdateByUserCode  = CurrentEmployee.EmployeeCode,
                    UpdateByUserName  = CurrentEmployee.EmployeeName,
                    FinishedTime      = DateTime.Now
                };
                ViewState["IsSubmit"] = true;
                if (bfApproval.AddApprovalRecord(appRecord))
                {
                    wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                    if (wf_Instruction.UpdateStatus(id, "03", workFlowInstance.WfInstanceId))
                    {
                        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.close();", true);
                    }
                }
            }

            Countersign1.SaveAndSubmit();
        }
    }
Ejemplo n.º 3
0
    //批准
    protected void Save_Click(object sender, EventArgs e)
    {
        string           id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);
            Countersign1.SaveAndSubmit();
            //
            string action    = "同意";
            bool   isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action);

            string Opinion          = GetApproveOpinion(nodeName.Value);
            string ApproveResult    = "同意";
            string OpinionType      = "";
            string IsSign           = "0";
            string DelegateUserName = "";
            string DelegateUserCode = "";

            if (isSuccess)
            {
                var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record()
                {
                    ApprovalID        = Guid.NewGuid().ToString(),
                    WFTaskID          = int.Parse(taskID.Value),
                    FormID            = id,
                    InstanceID        = workFlowInstance.InstanceId,
                    Opinion           = Opinion,
                    ApproveAtTime     = DateTime.Now,
                    ApproveByUserCode = CurrentEmployee.EmployeeCode,
                    ApproveByUserName = CurrentEmployee.EmployeeName,
                    ApproveResult     = ApproveResult,
                    OpinionType       = OpinionType,
                    CurrentActiveName = nodeName.Value,
                    ISSign            = IsSign,
                    CurrentActiveID   = nodeID.Value,
                    DelegateUserName  = DelegateUserName,
                    DelegateUserCode  = DelegateUserCode,
                    CreateAtTime      = DateTime.Now,
                    CreateByUserCode  = CurrentEmployee.EmployeeCode,
                    CreateByUserName  = CurrentEmployee.EmployeeName,
                    UpdateAtTime      = DateTime.Now,
                    UpdateByUserCode  = CurrentEmployee.EmployeeCode,
                    UpdateByUserName  = CurrentEmployee.EmployeeName,
                    FinishedTime      = DateTime.Now
                };


                if (bfApproval.AddApprovalRecord(appRecord))
                {
                    if (WorkflowHelper.GetProcessInstance(int.Parse(workFlowInstance.WfInstanceId)).Status1 == ProcessInstance.Status.Completed)
                    {
                        wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "2", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), DateTime.Now, CurrentEmployee);

                        if (wf_Instruction.UpdateStatus(id, "04", workFlowInstance.WfInstanceId))
                        {
                            WebCommon.Show(this, Resources.Message.ApplicationReviewSucess);
                            Response.Redirect("~/Workflow/ToDoWorkList.aspx", false);
                        }
                    }
                    else
                    {
                        wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                        if (wf_Instruction.UpdateStatus(id, "03", workFlowInstance.WfInstanceId))
                        {
                            WebCommon.Show(this, Resources.Message.ApplicationReviewSucess);
                            Response.Redirect("~/Workflow/ToDoWorkList.aspx", false);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        #region 工作流参数
        //get users by role
        BFEmployee         employee    = new BFEmployee();
        EmployeeAdditional employeeadd = employee.GetEmployeeAdditionalByLoginName("xupc");

        Employee em = employee.GetEmployeeByEmployeeCode(employeeadd.EmployeeCode);//get user info

        //get activity destination users
        BFPmsUserRoleDepartment bfurd = new BFPmsUserRoleDepartment();
        DataTable dtDept  = bfurd.GetSelectRoleUser(em.DepartCode, "部门负责人");
        DataTable dtCheck = bfurd.GetSelectRoleUser(em.CompanyCode, "流程审核人");
        //BFCountersignRoleDepartment CountersignRole= new BFCountersignRoleDepartment();
        //DataTable dtContri = CountersignRole.GetSelectCountersignDepartment(em.CompanyCode);
        DataTable dtlead = bfurd.GetSelectRoleUser(em.DepartCode, "主管总裁");
        DataTable dtCEO  = bfurd.GetSelectRoleUser(em.CompanyCode, "CEO");

        //add datafields
        NameValueCollection dataFields = new NameValueCollection();
        //部门负责人
        if (chkDeptManager.Checked)
        {
            dataFields.Add("DeptManager", "K2:Founder\\" + dtDept.Rows[0]["LoginName"].ToString());
        }
        else
        {
            dataFields.Add("DeptManager", "noapprovers");
        }
        //流程审核人
        dataFields.Add("WFM", "K2:Founder\\" + dtCheck.Rows[0]["LoginName"].ToString());
        //会签
        //dataFields.Add("CounterSignUsers", "K2:Founder\\" + dtContri.Rows[0]["LoginName"].ToString());
        //部门主管领导
        dataFields.Add("leaders", "K2:Founder\\" + dtlead.Rows[0]["LoginName"].ToString());
        //CEO
        dataFields.Add("CEO", "K2:Founder\\" + dtCEO.Rows[0]["LoginName"].ToString());
        //触发新流程
        if (cbIsReport.Checked)
        {
            dataFields.Add("NewFlow_SP", "wf_usp_CreateNewForm");
        }
        #endregion

        int    wfInstanceId = 0; //process instance id
        string id           = ViewState["FormID"].ToString();

        Countersign1.SaveData();//会签数据保存

        InstructionOfPkurg instructionOfPkurg = SaveInstructionOfPkurg(id, "02");
        if (instructionOfPkurg != null)
        {
            UploadAttachments1.SaveAttachment(id);
            Countersign1.SaveAndSubmit();//会签数据保存

            WorkflowHelper.StartProcess(@"K2Workflow\InstructionOfPKURG", id, dataFields, ref wfInstanceId);
            if (wfInstanceId > 0)
            {
                if (SaveWorkFlowInstance(instructionOfPkurg, "1", DateTime.Now, wfInstanceId.ToString()))
                {
                    if (wf_Instruction.UpdateStatus(id, "02", wfInstanceId.ToString()))
                    {
                        string           Opinion          = "";
                        string           ApproveResult    = "同意";
                        string           OpinionType      = "";
                        string           IsSign           = "0";
                        string           DelegateUserName = "";
                        string           DelegateUserCode = "";
                        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(instructionOfPkurg.FormId);

                        var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record()
                        {
                            ApprovalID = Guid.NewGuid().ToString(),

                            FormID            = id,
                            InstanceID        = workFlowInstance.InstanceId,
                            Opinion           = Opinion,
                            ApproveAtTime     = DateTime.Now,
                            ApproveByUserCode = CurrentEmployee.EmployeeCode,
                            ApproveByUserName = CurrentEmployee.EmployeeName,
                            ApproveResult     = ApproveResult,
                            OpinionType       = OpinionType,
                            CurrentActiveName = "拟稿",
                            ISSign            = IsSign,

                            DelegateUserName = DelegateUserName,
                            DelegateUserCode = DelegateUserCode,
                            CreateAtTime     = DateTime.Now,
                            CreateByUserCode = CurrentEmployee.EmployeeCode,
                            CreateByUserName = CurrentEmployee.EmployeeName,
                            UpdateAtTime     = DateTime.Now,
                            UpdateByUserCode = CurrentEmployee.EmployeeCode,
                            UpdateByUserName = CurrentEmployee.EmployeeName,
                            FinishedTime     = DateTime.Now
                        };
                        BFApprovalRecord bfApproval = new BFApprovalRecord();
                        bfApproval.AddApprovalRecord(appRecord);

                        //WebCommon.Show(this, Resources.Message.SubmitSucess);
                        //Response.Redirect("~/Workflow/ToDoWorkList.aspx", false);
                    }
                }
            }
        }
        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功'); window.close();", true);

        //WorkflowHelper.ApproveProcess
        //insert data to business object
    }