コード例 #1
0
        public bool UpdateItemsGuid(Item item)
        {
            IntegrationConfigData integrationData = null;

            try
            {
                integrationData = IntegrationConfigDataProvider.GetFromItem(item);

                Assert.IsNotNull(integrationData, "integrationData");

                var context = SpContextProviderBase.Instance.CreateDataContext(integrationData);
                var list    = BaseList.GetList(integrationData.Web, integrationData.List, context);

                Assert.IsNotNull(list, "list");

                var itemCollection = list.GetItems(new ItemsRetrievingOptions
                {
                    Folder    = integrationData.Folder,
                    ItemLimit = integrationData.ItemLimit,
                    ViewName  = integrationData.View
                });

                foreach (var listItem in itemCollection)
                {
                    var connectedItem = this.GetConnectedItem(item, listItem, list);

                    if (connectedItem != null)
                    {
                        using (new SecurityDisabler())
                        {
                            new IntegrationItem(connectedItem).GUID = listItem.GUID;
                        }

                        if (listItem is FolderItem)
                        {
                            this.UpdateItemsGuid(connectedItem);
                        }
                    }
                }

                return(true);
            }
            catch (Exception exception)
            {
                var errorMessage = new StringBuilder("Updating guids have been failed.");
                errorMessage.AppendLine(string.Format("Integration config item: {0}", item.ID));

                if (integrationData != null)
                {
                    errorMessage.AppendLine(LogMessageFormatter.FormatWeb01List23(integrationData));
                }

                Log.Error(errorMessage.ToString(), exception, this);

                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Set integration configuration data for integration folder or integration configuration item.
        /// </summary>
        /// <param name="synchContext">The synchronization context.</param>
        /// <param name="sourceSharepointFolderItem">The source.</param>
        /// <param name="targetIntegrationItem">The item  .</param>
        private static void UpdateIntegrationConfigData([NotNull] Item targetIntegrationItem, [NotNull] FolderItem sourceSharepointFolderItem, [NotNull] SynchContext synchContext)
        {
            Assert.ArgumentNotNull(targetIntegrationItem, "targetIntegrationItem");
            Assert.ArgumentNotNull(sourceSharepointFolderItem, "sourceSharepointFolderItem");
            Assert.ArgumentNotNull(synchContext, "synchContext");

            IntegrationConfigData integrationConfigData = synchContext.IntegrationConfigData.Clone();

            integrationConfigData.Folder = StringUtil.RemovePrefix('/', StringUtil.EnsurePostfix('/', synchContext.IntegrationConfigData.Folder) + sourceSharepointFolderItem.Title + "/");

            IntegrationConfigDataProvider.SaveToItem(integrationConfigData, targetIntegrationItem);
        }
コード例 #3
0
        protected bool UpdateIntegrationConfigData(Item item)
        {
            IntegrationConfigData integrationData = null;

            try
            {
                integrationData = IntegrationConfigDataProvider.GetFromItem(item);
                if (integrationData == null)
                {
                    return(true);
                }

                var context = SpContextProviderBase.Instance.CreateDataContext(integrationData);

                string listId;
                listId = BaseList.GetList(integrationData.Web, integrationData.List, context).ID;

                Assert.IsNotNullOrEmpty(listId, "listId");

                if (integrationData.List == listId)
                {
                    return(true);
                }
                integrationData.List = listId;

                IntegrationConfigDataProvider.SaveToItem(integrationData, item);
                IntegrationCache.RemoveIntegrationConfigData(item.ID);

                return(true);
            }
            catch (Exception exception)
            {
                var errorMessage = new StringBuilder("Updating integration config data has been failed.");
                errorMessage.AppendLine(string.Format("Integration config item: {0}", item.ID));
                if (integrationData != null)
                {
                    errorMessage.AppendLine(string.Format("SharePoint list: {0}{1}{2}", integrationData.Server.Trim('/'), StringUtil.EnsurePrefix('/', StringUtil.EnsurePostfix('/', integrationData.Web)), integrationData.List.Trim('/')));
                }

                Log.Error(errorMessage.ToString(), exception, this);

                return(false);
            }
        }
コード例 #4
0
        /// <exception cref="NullReferenceException">Throws <c>NullReferenceException</c> if Integration Config Data of the current Integration item is not specified.</exception>
        protected void Initialize()
        {
            CacheableIntegrationConfigData integrationConfigData = IntegrationCache.GetIntegrationConfigData(this.ParentID);

            if (integrationConfigData != null)
            {
                this.IntegrationConfigData = integrationConfigData.Data;
            }
            else
            {
                this.IntegrationConfigData = IntegrationConfigDataProvider.GetFromItem(this.ParentItem);
            }

            if (this.IntegrationConfigData == null)
            {
                string message = string.Format("Integration Config Data of Integration item \"{0}\" is not specified.", this.ParentItem.Paths.FullPath);
                throw new NullReferenceException(message);
            }
        }