150 lines
3.5 KiB
C#
150 lines
3.5 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_ADM.WebUserControls
|
|
{
|
|
public partial class cmp_ImageArchive : BaseUserControl
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected string imgPathShedaTecn = memLayer.ML.CRS("imgPathShedaTecn");
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string PathFull
|
|
{
|
|
get
|
|
{
|
|
return hfPathFull.Value;
|
|
}
|
|
set
|
|
{
|
|
hfPathFull.Value = value;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
public string SearchVal
|
|
{
|
|
get
|
|
{
|
|
return txtSearchArt.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtSearchArt.Text = value;
|
|
}
|
|
}
|
|
|
|
public string selImage
|
|
{
|
|
get
|
|
{
|
|
return hfSelImage.Value;
|
|
}
|
|
set
|
|
{
|
|
hfSelImage.Value = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void doUpdate()
|
|
{
|
|
repImages.DataBind();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected void ddlSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
doUpdate();
|
|
}
|
|
|
|
protected void lbtImage_Click(object sender, EventArgs e)
|
|
{
|
|
// recupero nome immagine...
|
|
LinkButton lbt = (LinkButton)sender;
|
|
if (lbt != null)
|
|
{
|
|
selImage = lbt.CommandArgument;
|
|
}
|
|
raiseSelNew();
|
|
}
|
|
|
|
protected void lbtSearchReset_Click(object sender, EventArgs e)
|
|
{
|
|
txtSearchArt.Text = "";
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
PathFull = Server.MapPath(imgPathShedaTecn);
|
|
selImage = "";
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public List<FileData> ElencoFiles(string dirPath, string searchVal, int maxNum)
|
|
{
|
|
int currNum = 0;
|
|
List<FileData> answ = new List<FileData>();
|
|
try
|
|
{
|
|
searchVal = string.IsNullOrEmpty(searchVal) ? "*" : $"*{searchVal}*";
|
|
var tabFiles = Directory.GetFiles(dirPath, searchVal);
|
|
foreach (var item in tabFiles)
|
|
{
|
|
answ.Add(new FileData() { name = Path.GetFileName(item), relPath = $"{imgPathShedaTecn}{Path.GetFileName(item)}", fullPath = item });
|
|
currNum++;
|
|
// se superato max --> mi fermo
|
|
if (currNum >= maxNum)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Public Classes
|
|
|
|
public class FileData
|
|
{
|
|
#region Public Properties
|
|
|
|
public string fullPath { get; set; } = "";
|
|
public string name { get; set; } = "";
|
|
public string relPath { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Public Classes
|
|
}
|
|
} |