コード例 #1
0
        private IList <string> GetEffectedMirorringChannelsByConvertingPage(
            ContentReference convertContentRef,
            bool recursive)
        {
            List <string> stringList = new List <string>();

            foreach (MirroringData mirroringData in MirroringData.List())
            {
                if (mirroringData.InitialMirroringDone)
                {
                    PermanentLinkMap permanentLinkMap = PermanentLinkMapper.Service.Find(mirroringData.FromPageGuid);
                    if (permanentLinkMap != null && !ContentReference.IsNullOrEmpty(permanentLinkMap.ContentReference))
                    {
                        if (ContentRepository.GetAncestors(convertContentRef).Select(p => p.ContentLink).Contains(permanentLinkMap.ContentReference) || permanentLinkMap.ContentReference.CompareToIgnoreWorkID(convertContentRef))
                        {
                            stringList.Add(mirroringData.Name);
                        }
                        else if (recursive && ContentRepository.GetAncestors(permanentLinkMap.ContentReference).Select(p => p.ContentLink).Contains(convertContentRef))
                        {
                            stringList.Add(mirroringData.Name);
                        }
                    }
                }
            }
            return(stringList);
        }
コード例 #2
0
 public void RegisterLinkMap(PermanentLinkMap linkMap)
 {
     _linkMaps.Add(linkMap);
 }
コード例 #3
0
 public void RegisterLinkMap(PermanentLinkMap linkMap)
 {
     _linkMaps.Add(linkMap);
 }
        protected override IContent Import(ImportedContentData importedContentData
                                           , AccessLevel requiredDestinationAccess, IContentTransferContext context
                                           , TransferImportOptions options, out Guid importedPageGuid)
        {
            if (options.TransferType != TypeOfTransfer.Importing)
            {
                return(base.Import(importedContentData
                                   , requiredDestinationAccess
                                   , context, options, out importedPageGuid));
            }

            CultureInfo originalSelectedLanguage = null;

            if (importedContentData.SelectedLanguage != null)
            {
                originalSelectedLanguage = CultureInfo.GetCultureInfo(importedContentData.SelectedLanguage.Name);
            }

            var selectedLanguageAction = importedContentData.GetType().GetProperty("SelectedLanguage");
            var contentLanguage        = importedContentData.GetLanguageBranch();

            if (!string.IsNullOrEmpty(contentLanguage))
            {
                selectedLanguageAction.SetValue(importedContentData, CultureInfo.GetCultureInfo(contentLanguage));
            }

            var        status              = importedContentData.GetStatus();
            var        propSaveAction      = context.GetType().GetProperty("SaveAction");
            SaveAction originalSaveActions = SaveAction.Publish | SaveAction.SkipValidation;

            if (!string.IsNullOrEmpty(status) && int.Parse(status) < (int)VersionStatus.Published)
            {
                propSaveAction.SetValue(context, SaveAction.CheckOut | SaveAction.ForceNewVersion | SaveAction.SkipValidation);
            }

            var orgPageSaveDBChangeBy  = ContextCache.Current["PageSaveDB:ChangedBy"];
            var orgPageSaveDBPageSaved = ContextCache.Current["PageSaveDB:PageSaved"];

            ContextCache.Current["PageSaveDB:ChangedBy"] = string.Empty;
            ContextCache.Current["PageSaveDB:PageSaved"] = string.Empty;

            try
            {
                var importedContentGuid     = new Guid(importedContentData.GetContentGuid());
                var handleContentGuidMethod = defaultContentImporter.GetType()
                                              .GetMethod("HandleContentGuid", BindingFlags.NonPublic | BindingFlags.Instance);
                var guid = (Guid)handleContentGuidMethod.Invoke(
                    defaultContentImporter
                    , new object[] { importedContentGuid, context });
                PermanentLinkMap permanentLinkMap = permanentLinkMapper.Find(guid);

                var baseContent = base.Import(importedContentData
                                              , requiredDestinationAccess
                                              , context, options, out importedPageGuid);

                if (permanentLinkMap != null && (context.SaveAction & SaveAction.Publish) != SaveAction.Publish)
                {
                    contentRepository.Save(baseContent, context.SaveAction, requiredDestinationAccess);
                }

                return(baseContent);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
            finally
            {
                selectedLanguageAction.SetValue(importedContentData, originalSelectedLanguage);
                propSaveAction.SetValue(context, originalSaveActions);
                ContextCache.Current["PageSaveDB:ChangedBy"] = orgPageSaveDBChangeBy;
                ContextCache.Current["PageSaveDB:PageSaved"] = orgPageSaveDBPageSaved;
            }
        }