C2018-039: Upgrade – User Control of Format
This commit is contained in:
@@ -140,7 +140,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[NonSerialized]
|
||||
private PlantFormat _PlantFormat;
|
||||
public PlantFormat PlantFormat
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this)); } }
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this, Config)); } }
|
||||
#endregion
|
||||
public static event FormatEvent FormatLoaded;
|
||||
private static void OnFormatLoaded(object sender, FormatEventArgs args)
|
||||
@@ -517,11 +517,75 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
// Get format data, but do not resolve the 'Data' and 'Genmac' fields, i.e. keep empty if they are
|
||||
// empty.
|
||||
public static FormatInfo GetFormatNoUCFByFormatID(int formatID)
|
||||
{
|
||||
try
|
||||
{
|
||||
FormatInfo tmp = DataPortal.Fetch<FormatInfo>(new FormatIDNoUCFCriteria(formatID));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up FormatInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on FormatInfo.GetFormatNoUCFByFormatID", ex);
|
||||
}
|
||||
}
|
||||
protected class FormatIDNoUCFCriteria
|
||||
{
|
||||
private int _FormatID;
|
||||
public int FormatID { get { return _FormatID; } }
|
||||
public FormatIDNoUCFCriteria(int formatID)
|
||||
{
|
||||
_FormatID = formatID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(FormatIDNoUCFCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
ApplicationContext.LocalContext["cn"] = cn;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getFormatNoUCF";
|
||||
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
// removing of item only needed for local data portal
|
||||
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
|
||||
ApplicationContext.LocalContext.Remove("cn");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
#region PlantFormat
|
||||
[NonSerialized]
|
||||
private PlantFormat _PlantFormat;
|
||||
public PlantFormat PlantFormat
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this)); } }
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this, Config)); } }
|
||||
#endregion
|
||||
public IFormatOrFormatInfo MyIParent { get { return MyParent; } }
|
||||
public override string ToString()
|
||||
@@ -608,6 +672,51 @@ namespace VEPROMS.CSLA.Library
|
||||
return _SortedFormatInfoList;
|
||||
}
|
||||
}
|
||||
public static FormatInfoList GetFormatInfoListUsed()
|
||||
{
|
||||
try
|
||||
{
|
||||
FormatInfoList fvl = (FormatInfoList)DataPortal.Fetch(new FormatInfoListUsedCriteria());
|
||||
return fvl;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("FormatVersionList.DataPortal_Fetch GetFormatVersions", ex);
|
||||
}
|
||||
}
|
||||
protected class FormatInfoListUsedCriteria
|
||||
{
|
||||
}
|
||||
private void DataPortal_Fetch(FormatInfoListUsedCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getFormatListUsed";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
FormatInfo formatInfo = new FormatInfo(dr);
|
||||
IsReadOnly = false;
|
||||
this.Add(formatInfo);
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("FormatInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class FormatVersion
|
||||
{
|
||||
|
Reference in New Issue
Block a user