diff --git a/.vs/console_spo_utils/FileContentIndex/aa388625-63fe-490a-b358-0e1b49fe4766.vsidx b/.vs/console_spo_utils/FileContentIndex/aa388625-63fe-490a-b358-0e1b49fe4766.vsidx new file mode 100644 index 0000000..c3be2b2 Binary files /dev/null and b/.vs/console_spo_utils/FileContentIndex/aa388625-63fe-490a-b358-0e1b49fe4766.vsidx differ diff --git a/.vs/console_spo_utils/FileContentIndex/db305bde-7b9a-474b-8075-2467725ef940.vsidx b/.vs/console_spo_utils/FileContentIndex/db305bde-7b9a-474b-8075-2467725ef940.vsidx deleted file mode 100644 index dea7c2c..0000000 Binary files a/.vs/console_spo_utils/FileContentIndex/db305bde-7b9a-474b-8075-2467725ef940.vsidx and /dev/null differ diff --git a/console_spo_utils/Program.cs b/console_spo_utils/Program.cs index 91cdabd..bc044a4 100644 --- a/console_spo_utils/Program.cs +++ b/console_spo_utils/Program.cs @@ -52,7 +52,8 @@ namespace SharePointOnlineUtils public static async Task ProjectsByYearSite(string siteCollection, string user, SecureString psw) { - string projectsYear = "Commesse" + DateTime.Now.Year.ToString(); + string year = DateTime.Now.Year.ToString(); + string projectsYear = "Commesse" + year; Uri site = new Uri(siteCollection + "/sites/" + projectsYear); using (var authenticationManager = new AuthenticationManager()) @@ -65,7 +66,7 @@ namespace SharePointOnlineUtils else { Console.WriteLine($"{projectsYear} - Non esiste, a breve verrà generata."); - SPCheck.ProjectsYearGenerator(site, projectsYear, siteCollection, user, psw); + SPCheck.ProjectsYearGenerator(year, site, user, psw); } } } @@ -88,36 +89,11 @@ namespace SharePointOnlineUtils } } - public static async Task ProjectsYearGenerator(Uri site, string projectsYear, string sitePath, string user, SecureString psw) + public static async Task ProjectsYearGenerator(string year, Uri site, string user, SecureString psw) { - #region old - //Uri site = new Uri(siteCollection); - //using (var authenticationManager = new AuthenticationManager()) - //using (var ctx = authenticationManager.GetContext(site, user, psw)) - //{ - // try - // { - // WebCreationInformation creation = new WebCreationInformation() - // { - // Title = projectsYear, - // Url = projectsYear - // }; - // - // Web newWeb = ctx.; - // - // ctx.Load(newWeb, w => w.Title); - // ctx.ExecuteQuery(); - // - // Console.WriteLine($"Il sito è stato creato con successo.\n{site}/sites/{projectsYear}"); - // } - // catch (Exception ex) - // { - // Console.WriteLine($"Non è stato possibile creare la pagina: {ex.Message}"); - // } - // - //} - #endregion - Uri path = new Uri(sitePath); + string siteAdmin = "https://italsortbuttrio-admin.sharepoint.com"; + + Uri path = new Uri(siteAdmin); using (var authenticationManager = new AuthenticationManager()) using (var ctx = authenticationManager.GetContext(path, user, psw)) @@ -128,8 +104,9 @@ namespace SharePointOnlineUtils var scp = new SiteCreationProperties(); scp.Url = site.ToString(); - scp.Title = projectsYear; + scp.Title = "Commesse " + year; scp.Owner = user; + scp.Template = "SITEPAGEPUBLISHING#0"; SpoOperation spo = tenant.CreateSite(scp); ctx.Load(tenant); @@ -138,7 +115,7 @@ namespace SharePointOnlineUtils while (!spo.IsComplete) { - //Wait for 30 seconds and then try again + Console.WriteLine($"Il sito '../{scp.Title}' è in fase di creazione."); System.Threading.Thread.Sleep(30000); spo.RefreshLoad(); ctx.ExecuteQuery(); @@ -148,7 +125,7 @@ namespace SharePointOnlineUtils } catch (Exception ex) { - Console.WriteLine("Xe da qualcosa storto. " + ex.Message); + Console.WriteLine("Qualcosa è andato storto. (" + ex.Message + ")"); } } }