private void GenerateGetNavigationAction(int permissionid, Dictionary <string, int> permissionNavis) { foreach (var item in Entity.NavigationPropertys.Values) { ControllerMethodMetadata method; var controller = Entity.Definition.Controller; if (item.PropertyType.IsCollection) { method = new ControllerMethodMetadata(EControllerMethodType.GetNavigateQueryable).PermissionAction(permissionid); if (controller.DisablePage) { method.Write("System.Web.OData.EnableQuery"); } else { method.Write("System.Web.OData.EnableQuery", $"PageSize={controller.PageSize}"); } } else { method = new ControllerMethodMetadata(EControllerMethodType.GetNavigateSingleResult).PermissionAction(permissionid); method.Write("System.Web.OData.EnableQuery"); } method.Navigation = item; if (permissionNavis.ContainsKey(item.Name)) { method.PermissionAction(permissionNavis[item.Name]); } Methods.Add(method); } }
private void GenerateGetAction(ControllerConfigure controller) { int permissionid = PermissionAction("RETRIEVE", "查询权限", "查询数据[" + Entity.ProjectItem.Title + "]的权限"); var getcol = new ControllerMethodMetadata(EControllerMethodType.GetQueryable); if (controller.AuthGet) { getcol.PermissionAction(permissionid); } var getobj = new ControllerMethodMetadata(EControllerMethodType.GetSingleResult); if (controller.AuthGet) { getobj.PermissionAction(permissionid); } string idstr = string.Empty, namestr = string.Empty; Dictionary <string, int> permissionNavis = PermissionPropertys(controller, ref idstr, ref namestr); if (!string.IsNullOrEmpty(idstr) && controller.AuthGet) { if (controller.DisablePage) { getcol.Write("Wilmar.Service.Common.Attributes.ODataQuery", idstr, namestr, $"MaxNodeCount={int.MaxValue}", "MaxExpansionDepth = 4"); } else { getcol.Write("Wilmar.Service.Common.Attributes.ODataQuery", idstr, namestr, $"MaxNodeCount={int.MaxValue}", "MaxExpansionDepth = 4", $"PageSize={controller.PageSize}"); } getobj.Write("Wilmar.Service.Common.Attributes.ODataQuery", idstr, namestr); } else { if (controller.DisablePage) { getcol.Write("Wilmar.Service.Common.Attributes.CustomEnableQuery", $"MaxNodeCount={int.MaxValue}", "MaxExpansionDepth = 4"); } else { getcol.Write("Wilmar.Service.Common.Attributes.CustomEnableQuery", $"MaxNodeCount={int.MaxValue}", "MaxExpansionDepth = 4", $"PageSize={controller.PageSize}"); } getobj.Write("Wilmar.Service.Common.Attributes.CustomEnableQuery"); } Methods.Add(getcol); Methods.Add(getobj); GenerateGetNavigationAction(permissionid, permissionNavis); }