public override void Execute()
{
foreach (SiteCollInfo siteCollInfo in Owner.WorkingSiteCollections)
{
using (var siteColl = Owner.ObjectsFactory.GetSite(siteCollInfo.URL))
{
foreach (SiteInfo siteInfo in siteCollInfo.Sites)
{
using (var web = siteColl.OpenWeb(siteInfo.ID))
{
var available = siteInfo.Lists;
//shuffle because of big lists
available.Shuffle();
foreach (ListInfo listInfo in available)
{
_titleUsage.Clear();
if (!listInfo.isLib)
{
var list = web.GetList(listInfo.Name);
if( listInfo.TemplateType == SPDGListTemplateType.Tasks )
{
Owner.IncrementCurrentTaskProgress("Start adding items to tasks list: " + listInfo.Name + " in site: " + web.Url,0);
}
else if (listInfo.TemplateType == SPDGListTemplateType.Events)
{
Owner.IncrementCurrentTaskProgress("Start adding events to calendar: " + listInfo.Name + " in site: " + web.Url,0);
}
else
{
Owner.IncrementCurrentTaskProgress("Start adding items to list: " + listInfo.Name + " in site: " + web.Url,0);
}
List<ISPDGListItemInfo> batch=new List<ISPDGListItemInfo>();
int itemCount = listInfo.isBigList ? WorkingDefinition.MaxNumberofItemsBigListToGenerate : WorkingDefinition.MaxNumberofItemsToGenerate;
itemCount = SampleData.GetRandomNumber(itemCount*3/4, itemCount);
for (int i = 0; i < itemCount; i++ )
{
var itemInfo=new SPDGListItemInfo();
if (listInfo.TemplateType == SPDGListTemplateType.Tasks)
{
populateTask(itemInfo);
}
else if (listInfo.TemplateType == SPDGListTemplateType.Events)
{
populateEvent(itemInfo);
}
else
{
populateItemInfo(list, itemInfo, false);
}
batch.Add(itemInfo);
if (batch.Count > 400)
{
list.AddItems(batch);
Owner.IncrementCurrentTaskProgress(string.Format("Created {0}/{1} items for list {2}: ", i + 1, itemCount, list.RootFolder.Url), batch.Count);
batch.Clear();
}
}
if (batch.Count > 0)
{
list.AddItems(batch);
Owner.IncrementCurrentTaskProgress(string.Format("Created {0} items for list {1}: ", itemCount, list.RootFolder.Url), batch.Count);
batch.Clear();
}
listInfo.ItemCount = itemCount;
}
else
{
_docsAdded = 0;
var list = web.GetList(listInfo.Name);
Owner.IncrementCurrentTaskProgress("Start adding documents to library: " + listInfo.Name + " in site: " + web.Url,0);
while (_docsAdded < WorkingDefinition.MaxNumberofDocumentLibraryItemsToGenerate)
{
addDocumentToFolder(list,list.RootFolder);
}
}
}
}
}
}
}
}