private void CreateSiteCollection(SPWebApplication webApp) { string sitCollName = ""; string url = ""; string baseName = ""; findAvailableSiteCollectionName(webApp, out sitCollName, out url, out baseName); Owner.IncrementCurrentTaskProgress("Creating site collection '" + url + "'"); SPSiteCollection siteCollections = webApp.Sites; SPSite site = siteCollections.Add("/sites/" + url, WorkingDefinition.SiteCollOwnerLogin, WorkingDefinition.SiteCollOwnerEmail); SPWeb web = site.RootWeb; web.Title = sitCollName; web.Update(); SiteCollInfo siteCollInfo = new SiteCollInfo(); siteCollInfo.URL = site.Url; Owner.WorkingSiteCollections.Add(siteCollInfo); }
public virtual bool startDataGeneration() { try { Log.Write("*** SHAREPOINT DATA GENERATION SESSION STARTS ***"); //if we are using and existing site collection and not creating any new ones if (!string.IsNullOrEmpty(WorkingDefinition.SiteCollection)) { SiteCollInfo siteCollInfo = new SiteCollInfo(); siteCollInfo.URL = WorkingDefinition.SiteCollection; siteCollInfo.Sites = getSitesForSiteCollection(); WorkingSiteCollections.Add(siteCollInfo); } _overallProgressMaxSteps = _tasks.Count(); foreach (var task in _tasks) { if (task.IsActive) { var totalSteps = task.CalculateTotalSteps(); updateProgressOverall(task.Title, totalSteps); task.Execute(); } } Log.Write("*** SHAREPOINT DATA GENERATION SESSION COMPLETED ***"); return(true); } catch (Exception ex) { Errors.Log(ex); } return(false); }
public override void Execute() { var helper = _generator.DataHelper; HashSet<string> existingSites = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (var siteCollectionUrl in helper.GetAllSiteCollections(Guid.Empty)) { existingSites.Add(siteCollectionUrl); } for (int s = 0; s < WorkingDefinition.CreateNewSiteCollections; s++) { string siteName = ""; string siteUrl = ""; string leafName = ""; int i = 0; string baseName = ""; do { siteName = SampleData.GetRandomName(SampleData.Companies, SampleData.Offices, null, ref i, out baseName); leafName = Utils.GenerateSlug(siteName, 25); siteUrl = string.Format("https://{0}.sharepoint.com/sites/{1}", WorkingDefinition.TenantName, leafName); } while (existingSites.Contains(siteUrl)); Owner.IncrementCurrentTaskProgress("Creating site collection '" + siteUrl + "'"); var owner = WorkingDefinition.SiteCollOwnerLogin; if (string.IsNullOrEmpty(owner)) { owner = WorkingDefinition.Username; } helper.CreateNewSiteCollection(siteName, leafName, owner); SiteCollInfo siteCollInfo = new SiteCollInfo(); siteCollInfo.URL = siteUrl; Owner.WorkingSiteCollections.Add(siteCollInfo); } }
public override void Execute() { var helper = _generator.DataHelper; HashSet <string> existingSites = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (var siteCollectionUrl in helper.GetAllSiteCollections(Guid.Empty)) { existingSites.Add(siteCollectionUrl); } for (int s = 0; s < WorkingDefinition.CreateNewSiteCollections; s++) { string siteName = ""; string siteUrl = ""; string leafName = ""; int i = 0; string baseName = ""; do { siteName = SampleData.GetRandomName(SampleData.Companies, SampleData.Offices, null, ref i, out baseName); leafName = Utils.GenerateSlug(siteName, 25); siteUrl = string.Format("https://{0}.sharepoint.com/sites/{1}", WorkingDefinition.TenantName, leafName); } while (existingSites.Contains(siteUrl)); Owner.IncrementCurrentTaskProgress("Creating site collection '" + siteUrl + "'"); var owner = WorkingDefinition.SiteCollOwnerLogin; if (string.IsNullOrEmpty(owner)) { owner = WorkingDefinition.Username; } helper.CreateNewSiteCollection(siteName, leafName, owner); SiteCollInfo siteCollInfo = new SiteCollInfo(); siteCollInfo.URL = siteUrl; Owner.WorkingSiteCollections.Add(siteCollInfo); } }