
Add RoFstLookup Dicitonary Entries for Multiple Return Values AddByROFstIDImageIDs - Add a list of figures based upon a List of ImageIDs Fix regular expression to find RO Text to replace GetDROUsagesByROIDs - get a list of ROUSages for a list of ROIDs GetJustRODB - Get Just RODB object without children GetJustROFst - Get Just ROFst or ROFstInfo object without children Reduce duplicate gets of RODB and ROFst Improve ROFst Update Performance GetByRODbIDNoData - Get RoImageInfo objects without graphic data for ROFst Update comparison GetROUSagesByROIDs - Get a list of ROUSages by ROIDs. This reduces the number of ROIDs to be checked when updating ROFst. Use GetJustRoFst and GetJustRoDB to improve the performance to see if the "Update ROFst" button should be active.
213 lines
6.0 KiB
C#
213 lines
6.0 KiB
C#
// ========================================================================
|
|
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
|
|
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
|
// ------------------------------------------------------------------------
|
|
// $Workfile: $ $Revision: $
|
|
// $Author: $ $Date: $
|
|
//
|
|
// $History: $
|
|
// ========================================================================
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using System.Xml;
|
|
using System.Xml.XPath;
|
|
using Csla;
|
|
using Csla.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
|
|
namespace VEPROMS.CSLA.Library
|
|
{
|
|
public partial class RODbInfo
|
|
{
|
|
#region RODb Config
|
|
[NonSerialized]
|
|
private RODbConfig _RODbConfig;
|
|
public RODbConfig RODbConfig
|
|
{ get { return (_RODbConfig != null ? _RODbConfig : _RODbConfig = new RODbConfig(this)); } }
|
|
private void RODbConfigRefresh()
|
|
{
|
|
_RODbConfig = null;
|
|
}
|
|
#endregion
|
|
public static RODbInfo GetJustRODB(int rODbID)
|
|
{
|
|
//if (!CanGetObject())
|
|
// throw new System.Security.SecurityException("User not authorized to view a RODb");
|
|
try
|
|
{
|
|
RODbInfo tmp = GetCachedByPrimaryKey(rODbID);
|
|
if (tmp == null)
|
|
{
|
|
tmp = DataPortal.Fetch<RODbInfo>(new PKCriteriaJustRODB(rODbID));
|
|
AddToCache(tmp);
|
|
}
|
|
if (tmp.ErrorMessage == "No Record Found")
|
|
{
|
|
tmp.Dispose(); // Clean-up RODbInfo
|
|
tmp = null;
|
|
}
|
|
return tmp;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new DbCslaException("Error on RODbInfo.Get", ex);
|
|
}
|
|
}
|
|
[Serializable()]
|
|
protected class PKCriteriaJustRODB
|
|
{
|
|
private int _RODbID;
|
|
public int RODbID
|
|
{ get { return _RODbID; } }
|
|
public PKCriteriaJustRODB(int rODbID)
|
|
{
|
|
_RODbID = rODbID;
|
|
}
|
|
}
|
|
private void DataPortal_Fetch(PKCriteriaJustRODB criteria)
|
|
{
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.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 = "getJustRODb";
|
|
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
|
|
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("RODbInfo.DataPortal_Fetch", ex);
|
|
_ErrorMessage = ex.Message;
|
|
throw new DbCslaException("RODbInfo.DataPortal_Fetch", ex);
|
|
}
|
|
}
|
|
|
|
}
|
|
public partial class RODb
|
|
{
|
|
public static RODb GetJustRoDb(int rODbID)
|
|
{
|
|
if (!CanGetObject())
|
|
throw new System.Security.SecurityException("User not authorized to view a RODb");
|
|
try
|
|
{
|
|
RODb tmp = DataPortal.Fetch<RODb>(new PKCriteriaJustRoDb(rODbID));
|
|
if (tmp.ErrorMessage == "No Record Found")
|
|
{
|
|
tmp.Dispose(); // Clean-up RODb
|
|
tmp = null;
|
|
}
|
|
return tmp;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new DbCslaException("Error on RODb.Get", ex);
|
|
}
|
|
}
|
|
private void DataPortal_Fetch(PKCriteriaJustRoDb criteria)
|
|
{
|
|
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODb.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 = "getJustRODb";
|
|
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
|
|
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
|
{
|
|
if (!dr.Read())
|
|
{
|
|
_ErrorMessage = "No Record Found";
|
|
return;
|
|
}
|
|
ReadData(dr);
|
|
// Don't load child objects
|
|
//dr.NextResult();
|
|
//_RODbROFsts = RODbROFsts.Get(dr);
|
|
// load child objects
|
|
//dr.NextResult();
|
|
//_RODbROImages = RODbROImages.Get(dr);
|
|
// load child objects
|
|
//dr.NextResult();
|
|
//_RODbRoUsages = RODbRoUsages.Get(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("RODb.DataPortal_Fetch", ex);
|
|
_ErrorMessage = ex.Message;
|
|
throw new DbCslaException("RODb.DataPortal_Fetch", ex);
|
|
}
|
|
}
|
|
[Serializable()]
|
|
protected class PKCriteriaJustRoDb
|
|
{
|
|
private int _RODbID;
|
|
public int RODbID
|
|
{ get { return _RODbID; } }
|
|
public PKCriteriaJustRoDb(int rODbID)
|
|
{
|
|
_RODbID = rODbID;
|
|
}
|
|
}
|
|
|
|
#region Log4Net
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
#endregion
|
|
|
|
#region RODb Config
|
|
[NonSerialized]
|
|
private RODbConfig _RODbConfig;
|
|
public RODbConfig RODbConfig
|
|
{
|
|
get
|
|
{
|
|
if (_RODbConfig == null)
|
|
{
|
|
_RODbConfig = new RODbConfig(this);
|
|
_RODbConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_RODbConfig_PropertyChanged);
|
|
}
|
|
return _RODbConfig;
|
|
}
|
|
}
|
|
private void _RODbConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
{
|
|
Config = _RODbConfig.ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
}
|