Exemple #1
0
    //拒绝
    protected void Reject_Click(object sender, EventArgs e)
    {
        string           id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);
            string action = "不同意";
            ChangeResultToUnAgree();
            bool   isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId);
            string Opinion   = GetApproveOpinion(nodeName.Value);
            if (string.IsNullOrEmpty(Opinion))
            {
                Opinion = "不同意";
            }
            string ApproveResult    = "不同意";
            string OpinionType      = "";
            string IsSign           = "0";
            string DelegateUserName = "";
            string DelegateUserCode = "";
            if (isSuccess && !(bool)ViewState["IsSubmit"])
            {
                NameValueCollection dataFields = new NameValueCollection();
                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
                };
                bfApproval.AddApprovalRecord(appRecord);
                ViewState["IsSubmit"] = true;
                wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                //if (jc.UpdateStatus(id, "01"))
                //{ }
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
            }
        }
    }
    //拒绝
    protected void Reject_Click(object sender, EventArgs e)
    {
        string id = ViewState["FormID"].ToString();

        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);

            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 && !(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;
                bfApproval.AddApprovalRecord(appRecord);
                wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                if (wf_Instruction.UpdateStatus(id, "01", workFlowInstance.WfInstanceId))
                {
                    WebCommon.Show(this, Resources.Message.ApplicationReviewSucess);
                    Response.Redirect("~/Workflow/ToDoWorkList.aspx", false);
                }
            }
        }

        //WorkflowHelper.ApproveProcess
        //insert data to business object
    }
Exemple #3
0
    protected bool CommonApproval(string sn, string option, string action)
    {
        if (string.IsNullOrWhiteSpace(option))
        {
            option = action;
        }
        activityName = GetCurrentActiveName(sn);
        bool isAddSign    = new Workflow_Common().IsAddSign(sn, _BPMContext.CurrentUser.LoginId);
        bool isChangeSign = new Workflow_Common().IsChangeSign(sn, _BPMContext.CurrentUser.LoginId);
        bool isSuccess    = false;

        if (!isAddSign)
        {
            isSuccess = WorkflowHelper.ApproveProcess(sn, action, _BPMContext.CurrentUser.ApprovalUser);
        }
        else if (isChangeSign)
        {
            isSuccess = WorkflowHelper.ApproveProcess(sn, action, _BPMContext.CurrentUser.ApprovalUser);
        }
        else
        {
            isSuccess = WorkflowHelper.BackToPreApprover(sn, _BPMContext.CurrentUser.ApprovalUser);
        }
        if (isSuccess)
        {
            AddApprovalOption(sn, action, option, isAddSign ? "1" : "0", activityName);
            return(true);
        }
        return(false);
    }
Exemple #4
0
        protected void btnReject_Click(object sender, ImageClickEventArgs e)
        {
            string _sn = Request.QueryString["SN"];

            if (!string.IsNullOrEmpty(_sn))
            {
                if (WorkflowHelper.ApproveProcess(_sn, "Reject"))
                {
                    ProcessLog("Reject", "审批", "Reject");
                    MessageBox.ShowAndPop(this.Page, "提交成功!", "/WorkSpace/MyWorklist.aspx");
                }
            }
        }
Exemple #5
0
        protected void btnOriginator_Click(object sender, ImageClickEventArgs e)
        {
            string _sn = Request.QueryString["SN"];

            if (!string.IsNullOrEmpty(_sn))
            {
                if (WorkflowHelper.ApproveProcess(_sn, "Submit"))
                {
                    ProcessLog("SubmitOriginator", "会签", "SubmitOriginator");
                    MessageBox.ShowAndPop(this.Page, "已发送至发起人!", "/WorkSpace/MyWorklist.aspx");
                }
            }
        }
Exemple #6
0
    /// <summary>
    /// 通用审批接口
    /// </summary>
    /// <param name="sn"></param>
    /// <param name="action"></param>
    /// <param name="opinion"></param>
    /// <param name="isSign"></param>
    /// <returns></returns>
    public bool Approval(string sn, string action, string opinion, string isSign = "0", string customActiveName = "")
    {
        WorklistItem listItem = null;

        try
        {
            listItem = WorkflowHelper.GetWorklistItemWithSN(sn, _BPMContext.CurrentUser.ApprovalUser);
        }
        catch
        {
            return(false);
        }
        string currentActiveName = string.IsNullOrWhiteSpace(customActiveName) ? listItem.ActivityInstanceDestination.Name : customActiveName;

        bool isSuccess = WorkflowHelper.ApproveProcess(sn, action, _BPMContext.CurrentUser.ApprovalUser);


        if (isSuccess)
        {
            AddApprovalOption(action, opinion, isSign, currentActiveName);
            return(true);
        }
        return(false);
    }
    /// <summary>
    /// 批准事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Agree_Click(object sender, EventArgs e)
    {
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormID);
        bool             IsSubmit         = true;

        if (nodeName.Value == "流程审核员审核")
        {
            SaveWFParams();
            UpdateWFParams();
            SaveData(ViewState["FormID"].ToString(), "");
        }

        if (IsSubmit)
        {
            if (workFlowInstance != null)
            {
                UploadAttachments1.SaveAttachment(FormID);
                string action    = "同意";
                bool   isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId);
                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            = FormID,
                        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))
                    {
                        ViewState["IsSubmit"] = true;
                        wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true);
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
                    }
                }
            }
        }
    }
Exemple #8
0
    //protected void lbUnAgree_Click(object sender, EventArgs e)
    //{
    //    Execute(1);
    //}
    //protected void lbAgree_Click(object sender, EventArgs e)
    //{
    //    Execute(0);
    //}

    //private void Execute(int option)
    //{
    //    Employee currentUserInfo = _BPMContext.CurrentPWordUser;

    //    FromControl.AppendParams();

    //    WorklistItem item = WorkflowHelper.GetWorklistItemWithSN(_BPMContext.Sn, _BPMContext.CurrentUser.LoginId);
    //    bool isSuccess = WorkflowHelper.ApproveProcess(_BPMContext.Sn, item.Actions[option].Name, _BPMContext.CurrentUser.LoginId);

    //    if (isSuccess)
    //    {
    //        new Pkurg.BPM.Services.ApprovalRecordService().Save(new Pkurg.BPM.Entities.ApprovalRecord()
    //        {
    //            InstanceId = _BPMContext.ProcInst.ProcId,
    //            ApproveByUserCode = currentUserInfo.EmployeeCode,
    //            ApproveByUserName = currentUserInfo.EmployeeName,
    //            ApproveAtTime = DateTime.Now,
    //            FinishedTime = DateTime.Now,
    //             ApprovalID = Guid.NewGuid().ToString(),
    //            CurrentActiveName = item.ActivityInstanceDestination.Name,
    //            Opinion = FromControl.ApprovalText
    //        });

    //        FromControl.Save();

    //        if (WorkflowHelper.GetProcessInstance(int.Parse(_BPMContext.ProcInst.WorkflowId)).Status1 == ProcessInstance.Status.Completed)
    //        {
    //            _BPMContext.ProcInst.Status = "2";
    //            _BPMContext.ProcInst.EndTime = DateTime.Now;
    //        }

    //        if (option == 1)
    //        {
    //            _BPMContext.ProcInst.Status = "4";
    //        }

    //        _BPMContext.Save();
    //    }
    //    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批完成'); window.close();", true);
    //}

    protected void btnDoAction_Click(object sender, EventArgs e)
    {
        string actionName = hf_ActionName.Value;

        if (string.IsNullOrEmpty(actionName))
        {
            return;
        }
        string Opinion       = FromControl.ApprovalText;
        string ApproveResult = actionName;
        string OpinionType   = "";
        string IsSign        = "0";//

        var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record()
        {
            ApprovalID        = Guid.NewGuid().ToString(),
            WFTaskID          = K2_TaskItem.ID,
            FormID            = _BPMContext.ProcInst.FormId,
            InstanceID        = _BPMContext.ProcInst.ProcId,
            Opinion           = Opinion,
            ApproveAtTime     = DateTime.Now,
            ApproveByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode,
            ApproveByUserName = _BPMContext.CurrentPWordUser.EmployeeName,
            ApproveResult     = ApproveResult,
            OpinionType       = OpinionType,
            CurrentActiveName = K2_TaskItem.ActivityInstanceDestination.Name,
            ISSign            = IsSign,
            CurrentActiveID   = K2_TaskItem.ActivityInstanceDestination.ID.ToString(),
            DelegateUserName  = "",
            DelegateUserCode  = "",
            CreateAtTime      = DateTime.Now,
            CreateByUserCode  = _BPMContext.CurrentPWordUser.EmployeeCode,
            CreateByUserName  = _BPMContext.CurrentPWordUser.EmployeeName,
            UpdateAtTime      = DateTime.Now,
            UpdateByUserCode  = _BPMContext.CurrentPWordUser.EmployeeCode,
            UpdateByUserName  = _BPMContext.CurrentPWordUser.EmployeeName
        };

        //审批前设置参数
        FromControl.AppendParams();

        bool isSuccess = false;

        if ("addSignback" == actionName)//加签提交
        {
            isSuccess = WorkflowHelper.BackToPreApprover(_BPMContext.Sn, _BPMContext.CurrentUser.LoginId);
            IsSign    = "2";//
        }
        //转签提交【是否需要】
        else if ("changeSignback" == actionName)
        {
            isSuccess = WorkflowHelper.BackToNextApprover(_BPMContext.Sn, _BPMContext.CurrentUser.LoginId);
            IsSign    = "3";
        }
        else
        {
            //普通审批
            isSuccess = WorkflowHelper.ApproveProcess(_BPMContext.Sn, actionName, _BPMContext.CurrentUser.LoginId);
        }

        if (isSuccess)
        {
            new BFApprovalRecord().AddApprovalRecord(appRecord);

            ///保存数据(主要是流程审核人数据)
            FromControl.SaveFormData();

            new WF_WorkFlowInstance().UpdateStatus(
                _BPMContext.WorkflowId,
                actionName == "不同意" ? "4" : "1",//更新流程状态
                K2_TaskItem.ActivityInstanceDestination.ID.ToString(),
                K2_TaskItem.ActivityInstanceDestination.Name,
                K2_TaskItem.ID,
                null,
                _BPMContext.CurrentPWordUser);

            ///更新流程状态
            //if (actionName == "不同意")
            //{
            //    _BPMContext.ProcInst.Status = "4";
            //}
            _BPMContext.Save();

            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批完成'); window.close();", true);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('操作失败,请重试'); ", true);
        }
    }
    //批准
    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();
        }
    }
    /// <summary>
    /// 拒绝事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Reject_Click(object sender, EventArgs e)
    {
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormID);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(FormID);
            string action = "不同意";
            //得到节点名称
            string currentName = K2_TaskItem.ActivityInstanceDestination.Name;
            if (currentName == "集团招标委员会意见" || currentName == "招标委员会意见")
            {
                action = "同意";
                ChangeResultToNext();//在招标委员会节点上不同意时触发的函数【流程扭转到下一个招标委员会主任节点】
            }
            else
            {
                ChangeResultToUnAgree();//不同意时触发的函数
            }

            bool   isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId);
            string Opinion   = GetApproveOpinion(nodeName.Value);
            if (string.IsNullOrEmpty(Opinion))
            {
                Opinion = "不同意";
            }
            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            = FormID,
                    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
                };

                bfApproval.AddApprovalRecord(appRecord);
                wf_WorkFlowInstance.UpdateNowStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);
            }
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true);
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
        }

        //WorkflowHelper.ApproveProcess
        //insert data to business object
    }
    /// <summary>
    /// 批准事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    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);
            string action      = "同意";
            string currentName = K2_TaskItem.ActivityInstanceDestination.Name;
            if (currentName == "招标委员会主任意见" || currentName == "集团招标委员会主任意见")
            {
                //如果招标委员会意见是同意,则之前的意见可以忽略,只看招标委员会主任的意见
                ChangeResultToAgree();
            }
            bool   isSuccess     = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId);
            string optionDefault = "同意";
            string Opinion       = "";
            if (GetApproveOpinion(nodeName.Value) == null || GetApproveOpinion(nodeName.Value) == "")
            {
                Opinion = optionDefault;
            }
            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);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true);
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
                }
            }
        }
    }
Exemple #12
0
    protected void lbSubmit_Click(object sender, EventArgs e)
    {
        int procId = 0;

        FromControl.AppendParams();

        //未发起
        if (_BPMContext.ProcInst == null || _BPMContext.ProcInst.Status == "0")
        {
            WorkflowHelper.CurrentUser = _BPMContext.CurrentUser.LoginId;
            bool isSuccess = WorkflowHelper.StartProcess(AppInfo.WorkFlowName, DateTime.Now.ToString(), FromControl.FlowParams.WorkflowFieldDatas, ref procId);

            if (!isSuccess)
            {
                return;
            }

            FromControl.SaveFormData();


            if (_BPMContext.ProcInst == null)
            {
                _BPMContext.ProcID   = Guid.NewGuid().ToString();
                _BPMContext.ProcInst = new Pkurg.BPM.Services.WorkFlowInstanceService().Save(new Pkurg.BPM.Entities.WorkFlowInstance()
                {
                    FormTitle        = FromControl.ProcName,
                    InstanceId       = _BPMContext.ProcID,
                    AppId            = AppInfo.AppId,
                    FormId           = FromControl.SerialNumber,
                    CreateByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode,
                    CreateByUserName = _BPMContext.CurrentPWordUser.EmployeeName,
                    CreateDeptCode   = _BPMContext.CurrentPWordUser.DepartCode,
                    CreateDeptName   = _BPMContext.CurrentPWordUser.DepartName,
                    CreateAtTime     = DateTime.Now
                }).ToContextInfo();
            }

            _BPMContext.ProcInst.WorkflowId = procId.ToString();
            _BPMContext.ProcInst.Status     = "1";
            _BPMContext.ProcInst.StartTime  = DateTime.Now;


            new Pkurg.BPM.Services.ApprovalRecordService().Save(new Pkurg.BPM.Entities.ApprovalRecord()
            {
                InstanceId        = _BPMContext.ProcInst.ProcId,
                ApproveByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode,
                ApproveByUserName = _BPMContext.CurrentUser.Name,
                ApproveAtTime     = DateTime.Now,
                FinishedTime      = DateTime.Now,
                ApprovalId        = Guid.NewGuid().ToString()
            });


            _BPMContext.Save();
        }
        else if (_BPMContext.ProcInst.Status == "4")
        {
            WorklistItem item      = WorkflowHelper.GetWorklistItemWithSN(_BPMContext.Sn, _BPMContext.CurrentUser.LoginId);
            bool         isSuccess = WorkflowHelper.ApproveProcess(_BPMContext.Sn, item.Actions[0].Name, _BPMContext.CurrentUser.LoginId);

            if (isSuccess)
            {
                new Pkurg.BPM.Services.ApprovalRecordService().Save(new Pkurg.BPM.Entities.ApprovalRecord()
                {
                    InstanceId        = _BPMContext.ProcInst.ProcId,
                    ApproveByUserCode = _BPMContext.CurrentUser.Id,
                    ApproveByUserName = _BPMContext.CurrentUser.Name,
                    ApproveAtTime     = DateTime.Now,
                    FinishedTime      = DateTime.Now,
                    ApprovalId        = Guid.NewGuid().ToString(),
                    CurrentActiveName = item.ActivityInstanceDestination.Name,
                    Opinion           = "重新发起"
                });

                FromControl.SaveFormData();
                _BPMContext.ProcInst.Status = "1";
                _BPMContext.Save();
            }
        }

        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功'); window.close();", true);
    }
    //批准
    protected void Agree_Click(object sender, EventArgs e)
    {
        string id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            //修改合同编号 2015-08-05 by yanghechun
            //2015-8-5 经办人确认生效
            //更新合同编号
            if (nodeName.Value == "经办人确认生效")
            {
                if (txtContract_No.Text.Trim() == "")
                {
                    Alert(Page, "合同编号不能为空,请输入!");
                    txtContract_No.Focus();
                    return;
                }
                try
                {
                    ContractClass contractClass = new ContractClass();
                    int biz_type = Convert.ToInt16(hf_biz_type.Value);
                    int biz_id = Convert.ToInt16(hf_biz_id.Value);
                    contractClass.UpdateContractNo(biz_type, biz_id, txtContract_No.Text.Trim());
                }
                catch
                {
                }
            }

            string action = "同意";
            bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId);
            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
                };

                if (bfApproval.AddApprovalRecord(appRecord))
                {
                    ViewState["IsSubmit"] = true;
                    wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true);
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true);
                }
            }
        }
    }