Added methods to support transition report functionality

This commit is contained in:
Rich
2015-01-22 22:28:14 +00:00
parent 9fd18c177d
commit 688c286296
3 changed files with 465 additions and 22 deletions

View File

@@ -324,6 +324,61 @@ namespace VEPROMS.CSLA.Library
}
public partial class FormatInfo : IFormatOrFormatInfo
{
//transition report stuff
private static Dictionary<int, string> _TransitionTypes;
public static Dictionary<int, string> GetTransitionTypesByFormatID(int formatID)
{
try
{
DataPortal.Fetch(new FormatIDCriteria(formatID));
return _TransitionTypes;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatInfo.GetTransitionTypesByFormatID", ex);
}
}
[Serializable()]
private class FormatIDCriteria
{
private int _FormatID;
public int FormatID { get { return _FormatID; } }
public FormatIDCriteria(int formatID)
{
_FormatID = formatID;
}
}
private void DataPortal_Fetch(FormatIDCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_Fetch", GetHashCode());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_GetTranTypesByFormatID";
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
_TransitionTypes = new Dictionary<int, string>();
while (dr.Read())
{
_TransitionTypes.Add(dr.GetInt32(0), dr.GetString(1));
}
}
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatInfo.DataPortal_Fetch", ex);
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
}
}
//end transition report stuff
public virtual Format GetJustFormat()
{
return _Editable = Format.GetJustFormat(_FormatID);
@@ -480,4 +535,61 @@ namespace VEPROMS.CSLA.Library
}
}
}
public class FormatVersion
{
private string _Title;
public string Title { get { return _Title; } }
private int _FormatID;
public int FormatID { get { return _FormatID; } }
private int _VersionID;
public int VersionID { get { return _VersionID; } }
public FormatVersion(string title, int formatID, int versionID)
{
_Title = title;
_FormatID = formatID;
_VersionID = versionID;
}
}
public class FormatVersionList : List<FormatVersion>
{
public static FormatVersionList GetFormatVersions()
{
try
{
FormatVersionList fvl = DataPortal.Fetch<FormatVersionList>();
return fvl;
}
catch (Exception ex)
{
throw new DbCslaException("FormatVersionList.DataPortal_Fetch GetFormatVersions", ex);
}
}
private void DataPortal_Fetch()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_GetFormatVersions";
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
while (dr.Read())
{
this.Add(new FormatVersion(dr.GetString(0), dr.GetInt32(1), dr.GetInt32(2)));
}
}
}
}
}
catch (Exception ex)
{
Database.LogException("FormatVersionList.DataPortal_Fetch", ex);
throw new DbCslaException("FormatVersionList.DataPortal_Fetch", ex);
}
}
}
}