Offer
This commit is contained in:
+234
-99
@@ -23,7 +23,7 @@ namespace SharePointOnlineUtils
|
||||
public string Customer { get; set; }
|
||||
public string DeliveryReason { get; set; }
|
||||
public List<SubProj> SubProjects { get; set; }
|
||||
}
|
||||
}// TODO: Import variable from PP [C:\Sources\VS\web_portal\webapp_italsort\DataItalsortGestionale\ProjTable.cs]
|
||||
|
||||
public class SubProj
|
||||
{
|
||||
@@ -51,21 +51,31 @@ namespace SharePointOnlineUtils
|
||||
|
||||
#region General Variable
|
||||
string year = DateTime.Now.Year.ToString();
|
||||
string projectsYear = $"Commesse{year}";
|
||||
string listTitle = $"Lista Commesse {year}";
|
||||
string ssProjectTitle = "CT0001";
|
||||
string[] ssSubProjectTitle = { "CT0001-0001", "CT0001-0002", "CT0001-0003" };
|
||||
string varProjSiteName = $"Commesse {year}";
|
||||
string projectsYear = $"{varProjSiteName.Replace(" ", string.Empty)}";
|
||||
string listTitle = $"Lista {varProjSiteName}";
|
||||
string ssProjectTitle = "CT0016";
|
||||
string[] ssSubProjectTitle = { "CT0016-0001", "CT0016-0002", "CT0016-0003" };
|
||||
|
||||
Uri site = new Uri($"{siteCollection}/sites/{projectsYear}");
|
||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||
#endregion
|
||||
|
||||
//ProjectsByYearSite(listTitle, year, svcUser, site, svcUserPsw);
|
||||
Project(siteCollection, svcUser, svcUserPsw);
|
||||
spc.ProjectsYSite(varProjSiteName, site, svcUser, svcUserPsw);
|
||||
|
||||
#region Project
|
||||
//ProjectsByYearSite(listTitle, varProjSiteName, svcUser, site, svcUserPsw);
|
||||
//Project(siteCollection, svcUser, svcUserPsw);
|
||||
//SubProject(siteCollection, svcUser, svcUserPsw);
|
||||
#endregion
|
||||
|
||||
#region Offer
|
||||
Offer(siteCollection, svcUser, svcUserPsw);
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static async Task ProjectsByYearSite(string listTitle, string year, string user, Uri site, SecureString psw)
|
||||
#region Project
|
||||
public static async Task ProjectsByYearSite(string listTitle, string varProjSiteName, string user, Uri site, SecureString psw)
|
||||
{
|
||||
using (var authMgr = new AuthenticationManager())
|
||||
using (var ctx = authMgr.GetContext(site, user, psw))
|
||||
@@ -73,9 +83,9 @@ namespace SharePointOnlineUtils
|
||||
|
||||
if (spc.SiteExist(ctx) == false)
|
||||
{
|
||||
spc.ProjectsYSite(year, site, user, psw);
|
||||
spc.DomainGroupRights(ctx, "");
|
||||
spc.OnenoteSPFeature(ctx, "", "");
|
||||
spc.ProjectsYSite(varProjSiteName, site, user, psw);
|
||||
spc.DomainGroupRights(ctx, string.Empty);
|
||||
spc.OnenoteSPFeature(ctx, string.Empty, string.Empty);
|
||||
spc.ProjectsYField(ctx);
|
||||
spc.ProjectsYList(listTitle, ctx);
|
||||
spc.ProjectsYListView(listTitle, ctx);
|
||||
@@ -88,7 +98,7 @@ namespace SharePointOnlineUtils
|
||||
string year = DateTime.Now.Year.ToString();
|
||||
string projectsYear = $"Commesse{year}";
|
||||
string listTitle = $"Lista Commesse {year}";
|
||||
string ssProjectTitle = "CT0002";
|
||||
string ssProjectTitle = "CT0016";
|
||||
|
||||
Uri site = new Uri($"{siteCollection}/sites/{projectsYear}");
|
||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||
@@ -97,24 +107,20 @@ namespace SharePointOnlineUtils
|
||||
var ctx = authMgr.GetContext(site, user, psw);
|
||||
var sCtx = authMgr.GetContext(subSite, user, psw);
|
||||
|
||||
spc.WebPartPage(sCtx, subSite.ToString(), ssProjectTitle);
|
||||
|
||||
//if (spc.SiteExist(ctx) == true && spc.SiteExist(sCtx) == false)
|
||||
//{
|
||||
// #region Site Context
|
||||
// spc.ProjectSubSite(ssProjectTitle, projectsYear, ctx);
|
||||
// spc.OnenoteSPFeature(ctx, year, ssProjectTitle);
|
||||
// spc.ProjectListEntry(ssProjectTitle, listTitle, projectsYear, ctx);
|
||||
// #endregion
|
||||
|
||||
// #region SubSite Context
|
||||
// spc.ProjectDocLib(ssProjectTitle, sCtx);
|
||||
// spc.ProjectSubProjList(ssProjectTitle, sCtx);
|
||||
// spc.ProjectQuickMenu(ssProjectTitle, subSite.ToString(), sCtx);
|
||||
// #endregion
|
||||
//}
|
||||
|
||||
if (spc.SiteExist(ctx) == true && spc.SiteExist(sCtx) == false)
|
||||
{
|
||||
#region Site Context
|
||||
spc.ProjectSubSite(ssProjectTitle, projectsYear, ctx);
|
||||
spc.OnenoteSPFeature(ctx, year, ssProjectTitle);
|
||||
spc.ProjectListEntry(ssProjectTitle, listTitle, projectsYear, ctx);
|
||||
#endregion
|
||||
|
||||
#region SubSite Context
|
||||
spc.ProjectDocLib(ssProjectTitle, sCtx);
|
||||
spc.ProjectSubProjList(ssProjectTitle, sCtx);
|
||||
spc.ProjectQuickMenu(ssProjectTitle, subSite.ToString(), sCtx);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task SubProject(string siteCollection, string user, SecureString psw)
|
||||
@@ -122,18 +128,36 @@ namespace SharePointOnlineUtils
|
||||
string year = DateTime.Now.Year.ToString();
|
||||
string projectsYear = $"Commesse{year}";
|
||||
string listTitle = $"Lista Commesse {year}";
|
||||
string ssProjectTitle = "CT0001";
|
||||
string[] ssSubProjectTitle = { "CT0001-0001", "CT0001-0002", "CT0001-0003" };
|
||||
string ssProjectTitle = "CT0016";
|
||||
string[] ssSubProjectTitle = { "CT0016-0001", "CT0016-0002", "CT0016-0003" };
|
||||
|
||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||
|
||||
using (var authMgr = new AuthenticationManager())
|
||||
using (var ctx = authMgr.GetContext(subSite, user, psw))
|
||||
{
|
||||
spc.SubProjectDocSet(ssProjectTitle, ssSubProjectTitle, ctx);
|
||||
spc.SubProjectDocSet(ssProjectTitle, ssSubProjectTitle, ctx); //TODO: Controlare prima se esiste la commessa
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Offer
|
||||
public static async Task Offer(string siteCollection, string user, SecureString psw)
|
||||
{
|
||||
string year = "2021";//DateTime.Now.Year.ToString();
|
||||
string docLibName = $"Offerte {year}";
|
||||
|
||||
Uri site = new Uri($"{siteCollection}/sites/Offerte");
|
||||
|
||||
var authMgr = new AuthenticationManager();
|
||||
var ctx = authMgr.GetContext(site, user, psw);
|
||||
|
||||
if ( spc.SiteExist(ctx) && spc.ListExist(ctx, docLibName) == false )
|
||||
{
|
||||
spc.OfferDocLib(year, ctx);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SharePointCustomOperation
|
||||
@@ -154,7 +178,7 @@ namespace SharePointOnlineUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ListExist(string listTitle, ClientContext ctx)
|
||||
public static bool ListExist(ClientContext ctx, string listTitle)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -232,9 +256,9 @@ namespace SharePointOnlineUtils
|
||||
#endregion
|
||||
|
||||
#region Projects Years
|
||||
public static async Task ProjectsYSite(string year, Uri site, string user, SecureString psw)
|
||||
public static async Task ProjectsYSite(string siteName, Uri site, string user, SecureString psw)
|
||||
{
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione del sito '../Commesse{year}'.");
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione del sito '../{siteName.Replace(" ", string.Empty)}'.");
|
||||
|
||||
string siteAdmin = "https://italsortbuttrio-admin.sharepoint.com";
|
||||
|
||||
@@ -249,7 +273,7 @@ namespace SharePointOnlineUtils
|
||||
var scp = new SiteCreationProperties();
|
||||
|
||||
scp.Url = site.ToString();
|
||||
scp.Title = $"Commesse {year}";
|
||||
scp.Title = siteName;
|
||||
scp.Owner = user;
|
||||
scp.Template = "SITEPAGEPUBLISHING#0";
|
||||
|
||||
@@ -279,12 +303,10 @@ namespace SharePointOnlineUtils
|
||||
|
||||
public static async Task ProjectsYField(ClientContext ctx)
|
||||
{
|
||||
string xmlChoice = "<CHOICES><CHOICE>01 VENDITA MACCHINE / IMPIANTI</CHOICE><CHOICE>02 VENDITA RICAMBI</CHOICE><CHOICE>04 VENDITA SERVIZI FUORI COMMESSA</CHOICE><CHOICE>08 VENDITA RIPARAZIONI</CHOICE><CHOICE>09 ENGINEERING</CHOICE><CHOICE>11 VENDITA E LAVORAZ.CONTO TERZI</CHOICE><CHOICE>55 PREVENDITE</CHOICE><CHOICE>NC NON CONFORMITÁ</CHOICE></CHOICES>";
|
||||
|
||||
Dictionary<string, string[]> fieldList = new Dictionary<string, string[]>()
|
||||
{
|
||||
{ "PAL_ID_Project", new string[] { "URL", "ID Progetto", "PAL Field", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_DlvReason", new string[] { "Choice", "Causale", "PAL Field", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", xmlChoice } },
|
||||
{ "PAL_DlvReason", new string[] { "Choice", "Causale", "PAL Field", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "<CHOICES><CHOICE>01 VENDITA MACCHINE / IMPIANTI</CHOICE><CHOICE>02 VENDITA RICAMBI</CHOICE><CHOICE>04 VENDITA SERVIZI FUORI COMMESSA</CHOICE><CHOICE>08 VENDITA RIPARAZIONI</CHOICE><CHOICE>09 ENGINEERING</CHOICE><CHOICE>11 VENDITA E LAVORAZ.CONTO TERZI</CHOICE><CHOICE>55 PREVENDITE</CHOICE><CHOICE>NC NON CONFORMITÁ</CHOICE></CHOICES>" } },
|
||||
{ "PAL_Customer", new string[] { "Text", "Cliente", "PAL Field", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_Item", new string[] { "Text", "Item", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_ItemCode", new string[] { "Text", "Codice Articolo", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
@@ -494,15 +516,9 @@ namespace SharePointOnlineUtils
|
||||
Web web = ctx.Web;
|
||||
ctx.Load(web);
|
||||
|
||||
//if (libName.Contains("Commerciale"))
|
||||
//{
|
||||
// web.BreakRoleInheritance(false, true);
|
||||
// ctx.ExecuteQuery();
|
||||
//}
|
||||
|
||||
ListCreationInformation lci = new ListCreationInformation();
|
||||
lci.Title = libName;
|
||||
lci.TemplateType = (int)ListTemplateType.DocumentLibrary;
|
||||
lci.TemplateType = (int)ListTemplateType.DocumentLibrary; // TODO: PictureLibrary x Media
|
||||
List list = web.Lists.Add(lci);
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
@@ -510,17 +526,10 @@ namespace SharePointOnlineUtils
|
||||
if (libName.Contains("Commerciale")) DomainGroupRights(ctx, libName);
|
||||
Console.WriteLine($"> '{libName}' è stato creato con successo.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"!> Qualcosa è andato storto... {ex.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dir
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> folderName = new Dictionary<string, string>
|
||||
{
|
||||
{ "01_Costificazioni", $"Commerciale {ssProjectTitle}" },
|
||||
@@ -597,7 +606,7 @@ namespace SharePointOnlineUtils
|
||||
viewCreation.Title = listTitle;
|
||||
viewCreation.ViewTypeKind = ViewType.None;
|
||||
viewCreation.ColumnWidth = "350";
|
||||
viewCreation.ViewFields = new string[] { "Tipo", "Nome", "Descrizione", "Item", "Codice Articolo", "Descrizione Articolo", "Matricola Macchina", "Data/ora modifica", "Modificato da", "Versione", };
|
||||
viewCreation.ViewFields = new string[] { "Type", "Name", "Description", "Item", "Codice Articolo", "Descrizione Articolo", "Matricola Macchina", "Modified", "Editor", "Version", };
|
||||
|
||||
var view = views.Add(viewCreation);
|
||||
|
||||
@@ -624,6 +633,8 @@ namespace SharePointOnlineUtils
|
||||
}
|
||||
|
||||
public static async Task ProjectQuickMenu(string ssProjectTitle, string subSiteUrl, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> itemQuickMenu = new Dictionary<string, string>
|
||||
{
|
||||
@@ -636,7 +647,7 @@ namespace SharePointOnlineUtils
|
||||
NavigationNodeCollection spNavNodeColl = ctx.Web.Navigation.QuickLaunch;
|
||||
NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();
|
||||
|
||||
ctx.Load(ctx.Web);
|
||||
ctx.Load(ctx.Web, w => w.RootFolder.WelcomePage);
|
||||
|
||||
foreach (KeyValuePair<string, string> item in itemQuickMenu)
|
||||
{
|
||||
@@ -646,19 +657,26 @@ namespace SharePointOnlineUtils
|
||||
newNavNode.AsLastNode = true;
|
||||
spNavNodeColl.Add(newNavNode);
|
||||
|
||||
try
|
||||
{
|
||||
ctx.ExecuteQuery();
|
||||
Console.WriteLine($"> Il menu rapido è stato aggiornato in {ssProjectTitle}");
|
||||
|
||||
|
||||
if (item.Key == $"SottoCommesse {ssProjectTitle}")
|
||||
{
|
||||
ctx.Web.RootFolder.WelcomePage = $"SottoCommesse%20{ssProjectTitle}/Forms/SottoCommesse%20{ssProjectTitle}.aspx";
|
||||
|
||||
ctx.Web.RootFolder.Update();
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} )"); return; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SubProject
|
||||
public static async Task SubProjectDocSet(string ssProjectTitle, string[] ssSubProjectTitle, ClientContext ctx) //TODO: da impostare le variabili generali
|
||||
#region Sub Project
|
||||
public static async Task SubProjectDocSet(string ssProjectTitle, string[] ssSubProjectTitle, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -701,7 +719,7 @@ namespace SharePointOnlineUtils
|
||||
{
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione per {spt}.");
|
||||
|
||||
#region DocSet & Field value
|
||||
#region DocSet Field Entry
|
||||
|
||||
DocumentSet.Create(ctx, list.RootFolder, spt, contentType.Id);
|
||||
ctx.ExecuteQuery();
|
||||
@@ -749,6 +767,124 @@ namespace SharePointOnlineUtils
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Offer
|
||||
public static async Task OfferField(ClientContext ctx) // Set to run manualy or if Offerte doesn't exist (se non dovesse essistere qualche mano lesta lo ha cancellato)
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string[]> fieldList = new Dictionary<string, string[]>()
|
||||
{
|
||||
{ "PAL_Offers_Reason", new string[] { "Choice", "Causale", "PAL Field", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", "<CHOICES><CHOICE>01 VENDITA MACCHINE / IMPIANTI</CHOICE><CHOICE>02 VENDITA RICAMBI</CHOICE><CHOICE>04 VENDITA SERVIZI FUORI COMMESSA</CHOICE><CHOICE>08 VENDITA RIPARAZIONI</CHOICE><CHOICE>09 ENGINEERING</CHOICE><CHOICE>11 VENDITA E LAVORAZ.CONTO TERZI</CHOICE><CHOICE>55 PREVENDITE</CHOICE><CHOICE>NC NON CONFORMITÁ</CHOICE></CHOICES>" } },
|
||||
{ "PAL_Customer", new string[] { "Text", "Cliente", "PAL Field", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_ID_Offer", new string[] { "Text", "Codice Articolo", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_Offers_Name", new string[] { "Text", "Item", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_Authors", new string[] { "Text", "Descrizione Articolo", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } }
|
||||
};
|
||||
|
||||
var site = ctx.Site;
|
||||
ctx.Load(site, w => w.RootWeb, w => w.RootWeb.Fields);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (KeyValuePair<string, string[]> f in fieldList)
|
||||
{
|
||||
var fieldXml = $"<Field Name='{f.Key}' Type='{f.Value[0]}' Description='' DisplayName='{f.Value[1]}' StaticName='{f.Key}' Group='{f.Value[2]}' Hidden='{f.Value[3]}' Required='{f.Value[4]}' Sealed='{f.Value[5]}' ShowInDisplayForm='{f.Value[6]}' ShowInEditForm='{f.Value[7]}' ShowInNewForm='{f.Value[8]}'>{f.Value[9]}</Field>";
|
||||
site.RootWeb.Fields.AddFieldAsXml(fieldXml, false, AddFieldOptions.AddToDefaultContentType);
|
||||
|
||||
ctx.Load(site.RootWeb.Fields);
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} )"); return; }
|
||||
}
|
||||
|
||||
public static async Task OfferDocLib(string year, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
string docLibName = $"Offerte {year}";
|
||||
#region New DocLib
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione '{docLibName}'.");
|
||||
|
||||
Web web = ctx.Web;
|
||||
ctx.Load(web, w => w.RootFolder.WelcomePage, w => w.Url);
|
||||
|
||||
ListCreationInformation lci = new ListCreationInformation();
|
||||
lci.Title = docLibName;
|
||||
lci.TemplateType = (int)ListTemplateType.DocumentLibrary;
|
||||
List list = web.Lists.Add(lci);
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
Console.WriteLine($"> Completata la fase di creazione '{docLibName}'.");
|
||||
#endregion
|
||||
|
||||
DomainGroupRights(ctx, docLibName);
|
||||
|
||||
#region Shortcut on Quickmenu
|
||||
|
||||
NavigationNodeCollection spNavNodeColl = web.Navigation.QuickLaunch;
|
||||
NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();
|
||||
|
||||
newNavNode.Title = $"{docLibName}";
|
||||
newNavNode.Url = $"{web.Url}/Offerte%20{year}";
|
||||
newNavNode.AsLastNode = true;
|
||||
spNavNodeColl.Add(newNavNode);
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Il menu rapido è stato aggiornato, il collegamemento a {docLibName} è ora disponibile.");
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ Console.WriteLine($"!> Qualcosa è andato storto... {ex.Message}"); return; }
|
||||
}
|
||||
|
||||
public static async Task OfferDocSet(string year, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region Context
|
||||
var listTitle = $"Offerte {year}";
|
||||
var web = ctx.Web;
|
||||
ctx.Load(web, w => w.Url);
|
||||
var list = web.Lists.GetByTitle(listTitle);
|
||||
ctx.Load(list, l => l.RootFolder, l => l.ContentTypes, l => l.Fields, l => l.ContentTypesEnabled);
|
||||
ctx.ExecuteQuery();
|
||||
list.ContentTypesEnabled = true;
|
||||
list.Update();
|
||||
|
||||
if (ListContentTypeExist(ctx, listTitle, "Set di documenti") == false)
|
||||
{
|
||||
var documentCT = ctx.Site.RootWeb.AvailableContentTypes.GetById("0x0120D5");
|
||||
ctx.Load(documentCT);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
var ctDocSet = new ContentTypeCreationInformation()
|
||||
{
|
||||
Name = "Set di documenti",
|
||||
ParentContentType = documentCT
|
||||
};
|
||||
list.ContentTypes.Add(ctDocSet);
|
||||
|
||||
list.Update();
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
var ctData = list.ContentTypes.Where(c => c.Name == "Set di documenti");
|
||||
var contentType = ctData.FirstOrDefault();
|
||||
ctx.Load(contentType);
|
||||
ctx.ExecuteQuery();
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} )");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SPFeature
|
||||
public static async Task OnenoteSPFeature(ClientContext ctx, string year, string ssProjectTitle)
|
||||
{
|
||||
@@ -853,7 +989,6 @@ namespace SharePointOnlineUtils
|
||||
|
||||
foreach (KeyValuePair<string, string> role in itsADGruopSalesRole)
|
||||
{
|
||||
|
||||
var adGroup = web.EnsureUser(role.Key);
|
||||
ctx.Load(adGroup);
|
||||
|
||||
@@ -876,27 +1011,27 @@ namespace SharePointOnlineUtils
|
||||
|
||||
#region WebParts
|
||||
|
||||
public static void WebPartPage(ClientContext ctx, string sitePath, string ssProjectTitle)
|
||||
{
|
||||
var homeLocation = $"{sitePath}/SitePages/Home.aspx";
|
||||
string[] listName = { $"Documenti {ssProjectTitle}", $"Media {ssProjectTitle}", $"SottoCommesse {ssProjectTitle}", $"Commerciale {ssProjectTitle}" };
|
||||
//public static void WebPartPage(ClientContext ctx, string sitePath, string ssProjectTitle)
|
||||
//{
|
||||
// var homeLocation = $"{sitePath}/SitePages/Home.aspx";
|
||||
// string[] listName = { $"Documenti {ssProjectTitle}", $"Media {ssProjectTitle}", $"SottoCommesse {ssProjectTitle}", $"Commerciale {ssProjectTitle}" };
|
||||
|
||||
try
|
||||
{
|
||||
foreach (string item in listName)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// foreach (string item in listName)
|
||||
// {
|
||||
|
||||
|
||||
List list = ctx.Web.Lists.GetByTitle(item);
|
||||
ctx.Load(list, l => l.Id);
|
||||
ctx.ExecuteQuery();
|
||||
//Console.WriteLine(viewList);
|
||||
// List list = ctx.Web.Lists.GetByTitle(item);
|
||||
// ctx.Load(list, l => l.Id);
|
||||
// ctx.ExecuteQuery();
|
||||
// //Console.WriteLine(viewList);
|
||||
|
||||
//AddWebPart(ctx, homeLocation, viewList.HtmlSchemaXml);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
||||
}
|
||||
// //AddWebPart(ctx, homeLocation, viewList.HtmlSchemaXml);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
||||
//}
|
||||
|
||||
//private static void CreateWebPartPage(this SPWeb web, List list, string pageName, int layoutTemplate)
|
||||
//{
|
||||
@@ -917,30 +1052,30 @@ namespace SharePointOnlineUtils
|
||||
// var result = web.ProcessBatchData(newWPPageBatchXml);
|
||||
//}
|
||||
|
||||
public static void AddWebPart(ClientContext context, string pageUrl, string xml)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine("Start");
|
||||
//public static void AddWebPart(ClientContext context, string pageUrl, string xml)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// Console.WriteLine("Start");
|
||||
|
||||
var page = context.Web.GetFileByUrl(pageUrl);
|
||||
var webpartManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
|
||||
context.Load(webpartManager, w => w.WebParts);
|
||||
context.ExecuteQuery();
|
||||
// var page = context.Web.GetFileByUrl(pageUrl);
|
||||
// var webpartManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
|
||||
// context.Load(webpartManager, w => w.WebParts);
|
||||
// context.ExecuteQuery();
|
||||
|
||||
|
||||
WebPartDefinition webpartDef = webpartManager.ImportWebPart(xml);
|
||||
WebPartDefinition webpart = webpartManager.AddWebPart(webpartDef.WebPart, "mainContent", 0);
|
||||
context.Load(webpartDef);
|
||||
context.ExecuteQuery();
|
||||
// WebPartDefinition webpartDef = webpartManager.ImportWebPart(xml);
|
||||
// WebPartDefinition webpart = webpartManager.AddWebPart(webpartDef.WebPart, "mainContent", 0);
|
||||
// context.Load(webpartDef);
|
||||
// context.ExecuteQuery();
|
||||
|
||||
//webpartManager.ImportWebPart(xmlWP);
|
||||
//context.ExecuteQuery();
|
||||
// //webpartManager.ImportWebPart(xmlWP);
|
||||
// //context.ExecuteQuery();
|
||||
|
||||
Console.WriteLine("End");
|
||||
}
|
||||
catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
||||
}
|
||||
// Console.WriteLine("End");
|
||||
// }
|
||||
// catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
||||
//}
|
||||
|
||||
//protected void ReplaceWebPartsWithAppParts(ClientContext ctx)
|
||||
//{
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
"PnP.Core": "1.7.0",
|
||||
"PnP.Core.Admin": "1.7.0",
|
||||
"PnP.Core.Auth": "1.7.0",
|
||||
"SharePointPnP.IdentityModel.Extensions": "1.2.4",
|
||||
"SharePointPnPCoreOnline": "3.28.2012",
|
||||
"SharePointPnPModernizationOnline": "1.0.2012",
|
||||
"System.IdentityModel.Tokens.Jwt": "6.22.0"
|
||||
},
|
||||
"runtime": {
|
||||
@@ -35,17 +33,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"AngleSharp.Css/0.14.2": {
|
||||
"dependencies": {
|
||||
"AngleSharp": "0.14.0"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/AngleSharp.Css.dll": {
|
||||
"assemblyVersion": "0.14.2.0",
|
||||
"fileVersion": "0.14.2.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.ApplicationInsights/2.16.0": {
|
||||
"dependencies": {
|
||||
"System.Diagnostics.DiagnosticSource": "6.0.0"
|
||||
@@ -887,20 +874,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"SharePointPnPModernizationOnline/1.0.2012": {
|
||||
"dependencies": {
|
||||
"AngleSharp.Css": "0.14.2",
|
||||
"Microsoft.ApplicationInsights": "2.16.0",
|
||||
"Microsoft.Extensions.Caching.Memory": "6.0.0",
|
||||
"SharePointPnPCoreOnline": "3.28.2012"
|
||||
},
|
||||
"runtime": {
|
||||
"lib/net461/SharePointPnP.Modernization.Framework.dll": {
|
||||
"assemblyVersion": "1.0.2012.0",
|
||||
"fileVersion": "1.0.2012.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"System.AppContext/4.1.0": {
|
||||
"dependencies": {
|
||||
"System.Runtime": "4.3.0"
|
||||
@@ -1883,13 +1856,6 @@
|
||||
"path": "anglesharp/0.14.0",
|
||||
"hashPath": "anglesharp.0.14.0.nupkg.sha512"
|
||||
},
|
||||
"AngleSharp.Css/0.14.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-2USpPu9V/+1iBwHpanBsqr1eR+3vxKe19ZsnejbZfxNOadsMvUUkJ+0OjMsQmT0ExSW4vjCKXq9K/JWv0ie8JQ==",
|
||||
"path": "anglesharp.css/0.14.2",
|
||||
"hashPath": "anglesharp.css.0.14.2.nupkg.sha512"
|
||||
},
|
||||
"Microsoft.ApplicationInsights/2.16.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
@@ -2394,13 +2360,6 @@
|
||||
"path": "sharepointpnpcoreonline/3.28.2012",
|
||||
"hashPath": "sharepointpnpcoreonline.3.28.2012.nupkg.sha512"
|
||||
},
|
||||
"SharePointPnPModernizationOnline/1.0.2012": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-YLjjZD2+1lfzlPn/e3VAfTmVVkH92jRqhMbdXOocRmIaa/U5hsjkJwt9xDoSDo6TiNfvRx2GyMjB4yd5Eq3+Lg==",
|
||||
"path": "sharepointpnpmodernizationonline/1.0.2012",
|
||||
"hashPath": "sharepointpnpmodernizationonline.1.0.2012.nupkg.sha512"
|
||||
},
|
||||
"System.AppContext/4.1.0": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
|
||||
@@ -154,5 +154,3 @@ C:\Sources\VS\console_spo_utils\console_spo_utils\bin\Debug\net6.0\runtimes\unix
|
||||
C:\Sources\VS\console_spo_utils\console_spo_utils\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Drawing.Common.dll
|
||||
C:\Sources\VS\console_spo_utils\console_spo_utils\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Security.Cryptography.ProtectedData.dll
|
||||
C:\Sources\VS\console_spo_utils\console_spo_utils\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Windows.Extensions.dll
|
||||
C:\Sources\VS\console_spo_utils\console_spo_utils\bin\Debug\net6.0\AngleSharp.Css.dll
|
||||
C:\Sources\VS\console_spo_utils\console_spo_utils\bin\Debug\net6.0\SharePointPnP.Modernization.Framework.dll
|
||||
|
||||
Reference in New Issue
Block a user