public async Task <string> RenderAsync(SerializableList <YetaWF.Core.Identity.Role> model) { HtmlBuilder hb = new HtmlBuilder(); bool header = PropData.GetAdditionalAttributeValue("Header", true); GridModel grid = new GridModel() { GridDef = GetGridModel(header) }; grid.GridDef.DirectDataAsync = (int skip, int take, List <DataProviderSortInfo> sorts, List <DataProviderFilterInfo> filters) => { List <RoleInfo> allRoles = Resource.ResourceAccess.GetDefaultRoleList(); int superuserRole = Resource.ResourceAccess.GetSuperuserRoleId(); int userRole = Resource.ResourceAccess.GetUserRoleId(); List <Entry> roles = (from r in allRoles orderby r.Name select new Entry { RoleId = r.RoleId, Name = r.Name, Description = r.Description, InRole = userRole == r.RoleId || (model != null && model.Contains(new Role { RoleId = r.RoleId }, new RoleComparer())), __editable = (userRole != r.RoleId) // we disable the user entry }).ToList <Entry>(); DataSourceResult data = new DataSourceResult { Data = roles.ToList <object>(), Total = roles.Count, }; return(Task.FromResult(data)); }; hb.Append($@" <div class='yt_yetawf_identity_userroles t_edit' id='{DivId}'> {await HtmlHelper.ForDisplayAsAsync(Container, PropertyName, FieldName, grid, nameof(grid.GridDef), grid.GridDef, "Grid", HtmlAttributes: HtmlAttributes)} </div>"); hb.Append($"<div class='yt_yetawf_identity_userroles t_edit'>"); return(hb.ToString()); }
public async Task <string> RenderAsync(SerializableList <Role> model) { HtmlBuilder hb = new HtmlBuilder(); bool header = PropData.GetAdditionalAttributeValue("Header", true); bool exclude2FA = PropData.GetAdditionalAttributeValue("ExcludeUser2FA", false); bool?showFilter = PropData.GetAdditionalAttributeValue <bool?>("ShowFilter", null); GridModel grid = new GridModel() { GridDef = GetGridModel(header, showFilter) }; grid.GridDef.DirectDataAsync = (int skip, int take, List <DataProviderSortInfo> sorts, List <DataProviderFilterInfo> filters) => { List <RoleInfo> allRoles = Resource.ResourceAccess.GetDefaultRoleList(Exclude2FA: exclude2FA); int anonymousRole = Resource.ResourceAccess.GetAnonymousRoleId(); List <Entry> roles = (from r in allRoles orderby r.Name where r.RoleId != anonymousRole && model.Contains(new Role { RoleId = r.RoleId }, new RoleComparer()) select new Entry { Name = r.Name, Description = r.Description, }).ToList <Entry>(); DataSourceResult data = new DataSourceResult { Data = roles.ToList <object>(), Total = roles.Count, }; return(Task.FromResult(data)); }; hb.Append($@" <div class='yt_yetawf_identity_rolesselector t_display'> {await HtmlHelper.ForDisplayAsAsync(Container, PropertyName, FieldName, grid, nameof(grid.GridDef), grid.GridDef, "Grid", HtmlAttributes: HtmlAttributes)} </div>"); return(hb.ToString()); }
public override PacketMainReturnType interiorMain(ref Packet in_packet) { if (in_packet.ContainsLayer(Protocol.IP)) { IPPacket ipp = (IPPacket)in_packet; if ((ipp.Outbound && IPLists.Instance.InList("blacklist", ipp.DestIP)) || (!ipp.Outbound && IPLists.Instance.InList("blacklist", ipp.SourceIP))) { return(PacketMainReturnType.Drop); } if (in_packet.ContainsLayer(Protocol.TCP) && !ipp.Outbound) { TCPPacket tcp = (TCPPacket)ipp; if (Traps.Contains(tcp.DestPort)) { IPLists.Instance.AddToList("blacklist", tcp.SourceIP); LogCenter.Instance.LogEvent(new LogEvent(tcp.SourceIP.ToString() + " tried to access port " + tcp.DestPort.ToString() + " and is now blacklisted", this)); return(PacketMainReturnType.Drop); } } } return(0); }
public static SerializableList<string> GetDDFieldsList(CQ dom) { var data = new SerializableList<string>(); foreach (var dd in dom.Select(x => x.Cq())) { var topField = dd[0].InnerText.Trim(); if (!data.Contains(topField)) { data.Add(ToolsHelper.MakeXmlSafe(topField)); } } return data; }