document.addEventListener("DOMContentLoaded", function() {
var lazyImages = [].slice.call(document.querySelectorAll("img.lazy"));;
if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
let lazyImage = entry.target;
lazyImage.src = lazyImage.dataset.src;
lazyImage.srcset = lazyImage.dataset.srcset;
lazyImage.classList.remove("lazy");
lazyImageObserver.unobserve(lazyImage);
}
});
});
lazyImages.forEach(function(lazyImage) {
lazyImageObserver.observe(lazyImage);
});
}
//這裡可以加上else處理萬一瀏覽器不支援的狀況
});
public void TEST(SEPM.SEPMDataContext oDC)
{
//一般 LINQ 寫法, 欄位只能寫死, 如:
var Q = query.OrderBy(r => r.statusId).ToList();
//若 OrderBy 的欄位不是固定的
//方法一:條列
var orderBy = "XXX";
if (orderBy == "ownerId")
{
Q = Q.OrderBy(r => r.ownerId).ToList();
}
else if (orderBy == "endDate")
{
Q = Q.OrderBy(r => r.endDate).ToList();
}
//方法二:
Q = Q.OrderBy(r => GetPropertyValue(r, orderBy)).ToList();
}
private object GetPropertyValue(object obj, string property)
{
System.Reflection.PropertyInfo propertyInfo = obj.GetType().GetProperty(property);
return propertyInfo.GetValue(obj, null);
}
foreach (DataRow oRow in DT.Rows)
{
var oSP = new DB.StorePointRecord(oRow);
:
:
}
var oSP = new DB.StorePointRecord();
foreach (DataRow oRow in DT.Rows)
{
oSP.row = oRow;
:
:
}
public static DataTable DTFromSQL(string Sql, string DBC = null, Int32 timeout = 0)
{
SqlDataAdapter DA = new SqlDataAdapter(Sql, GetDBC(DBC));
DataTable DT = new DataTable();
try
{
DA = new SqlDataAdapter(Sql, DBC);
if (timeout > 0)
{
DA.SelectCommand.CommandTimeout = timeout;
}
DA.Fill(DT);
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
finally
{
DA.Dispose();
}
return DT;
}
public static DataTable DTFromSQL(string Sql, string DBC = null, Int32 timeout = 30)
{
using (var DA = new SqlDataAdapter(Sql, GetDBC(DBC)))
{
//不可為 null
DataTable DT = new DataTable();
DA.SelectCommand.CommandTimeout = timeout;
DA.Fill(DT);
return DT;
}
}
public static void WriteText1(string FileName, List<string> ltData)
{
foreach(string data in ltData)
{
System.IO.File.AppendAllText(FileName, data);
}
}
public static void WriteText2(string FileName, List<string> ltData)
{
var Res = "";
foreach (string data in ltData)
{
Res += data;
}
System.IO.File.WriteAllText(FileName, Res);
}