Наследование: Orchard.ContentManagement.Handlers.ContentContextBase
Пример #1
0
        private void ImportRouteSettings(ImportContentContext context, CacheSettingsPart part)
        {
            var partElement = context.Data.Element(part.PartDefinition.Name);

            // Don't do anything if the tag is not specified.
            if (partElement == null)
                return;

            var routesElement = partElement.Element("Routes");

            if (routesElement == null)
                return;

            var routeConfigs = routesElement.Elements().Select(x => new CacheRouteConfig {
                RouteKey = x.Attr("Key"),
                Duration = x.Attr<int?>("Duration"),
                Priority = x.Attr<int>("Priority"),
                Url = x.Attr("Url"),
                MaxAge = x.Attr<int?>("MaxAge"),
                GraceTime = x.Attr<int?>("GraceTime"),
                FeatureName = x.Attr("FeatureName")
            });

            _cacheService.SaveRouteConfigs(routeConfigs);
        }
Пример #2
0
        /*  
         <Settings>
          <SiteSettingsPart PageSize="30" />
          <CommentSettingsPart ModerateComments="true" />
         </Settings>
        */
        // Set site and part settings.
        public void ExecuteRecipeStep(RecipeContext recipeContext) {
            if (!String.Equals(recipeContext.RecipeStep.Name, "Settings", StringComparison.OrdinalIgnoreCase)) {
                return;
            }

            var siteContentItem = _siteService.GetSiteSettings().ContentItem;

            var importContentSession = new ImportContentSession(_contentManager);

            var context = new ImportContentContext(siteContentItem, recipeContext.RecipeStep.Step, importContentSession);
            foreach (var contentHandler in Handlers) {
                contentHandler.Importing(context);
            }

            foreach (var contentPart in siteContentItem.Parts) {
                var partElement = context.Data.Element(contentPart.PartDefinition.Name);
                if (partElement == null) {
                    continue;
                }

                if (!string.IsNullOrEmpty(recipeContext.ExecutionId)) {
                    _recipeJournal.WriteJournalEntry(recipeContext.ExecutionId, T("Setting: {0}.", contentPart.PartDefinition.Name).Text);
                }

                ImportSettingPart(contentPart, partElement);
            }

            foreach (var contentHandler in Handlers) {
                contentHandler.Imported(context);
            }

            recipeContext.Executed = true;
        }
Пример #3
0
        /*  
         <Settings>
          <SiteSettingsPart PageSize="30" />
          <CommentSettingsPart ModerateComments="true" />
         </Settings>
        */
        // Set site and part settings.
        public override void Execute(RecipeExecutionContext context) {
            var siteContentItem = _siteService.GetSiteSettings().ContentItem;
            var importContentSession = new ImportContentSession(_contentManager);
            var importContentContext = new ImportContentContext(siteContentItem, context.RecipeStep.Step, importContentSession);

            foreach (var contentHandler in Handlers) {
                contentHandler.Importing(importContentContext);
            }

            foreach (var contentPart in siteContentItem.Parts) {
                var partElement = importContentContext.Data.Element(contentPart.PartDefinition.Name);
                if (partElement == null) {
                    continue;
                }

                Logger.Information("Importing settings part '{0}'.", contentPart.PartDefinition.Name);
                try {
                    ImportSettingPart(contentPart, partElement);
                }
                catch (Exception ex) {
                    Logger.Error(ex, "Error while importing settings part '{0}'.", contentPart.PartDefinition.Name);
                    throw;
                }
            }

            foreach (var contentHandler in Handlers) {
                contentHandler.Imported(importContentContext);
            }
        }
Пример #4
0
        public void Import(dynamic state, ImportContentContext context) {
            string termIdentities = Convert.ToString(state.TermIds);

            if (!String.IsNullOrEmpty(termIdentities)) {
                var identities = termIdentities.Split(new[] { ',' }).ToArray();
                var terms = identities.Select(context.GetItemFromSession).ToList();
                var ids = terms.Select(x => x.Id).Select(x => x.ToString()).ToArray();

                state.TermIds = String.Join(",", ids);
            }
        }
Пример #5
0
        public string Import(string formName, string state, ImportContentContext importContext) {
            var describeContext = new DescribeContext();
            foreach (var provider in _formProviders) {
                provider.Describe(describeContext);
            }

            var descriptor = describeContext.Describe().FirstOrDefault(x => x.Name == formName);

            if (descriptor == null || descriptor.Import == null) {
                return state;
            }

            var dynamicState = FormParametersHelper.ToDynamic(state);
            descriptor.Import(dynamicState, importContext);

            return FormParametersHelper.ToString(dynamicState);
        }
        public IEnumerable<RemoteContentItem> Fetch(Uri remoteInstanceRoot) {
            List<RemoteContentItem> remoteContentItems = new List<RemoteContentItem>();
            var recipe = FetchRecipe(remoteInstanceRoot);
            var importContentSession = new ImportContentSession(_orchardServices.ContentManager);
            foreach (var step in recipe.RecipeSteps)
            {
                foreach (var element in step.Step.Elements())
                {
                    if (!ContentSync.SyncableContentTypes.Contains(element.Name.LocalName))
                        continue;

                    var elementId = element.Attribute("Id");
                    if (elementId == null)
                        continue;

                    var identity = elementId.Value;
                    var status = element.Attribute("Status");

                    var item = _orchardServices.ContentManager.New(element.Name.LocalName);
                    var context = new ImportContentContext(item, element, importContentSession);

                    foreach (var contentHandler in _handlers.Value)
                    {
                        contentHandler.Importing(context);
                    }

                    foreach (var contentHandler in _handlers.Value)
                    {
                        contentHandler.Imported(context);
                    }

                    remoteContentItems.Add(new RemoteContentItem() { ContentItem = item, Xml = element });
                }
            }
            _orchardServices.ContentManager.Clear();

            return remoteContentItems;
        }
 public override void Imported(ImportContentContext context) {
     context.Logger = Logger;
     foreach (var contentFieldDriver in _drivers) {
         contentFieldDriver.Imported(context);
     }
 }
 protected override void Imported(ImportContentContext context)
 {
     EnforceResourceSharingOffOnDefault(context);
 }
 public override void Importing(ImportContentContext context) {
     foreach (var contentFieldDriver in _drivers) {
         contentFieldDriver.Importing(context);
     }
 }
 protected override void Imported(ImportContentContext context) {
     RecordAuditTrailEvent(ContentAuditTrailEventProvider.Imported, context.ContentItem);
 }
 public void Imported(ImportContentContext context)
 {
     TriggerIfGraph(context);
 }
 public ImportContentContextWrapper(ImportContentContext context) {
     _context = context;
 }
Пример #13
0
 protected virtual void Imported(ImportContentContext context)
 {
 }
Пример #14
0
 void IContentHandler.Imported(ImportContentContext context)
 {
     Imported(context);
 }
Пример #15
0
 void IContentHandler.Importing(ImportContentContext context)
 {
     Importing(context);
 }
 public void Importing(ImportContentContext context)
 {
 }
Пример #17
0
 public override void ImportCompleted(ImportContentContext context) {
     foreach (var contentPartDriver in _drivers) {
         contentPartDriver.ImportCompleted(context);
     }
 }
Пример #18
0
 public void Imported(ImportContentContext context)
 {
 }