Service update, import changes from web_portal
This commit is contained in:
@@ -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)}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user