示例#1
0
        public virtual void Process([NotNull] ProcessIntegrationItemArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            Assert.IsNotNull(args.IntegrationItem, "args.IntegrationItem");

            args.IntegrationItem.Delete();
        }
        public static ProcessIntegrationItemArgs DeleteIntegrationItem([NotNull] ID integrationItemID, [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(integrationItemID, "integrationItemID");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var pipelineArgs = new ProcessIntegrationItemArgs
            {
                IntegrationItemID = integrationItemID,
                SynchContext      = synchContext
            };

            return(DeleteIntegrationItem(pipelineArgs) ? pipelineArgs : null);
        }
示例#3
0
        public virtual void Process([NotNull] ProcessIntegrationItemArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            Assert.IsNotNull(args.IntegrationItemID, "args.IntegrationItemID");
            Assert.IsNotNull(args.IntegrationItemTemplateID, "args.IntegrationItemTemplateID");
            Assert.IsNotNull(args.SourceSharepointItem, "args.SourceSharepointItem");
            Assert.IsNotNull(args.SynchContext, "args.SynchContext");

            args.IntegrationItem = IntegrationItemProvider.CreateItem(
                args.IntegrationItemID,
                args.IntegrationItemTemplateID,
                args.SourceSharepointItem,
                args.SynchContext);
        }
        public void should_abort_pipeline_if_item_is_null()
        {
            // Arrange
            var args = new ProcessIntegrationItemArgs
            {
                IntegrationItemID = ID.NewID,
                SynchContext      = this.CreateSynchContext()
            };

            // Act
            this.processor.Process(args);

            // Assert
            args.Aborted.Should().BeTrue();
        }
        public static bool UpdateIntegrationItem([NotNull] ProcessIntegrationItemArgs pipelineArgs)
        {
            Assert.ArgumentNotNull(pipelineArgs, "pipelineArgs");

            try
            {
                PipelineRunner.AssertRun(PipelineNames.UpdateIntegrationItem, pipelineArgs);
                return(true);
            }
            catch (Exception exception)
            {
                LogMessage(exception, LogMessages.Text0IntegrationItem1HasBeenFailed, "Updating", pipelineArgs.IntegrationItemID);
            }

            return(false);
        }
        public void should_get_item_from_db()
        {
            // Arrange
            var  database     = Substitute.For <Database>();
            Item expectedItem = database.CreateIntegrationItem();

            var args = new ProcessIntegrationItemArgs
            {
                IntegrationItemID = expectedItem.ID,
                SynchContext      = this.CreateSynchContext(database)
            };

            // Act
            this.processor.Process(args);

            // Assert
            args.IntegrationItem.Should().Be(expectedItem).And.NotBeNull();
        }
        public void should_log_if_item_is_null()
        {
            // Arrange
            var args = new ProcessIntegrationItemArgs
            {
                IntegrationItemID = ID.NewID,
                SynchContext      = this.CreateSynchContext()
            };

            // Act
            var logWatcher = new LogWatcher(() => this.processor.Process(args));

            // Assert
            logWatcher.Ensure()
            .LevelIs(LogNotificationLevel.Warning)
            .MessageIs(
                "Can't get item '{0}' from database '{1}'".FormatWith(args.IntegrationItemID, args.SynchContext.Database));
        }
示例#8
0
        public virtual void Process([NotNull] ProcessIntegrationItemArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            Assert.IsNotNull(args.SourceSharepointItem, "args.SourceSharepointItem");
            Assert.IsNotNull(args.SynchContext, "args.SynchContext");

            if (args.SourceSharepointItem is DocumentItem)
            {
                string extension = StringUtil.GetLastPostfix(args.SourceSharepointItem.Title, '.');

                string templateName = MediaManager.Config.GetTemplate(extension, false);
                if (!string.IsNullOrEmpty(templateName))
                {
                    Template template = TemplateManager.GetTemplate(templateName, args.SynchContext.Database);
                    if (template != null)
                    {
                        args.IntegrationItemTemplateID = template.ID;
                        return;
                    }
                }
            }

            if (args.SourceSharepointItem is FolderItem)
            {
                args.IntegrationItemTemplateID = TemplateIDs.IntegrationFolder;
                return;
            }

            ID templateID;

            if (!ID.TryParse(args.SynchContext.IntegrationConfigData.TemplateID, out templateID))
            {
                string logMessage = string.Format(LogMessages.IntegrationConfigurationDataOf0ItemDoesNotContainValidTemplateIDSetting, args.SynchContext.ParentItem.Paths.Path);
                Log.Error(logMessage, this);

                return;
            }

            args.IntegrationItemTemplateID = templateID;
        }
        public static ProcessIntegrationItemArgs UpdateIntegrationItem(
            [NotNull] ID integrationItemID,
            [NotNull] SharepointBaseItem sourceSharepointItem,
            [NotNull] SynchContext synchContext,
            [NotNull] ProcessIntegrationItemsOptions options,
            [NotNull] EventSender eventSender)
        {
            Assert.ArgumentNotNull(integrationItemID, "integrationItemID");
            Assert.ArgumentNotNull(sourceSharepointItem, "sourceSharepointItem");
            Assert.ArgumentNotNull(synchContext, "synchContext");
            Assert.ArgumentNotNull(options, "options");

            var pipelineArgs = new ProcessIntegrationItemArgs
            {
                IntegrationItemID    = integrationItemID,
                SourceSharepointItem = sourceSharepointItem,
                SynchContext         = synchContext,
                Options     = options,
                EventSender = eventSender
            };

            return(UpdateIntegrationItem(pipelineArgs) ? pipelineArgs : null);
        }