Service update, import changes from web_portal
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
using console_spo_utils.Model;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Web;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services
|
||||
namespace library_spo_utils.Services
|
||||
{
|
||||
internal sealed class SharePointAuthenticationManager : IDisposable, ISharePointAuthenticationManager
|
||||
{
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
using Microsoft.SharePoint.Client;
|
||||
using System;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using AngleSharp.Dom;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using PnP.Framework.Extensions;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class FieldEntryDataUpdate : IFieldEntryDataUpdate
|
||||
{
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly IProjectRepository _projectRepository;
|
||||
private readonly ISubProjectRepository _subProjectRepository;
|
||||
private readonly IQuotationRepository _quotationRepository;
|
||||
private readonly INonComplianceRepository _nonComplianceRepository;
|
||||
private readonly IPurchasingOrderRepository _purchasingOrderRepository;
|
||||
private readonly IPurchasingPackingSlipRepository _purchasingPackingSlipRepository;
|
||||
private readonly IPurchasingRequestRepository _purchasingRequestRepository;
|
||||
|
||||
public FieldEntryDataUpdate(
|
||||
ISiteOptions siteOptions,
|
||||
IProjectRepository projectRepository,
|
||||
ISubProjectRepository subProjectRepository,
|
||||
IQuotationRepository quotationRepository,
|
||||
INonComplianceRepository nonComplianceRepository,
|
||||
IPurchasingOrderRepository purchasingOrderRepository,
|
||||
IPurchasingPackingSlipRepository purchasingPackingSlipRepository,
|
||||
IPurchasingRequestRepository purchasingRequestRepository
|
||||
)
|
||||
{
|
||||
_siteOptions = siteOptions;
|
||||
_projectRepository = projectRepository;
|
||||
_subProjectRepository = subProjectRepository;
|
||||
_quotationRepository = quotationRepository;
|
||||
_nonComplianceRepository = nonComplianceRepository;
|
||||
_purchasingOrderRepository = purchasingOrderRepository;
|
||||
_purchasingPackingSlipRepository = purchasingPackingSlipRepository;
|
||||
_purchasingRequestRepository = purchasingRequestRepository;
|
||||
}
|
||||
|
||||
public void FieldUpdate(ClientContext ctx, string listName, string element, FieldUpdateType type)
|
||||
{
|
||||
List oList = ctx.Web.Lists.GetByTitle(listName);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case FieldUpdateType.Project:
|
||||
Project(ctx, oList, element);
|
||||
break;
|
||||
|
||||
case FieldUpdateType.SubProject:
|
||||
SubProject(ctx, oList, element);
|
||||
break;
|
||||
|
||||
case FieldUpdateType.Quotation:
|
||||
Quotation(ctx, oList, element);
|
||||
break;
|
||||
|
||||
case FieldUpdateType.NonCompliance:
|
||||
NonCompliance(ctx, oList, element);
|
||||
break;
|
||||
|
||||
case FieldUpdateType.PurchasingOrder:
|
||||
PurchasingOrder(ctx, oList, element);
|
||||
break;
|
||||
|
||||
case FieldUpdateType.PurchasingPackingSlip:
|
||||
PurchasingPackingSlip(ctx, oList, element);
|
||||
break;
|
||||
|
||||
case FieldUpdateType.PurchasingRequest:
|
||||
PurchasingRequest(ctx, oList, element);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Project(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
var url = $"/sites/{_siteOptions.GetProjYearTenant(element).Replace(" ", string.Empty)}/{element}";
|
||||
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='PAL_ID_Project'/><Value Type='URL'>{url}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["PAL_Description"] = _projectRepository.DefaultDescription(element);
|
||||
oListItem["PAL_Customer"] = _projectRepository.DefaultCostumer(element);
|
||||
oListItem["PAL_DlvReason"] = _projectRepository.DefaultDlvReason(element);
|
||||
oListItem["PAL_Status"] = _projectRepository.DefaultState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
private void SubProject(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{element}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["_ExtendedDescription"] = _subProjectRepository.DefaultDescription(element);
|
||||
oListItem["PAL_Item"] = _subProjectRepository.DefaultItem(element);
|
||||
oListItem["PAL_ItemCode"] = _subProjectRepository.DefaultItemCode(element);
|
||||
oListItem["PAL_ItemDescription"] = _subProjectRepository.DefaultItemDescription(element);
|
||||
oListItem["PAL_SerialNumber"] = _subProjectRepository.DefaultSerialNumber(element);
|
||||
oListItem["PAL_Status"] = _subProjectRepository.DefaultState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
private void Quotation(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{element}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["PAL_ID_Quotation"] = _quotationRepository.DefaultIdQuotation(element);
|
||||
oListItem["PAL_Quotation_Name"] = _quotationRepository.DefaultQuotationName(element);
|
||||
oListItem["PAL_Description"] = _quotationRepository.DefaultDescription(element);
|
||||
oListItem["PAL_Quotation_Reason"] = _quotationRepository.DefaultQuotationReason(element);
|
||||
oListItem["PAL_Authors"] = _quotationRepository.DefaultAuthors(element);
|
||||
oListItem["PAL_Status"] = _quotationRepository.DefaultQuotationState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
private void NonCompliance(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{element}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["PAL_NC_Source"] = _nonComplianceRepository.DefaultNonComplianceSource(element);
|
||||
oListItem["PAL_NC_Reference"] = _nonComplianceRepository.DefaultNonComplianceReference(element);
|
||||
oListItem["PAL_NC_Nominative"] = _nonComplianceRepository.DefaultNonComplianceNominative(element);
|
||||
oListItem["PAL_NC_DateOfDetection"] = _nonComplianceRepository.DefaultNonComplianceDateOfDetection(element);
|
||||
oListItem["PAL_NC_Project"] = _nonComplianceRepository.DefaultNonComplianceProject(element);
|
||||
oListItem["PAL_NC_ItemCode"] = _nonComplianceRepository.DefaultNonComplianceItemCode(element);
|
||||
oListItem["PAL_NC_PortalUrl"] = _nonComplianceRepository.DefaultNonCompliancePortalUrl(element);
|
||||
oListItem["PAL_Status"] = _nonComplianceRepository.DefaultNonComplianceState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
private void PurchasingOrder(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{element}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["PAL_PO_Supplier"] = _purchasingOrderRepository.DefaultPurchasingOrderSupplier(element);
|
||||
oListItem["PAL_Status"] = _purchasingOrderRepository.DefaultPurchasingOrderState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
private void PurchasingPackingSlip(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{element}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["PAL_PO_Supplier"] = _purchasingPackingSlipRepository.DefaultPurchasingPackingSlipSupplier(element);
|
||||
oListItem["PAL_Status"] = _purchasingPackingSlipRepository.DefaultPurchasingPackingSlipState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
private void PurchasingRequest(ClientContext ctx, List oList, string element)
|
||||
{
|
||||
|
||||
CamlQuery cQuery = new CamlQuery()
|
||||
{
|
||||
ViewXml = $"<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{element}</Value></Eq></Where></Query></View>"
|
||||
};
|
||||
|
||||
var collection = oList.GetItems(cQuery);
|
||||
|
||||
ctx.Load(collection);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
foreach (var oListItem in collection)
|
||||
{
|
||||
oListItem["PAL_PO_Supplier"] = _purchasingRequestRepository.DefaultPurchasingRequestSupplier(element);
|
||||
oListItem["PAL_Status"] = _purchasingRequestRepository.DefaultPurchasingRequestState(element);
|
||||
oListItem.Update();
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class NonComplianceBuildService : INonComplianceBuildService
|
||||
{
|
||||
@@ -11,6 +12,7 @@ internal class NonComplianceBuildService : INonComplianceBuildService
|
||||
private readonly ITenantService tenantService;
|
||||
private readonly INonComplianceDocLibraryService nonComplianceDocLibraryService;
|
||||
private readonly INonComplianceDocSetService nonComplianceDocSetService;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<NonComplianceBuildService> logger;
|
||||
|
||||
public NonComplianceBuildService(
|
||||
@@ -20,6 +22,7 @@ internal class NonComplianceBuildService : INonComplianceBuildService
|
||||
ITenantService tenantService,
|
||||
INonComplianceDocLibraryService nonComplianceDocLibraryService,
|
||||
INonComplianceDocSetService nonComplianceDocSetService,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<NonComplianceBuildService> logger)
|
||||
{
|
||||
this.siteOptions = siteOptions;
|
||||
@@ -28,6 +31,7 @@ internal class NonComplianceBuildService : INonComplianceBuildService
|
||||
this.tenantService = tenantService;
|
||||
this.nonComplianceDocLibraryService = nonComplianceDocLibraryService;
|
||||
this.nonComplianceDocSetService = nonComplianceDocSetService;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@@ -35,24 +39,27 @@ internal class NonComplianceBuildService : INonComplianceBuildService
|
||||
{
|
||||
var site = siteOptions.GetNonComplianceSite();
|
||||
var ctx = sharePointAuthenticationManager.GetContext(site);
|
||||
var list = siteOptions.GetNonComplianceLibrary();
|
||||
var list = siteOptions.GetNonComplianceLibrary(nonComplianceName);
|
||||
var tenant = siteOptions.GetNonComplianceTenant();
|
||||
|
||||
if (!spc.SiteExist(ctx))
|
||||
{
|
||||
tenantService.CreateForNonCompliance();
|
||||
}
|
||||
else if (!spc.ListExist(ctx, list))
|
||||
|
||||
if (!spc.ListExist(ctx, list))
|
||||
{
|
||||
nonComplianceDocLibraryService.Create(list, ctx);
|
||||
}
|
||||
else if (!spc.FolderExistsInsideList(ctx, list, nonComplianceName))
|
||||
|
||||
if (!spc.FolderExistsInsideList(ctx, list, nonComplianceName))
|
||||
{
|
||||
nonComplianceDocSetService.Create(nonComplianceName, list, tenant, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogInformation($"Quotation with {nonComplianceName} already exist");
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, list, nonComplianceName, FieldUpdateType.NonCompliance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class NonComplianceDocLibraryService : INonComplianceDocLibraryService
|
||||
{
|
||||
@@ -45,7 +46,7 @@ internal class NonComplianceDocLibraryService : INonComplianceDocLibraryService
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
string[] fieldName = { "Sorgente", "Rifermento", "Nominativo", "Data Rilevazione", "Commessa", "Parte", "Portal" };
|
||||
string[] fieldName = { "Sorgente", "Rifermento", "Nominativo", "Data Rilevazione", "Commessa", "Parte", "Portal", "Stato" };
|
||||
|
||||
foreach (var fn in fieldName)
|
||||
{
|
||||
@@ -71,7 +72,7 @@ internal class NonComplianceDocLibraryService : INonComplianceDocLibraryService
|
||||
viewCreation.Title = libName;
|
||||
viewCreation.ViewTypeKind = ViewType.None;
|
||||
viewCreation.ColumnWidth = "350";
|
||||
viewCreation.ViewFields = new string[] { "Type", "Name", "Sorgente", "Rifermento", "Nominativo", "Data Rilevazione", "Commessa", "Parte", "Portal" };
|
||||
viewCreation.ViewFields = Fields.NonComplianceView;
|
||||
|
||||
var view = views.Add(viewCreation);
|
||||
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Repositories;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class NonComplianceDocSetService : INonComplianceDocSetService
|
||||
{
|
||||
private readonly ISharePointCustomOperation cpt;
|
||||
private readonly IOneNoteService oneNoteService;
|
||||
private readonly INonComplianceRepository nonComplianceRepository;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
|
||||
public NonComplianceDocSetService(
|
||||
ISharePointCustomOperation cpt,
|
||||
IOneNoteService oneNoteService,
|
||||
INonComplianceRepository nonComplianceRepository)
|
||||
INonComplianceRepository nonComplianceRepository,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate)
|
||||
{
|
||||
this.cpt = cpt;
|
||||
this.oneNoteService = oneNoteService;
|
||||
this.nonComplianceRepository = nonComplianceRepository;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
}
|
||||
|
||||
public void Create(string nonComplianceName, string docLibraryName, string tenantName, ClientContext ctx)
|
||||
@@ -59,7 +62,6 @@ internal class NonComplianceDocSetService : INonComplianceDocSetService
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione per {nonComplianceName}.");
|
||||
|
||||
#region DocSet Field Entry
|
||||
@@ -69,33 +71,27 @@ internal class NonComplianceDocSetService : INonComplianceDocSetService
|
||||
|
||||
Console.WriteLine($"> DocumentSet {nonComplianceName} creata.");
|
||||
|
||||
var dsItem = list.RootFolder.Folders.GetByUrl(nonComplianceName).ListItemAllFields;
|
||||
//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["PAL_NC_Source"] = nonComplianceRepository.DefaultNonComplianceSource(nonComplianceName);
|
||||
//dsItem["PAL_NC_Reference"] = nonComplianceRepository.DefaultNonComplianceReference(nonComplianceName);
|
||||
//dsItem["PAL_NC_Nominative"] = nonComplianceRepository.DefaultNonComplianceNominative(nonComplianceName);
|
||||
//dsItem["PAL_NC_DateOfDetection"] = nonComplianceRepository.DefaultNonComplianceDateOfDetection(nonComplianceName);
|
||||
//dsItem["PAL_NC_Project"] = nonComplianceRepository.DefaultNonComplianceProject(nonComplianceName);
|
||||
//dsItem["PAL_NC_ItemCode"] = nonComplianceRepository.DefaultNonComplianceItemCode(nonComplianceName);
|
||||
//dsItem["PAL_NC_PortalUrl"] = nonComplianceRepository.DefaultNonCompliancePortalUrl(nonComplianceName);
|
||||
//dsItem["PAL_Status"] = nonComplianceRepository.DefaultNonComplianceState(nonComplianceName);
|
||||
|
||||
dsItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
//dsItem.Update();
|
||||
//ctx.ExecuteQuery();
|
||||
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, docLibraryName, nonComplianceName, FieldUpdateType.NonCompliance);
|
||||
|
||||
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();
|
||||
#region Folder
|
||||
|
||||
oneNoteService.CreateFolderInsideNonCompliance(nonComplianceName, ctx);
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using System.Net;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class OneNoteService : IOneNoteService
|
||||
{
|
||||
@@ -31,7 +34,7 @@ internal class OneNoteService : IOneNoteService
|
||||
ctx.Load(list, l => l.RootFolder);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetProjYearTenant()} Notebook/{projName}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetProjYearTenant(projName)} Notebook/{projName}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
@@ -46,6 +49,7 @@ internal class OneNoteService : IOneNoteService
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateFolderInsideQuotation(string quotationName, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
@@ -53,18 +57,20 @@ internal class OneNoteService : IOneNoteService
|
||||
|
||||
logger.LogInformation($"> Inizializzata la fase di creazione della sezione {quotationName} in OneNote.");
|
||||
|
||||
var year = siteOptions.GetYear(quotationName);
|
||||
|
||||
var list = ctx.Web.Lists.EnsureSiteAssetsLibrary();
|
||||
ctx.Load(list, l => l.RootFolder);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
if (!spc.FolderExistsInsideList(ctx, $"{siteOptions.GetQuotationTenant()} Notebook", $"{DateTime.Today.Year}"))
|
||||
if (!spc.FolderExist(ctx, $"SiteAssets/{siteOptions.GetQuotationTenant()} Notebook/{year}"))
|
||||
{
|
||||
var rYearPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetQuotationTenant()} Notebook/{DateTime.Today.Year}");
|
||||
var rYearPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetQuotationTenant()} Notebook/{year}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rYearPath);
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetQuotationTenant()} Notebook/{DateTime.Today.Year}/{quotationName}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetQuotationTenant()} Notebook/{year}/{quotationName}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
@@ -80,29 +86,31 @@ internal class OneNoteService : IOneNoteService
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateFolderInsideNonCompliance(string quotationName, ClientContext ctx)
|
||||
public bool CreateFolderInsideNonCompliance(string nonComplianceName, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
logger.LogInformation($"> Inizializzata la fase di creazione della sezione {quotationName} in OneNote.");
|
||||
logger.LogInformation($"> Inizializzata la fase di creazione della sezione {nonComplianceName} in OneNote.");
|
||||
|
||||
var year = siteOptions.GetYear(nonComplianceName);
|
||||
|
||||
var list = ctx.Web.Lists.EnsureSiteAssetsLibrary();
|
||||
ctx.Load(list, l => l.RootFolder);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
if (!spc.FolderExistsInsideList(ctx, $"{siteOptions.GetNonComplianceTenant()} Notebook", $"{DateTime.Today.Year}"))
|
||||
if (!spc.FolderExist(ctx, $"SiteAssets/{siteOptions.GetNonComplianceTenant()} Notebook/{year}"))
|
||||
{
|
||||
var rYearPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetNonComplianceTenant()} Notebook/{DateTime.Today.Year}");
|
||||
var rYearPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetNonComplianceTenant()} Notebook/{year}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rYearPath);
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetNonComplianceTenant()} Notebook/{DateTime.Today.Year}/{quotationName}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{siteOptions.GetNonComplianceTenant()} Notebook/{year}/{nonComplianceName}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
logger.LogInformation($"> Completata la fase di creazione della sezione {quotationName} in OneNote.");
|
||||
logger.LogInformation($"> Completata la fase di creazione della sezione {nonComplianceName} in OneNote.");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -114,6 +122,62 @@ internal class OneNoteService : IOneNoteService
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateFolderInsidePurchasing(string purchasingName, ClientContext ctx, PurchType type)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"> Inizializzata la fase di creazione della sezione {purchasingName} in OneNote.");
|
||||
|
||||
var purchasingOneNote = "Acquisti Notebook";
|
||||
var year = siteOptions.GetYear(purchasingName);
|
||||
|
||||
|
||||
var list = ctx.Web.Lists.EnsureSiteAssetsLibrary();
|
||||
ctx.Load(list, l => l.RootFolder);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
if (!spc.FolderExist(ctx, $"SiteAssets/{purchasingOneNote}/{year}"))
|
||||
{
|
||||
foreach (var dir in Folders.PurchasingOneNoteDir(year))
|
||||
{
|
||||
var rDirPath = ResourcePath.FromDecodedUrl($"{purchasingOneNote}/{dir}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rDirPath);
|
||||
ctx.ExecuteQuery();
|
||||
}
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case PurchType.Order:
|
||||
var oPath = ResourcePath.FromDecodedUrl($"{purchasingOneNote}/{year}/Ordini di Acquisto/{purchasingName}");
|
||||
list.RootFolder.AddSubFolderUsingPath(oPath);
|
||||
ctx.ExecuteQuery();
|
||||
break;
|
||||
|
||||
case PurchType.PackingSlip:
|
||||
var psPath = ResourcePath.FromDecodedUrl($"{purchasingOneNote}/{year}/DDT di Acquisto/{purchasingName}");
|
||||
list.RootFolder.AddSubFolderUsingPath(psPath);
|
||||
ctx.ExecuteQuery();
|
||||
break;
|
||||
|
||||
case PurchType.Request:
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{purchasingOneNote}/{year}/Richieste di Acquisto/{purchasingName}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
ctx.ExecuteQuery();
|
||||
break;
|
||||
}
|
||||
|
||||
logger.LogInformation($"> Completata la fase di creazione della sezione {purchasingName} in OneNote.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "OnenoteSPFeature");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void EnableFeature(ClientContext ctx)
|
||||
{
|
||||
var featureName = "SiteNotebook";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class ProjectDocLibraryService : IProjectDocLibraryService
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Navigation;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class ProjectQuickMenuService : IProjectQuickMenuService
|
||||
{
|
||||
@@ -50,7 +49,9 @@ internal class ProjectQuickMenuService : IProjectQuickMenuService
|
||||
continue;
|
||||
}
|
||||
|
||||
ctx.Web.RootFolder.WelcomePage = $"SottoCommesse%20{projName}/Forms/SottoCommesse%20{projName}.aspx";
|
||||
var projNameWithoutDash = projName.Replace("-", "");
|
||||
|
||||
ctx.Web.RootFolder.WelcomePage = $"SottoCommesse%20{projNameWithoutDash}/Forms/SottoCommesse%20{projNameWithoutDash}.aspx";
|
||||
|
||||
ctx.Web.RootFolder.Update();
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.WebParts;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class ProjectService : IProjectService
|
||||
{
|
||||
@@ -24,13 +24,13 @@ internal class ProjectService : IProjectService
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void BuildWebParts()
|
||||
public void BuildWebParts(string projName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string wpName = siteOptions.GetProjYearTenant();
|
||||
string wpName = siteOptions.GetProjYearTenant(projName);
|
||||
|
||||
var listView = GetListsId(siteOptions.GetProjListTitle(), Fields.SynthticProjTitle);
|
||||
var listView = GetListsId(projName, siteOptions.GetProjListTitle(projName), Fields.SynthticProjTitle);
|
||||
|
||||
var ctx = sharePointAuthenticationManager.GetContext(siteOptions.GetProjectSite());
|
||||
Web web = ctx.Web;
|
||||
@@ -40,11 +40,11 @@ internal class ProjectService : IProjectService
|
||||
|
||||
LimitedWebPartManager mgr = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
|
||||
|
||||
string url = siteOptions.GetProjectYearSite() + "/Lists/" +
|
||||
siteOptions.GetProjListTitle().Replace(" ", "%20") +
|
||||
"/" + siteOptions.GetProjListTitle().Replace(" ", "%20") + ".aspx?viewid=";
|
||||
string url = siteOptions.GetProjectYearSite(projName) + "/Lists/" +
|
||||
siteOptions.GetProjListTitle(projName).Replace(" ", "%20") +
|
||||
"/" + siteOptions.GetProjListTitle(projName).Replace(" ", "%20") + ".aspx?viewid=";
|
||||
|
||||
string htmlSchema = $"<div><h1 style=\"font-weight: bold; font-size: 18pt; clear: both;\">{siteOptions.GetProjYearTenant()}</h1></div>" +
|
||||
string htmlSchema = $"<div><h1 style=\"font-weight: bold; font-size: 18pt; clear: both;\">{siteOptions.GetProjYearTenant(projName)}</h1></div>" +
|
||||
$"<div><p><a style=\"color: green\" href=\"{url}{listView[Fields.SynthticProjTitle[0]]}\">Progetti Macchina</a><br>Solo i progetti di vendita Macchine/Impianti</p></div>" +
|
||||
$"<div><p><a style=\"color: green\" href=\"{url}{listView[Fields.SynthticProjTitle[1]]}\">Progetti Ricambi</a><br>Solo i progetti di vendita Ricambi</p></div>" +
|
||||
$"<div><p><a style=\"color: green\" href=\"{url}{listView[Fields.SynthticProjTitle[2]]}\">Altri Progetti</a><br>Tutti gli altri progetti che non siano di vendita Macchine/Impianti o Ricambi</p></div>";
|
||||
@@ -53,7 +53,7 @@ internal class ProjectService : IProjectService
|
||||
"<WebPart xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
|
||||
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
|
||||
" xmlns=\"http://schemas.microsoft.com/WebPart/v2\">" +
|
||||
$"<Title>{siteOptions.GetProjYearTenant()}</Title><FrameType>None</FrameType>" +
|
||||
$"<Title>{siteOptions.GetProjYearTenant(projName)}</Title><FrameType>None</FrameType>" +
|
||||
"<Assembly>Microsoft.SharePoint, Version=13.0.0.0, Culture=neutral, " +
|
||||
"PublicKeyToken=94de0004b6e3fcc5</Assembly>" +
|
||||
"<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>" +
|
||||
@@ -67,8 +67,8 @@ internal class ProjectService : IProjectService
|
||||
|
||||
var qm = new NavigationNodeCreationInformation()
|
||||
{
|
||||
Title = siteOptions.GetProjYearTenant(),
|
||||
Url = siteOptions.GetProjectYearSite().ToString(),
|
||||
Title = siteOptions.GetProjYearTenant(projName),
|
||||
Url = siteOptions.GetProjectYearSite(projName).ToString(),
|
||||
AsLastNode = true
|
||||
};
|
||||
|
||||
@@ -82,7 +82,7 @@ internal class ProjectService : IProjectService
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetListsId(string listTitle, string[] listViewTitle)
|
||||
private Dictionary<string, string> GetListsId(string projName, string listTitle, string[] listViewTitle)
|
||||
{
|
||||
Dictionary<string, string> listViewId = new Dictionary<string, string>();
|
||||
|
||||
@@ -90,7 +90,7 @@ internal class ProjectService : IProjectService
|
||||
{
|
||||
foreach (var lViewTitle in listViewTitle)
|
||||
{
|
||||
var ctx = sharePointAuthenticationManager.GetContext(siteOptions.GetProjectYearSite());
|
||||
var ctx = sharePointAuthenticationManager.GetContext(siteOptions.GetProjectYearSite(projName));
|
||||
|
||||
var list = ctx.Web.Lists.GetByTitle(listTitle);
|
||||
ctx.Load(list.Views);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class ProjectYearService : IProjectYearService
|
||||
{
|
||||
@@ -18,7 +18,7 @@ internal class ProjectYearService : IProjectYearService
|
||||
this.projectService = projectService;
|
||||
}
|
||||
|
||||
public void CreateList(string listTitle, ClientContext ctx)
|
||||
public void CreateList(string projName, string listTitle, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -66,7 +66,7 @@ internal class ProjectYearService : IProjectYearService
|
||||
|
||||
foreach (var fn in Fields.SiteFields)
|
||||
{
|
||||
var Fields = siteField.Fields.GetByTitle(fn);
|
||||
var Fields = siteField.Fields.GetByInternalNameOrTitle(fn);
|
||||
list.Fields.Add(Fields);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ internal class ProjectYearService : IProjectYearService
|
||||
|
||||
CreateViewList(list, ctx);
|
||||
|
||||
projectService.BuildWebParts();
|
||||
projectService.BuildWebParts(projName);
|
||||
|
||||
|
||||
Console.WriteLine($"> Impostata come HomePage di '{viewCreation.Title}'");
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Runtime.CompilerServices;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingOrderBuildService : IPurchasingOrderBuildService
|
||||
{
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly ISharePointAuthenticationManager _sharePointAuthenticationManager;
|
||||
private readonly ISharePointCustomOperation _spc;
|
||||
private readonly IPurchasingOrderDocLibraryService _purchasingOrderDocLibraryService;
|
||||
private readonly IPurchasingOrderDocSetService _purchasingOrderDocSetService;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<PurchasingOrderBuildService> _logger;
|
||||
|
||||
public PurchasingOrderBuildService(ISiteOptions siteOptions,
|
||||
ISharePointAuthenticationManager sharePointAuthenticationManager,
|
||||
ISharePointCustomOperation spc,
|
||||
IPurchasingOrderDocLibraryService purchasingOrderDocLibraryService,
|
||||
IPurchasingOrderDocSetService purchasingOrderDocSetService,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<PurchasingOrderBuildService> logger)
|
||||
{
|
||||
_siteOptions = siteOptions;
|
||||
_sharePointAuthenticationManager = sharePointAuthenticationManager;
|
||||
_spc = spc;
|
||||
_purchasingOrderDocLibraryService = purchasingOrderDocLibraryService;
|
||||
_purchasingOrderDocSetService = purchasingOrderDocSetService;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateIfNotExists(string purchasingOrder)
|
||||
{
|
||||
var site = _siteOptions.GetPurchasingOrderSite();
|
||||
var ctx = _sharePointAuthenticationManager.GetContext(site);
|
||||
var list = _siteOptions.GetPurchasingOrderLibrary(purchasingOrder);
|
||||
var tenant = _siteOptions.GetPurchasingOrderTenat();
|
||||
|
||||
if (!_spc.SiteExist(ctx))
|
||||
{
|
||||
throw new Exception($"Impossibile to build site it don't exist");
|
||||
}
|
||||
|
||||
if (!_spc.ListExist(ctx, list))
|
||||
{
|
||||
_purchasingOrderDocLibraryService.Create(list, ctx);
|
||||
}
|
||||
|
||||
if (!_spc.FolderExistsInsideList(ctx, list, purchasingOrder))
|
||||
{
|
||||
_purchasingOrderDocSetService.Create(purchasingOrder, list, tenant, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, list, purchasingOrder, FieldUpdateType.PurchasingOrder);
|
||||
_logger.LogInformation($"Quotation with {purchasingOrder} already exist");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingOrderDocLibraryService : IPurchasingOrderDocLibraryService
|
||||
{
|
||||
private readonly ILogger<PurchasingOrderDocLibraryService> _logger;
|
||||
|
||||
public PurchasingOrderDocLibraryService(ILogger<PurchasingOrderDocLibraryService> logger)
|
||||
{
|
||||
_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 = { "Fornitore", "Stato" };
|
||||
|
||||
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 = Fields.PurchasingView;
|
||||
|
||||
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")}";
|
||||
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,112 @@
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingOrderDocSetService : IPurchasingOrderDocSetService
|
||||
{
|
||||
private readonly IPurchasingOrderRepository _purchasingOrderRepository;
|
||||
private readonly ISharePointCustomOperation _cpt;
|
||||
private readonly IOneNoteService _oneNoteService;
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ISharePointAuthenticationManager _sharePointAuthenticationManager;
|
||||
private readonly ILogger<PurchasingOrderBuildService> _logger;
|
||||
|
||||
public PurchasingOrderDocSetService(
|
||||
IPurchasingOrderRepository purchasingOrderRepository,
|
||||
ISharePointCustomOperation cpt,
|
||||
IOneNoteService oneNoteService,
|
||||
ISiteOptions siteOptions,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ISharePointAuthenticationManager sharePointAuthenticationManager,
|
||||
ILogger<PurchasingOrderBuildService> logger)
|
||||
{
|
||||
_purchasingOrderRepository = purchasingOrderRepository;
|
||||
_cpt = cpt;
|
||||
_oneNoteService = oneNoteService;
|
||||
_siteOptions = siteOptions;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
_sharePointAuthenticationManager = sharePointAuthenticationManager;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Create(string purchasingOrderName, 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 {purchasingOrderName}.");
|
||||
|
||||
#region DocSet Field Entry
|
||||
|
||||
DocumentSet.Create(ctx, list.RootFolder, purchasingOrderName, contentType.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> DocumentSet {purchasingOrderName} creata.");
|
||||
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, docLibraryName, purchasingOrderName, FieldUpdateType.PurchasingOrder);
|
||||
|
||||
Console.WriteLine($"> Field value update.");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Folder
|
||||
|
||||
foreach (var name in Folders.PurchasingOrder)
|
||||
{
|
||||
Console.WriteLine($"La sotto cartella {name} verrà creata in {purchasingOrderName}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{purchasingOrderName}/{name}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
var purchCtx = _sharePointAuthenticationManager.GetContext(_siteOptions.GetPurchasingSite());
|
||||
|
||||
_oneNoteService.CreateFolderInsidePurchasing(purchasingOrderName, purchCtx, PurchType.Order);
|
||||
|
||||
Console.WriteLine($"Le sotto cartelle sono state create con successo in {purchasingOrderName}");
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine($"> {purchasingOrderName} creato con successo.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingPackingSlipBuildService : IPurchasingPackingSlipBuildService
|
||||
{
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly ISharePointAuthenticationManager _sharePointAuthenticationManager;
|
||||
private readonly ISharePointCustomOperation _spc;
|
||||
private readonly IPurchasingPackingSlipDocLibraryService _purchasingPackingSlipDocLibraryService;
|
||||
private readonly IPurchasingPackingSlipDocSetService _purchasingPackingSlipDocSetService;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<PurchasingOrderBuildService> _logger;
|
||||
|
||||
public PurchasingPackingSlipBuildService(
|
||||
ISiteOptions siteOptions,
|
||||
ISharePointAuthenticationManager sharePointAuthenticationManager,
|
||||
ISharePointCustomOperation spc,
|
||||
IPurchasingPackingSlipDocLibraryService purchasingPackingSlipDocLibraryService,
|
||||
IPurchasingPackingSlipDocSetService purchasingPackingSlipDocSetService,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<PurchasingOrderBuildService> logger)
|
||||
{
|
||||
_siteOptions = siteOptions;
|
||||
_sharePointAuthenticationManager = sharePointAuthenticationManager;
|
||||
_spc = spc;
|
||||
_purchasingPackingSlipDocLibraryService = purchasingPackingSlipDocLibraryService;
|
||||
_purchasingPackingSlipDocSetService = purchasingPackingSlipDocSetService;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateIfNotExists(string purchasingPackingSlipName)
|
||||
{
|
||||
var site = _siteOptions.GetPurchasingPackingSlipSite();
|
||||
var ctx = _sharePointAuthenticationManager.GetContext(site);
|
||||
var list = _siteOptions.GetPurchasingPackingSlipLibrary(purchasingPackingSlipName);
|
||||
var tenant = _siteOptions.GetPurchasingPackingSlipTenat();
|
||||
|
||||
if (!_spc.SiteExist(ctx))
|
||||
{
|
||||
throw new Exception($"Impossibile to build site it don't exist");
|
||||
}
|
||||
|
||||
if (!_spc.ListExist(ctx, list))
|
||||
{
|
||||
_purchasingPackingSlipDocLibraryService.Create(list, ctx);
|
||||
}
|
||||
|
||||
if (!_spc.FolderExistsInsideList(ctx, list, purchasingPackingSlipName))
|
||||
{
|
||||
_purchasingPackingSlipDocSetService.Create(purchasingPackingSlipName, list, tenant, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation($"Quotation with {purchasingPackingSlipName} already exist");
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, list, purchasingPackingSlipName, FieldUpdateType.PurchasingPackingSlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingPackingSlipDocLibraryService : IPurchasingPackingSlipDocLibraryService
|
||||
{
|
||||
private readonly ILogger<PurchasingPackingSlipDocLibraryService> _logger;
|
||||
|
||||
public PurchasingPackingSlipDocLibraryService(ILogger<PurchasingPackingSlipDocLibraryService> logger)
|
||||
{
|
||||
_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 = { "Fornitore", "Stato" };
|
||||
|
||||
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 = Fields.PurchasingView;
|
||||
|
||||
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")}";
|
||||
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,113 @@
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingPackingSlipDocSetService : IPurchasingPackingSlipDocSetService
|
||||
{
|
||||
private readonly IPurchasingPackingSlipRepository _purchasingPackingSlipRepository;
|
||||
private readonly ISharePointCustomOperation _cpt;
|
||||
private readonly IOneNoteService _oneNoteService;
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly ISharePointAuthenticationManager _sharePointAuthenticationManager;
|
||||
private readonly ILogger<PurchasingPackingSlipDocSetService> _logger;
|
||||
|
||||
public PurchasingPackingSlipDocSetService(
|
||||
IPurchasingPackingSlipRepository purchasingPackingSlipRepository,
|
||||
ISharePointCustomOperation cpt,
|
||||
IOneNoteService oneNoteService,
|
||||
ISiteOptions siteOptions,
|
||||
ISharePointAuthenticationManager sharePointAuthenticationManager,
|
||||
ILogger<PurchasingPackingSlipDocSetService> logger)
|
||||
{
|
||||
_purchasingPackingSlipRepository = purchasingPackingSlipRepository;
|
||||
_cpt = cpt;
|
||||
_oneNoteService = oneNoteService;
|
||||
_siteOptions = siteOptions;
|
||||
_sharePointAuthenticationManager = sharePointAuthenticationManager;
|
||||
_logger = logger;
|
||||
}
|
||||
public void Create(string purchasingPackingSlipName, 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 {purchasingPackingSlipName}.");
|
||||
|
||||
#region DocSet Field Entry
|
||||
|
||||
DocumentSet.Create(ctx, list.RootFolder, purchasingPackingSlipName, contentType.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> DocumentSet {purchasingPackingSlipName} creata.");
|
||||
var dsItem = list.RootFolder.Folders.GetByUrl(purchasingPackingSlipName).ListItemAllFields;
|
||||
|
||||
dsItem["PAL_PO_Supplier"] = _purchasingPackingSlipRepository.DefaultPurchasingPackingSlipSupplier(purchasingPackingSlipName);
|
||||
dsItem["PAL_Status"] = _purchasingPackingSlipRepository.DefaultPurchasingPackingSlipState(purchasingPackingSlipName);
|
||||
|
||||
dsItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Field value update.");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Folder
|
||||
|
||||
//foreach (var name in Folders.PurchasingOrder)
|
||||
//{
|
||||
// Console.WriteLine($"La sotto cartella {name} verrà creata in {nonComplianceName}");
|
||||
// var rPath = ResourcePath.FromDecodedUrl($"{nonComplianceName}/{name}");
|
||||
// list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
//}
|
||||
|
||||
//ctx.ExecuteQuery();
|
||||
|
||||
var purchCtx = _sharePointAuthenticationManager.GetContext(_siteOptions.GetPurchasingSite());
|
||||
|
||||
|
||||
_oneNoteService.CreateFolderInsidePurchasing(purchasingPackingSlipName, purchCtx, PurchType.PackingSlip);
|
||||
|
||||
Console.WriteLine($"Le sotto cartelle sono state create con successo in {purchasingPackingSlipName}");
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine($"> {purchasingPackingSlipName} creato con successo.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingRequestBuildService : IPurchasingRequestBuildService
|
||||
{
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly ISharePointAuthenticationManager _sharePointAuthenticationManager;
|
||||
private readonly ISharePointCustomOperation _spc;
|
||||
private readonly IPurchasingRequestDocLibraryService _purchasingRequestDocLibraryService;
|
||||
private readonly IPurchasingRequestDocSetService _purchasingRequestDocSetService;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<PurchasingRequestBuildService> _logger;
|
||||
|
||||
public PurchasingRequestBuildService(ISiteOptions siteOptions,
|
||||
ISharePointAuthenticationManager sharePointAuthenticationManager,
|
||||
ISharePointCustomOperation spc,
|
||||
IPurchasingRequestDocLibraryService purchasingRequestDocLibraryService,
|
||||
IPurchasingRequestDocSetService purchasingRequestDocSetService,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<PurchasingRequestBuildService> logger)
|
||||
{
|
||||
_siteOptions = siteOptions;
|
||||
_sharePointAuthenticationManager = sharePointAuthenticationManager;
|
||||
_spc = spc;
|
||||
_purchasingRequestDocLibraryService = purchasingRequestDocLibraryService;
|
||||
_purchasingRequestDocSetService = purchasingRequestDocSetService;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateIfNotExists(string purchasingRequestName)
|
||||
{
|
||||
var site = _siteOptions.GetPurchasingRequestSite();
|
||||
var ctx = _sharePointAuthenticationManager.GetContext(site);
|
||||
var list = _siteOptions.GetPurchasingRequestLibrary(purchasingRequestName);
|
||||
var tenant = _siteOptions.GetPurchasingRequestTenat();
|
||||
|
||||
if (!_spc.SiteExist(ctx))
|
||||
{
|
||||
throw new Exception($"Impossibile to build site it don't exist");
|
||||
}
|
||||
|
||||
if (!_spc.ListExist(ctx, list))
|
||||
{
|
||||
_purchasingRequestDocLibraryService.Create(list, ctx);
|
||||
}
|
||||
|
||||
if (!_spc.FolderExistsInsideList(ctx, list, purchasingRequestName))
|
||||
{
|
||||
_purchasingRequestDocSetService.Create(purchasingRequestName, list, tenant, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation($"Quotation with {purchasingRequestName} already exist");
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, list, purchasingRequestName, FieldUpdateType.PurchasingRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingRequestDocLibraryService : IPurchasingRequestDocLibraryService
|
||||
{
|
||||
private readonly ILogger<PurchasingRequestDocLibraryService> _logger;
|
||||
|
||||
public PurchasingRequestDocLibraryService(ILogger<PurchasingRequestDocLibraryService> logger)
|
||||
{
|
||||
_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 = { "Fornitore", "Stato" };
|
||||
|
||||
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 = Fields.PurchasingView;
|
||||
|
||||
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")}";
|
||||
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,113 @@
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class PurchasingRequestDocSetService : IPurchasingRequestDocSetService
|
||||
{
|
||||
private readonly IPurchasingRequestRepository _purchasingRequestRepository;
|
||||
private readonly ISharePointCustomOperation _cpt;
|
||||
private readonly IOneNoteService _oneNoteService;
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly ISharePointAuthenticationManager _sharePointAuthenticationManager;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<PurchasingRequestDocSetService> _logger;
|
||||
|
||||
public PurchasingRequestDocSetService(
|
||||
IPurchasingRequestRepository purchasingRequestRepository,
|
||||
ISharePointCustomOperation cpt,
|
||||
IOneNoteService oneNoteService,
|
||||
ISiteOptions siteOptions,
|
||||
ISharePointAuthenticationManager sharePointAuthenticationManager,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<PurchasingRequestDocSetService> logger)
|
||||
{
|
||||
_purchasingRequestRepository = purchasingRequestRepository;
|
||||
_cpt = cpt;
|
||||
_oneNoteService = oneNoteService;
|
||||
_siteOptions = siteOptions;
|
||||
_sharePointAuthenticationManager = sharePointAuthenticationManager;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void Create(string purchasingRequestName, 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 {purchasingRequestName}.");
|
||||
|
||||
#region DocSet Field Entry
|
||||
|
||||
DocumentSet.Create(ctx, list.RootFolder, purchasingRequestName, contentType.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> DocumentSet {purchasingRequestName} creata.");
|
||||
|
||||
//var dsItem = list.RootFolder.Folders.GetByUrl(purchasingRequestName).ListItemAllFields;
|
||||
|
||||
//dsItem["PAL_PO_Supplier"] = _purchasingRequestRepository.DefaultPurchasingRequestSupplier(purchasingRequestName);
|
||||
//dsItem["PAL_Status"] = _purchasingRequestRepository.DefaultPurchasingRequestState(purchasingRequestName);
|
||||
|
||||
//dsItem.Update();
|
||||
//ctx.ExecuteQuery();
|
||||
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, docLibraryName, purchasingRequestName, FieldUpdateType.PurchasingRequest);
|
||||
|
||||
Console.WriteLine($"> Field value update.");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Folder
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
var purchCtx = _sharePointAuthenticationManager.GetContext(_siteOptions.GetPurchasingSite());
|
||||
|
||||
_oneNoteService.CreateFolderInsidePurchasing(purchasingRequestName, purchCtx, PurchType.Request);
|
||||
|
||||
Console.WriteLine($"Le sotto cartelle sono state create con successo in {purchasingRequestName}");
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine($"> {purchasingRequestName} creato con successo.");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class QuotationBuildService : IQuotationBuildService
|
||||
{
|
||||
@@ -11,6 +12,7 @@ internal class QuotationBuildService : IQuotationBuildService
|
||||
private readonly ITenantService tenantService;
|
||||
private readonly IQuotationDocLibraryService quotationDocLibraryService;
|
||||
private readonly IQuotationDocSetService quotationDocSetService;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<QuotationBuildService> logger;
|
||||
|
||||
public QuotationBuildService(
|
||||
@@ -20,6 +22,7 @@ internal class QuotationBuildService : IQuotationBuildService
|
||||
ITenantService tenantService,
|
||||
IQuotationDocLibraryService quotationDocLibraryService,
|
||||
IQuotationDocSetService quotationDocSetService,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<QuotationBuildService> logger)
|
||||
{
|
||||
this.siteOptions = siteOptions;
|
||||
@@ -28,6 +31,7 @@ internal class QuotationBuildService : IQuotationBuildService
|
||||
this.tenantService = tenantService;
|
||||
this.quotationDocLibraryService = quotationDocLibraryService;
|
||||
this.quotationDocSetService = quotationDocSetService;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@@ -35,24 +39,27 @@ internal class QuotationBuildService : IQuotationBuildService
|
||||
{
|
||||
var site = siteOptions.GetQuotationSite();
|
||||
var ctx = sharePointAuthenticationManager.GetContext(site);
|
||||
var list = siteOptions.GetQuotationLibrary();
|
||||
var list = siteOptions.GetQuotationLibrary(quotationName);
|
||||
var tenant = siteOptions.GetQuotationTenant();
|
||||
|
||||
if (!spc.SiteExist(ctx))
|
||||
{
|
||||
tenantService.CreateForQuotation();
|
||||
}
|
||||
else if (!spc.ListExist(ctx, list))
|
||||
|
||||
if (!spc.ListExist(ctx, list))
|
||||
{
|
||||
quotationDocLibraryService.Create(list, ctx);
|
||||
}
|
||||
else if (!spc.FolderExistsInsideList(ctx, list, quotationName))
|
||||
|
||||
if (!spc.FolderExistsInsideList(ctx, list, quotationName))
|
||||
{
|
||||
quotationDocSetService.Create(quotationName, list, tenant, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogInformation($"Quotation with {quotationName} already exist");
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, list, quotationName, FieldUpdateType.Quotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class QuotationDocLibraryService : IQuotationDocLibraryService
|
||||
{
|
||||
@@ -45,11 +46,11 @@ internal class QuotationDocLibraryService : IQuotationDocLibraryService
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
string[] fieldName = { "ID Offerta", "Fornitore", "Causale", "Autore" };
|
||||
string[] fieldName = { "PAL_Quotation_Reason", "PAL_ID_Quotation", "PAL_Quotation_Name", "PAL_Description", "PAL_Authors", "PAL_Status" };
|
||||
|
||||
foreach (var fn in fieldName)
|
||||
{
|
||||
var Fields = siteField.Fields.GetByTitle(fn);
|
||||
var Fields = siteField.Fields.GetByInternalNameOrTitle(fn);
|
||||
list.Fields.Add(Fields);
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ internal class QuotationDocLibraryService : IQuotationDocLibraryService
|
||||
viewCreation.Title = libName;
|
||||
viewCreation.ViewTypeKind = ViewType.None;
|
||||
viewCreation.ColumnWidth = "350";
|
||||
viewCreation.ViewFields = new string[] { "Type", "Name", "ID Offerta", "Fornitore", "Causale", "Autore" };
|
||||
viewCreation.ViewFields = Fields.QuotationView;
|
||||
|
||||
var view = views.Add(viewCreation);
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Repositories;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class QuotationDocSetService : IQuotationDocSetService
|
||||
{
|
||||
@@ -13,16 +14,19 @@ internal class QuotationDocSetService : IQuotationDocSetService
|
||||
private readonly ILogger<QuotationDocSetService> logger;
|
||||
private readonly IOneNoteService oneNoteService;
|
||||
private readonly IQuotationRepository quotationRepository;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
|
||||
public QuotationDocSetService(ISharePointCustomOperation cpt,
|
||||
ILogger<QuotationDocSetService> logger,
|
||||
IOneNoteService oneNoteService,
|
||||
IQuotationRepository quotationRepository)
|
||||
IQuotationRepository quotationRepository,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate)
|
||||
{
|
||||
this.cpt = cpt;
|
||||
this.logger = logger;
|
||||
this.oneNoteService = oneNoteService;
|
||||
this.quotationRepository = quotationRepository;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
}
|
||||
|
||||
public void Create(string quotationName, string docLibraryName, string tenantName, ClientContext ctx)
|
||||
@@ -73,15 +77,18 @@ internal class QuotationDocSetService : IQuotationDocSetService
|
||||
|
||||
Console.WriteLine($"> DocumentSet {quotationName} creata.");
|
||||
|
||||
var dsItem = list.RootFolder.Folders.GetByUrl(quotationName).ListItemAllFields;
|
||||
//var dsItem = list.RootFolder.Folders.GetByUrl(quotationName).ListItemAllFields;
|
||||
|
||||
dsItem["PAL_ID_Quotation"] = quotationRepository.DefaultIdQuotation(quotationName);
|
||||
dsItem["PAL_Quotation_Name"] = quotationRepository.DefaultQuotationName(quotationName);
|
||||
dsItem["PAL_Quotation_Reason"] = quotationRepository.DefaultQuotationReason(quotationName);
|
||||
dsItem["PAL_Authors"] = quotationRepository.DefaultAuthors(quotationName);
|
||||
//dsItem["PAL_ID_Quotation"] = quotationRepository.DefaultIdQuotation(quotationName);
|
||||
//dsItem["PAL_Quotation_Name"] = quotationRepository.DefaultQuotationName(quotationName);
|
||||
//dsItem["PAL_Quotation_Reason"] = quotationRepository.DefaultQuotationReason(quotationName);
|
||||
//dsItem["PAL_Authors"] = quotationRepository.DefaultAuthors(quotationName);
|
||||
//dsItem["PAL_Status"] = quotationRepository.DefaultQuotationState(quotationName);
|
||||
|
||||
dsItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
//dsItem.Update();
|
||||
//ctx.ExecuteQuery();
|
||||
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, docLibraryName, quotationName, FieldUpdateType.Quotation);
|
||||
|
||||
Console.WriteLine($"> Field value update.");
|
||||
|
||||
@@ -89,7 +96,9 @@ internal class QuotationDocSetService : IQuotationDocSetService
|
||||
|
||||
#region Quotation Folder
|
||||
|
||||
foreach (var name in Folders.OfferDocSet)
|
||||
var revision = "Rev.00";
|
||||
|
||||
foreach (var name in Folders.OfferDocSet(revision))
|
||||
{
|
||||
Console.WriteLine($"La sotto cartella {name} verrà creata in {quotationName}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{quotationName}/{name}");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services
|
||||
namespace library_spo_utils.Services
|
||||
{
|
||||
internal class RightsService : IRightsService
|
||||
{
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using console_spo_utils.Enums;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Online.SharePoint.TenantAdministration;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using System.Security;
|
||||
using System.Xml.Linq;
|
||||
using console_spo_utils.Constants;
|
||||
|
||||
namespace console_spo_utils.Services
|
||||
namespace library_spo_utils.Services
|
||||
{
|
||||
internal class SharePointCustomOperation : ISharePointCustomOperation
|
||||
{
|
||||
@@ -59,6 +56,22 @@ namespace console_spo_utils.Services
|
||||
}
|
||||
}
|
||||
|
||||
public bool FolderExist(ClientContext ctx, string path)
|
||||
{
|
||||
var folder = ctx.Web.GetFolderByServerRelativeUrl(path).Folders;
|
||||
ctx.Load(folder, f => f.Include(fi => fi.ListItemAllFields));
|
||||
|
||||
try
|
||||
{
|
||||
ctx.ExecuteQuery();
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FolderExistsInsideList(ClientContext context, string listTitle, string folderName)
|
||||
{
|
||||
var folderExists = context.Web.Lists.GetByTitle(listTitle).RootFolder;
|
||||
|
||||
@@ -1,38 +1,54 @@
|
||||
using System.Linq.Expressions;
|
||||
using console_spo_utils.Interfaces.Repositories;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class SharePointStructureBuilderService : ISharePointStructureBuilder
|
||||
{
|
||||
private readonly ISiteOptions siteOptions;
|
||||
private readonly ISiteService siteService;
|
||||
private readonly ISubProjectRepository subProjectRepository;
|
||||
private readonly ISubProjectBuilderService subProjectBuilderService;
|
||||
private readonly IQuotationBuildService quotationBuildService;
|
||||
private readonly INonComplianceBuildService nonComplianceBuildService;
|
||||
private readonly IPurchasingOrderBuildService purchasingOrderBuildService;
|
||||
private readonly IPurchasingPackingSlipBuildService purchasingPackingSlipBuildService;
|
||||
private readonly IPurchasingRequestBuildService purchasingRequestBuildService;
|
||||
private readonly IWebpartService webpartService;
|
||||
|
||||
public SharePointStructureBuilderService(
|
||||
ISiteOptions siteOptions,
|
||||
ISiteService siteService,
|
||||
ISubProjectRepository subProjectRepository,
|
||||
ISubProjectBuilderService subProjectBuilderService,
|
||||
IQuotationBuildService quotationBuildService,
|
||||
INonComplianceBuildService nonComplianceBuildService,
|
||||
IPurchasingOrderBuildService purchasingOrderBuildService,
|
||||
IPurchasingPackingSlipBuildService purchasingPackingSlipBuildService,
|
||||
IPurchasingRequestBuildService purchasingRequestBuildService,
|
||||
IWebpartService webpartService)
|
||||
{
|
||||
this.siteOptions = siteOptions;
|
||||
this.siteService = siteService;
|
||||
this.subProjectRepository = subProjectRepository;
|
||||
this.subProjectBuilderService = subProjectBuilderService;
|
||||
this.quotationBuildService = quotationBuildService;
|
||||
this.nonComplianceBuildService = nonComplianceBuildService;
|
||||
this.purchasingOrderBuildService = purchasingOrderBuildService;
|
||||
this.purchasingPackingSlipBuildService = purchasingPackingSlipBuildService;
|
||||
this.purchasingRequestBuildService = purchasingRequestBuildService;
|
||||
this.webpartService = webpartService;
|
||||
}
|
||||
|
||||
|
||||
public bool BuildProject(string projName)
|
||||
{
|
||||
var siteBuilderResult = siteService.CreateProjectSiteIfNotExists();
|
||||
if (!siteOptions.IsValidDate(projName))
|
||||
{
|
||||
throw new Exception(projName + " is not valid, return year " + siteOptions.GetYear(projName));
|
||||
}
|
||||
|
||||
var siteBuilderResult = siteService.CreateProjectSiteIfNotExists(projName);
|
||||
if (!siteBuilderResult)
|
||||
{
|
||||
throw new Exception($"Impossibile to build site");
|
||||
@@ -51,11 +67,17 @@ internal class SharePointStructureBuilderService : ISharePointStructureBuilder
|
||||
{
|
||||
throw new Exception($"Impossibile to build subSite for {projName} ");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool BuildQuotation(string quotationName)
|
||||
{
|
||||
if (!siteOptions.IsValidDate(quotationName))
|
||||
{
|
||||
throw new Exception(quotationName + " is not valid, return year " + siteOptions.GetYear(quotationName));
|
||||
}
|
||||
|
||||
var siteBuildResult = siteService.CreateQuotationSiteIfNotExists(quotationName);
|
||||
if (!siteBuildResult)
|
||||
{
|
||||
@@ -69,6 +91,11 @@ internal class SharePointStructureBuilderService : ISharePointStructureBuilder
|
||||
|
||||
public bool BuildNonCompliance(string nonComplianceName)
|
||||
{
|
||||
if (!siteOptions.IsValidDate(nonComplianceName))
|
||||
{
|
||||
throw new Exception(nonComplianceName + " is not valid, return year " + siteOptions.GetYear(nonComplianceName));
|
||||
}
|
||||
|
||||
var siteBuildResult = siteService.CreateNonComplianceSiteIfNotExists(nonComplianceName);
|
||||
if (!siteBuildResult)
|
||||
{
|
||||
@@ -79,4 +106,40 @@ internal class SharePointStructureBuilderService : ISharePointStructureBuilder
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool BuildPurchasingOrder(string purchasingOrderName)
|
||||
{
|
||||
if (!siteOptions.IsValidDate(purchasingOrderName))
|
||||
{
|
||||
throw new Exception(purchasingOrderName + " is not valid, return year " + siteOptions.GetYear(purchasingOrderName));
|
||||
}
|
||||
|
||||
purchasingOrderBuildService.CreateIfNotExists(purchasingOrderName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool BuildPurchasingPackingSlip(string purchasingPackingSlipName)
|
||||
{
|
||||
if (!siteOptions.IsValidDate(purchasingPackingSlipName))
|
||||
{
|
||||
throw new Exception(purchasingPackingSlipName + " is not valid, return year " + siteOptions.GetYear(purchasingPackingSlipName));
|
||||
}
|
||||
|
||||
purchasingPackingSlipBuildService.CreateIfNotExists(purchasingPackingSlipName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool BuildPurchasingRequest(string purchasingRequestName)
|
||||
{
|
||||
if (!siteOptions.IsValidDate(purchasingRequestName))
|
||||
{
|
||||
throw new Exception(purchasingRequestName + " is not valid, return year " + siteOptions.GetYear(purchasingRequestName));
|
||||
}
|
||||
|
||||
purchasingRequestBuildService.CreateIfNotExists(purchasingRequestName);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,55 @@
|
||||
using System.Net;
|
||||
using System.Security;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using System.Text.RegularExpressions;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Graph;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
public class SiteOptions : ISiteOptions
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public SiteOptions(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
private const string SiteCollection = "https://italsortbuttrio.sharepoint.com";
|
||||
public string TokenEndpoint { get; } = "https://login.microsoftonline.com/common/oauth2/token";
|
||||
public string DefaultAadAppId { get; } = "46e6296e-176f-4ebb-a14b-bdd5678c16e6";
|
||||
public Uri GetProjectYearSite()
|
||||
public int ZeroDate { get; } = 2022;
|
||||
|
||||
public Uri GetProjectYearSite(string code)
|
||||
{
|
||||
return new Uri($"{SiteCollection}/sites/{GetProjYearTenant().Replace(" ","")}");
|
||||
return new Uri($"{SiteCollection}/sites/{GetProjYearTenant(code).Replace(" ","")}");
|
||||
}
|
||||
|
||||
private static int GetYear()
|
||||
public string GetYear(string code)
|
||||
{
|
||||
return DateTime.Today.Year;
|
||||
var codeHeader = code.Split("-")[0];
|
||||
var codeYears = Regex.Replace(codeHeader, @"\D", "");
|
||||
var currentCent = DateTime.Today.Year.ToString().Substring(0, 2);
|
||||
|
||||
return currentCent + codeYears;
|
||||
}
|
||||
|
||||
public string GetProjYearTenant()
|
||||
public bool IsValidDate(string code)
|
||||
{
|
||||
return $"Commesse {GetYear()}";
|
||||
int zeroDate = ZeroDate;
|
||||
int retDate = int.Parse(GetYear(code));
|
||||
int curDate = int.Parse(DateTime.Now.Year.ToString());
|
||||
|
||||
if (zeroDate <= retDate && retDate <= curDate)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetProjYearTenant(string code)
|
||||
{
|
||||
return $"Commesse {GetYear(code)}";
|
||||
}
|
||||
|
||||
public string GetUser()
|
||||
@@ -35,14 +62,14 @@ public class SiteOptions : ISiteOptions
|
||||
return new NetworkCredential("", "$O,D1XBp1O5.OdjZt86#a=").SecurePassword;
|
||||
}
|
||||
|
||||
public string GetProjListTitle()
|
||||
public string GetProjListTitle(string code)
|
||||
{
|
||||
return $"Lista {GetProjYearTenant()}";
|
||||
return $"Lista {GetProjYearTenant(code)}";
|
||||
}
|
||||
|
||||
public Uri GetSubProjSite(string projName)
|
||||
{
|
||||
return new Uri($"{GetProjectYearSite()}/{projName}");
|
||||
return new Uri($"{GetProjectYearSite(projName)}/{projName}");
|
||||
}
|
||||
|
||||
public string GetQuotationTenant()
|
||||
@@ -50,9 +77,9 @@ public class SiteOptions : ISiteOptions
|
||||
return "Offerte";
|
||||
}
|
||||
|
||||
public string GetQuotationLibrary()
|
||||
public string GetQuotationLibrary(string code)
|
||||
{
|
||||
return $"{GetQuotationTenant()} {GetYear()}";
|
||||
return $"{GetQuotationTenant()} {GetYear(code)}";
|
||||
}
|
||||
|
||||
public Uri GetQuotationSite()
|
||||
@@ -80,13 +107,63 @@ public class SiteOptions : ISiteOptions
|
||||
return "Non Conformità";
|
||||
}
|
||||
|
||||
public string GetNonComplianceLibrary()
|
||||
public string GetNonComplianceLibrary(string code)
|
||||
{
|
||||
return $"{GetNonComplianceTenant()} {GetYear()}";
|
||||
return $"{GetNonComplianceTenant()} {GetYear(code)}";
|
||||
}
|
||||
|
||||
public Uri GetNonComplianceSite()
|
||||
{
|
||||
return new Uri($"{SiteCollection}/sites/{GetNonComplianceTenant().Replace(" ", String.Empty)}");
|
||||
return new Uri($"{SiteCollection}/sites/{GetNonComplianceTenant().Replace(" ", string.Empty)}");
|
||||
}
|
||||
|
||||
public Uri GetPurchasingSite()
|
||||
{
|
||||
return new Uri($"{SiteCollection}/teams/purchasing/");
|
||||
}
|
||||
|
||||
public string GetPurchasingOrderTenat()
|
||||
{
|
||||
return "Ordini di Acquisto";
|
||||
}
|
||||
|
||||
public string GetPurchasingOrderLibrary(string code)
|
||||
{
|
||||
return $"{GetPurchasingOrderTenat()} {GetYear(code)}";
|
||||
}
|
||||
|
||||
public Uri GetPurchasingOrderSite()
|
||||
{
|
||||
return new Uri($"{SiteCollection}/teams/purchasing/{GetPurchasingOrderTenat().Replace(" ", string.Empty)}");
|
||||
}
|
||||
|
||||
public string GetPurchasingPackingSlipTenat()
|
||||
{
|
||||
return "DDT di Acquisto";
|
||||
}
|
||||
|
||||
public string GetPurchasingPackingSlipLibrary(string code)
|
||||
{
|
||||
return $"{GetPurchasingPackingSlipTenat()} {GetYear(code)}";
|
||||
}
|
||||
|
||||
public Uri GetPurchasingPackingSlipSite()
|
||||
{
|
||||
return new Uri($"{SiteCollection}/teams/purchasing/{GetPurchasingPackingSlipTenat().Replace(" ", string.Empty)}");
|
||||
}
|
||||
|
||||
public string GetPurchasingRequestTenat()
|
||||
{
|
||||
return "Richieste di Acquisto";
|
||||
}
|
||||
|
||||
public string GetPurchasingRequestLibrary(string code)
|
||||
{
|
||||
return $"{GetPurchasingRequestTenat()} {GetYear(code)}";
|
||||
}
|
||||
|
||||
public Uri GetPurchasingRequestSite()
|
||||
{
|
||||
return new Uri($"{SiteCollection}/teams/purchasing/{GetPurchasingRequestTenat().Replace(" ", string.Empty)}");
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,25 @@
|
||||
using console_spo_utils.Enums;
|
||||
using console_spo_utils.Interfaces.Repositories;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class SiteService : ISiteService
|
||||
{
|
||||
private readonly ILogger<SiteService> logger;
|
||||
private readonly ISharePointAuthenticationManager authMgr;
|
||||
private readonly ISharePointCustomOperation spc;
|
||||
private readonly ISiteOptions siteOptions;
|
||||
private readonly ISubSiteService subSiteService;
|
||||
private readonly IOneNoteService oneNoteService;
|
||||
private readonly IProjectSettingsRepository projectSettingsRepository;
|
||||
private readonly IProjectDocLibraryService projectDocLibraryService;
|
||||
private readonly IProjectQuickMenuService projectQuickMenuService;
|
||||
private readonly ITenantService tenantService;
|
||||
private readonly IProjectYearService projectYearService;
|
||||
private readonly ILogger<SiteService> _logger;
|
||||
private readonly ISharePointAuthenticationManager _authMgr;
|
||||
private readonly ISharePointCustomOperation _spc;
|
||||
private readonly ISiteOptions _siteOptions;
|
||||
private readonly ISubSiteService _subSiteService;
|
||||
private readonly IOneNoteService _oneNoteService;
|
||||
private readonly IProjectRepository _projectRepository;
|
||||
private readonly IProjectDocLibraryService _projectDocLibraryService;
|
||||
private readonly IProjectQuickMenuService _projectQuickMenuService;
|
||||
private readonly ITenantService _tenantService;
|
||||
private readonly IProjectYearService _projectYearService;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
|
||||
public SiteService(
|
||||
ILogger<SiteService> logger,
|
||||
@@ -27,43 +28,45 @@ internal class SiteService : ISiteService
|
||||
ISiteOptions siteOptions,
|
||||
ISubSiteService subSiteService,
|
||||
IOneNoteService oneNoteService,
|
||||
IProjectSettingsRepository projectSettingsRepository,
|
||||
IProjectRepository projectRepository,
|
||||
IProjectDocLibraryService projectDocLibraryService,
|
||||
IProjectQuickMenuService projectQuickMenuService,
|
||||
ITenantService tenantService,
|
||||
IProjectYearService projectYearService)
|
||||
IProjectYearService projectYearService,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.authMgr = authMgr;
|
||||
this.spc = spc;
|
||||
this.siteOptions = siteOptions;
|
||||
this.subSiteService = subSiteService;
|
||||
this.oneNoteService = oneNoteService;
|
||||
this.projectSettingsRepository = projectSettingsRepository;
|
||||
this.projectDocLibraryService = projectDocLibraryService;
|
||||
this.projectQuickMenuService = projectQuickMenuService;
|
||||
this.tenantService = tenantService;
|
||||
this.projectYearService = projectYearService;
|
||||
_logger = logger;
|
||||
_authMgr = authMgr;
|
||||
_spc = spc;
|
||||
_siteOptions = siteOptions;
|
||||
_subSiteService = subSiteService;
|
||||
_oneNoteService = oneNoteService;
|
||||
_projectRepository = projectRepository;
|
||||
_projectDocLibraryService = projectDocLibraryService;
|
||||
_projectQuickMenuService = projectQuickMenuService;
|
||||
_tenantService = tenantService;
|
||||
_projectYearService = projectYearService;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
}
|
||||
|
||||
public bool CreateProjectSiteIfNotExists()
|
||||
public bool CreateProjectSiteIfNotExists(string projName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var site = siteOptions.GetProjectYearSite();
|
||||
var listTitle = siteOptions.GetProjListTitle();
|
||||
using var ctx = authMgr.GetContext(site);
|
||||
if (spc.SiteExist(ctx))
|
||||
var site = _siteOptions.GetProjectYearSite(projName);
|
||||
var listTitle = _siteOptions.GetProjListTitle(projName);
|
||||
using var ctx = _authMgr.GetContext(site);
|
||||
if (_spc.SiteExist(ctx))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
tenantService.CreateForProject();
|
||||
projectYearService.CreateList(listTitle,ctx);
|
||||
_tenantService.CreateForProject(projName);
|
||||
_projectYearService.CreateList(projName, listTitle, ctx);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "Site Service");
|
||||
_logger.LogError(e, "Site Service");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,37 +76,41 @@ internal class SiteService : ISiteService
|
||||
public bool CreateSubSiteIfNotExists(string projName)
|
||||
{
|
||||
|
||||
var projectSite = siteOptions.GetProjectYearSite();
|
||||
var subProjSite = siteOptions.GetSubProjSite(projName);
|
||||
var projectSite = _siteOptions.GetProjectYearSite(projName);
|
||||
var subProjSite = _siteOptions.GetSubProjSite(projName);
|
||||
|
||||
var siteContext = authMgr.GetContext(projectSite);
|
||||
var subSiteContext = authMgr.GetContext(subProjSite);
|
||||
var siteContext = _authMgr.GetContext(projectSite);
|
||||
var subSiteContext = _authMgr.GetContext(subProjSite);
|
||||
|
||||
if (!spc.SiteExist(siteContext))
|
||||
if (!_spc.SiteExist(siteContext))
|
||||
{
|
||||
throw new Exception($"Site {siteContext.Url} not exists");
|
||||
}
|
||||
|
||||
if (spc.SiteExist(subSiteContext))
|
||||
if (_spc.SiteExist(subSiteContext))
|
||||
{
|
||||
logger.LogInformation($"The subsite {subSiteContext.Url} already exists");
|
||||
_logger.LogInformation($"The subsite {subSiteContext.Url} already exists");
|
||||
_fieldEntryDataUpdate.FieldUpdate(siteContext, _siteOptions.GetProjListTitle(projName), projName, FieldUpdateType.Project);
|
||||
|
||||
return true;
|
||||
}
|
||||
var existSubSite = subSiteService.Create(projName, siteContext);
|
||||
|
||||
|
||||
var existSubSite = _subSiteService.Create(projName, siteContext);
|
||||
if (!existSubSite)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
oneNoteService.CreateFolderInsideProject(projName, siteContext);
|
||||
_oneNoteService.CreateFolderInsideProject(projName, siteContext);
|
||||
|
||||
CreateProjectListEntry(projName, siteContext);
|
||||
|
||||
projectDocLibraryService.Create(projName, subSiteContext);
|
||||
_projectDocLibraryService.Create(projName, subSiteContext);
|
||||
|
||||
subSiteService.AddColumnsToListView(projName, subSiteContext);
|
||||
_subSiteService.AddColumnsToListView(projName, subSiteContext);
|
||||
|
||||
projectQuickMenuService.CreateForProject(projName, subSiteContext);
|
||||
_projectQuickMenuService.CreateForProject(projName, subSiteContext);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -112,17 +119,17 @@ internal class SiteService : ISiteService
|
||||
{
|
||||
try
|
||||
{
|
||||
var site = siteOptions.GetQuotationSite();
|
||||
using var ctx = authMgr.GetContext(site);
|
||||
if (spc.SiteExist(ctx))
|
||||
var site = _siteOptions.GetQuotationSite();
|
||||
using var ctx = _authMgr.GetContext(site);
|
||||
if (_spc.SiteExist(ctx))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
tenantService.CreateForQuotation();
|
||||
_tenantService.CreateForQuotation();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "Site Service");
|
||||
_logger.LogError(e, "Site Service");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,30 +140,29 @@ internal class SiteService : ISiteService
|
||||
{
|
||||
try
|
||||
{
|
||||
var site = siteOptions.GetNonComplianceSite();
|
||||
using var ctx = authMgr.GetContext(site);
|
||||
if (spc.SiteExist(ctx))
|
||||
var site = _siteOptions.GetNonComplianceSite();
|
||||
using var ctx = _authMgr.GetContext(site);
|
||||
if (_spc.SiteExist(ctx))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
tenantService.CreateForNonCompliance();
|
||||
_tenantService.CreateForNonCompliance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, "Site Service");
|
||||
_logger.LogError(e, "Site Service");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void CreateProjectListEntry(string projName, ClientContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
var listTitle = siteOptions.GetProjListTitle();
|
||||
var tenant = siteOptions.GetProjYearTenant().Replace(" ",string.Empty);
|
||||
var listTitle = _siteOptions.GetProjListTitle(projName);
|
||||
var tenant = _siteOptions.GetProjYearTenant(projName).Replace(" ",string.Empty);
|
||||
var list = ctx.Web.Lists.GetByTitle(listTitle);
|
||||
|
||||
var itemCreateInfo = new ListItemCreationInformation();
|
||||
@@ -169,17 +175,17 @@ internal class SiteService : ISiteService
|
||||
};
|
||||
|
||||
oItem["PAL_ID_Project"] = link;
|
||||
oItem["PAL_Customer"] = projectSettingsRepository.DefaultCostumer(projName);
|
||||
oItem["PAL_DlvReason"] = projectSettingsRepository.DefaultDlvReason(projName);
|
||||
|
||||
oItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
logger.LogInformation($"> La Commessa {projName} è stata aggiunta alla lista {listTitle} con successo!");
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, listTitle, projName, FieldUpdateType.Project);
|
||||
|
||||
_logger.LogInformation($"> La Commessa {projName} è stata aggiunta alla lista {listTitle} con successo!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Create List Entry");
|
||||
_logger.LogError(ex, "Create List Entry");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Repositories;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Repositories;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.DocumentSet;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class SubProjectBuilderService : ISubProjectBuilderService
|
||||
{
|
||||
@@ -13,23 +14,26 @@ internal class SubProjectBuilderService : ISubProjectBuilderService
|
||||
private readonly ISharePointCustomOperation cpt;
|
||||
private readonly ISharePointAuthenticationManager authMgr;
|
||||
private readonly ISubProjectRepository subProjectRepository;
|
||||
private readonly IFieldEntryDataUpdate _fieldEntryDataUpdate;
|
||||
private readonly ILogger<SubProjectBuilderService> logger;
|
||||
|
||||
public SubProjectBuilderService(ISiteOptions siteOptions,
|
||||
ISharePointCustomOperation cpt,
|
||||
ISharePointAuthenticationManager authMgr,
|
||||
ISubProjectRepository subProjectRepository,
|
||||
IFieldEntryDataUpdate fieldEntryDataUpdate,
|
||||
ILogger<SubProjectBuilderService> logger)
|
||||
{
|
||||
this.siteOptions = siteOptions;
|
||||
this.cpt = cpt;
|
||||
this.authMgr = authMgr;
|
||||
this.subProjectRepository = subProjectRepository;
|
||||
_fieldEntryDataUpdate = fieldEntryDataUpdate;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public bool SubProjectDocSet(string projName, List<string> subProjTitle)
|
||||
public bool SubProjectDocSet(string projName, List<string> listOfSubProjIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -70,51 +74,56 @@ internal class SubProjectBuilderService : ISubProjectBuilderService
|
||||
|
||||
#endregion
|
||||
|
||||
foreach (var spt in subProjTitle)
|
||||
foreach (var subProjId in listOfSubProjIds)
|
||||
{
|
||||
if (cpt.FolderExistsInsideList(ctx, listTitle, spt) == false)
|
||||
if (cpt.FolderExistsInsideList(ctx, listTitle, subProjId))
|
||||
{
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione per {spt}.");
|
||||
|
||||
#region DocSet Field Entry
|
||||
|
||||
DocumentSet.Create(ctx, list.RootFolder, spt, contentType.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> DocumentSet {spt} creata.");
|
||||
|
||||
var dsItem = list.RootFolder.Folders.GetByUrl(spt).ListItemAllFields;
|
||||
|
||||
dsItem["_ExtendedDescription"] = subProjectRepository.DefaultDescription(projName);
|
||||
dsItem["PAL_Item"] = subProjectRepository.DefaultItem(projName);
|
||||
dsItem["PAL_ItemCode"] = subProjectRepository.DefaultItemCode(projName);
|
||||
dsItem["PAL_ItemDescription"] = subProjectRepository.DefaultItemDescription(projName);
|
||||
dsItem["PAL_SerialNumber"] = subProjectRepository.DefaultSerialNumber(projName);
|
||||
|
||||
dsItem.Update();
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> Field value update.");
|
||||
|
||||
#endregion
|
||||
|
||||
#region SubProject Folder
|
||||
|
||||
foreach (var name in Folders.SubProjectDocSet)
|
||||
{
|
||||
Console.WriteLine($"La sotto cartella {name} verrà creata in {spt}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{spt}/{name}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"Le sotto cartelle sono state create con successo in {spt}");
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine($"> {spt} creato con successo in SottoCommesse {projName}.");
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, listTitle, projName, FieldUpdateType.SubProject);
|
||||
continue;
|
||||
}
|
||||
Console.WriteLine($"> Inizializzata la fase di creazione per {subProjId}.");
|
||||
|
||||
#region DocSet Field Entry
|
||||
|
||||
DocumentSet.Create(ctx, list.RootFolder, subProjId, contentType.Id);
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"> DocumentSet {subProjId} creata.");
|
||||
|
||||
//var dsItem = list.RootFolder.Folders.GetByUrl(subProjId).ListItemAllFields;
|
||||
|
||||
//dsItem["_ExtendedDescription"] = subProjectRepository.DefaultDescription(projName);
|
||||
//dsItem["PAL_Item"] = subProjectRepository.DefaultItem(projName);
|
||||
//dsItem["PAL_ItemCode"] = subProjectRepository.DefaultItemCode(projName);
|
||||
//dsItem["PAL_ItemDescription"] = subProjectRepository.DefaultItemDescription(projName);
|
||||
//dsItem["PAL_SerialNumber"] = subProjectRepository.DefaultSerialNumber(projName);
|
||||
//dsItem["PAL_Status"] = subProjectRepository.DefaultState(projName);
|
||||
|
||||
//dsItem.Update();
|
||||
//ctx.ExecuteQuery();
|
||||
|
||||
_fieldEntryDataUpdate.FieldUpdate(ctx, listTitle, subProjId, FieldUpdateType.SubProject);
|
||||
|
||||
Console.WriteLine($"> Field value update.");
|
||||
|
||||
#endregion
|
||||
|
||||
#region SubProject Folder
|
||||
|
||||
foreach (var name in Folders.SubProjectDocSet)
|
||||
{
|
||||
Console.WriteLine($"La sotto cartella {name} verrà creata in {subProjId}");
|
||||
var rPath = ResourcePath.FromDecodedUrl($"{subProjId}/{name}");
|
||||
list.RootFolder.AddSubFolderUsingPath(rPath);
|
||||
}
|
||||
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
Console.WriteLine($"Le sotto cartelle sono state create con successo in {subProjId}");
|
||||
|
||||
#endregion
|
||||
|
||||
Console.WriteLine($"> {subProjId} creato con successo in SottoCommesse {projName}.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using console_spo_utils.Constants;
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Constants;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class SubSiteService : ISubSiteService
|
||||
{
|
||||
@@ -106,7 +106,7 @@ internal class SubSiteService : ISubSiteService
|
||||
{
|
||||
foreach (var fieldName in Fields.SubSiteProject)
|
||||
{
|
||||
var fields = siteField.Fields.GetByTitle(fieldName);
|
||||
var fields = siteField.Fields.GetByInternalNameOrTitle(fieldName);
|
||||
list.Fields.Add(fields);
|
||||
}
|
||||
ctx.ExecuteQuery();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Enums;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Online.SharePoint.TenantAdministration;
|
||||
using console_spo_utils.Enums;
|
||||
|
||||
namespace console_spo_utils.Services;
|
||||
namespace library_spo_utils.Services;
|
||||
|
||||
internal class TenantService : ITenantService
|
||||
{
|
||||
@@ -30,11 +30,11 @@ internal class TenantService : ITenantService
|
||||
this.siteOptions = siteOptions;
|
||||
}
|
||||
|
||||
public void CreateForProject()
|
||||
public void CreateForProject(string projName)
|
||||
{
|
||||
TenantCreation(
|
||||
siteOptions.GetProjYearTenant(),
|
||||
siteOptions.GetProjectYearSite(),
|
||||
siteOptions.GetProjYearTenant(projName),
|
||||
siteOptions.GetProjectYearSite(projName),
|
||||
PalFieldType.Project
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using console_spo_utils.Interfaces.Services;
|
||||
using library_spo_utils.Interfaces.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.SharePoint.Client;
|
||||
using Microsoft.SharePoint.Client.WebParts;
|
||||
|
||||
|
||||
namespace console_spo_utils.Services
|
||||
namespace library_spo_utils.Services
|
||||
{
|
||||
internal class WebpartService : IWebpartService
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user