/// <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);
        }
Esempio n. 2
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);
            }
        }