// ========================================================================
// Copyright 2007 - Volian Enterprises, Inc. All rights reserved.
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
// ------------------------------------------------------------------------
// $Workfile: $ $Revision: $
// $Author: $ $Date: $
//
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
///
/// Part Generated by MyGeneration using the CSLA Object Mapping template
///
[Serializable()]
[TypeConverter(typeof(PartConverter))]
public partial class Part : BusinessBase, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List _RefreshParts = new List();
private void AddToRefreshList(List refreshParts)
{
if (IsDirty)
refreshParts.Add(this);
}
private void ClearRefreshList()
{
_RefreshParts = new List();
}
private void BuildRefreshList()
{
ClearRefreshList();
AddToRefreshList(_RefreshParts);
}
private void ProcessRefreshList()
{
foreach (Part tmp in _RefreshParts)
{
PartInfo.Refresh(tmp);
if (tmp._MyContent != null) ContentInfo.Refresh(tmp._MyContent);
if (tmp._MyItem != null) ItemInfo.Refresh(tmp._MyItem);
}
ClearRefreshList();
}
#endregion
#region Collection
private static List _CacheList = new List();
protected static void AddToCache(Part part)
{
if (!_CacheList.Contains(part)) _CacheList.Add(part); // In AddToCache
}
protected static void RemoveFromCache(Part part)
{
while (_CacheList.Contains(part)) _CacheList.Remove(part); // In RemoveFromCache
}
private static Dictionary> _CacheByPrimaryKey = new Dictionary>();
private static void ConvertListToDictionary()
{
while (_CacheList.Count > 0) // Move Part(s) from temporary _CacheList to _CacheByPrimaryKey
{
Part tmp = _CacheList[0]; // Get the first Part
string pKey = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[pKey] = new List(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first Part
}
}
protected static Part GetCachedByPrimaryKey(int contentID, int fromType)
{
ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null;
}
#endregion
#region Business Methods
private string _ErrorMessage = string.Empty;
public string ErrorMessage
{
get { return _ErrorMessage; }
}
private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)]
public int ContentID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent != null) _ContentID = _MyContent.ContentID;
return _ContentID;
}
}
private Content _MyContent;
[System.ComponentModel.DataObjectField(true, true)]
public Content MyContent
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
return _MyContent;
}
}
private int _FromType;
[System.ComponentModel.DataObjectField(true, true)]
public int FromType
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _FromType;
}
}
private int _ItemID;
public int ItemID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID;
}
}
private Item _MyItem;
public Item MyItem
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_MyItem != value)
{
_MyItem = value;
_ItemID = value.ItemID;// Update underlying data field
PropertyHasChanged();
}
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UserID = string.Empty;
public string UserID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
return _UserID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
if (value == null) value = string.Empty;
if (_UserID != value)
{
_UserID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty
{
get
{
if (base.IsDirty)
return true;
return IsDirtyList(new List