public static Type GetModelType(byte ConstType) { return(ConstTypeContainer.GetModelType(ConstType)); }
protected void RaiseBeforeEvent(TValue value, ChangeType changetype, TValue oldValue = default(TValue)) { if (this.SiteObjectType == typeof(Page)) { var maxpages = Kooboo.Data.Infrastructure.InfraManager.instance.MaxPages(this.SiteDb.WebSite.OrganizationId); if (maxpages != int.MaxValue) { var count = this.SiteDb.Pages.Count(); if (count >= maxpages) { throw new Exception(Kooboo.Data.Language.Hardcoded.GetValue("Max number of pages per site has been reached, service level upgrade required")); } } } if (this.SiteDb.WebSite.EnableConstraintFixOnSave && changetype != ChangeType.Delete) { Constraints.ConstraintChecker.FixOnSave(this.SiteDb, value as SiteObject); } // for kscript parameters. if (value is IScriptable) { var kscriptobject = value as IScriptable; var domobjct = value as IDomObject; if (kscriptobject != null && domobjct != null) { kscriptobject.RequestParas = Kooboo.Sites.Scripting.ScriptHelper.GetkScriptParaFromDom(this.SiteDb, domobjct.Dom); } } if (value is Kooboo.Sites.Models.Code) { var code = value as Kooboo.Sites.Models.Code; if (code.CodeType == Sites.Models.CodeType.PageScript) { code.Parameters = Kooboo.Sites.Scripting.ScriptHelper.GetKScriptParameters(code.Body); } } if (value is Kooboo.Sites.Models.CoreObject && changetype != ChangeType.Delete) { if (value is Kooboo.Sites.Routing.Route) { return; } var size = Kooboo.Sites.Service.ObjectService.GetSize(value); if (!Kooboo.Data.Infrastructure.InfraManager.Test(this.WebSite.OrganizationId, Data.Infrastructure.InfraType.Disk, size)) { var message = Data.Language.Hardcoded.GetValue("Over Disk Quota"); throw new Exception(message); } else { string msg = ConstTypeContainer.GetName(value.ConstType); var objinfo = Kooboo.Sites.Service.ObjectService.GetObjectInfo(this.SiteDb, value); if (objinfo != null) { msg += "| " + objinfo.DisplayName; } else { msg += "| " + value.Name; } Kooboo.Data.Infrastructure.InfraManager.Add(this.WebSite.OrganizationId, Data.Infrastructure.InfraType.Disk, size, msg); } } }
public static async Task Render(FrontContext context) { //systemroute.Name = "__kb/{objecttype}/{nameorid}"; defined in Routes. var paras = context.Route.Parameters; var strObjectType = paras.GetValue("objecttype"); if (strObjectType == null) { return; } byte constType = ConstObjectType.Unknown; if (!byte.TryParse(strObjectType, out constType)) { constType = ConstTypeContainer.GetConstType(strObjectType); if (constType == 0 && strObjectType == "custom") { // sysRoute.Name = "/__kb/{objecttype}/{nameorid}/{action}"; var type = paras.GetValue("nameorid"); var para = paras.GetValue("action"); await Kooboo.Sites.Render.Renderers.Custom.CustomRenderManager.RenderAsync(type, para, context); return; } } var id = paras.GetValue("nameorid"); switch (constType) { case ConstObjectType.ResourceGroup: ResourceGroupRender(context, id); return; case ConstObjectType.View: await ViewRender(context, id, paras); return; case ConstObjectType.Image: { ImageRender(context, id, paras); return; } case ConstObjectType.CmsFile: { FileRender(context, id, paras); return; } case ConstObjectType.kfile: { KFileRender(context, paras); return; } //case ConstObjectType.TextContent: // { // TextContentRender(context, id, paras); // return; // } default: DefaultRender(context, constType, strObjectType, id, paras); break; } }