Ejemplo n.º 1
0
        public JsonResult LoadModuleRight(int module)
        {
            var list = new List <SelectItem>();
            //模块拥有的权限
            List <int> existRight = new List <int>();

            if (module != 0)
            {
                existRight = _repositoryFactory.ISystemModuleRight.Where(m => m.ModuleId == module).Select(m => m.RightId).ToList();
            }
            //所有权限
            var allRight = EnumHepler.GetEnumData(typeof(EnumHepler.ActionPermission));

            foreach (var right in allRight)
            {
                list.Add(new SelectItem()
                {
                    Text = right.Key, Value = right.Value, Selected = existRight.Contains(right.Value)
                });
            }
            return(Json(new TipMessage()
            {
                Status = true, Data = list
            }, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        protected override void SplitsDeStream(string stream)
        {
            // De stream komt in een zin.
            // die moet knippen worden.
            // hier knip de stream .
            string[] opgeknipt           = stream.Split(new char[] { '%' });
            string[] opgekniptTweedeDeel = opgeknipt[1].Split(new char[] { '&' });

            if (opgeknipt[0] == null)
            {
                throw new ArgumentNullException("Ietem mag niet null zijn.");
            }

            if (opgeknipt[1] == null)
            {
                throw new ArgumentNullException("Ietem mag niet null zijn.");
            }

            if (opgekniptTweedeDeel[0] == null)
            {
                throw new ArgumentNullException("Ietem mag niet null zijn.");
            }

            if (opgekniptTweedeDeel[1] == null)
            {
                throw new ArgumentNullException("Ietem mag niet null zijn.");
            }

            // nu hebben we de naam van de speler en de situatie als string.
            // We gaan de situatie verandert tot een enum.
            EnumHepler enumHepler = new EnumHepler();

            this.game.HandlSpeler(opgeknipt[0], enumHepler.EnumConvert <Status>(opgekniptTweedeDeel[0]), opgekniptTweedeDeel[1]);
            this.HandlHetSpel();
        }
Ejemplo n.º 3
0
        public ActionResult RightConfig(int id)
        {
            ViewBag.RoleId = id;
            //模块列表
            var moduleList = _repositoryFactory.ISystemModule.WhereJoin(m => m.IsDisplay, m => m.Sort, true, "SystemModuleRight").ToList();
            //该角色已保存的权限
            var existRight = _repositoryFactory.ISystemRoleRight.Where(m => m.RoleId == id).ToList();
            //页面展示的数据
            var viewList = new List <RoleModuleRight>();

            foreach (var module in moduleList)
            {
                var viewModel = new RoleModuleRight();
                viewModel.Name   = module.Name;
                viewModel.Parent = module.ParentId;
                viewModel.Value  = module.Id;
                viewModel.Sort   = module.Sort;
                foreach (var mr in module.SystemModuleRight)
                {
                    viewModel.RightList.Add(new ModuleRight()
                    {
                        Value   = mr.RightId,
                        Text    = EnumHepler.GetEnumDescription(typeof(EnumHepler.ActionPermission), mr.RightId),
                        Checked = existRight.Count(m => m.RightId == mr.RightId && m.ModuleId == module.Id) > 0
                    });
                }
                viewList.Add(viewModel);
            }
            return(View(viewList));
        }
Ejemplo n.º 4
0
        public JsonResult LoadMenuTypeCombobxo()
        {
            List <ComboboxDTO> list = EnumHepler.ConvertEnumToComboboxDTO <MenuTypeDTO>();

            list.Insert(0, new ComboboxDTO()
            {
                Id = "-1", Text = "———请选择———"
            });
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///  读取 GroupList , 生成 “组合” 下拉菜单的选项
        /// </summary>
        private void GetGroups()
        {
            Dictionary <int, string> dictGroups = EnumHepler.EnumToDictionary <GroupType>();

            this.ddlGroup.DisplayMember = "Name";
            this.ddlGroup.ValueMember   = "Id";

            foreach (var item in dictGroups)
            {
                ComboBoxListItem listItem = new ComboBoxListItem(
                    item.Key, item.Value, GroupUtil.GetGroupColorByGroupId(item.Key)
                    );
                this.ddlGroup.Items.Add(listItem);
            }

            this.ddlGroup.SelectedIndex = 0;
        }
Ejemplo n.º 6
0
        public JsonResult ExportMember(string keyword = "")
        {
            var list = _repositoryFactory.IMemberCard.Where(c => true);

            //搜索关键字过滤
            if (!string.IsNullOrEmpty(keyword))
            {
                list = list.Where(c => c.CardNo.Contains(keyword) || c.Mobile.Contains(keyword));
            }
            var data = list.OrderByDescending(m => m.CreateTime).ToList();

            if (data.Count > 0)
            {
                //NPOI导出数据
                NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
                ISheet     sheet  = book.CreateSheet("sheet1");
                ICellStyle style1 = book.CreateCellStyle();
                style1.Alignment         = HorizontalAlignment.Center;
                style1.VerticalAlignment = VerticalAlignment.Center;
                ICellStyle style2 = book.CreateCellStyle();
                style2.Alignment         = HorizontalAlignment.Left;
                style2.VerticalAlignment = VerticalAlignment.Center;
                IRow  headerrow = sheet.CreateRow(0);
                ICell cell_1    = headerrow.CreateCell(0);
                cell_1.CellStyle = style1;
                cell_1.SetCellValue("会员卡号");
                ICell cell_2 = headerrow.CreateCell(1);
                cell_2.CellStyle = style1;
                cell_2.SetCellValue("手机号");
                ICell cell_3 = headerrow.CreateCell(2);
                cell_3.CellStyle = style1;
                cell_3.SetCellValue("姓名");
                ICell cell_4 = headerrow.CreateCell(3);
                cell_4.CellStyle = style1;
                cell_4.SetCellValue("性别");
                ICell cell_5 = headerrow.CreateCell(4);
                cell_5.CellStyle = style1;
                cell_5.SetCellValue("创建时间");
                ICell cell_6 = headerrow.CreateCell(5);
                cell_6.CellStyle = style1;
                cell_6.SetCellValue("创建人");
                ICell cell_7 = headerrow.CreateCell(6);
                cell_7.CellStyle = style1;
                cell_7.SetCellValue("状态");
                ICell cell_8 = headerrow.CreateCell(7);
                cell_8.CellStyle = style1;
                cell_8.SetCellValue("可用余额");
                ICell cell_9 = headerrow.CreateCell(8);
                cell_9.CellStyle = style1;
                cell_9.SetCellValue("累计充值");
                foreach (var item in data)
                {
                    IRow  headerrow_1 = sheet.CreateRow(data.IndexOf(item) + 1);
                    ICell cell_1_1    = headerrow_1.CreateCell(0);
                    cell_1_1.CellStyle = style1;
                    cell_1_1.SetCellValue(item.CardNo);
                    ICell cell_1_2 = headerrow_1.CreateCell(1);
                    cell_1_2.CellStyle = style1;
                    cell_1_2.SetCellValue(item.Mobile);
                    ICell cell_1_3 = headerrow_1.CreateCell(2);
                    cell_1_3.CellStyle = style1;
                    cell_1_3.SetCellValue(item.Name);
                    ICell cell_1_4 = headerrow_1.CreateCell(3);
                    cell_1_4.CellStyle = style1;
                    cell_1_4.SetCellValue(item.Sex);
                    ICell cell_1_5 = headerrow_1.CreateCell(4);
                    cell_1_5.CellStyle = style1;
                    cell_1_5.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", item.CreateTime));
                    ICell cell_1_6 = headerrow_1.CreateCell(5);
                    cell_1_6.CellStyle = style1;
                    cell_1_6.SetCellValue(item.CreateUser);
                    ICell cell_1_7 = headerrow_1.CreateCell(6);
                    cell_1_7.CellStyle = style1;
                    cell_1_7.SetCellValue(EnumHepler.GetEnumDescription(((EnumHepler.MemberCardStatus)item.Status)));
                    ICell cell_1_8 = headerrow_1.CreateCell(7);
                    cell_1_8.CellStyle = style1;
                    cell_1_8.SetCellValue(string.Format("{0:N2}", item.Banlance));
                    ICell cell_1_9 = headerrow_1.CreateCell(8);
                    cell_1_9.CellStyle = style1;
                    cell_1_9.SetCellValue(string.Format("{0:N2}", item.TotalMoney));
                }
                sheet.SetColumnWidth(1, 30 * 150);
                sheet.SetColumnWidth(3, 30 * 250);
                string fileName = "会员卡列表_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
                string filePath = HttpContext.Server.MapPath("/Upload/Export/" + fileName);
                using (FileStream fs = System.IO.File.OpenWrite(filePath))
                {
                    book.Write(fs);//向打开的这个xls文件中写入并保存。
                }
                return(Json(new TipMessage()
                {
                    Status = true, MsgText = "导出成功!", Url = Url.Action("DownLoadFile", "FileHandler", new { path = filePath, content = "application/ms-excel" })
                }, JsonRequestBehavior.DenyGet));
            }
            else
            {
                return(Json(new TipMessage()
                {
                    Status = false, MsgText = "暂无会员卡记录!"
                }, JsonRequestBehavior.DenyGet));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 登录和操作权限验证
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            var  accept        = filterContext.HttpContext.Request.AcceptTypes;
            bool isJsonRequest = accept.Contains("application/json");

            //登录验证
            if (CurrentLoginUser == null)
            {
                if (filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    if (isJsonRequest)
                    {
                        filterContext.Result = new JsonResult()
                        {
                            Data = new TipMessage()
                            {
                                Status = false, MsgText = "您尚未登录或登录超时!正在跳转...", Url = Url.Action("Index", "Login")
                            },
                            JsonRequestBehavior = JsonRequestBehavior.AllowGet
                        };
                    }
                    else
                    {
                        filterContext.Result = new JavaScriptResult {
                            Script = "show_message(false,'您尚未登录或登录超时!正在跳转...','" + Url.Action("Index", "Login") + "');"
                        };
                    }
                }
                else
                {
                    RedirectResult _RedirectResult = new RedirectResult("~/Login");
                    filterContext.Result = _RedirectResult;
                }
            }
            else
            {
                //操作权限验证
                bool   isAuthorized = false;
                string failAction   = string.Empty;
                if (CurrentLoginUser.IsSuperUser)
                {
                    //超级管理员拥有所有权限,所以不用检查了
                    isAuthorized = true;
                }
                else
                {
                    var Attributes = filterContext.ActionDescriptor.GetCustomAttributes(typeof(PermissionFilterAttribute), false);
                    if (Attributes.Length > 0)
                    {
                        //标记了操作权限验证的过滤器
                        var PermissionCheck = Attributes[0] as PermissionFilterAttribute;
                        //判断是否拥有对应的操作权限
                        int module = 0;
                        //从cookie中取出当前操作的模块
                        int.TryParse(CookieHelper.GetCookie("thenode"), out module);
                        if (module != 0)
                        {
                            //开始判断
                            if (!string.IsNullOrEmpty(CurrentLoginUser.RoleString))
                            {
                                IEnumerable <int> role = CurrentLoginUser.RoleString.Split(',').Select(m => Convert.ToInt32(m));
                                bool validate          = true;
                                int  checkCount        = 0;
                                foreach (var code in PermissionCheck.Code)
                                {
                                    //找到数据库里的权限记录数量
                                    checkCount = _repositoryFactory.ISystemRoleRight.Count(m => role.Contains(m.RoleId) && m.RightId == (int)code && m.ModuleId == module);
                                    if (checkCount == 0)
                                    {
                                        validate   = false;
                                        failAction = EnumHepler.GetEnumDescription(code);
                                        break;//有一个验证失败剩下的就不用验证了,直接是没权限
                                    }
                                }
                                isAuthorized = validate;
                            }
                        }
                    }
                    else
                    {
                        //没有添加权限验证属性的就认为是可以操作的
                        isAuthorized = true;
                    }
                }
                if (!isAuthorized)
                {
                    if (filterContext.HttpContext.Request.IsAjaxRequest())
                    {
                        if (isJsonRequest)
                        {
                            filterContext.Result = new JsonResult()
                            {
                                Data = new TipMessage()
                                {
                                    Status = false, MsgText = "您没有" + failAction + "权限!"
                                },
                                JsonRequestBehavior = JsonRequestBehavior.AllowGet
                            };
                        }
                        else
                        {
                            filterContext.Result = new JavaScriptResult
                            {
                                Script = "show_message(false,'您没有" + failAction + "权限!',null);"
                            };
                        }
                    }
                    else
                    {
                        filterContext.Result = new RedirectResult("~/Error/NoViewPermission");
                    }
                }
            }
        }