Exemplo n.º 1
0
        //private void SettingsPublishing(object sender, ContentEventArgs e)
        //{
        //}

        protected virtual void SettingsPublished(object sender, ContentEventArgs e)
        {
            try
            {
                if (e.ContentLink.CompareToIgnoreWorkID(ConfigurationPageLink))
                {
                    var page     = (AzureAdSecuritySettingsPage)e.Content;
                    var newRoles = page.Settings?.Roles ?? new List <string>();

                    var previousVersion = ContentVersionRepository.List(ConfigurationPageLink)
                                          .Where(x => x.Status == VersionStatus.PreviouslyPublished)
                                          .OrderByDescending(x => x.Saved)
                                          .FirstOrDefault();

                    var previousPage = previousVersion != null?ContentRepository.Get <AzureAdSecuritySettingsPage>(previousVersion.ContentLink, DefaultLoaderOptions) : null;

                    var diff = Diff(newRoles, previousPage?.Settings?.Roles ?? new List <string>());

                    if (!diff.IsEmpty)
                    {
                        RolesWatcher.RolesChanged(diff);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Error handling roles update (published page #{e.ContentLink.ID}): {ex}");
            }
        }