Example #1
0
        /// <summary>
        /// 添加请示单
        /// </summary>
        /// <param name="rd"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        //public bool AddGeneralReimburse(Entities.Reimburse rd, TList<ReceiptInfo> list, decimal Balance, string strBankAccount, Employee CurrentEmployee)
        public bool AddInstructionOfPkurg(InstructionOfPkurg rd)
        {
            string methodName = "AddInstructionOfPkurg";

            Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + MessageType.IN + ":" + string.Format("InstructionOfPkurg={0}", rd));

            TransactionManager transaction = DataRepository.Provider.CreateTransaction();

            try
            {
                transaction.BeginTransaction();

                //插入请示单
                bool result = DataRepository.InstructionOfPkurgProvider.Insert(transaction, rd);

                transaction.Commit();
                return(true);
            }
            catch (Exception exp)
            {
                transaction.Rollback();
                Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + MessageType.Exception + ":" + string.Format("Exception={0}", exp));
                throw exp;
            }
        }
    private void InintData()
    {
        string methodName = "InintData";

        try
        {
            WorkFlowInstance   Instance = wf_WorkFlowInstance.GetWorkFlowInstanceById(ViewState["InstanceID"].ToString());
            InstructionOfPkurg item     = wf_Instruction.GetInstructionOfPkurgById(Instance.FormId.ToString());
            if (item != null)
            {
                cblSecurityLevel.SelectedValue = item.SecurityLevel.ToString();
                cblUrgentLevel.SelectedValue   = item.UrgenLevel != null?item.UrgenLevel.ToString() : "0";

                tbData.Text        = ((DateTime)item.Date).ToString("yyyy-MM-dd");
                tbPerson.Text      = item.UserName;
                tbDepartName.Text  = item.DeptName;
                tbPhone.Text       = item.Mobile;
                tbTheme.Text       = item.ReportTitle;
                tbContent.Text     = item.ReportContent;
                tbNumber.Text      = item.ReportCode;
                cbIsReport.Checked = item.IsReport == 1 ? true : false;
            }

            FlowRelated1.ProcId       = ViewState["InstanceID"].ToString();
            Countersign1.ProcId       = ViewState["InstanceID"].ToString();
            UploadAttachments1.ProcId = ViewState["InstanceID"].ToString();

            ApproveOpinionUCDeptleader.InstanceId  = ViewState["InstanceID"].ToString();
            ApproveOpinionUCRealateDept.InstanceId = ViewState["InstanceID"].ToString();
            ApproveOpinionUCLeader.InstanceId      = ViewState["InstanceID"].ToString();
            ApproveOpinionUCCEO.InstanceId         = ViewState["InstanceID"].ToString();
        }
        catch (Exception ex)
        {
            Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex));
            throw ex;
        }
        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT);
    }
Example #3
0
        public bool UpdateStatus(string ID, string strStatus, string wfInstanceId)
        {
            bool   result     = false;
            string methodName = "UpdateStatus";

            Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.IN + ":" + string.Format("ID={0};Status={1};InstanceId={2}", ID, strStatus, wfInstanceId));

            InstructionOfPkurg instructionOfPkurg = GetInstructionOfPkurgById(ID);

            instructionOfPkurg.SumitTime     = DateTime.Now;
            instructionOfPkurg.ApproveStatus = strStatus;
            instructionOfPkurg.WflInstanceId = wfInstanceId;

            result = DataRepository.InstructionOfPkurgProvider.Update(instructionOfPkurg);
            if (!result)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
    protected void Save_Click(object sender, EventArgs e)
    {
        string id = ViewState["FormID"].ToString();

        InstructionOfPkurg instructionOfPkurg = SaveInstructionOfPkurg(id, "00");

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



            if (SaveWorkFlowInstance(instructionOfPkurg, "0", null, ""))
            {
                WebCommon.Show(this, Resources.Message.SaveSucess);
                //Response.Redirect("~/Workflow/EditPage/InstructionList.aspx", false);
            }
        }
        else
        {
            WebCommon.Show(this, Resources.Message.SaveFail);
        }
    }
Example #5
0
    private void InintData()
    {
        string methodName = "InintData";

        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.IN);
        try
        {
            InstructionOfPkurg instructionOfPkurg = wf_Instruction.GetInstructionOfPkurgById(ViewState["FormID"].ToString());
            if (instructionOfPkurg != null)
            {
                cblSecurityLevel.SelectedValue = instructionOfPkurg.SecurityLevel.ToString();
                cblUrgentLevel.SelectedValue   = instructionOfPkurg.UrgenLevel != null?instructionOfPkurg.UrgenLevel.ToString() : "0";

                tbData.Text       = ((DateTime)instructionOfPkurg.Date).ToString("yyyy-MM-dd");
                tbPerson.Text     = instructionOfPkurg.UserName;
                tbDepartName.Text = instructionOfPkurg.DeptName;

                tbPhone.Text   = instructionOfPkurg.Mobile;
                tbTheme.Text   = instructionOfPkurg.ReportTitle;
                tbContent.Text = instructionOfPkurg.ReportContent;
                instructionOfPkurg.ReportTitle = tbTheme.Text;
                tbNumber.Text = instructionOfPkurg.ReportCode;

                WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(instructionOfPkurg.FormId);
                //this.ApproveOpinionUC1.CurrentNode = nodeName.Value;
                //this.ApproveOpinionUC1.InstanceId = workFlowInstance.InstanceId;
                AddSign1.ProcId = workFlowInstance.InstanceId;
                #region 审批意见框
                ApproveOpinionUCDeptleader.InstanceId  = workFlowInstance.InstanceId;
                ApproveOpinionUCRealateDept.InstanceId = workFlowInstance.InstanceId;
                ApproveOpinionUCLeader.InstanceId      = workFlowInstance.InstanceId;
                ApproveOpinionUCCEO.InstanceId         = workFlowInstance.InstanceId;

                if (ApproveOpinionUCDeptleader.CurrentNodeName == nodeName.Value)
                {
                    ApproveOpinionUCDeptleader.CurrentNode = true;
                }

                if (ApproveOpinionUCRealateDept.CurrentNodeName == nodeName.Value)
                {
                    ApproveOpinionUCRealateDept.CurrentNode = true;
                }

                if (ApproveOpinionUCLeader.CurrentNodeName == nodeName.Value)
                {
                    ApproveOpinionUCLeader.CurrentNode = true;
                }

                if (ApproveOpinionUCCEO.CurrentNodeName == nodeName.Value)
                {
                    ApproveOpinionUCCEO.CurrentNode = true;
                }
                #endregion

                //查询已经添加的附件
                //UploadFilesUC1.BindAttachmentListByCode(ViewState["FormID"].ToString());
                UploadAttachments1.ProcId = workFlowInstance.InstanceId;
            }
        }
        catch (Exception ex)
        {
            Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex));
            throw ex;
        }
        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT);
    }
    private void InintData()
    {
        string methodName = "InintData";

        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.IN);
        try
        {
            InstructionOfPkurg instructionOfPkurg = wf_Instruction.GetInstructionOfPkurgById(ViewState["FormID"].ToString());

            cblSecurityLevel.SelectedValue = instructionOfPkurg.SecurityLevel.ToString();
            cblUrgentLevel.SelectedValue   = instructionOfPkurg.UrgenLevel != null?instructionOfPkurg.UrgenLevel.ToString() : "0";

            UpdatedTextBox.Value           = ((DateTime)instructionOfPkurg.Date).ToString("yyyy-MM-dd");
            tbPerson.Text                  = instructionOfPkurg.UserName;
            tbDepartName.Text              = instructionOfPkurg.DeptName;
            tbPhone.Text                   = instructionOfPkurg.Mobile;
            tbTheme.Text                   = instructionOfPkurg.ReportTitle;
            tbContent.Text                 = instructionOfPkurg.ReportContent;
            instructionOfPkurg.ReportTitle = tbTheme.Text;//?
            tbNumber.Text                  = instructionOfPkurg.ReportCode;

            //初始化勾选框
            XmlDocument xmldoc = new XmlDocument();
            if (!string.IsNullOrEmpty(instructionOfPkurg.LeaderSelect))
            {
                xmldoc.LoadXml(instructionOfPkurg.LeaderSelect);
            }
            //经办部门负责人
            if (xmldoc.SelectSingleNode("//DeptManager") != null)
            {
                if (xmldoc.SelectSingleNode("//DeptManager").OuterXml.Length > 21)
                {
                    chkDeptManager.Checked = true;
                }
                else
                {
                    chkDeptManager.Checked = false;
                }
            }
            else
            {
                chkDeptManager.Checked = false;
            }
            cbIsReport.Checked = instructionOfPkurg.IsReport == 1?true:false;

            //查询已经添加的附件
            //UploadFilesUC1.BindAttachmentListByCode(ViewState["FormID"].ToString());
            WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(instructionOfPkurg.FormId);
            FlowRelated1.ProcId       = workFlowInstance.InstanceId;
            Countersign1.ProcId       = workFlowInstance.InstanceId;
            UploadAttachments1.ProcId = workFlowInstance.InstanceId;
            hfInstanceId.Value        = workFlowInstance.InstanceId;
            #region 审批意见框
            ApproveOpinionUCDeptleader.InstanceId  = workFlowInstance.InstanceId;
            ApproveOpinionUCRealateDept.InstanceId = workFlowInstance.InstanceId;
            ApproveOpinionUCLeader.InstanceId      = workFlowInstance.InstanceId;
            ApproveOpinionUCCEO.InstanceId         = workFlowInstance.InstanceId;
            #endregion
        }
        catch (Exception ex)
        {
            Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex));
            throw ex;
        }
        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT);
    }
    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
    }
    private bool SaveWorkFlowInstance(InstructionOfPkurg instructionOfPkurg, string WfStatus, DateTime?SumitTime, string WfInstanceId)
    {
        string methodName = "SaveInstructionOfPkurg";

        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.IN);
        bool             result           = false;
        WorkFlowInstance workFlowInstance = null;

        try
        {
            workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(instructionOfPkurg.FormId);
            bool isEdit = false;
            if (workFlowInstance == null)
            {
                workFlowInstance                  = new WorkFlowInstance();
                workFlowInstance.InstanceId       = Guid.NewGuid().ToString();
                workFlowInstance.CreateDeptCode   = CurrentEmployee.DepartCode;
                workFlowInstance.CreateDeptName   = CurrentEmployee.DepartName;
                workFlowInstance.CreateAtTime     = DateTime.Now;
                workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode;
                workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName;
                workFlowInstance.AppId            = "1002";
            }
            else
            {
                workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode;
                workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName;
                isEdit = true;
            }
            workFlowInstance.FormId    = instructionOfPkurg.FormId;
            workFlowInstance.FormTitle = instructionOfPkurg.ReportTitle;
            workFlowInstance.WfStatus  = WfStatus;
            if (SumitTime != null)
            {
                workFlowInstance.SumitTime = SumitTime;
            }

            if (WfInstanceId != "")
            {
                workFlowInstance.WfInstanceId = WfInstanceId;
            }

            if (!isEdit)
            {
                result = wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance);
            }
            else
            {
                result = wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance);
            }
            FlowRelated1.ProcId = workFlowInstance.InstanceId;
            Countersign1.ProcId = workFlowInstance.InstanceId;
            Countersign1.SaveData();//会签数据保存
        }
        catch (Exception ex)
        {
            Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex));
            throw ex;
        }

        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT);
        return(result);
    }
    private InstructionOfPkurg SaveInstructionOfPkurg(string ID, string wfStatus)
    {
        string methodName = "SaveInstructionOfPkurg";

        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.IN);
        bool result = false;
        InstructionOfPkurg instructionOfPkurg = null;

        try
        {
            instructionOfPkurg = wf_Instruction.GetInstructionOfPkurgById(ID);

            bool isEdit = false;
            if (instructionOfPkurg == null)
            {
                instructionOfPkurg        = new InstructionOfPkurg();
                instructionOfPkurg.FormId = ViewState["FormID"].ToString();

                instructionOfPkurg.ReportCode = ViewState["FormID"].ToString();

                instructionOfPkurg.ApproveStatus = wfStatus;

                instructionOfPkurg.CreateByUserCode = CurrentEmployee.EmployeeCode;
                instructionOfPkurg.CreateAtTime     = DateTime.Now;
                instructionOfPkurg.CreateByUserName = CurrentEmployee.EmployeeName;
            }
            else
            {
                isEdit = true;
                instructionOfPkurg.FormId         = ViewState["FormID"].ToString();
                instructionOfPkurg.OriginalFormId = ViewState["FormID"].ToString();
                instructionOfPkurg.ApproveStatus  = wfStatus;

                instructionOfPkurg.UpdateByUserCode = CurrentEmployee.EmployeeCode;
                instructionOfPkurg.UpdateByUserName = CurrentEmployee.EmployeeName;
            }
            if (cblSecurityLevel.SelectedIndex != -1)
            {
                instructionOfPkurg.SecurityLevel = short.Parse(cblSecurityLevel.SelectedValue);
            }
            if (cblUrgentLevel.SelectedIndex != -1)
            {
                instructionOfPkurg.UrgenLevel = short.Parse(cblUrgentLevel.SelectedValue);
            }
            instructionOfPkurg.Date     = DateTime.Parse(UpdatedTextBox.Value);
            instructionOfPkurg.UserName = tbPerson.Text;
            instructionOfPkurg.DeptName = tbDepartName.Text;

            instructionOfPkurg.Mobile        = tbPhone.Text;
            instructionOfPkurg.ReportTitle   = tbTheme.Text;
            instructionOfPkurg.ReportContent = tbContent.Text;
            instructionOfPkurg.LeaderSelect  = SaveSelectedSignLeader();
            instructionOfPkurg.IsReport      = (byte)(cbIsReport.Checked == true?1:0);
            if (!isEdit)
            {
                result = wf_Instruction.AddInstructionOfPkurg(instructionOfPkurg);
            }
            else
            {
                result = wf_Instruction.UpdateInstructionOfPkurg(instructionOfPkurg);
            }
        }
        catch (Exception ex)
        {
            Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex));
            throw ex;
        }

        Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT);
        return(instructionOfPkurg);
    }