Exemplo n.º 1
0
        public void should_call_pipeline()
        {
            // Arrange
            using (var pipelines = new PipelinesHandler())
            {
                var updateItem = new ItemMock();
                var item       = new ItemMock().AsConfigurationItem()
                                 .WithChild(updateItem);

                var synchContext   = new SynchContext(item);
                var sharepointItem = TestHelper.CreateSharepointItem();
                var options        = new ProcessIntegrationItemsOptions();
                var action         = new UpdateIntegrationItemAction(new IntegrationItem(updateItem), sharepointItem, synchContext, options);

                // Act
                action.Execute();
                action.IsSuccessful.Should().BeTrue();

                // Assert
                pipelines.ShouldReceiveCall <ProcessIntegrationItemArgs>(
                    PipelineNames.UpdateIntegrationItem,
                    x => x.IntegrationItemID == updateItem.ID &&
                    x.SourceSharepointItem == sharepointItem &&
                    x.SynchContext == synchContext &&
                    x.Options == options);
            }
        }
Exemplo n.º 2
0
        protected void Process(
            [NotNull] Item integrationItem,
            [NotNull] ObjectModel.Entities.Items.BaseItem sourceSharepointItem,
            [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(integrationItem, "integrationItem");
            Assert.ArgumentNotNull(sourceSharepointItem, "sourceSharepointItem");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var sourceSharepointDocumentItem = sourceSharepointItem as DocumentItem;

            if (sourceSharepointDocumentItem == null)
            {
                return;
            }

            var sharepointDataModifiedField = integrationItem.Fields[FieldNames.SharepointDataModified];

            if (sharepointDataModifiedField != null &&
                DateUtil.ToServerTime(new DateField(sharepointDataModifiedField).DateTime) == DateUtil.ToServerTime(System.Convert.ToDateTime(sourceSharepointDocumentItem["ows_Modified"]).ToUniversalTime()))
            {
                return;
            }

            IntegrationItemProvider.UpdateBlob(integrationItem, sourceSharepointDocumentItem, synchContext);
        }
Exemplo n.º 3
0
        public UpdateExpirationIntervalTests()
        {
            Item item = new ItemMock().AsConfigurationItem();

            this.itemId       = item.ID;
            this.synchContext = new SynchContext(item);
        }
Exemplo n.º 4
0
 public static string FormatIntegrationConfigItemID02([NotNull] SynchContext context)
 {
     Assert.ArgumentNotNull(context, "context");
     return(string.Format(
                LogMessages.IntegrationConfigItemID02,
                context.ParentID,
                FormatWeb01List23(context.IntegrationConfigData)));
 }
        private SynchContext CreateSynchContext(IntegrationConfigData integrationConfigData)
        {
            var id = ID.NewID;

            IntegrationCache.AddIntegrationConfigData(id, integrationConfigData, 0);
            var synchContext = new SynchContext(id, Substitute.For <Database>());

            return(synchContext);
        }
        public void should_run_sync_pipeline()
        {
            // Arrange
            using (var pipelines = new PipelinesHandler())
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());

                // Act
                IntegrationPipelinesRunner.SynchronizeTree(ProcessIntegrationItemsOptions.DefaultOptions, synchContext);

                // Assert
                pipelines.ShouldReceiveCall <SynchronizeTreeArgs>(PipelineNames.SynchronizeTree, x => x.Context == synchContext);
            }
        }
        public void should_not_throw_if_sync_pipeline_throws()
        {
            // Arrange
            using (new PipelinesHandler().ThrowInPipeline(PipelineNames.SynchronizeTree, new Exception("Pipeline is not work")))
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());

                // Act
                Action action = () => IntegrationPipelinesRunner.SynchronizeTree(ProcessIntegrationItemsOptions.DefaultOptions, synchContext);

                // Assert
                action.ShouldNotThrow();
            }
        }
Exemplo n.º 8
0
        public void should_be_not_successsfull_if_pipeline_throw_exception()
        {
            // Arrange
            using (new PipelinesHandler().ThrowInPipeline(PipelineNames.CreateIntegrationItem))
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());
                var action       = new CreateIntegrationItemAction(TestHelper.CreateSharepointItem(), synchContext, ProcessIntegrationItemsOptions.DefaultOptions);

                // Act
                action.Execute();

                // Assert
                action.IsSuccessful.Should().BeFalse();
            }
        }
        public void should_be_not_successsfull_if_pipeline_throw_exception()
        {
            // Arrange
            using (new PipelinesHandler().ThrowInPipeline(PipelineNames.DeleteIntegrationItem))
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());
                var action       = new DeleteIntegrationItemAction(new IntegrationItem(new ItemMock().AsIntegrationItem()), synchContext);

                // Act
                action.Execute();

                // Assert
                action.IsSuccessful.Should().BeFalse();
            }
        }
Exemplo n.º 10
0
        private MenuItemViewModel AddDatabaseEntry(IFile dbFile)
        {
            var id = dbFile.IdFromPath();

            var exists = Databases.FirstOrDefault(m => m.Id == dbFile.IdFromPath());

            if (exists != null)
            {
                return(exists);
            }

            var entry = new MenuItemViewModel
            {
                DisplayName = dbFile.Name,
                Id          = dbFile.IdFromPath(),
                Command     = new DelegateCommand(async() =>
                {
                    try
                    {
                        var db = await _cache.UnlockAsync(id, _credentialProvider);

                        if (db != null)
                        {
                            _navigator.GoToDatabaseView(db, db.Root);
                        }
                    }
                    catch (InvalidCredentialsException)
                    {
                        await _messageDialogs.InvalidCredentialsAsync();
                    }
                    catch (DatabaseUnlockException e)
                    {
                        await _messageDialogs.UnlockErrorAsync(e.Message);
                    }
                })
            };

            entry.RemoveCommand = new DelegateCommand(async() =>
            {
                await _cache.RemoveDatabaseAsync(dbFile);
            });

            SynchContext.Post(_ => Databases.Add(entry), null);

            return(entry);
        }
        public static ProcessSharepointItemArgs CreateSharepointItem(
            [NotNull] string sourceIntegrationItemName,
            [NotNull] ID sourceIntegrationItemTemplateID,
            [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(sourceIntegrationItemName, "sourceIntegrationItemName");
            Assert.ArgumentNotNull(sourceIntegrationItemTemplateID, "sourceIntegrationItemTemplateID");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var pipelineArgs = new ProcessSharepointItemArgs
            {
                SourceIntegrationItemName       = sourceIntegrationItemName,
                SourceIntegrationItemTemplateID = sourceIntegrationItemTemplateID,
                SynchContext = synchContext
            };

            return(CreateSharepointItem(pipelineArgs) ? pipelineArgs : null);
        }
        public static ProcessSharepointItemArgs UpdateSharepointItem(
            [NotNull] string sharepointItemID,
            [NotNull] Item sourceIntegrationItem,
            [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(sharepointItemID, "sharepointItemID");
            Assert.ArgumentNotNull(sourceIntegrationItem, "sourceIntegrationItem");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var pipelineArgs = new ProcessSharepointItemArgs
            {
                SharepointItemID      = sharepointItemID,
                SourceIntegrationItem = sourceIntegrationItem,
                SynchContext          = synchContext
            };

            return(UpdateSharepointItem(pipelineArgs) ? pipelineArgs : null);
        }
        public void should_log_if_sync_pipeline_throws()
        {
            // Arrange
            var exc = new Exception("Pipeline is not work");

            using (new PipelinesHandler().ThrowInPipeline(PipelineNames.SynchronizeTree, exc))
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());

                // Act
                var logWatcher = new LogWatcher(() => IntegrationPipelinesRunner.SynchronizeTree(ProcessIntegrationItemsOptions.DefaultOptions, synchContext));

                // Assert
                logWatcher.Ensure()
                .LevelIs(LogNotificationLevel.Error)
                .MessageIs(string.Format("Sharepoint Provider can't process tree.{2}Integration config item ID: {0}, {1}", synchContext.ParentID, "Web: server List: list", Environment.NewLine))
                .ExceptionIs(exc);
            }
        }
Exemplo n.º 14
0
        public void should_call_pipeline()
        {
            // Arrange
            using (var pipelines = new PipelinesHandler())
            {
                var synchContext   = new SynchContext(new ItemMock().AsConfigurationItem());
                var sharepointItem = TestHelper.CreateSharepointItem();
                var action         = new CreateIntegrationItemAction(sharepointItem, synchContext, ProcessIntegrationItemsOptions.DefaultOptions);

                // Act
                action.Execute();
                action.IsSuccessful.Should().BeTrue();

                // Assert
                pipelines.ShouldReceiveCall <ProcessIntegrationItemArgs>(
                    PipelineNames.CreateIntegrationItem,
                    x => x.SourceSharepointItem == sharepointItem && x.SynchContext == synchContext);
            }
        }
        public void should_correct_log_soap_exception()
        {
            // Arrange
            var document = new XmlDocument();

            document.LoadXml("<details>DetailsInfo</details>");
            var exc = new SoapException("Pipeline is not work", new XmlQualifiedName(), "actor", document.ChildNodes[0]);

            using (new PipelinesHandler().ThrowInPipeline(PipelineNames.SynchronizeTree, exc))
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());

                // Act
                var logWatcher = new LogWatcher(() => IntegrationPipelinesRunner.SynchronizeTree(ProcessIntegrationItemsOptions.DefaultOptions, synchContext));

                // Assert
                logWatcher.Ensure()
                .Message.Should()
                .EndWith(string.Format("{1}{0}", exc.Detail.InnerText, Environment.NewLine));
            }
        }
        public void should_call_pipeline()
        {
            // Arrange
            using (var pipelines = new PipelinesHandler())
            {
                var  deletedItem = new ItemMock();
                Item item        = new ItemMock().AsConfigurationItem().WithChild(deletedItem);

                var synchContext = new SynchContext(item);

                var action = new DeleteIntegrationItemAction(new IntegrationItem(deletedItem), synchContext);

                // Act
                action.Execute();
                action.IsSuccessful.Should().BeTrue();

                // Assert
                pipelines.ShouldReceiveCall <ProcessIntegrationItemArgs>(
                    PipelineNames.DeleteIntegrationItem,
                    x => x.IntegrationItemID == deletedItem.ID && x.SynchContext == synchContext);
            }
        }
Exemplo n.º 17
0
        public void should_call_pipeline()
        {
            // Arrange
            using (var pipelines = new PipelinesHandler())
            {
                var synchContext = new SynchContext(new ItemMock().AsConfigurationItem());

                Item sourceItem = new ItemMock().AsIntegrationItem();
                var  action     = new CreateSharepointItemAction(new IntegrationItem(sourceItem), synchContext);

                // Act
                action.Execute();
                action.IsSuccessful.Should().BeTrue();

                // Assert
                pipelines.ShouldReceiveCall <ProcessSharepointItemArgs>(
                    PipelineNames.CreateSharepointItem,
                    x =>
                    x.SourceIntegrationItem == sourceItem && x.SourceIntegrationItemTemplateID == sourceItem.TemplateID &&
                    x.SynchContext == synchContext);
            }
        }
        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);
        }
Exemplo n.º 19
0
        private void AddDatabaseEntry(IFile dbFile)
        {
            var id = dbFile.IdFromPath();

            var entry = new MenuItemViewModel
            {
                DisplayName = dbFile.Name,
                Command     = new DelegateCommand(async() =>
                {
                    try
                    {
                        var db = await _cache.UnlockAsync(id, _credentialProvider);

                        if (db != null)
                        {
                            _navigator.GoToDatabaseView(db, db.Root);
                        }
                    }
                    catch (InvalidCredentialsException)
                    {
                        await _messageDialogs.InvalidCredentialsAsync();
                    }
                    catch (DatabaseUnlockException e)
                    {
                        await _messageDialogs.UnlockErrorAsync(e.Message);
                    }
                })
            };

            entry.RemoveCommand = new DelegateCommand(async() =>
            {
                await _cache.RemoveDatabaseAsync(dbFile)
                .ContinueWith((t, o) => Databases.Remove(entry), SynchContext);
            });

            SynchContext.Post(_ => Databases.Add(entry), null);
        }
 protected SyncActionSafeBase(SynchContext synchContext)
 {
     this.SynchContext = synchContext;
 }
Exemplo n.º 21
0
 public CreateSharepointItemAction(IntegrationItem item, SynchContext synchContext)
     : base(item, synchContext)
 {
     Assert.IsTrue(this.Item.IsNew, "The item should be new");
 }
 public ComparableUpdateSharepointItemAction(ObjectModel.Entities.Items.BaseItem sharepointItem, IntegrationItem item, SynchContext synchContext)
     : base(sharepointItem, item, synchContext)
 {
 }
Exemplo n.º 23
0
 public UpdateSharepointItemAction(ObjectModel.Entities.Items.BaseItem sharepointItem, IntegrationItem item, SynchContext synchContext)
     : base(item, synchContext)
 {
     this.sharepointItem = sharepointItem;
 }
        public static void SynchronizeTree(ProcessIntegrationItemsOptions processIntegrationItemsOptions, SynchContext synchContext)
        {
            Assert.ArgumentNotNull(processIntegrationItemsOptions, "processIntegrationItemsOptions");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var pipelineArgs = new SynchronizeTreeArgs
            {
                Context = synchContext,
                Options = processIntegrationItemsOptions
            };

            SynchronizeTree(pipelineArgs);
        }
 protected IntegrationItemActionBase(IntegrationItem item, SynchContext synchContext)
     : base(synchContext)
 {
     this.Item = item;
 }
Exemplo n.º 26
0
 public ComparableDeleteSharepointItemAction(BaseItem sharepointItem, SynchContext synchContext)
     : base(sharepointItem, synchContext)
 {
 }
        public static ProcessSharepointItemArgs DeleteSharepointItem([NotNull] SharepointBaseItem sharepointItem, [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(sharepointItem, "sharepointItem");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var pipelineArgs = new ProcessSharepointItemArgs
            {
                SharepointItemID = sharepointItem.UniqueID,
                SharepointItem   = sharepointItem,
                SynchContext     = synchContext
            };

            return(DeleteSharepointItem(pipelineArgs) ? pipelineArgs : null);
        }
Exemplo n.º 28
0
 public DeleteIntegrationItemAction(IntegrationItem item, SynchContext synchContext)
     : base(item, synchContext)
 {
 }
        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);
        }
        public static ProcessSharepointItemArgs CreateSharepointItem([NotNull] IntegrationItem sourceIntegrationItem, [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(sourceIntegrationItem, "sourceIntegrationItem");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            var args = new ProcessSharepointItemArgs
            {
                SourceIntegrationItemName       = sourceIntegrationItem.Name,
                SourceIntegrationItem           = sourceIntegrationItem.InnerItem,
                SourceIntegrationItemTemplateID = sourceIntegrationItem.InnerItem.TemplateID,
                SynchContext = synchContext
            };

            return(CreateSharepointItem(args) ? args : null);
        }