Files
NKC/NKC_WF/WebUserControls/cmp_OOIL_drawings.ascx.cs
2020-08-14 14:14:59 +02:00

79 lines
2.4 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 NKC_WF.WebUserControls
{
public partial class cmp_OOIL_drawings : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public string DrawingPath
{
get
{
return hfDrawingPath.Value;
}
set
{
string nestBasePath = memLayer.ML.CRS("nestBasePath").ToLower();
string servBasePath = memLayer.ML.CRS("servBasePath").ToLower();
string fixPath = value.Replace(nestBasePath, servBasePath);
hfDrawingPath.Value = fixPath;
fixDataBind();
}
}
private void fixDataBind()
{
string currPath = DrawingPath;
try
{
// in primis: fix directory
// visibile SOLO SE valore != null...
if (string.IsNullOrEmpty(currPath))
{
divDrawings.Visible = false;
}
else
{
divDrawings.Visible = true;
List<imgData> elencoDisegni = new List<imgData>();
// verifico path assoluto...
if (!Path.IsPathRooted(currPath))
{
currPath = Server.MapPath(currPath);
}
// leggo da filesystem...
string[] elencoFiles = Directory.GetFiles(currPath, "*.svg");
if (elencoFiles != null)
{
foreach (var item in elencoFiles)
{
elencoDisegni.Add(new imgData { imgName = Path.GetFileName(item), DrawPath = item.Replace(@"/", @"\") });
}
}
// sistemo repeater
repDraw.DataSource = elencoDisegni;
repDraw.DataBind();
}
}
catch
{ }
}
public class imgData
{
public string imgName { get; set; } = "";
public string DrawPath { get; set; } = "";
}
}
}