92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using Csla;
|
|
using Csla.Data;
|
|
using System.ComponentModel;
|
|
|
|
namespace VEPROMS.CSLA.Library
|
|
{
|
|
// B2022-047 - refresh the Content/Text field for table. Get all grids in database.
|
|
public class CriteriaAllGridIds
|
|
{
|
|
public bool AllGridIds { get; set; }
|
|
public CriteriaAllGridIds(bool allGridIds) => AllGridIds = allGridIds;
|
|
}
|
|
[Serializable()]
|
|
[TypeConverter(typeof(FormatInfoListConverter))]
|
|
public partial class GridInfoList : ReadOnlyListBase<GridInfoList, GridInfo>
|
|
{
|
|
#region Log4Net
|
|
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
#endregion
|
|
private bool _Disposed = false;
|
|
public void Dispose()
|
|
{
|
|
if (_Disposed) return;
|
|
_Disposed = true;
|
|
}
|
|
public static GridInfoList _GridInfoList = null;
|
|
public static List<int> GetIds()
|
|
{
|
|
try
|
|
{
|
|
List<int> _GridInfoIdList = new List<int>();
|
|
try
|
|
{
|
|
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
|
{
|
|
using (SqlCommand cm = cn.CreateCommand())
|
|
{
|
|
cm.CommandType = CommandType.StoredProcedure;
|
|
cm.CommandText = "getGridIds";
|
|
cm.CommandTimeout = Database.DefaultTimeout;
|
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
|
{
|
|
while (dr.Read()) _GridInfoIdList.Add(dr.GetInt32("ContentID"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (_MyLog.IsErrorEnabled) _MyLog.Error("CriteriaAllGridIds.DataPortal_Fetch", ex);
|
|
throw new DbCslaException("CriteriaAllGridIds.DataPortal_Fetch", ex);
|
|
}
|
|
return _GridInfoIdList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new DbCslaException("Error on GridInfoList.Get", ex);
|
|
}
|
|
}
|
|
}
|
|
public partial class GridInfo
|
|
{
|
|
public void ResetContent(Grid myGrid) => RefreshFields(myGrid);
|
|
public void SetData(string myData)
|
|
{
|
|
_Data = myData;
|
|
RemoveFromCache(this);
|
|
}
|
|
public static GridInfo GetNonCached(int contentID)
|
|
{
|
|
try
|
|
{
|
|
GridInfo tmp = DataPortal.Fetch<GridInfo>(new PKCriteria(contentID));
|
|
if (tmp.ErrorMessage == "No Record Found")
|
|
{
|
|
tmp.Dispose(); // Clean-up GridInfo
|
|
tmp = null;
|
|
}
|
|
return tmp;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new DbCslaException("Error on GridInfo.Get", ex);
|
|
}
|
|
}
|
|
}
|
|
}
|