Exemple #1
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 #2
0
    //提交
    protected void Submit_Click(object sender, EventArgs e)
    {
        string           id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

        if (workFlowInstance != null)
        {
            UploadAttachments1.SaveAttachment(id);
            bool isSuccess = WorkflowHelper.BackToPreApprover(sn.Value, "founder\\" + _BPMContext.CurrentUser.LoginId);

            string Opinion = GetApproveOpinion(nodeName.Value);
            if (string.IsNullOrEmpty(Opinion))
            {
                Opinion = "同意";
            }
            string ApproveResult    = "同意";
            string OpinionType      = "";
            string IsSign           = "2";//会签步骤
            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))
                {
                    wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee);

                    //if (jc.UpdateStatus(id, "03"))
                    //{}
                    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 #3
0
    /// <summary>
    /// 反加签(提交步骤)
    /// </summary>
    /// <param name="sn"></param>
    /// <param name="action"></param>
    /// <param name="opinion"></param>
    /// <returns></returns>
    public bool BackToPreApprover(string sn, string action, string opinion, string customActiveName = "")
    {
        if (string.IsNullOrWhiteSpace(opinion))
        {
            opinion = action;
        }
        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.BackToPreApprover(sn, _BPMContext.CurrentUser.ApprovalUser);

        if (isSuccess)
        {
            AddApprovalOption(action, opinion, "2", currentActiveName);
            return(true);
        }
        return(false);
    }
    //提交
    protected void Submit_Click(object sender, EventArgs e)
    {
        string           id = ViewState["FormID"].ToString();
        WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id);

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

            WorkflowHelper.BackToPreApprover(sn.Value, ViewState["loginName"].ToString());

            string Opinion          = GetApproveOpinion(nodeName.Value);
            string ApproveResult    = "同意";
            string OpinionType      = "";
            string IsSign           = "2";//会签步骤
            string DelegateUserName = "";
            string DelegateUserCode = "";

            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))
            {
                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);
                }
            }
        }
    }
Exemple #5
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);
        }
    }