Acceleratio.SPDG.Generator.Server.GenerationTasks.CreateContentTypesGenerationTask.AddCustomContentTypesToLists C# (CSharp) Метод

AddCustomContentTypesToLists() публичный Метод

public AddCustomContentTypesToLists ( ) : void
Результат void
        public void AddCustomContentTypesToLists()
        {
            foreach (SiteCollInfo siteCollInfo in Owner.WorkingSiteCollections)
            {
                using (SPSite siteColl = new SPSite(siteCollInfo.URL))
                {
                    foreach (SiteInfo siteInfo in siteCollInfo.Sites)
                    {
                        using (SPWeb web = siteColl.OpenWeb(siteInfo.ID))
                        {
                            Log.Write("Applying Content Types to lists for site: " + web.Url);
                            int listCount = web.Lists.Count;
                            if (listCount == 0)
                            {
                                continue;
                            }

                            foreach (SPContentType contentType in _newContentTypes)
                            {
                                for (int i = 0; i < (listCount * _contentTypeListAssignmentModifier); i++)
                                {
                                    var listIndex = SampleData.GetRandomNumber(0, listCount);
                                    if (!web.Lists[listIndex].ContentTypesEnabled)
                                    {
                                        continue;
                                    }

                                    if (web.Lists[listIndex].ContentTypes[contentType.Name] == null)
                                    {
                                        web.Lists[listIndex].ContentTypes.Add(contentType);
                                    }
                                }
                            }

                        }
                    }
                }
            }
        }