Example #1
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        #region 工作流参数
        NameValueCollection dataFields = SetWFParams();
        if (dataFields == null)
        {
            return;
        }
        #endregion
        int    wfInstanceId = 0; //process instance id
        string id           = ViewState["FormID"].ToString();

        BP_LeaseContractInfo obj = SaveData(id, "02");
        if (obj != null)
        {
            //开启流程
            WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId;
            WorkflowHelper.StartProcess(@"K2Workflow\BP_LeaseContract", id, dataFields, ref wfInstanceId);
            if (wfInstanceId > 0)
            {
                if (SaveWorkFlowInstance(obj, "1", DateTime.Now, wfInstanceId.ToString()))
                {
                    if (lc.UpdateStatus(id, "02"))
                    {
                        string           Opinion          = "";
                        string           ApproveResult    = "同意";
                        string           OpinionType      = "";
                        string           IsSign           = "0";
                        string           DelegateUserName = "";
                        string           DelegateUserCode = "";
                        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID);
                        //通知系统
                        string instanceID = workFlowInstance.InstanceId;
                        string url        = "http://" + Request.Url.Authority + "/Workflow/ViewPage/V_BP_LeaseContract.aspx?ID=" + instanceID;

                        try
                        {
                            ContractClass.SubmitWorkFlow(url, Convert.ToInt16(tbBizType.Text.ToString()), Convert.ToInt16(tbBizID.Text.ToString()));
                        }
                        catch
                        {
                        }

                        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);
                    }
                }
            }
        }
        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功');", true);
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
    }