예제 #1
0
        private void SettingsKey_InsertUpdate_After(object sender, ObjectEventArgs e)
        {
            SettingsKeyInfo Key = (SettingsKeyInfo)e.Object;

            switch (Key.KeyName.ToLower())
            {
            case "cmsdefaultculturecode":
                if (Key.SiteID > 0)
                {
                    string SiteName = DynamicRouteHelper.GetSite(Key.SiteID).SiteName;
                    DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                }
                else
                {
                    foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                    {
                        DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                    }
                }
                break;

            case "generateculturevariationurlslugs":
                if (Key.SiteID > 0)
                {
                    string SiteName = DynamicRouteHelper.GetSite(Key.SiteID).SiteName;
                    DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                }
                else
                {
                    foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                    {
                        DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                    }
                }
                break;
            }
        }
        private void SettingsKey_InsertUpdate_After(object sender, ObjectEventArgs e)
        {
            SettingsKeyInfo Key = (SettingsKeyInfo)e.Object;

            switch (Key.KeyName.ToLower())
            {
            case "cmsdefaultculturecode":
                try
                {
                    if (Key.SiteID > 0)
                    {
                        string SiteName = DynamicRouteInternalHelper.GetSite(Key.SiteID).SiteName;
                        DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                    }
                    else
                    {
                        foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                        {
                            DynamicRouteEventHelper.SiteDefaultLanguageChanged(SiteName);
                        }
                    }
                }
                catch (UrlSlugCollisionException ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                    e.Cancel();
                }
                catch (Exception ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                }
                break;

            case "generateculturevariationurlslugs":
                try
                {
                    if (Key.SiteID > 0)
                    {
                        string SiteName = DynamicRouteInternalHelper.GetSite(Key.SiteID).SiteName;
                        DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                    }
                    else
                    {
                        foreach (string SiteName in SiteInfoProvider.GetSites().Select(x => x.SiteName))
                        {
                            DynamicRouteEventHelper.CultureVariationSettingsChanged(SiteName);
                        }
                    }
                }
                catch (UrlSlugCollisionException ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "UrlSlugConflict", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                    e.Cancel();
                }
                catch (Exception ex)
                {
                    LogErrorsInSeparateThread(ex, "DynamicRouting", "Error", $"Occurred on Settings Key Update After for Key {Key.KeyName}");
                }
                break;
            }
        }