Exemplo n.º 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);
            }
        }