From fe2b0a96a55659fc18823aa27b6699f3d9c32bd2 Mon Sep 17 00:00:00 2001 From: Kalarumeth <70245579+Kalarumeth@users.noreply.github.com> Date: Sat, 9 Jul 2022 12:02:12 +0200 Subject: [PATCH] Minor Update --- console_spo_utils/Program.cs | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/console_spo_utils/Program.cs b/console_spo_utils/Program.cs index bc044a4..ba4ebb4 100644 --- a/console_spo_utils/Program.cs +++ b/console_spo_utils/Program.cs @@ -23,31 +23,6 @@ namespace SharePointOnlineUtils SecureString svcUserPsw = new NetworkCredential("", "$O,D1XBp1O5.OdjZt86#a=").SecurePassword; ProjectsByYearSite(siteCollection, svcUser, svcUserPsw); - - #region test - // Note: The PnP Sites Core AuthenticationManager class also supports this - /*Uri site = new Uri(siteCollection); - using (var authenticationManager = new AuthenticationManager()) - using (var ctx = authenticationManager.GetContext(site, svcUser, svcUserPsw)) - { - Web web = ctx.Web; - - //web.Description = ""; - //web.Update(); - - ctx.Load(web, - w => w.Title, - w => w.Description, - w => w.SiteGroups - ); - - await ctx.ExecuteQueryAsync(); - - Console.WriteLine($"Web: {web.Title}"); - Console.WriteLine($"Description: {web.Description}"); - Console.WriteLine($"Group: {web.SiteGroups}"); - }*/ - #endregion } public static async Task ProjectsByYearSite(string siteCollection, string user, SecureString psw) @@ -59,20 +34,20 @@ namespace SharePointOnlineUtils using (var authenticationManager = new AuthenticationManager()) using (var ctx = authenticationManager.GetContext(site, user, psw)) { - if (SPCheck.SiteExist(ctx) != false) + if (SharePointCustomOperation.SiteExist(ctx) != false) { Console.WriteLine($"{projectsYear} - Esiste già."); } else { Console.WriteLine($"{projectsYear} - Non esiste, a breve verrà generata."); - SPCheck.ProjectsYearGenerator(year, site, user, psw); + SharePointCustomOperation.ProjectsYearGenerator(year, site, user, psw); } } } } - public class SPCheck + public class SharePointCustomOperation { public static bool SiteExist(ClientContext ctx) { @@ -109,6 +84,7 @@ namespace SharePointOnlineUtils scp.Template = "SITEPAGEPUBLISHING#0"; SpoOperation spo = tenant.CreateSite(scp); + ctx.Load(tenant); ctx.Load(spo, i => i.IsComplete); ctx.ExecuteQuery(); @@ -129,6 +105,8 @@ namespace SharePointOnlineUtils } } } + + } public class AuthenticationManager : IDisposable