public static void HandleDelete(object sender, DeleteContentEventArgs e)
        {
            var beingDeleted = new List <ContentReference>();

            if (e.ContentLink != null)
            {
                beingDeleted.Add(e.ContentLink);
            }
            beingDeleted.AddRange(e.DeletedDescendents);

            foreach (var item in beingDeleted)
            {
                var contentMapping = DivvyContentMapping.FindFromEpiserverContent(item.ID);

                if (contentMapping != null)
                {
                    DivvyContentMapping.Archive(contentMapping);

                    DivvyLogManager.Log("Deleted Event Raised", new { EpiserverId = item.ID, DivvyId = DivvyContentMapping.FindFromEpiserverContent(item.ID).DivvyId });

                    var content = repo.Get <IContent>(new ContentReference(item.ID));
                    NotifyDivvy(content, Settings.DeletedStatusLabel);
                }
            }
        }
        public static void HandlePublish(object sender, ContentEventArgs e)
        {
            var contentMapping = DivvyContentMapping.FindFromEpiserverContent(e.Content.ContentLink.ID);

            if (contentMapping != null)
            {
                DivvyLogManager.Log("Published Event Raised", new { contentMapping.EpiserverContentId, contentMapping.DivvyId });
                NotifyDivvy(e.Content, Settings.PublishedStatusLabel);
            }
        }
        public static void Init()
        {
            if (Settings.InitComplete)
            {
                return;
            }

            // This reads everything from the web.config
            var configSection = (DivvyConfigSection)ConfigurationManager.GetSection("divvy");

            if (configSection == null)
            {
                // No config means we're disabled
                Settings.Mode = DivvyMode.Disabled;
                DivvyLogManager.Log("No config found in web.config. System disabled.");
                return;
            }

            if (configSection.Enabled)
            {
                Settings.Mode = DivvyMode.Enabled;
            }
            else
            {
                // If we're disabled, nothing below matters
                return;
            }

            Settings.AccessToken = configSection.AuthToken;
            if (Settings.AccessToken == null || Settings.AccessToken == Guid.Empty)
            {
                // If they didn't set the access token, we disable
                Settings.Mode = DivvyMode.Disabled;
                DivvyLogManager.Log("No access token found in config. System disabled.");
                return;
            }

            Settings.DebugRole = configSection.DebugRole;

            foreach (DivvyMappingConfig mapping in configSection.Mappings)
            {
                Settings.AddMapping(new DivvyTypeMapping()
                {
                    DivvyTypeName         = mapping.DivvyType,
                    EpiserverPageTypeName = mapping.EpiserverType,
                    ParentNode            = mapping.Parent
                });;
            }

            Settings.InitComplete = true;
        }