Added field on SitePage
Update DevExpress
This commit is contained in:
@@ -58,11 +58,10 @@ namespace SharePointOnlineUtils
|
||||
Uri subSite = new Uri($"{siteCollection}/sites/{projectsYear}/{ssProjectTitle}");
|
||||
#endregion
|
||||
|
||||
SharePointCustomOperation.ProjectsYField();
|
||||
|
||||
//ProjectsByYearSite(listTitle, year, svcUser, site, svcUserPsw);
|
||||
//Project(siteCollection, svcUser, svcUserPsw);
|
||||
//SubProject(siteCollection, svcUser, svcUserPsw);
|
||||
ProjectsByYearSite(listTitle, year, svcUser, site, svcUserPsw);
|
||||
Project(siteCollection, svcUser, svcUserPsw);
|
||||
SubProject(siteCollection, svcUser, svcUserPsw);
|
||||
}
|
||||
|
||||
public static async Task ProjectsByYearSite(string listTitle, string year, string user, Uri site, SecureString psw)
|
||||
@@ -70,12 +69,12 @@ namespace SharePointOnlineUtils
|
||||
using (var authMgr = new AuthenticationManager())
|
||||
using (var ctx = authMgr.GetContext(site, user, psw))
|
||||
{
|
||||
|
||||
if (SharePointCustomOperation.SiteExist(ctx) == false)
|
||||
{
|
||||
SharePointCustomOperation.ProjectsYSite(year, site, user, psw);
|
||||
//SharePointCustomOperation.ProjectsYField(ctx);
|
||||
SharePointCustomOperation.ProjectsYField(ctx);
|
||||
SharePointCustomOperation.ProjectsYList(listTitle, ctx);
|
||||
SharePointCustomOperation.ProjectsYListField(listTitle, ctx);
|
||||
SharePointCustomOperation.ProjectsYListView(listTitle, ctx);
|
||||
}
|
||||
}
|
||||
@@ -262,25 +261,28 @@ namespace SharePointOnlineUtils
|
||||
ctx.Load(site, w => w.RootWeb, w => w.RootWeb.Fields);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
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 Progretto", "", "", "", "", "", "", "", "", "", "" } },
|
||||
{ "PAL_DlvReason", new string[] { "Choice", "", "", "", "", "", "", "", "", "", "", "" } },
|
||||
{ "PAL_Customer", new string[] { "Text", "", "", "", "", "", "", "", "", "", "", "" } },
|
||||
{ "PAL_Item", new string[] { "Text", "", "", "", "", "", "", "", "", "", "", "" } },
|
||||
{ "PAL_ItemCode", new string[] { "Text", "", "", "", "", "", "", "", "", "", "", "" } },
|
||||
{ "PAL_ItemDescription", new string[] { "Text", "", "", "", "", "", "", "", "", "", "", "" } },
|
||||
{ "PAL_SerialNumber", new string[] { "Text", "", "", "", "", "", "", "", "", "", "", "" } }
|
||||
{ "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_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 } },
|
||||
{ "PAL_ItemDescription", new string[] { "Text", "Descrizione Articolo", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
|
||||
{ "PAL_SerialNumber", new string[] { "Text", "Matricola Macchina", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } }
|
||||
};
|
||||
//"<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>"
|
||||
|
||||
foreach (KeyValuePair<string, string[]> f in fieldList)
|
||||
{
|
||||
var fieldXml = $"<Field Name='{f.Key}' Type='{f.Value[0]}' Description='' DisplayName='{f.Value[1]}' StaticName='{f.Value[3]}' Group='{f.Value[4]}' Hidden='{f.Value[5]}' Required='{f.Value[6]}' Sealed='{f.Value[7]}' ShowInDisplayForm='{f.Value[8]}' ShowInEditForm='{f.Value[9]}' ShowInNewForm='{f.Value[10]}'>{f.Value[11]}</Field>";
|
||||
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();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ Console.WriteLine($"> Qualcosa è andato storto... ( {ex.Message} )"); }
|
||||
@@ -323,57 +325,36 @@ namespace SharePointOnlineUtils
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task ProjectsYListField(string listTitle, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione dei campi '{listTitle}'.");
|
||||
|
||||
Web web = ctx.Web;
|
||||
List list = web.Lists.GetByTitle(listTitle);
|
||||
List projectsList = web.Lists.GetByTitle(listTitle);
|
||||
|
||||
ctx.Load(list, l => l.Fields);
|
||||
ctx.Load(projectsList, b => b.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
string idProjField = @"<Field Type='URL' Name='PAL_ID_Project' StaticName='PAL_ID_Project' DisplayName='ID Progetto' Required='TRUE' />";
|
||||
Field lookupIdProjField = list.Fields.AddFieldAsXml(idProjField, true, AddFieldOptions.DefaultValue);
|
||||
|
||||
string clientField = @"<Field Type='Text' Name='PAL_Customer' StaticName='PAL_Customer' DisplayName='Cliente' Required='TRUE' />";
|
||||
Field lookupClientField = list.Fields.AddFieldAsXml(clientField, true, AddFieldOptions.DefaultValue);
|
||||
|
||||
string dlvReasonField = @"<Field Type='Choice' Name='PAL_DlvReason' StaticName='PAL_DlvReason' DisplayName='Causale' Required='TRUE' Format='RadioButtons' >"
|
||||
+ "<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>"
|
||||
+ "</Field>";
|
||||
Field lookupDlvReasonField = list.Fields.AddFieldAsXml(dlvReasonField, true, AddFieldOptions.DefaultValue);
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Completata la fase di creazione dei campi '{listTitle}'.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"> Qualcosa è andato storto nella creazione delle colonne. ( {ex.Message} )");
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task ProjectsYListView(string listTitle, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione della ListView '{listTitle}'.");
|
||||
#region Field
|
||||
Console.WriteLine($"> Inizializzata la fase di importazione dei campi '{listTitle}'.");
|
||||
|
||||
List list = ctx.Web.Lists.GetByTitle(listTitle);
|
||||
var siteField = ctx.Site.RootWeb;
|
||||
ctx.Load(list, l => l.Fields);
|
||||
ctx.Load(siteField, s => s.Fields);
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
string[] fieldName = { "ID Progetto", "Cliente", "Causale" };
|
||||
|
||||
foreach (var fn in fieldName)
|
||||
{
|
||||
var Fields = siteField.Fields.GetByTitle(fn);
|
||||
list.Fields.Add(Fields);
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Completata la fase di importazione dei campi '{listTitle}'.");
|
||||
#endregion
|
||||
|
||||
#region View
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione della ListView '{listTitle}'.");
|
||||
|
||||
var views = list.Views;
|
||||
|
||||
|
||||
@@ -383,7 +364,7 @@ namespace SharePointOnlineUtils
|
||||
viewCreation.Title = listTitle;
|
||||
viewCreation.ViewTypeKind = ViewType.None;
|
||||
viewCreation.ColumnWidth = "350";
|
||||
viewCreation.ViewFields = new string[3] { "ID Progetto", "Cliente", "Causale" };
|
||||
viewCreation.ViewFields = new string[] { "ID Progetto", "Cliente", "Causale" };
|
||||
|
||||
var view = views.Add(viewCreation);
|
||||
|
||||
@@ -407,6 +388,8 @@ namespace SharePointOnlineUtils
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Impostata come HomePage di '{viewCreation.Title}'");
|
||||
#endregion
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -454,9 +437,9 @@ namespace SharePointOnlineUtils
|
||||
link.Url = $"/sites/{projectsYear}/{ssProjectTitle}";
|
||||
link.Description = ssProjectTitle;
|
||||
|
||||
oItem["ID_x0020_Progetto"] = link;
|
||||
oItem["Cliente"] = "PAL";
|
||||
oItem["Causale"] = "02 VENDITA RICAMBI";
|
||||
oItem["PAL_ID_Project"] = link;
|
||||
oItem["PAL_Customer"] = "PAL";
|
||||
oItem["PAL_DlvReason"] = "02 VENDITA RICAMBI";
|
||||
|
||||
oItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
@@ -542,24 +525,27 @@ namespace SharePointOnlineUtils
|
||||
{
|
||||
var listTitle = $"SottoCommesse {ssProjectTitle}";
|
||||
#region Field
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione dei campi in 'SottoCommesse {ssProjectTitle}'.");
|
||||
Console.WriteLine($"> Inizializzata la fase di importazione dei campi in 'SottoCommesse {ssProjectTitle}'.");
|
||||
|
||||
Web web = ctx.Web;
|
||||
List list = web.Lists.GetByTitle(listTitle);
|
||||
List projectsList = web.Lists.GetByTitle(listTitle);
|
||||
|
||||
var siteField = ctx.Site.RootWeb ;
|
||||
ctx.Load(list, l => l.Fields);
|
||||
ctx.Load(projectsList, b => b.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Field lookupItemField = list.Fields.AddFieldAsXml(@"<Field Type='Text' Name='PAL_Item' StaticName='PAL_Item' DisplayName='Item' Required='FALSE' />", true, AddFieldOptions.DefaultValue);
|
||||
Field lookupArticleNumberField = list.Fields.AddFieldAsXml(@"<Field Type='Text' Name='PAL_ItemCode' StaticName='PAL_ItemCode' DisplayName='Codice Articolo' Required='FALSE' />", true, AddFieldOptions.DefaultValue);
|
||||
Field lookupArticleDescriptionField = list.Fields.AddFieldAsXml(@"<Field Type='Text' Name='PAL_ItemDescription' StaticName='PAL_ItemDescription' DisplayName='Descrizione Articolo' Required='FALSE' />", true, AddFieldOptions.DefaultValue);
|
||||
Field lookupMachineSerialNumberField = list.Fields.AddFieldAsXml(@"<Field Type='Text' Name='PAL_SerialNumber' StaticName='PAL_SerialNumber' DisplayName='Matricola Macchina' Required='FALSE' />", true, AddFieldOptions.DefaultValue);
|
||||
ctx.Load(siteField, s => s.Fields);
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Completata la fase di creazione dei campi in 'SottoCommesse {ssProjectTitle}'.");
|
||||
string[] fieldName = { "Item", "Codice Articolo", "Descrizione Articolo", "Matricola Macchina" };
|
||||
|
||||
foreach (var fn in fieldName)
|
||||
{
|
||||
var Fields = siteField.Fields.GetByTitle(fn);
|
||||
list.Fields.Add(Fields);
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Completata la fase di importazione dei campi in 'SottoCommesse {ssProjectTitle}'.");
|
||||
#endregion
|
||||
|
||||
#region View
|
||||
@@ -686,10 +672,10 @@ namespace SharePointOnlineUtils
|
||||
var dsItem = list.RootFolder.Folders.GetByUrl(spt).ListItemAllFields;
|
||||
|
||||
dsItem["_ExtendedDescription"] = "valueDescription";
|
||||
dsItem["Item"] = "valueItem";
|
||||
dsItem["Codice_x0020_Articolo"] = "valueItemCode";
|
||||
dsItem["Descrizione_x0020_Articolo"] = "valueItemDescription";
|
||||
dsItem["Matricola_x0020_Macchina"] = "valueSerialNumber";
|
||||
dsItem["PAL_Item"] = "valueItem";
|
||||
dsItem["PAL_ItemCode"] = "valueItemCode";
|
||||
dsItem["PAL_ItemDescription"] = "valueItemDescription";
|
||||
dsItem["PAL_SerialNumber"] = "valueSerialNumber";
|
||||
|
||||
dsItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\DevExpress 21.2\\Components\\Offline Packages",
|
||||
"C:\\Program Files\\DevExpress 22.1\\Components\\Offline Packages",
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\cbo\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\DevExpress 21.2.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\DevExpress 22.1.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
@@ -29,6 +31,7 @@
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\DevExpress 21.2\\Components\\System\\Components\\Packages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\DevExpress 22.1\\Components\\System\\Components\\Packages": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\cbo\.nuget\packages\;C:\Program Files (x86)\DevExpress 21.2\Components\Offline Packages;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\cbo\.nuget\packages\;C:\Program Files (x86)\DevExpress 21.2\Components\Offline Packages;C:\Program Files\DevExpress 22.1\Components\Offline Packages;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.2.1</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\cbo\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\DevExpress 21.2\Components\Offline Packages\" />
|
||||
<SourceRoot Include="C:\Program Files\DevExpress 22.1\Components\Offline Packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -6169,6 +6169,7 @@
|
||||
"packageFolders": {
|
||||
"C:\\Users\\cbo\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files (x86)\\DevExpress 21.2\\Components\\Offline Packages": {},
|
||||
"C:\\Program Files\\DevExpress 22.1\\Components\\Offline Packages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
|
||||
},
|
||||
"project": {
|
||||
@@ -6182,11 +6183,13 @@
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\DevExpress 21.2\\Components\\Offline Packages",
|
||||
"C:\\Program Files\\DevExpress 22.1\\Components\\Offline Packages",
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\cbo\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\DevExpress 21.2.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\DevExpress 22.1.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
@@ -6196,6 +6199,7 @@
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\DevExpress 21.2\\Components\\System\\Components\\Packages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"C:\\Program Files\\DevExpress 22.1\\Components\\System\\Components\\Packages": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
|
||||
Reference in New Issue
Block a user