using Microsoft.AspNetCore.Components; using MP.Data; namespace MP.SPEC.Components { public partial class FolderBrowser { #region Public Properties [Parameter] public string LogicalPath { get; set; } = ""; #endregion Public Properties #region Protected Properties [Inject] protected IConfiguration ConfMan { get; set; } = null!; #endregion Protected Properties #region Protected Methods /// /// Restituisce size calcolata /// /// /// protected string CalcSize(long origSize) { return MeasureUtils.SizeSuffix(origSize, 1); } protected string FileLink(string fName) { return $"RET_DATA/{LogicalPath}/{fName}"; } /// /// Eseguo browsing directory... /// /// protected override void OnParametersSet() { ReloadData(); } private void ReloadData() { // calcolo phisical path... string BasePathOdlReturn = ConfMan.GetValue("ServerConf:BasePathOdlReturn") ?? ConfMan.GetValue("OptConf:BasePathOdlReturn") ?? ""; PhysicalPath = Path.Combine(BasePathOdlReturn, LogicalPath); // controllo esista if (Directory.Exists(PhysicalPath)) { // recupero come DirectoryInfo x avere tutte le informazioni su nome, tipo, size... DirectoryInfo dirInfo = new DirectoryInfo(PhysicalPath); SearchRecords = dirInfo.GetFiles().ToList(); } totalCount = SearchRecords.Count; // filtro x display ListRecords = SearchRecords .Skip(numRecord * (currPage - 1)) .Take(numRecord) .ToList(); } private int totalCount { get; set; } = 0; #endregion Protected Methods #region Private Properties private List ListRecords { get; set; } = new List(); private List SearchRecords { get; set; } = new List(); private string PhysicalPath { get; set; } = ""; #endregion Private Properties private int currPage { get; set; } = 1; private bool isLoading { get; set; } = false; private int numRecord { get; set; } = 10; protected async Task SetNumRec(int newNum) { numRecord = newNum; currPage = 1; ReloadData(); await InvokeAsync(ReloadData); } protected async Task SetPage(int newNum) { ReloadData(); currPage = newNum; await InvokeAsync(ReloadData); } } }