Exemple #1
0
        public ActionResult Auth(string ID)
        {
            var           rolePages = SysService.GetRolePages(ID);
            RoleAuthModel model     = new RoleAuthModel {
                RoleID = ID, Pages = new List <AuthPageModel>()
            };

            foreach (var g in AppConfig.Current.PageGroups)
            {
                foreach (var p in g.Pages.Where(w => w.IsEnable))
                {
                    model.Pages.Add(new AuthPageModel
                    {
                        PageID  = p.PageID,
                        Title   = p.Title,
                        Actions = p.Config.Actions.Where(a => a.IsEnable).GroupBy(a => a.Title)
                                  .Select(m => new AuthActionModel
                        {
                            ActionTitle = m.Key,
                            ActionValue = m.First().ActionValue,
                            IsSelected  = rolePages.FirstOrDefault(f => f.PageID.Equals(p.PageID) &&
                                                                   (f.ActionValue & m.First().ActionValue) == m.First().ActionValue) != null
                        }).ToList()
                    });
                }
            }
            return(View(model));
        }
Exemple #2
0
        public ActionResult Edit(string ID)
        {
            var model = SysService.GetRole(ID);

            var           rolePages = SysService.GetRolePages(ID);
            RoleAuthModel pagemodel = new RoleAuthModel {
                RoleID = ID, Name = model.Name, Description = model.Description, Pages = new List <AuthPageModel>()
            };

            pagemodel.DataFilter = null;
            pagemodel.Titles     = new List <string>();
            foreach (var g in AppConfig.Current.PageGroups)
            {
                pagemodel.Titles.Add(g.Name);
                foreach (var p in g.Pages.Where(w => w.IsEnable))
                {
                    pagemodel.Pages.Add(new AuthPageModel
                    {
                        PageID  = p.PageID,
                        Title   = p.Title,
                        Name    = g.Name,
                        Actions = p.Config.Actions.Where(a => a.IsEnable).GroupBy(a => a.Title)
                                  .Select(m => new AuthActionModel
                        {
                            ActionTitle = m.Key,
                            ActionValue = m.First().ActionValue,
                            IsSelected  = rolePages.FirstOrDefault(f => f.PageID.Equals(p.PageID) &&
                                                                   (f.ActionValue & m.First().ActionValue) == m.First().ActionValue) != null
                        }).ToList()
                    });
                }
            }
            var companyids = (from rp in rolePages where rp.PageID.Equals("P01001") select rp.DataFilter.ToString()).ToArray();
            var deptids    = (from rp in rolePages where rp.PageID.Equals("P01002") select rp.DataFilter.ToString()).ToArray();;
            var bankids    = (from rp in rolePages where rp.PageID.Equals("P01017") select rp.DataFilter.ToString()).ToArray();

            foreach (var companyid in companyids)
            {
                pagemodel.DataFilter += companyid;
            }
            pagemodel.DataFilter += ":";
            foreach (var deptid in deptids)
            {
                pagemodel.DataFilter += deptid;
            }
            pagemodel.DataFilter += ":";
            foreach (var bankid in bankids)
            {
                pagemodel.DataFilter += bankid;
            }
            return(View(pagemodel));
        }
Exemple #3
0
        public string GetTreegridState(string ID)
        {
            string jsonstr   = "";
            string col       = "";
            int    pcount    = 0;
            var    rolePages = SysService.GetRolePages(ID);

            foreach (var g in AppConfig.Current.PageGroups)
            {
                col += "{\"id\":\"" + g.Name + "\",\"name\":\"" + g.Name + "\"},";
                foreach (var p in g.Pages.Where(w => w.IsEnable))
                {
                    col += "{\"id\":\"" + p.PageID + "\",\"name\":\"" + p.Title + "\",\"_parentId\":\"" + g.Name + "\",\"action\":\"";
                    int prevalue = 0;
                    foreach (var a in p.Config.Actions.Where(a => a.IsEnable).GroupBy(a => a.Title))
                    {
                        if (prevalue != a.First().ActionValue)
                        {
                            if (a.First().ActionValue != 0)
                            {
                                bool state = rolePages.FirstOrDefault(f => f.PageID.Equals(p.PageID) && (f.ActionValue & a.First().ActionValue) == a.First().ActionValue) != null;
                                col += a.First().ActionValue + ":" + a.Key + ":" + state.ToString();
                                if (a.Key != p.Config.Actions.Where(k => k.IsEnable).GroupBy(k => k.Title).Last().Key)
                                {
                                    col += ",";
                                }
                            }
                            prevalue = a.First().ActionValue;
                        }
                    }
                    col += "\"},";
                }
                pcount += g.Pages.Where(w => w.IsEnable).Count();
            }
            col      = col.Substring(0, col.Length - 1);
            jsonstr += "{\"total\":" + (Convert.ToInt16(AppConfig.Current.PageGroups.Count()) + pcount) + ",\"rows\":[" + col + "]}";
            return(jsonstr.Replace("\\", ""));
        }