Offer
This commit is contained in:
+235
-100
@@ -23,7 +23,7 @@ namespace SharePointOnlineUtils
|
|||||||
public string Customer { get; set; }
|
public string Customer { get; set; }
|
||||||
public string DeliveryReason { get; set; }
|
public string DeliveryReason { get; set; }
|
||||||
public List<SubProj> SubProjects { 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
|
public class SubProj
|
||||||
{
|
{
|
||||||
@@ -51,21 +51,31 @@ namespace SharePointOnlineUtils
|
|||||||
|
|
||||||
#region General Variable
|
#region General Variable
|
||||||
string year = DateTime.Now.Year.ToString();
|
string year = DateTime.Now.Year.ToString();
|
||||||
string projectsYear = $"Commesse{year}";
|
string varProjSiteName = $"Commesse {year}";
|
||||||
string listTitle = $"Lista Commesse {year}";
|
string projectsYear = $"{varProjSiteName.Replace(" ", string.Empty)}";
|
||||||
string ssProjectTitle = "CT0001";
|
string listTitle = $"Lista {varProjSiteName}";
|
||||||
string[] ssSubProjectTitle = { "CT0001-0001", "CT0001-0002", "CT0001-0003" };
|
string ssProjectTitle = "CT0016";
|
||||||
|
string[] ssSubProjectTitle = { "CT0016-0001", "CT0016-0002", "CT0016-0003" };
|
||||||
|
|
||||||
Uri site = new Uri($"{siteCollection}/sites/{projectsYear}");
|
Uri site = new Uri($"{siteCollection}/sites/{projectsYear}");
|
||||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//ProjectsByYearSite(listTitle, year, svcUser, site, svcUserPsw);
|
spc.ProjectsYSite(varProjSiteName, site, svcUser, svcUserPsw);
|
||||||
Project(siteCollection, svcUser, svcUserPsw);
|
|
||||||
|
#region Project
|
||||||
|
//ProjectsByYearSite(listTitle, varProjSiteName, svcUser, site, svcUserPsw);
|
||||||
|
//Project(siteCollection, svcUser, svcUserPsw);
|
||||||
//SubProject(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 authMgr = new AuthenticationManager())
|
||||||
using (var ctx = authMgr.GetContext(site, user, psw))
|
using (var ctx = authMgr.GetContext(site, user, psw))
|
||||||
@@ -73,9 +83,9 @@ namespace SharePointOnlineUtils
|
|||||||
|
|
||||||
if (spc.SiteExist(ctx) == false)
|
if (spc.SiteExist(ctx) == false)
|
||||||
{
|
{
|
||||||
spc.ProjectsYSite(year, site, user, psw);
|
spc.ProjectsYSite(varProjSiteName, site, user, psw);
|
||||||
spc.DomainGroupRights(ctx, "");
|
spc.DomainGroupRights(ctx, string.Empty);
|
||||||
spc.OnenoteSPFeature(ctx, "", "");
|
spc.OnenoteSPFeature(ctx, string.Empty, string.Empty);
|
||||||
spc.ProjectsYField(ctx);
|
spc.ProjectsYField(ctx);
|
||||||
spc.ProjectsYList(listTitle, ctx);
|
spc.ProjectsYList(listTitle, ctx);
|
||||||
spc.ProjectsYListView(listTitle, ctx);
|
spc.ProjectsYListView(listTitle, ctx);
|
||||||
@@ -88,7 +98,7 @@ namespace SharePointOnlineUtils
|
|||||||
string year = DateTime.Now.Year.ToString();
|
string year = DateTime.Now.Year.ToString();
|
||||||
string projectsYear = $"Commesse{year}";
|
string projectsYear = $"Commesse{year}";
|
||||||
string listTitle = $"Lista Commesse {year}";
|
string listTitle = $"Lista Commesse {year}";
|
||||||
string ssProjectTitle = "CT0002";
|
string ssProjectTitle = "CT0016";
|
||||||
|
|
||||||
Uri site = new Uri($"{siteCollection}/sites/{projectsYear}");
|
Uri site = new Uri($"{siteCollection}/sites/{projectsYear}");
|
||||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||||
@@ -97,24 +107,20 @@ namespace SharePointOnlineUtils
|
|||||||
var ctx = authMgr.GetContext(site, user, psw);
|
var ctx = authMgr.GetContext(site, user, psw);
|
||||||
var sCtx = authMgr.GetContext(subSite, user, psw);
|
var sCtx = authMgr.GetContext(subSite, user, psw);
|
||||||
|
|
||||||
spc.WebPartPage(sCtx, subSite.ToString(), ssProjectTitle);
|
if (spc.SiteExist(ctx) == true && spc.SiteExist(sCtx) == false)
|
||||||
|
{
|
||||||
//if (spc.SiteExist(ctx) == true && spc.SiteExist(sCtx) == false)
|
#region Site Context
|
||||||
//{
|
spc.ProjectSubSite(ssProjectTitle, projectsYear, ctx);
|
||||||
// #region Site Context
|
spc.OnenoteSPFeature(ctx, year, ssProjectTitle);
|
||||||
// spc.ProjectSubSite(ssProjectTitle, projectsYear, ctx);
|
spc.ProjectListEntry(ssProjectTitle, listTitle, projectsYear, ctx);
|
||||||
// spc.OnenoteSPFeature(ctx, year, ssProjectTitle);
|
#endregion
|
||||||
// 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
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
#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)
|
public static async Task SubProject(string siteCollection, string user, SecureString psw)
|
||||||
@@ -122,18 +128,36 @@ namespace SharePointOnlineUtils
|
|||||||
string year = DateTime.Now.Year.ToString();
|
string year = DateTime.Now.Year.ToString();
|
||||||
string projectsYear = $"Commesse{year}";
|
string projectsYear = $"Commesse{year}";
|
||||||
string listTitle = $"Lista Commesse {year}";
|
string listTitle = $"Lista Commesse {year}";
|
||||||
string ssProjectTitle = "CT0001";
|
string ssProjectTitle = "CT0016";
|
||||||
string[] ssSubProjectTitle = { "CT0001-0001", "CT0001-0002", "CT0001-0003" };
|
string[] ssSubProjectTitle = { "CT0016-0001", "CT0016-0002", "CT0016-0003" };
|
||||||
|
|
||||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||||
|
|
||||||
using (var authMgr = new AuthenticationManager())
|
using (var authMgr = new AuthenticationManager())
|
||||||
using (var ctx = authMgr.GetContext(subSite, user, psw))
|
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
|
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
|
try
|
||||||
{
|
{
|
||||||
@@ -232,9 +256,9 @@ namespace SharePointOnlineUtils
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Projects Years
|
#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";
|
string siteAdmin = "https://italsortbuttrio-admin.sharepoint.com";
|
||||||
|
|
||||||
@@ -249,7 +273,7 @@ namespace SharePointOnlineUtils
|
|||||||
var scp = new SiteCreationProperties();
|
var scp = new SiteCreationProperties();
|
||||||
|
|
||||||
scp.Url = site.ToString();
|
scp.Url = site.ToString();
|
||||||
scp.Title = $"Commesse {year}";
|
scp.Title = siteName;
|
||||||
scp.Owner = user;
|
scp.Owner = user;
|
||||||
scp.Template = "SITEPAGEPUBLISHING#0";
|
scp.Template = "SITEPAGEPUBLISHING#0";
|
||||||
|
|
||||||
@@ -279,12 +303,10 @@ namespace SharePointOnlineUtils
|
|||||||
|
|
||||||
public static async Task ProjectsYField(ClientContext ctx)
|
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[]>()
|
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_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_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_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 } },
|
{ "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;
|
Web web = ctx.Web;
|
||||||
ctx.Load(web);
|
ctx.Load(web);
|
||||||
|
|
||||||
//if (libName.Contains("Commerciale"))
|
|
||||||
//{
|
|
||||||
// web.BreakRoleInheritance(false, true);
|
|
||||||
// ctx.ExecuteQuery();
|
|
||||||
//}
|
|
||||||
|
|
||||||
ListCreationInformation lci = new ListCreationInformation();
|
ListCreationInformation lci = new ListCreationInformation();
|
||||||
lci.Title = libName;
|
lci.Title = libName;
|
||||||
lci.TemplateType = (int)ListTemplateType.DocumentLibrary;
|
lci.TemplateType = (int)ListTemplateType.DocumentLibrary; // TODO: PictureLibrary x Media
|
||||||
List list = web.Lists.Add(lci);
|
List list = web.Lists.Add(lci);
|
||||||
|
|
||||||
ctx.ExecuteQuery();
|
ctx.ExecuteQuery();
|
||||||
@@ -510,17 +526,10 @@ namespace SharePointOnlineUtils
|
|||||||
if (libName.Contains("Commerciale")) DomainGroupRights(ctx, libName);
|
if (libName.Contains("Commerciale")) DomainGroupRights(ctx, libName);
|
||||||
Console.WriteLine($"> '{libName}' è stato creato con successo.");
|
Console.WriteLine($"> '{libName}' è stato creato con successo.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"!> Qualcosa è andato storto... {ex.Message}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Dir
|
#region Dir
|
||||||
try
|
|
||||||
{
|
|
||||||
Dictionary<string, string> folderName = new Dictionary<string, string>
|
Dictionary<string, string> folderName = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "01_Costificazioni", $"Commerciale {ssProjectTitle}" },
|
{ "01_Costificazioni", $"Commerciale {ssProjectTitle}" },
|
||||||
@@ -597,7 +606,7 @@ namespace SharePointOnlineUtils
|
|||||||
viewCreation.Title = listTitle;
|
viewCreation.Title = listTitle;
|
||||||
viewCreation.ViewTypeKind = ViewType.None;
|
viewCreation.ViewTypeKind = ViewType.None;
|
||||||
viewCreation.ColumnWidth = "350";
|
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);
|
var view = views.Add(viewCreation);
|
||||||
|
|
||||||
@@ -624,6 +633,8 @@ namespace SharePointOnlineUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ProjectQuickMenu(string ssProjectTitle, string subSiteUrl, ClientContext ctx)
|
public static async Task ProjectQuickMenu(string ssProjectTitle, string subSiteUrl, ClientContext ctx)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, string> itemQuickMenu = new Dictionary<string, string>
|
Dictionary<string, string> itemQuickMenu = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
@@ -636,7 +647,7 @@ namespace SharePointOnlineUtils
|
|||||||
NavigationNodeCollection spNavNodeColl = ctx.Web.Navigation.QuickLaunch;
|
NavigationNodeCollection spNavNodeColl = ctx.Web.Navigation.QuickLaunch;
|
||||||
NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();
|
NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();
|
||||||
|
|
||||||
ctx.Load(ctx.Web);
|
ctx.Load(ctx.Web, w => w.RootFolder.WelcomePage);
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> item in itemQuickMenu)
|
foreach (KeyValuePair<string, string> item in itemQuickMenu)
|
||||||
{
|
{
|
||||||
@@ -646,19 +657,26 @@ namespace SharePointOnlineUtils
|
|||||||
newNavNode.AsLastNode = true;
|
newNavNode.AsLastNode = true;
|
||||||
spNavNodeColl.Add(newNavNode);
|
spNavNodeColl.Add(newNavNode);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ctx.ExecuteQuery();
|
ctx.ExecuteQuery();
|
||||||
Console.WriteLine($"> Il menu rapido è stato aggiornato in {ssProjectTitle}");
|
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)
|
catch (Exception ex)
|
||||||
{ Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} )"); return; }
|
{ Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} )"); return; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sub Project
|
#region Sub Project
|
||||||
public static async Task SubProjectDocSet(string ssProjectTitle, string[] ssSubProjectTitle, ClientContext ctx) //TODO: da impostare le variabili generali
|
public static async Task SubProjectDocSet(string ssProjectTitle, string[] ssSubProjectTitle, ClientContext ctx)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -701,7 +719,7 @@ namespace SharePointOnlineUtils
|
|||||||
{
|
{
|
||||||
Console.WriteLine($"> Inizializzata la fase di creazione per {spt}.");
|
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);
|
DocumentSet.Create(ctx, list.RootFolder, spt, contentType.Id);
|
||||||
ctx.ExecuteQuery();
|
ctx.ExecuteQuery();
|
||||||
@@ -749,6 +767,124 @@ namespace SharePointOnlineUtils
|
|||||||
}
|
}
|
||||||
#endregion
|
#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
|
#region SPFeature
|
||||||
public static async Task OnenoteSPFeature(ClientContext ctx, string year, string ssProjectTitle)
|
public static async Task OnenoteSPFeature(ClientContext ctx, string year, string ssProjectTitle)
|
||||||
{
|
{
|
||||||
@@ -853,7 +989,6 @@ namespace SharePointOnlineUtils
|
|||||||
|
|
||||||
foreach (KeyValuePair<string, string> role in itsADGruopSalesRole)
|
foreach (KeyValuePair<string, string> role in itsADGruopSalesRole)
|
||||||
{
|
{
|
||||||
|
|
||||||
var adGroup = web.EnsureUser(role.Key);
|
var adGroup = web.EnsureUser(role.Key);
|
||||||
ctx.Load(adGroup);
|
ctx.Load(adGroup);
|
||||||
|
|
||||||
@@ -876,27 +1011,27 @@ namespace SharePointOnlineUtils
|
|||||||
|
|
||||||
#region WebParts
|
#region WebParts
|
||||||
|
|
||||||
public static void WebPartPage(ClientContext ctx, string sitePath, string ssProjectTitle)
|
//public static void WebPartPage(ClientContext ctx, string sitePath, string ssProjectTitle)
|
||||||
{
|
//{
|
||||||
var homeLocation = $"{sitePath}/SitePages/Home.aspx";
|
// var homeLocation = $"{sitePath}/SitePages/Home.aspx";
|
||||||
string[] listName = { $"Documenti {ssProjectTitle}", $"Media {ssProjectTitle}", $"SottoCommesse {ssProjectTitle}", $"Commerciale {ssProjectTitle}" };
|
// string[] listName = { $"Documenti {ssProjectTitle}", $"Media {ssProjectTitle}", $"SottoCommesse {ssProjectTitle}", $"Commerciale {ssProjectTitle}" };
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
foreach (string item in listName)
|
// foreach (string item in listName)
|
||||||
{
|
// {
|
||||||
|
|
||||||
|
|
||||||
List list = ctx.Web.Lists.GetByTitle(item);
|
// List list = ctx.Web.Lists.GetByTitle(item);
|
||||||
ctx.Load(list, l => l.Id);
|
// ctx.Load(list, l => l.Id);
|
||||||
ctx.ExecuteQuery();
|
// ctx.ExecuteQuery();
|
||||||
//Console.WriteLine(viewList);
|
// //Console.WriteLine(viewList);
|
||||||
|
|
||||||
//AddWebPart(ctx, homeLocation, viewList.HtmlSchemaXml);
|
// //AddWebPart(ctx, homeLocation, viewList.HtmlSchemaXml);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
// 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)
|
//private static void CreateWebPartPage(this SPWeb web, List list, string pageName, int layoutTemplate)
|
||||||
//{
|
//{
|
||||||
@@ -917,30 +1052,30 @@ namespace SharePointOnlineUtils
|
|||||||
// var result = web.ProcessBatchData(newWPPageBatchXml);
|
// var result = web.ProcessBatchData(newWPPageBatchXml);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static void AddWebPart(ClientContext context, string pageUrl, string xml)
|
//public static void AddWebPart(ClientContext context, string pageUrl, string xml)
|
||||||
{
|
//{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
Console.WriteLine("Start");
|
// Console.WriteLine("Start");
|
||||||
|
|
||||||
var page = context.Web.GetFileByUrl(pageUrl);
|
// var page = context.Web.GetFileByUrl(pageUrl);
|
||||||
var webpartManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
|
// var webpartManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared);
|
||||||
context.Load(webpartManager, w => w.WebParts);
|
// 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();
|
|
||||||
|
|
||||||
//webpartManager.ImportWebPart(xmlWP);
|
|
||||||
// context.ExecuteQuery();
|
// context.ExecuteQuery();
|
||||||
|
|
||||||
Console.WriteLine("End");
|
|
||||||
}
|
// WebPartDefinition webpartDef = webpartManager.ImportWebPart(xml);
|
||||||
catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
// WebPartDefinition webpart = webpartManager.AddWebPart(webpartDef.WebPart, "mainContent", 0);
|
||||||
}
|
// context.Load(webpartDef);
|
||||||
|
// context.ExecuteQuery();
|
||||||
|
|
||||||
|
// //webpartManager.ImportWebPart(xmlWP);
|
||||||
|
// //context.ExecuteQuery();
|
||||||
|
|
||||||
|
// Console.WriteLine("End");
|
||||||
|
// }
|
||||||
|
// catch (Exception ex) { Console.WriteLine($"!> Qualcosa è andato storto... ( {ex.Message} {ex.StackTrace} )"); return; }
|
||||||
|
//}
|
||||||
|
|
||||||
//protected void ReplaceWebPartsWithAppParts(ClientContext ctx)
|
//protected void ReplaceWebPartsWithAppParts(ClientContext ctx)
|
||||||
//{
|
//{
|
||||||
|
|||||||
@@ -15,9 +15,7 @@
|
|||||||
"PnP.Core": "1.7.0",
|
"PnP.Core": "1.7.0",
|
||||||
"PnP.Core.Admin": "1.7.0",
|
"PnP.Core.Admin": "1.7.0",
|
||||||
"PnP.Core.Auth": "1.7.0",
|
"PnP.Core.Auth": "1.7.0",
|
||||||
"SharePointPnP.IdentityModel.Extensions": "1.2.4",
|
|
||||||
"SharePointPnPCoreOnline": "3.28.2012",
|
"SharePointPnPCoreOnline": "3.28.2012",
|
||||||
"SharePointPnPModernizationOnline": "1.0.2012",
|
|
||||||
"System.IdentityModel.Tokens.Jwt": "6.22.0"
|
"System.IdentityModel.Tokens.Jwt": "6.22.0"
|
||||||
},
|
},
|
||||||
"runtime": {
|
"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": {
|
"Microsoft.ApplicationInsights/2.16.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Diagnostics.DiagnosticSource": "6.0.0"
|
"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": {
|
"System.AppContext/4.1.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Runtime": "4.3.0"
|
"System.Runtime": "4.3.0"
|
||||||
@@ -1883,13 +1856,6 @@
|
|||||||
"path": "anglesharp/0.14.0",
|
"path": "anglesharp/0.14.0",
|
||||||
"hashPath": "anglesharp.0.14.0.nupkg.sha512"
|
"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": {
|
"Microsoft.ApplicationInsights/2.16.0": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"serviceable": true,
|
"serviceable": true,
|
||||||
@@ -2394,13 +2360,6 @@
|
|||||||
"path": "sharepointpnpcoreonline/3.28.2012",
|
"path": "sharepointpnpcoreonline/3.28.2012",
|
||||||
"hashPath": "sharepointpnpcoreonline.3.28.2012.nupkg.sha512"
|
"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": {
|
"System.AppContext/4.1.0": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"serviceable": true,
|
"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.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.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\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