Exemplo n.º 1
0
        protected int Update(IApproveEntry rep, ApproveEntryViewModel model, string pkValue, string approveReturn)
        {
            UserInfo   sysUser  = CacheInit.GetUserInfo(HttpContext);
            DataUpdate dbUpdate = new DataUpdate();

            try
            {
                dbUpdate.BeginTransaction();
                rep.DbUpdate = dbUpdate;
                if (model.FormMode != "approve")
                {
                    //再申请的,将状态由再申请初期变为再申请
                    if (model.FormMode == "reapply")
                    {
                        ApproveRepository repApprove = new ApproveRepository();
                        repApprove.DbUpdate = rep.DbUpdate;
                        repApprove.EditData(sysUser, model.ViewTitle, model.ApproveTableName, model.ApprovePkField, model.ApprovePkValue, "A", model.ApproveMind, model.ApproveNode);
                    }
                    if (CheckModelIsValid(model))
                    {
                        rep.Update(model, sysUser, model.FormMode, pkValue, model.ViewTitle);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    //ModelState.Clear();
                    if (ApproveAndUpdate(rep, model, pkValue, approveReturn, sysUser) == 0)
                    {
                        return(0);
                    }
                    int val = DealApprove(rep, model, approveReturn, "");
                    if (val == 0)
                    {
                        return(0);
                    }
                }
                dbUpdate.Commit();
                return(1);
            }
            catch (Exception ex)
            {
                dbUpdate.Rollback();
                model.Message  = ex.Message;
                model.HasError = "true";
                AppLog.WriteLog(sysUser.UserName, LogType.Error, "UpdateError", "[Message]:" + ex.Message + " [StackTrace]:" + ex.StackTrace);
                return(0);
            }
            finally
            {
                dbUpdate.Close();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存审批信息,1:成功执行;2:成功执行并且是审批结束;3:同一节点已被同一角色下的其他人审批,不能再审批
        /// </summary>
        /// <param name="approveReturn"></param>
        /// <param name="tableName"></param>
        /// <param name="pkField"></param>
        /// <param name="pkValue"></param>
        /// <param name="approveMind"></param>
        /// <param name="approveLevel"></param>
        /// <param name="approveNode"></param>
        /// <param name="viewTitle"></param>
        /// <returns>1:成功执行;2:成功执行并且是审批结束;3:同一节点已被同一角色下的其他人审批,不能再审批</returns>
        protected int SaveApprove(IApproveEntry repApproveMaster, string approveReturn, string tableName, string pkField, string pkValue, string approveMind, string approveLevel, string approveNode, string viewTitle)
        {
            ApproveRepository rep = new ApproveRepository();

            rep.DbUpdate = repApproveMaster.DbUpdate;
            UserInfo sysUser = CacheInit.GetUserInfo(HttpContext);

            if (rep.CheckSameNodeOtherHasApprove(sysUser, tableName, pkField, pkValue, approveNode))
            {
                return(3);
            }
            if (DataConvert.ToString(approveReturn) == "true")
            {
                string createUser = rep.GetApplyUser(tableName, pkField, pkValue);
                //修改当前的那条审批记录
                rep.EditData(sysUser, viewTitle, tableName, pkField, pkValue, "R", approveMind, approveNode);

                //插入一条状态为再申请的审批记录
                Dictionary <string, object> objs = new Dictionary <string, object>();
                objs.Add("refId", pkValue);
                objs.Add("tableName", tableName);
                objs.Add("approver", createUser);
                objs.Add("isValid", "Y");
                objs.Add("approveState", "B");
                rep.AddData(objs, sysUser, viewTitle, tableName, pkField, pkValue, "B", true);
            }
            else
            {
                bool isEndNode = false;
                repApproveMaster.InitNextApproveTask(tableName, approveNode, approveLevel, sysUser.UserId, pkField, pkValue, viewTitle, ref isEndNode);
                rep.EditData(sysUser, viewTitle, tableName, pkField, pkValue, "P", approveMind, approveNode, isEndNode);
                if (isEndNode)
                {
                    return(2);
                }
            }
            return(1);
        }