NC Completed

This commit is contained in:
Kalarumeth
2022-09-28 17:34:55 +02:00
parent b840d8a984
commit 3ab3afe25e
19 changed files with 401 additions and 251 deletions
+3 -3
View File
@@ -117,7 +117,7 @@ public static class Fields
{
return new Dictionary<string, string[]>()
{
{ "PAL_Quotation_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_Quotation_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_ID_Quotation", new string[] { "Text", "ID Offerta", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_Quotation_Name", new string[] { "Text", "Fornitore", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_Authors", new string[] { "Text", "Autore", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } }
@@ -131,13 +131,13 @@ public static class Fields
{
return new Dictionary<string, string[]>()
{
{ "PAL_NC_Source", new string[] {"Choice", "Sorgente", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "<CHOICES><CHOICE>Interno</CHOICE><CHOICE>Cliente</CHOICE><CHOICE></CHOICE>Fornitore</CHOICE>" } },
{ "PAL_NC_Source", new string[] {"Choice", "Sorgente", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", "<CHOICES><CHOICE>Interno</CHOICE><CHOICE>Cliente</CHOICE><CHOICE>Fornitore</CHOICE></CHOICES>" } },
{ "PAL_NC_Reference", new string[] { "Text", "Rifermento", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_NC_Nominative", new string[] { "Text", "Nominativo", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_NC_DateOfDetection", new string[] { "Text", "Data Rilevazione", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_NC_Project", new string[] { "Text", "Commessa", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_NC_ItemCode", new string[] { "Text", "Parte", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_NC_Portal", new string[] {"URL", "Portal", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
{ "PAL_NC_PortalUrl", new string[] {"URL", "Portal", "PAL Field", "FALSE", "FALSE", "TRUE", "TRUE", "TRUE", "TRUE", string.Empty } },
};
}
}
@@ -0,0 +1,47 @@
using console_spo_utils.Interfaces.Repositories;
using Microsoft.SharePoint.Client;
using static System.Net.WebRequestMethods;
namespace console_spo_utils.Fakes.Repositories;
public class FakeNonComplianceSettingsRepository : INonComplianceRepository
{
public string DefaultNonComplianceSource()
{
return "Interno";
}
public string DefaultNonComplianceReference()
{
return "Italsort";
}
public string DefaultNonComplianceNominative()
{
return "Mario Issor";
}
public string DefaultNonComplianceDateOfDetection()
{
return "28-09-2022";
}
public string DefaultNonComplianceProject()
{
return "CT0001-001";
}
public string DefaultNonComplianceItemCode()
{
return "M24x3";
}
public FieldUrlValue DefaultNonCompliancePortalUrl()
{
return new FieldUrlValue
{
Description = "Vai a Portal",
Url = "https://portal.pal.local/"
};
}
}
@@ -0,0 +1,15 @@
using Microsoft.SharePoint.Client;
namespace console_spo_utils.Interfaces.Repositories;
public interface INonComplianceRepository
{
public string DefaultNonComplianceSource();
public string DefaultNonComplianceReference();
public string DefaultNonComplianceNominative();
public string DefaultNonComplianceDateOfDetection();
public string DefaultNonComplianceProject();
public string DefaultNonComplianceItemCode();
public FieldUrlValue DefaultNonCompliancePortalUrl();
}
@@ -0,0 +1,6 @@
namespace console_spo_utils.Interfaces.Services;
public interface INonComplianceBuildService
{
public void CreateIfNotExists(string nonComplianceName);
}
@@ -0,0 +1,8 @@
using Microsoft.SharePoint.Client;
namespace console_spo_utils.Interfaces.Services;
public interface INonComplianceDocLibraryService
{
public void Create(string libName, ClientContext ctx);
}
@@ -0,0 +1,9 @@
using Microsoft.SharePoint.Client;
namespace console_spo_utils.Interfaces.Services;
public interface INonComplianceDocSetService
{
public void Create(string nonComplianceName, string docLibraryName, string tenantName, ClientContext ctx);
}
@@ -6,5 +6,6 @@ public interface IOneNoteService
{
public bool CreateFolderInsideProject(string projName, ClientContext ctx);
public bool CreateFolderInsideQuotation(string quotationName, ClientContext ctx);
public bool CreateFolderInsideNonCompliance(string quotationName, ClientContext ctx);
public void EnableFeature(ClientContext ctx);
}
+4
View File
@@ -19,6 +19,7 @@ namespace console_spo_utils
services.AddTransient<IProjectSettingsRepository, FakeProjectSettingsRepository>();
services.AddTransient<ISubProjectRepository, FakeSubProjectRepository>();
services.AddTransient<IQuotationRepository, FakeQuotationSettingRepository>();
services.AddTransient<INonComplianceRepository, FakeNonComplianceSettingsRepository>();
services.AddHostedService<MainWorker>();
})
@@ -45,6 +46,9 @@ namespace console_spo_utils
services.AddTransient<IQuotationBuildService, QuotationBuildService>();
services.AddTransient<IQuotationDocLibraryService, QuotationDocLibraryService>();
services.AddTransient<IQuotationDocSetService, QuotationDocSetService>();
services.AddTransient<INonComplianceBuildService, NonComplianceBuildService>();
services.AddTransient<INonComplianceDocLibraryService, NonComplianceDocLibraryService>();
services.AddTransient<INonComplianceDocSetService, NonComplianceDocSetService>();
services.AddTransient<IWebpartService, WebpartService>();
services.AddTransient<IProjectService, ProjectService>();
@@ -0,0 +1,58 @@
using console_spo_utils.Interfaces.Services;
using Microsoft.Extensions.Logging;
namespace console_spo_utils.Services;
public class NonComplianceBuildService : INonComplianceBuildService
{
private readonly ISiteOptions siteOptions;
private readonly ISharePointAuthenticationManager sharePointAuthenticationManager;
private readonly ISharePointCustomOperation spc;
private readonly ITenantService tenantService;
private readonly INonComplianceDocLibraryService nonComplianceDocLibraryService;
private readonly INonComplianceDocSetService nonComplianceDocSetService;
private readonly ILogger<NonComplianceBuildService> logger;
public NonComplianceBuildService(
ISiteOptions siteOptions,
ISharePointAuthenticationManager sharePointAuthenticationManager,
ISharePointCustomOperation spc,
ITenantService tenantService,
INonComplianceDocLibraryService nonComplianceDocLibraryService,
INonComplianceDocSetService nonComplianceDocSetService,
ILogger<NonComplianceBuildService> logger)
{
this.siteOptions = siteOptions;
this.sharePointAuthenticationManager = sharePointAuthenticationManager;
this.spc = spc;
this.tenantService = tenantService;
this.nonComplianceDocLibraryService = nonComplianceDocLibraryService;
this.nonComplianceDocSetService = nonComplianceDocSetService;
this.logger = logger;
}
public void CreateIfNotExists(string nonComplianceName)
{
var site = siteOptions.GetNonComplianceSite();
var ctx = sharePointAuthenticationManager.GetContext(site);
var list = siteOptions.GetNonComplianceLibrary();
var tenant = siteOptions.GetNonComplianceTenant();
if (!spc.SiteExist(ctx))
{
tenantService.CreateForNonCompliance();
}
else if (!spc.ListExist(ctx, list))
{
nonComplianceDocLibraryService.Create(list, ctx);
}
else if (!spc.FolderExistsInsideList(ctx, list, nonComplianceName))
{
nonComplianceDocSetService.Create(nonComplianceName, list, tenant, ctx);
}
else
{
logger.LogInformation($"Quotation with {nonComplianceName} already exist");
}
}
}
@@ -0,0 +1,115 @@
using console_spo_utils.Interfaces.Services;
using Microsoft.Extensions.Logging;
using Microsoft.SharePoint.Client;
namespace console_spo_utils.Services;
public class NonComplianceDocLibraryService : INonComplianceDocLibraryService
{
private readonly ILogger<NonComplianceDocLibraryService> logger;
public NonComplianceDocLibraryService(ILogger<NonComplianceDocLibraryService> logger)
{
this.logger = logger;
}
public void Create(string libName, ClientContext ctx)
{
try
{
#region New DocLib
Console.WriteLine($"> Inizializzata la fase di creazione '{libName}'.");
Web web = ctx.Web;
ctx.Load(web, w => w.RootFolder.WelcomePage, w => w.Url);
ListCreationInformation lci = new ListCreationInformation();
lci.Title = libName;
lci.TemplateType = (int)ListTemplateType.DocumentLibrary;
web.Lists.Add(lci);
ctx.ExecuteQuery();
Console.WriteLine($"> Completata la fase di creazione '{libName}'.");
#endregion
#region Field
Console.WriteLine($"> Inizializzata la fase di importazione dei campi '{libName}'.");
List list = ctx.Web.Lists.GetByTitle(libName);
var siteField = ctx.Site.RootWeb;
ctx.Load(list, l => l.Fields);
ctx.Load(siteField, s => s.Fields);
ctx.ExecuteQuery();
string[] fieldName = { "Sorgente", "Rifermento", "Nominativo", "Data Rilevazione", "Commessa", "Parte", "Portal" };
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 '{libName}'.");
#endregion
#region View
Console.WriteLine($"> Inizializzata la fase di creazione della ListView '{libName}'.");
var views = list.Views;
ViewCreationInformation viewCreation = new ViewCreationInformation();
viewCreation.SetAsDefaultView = true;
viewCreation.Title = libName;
viewCreation.ViewTypeKind = ViewType.None;
viewCreation.ColumnWidth = "350";
viewCreation.ViewFields = new string[] { "Type", "Name", "Sorgente", "Rifermento", "Nominativo", "Data Rilevazione", "Commessa", "Parte", "Portal" };
var view = views.Add(viewCreation);
ctx.Load(view);
ctx.ExecuteQuery();
Console.WriteLine($"> Completata la fase di creazione della ListView '{viewCreation.Title}'.");
var customView = views.GetByTitle(viewCreation.Title);
customView.MobileView = true;
customView.MobileDefaultView = true;
customView.Update();
ctx.ExecuteQuery();
Console.WriteLine($"> Abilitata la visualizzazione su mobile '{viewCreation.Title}'.");
#endregion
#region Shortcut on Quickmenu
NavigationNodeCollection spNavNodeColl = web.Navigation.QuickLaunch;
NavigationNodeCreationInformation newNavNode = new NavigationNodeCreationInformation();
newNavNode.Title = $"{libName}";
newNavNode.Url = $"{web.Url}/{libName.Replace(" ", "%20").Replace("à", "")}";
newNavNode.AsLastNode = true;
spNavNodeColl.Add(newNavNode);
ctx.ExecuteQuery();
Console.WriteLine($"> Il menu rapido è stato aggiornato, il collegamento a {libName} è ora disponibile.");
#endregion
}
catch (Exception ex)
{
logger.LogError(ex, "NonComplianceDocLibraryService");
}
}
}
@@ -0,0 +1,108 @@
using console_spo_utils.Constants;
using console_spo_utils.Interfaces.Repositories;
using console_spo_utils.Interfaces.Services;
using Microsoft.Extensions.Logging;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.DocumentSet;
namespace console_spo_utils.Services;
public class NonComplianceDocSetService : INonComplianceDocSetService
{
private readonly ISharePointCustomOperation cpt;
private readonly IOneNoteService oneNoteService;
private readonly INonComplianceRepository nonComplianceRepository;
public NonComplianceDocSetService(
ISharePointCustomOperation cpt,
IOneNoteService oneNoteService,
INonComplianceRepository nonComplianceRepository)
{
this.cpt = cpt;
this.oneNoteService = oneNoteService;
this.nonComplianceRepository = nonComplianceRepository;
}
public void Create(string nonComplianceName, string docLibraryName, string tenantName, ClientContext ctx)
{
#region Context
var web = ctx.Web;
ctx.Load(web, w => w.Url);
List list = web.Lists.GetByTitle(docLibraryName);
ctx.Load(list, l => l.RootFolder, l => l.ContentTypes, l => l.Fields, l => l.ContentTypesEnabled);
ctx.ExecuteQuery();
list.ContentTypesEnabled = true;
list.Update();
if (!cpt.ListContentTypeExist(ctx, docLibraryName, "Set di documenti"))
{
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
Console.WriteLine($"> Inizializzata la fase di creazione per {nonComplianceName}.");
#region DocSet Field Entry
DocumentSet.Create(ctx, list.RootFolder, nonComplianceName, contentType.Id);
ctx.ExecuteQuery();
Console.WriteLine($"> DocumentSet {nonComplianceName} creata.");
var dsItem = list.RootFolder.Folders.GetByUrl(nonComplianceName).ListItemAllFields;
dsItem["PAL_NC_Source"] = nonComplianceRepository.DefaultNonComplianceSource();
dsItem["PAL_NC_Reference"] = nonComplianceRepository.DefaultNonComplianceReference();
dsItem["PAL_NC_Nominative"] = nonComplianceRepository.DefaultNonComplianceNominative();
dsItem["PAL_NC_DateOfDetection"] = nonComplianceRepository.DefaultNonComplianceDateOfDetection();
dsItem["PAL_NC_Project"] = nonComplianceRepository.DefaultNonComplianceProject();
dsItem["PAL_NC_ItemCode"] = nonComplianceRepository.DefaultNonComplianceItemCode();
dsItem["PAL_NC_PortalUrl"] = nonComplianceRepository.DefaultNonCompliancePortalUrl();
dsItem.Update();
ctx.ExecuteQuery();
Console.WriteLine($"> Field value update.");
#endregion
#region Quotation Folder
foreach (var name in Folders.OfferDocSet)
{
Console.WriteLine($"La sotto cartella {name} verrà creata in {nonComplianceName}");
var rPath = ResourcePath.FromDecodedUrl($"{nonComplianceName}/{name}");
list.RootFolder.AddSubFolderUsingPath(rPath);
}
ctx.ExecuteQuery();
oneNoteService.CreateFolderInsideNonCompliance(nonComplianceName, ctx);
Console.WriteLine($"Le sotto cartelle sono state create con successo in {nonComplianceName}");
#endregion
Console.WriteLine($"> {nonComplianceName} creato con successo in Offerte/{docLibraryName}.");
}
}
+19 -5
View File
@@ -8,16 +8,16 @@ public class OneNoteService : IOneNoteService
{
private readonly ILogger<OneNoteService> logger;
private readonly ISiteOptions siteOptions;
private readonly ISharePointCustomOperation cpt;
private readonly ISharePointCustomOperation spc;
public OneNoteService(
ILogger<OneNoteService> logger,
ISiteOptions siteOptions,
ISharePointCustomOperation cpt)
ISharePointCustomOperation spc)
{
this.logger = logger;
this.siteOptions = siteOptions;
this.cpt = cpt;
this.spc = spc;
}
public bool CreateFolderInsideProject(string projName, ClientContext ctx)
@@ -57,6 +57,13 @@ public class OneNoteService : IOneNoteService
ctx.Load(list, l => l.RootFolder);
ctx.ExecuteQuery();
if (!spc.FolderExistsInsideList(ctx, $"{siteOptions.GetQuotationTenant()} Notebook", $"{DateTime.Today.Year}"))
{
var rYearPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetQuotationTenant()} Notebook/{DateTime.Today.Year}");
list.RootFolder.AddSubFolderUsingPath(rYearPath);
ctx.ExecuteQuery();
}
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetQuotationTenant()} Notebook/{DateTime.Today.Year}/{quotationName}");
list.RootFolder.AddSubFolderUsingPath(rPath);
ctx.ExecuteQuery();
@@ -83,7 +90,14 @@ public class OneNoteService : IOneNoteService
var list = ctx.Web.Lists.EnsureSiteAssetsLibrary();
ctx.Load(list, l => l.RootFolder);
ctx.ExecuteQuery();
//TODO: verificare se worka
if (!spc.FolderExistsInsideList(ctx, $"{siteOptions.GetNonComplianceTenant()} Notebook", $"{DateTime.Today.Year}"))
{
var rYearPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetNonComplianceTenant()} Notebook/{DateTime.Today.Year}");
list.RootFolder.AddSubFolderUsingPath(rYearPath);
ctx.ExecuteQuery();
}
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetNonComplianceTenant()} Notebook/{DateTime.Today.Year}/{quotationName}");
list.RootFolder.AddSubFolderUsingPath(rPath);
ctx.ExecuteQuery();
@@ -106,7 +120,7 @@ public class OneNoteService : IOneNoteService
var featureId = new Guid("f151bb39-7c3b-414f-bb36-6bf18872052f");
#region Feature Activate
if (!cpt.SiteFeaturesExist(ctx, featureName))
if (!spc.SiteFeaturesExist(ctx, featureName))
{
ctx.Web.ActivateFeature(featureId);
ctx.ExecuteQuery();
@@ -37,6 +37,7 @@ public class QuotationBuildService : IQuotationBuildService
var ctx = sharePointAuthenticationManager.GetContext(site);
var list = siteOptions.GetQuotationLibrary();
var tenant = siteOptions.GetQuotationTenant();
if (!spc.SiteExist(ctx))
{
tenantService.CreateForQuotation();
@@ -103,13 +103,13 @@ public class QuotationDocLibraryService : IQuotationDocLibraryService
ctx.ExecuteQuery();
Console.WriteLine($"> Il menu rapido è stato aggiornato, il collegamemento a {libName} è ora disponibile.");
Console.WriteLine($"> Il menu rapido è stato aggiornato, il collegamento a {libName} è ora disponibile.");
#endregion
}
catch (Exception ex)
{
logger.LogError(ex, "");
logger.LogError(ex, "QuotationDocLibraryService");
}
}
}
@@ -1,234 +0,0 @@
//using Microsoft.SharePoint.Client.DocumentSet;
//using Microsoft.SharePoint.Client;
//using System.Security;
//using console_spo_utils.Enums;
//using Microsoft.AddSharePointExtensions.Logging;
//namespace console_spo_utils.Services
//{
// internal class OfferService
// {
// private readonly SharePointCustomOperation spc;
// private readonly ILogger logger;
// private readonly SharePointAuthenticationManager authMgr;
// public OfferService(
// SharePointCustomOperation spc,
// ILogger<OfferService> logger,
// SharePointAuthenticationManager authMgr)
// {
// this.spc = spc;
// this.logger = logger;
// this.authMgr = authMgr;
// }
// public void Create(string siteCollection, string user, SecureString psw)
// {
// var year = DateTime.Now.Year.ToString();
// var tenantName = "Offerte";
// var docLibName = $"{tenantName} {year}";
// var quotationName = $"OF0002";
// var site = new Uri($"{siteCollection}/sites/Offerte");
// var ctx = authMgr.GetContext(site);
// //spc.AddWebPart(ctx, "/sites/Offerte/SitePages/homepage.aspx");
// if (!spc.SiteExist(ctx))
// {
// spc.TenantCreation(tenantName, PalFieldType.Quotation, site, user, psw);
// }
// else if (spc.SiteExist(ctx) && spc.ListExist(ctx, docLibName) == false)
// {
// OfferDocLib(docLibName, ctx);
// }
// else if (spc.SiteExist(ctx) && spc.ListExist(ctx, docLibName) && !spc.FolderExistsInsideList(ctx, docLibName, quotationName))
// {
// OfferDocSet(quotationName, docLibName, tenantName, ctx);
// }
// }
// public void OfferDocLib(string docLibName, ClientContext ctx)
// {
// try
// {
// #region New DocLib
// logger.LogInformation($"> Inizializzata la fase di creazione '{docLibName}'.");
// var web = ctx.Web;
// ctx.Load(web, w => w.RootFolder.WelcomePage, w => w.Url);
// var lci = new ListCreationInformation
// {
// Title = docLibName,
// TemplateType = (int)ListTemplateType.DocumentLibrary
// };
// web.Lists.Add(lci);
// ctx.ExecuteQuery();
// logger.LogInformation($"> Completata la fase di creazione '{docLibName}'.");
// #endregion
// #region Field
// logger.LogInformation($"> Inizializzata la fase di importazione dei campi '{docLibName}'.");
// var list = ctx.Web.Lists.GetByTitle(docLibName);
// var siteField = ctx.Site.RootWeb;
// ctx.Load(list, l => l.Fields);
// ctx.Load(siteField, s => s.Fields);
// ctx.ExecuteQuery();
// string[] fieldName = { "ID Offerta", "Fornitore", "Causale", "Autore" };
// foreach (var fn in fieldName)
// {
// var fields = siteField.Fields.GetByTitle(fn);
// list.Fields.Add(fields);
// }
// ctx.ExecuteQuery();
// logger.LogInformation($"> Completata la fase di importazione dei campi '{docLibName}'.");
// #endregion
// #region View
// logger.LogInformation($"> Inizializzata la fase di creazione della ListView '{docLibName}'.");
// var views = list.Views;
// var viewCreation = new ViewCreationInformation
// {
// SetAsDefaultView = true,
// Title = docLibName,
// ViewTypeKind = ViewType.None,
// ColumnWidth = "350",
// ViewFields = new string[] { "Type", "Name", "ID Offerta", "Fornitore", "Causale", "Autore" }
// };
// var view = views.Add(viewCreation);
// ctx.Load(view);
// ctx.ExecuteQuery();
// logger.LogInformation($"> Completata la fase di creazione della ListView '{viewCreation.Title}'.");
// var customView = views.GetByTitle(viewCreation.Title);
// customView.MobileView = true;
// customView.MobileDefaultView = true;
// customView.Update();
// ctx.ExecuteQuery();
// logger.LogInformation($"> Abilitata la visualizzazione su mobile '{viewCreation.Title}'.");
// #endregion
// #region Shortcut on Quickmenu
// var spNavNodeColl = web.Navigation.QuickLaunch;
// var newNavNode = new NavigationNodeCreationInformation
// {
// Title = $"{docLibName}",
// Url = $"{web.Url}/{docLibName.Replace(" ", "%20")}",
// AsLastNode = true
// };
// spNavNodeColl.Add(newNavNode);
// ctx.ExecuteQuery();
// logger.LogInformation($"> Il menu rapido è stato aggiornato, il collegamemento a {docLibName} è ora disponibile.");
// #endregion
// }
// catch (Exception ex)
// {
// logger.LogError("Create Doc Lib", ex);
// }
// }
// public void OfferDocSet(string quotationName, string docLibName, string tenantName, ClientContext ctx) //TODO: add onenote on creation of
// {
// try
// {
// #region Context
// var web = ctx.Web;
// ctx.Load(web, w => w.Url);
// var list = web.Lists.GetByTitle(docLibName);
// ctx.Load(list, l => l.RootFolder, l => l.ContentTypes, l => l.Fields, l => l.ContentTypesEnabled);
// ctx.ExecuteQuery();
// list.ContentTypesEnabled = true;
// list.Update();
// if (spc.ListContentTypeExist(ctx, docLibName, "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
// logger.LogInformation($"> Inizializzata la fase di creazione per {quotationName}.");
// #region DocSet Field Entry
// DocumentSet.Create(ctx, list.RootFolder, quotationName, contentType.Id);
// ctx.ExecuteQuery();
// logger.LogInformation($"> DocumentSet {quotationName} creata.");
// var dsItem = list.RootFolder.Folders.GetByUrl(quotationName).ListItemAllFields;
// dsItem["PAL_ID_Quotation"] = "valueItemCode";
// dsItem["PAL_Quotation_Name"] = "valueItemDescription";
// dsItem["PAL_Quotation_Reason"] = "NC NON CONFORMITÁ";
// dsItem["PAL_Authors"] = "Test";
// dsItem.Update();
// ctx.ExecuteQuery();
// logger.LogInformation($"> Field value update.");
// #endregion
// #region Quotation Folder
// var rev = "Rev. 1";
// string[] folderName = { rev, $"{rev}/01_Costificazione", $"{rev}/02_Offerta", $"{rev}/03_Meeting", $"{rev}/04_Corrispondenza", $"{rev}/08_Specifiche_Tecniche", $"{rev}/10_Fornitori", $"{rev}/11_Documenti_Tecnici", $"{rev}/14_Foto" };
// foreach (var name in folderName)
// {
// logger.LogInformation($"La sotto cartella {name} verrà creata in {quotationName}");
// var rPath = ResourcePath.FromDecodedUrl($"{quotationName}/{name}");
// list.RootFolder.AddSubFolderUsingPath(rPath);
// }
// ctx.ExecuteQuery();
// spc.OnenoteSPFeature(ctx, tenantName, quotationName);
// logger.LogInformation($"Le sotto cartelle sono state create con successo in {quotationName}");
// #endregion
// logger.LogInformation($"> {quotationName} creato con successo in Offerte/{docLibName}.");
// }
// catch (Exception ex)
// {
// logger.LogError("Create Doc Set", ex);
// }
// }
// }
//}
@@ -10,6 +10,7 @@ public class SharePointStructureBuilderService : ISharePointStructureBuilder
private readonly ISubProjectRepository subProjectRepository;
private readonly ISubProjectBuilderService subProjectBuilderService;
private readonly IQuotationBuildService quotationBuildService;
private readonly INonComplianceBuildService nonComplianceBuildService;
private readonly IWebpartService webpartService;
public SharePointStructureBuilderService(
@@ -17,12 +18,14 @@ public class SharePointStructureBuilderService : ISharePointStructureBuilder
ISubProjectRepository subProjectRepository,
ISubProjectBuilderService subProjectBuilderService,
IQuotationBuildService quotationBuildService,
INonComplianceBuildService nonComplianceBuildService,
IWebpartService webpartService)
{
this.siteService = siteService;
this.subProjectRepository = subProjectRepository;
this.subProjectBuilderService = subProjectBuilderService;
this.quotationBuildService = quotationBuildService;
this.nonComplianceBuildService = nonComplianceBuildService;
this.webpartService = webpartService;
}
@@ -72,7 +75,7 @@ public class SharePointStructureBuilderService : ISharePointStructureBuilder
throw new Exception($"Impossibile to build site");
}
quotationBuildService.CreateIfNotExists(nonComplianceName);
nonComplianceBuildService.CreateIfNotExists(nonComplianceName);
return true;
}
@@ -1,7 +1,6 @@
using console_spo_utils.Interfaces.Services;
using Microsoft.Extensions.Logging;
using Microsoft.Online.SharePoint.TenantAdministration;
using System.Security;
using console_spo_utils.Enums;
namespace console_spo_utils.Services;
@@ -1,11 +1,7 @@
using console_spo_utils.Interfaces.Services;
using Microsoft.Extensions.Logging;
using Microsoft.Graph;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
using OfficeDevPnP.Core.Pages;
//using PnP.Core.Model;
namespace console_spo_utils.Services
+1 -1
View File
@@ -36,7 +36,7 @@ namespace console_spo_utils.Workers
return;
}
var buildNonComplianceResult = structureBuilder.BuildNonCompliance("NC0001");
var buildNonComplianceResult = structureBuilder.BuildNonCompliance("NC0002");
if (!buildNonComplianceResult)
{