Esempio n. 1
0
        public int UpdateRight(SysRightOperateModel model)
        {
            //转换
            SysRightOperate rightOperate = new SysRightOperate();

            rightOperate.Id      = model.Id;
            rightOperate.RightId = model.RightId;
            rightOperate.KeyCode = model.KeyCode;
            rightOperate.IsValid = model.IsValid;

            using (var db = new SysMgr_DBEntities())
            {
                SysRightOperate right = db.SysRightOperate.Where(a => a.Id == rightOperate.Id).FirstOrDefault();
                if (right != null)
                {
                    right.IsValid = rightOperate.IsValid;
                }
                else
                {
                    db.SysRightOperate.Add(rightOperate);
                }
                if (db.SaveChanges() > 0)
                {
                    //更新角色--模块的有效标志RightFlag
                    var sysRight = (from r in db.SysRight
                                    where r.Id == rightOperate.RightId
                                    select r).FirstOrDefault();
                    db.P_Sys_UpdateSysRightRightFlag(sysRight.ModuleId, sysRight.RoleId);
                    return(1);
                }
            }
            return(0);
        }
Esempio n. 2
0
        public virtual bool Edit(ref ValidationErrors errors, SysRightOperateModel model)
        {
            try
            {
                SysRightOperate entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id      = model.Id;
                entity.RightId = model.RightId;
                entity.KeyCode = model.KeyCode;
                entity.IsValid = model.IsValid;



                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Esempio n. 3
0
        public virtual bool Create(ref ValidationErrors errors, SysRightOperateModel model)
        {
            try
            {
                SysRightOperate entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity         = new SysRightOperate();
                entity.Id      = model.Id;
                entity.RightId = model.RightId;
                entity.KeyCode = model.KeyCode;
                entity.IsValid = model.IsValid;


                if (m_Rep.Create(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Esempio n. 4
0
        public int UpdateRight(SysRightOperateModel model)
        {
            //转换
            SysRightOperate rightOperate = new SysRightOperate();

            rightOperate.Id      = model.Id;
            rightOperate.RightId = model.RightId;
            rightOperate.KeyCode = model.KeyCode;
            rightOperate.IsValid = model.IsValid;
            //判断rightOperate是否存在,如果存在就更新rightOperate,否则就添加一条
            using (DBContainer db = new DBContainer())
            {
                SysRightOperate right = db.SysRightOperate.Where(a => a.Id == rightOperate.Id).FirstOrDefault();
                if (right != null)
                {
                    right.IsValid = rightOperate.IsValid;
                }
                else
                {
                    db.Set <SysRightOperate>().Add(rightOperate);
                }
                if (db.SaveChanges() > 0)
                {
                    //更新角色--模块的有效标志RightFlag
                    var sysRight = (from r in db.SysRight
                                    where r.Id == rightOperate.RightId
                                    select r).First();
                    db.P_Sys_UpdateSysRightRightFlag(sysRight.ModuleId, sysRight.RoleId);
                    return(1);
                }
            }
            return(0);
        }
Esempio n. 5
0
        public int UpdateRight(SysRightOperateModel model)
        {
            //转换
            SysRightOperate rightOperate = new SysRightOperate();

            rightOperate.Id      = model.Id;
            rightOperate.RightId = model.RightId;
            rightOperate.KeyCode = model.KeyCode;
            rightOperate.IsValid = model.IsValid;
            return(m_Rep.UpdateRight(rightOperate));
        }
Esempio n. 6
0
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <SysRightOperateModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

            if (!targetFile.Exists)
            {
                errors.Add("导入的数据文件不存在");
                return(false);
            }

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <SysRightOperateModel>(x => x.RightId, "RightId");
            excelFile.AddMapping <SysRightOperateModel>(x => x.KeyCode, "KeyCode");
            excelFile.AddMapping <SysRightOperateModel>(x => x.IsValid, "IsValid");

            //SheetName
            var excelContent = excelFile.Worksheet <SysRightOperateModel>(0);
            int rowIndex     = 1;

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new SysRightOperateModel();
                entity.Id      = row.Id;
                entity.RightId = row.RightId;
                entity.KeyCode = row.KeyCode;
                entity.IsValid = row.IsValid;

                //=============================================================================
                if (errorMessage.Length > 0)
                {
                    errors.Add(string.Format(
                                   "第 {0} 列发现错误:{1}{2}",
                                   rowIndex,
                                   errorMessage,
                                   "<br/>"));
                }
                list.Add(entity);
                rowIndex += 1;
            }
            if (errors.Count > 0)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
        public bool UpdateRight(ref ValidationErrors errors, SysRightOperateModel model)
        {
            int flag = m_RightRepo.UpdateRight(model);

            if (flag == 1)
            {
                errors.Add(Suggestion.UpdateSucceed);
                return(true);
            }
            else
            {
                errors.Add(Suggestion.UpdateFail);
                return(false);
            }
        }
Esempio n. 8
0
        public bool UpdateRight(SysRightOperateModel model)
        {
            var ret = sysRightBLL.UpdateRight(ref errors, model);

            if (ret)
            {
                string ErrorCol = errors.Error;
                LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",KeyCode" + model.KeyCode + "," + ErrorCol, "成功", "更新", "Right");
                return(ret);
            }
            else
            {
                string ErrorCol = errors.Error;
                LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",KeyCode" + model.KeyCode + "," + ErrorCol, "失败", "更新", "Right");
                return(ret);
            }
        }
Esempio n. 9
0
        public virtual SysRightOperateModel GetById(object id)
        {
            if (IsExists(id))
            {
                SysRightOperate      entity = m_Rep.GetById(id);
                SysRightOperateModel model  = new SysRightOperateModel();
                model.Id      = entity.Id;
                model.RightId = entity.RightId;
                model.KeyCode = entity.KeyCode;
                model.IsValid = entity.IsValid;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 10
0
        public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(SysRightOperateModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                SysRightOperate entity = await m_Rep.GetByIdAsync(model.Id);

                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity         = new SysRightOperate();
                entity.Id      = model.Id;
                entity.RightId = model.RightId;
                entity.KeyCode = model.KeyCode;
                entity.IsValid = model.IsValid;


                if (await m_Rep.CreateAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
Esempio n. 11
0
        public virtual async Task <Tuple <ValidationErrors, bool> > EditAsync(SysRightOperateModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                SysRightOperate entity = await m_Rep.GetByIdAsync(model.Id);

                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity.Id      = model.Id;
                entity.RightId = model.RightId;
                entity.KeyCode = model.KeyCode;
                entity.IsValid = model.IsValid;


                if (await m_Rep.EditAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
Esempio n. 12
0
 public bool UpdateRight(ValidationErrors errors, SysRightOperateModel model)
 {
     try
     {
         if (model != null)
         {
             SysRightOperate entity = new SysRightOperate()
             {
                 Id      = model.Id,
                 RightId = model.RightId,
                 KeyCode = model.KeyCode,
                 IsValid = model.IsValid
             };
             if (Rep.UpdateRight(entity))
             {
                 return(true);
             }
             else
             {
                 errors.add(Suggestion.UpdateFail);
                 return(false);
             }
         }
         else
         {
             errors.add(Suggestion.UpdateFail);
             return(false);
         }
     }
     catch (Exception ex)
     {
         errors.add(ex.Message);
         ExceptionHandler.WriteException(ex);
         return(false);
     }
 }
Esempio n. 13
0
 public int UpdateRight(SysRightOperateModel model)
 {
     return(sysRightRepository.UpdateRight(model));
 }
Esempio n. 14
0
 public int UpdateRight(SysRightOperateModel model)
 {
     return(m_Rep.UpdateRight(model));
 }
Esempio n. 15
0
 public int UpdateRight(SysRightOperateModel model)
 {
     return(sysRightBLL.UpdateRight(model));
 }
Esempio n. 16
0
 public bool UpdateRight(SysRightOperateModel model)
 {
     return(rightBLL.UpdateRight(errors, model));
 }