예제 #1
0
        /// <summary>
        /// 保存角色
        /// </summary>
        /// <param name="roleFormViewModel">角色视图模型</param>
        /// <returns>保存结果</returns>
        public ActionResult Save(RoleFormViewModel roleFormViewModel)
        {
            RoleBll bll  = new RoleBll();
            Role    role = new Role();
            string  error;

            if (ModelState.IsValid)
            {
                role.RoleName       = roleFormViewModel.RoleName;
                role.Id             = roleFormViewModel.Id == null?0:int.Parse(roleFormViewModel.Id.ToString());
                role.Code           = roleFormViewModel.Code;
                role.Description    = roleFormViewModel.Description;
                role.LastChangeTime = DateTime.Now;
                role.LastChangeUser = int.Parse(Session["UserId"].ToString());
                try
                {
                    bll.SaveRole(role);
                }
                catch (Exception e)
                {
                    error = "保存出错,请重试";
                    return(Json(error, JsonRequestBehavior.AllowGet));
                }
                return(Json("access", JsonRequestBehavior.AllowGet));
            }
            else
            {
                error = "模型验证未通过";
                return(Json(error, JsonRequestBehavior.AllowGet));
            }
        }
예제 #2
0
 private void tsbAdd_Click(object sender, EventArgs e)
 {
     if (tsbtxtRoleName.Text == "")
     {
         MessageBox.Show("请输入要添加的角色名称!");
     }
     else
     {
         if (RoleBll.GetRole(tsbtxtRoleName.Text))
         {
             try
             {
                 RoleBll.AddRole(tsbtxtRoleName.Text);
                 dataGridView1.DataSource = RoleBll.RoleFillDs().Tables[0];
                 MessageBox.Show("添加成功!");
             }
             catch (Exception ee)
             {
                 MessageBox.Show("添加失败!" + ee);
                 throw;
             }
         }
         else
         {
             MessageBox.Show("角色已存在!");
         }
     }
 }
예제 #3
0
        public ActionResult RoleManage()
        {
            RoleBll Bll       = new RoleBll();
            var     modellist = Bll.GetRoleList();

            return(View(modellist));
        }
예제 #4
0
        public ActionResult UpdateRight(int rightId, string rights)
        {
            RoleBll roleBll = new RoleBll();
            bool    result  = roleBll.UpdateRight(rightId, rights);

            return(Json(result));
        }
예제 #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["roleName"] != null)
     {
         //拿到前台的值
         string roleName   = Request["roleName"];
         string roleRemark = Request["roleRemark"];
         int    roleSortId = Convert.ToInt32(Request["roleSortId"]);
         //插入到数据库里
         RoleModel role = new RoleModel();
         role.Name       = roleName;
         role.Remark     = roleRemark;
         role.SortId     = roleSortId;
         role.UpdateTime = DateTime.Now;
         role.IsDel      = 0;
         RoleBll BLL  = new RoleBll();
         int     rows = -1;
         rows = BLL.Add(role);
         //返回执行结果
         Response.Clear();
         Response.ContentType     = "text/plain";
         Response.ContentEncoding = System.Text.Encoding.UTF8;
         Response.Write(rows);
         Response.End();
     }
 }
예제 #6
0
        /// <summary>修改角色
        /// </summary>
        /// <param name="roleEntity"></param>
        /// <returns></returns>
        public ActionResult UpdateRole(RoleEntity roleEntity)
        {
            RoleBll roleBll = new RoleBll();
            bool    result  = roleBll.UpdateRole(roleEntity);

            return(Json(result));
        }
예제 #7
0
        /// <summary>删除角色
        /// </summary>
        /// <param name="roleId">角色Id</param>
        /// <returns></returns>
        public ActionResult DeleteRole(int roleId)
        {
            RoleBll roleBll = new RoleBll();
            bool    result  = roleBll.DeleteRole(roleId);

            return(Json(result));
        }
예제 #8
0
        /// <summary>
        /// 角色树数据绑定
        /// </summary>
        /// <param name="idList">当前模块所有的角色ID</param>
        /// <returns>角色树数据</returns>
        public JsTreeCheck JsTreeRoleWithCheck(List <int> idList)
        {
            RoleBll     bll   = new RoleBll();
            var         roles = bll.GetAllRole();
            JsTreeCheck jst   = new JsTreeCheck();

            jst.id   = 0;
            jst.text = "全选";

            List <JsTreeCheck> children = new List <JsTreeCheck>();

            foreach (var role in roles)
            {
                State childState = new State();
                if (idList.Contains(role.Id))
                {
                    childState.selected = true;
                }
                JsTreeCheck child = new JsTreeCheck()
                {
                    id    = role.Id,
                    text  = role.RoleName,
                    state = childState
                };
                children.Add(child);
            }
            jst.children = children;
            return(jst);
        }
예제 #9
0
        /// <summary>
        /// 检查重名检查角色名是否可用
        /// </summary>
        /// <param name="roleName">角色名</param>
        /// <param name="id">角色ID</param>
        /// <returns>true:是,false:否</returns>
        public JsonResult CheckRoleName(string roleName, int id)
        {
            RoleBll bll    = new RoleBll();
            var     result = bll.CheckRoleName(roleName, id);

            return(Json(result));
        }
예제 #10
0
 /// <summary>
 /// Function to Update the items
 /// </summary>
 public void EditFunction()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleBll  BllRole  = new RoleBll();
         infoRole.RoleId    = Convert.ToDecimal(dgvRole.CurrentRow.Cells["dgvtxtRoleId"].Value);
         infoRole.Role      = txtRole.Text.Trim();
         infoRole.Narration = txtNarration.Text.Trim();
         infoRole.Extra1    = string.Empty;
         infoRole.Extra2    = string.Empty;
         string strRole = txtRole.Text.Trim();
         if (BllRole.RoleCheckExistence(decRoleId, strRole) == false)
         {
             BllRole.RoleEdit(infoRole);
             Messages.UpdatedMessage();
             ClearFunction();
         }
         else
         {
             Messages.InformationMessage("Role already exists");
             txtRole.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request["method"] != null)
     {
         //查询数据库的数据
         RoleBll   BLL = new RoleBll();
         DataTable dt  = BLL.GetAll();
         DataSet   set = new DataSet();
         set.Tables.Add(dt);
         string json = JsonConvert.SerializeObject(set);
         //向客户端写回数据
         Response.Clear();
         Response.ContentType     = "text/plain";
         Response.ContentEncoding = System.Text.Encoding.UTF8;
         Response.Write(json);
         Response.End();
     }
     if (Request["id"] != null)
     {
         RoleBll BLL  = new RoleBll();
         int     rows = BLL.Del(Convert.ToInt32(Request["id"]));
         Response.Clear();
         Response.ContentType     = "text/plain";
         Response.ContentEncoding = System.Text.Encoding.UTF8;
         Response.Write(rows);
         Response.End();
     }
 }
예제 #12
0
 /// <summary>
 /// Save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         RoleInfo infoRole = new RoleInfo();
         RoleBll  BllRole  = new RoleBll();
         infoRole.Role      = txtRole.Text.Trim();
         infoRole.Narration = txtNarration.Text.Trim();
         infoRole.Extra1    = string.Empty;
         infoRole.Extra2    = string.Empty;
         string strRole = txtRole.Text.Trim();
         if (BllRole.RoleCheckExistence(decRoleId, strRole) == false)
         {
             decRoleId = BllRole.RoleAdd(infoRole);
             Messages.SavedMessage();
             ClearFunction();
         }
         else
         {
             Messages.InformationMessage("Role already exists");
             txtRole.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #13
0
    public void LoadData()
    {
        RoleBll BLL = new RoleBll();

        //role = BLL.GetById(1);
        role = BLL.GetById(Convert.ToInt32(Request["id"]));
    }
예제 #14
0
        public IActionResult Delete(Role model)
        {
            var bll = new RoleBll();
            var rst = bll.Delete(model);

            return(Json(rst));
        }
        /// <summary>
        /// 获取该用户组的角色
        /// </summary>
        /// <param name="id"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <param name="kw"></param>
        /// <returns></returns>
        public ActionResult MyRoles(int id, int page = 1, int size = 10, string kw = "")
        {
            Expression <Func <Role, bool> > where;
            Expression <Func <Role, bool> > where2;

            if (!string.IsNullOrEmpty(kw))
            {
                where  = u => u.UserGroupPermission.All(c => c.UserGroupId != id) && u.RoleName.Contains(kw);
                where2 = u => u.UserGroupPermission.Any(c => c.UserGroupId == id) && u.RoleName.Contains(kw);
            }
            else
            {
                where  = u => u.UserGroupPermission.All(c => c.UserGroupId != id);
                where2 = u => u.UserGroupPermission.Any(c => c.UserGroupId == id);
            }
            List <RoleOutputDto> not  = RoleBll.LoadPageEntities <int, RoleOutputDto>(page, size, out int total1, where, u => u.Id, false).ToList(); //不属于该应用
            List <Role>          list = RoleBll.LoadPageEntities(page, size, out int total2, where2, u => u.Id, false).ToList();                     //属于该应用
            List <RoleOutputDto> my   = new List <RoleOutputDto>();

            foreach (var p in list)
            {
                //判断有没有临时权限
                RoleOutputDto per = p.Mapper <RoleOutputDto>();
                per.HasRole = p.UserGroupPermission.Any(u => u.UserGroupId.Equals(id) && u.RoleId == p.Id && u.HasRole);
                my.Add(per);
            }
            return(PageResult(new { my, not }, size, total1 >= total2 ? total1 : total2));
        }
예제 #16
0
        public IActionResult GetList(Role model)
        {
            var bll = new RoleBll();
            var rst = bll.GetList(model);

            return(Json(rst));
        }
예제 #17
0
        /// <summary>
        ///保存选择的模块
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveChooseModules(string ids, int roleId = 0)
        {
            if (roleId == 0)
            {
                return(Json("请选择一个角色"));
            }
            RoleBll bll = new RoleBll();

            string[]   moduleIds = ids.Split(',');
            List <int> intIds    = new List <int>();

            foreach (var moduleId in moduleIds)
            {
                int intNum;
                if (int.TryParse(moduleId, out intNum))
                {
                    intIds.Add(intNum);
                }
            }
            try
            {
                bll.SaveRoleModules(intIds, roleId, int.Parse(Session["UserId"].ToString()));
            }
            catch (Exception e)
            {
                return(Json("保存出错", JsonRequestBehavior.AllowGet));
            }
            return(Json("access", JsonRequestBehavior.AllowGet));
        }
예제 #18
0
        /// <summary>
        /// 打开添加用户页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AddUser()
        {
            var roleList = new RoleBll().GetList();

            ViewBag.roleList = new SelectList(roleList, "RoleId", "Name");
            return(View());
        }
        public Dictionary <string, object> Login(BaseUser model)
        {
            string         Msg       = "";
            IPScanerHelper objScan   = new IPScanerHelper();
            string         IPAddress = NetHelper.GetIPAddress();

            objScan.IP       = IPAddress;
            objScan.DataPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Resource/IPScaner/QQWry.Dat");
            string   IPAddressName = objScan.IPLocation();
            int      msg           = 0;
            BaseUser base_user     = UserBll.UserLogin(model.Account, model.UserPassword, out msg);

            switch (msg)
            {
            case 0:
                Msg = "账号不存在";
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.fail, "账号不存在、IP所在城市" + IPAddressName);
                break;

            case 1:
                RoleBll RoleBll = new RoleBll();
                Role    role    = RoleBll.GetModelByUserId(base_user.UserId);

                IManageUser mangeuser = new IManageUser();
                mangeuser.UserId        = base_user.UserId;
                mangeuser.Account       = base_user.Account;
                mangeuser.IPAddress     = IPAddress;
                mangeuser.IPAddressName = IPAddressName;
                if (role != null)
                {
                    mangeuser.RoleName = role.RoleName;
                    mangeuser.RoleId   = role.RoleId;
                }
                else
                {
                    mangeuser.RoleName = "";
                    mangeuser.RoleId   = 0;
                }
                ManageProvider.Provider.AddCurrent(mangeuser);
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.Success, "登陆成功、IP所在城市" + IPAddressName);
                break;

            case 2:
                Msg = "账户锁定";
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.fail, "账户锁定、IP所在城市" + IPAddressName);
                break;

            case 3:
                Msg = "密码错误";
                SysLogBll.WriteLog(model.Account, OperationType.Login, LogSatus.fail, "密码错误、IP所在城市" + IPAddressName);
                break;
            }

            return(new Dictionary <string, object>
            {
                { "code", msg },
                { "msg", Msg }
            });
        }
예제 #20
0
        /// <summary>
        /// 获取模块树数据
        /// </summary>
        /// <param name="id">角色ID</param>
        /// <returns>json格式的JStree</returns>
        public ActionResult ModuleTreeList(int id = 0)
        {
            RoleBll bll     = new RoleBll();
            var     modules = bll.GetRoleModule(id);
            var     jsTree  = JsTreeAllModulewhithHead(modules);

            return(Json(jsTree, JsonRequestBehavior.AllowGet));
        }
예제 #21
0
        public ActionResult GetRoles(int pageIndex, int pageSize)
        {
            RoleBll           roleBll      = new RoleBll();
            int               count        = 0;
            List <RoleEntity> roleEntities = roleBll.GetRoles(pageIndex, pageSize, "", out count);

            return(PartialView(roleEntities));
        }
예제 #22
0
        public ActionResult GetUserRoles(string uId, string roldIds)
        {
            RoleBll           roleBll      = new RoleBll();
            List <RoleEntity> roleEntities = roleBll.GetRoles(roldIds);

            ViewData["uId"] = uId;
            return(PartialView(roleEntities));
        }
예제 #23
0
        public ActionResult GetRoles2()
        {
            RoleBll           roleBll      = new RoleBll();
            List <RoleEntity> roleEntities = roleBll.GetRoles();
            var data = roleEntities.Select(m => new { m.Id, m.Name });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
예제 #24
0
        /// <summary>
        /// 获取用户树数据
        /// </summary>
        /// <param name="id">角色ID</param>
        /// <returns>json格式的JStree</returns>
        public ActionResult UserTreeList(int id = 0)
        {
            RoleBll bll    = new RoleBll();
            var     roles  = bll.GetRoleUser(id);
            var     jsTree = JsTreeUserWithCheck(roles);

            return(Json(jsTree, JsonRequestBehavior.AllowGet));
        }
예제 #25
0
        public void Init()
        {
            RoleBll bll = new RoleBll(LJH.Attendance.Model.AppSettings.CurrentSetting.ConnectUri);

            this.DataSource    = bll.GetAllRoles().QueryObjects;
            this.DisplayMember = "Name";
            this.ValueMember   = "ID";
            this.DropDownStyle = ComboBoxStyle.DropDownList;
        }
예제 #26
0
        public void Init()
        {
            RoleBll bll = new RoleBll(Ralid.Park.BusinessModel.Configuration.AppSettings.CurrentSetting.ParkConnect);

            this.DataSource    = bll.GetAllRoles().QueryObjects;
            this.DisplayMember = "Name";
            this.ValueMember   = "RoleID";
            this.DropDownStyle = ComboBoxStyle.DropDownList;
        }
예제 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //绑定repeater 数据源,以及绑定
            //查询角色列表
            RoleBll roleBll = new RoleBll();

            Repeater1.DataSource = roleBll.GetRoleList();
            //绑定数据源
            Repeater1.DataBind();
        }
예제 #28
0
        protected string GetManageHospitalIDs()
        {
            var roleName = ((UserIdentity)this.Context.CurrentUser).RoleName;

            if (string.IsNullOrEmpty(roleName))
            {
                return(null);
            }
            return(RoleBll.GetDataByName(roleName)?.ManageHospital);
        }
예제 #29
0
        public TestBll(bool autoDetectChangesEnabled, bool lazyLoadingEnabled, bool isCreateDb)
        {
            Db = new LocationDb(isCreateDb);
            Db.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled;
            Db.Configuration.LazyLoadingEnabled       = lazyLoadingEnabled; //关闭延迟加载

            Maps                = new MapBll(Db);
            Areas               = new AreaBll(Db);
            Position            = new PositionBll(DbHistory);
            TagPositions        = new TagPositionBll(Db);
            Departments         = new DepartmentBll(Db);
            Users               = new UserBll(Db);
            Tags                = new TagBll(Db);
            Archors             = new ArchorBll(Db);
            KKSCodes            = new KKSCodeBll(Db);
            t_KKSCodes          = new t_KKSCodeBll(Dbtopviewxp);
            t_SetModels         = new t_SetModelBll(Db);
            t_TypeProperties    = new t_Template_TypePropertyBll(Db);
            TransformMs         = new TransformMBll(Db);
            DevInfos            = new DevInfoBll(Db);
            DevPos              = new DevPosBll(Db);
            U3DPositions        = new U3DPositionBll(DbHistory);
            PhysicalTopologys   = new PhysicalTopologyBll(Db);
            NodeKKSs            = new NodeKKSBll(Db);
            Personnels          = new PersonnelBll(Db);
            Posts               = new PostBll(Db);
            JurisDictions       = new JurisDictionBll(Db);
            JurisDictionRecords = new JurisDictionRecordBll(Db);
            Meterials           = new MeterialBll(Db);
            //U3DPositions.ToList();
            ConfigArgs                            = new ConfigArgBll(Db);
            Bounds                                = new BoundBll(Db);
            Points                                = new PointBll(Db);
            OperationTickets                      = new OperationTicketBll(Db);
            OperationItems                        = new OperationItemBll(Db);
            WorkTickets                           = new WorkTicketBll(Db);
            SafetyMeasuress                       = new SafetyMeasuresBll(Db);
            MobileInspections                     = new MobileInspectionBll(Db);
            MobileInspectionItems                 = new MobileInspectionItemBll(Db);
            MobileInspectionContents              = new MobileInspectionContentBll(Db);
            MobileInspectionDevs                  = new MobileInspectionDevBll(Db);
            PersonnelMobileInspections            = new PersonnelMobileInspectionBll(Db);
            PersonnelMobileInspectionItems        = new PersonnelMobileInspectionItemBll(Db);
            PersonnelMobileInspectionHistorys     = new PersonnelMobileInspectionHistoryBll(DbHistory);
            PersonnelMobileInspectionItemHistorys = new PersonnelMobileInspectionItemHistoryBll(DbHistory);
            OperationTicketHistorys               = new OperationTicketHistoryBll(DbHistory);
            OperationItemHistorys                 = new OperationItemHistoryBll(DbHistory);
            WorkTicketHistorys                    = new WorkTicketHistoryBll(DbHistory);
            SafetyMeasuresHistorys                = new SafetyMeasuresHistoryBll(DbHistory);
            Targets                               = new TargetBll(Db);
            Roles = new RoleBll(Db);
            Menus = new MenuBll(Db);

            Z.EntityFramework.Extensions.LicenseManager.AddLicense("34;100-LLHSWWHA", "384799A60700037CBFC0EB5E03A62474");
        }
예제 #30
0
        public RoleModule() : base("Role")
        {
            this.RequiresAuthentication();

            Get["RoleManage"] = _ => ValidPermission("RoleManage") ? View["RoleManage", RoleBll.GetData()] : View["NoPermissions"];
            Post["QueryRole"] = p =>
            {
                string name     = Request.Form["RoleName"];
                var    roleList = RoleBll.RoleLikeQuery(name);
                return(View["RoleManage", roleList]);
            };
            Post["CheckRoleName/{Name}"] = p => RoleBll.GetDataByName(p.Name) != null;
            Get["RoleAdd"]  = _ => ValidPermission("RoleAdd") ? View["RoleAdd"] : View["NoPermissions"];
            Post["RoleAdd"] = p =>
            {
                var roleModel = new RoleModel
                {
                    Name           = Request.Form["RoleName"].ToString(),
                    CreateTime     = DateTime.Now.ToString(),
                    CreateUer      = Context.CurrentUser.UserName,
                    Permission     = $"{Request.Form["Node"]},{Request.Form["group"]}",
                    Status         = Request.Form["Status"].ToString(),
                    ManageHospital = string.IsNullOrEmpty(Request.Form["HospitalText"]) ? ConstFile.ALL : Request.Form["HospitalText"].ToString()
                };
                RoleBll.Insert(roleModel);
                return(Response.AsRedirect("RoleManage"));
            };
            Get["RoleEdit/{Name}"] = p =>
            {
                var model = RoleBll.GetDataByName(p.Name);
                return(this.ValidPermission("RoleEdit") ? View["RoleEdit", model] : View["NoPermissions"]);
            };
            Post["RoleEdit"] = _ =>
            {
                var roleModel = new RoleModel
                {
                    Name           = Request.Form["Name"].ToString(),
                    CreateTime     = DateTime.Now.ToString(),
                    CreateUer      = Context.CurrentUser.UserName,
                    Permission     = $"{Request.Form["Node"]},{Request.Form["group"]}",
                    Status         = Request.Form["Status"].ToString(),
                    ManageHospital = string.IsNullOrEmpty(Request.Form["HospitalText"]) ? ConstFile.ALL : Request.Form["HospitalText"].ToString()
                };
                RoleBll.Update(roleModel);
                return(Response.AsRedirect("RoleManage"));
            };
            Post["RoleDelete/{Name}"] = p =>
            {
                return(RoleBll.Delete(p.Name));
            };
            Get["GetRolesToJson"] = _ =>
            {
                return(Response.AsJson(RoleBll.GetBuiCheckBoxJson()));
            };
        }