Example #1
0
        public static void HandleViewDataMethodChange(Kooboo.Events.Cms.SiteObjectChangeEvent <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);
                    }
                }
            }
        }
Example #2
0
        public static void HandleStyleChange(Kooboo.Events.Cms.SiteObjectChangeEvent <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);

            //    }

            //}
        }
Example #3
0
        public static void HandleFormChange(Kooboo.Events.Cms.SiteObjectChangeEvent <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);
            }
        }
Example #4
0
        public static void HandleImageChange(Kooboo.Events.Cms.SiteObjectChangeEvent <Image> ImageEvent)
        {
            Guid imageid = default(Guid);

            if (ImageEvent.Value != null)
            {
                imageid = ImageEvent.Value.Id;
            }
            else
            {
                imageid = ImageEvent.OldValue.Id;
            }

            ImageEvent.SiteDb.Thumbnails.DeleteByImageId(imageid);
        }
Example #5
0
        public static void HandleCssRuleChange(Kooboo.Events.Cms.SiteObjectChangeEvent <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);
            //    }

            //}
        }