This commit is contained in:
2009-01-27 15:36:38 +00:00
parent 20783cc178
commit 4dbbcf0478
7 changed files with 872 additions and 319 deletions

View File

@@ -271,7 +271,65 @@ namespace VEPROMS.CSLA.Library
tmp.FolderConfigRefresh();
}
}
public static FolderInfo GetTop()
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Folder");
try
{
FolderInfo tmp = DataPortal.Fetch<FolderInfo>(new TopCriteria());
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up FolderInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FolderInfo.GetTop", ex);
}
}
private void DataPortal_Fetch(TopCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.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 = "getTopFolder";
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("FolderInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FolderInfo.DataPortal_Fetch", ex);
}
}
#endregion
[Serializable()]
protected class TopCriteria
{
public TopCriteria() { ;}
}
}
}