예제 #1
0
        private static void HandleViewDataMethodChange(Kooboo.Events.Cms.SiteObjectEvent <ViewDataMethod> ViewDataMethodEvent)
        {
            var viewid = ViewDataMethodEvent.Value.ViewId;
            var pages  = ViewDataMethodEvent.SiteDb.Relations.GetReferredByRelations(viewid, ConstObjectType.Page);

            foreach (var item in pages)
            {
                Sites.Routing.PageRoute.UpdatePageRouteParameter(ViewDataMethodEvent.SiteDb, item.objectXId);
            }

            if (ViewDataMethodEvent.ChangeType == ChangeType.Delete)
            {
                var methodid   = ViewDataMethodEvent.Value.MethodId;
                var sitemethod = ViewDataMethodEvent.SiteDb.DataMethodSettings.Get(methodid);
                if (sitemethod != null && !sitemethod.IsPublic)
                {
                    // check being used or not.
                    var viewdatamethod = ViewDataMethodEvent.SiteDb.ViewDataMethods.Query.Where(o => o.MethodId == sitemethod.Id).SelectAll();
                    if (viewdatamethod == null || viewdatamethod.Count == 0)
                    {
                        ViewDataMethodEvent.SiteDb.DataMethodSettings.Delete(sitemethod.Id);
                    }
                }
            }
        }
예제 #2
0
        private static void HandleStyleChange(Kooboo.Events.Cms.SiteObjectEvent <Style> StyleEvent)
        {
            //if (StyleEvent.ChangeType == ChangeType.Add)
            //{
            //    Kooboo.Sites.Relation.StyleRelation.Compute(StyleEvent.Value, StyleEvent.SiteDb);
            //}
            //else if (StyleEvent.ChangeType == ChangeType.Update)
            //{
            //    if (StyleEvent.OldValue.Body != StyleEvent.Value.Body)
            //    {
            //        Kooboo.Sites.Relation.StyleRelation.Compute(StyleEvent.Value, StyleEvent.SiteDb);
            //    }
            //}
            //else
            //{
            //    List<CmsCssRule> rules = StyleEvent.SiteDb.CssRules.Query.Where(o => o.ParentStyleId == StyleEvent.Value.Id && o.ParentCssRuleId == default(Guid)).SelectAll();

            //    foreach (var item in rules)
            //    {
            //        StyleEvent.SiteDb.CssRules.Delete(item.Id);
            //    }

            //    StyleEvent.SiteDb.Relations.CleanObjectRelation(StyleEvent.Value.Id);


            //    if (StyleEvent.Value.IsEmbedded)
            //    {
            //        StyleEvent.SiteDb.Styles.RemoveEmbedded(StyleEvent.Value);

            //    }

            //}
        }
예제 #3
0
        private static void HandleCssRuleChange(Kooboo.Events.Cms.SiteObjectEvent <CmsCssRule> CssRuleEvent)
        {
            //if (CssRuleEvent.ChangeType == ChangeType.Add)
            //{
            //    Kooboo.Sites.Relation.CmsCssRuleRelation.Compute(CssRuleEvent.Value, CssRuleEvent.SiteDb);

            //}
            //else if (CssRuleEvent.ChangeType == ChangeType.Update)
            //{
            //    if (CssRuleEvent.OldValue.CssText != CssRuleEvent.Value.CssText)
            //    {
            //        Kooboo.Sites.Relation.CmsCssRuleRelation.Compute(CssRuleEvent.Value, CssRuleEvent.SiteDb);
            //    }
            //}
            //else
            //{
            //    List<CmsCssRule> subrules = CssRuleEvent.SiteDb.CssRules.Query.Where(o => o.ParentCssRuleId == CssRuleEvent.Value.Id).UseColumnData().SelectAll();

            //    foreach (var item in subrules)
            //    {
            //        CssRuleEvent.SiteDb.CssRules.Delete(item.Id);
            //    }

            //    // clean all relations.
            //    CssRuleEvent.SiteDb.Relations.CleanObjectRelation(CssRuleEvent.Value.Id);

            //    // clean all sub css declarations.
            //    List<CmsCssDeclaration> declarations = CssRuleEvent.SiteDb.CssDeclarations.Query.Where(o => o.CmsCssRuleId == CssRuleEvent.Value.Id).UseColumnData().SelectAll();

            //    foreach (var item in declarations)
            //    {
            //        CssRuleEvent.SiteDb.CssDeclarations.Delete(item.Id);
            //    }
            //}
        }
예제 #4
0
        private static void HandleFormChange(Kooboo.Events.Cms.SiteObjectEvent <Form> FormEvent)
        {
            if (FormEvent.ChangeType == ChangeType.Delete)
            {
                foreach (var item in FormEvent.SiteDb.FormValues.Query.Where(o => o.FormId == FormEvent.Value.Id).SelectAll())
                {
                    FormEvent.SiteDb.FormValues.Delete(item.Id);
                }

                FormEvent.SiteDb.Relations.CleanObjectRelation(FormEvent.Value.Id);
            }
        }
예제 #5
0
        private static void HandleImageChange(Kooboo.Events.Cms.SiteObjectEvent<Image> ImageEvent)
        {
            Guid imageid = default(Guid);
            if (ImageEvent.Value != null)
            {
                imageid = ImageEvent.Value.Id;
            }
            else
            {
                imageid = ImageEvent.OldValue.Id;
            }

            ImageEvent.SiteDb.Thumbnails.DeleteByImageId(imageid);
        }
예제 #6
0
 private static void HandleCodeChange(Kooboo.Events.Cms.SiteObjectEvent <Code> CodeEvent)
 {
     if (CodeEvent.ChangeType == ChangeType.Delete)
     {
         if (CodeEvent.Value.CodeType == CodeType.Api && CodeEvent.Value != null)
         {
             // for api, also need to remove the url.
             var route = CodeEvent.SiteDb.Routes.GetByObjectId(CodeEvent.Value.Id);
             if (route != null)
             {
                 CodeEvent.SiteDb.Routes.Delete(route.Id);
             }
         }
     }
 }
예제 #7
0
        private static void HandleCodeChange(Kooboo.Events.Cms.SiteObjectEvent <Code> CodeEvent)
        {
            if (CodeEvent.ChangeType == ChangeType.Delete)
            {
                if (CodeEvent.Value.CodeType == CodeType.Api && CodeEvent.Value != null)
                {
                    // for api, also need to remove the url.
                    var route = CodeEvent.SiteDb.Routes.GetByObjectId(CodeEvent.Value.Id);
                    if (route != null)
                    {
                        CodeEvent.SiteDb.Routes.Delete(route.Id);
                    }
                }
            }


            if (CodeEvent.Value.CodeType == CodeType.Event)
            {
                var website = CodeEvent.SiteDb.WebSite;

                if (CodeEvent.ChangeType == ChangeType.Delete)
                {
                    // check if there is any event....
                    if (website.EnableFrontEvents)
                    {
                        var events = CodeEvent.SiteDb.Code.Query.Where(o => o.CodeType == CodeType.Event).Count();
                        if (events == 0)
                        {
                            website.EnableFrontEvents = false;
                            Kooboo.Data.GlobalDb.WebSites.AddOrUpdate(website);
                        }
                    }
                }
                else
                {
                    CodeEvent.SiteDb.WebSite.EnableFrontEvents = true;
                    Kooboo.Data.GlobalDb.WebSites.AddOrUpdate(website);
                }
            }
        }