Esempio n. 1
0
 public bool attachDirty(ApproveInfo instance)
 {
     if (string.IsNullOrEmpty(instance.Id))
     {
         instance.Id = Guid.NewGuid().ToString().Replace("-", "");
         string insert = "INSERT INTO T_BIZ_LOAN_APPROVEINFO (" +
             "ID, SN, APPROVER, DECISION, DETAIL )VALUES(:1, :2, :3, :4, :5)";
         OracleParameter[] insertParms = {
             OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, instance.Id),
             OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 50, instance.Sn),
             OracleHelper.NewOracleParameter(":3", OracleType.VarChar, 50, instance.Approver),
             OracleHelper.NewOracleParameter(":4", OracleType.Int16, OracleHelper.OraBit(instance.Decision)),
             OracleHelper.NewOracleParameter(":5", OracleType.VarChar, 50, instance.Detail)
         };
         if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, insert, insertParms) != 1)
             return false;
         else return true;
     }
     else
     {
         string update = "UPDATE T_BIZ_LOAN_APPROVEINFO SET " +
         "SN=:2, APPROVER=:3, DECISION=:4, DETAIL=:5" +
         " WHERE ID=:1";
         OracleParameter[] updateParms = {
             OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 50, instance.Sn),
             OracleHelper.NewOracleParameter(":3", OracleType.VarChar, 50, instance.Approver),
             OracleHelper.NewOracleParameter(":4", OracleType.Int16, OracleHelper.OraBit(instance.Decision)),
             OracleHelper.NewOracleParameter(":5", OracleType.VarChar, 50, instance.Detail),
             OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, instance.Id)
         };
         if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, update, updateParms) != 1)
             return false;
         else return true;
     }
 }
Esempio n. 2
0
 public bool attachDirty(ApproveInfo instance)
 {
     if (string.IsNullOrEmpty(instance.Id))
     {
         instance.Id = Guid.NewGuid().ToString().Replace("-", "");
         string insert = "INSERT INTO T_BIZ_LOAN_APPROVEINFO (" +
                         "ID, SN, APPROVER, DECISION, DETAIL )VALUES(:1, :2, :3, :4, :5)";
         OracleParameter[] insertParms =
         {
             OracleHelper.NewOracleParameter(":1", OracleType.VarChar,                                      50, instance.Id),
             OracleHelper.NewOracleParameter(":2", OracleType.VarChar,                                      50, instance.Sn),
             OracleHelper.NewOracleParameter(":3", OracleType.VarChar,                                      50, instance.Approver),
             OracleHelper.NewOracleParameter(":4", OracleType.Int16,   OracleHelper.OraBit(instance.Decision)),
             OracleHelper.NewOracleParameter(":5", OracleType.VarChar,                                      50, instance.Detail)
         };
         if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, insert, insertParms) != 1)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         string update = "UPDATE T_BIZ_LOAN_APPROVEINFO SET " +
                         "SN=:2, APPROVER=:3, DECISION=:4, DETAIL=:5" +
                         " WHERE ID=:1";
         OracleParameter[] updateParms =
         {
             OracleHelper.NewOracleParameter(":2", OracleType.VarChar,                                      50, instance.Sn),
             OracleHelper.NewOracleParameter(":3", OracleType.VarChar,                                      50, instance.Approver),
             OracleHelper.NewOracleParameter(":4", OracleType.Int16,   OracleHelper.OraBit(instance.Decision)),
             OracleHelper.NewOracleParameter(":5", OracleType.VarChar,                                      50, instance.Detail),
             OracleHelper.NewOracleParameter(":1", OracleType.VarChar,                                      50, instance.Id)
         };
         if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, update, updateParms) != 1)
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
 }
Esempio n. 3
0
        public ApproveInfo findBySnAndUserId(String sn, String userId)
        {
            string           select = "SELECT * FROM T_BIZ_LOAN_APPROVEINFO WHERE SN=:1 and APPROVER=:2";
            OracleConnection conn   = new OracleConnection(connectionString);
            OracleDataReader reader = null;

            try
            {
                OracleParameter[] selectParms =
                {
                    OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, sn),
                    OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 50, userId)
                };
                reader = OracleHelper.ExecuteReader(conn, CommandType.Text, select, selectParms);
                if (reader.Read())
                {
                    ApproveInfo _ApproveInfo = new ApproveInfo()
                    {
                        Id       = Convert.ToString(reader["id"]),
                        Sn       = Convert.ToString(reader["sn"]),
                        Approver = Convert.ToString(reader["approver"]),
                        Decision = Convert.ToInt32(reader["decision"]) == 1 ? true : false,//Convert.ToString(reader["decision"]),
                        Detail   = Convert.ToString(reader["detail"])
                    };
                    return(_ApproveInfo);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
            return(null);
        }
Esempio n. 4
0
        public void Save_Click(object sender, AjaxEventArgs e)
        {
            string           workItemId = HWorkItemId.Value.ToString();
            IWorkflowSession wflsession = RuntimeContextExamples.GetRuntimeContext().getWorkflowSession();
            IWorkItem        wi         = wflsession.findWorkItemById(workItemId);
            String           sn         = (String)wi.TaskInstance.AliveProcessInstance.getProcessInstanceVariable("sn");

            ApproveInfoDAO aid = new ApproveInfoDAO();

            WebDemo.Example.LoanProcess.Persistence.ApproveInfo approveInfo = aid.findBySnAndUserId(sn, this.User.Identity.Name);
            if (approveInfo == null)
            {
                approveInfo          = new WebDemo.Example.LoanProcess.Persistence.ApproveInfo();
                approveInfo.Sn       = sn;
                approveInfo.Approver = this.User.Identity.Name;
            }
            approveInfo.Detail   = comments.Text;
            approveInfo.Decision = my_decision.SelectedItem.Value == "True";


            //3、保存业务数据
            aid.attachDirty(approveInfo);
            //4、完成工单
            try
            {
                if (wi != null)
                {
                    if (wi.ActorId == this.User.Identity.Name)
                    {
                        wi.complete(comments.Text);
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         if (this.Request.QueryString["WorkItemId"] != null)
         {
             string           workItemId = this.Request.QueryString["WorkItemId"];
             IWorkflowSession wflsession = RuntimeContextExamples.GetRuntimeContext().getWorkflowSession();
             IWorkItem        wi         = wflsession.findWorkItemById(workItemId);
             String           sn         = (String)wi.TaskInstance.AliveProcessInstance.getProcessInstanceVariable("sn");
             LoanInfoDAO      lid        = new LoanInfoDAO();
             LoanInfo         ti         = lid.findBySn(sn);
             if (ti != null)
             {
                 HWorkItemId.Value      = workItemId;
                 applicantName.Text     = ti.ApplicantName;
                 applicantId.Text       = ti.ApplicantId;
                 address.Text           = ti.Address;
                 salary.Text            = ti.Salary.ToString();
                 loanValue.Text         = ti.LoanValue.ToString();
                 returnDate.Text        = ti.ReturnDate;
                 loanteller.Text        = ti.Loanteller;
                 salaryIsReal.Text      = ti.SalaryIsReal ? "属实" : "不属实";
                 creditStatus.Text      = ti.CreditStatus ? "合格" : "不合格";
                 riskEvaluator.Text     = ti.RiskEvaluator;
                 riskInfoInputDate.Text = ti.RiskInfoInputDate.ToString("yyyy-MM-dd hh:mm:ss");
             }
             ApproveInfoDAO aid = new ApproveInfoDAO();
             WebDemo.Example.LoanProcess.Persistence.ApproveInfo approveInfo = aid.findBySnAndUserId(sn, this.User.Identity.Name);
             if (approveInfo != null)
             {
                 comments.Text = approveInfo.Detail;
                 my_decision.SelectedItem.Value = approveInfo.Decision.ToString();
             }
         }
     }
 }
Esempio n. 6
0
        public bool taskInstanceCanBeCompleted(IWorkflowSession currentSession, RuntimeContext runtimeContext, IProcessInstance processInstance, ITaskInstance taskInstance)
        {
            IPersistenceService persistenceService = runtimeContext.PersistenceService;
            List <IWorkItem>    workItems          = persistenceService.FindWorkItemsForTaskInstance(taskInstance.Id);

            //从流程变量中获取业务流水号
            String sn = (String)processInstance.getProcessInstanceVariable("sn");

            //已经完成的WorkItem数量
            int completedWorkItemCount = 0;

            //审批同意的决定的数量
            int approvedDecitionCount = 0;

            StringBuilder examinerList = new StringBuilder(); //所有审核人名单
            StringBuilder approverList = new StringBuilder(); //同意者名单
            StringBuilder opponentList = new StringBuilder(); //不同意者名单

            for (int i = 0; i < workItems.Count; i++)
            {
                IWorkItem wi = workItems[i];

                if (wi.State == WorkItemEnum.COMPLETED)
                {
                    completedWorkItemCount++;
                    WebDemo.Example.LoanProcess.Persistence.ApproveInfo approveInfo = approveInfoDAO.findBySnAndUserId(sn, wi.ActorId);
                    if (approveInfo != null)
                    {
                        examinerList.Append(approveInfo.Approver).Append(",");
                        if (approveInfo.Decision)
                        {
                            approvedDecitionCount++;
                            approverList.Append(approveInfo.Approver).Append(",");
                        }
                        else
                        {
                            opponentList.Append(approveInfo.Approver).Append(",");
                        }
                    }
                }
            }


            //------------------判断是否可以结束该汇签任务-----------
            float size    = (float)workItems.Count;
            float theRule = 2 / 3f;
            float currentCompletedPercentage = completedWorkItemCount / size; //已经完成的工单占总工单的比例
            float currentAggreePercentage    = approvedDecitionCount / size;  //已经同意的比例



            //如果完成的工单数量小于2/3,则直接返回false,即不可以结束TaskInstance
            if (currentCompletedPercentage < theRule)
            {
                return(false);
            }
            //如果同意的数量达到2/3则直接结束TaskInstance
            else if (currentAggreePercentage >= theRule)
            {
                //修改流程变量的值
                processInstance.setProcessInstanceVariable("Decision", true);

                //将最终审批决定纪录到业务表中
                LoanInfo loanInfo = loanInfoDAO.findBySn(sn);
                if (loanInfo != null)
                {
                    loanInfo.Decision     = true;
                    loanInfo.ExaminerList = examinerList.ToString();
                    loanInfo.ApproverList = approverList.ToString();
                    loanInfo.OpponentList = opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }

                return(true);
            }
            //当所有的workItem结束时,可以结束TaskInstance
            else if (completedWorkItemCount == workItems.Count)
            {
                LoanInfo loanInfo = loanInfoDAO.findBySn(sn);

                if (currentAggreePercentage < theRule)
                {
                    //修改流程变量的值
                    processInstance.setProcessInstanceVariable("Decision", false);

                    //将最终审批决定记录到业务表中
                    if (loanInfo != null)
                    {
                        loanInfo.Decision = false;
                    }
                    loanInfo.ExaminerList = examinerList.ToString();
                    loanInfo.ApproverList = approverList.ToString();
                    loanInfo.OpponentList = opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }
                else
                {
                    //修改流程变量的值
                    processInstance.setProcessInstanceVariable("Decision", true);

                    //将最终审批决定记录到业务表中
                    if (loanInfo != null)
                    {
                        loanInfo.Decision = true;
                    }
                    loanInfo.ExaminerList = examinerList.ToString();
                    loanInfo.ApproverList = approverList.ToString();
                    loanInfo.OpponentList = opponentList.ToString();
                    loanInfoDAO.attachDirty(loanInfo);
                }

                return(true);
            }
            return(false);
        }
Esempio n. 7
0
 public ApproveInfo findBySnAndUserId(String sn, String userId)
 {
     string select = "SELECT * FROM T_BIZ_LOAN_APPROVEINFO WHERE SN=:1 and APPROVER=:2";
     OracleConnection conn = new OracleConnection(connectionString);
     OracleDataReader reader = null;
     try
     {
         OracleParameter[] selectParms = {
             OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, sn),
             OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 50, userId)
         };
         reader = OracleHelper.ExecuteReader(conn, CommandType.Text, select, selectParms);
         if (reader.Read())
         {
             ApproveInfo _ApproveInfo = new ApproveInfo()
             {
                 Id = Convert.ToString(reader["id"]),
                 Sn = Convert.ToString(reader["sn"]),
                 Approver = Convert.ToString(reader["approver"]),
                 Decision = Convert.ToInt32(reader["decision"]) == 1 ? true : false,//Convert.ToString(reader["decision"]),
                 Detail = Convert.ToString(reader["detail"])
             };
             return _ApproveInfo;
         }
     }
     catch
     {
         throw;
     }
     finally
     {
         if (reader != null) reader.Close();
         if (conn.State != ConnectionState.Closed)
         {
             conn.Close();
             conn.Dispose();
         }
     }
     return null;
 }