public virtual void Process([NotNull] ProcessSharepointItemArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            Assert.IsNotNull(args.SharepointItem, "args.SharepointItem");
            Assert.IsNotNull(args.SourceIntegrationItem, "args.SourceIntegrationItem");
            Assert.IsNotNull(args.SynchContext, "args.SynchContext");

            SharepointItemProvider.UpdateItem(args.SourceIntegrationItem, args.SharepointItem, args.SynchContext);
        }
Beispiel #2
0
        public virtual void Process([NotNull] ProcessSharepointItemArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            Assert.IsNotNullOrEmpty(args.SourceIntegrationItemName, "args.SourceIntegrationItemName");
            Assert.IsNotNull(args.SourceIntegrationItemTemplateID, "args.SourceIntegrationItemTemplateID");
            Assert.IsNotNull(args.SynchContext, "args.SynchContext");

            TemplateItem templateItem = args.SynchContext.Database.GetTemplate(args.SourceIntegrationItemTemplateID);

            if (templateItem == null)
            {
                return;
            }

            TemplateFieldItem blobTemplateField = templateItem.GetField(FieldNames.Blob);

            if (blobTemplateField != null && blobTemplateField.Type.ToLower() == "attachment")
            {
                try
                {
                    var sourceItem = args.SourceIntegrationItem;
                    args.SharepointItem = SharepointItemProvider.CreateDocumentItem(args.SourceIntegrationItemName, args.SynchContext, sourceItem.Fields[FieldNames.Blob].GetBlobStream());

                    using (new EditContext(sourceItem))
                    {
                        if (sourceItem.Fields[FieldNames.SharepointDataModified] != null)
                        {
                            DateTime owsModified = Convert.ToDateTime(args.SharepointItem["ows_Modified"]);
                            sourceItem[FieldNames.SharepointDataModified] = DateUtil.ToIsoDate(owsModified);
                        }
                    }
                }
                catch (Exception e)
                {
                    args.AddMessage(e.Message);
                    args.AbortPipeline();
                }
            }

            if (args.SourceIntegrationItemTemplateID == TemplateIDs.IntegrationFolder)
            {
                args.SharepointItem = SharepointItemProvider.CreateFolderItem(args.SourceIntegrationItemName, args.SynchContext);
            }
        }