示例#1
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.04.21
        /// 描述:更新权限
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool UpdateRights(Rights model, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var modelObj = edb.Rights.SingleOrDefault(p => p.Id == model.Id);
                    if (null == modelObj)
                        return false;

                    modelObj.RightsType = model.RightsType;
                    modelObj.CName = model.CName;
                    modelObj.EName = model.EName;
                    modelObj.SCode = model.SCode;
                    modelObj.Areas = model.Areas;
                    modelObj.OrderNum = model.OrderNum;
                    modelObj.Controllers = model.Controllers;
                    modelObj.Views = model.Views;
                    modelObj.Parameters = model.Parameters;
                    modelObj.ParentId = model.ParentId;
                    modelObj.PlatformType = model.PlatformType;
                    modelObj.IsShortcut = model.IsShortcut;
                    modelObj.IsModule = model.IsModule;
                    modelObj.UpdateBy = model.UpdateBy;
                    modelObj.UpdateTime = model.UpdateTime;
                    edb.Entry(modelObj).State = EntityState.Modified;
                    //删除快捷入口
                    if (!modelObj.IsShortcut)
                    {
                        var modelUserShortcut = edb.UserShortcut.Where(p => p.RightsId == modelObj.Id);
                        foreach (var item in modelUserShortcut)
                        {
                            edb.Entry(item).State = EntityState.Deleted;
                        }
                    }
                    //删除页面模块
                    if (!modelObj.IsModule)
                    {
                        var modelUserModule = edb.UserModule.Where(p => p.RightsId == modelObj.Id);
                        foreach (var item in modelUserModule)
                        {
                            edb.Entry(item).State = EntityState.Deleted;
                        }
                    }

                    var result = edb.SaveChanges() > 0;

                    return result;
                }
                catch (Exception e)
                {
                    Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                    {
                        ExceptionType = CommonHelper.To<int>(ExceptionType.Message),
                        Message = string.Format("UserBLL-UpdateRights:{0};{1};{2}", e.Message, e.InnerException, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });
                    return false;
                }
            }
        }
示例#2
0
        public ActionResult RightsCreate(FormCollection fc)
        {
            var rightsType = fc["RightsCreate_RightsType"];
            var cName = fc["RightsCreate_CName"];
            var eName = fc["RightsCreate_EName"];
            var sCode = fc["RightsCreate_SCode"];
            var areas = fc["RightsCreate_Area"];
            var controller = fc["RightsCreate_Controller"];
            var view = fc["RightsCreate_View"];
            var parameter = fc["RightsCreate_Parameter"];
            var parent = fc["RightsCreate_Parent"];
            var platform = fc["RightsCreate_Platform"];
            var isShortcut = Utility.CommonHelper.To<bool>(fc["IsShortcut"].Split(',')[0]);
            var isModule = Utility.CommonHelper.To<bool>(fc["IsModule"].Split(',')[0]);

            var model = new Rights()
            {
                RightsType = Utility.CommonHelper.To<int>(rightsType),
                CName = cName,
                EName = eName,
                SCode = sCode,
                Areas = areas,
                Controllers = controller,
                Views = view,
                Parameters = parameter,
                ParentId = Utility.CommonHelper.To<int?>(parent),
                PlatformType = Utility.CommonHelper.To<int>(platform),
                IsShortcut = isShortcut,
                IsModule = isModule,
                OrderNum = 1,
                Status = Utility.CommonHelper.To<int>(StatusType.Active),
                CreateBy = WebCommon.LoginUserManager.CurrLoginUser.UserId,
                CreateTime = DateTime.Now
            };

            var result = UserBLL.CreateRights(model);
            var search = Session["SearchRightsModel"] as SearchRightsModel ?? new SearchRightsModel();
            return RightsList(search);
        }
示例#3
0
 /// <summary>
 /// 作者:Vincen
 /// 时间:2014.04.21
 /// 描述:创建权限
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool CreateRights(Rights model)
 {
     using (var edb = new EmeEntities())
     {
         edb.Entry(model).State = EntityState.Added;
         return edb.SaveChanges() > 0;
     }
 }