// ========================================================================
// 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
{
///
/// Assignment Generated by MyGeneration using the CSLA Object Mapping template
///
[Serializable()]
[TypeConverter(typeof(AssignmentConverter))]
public partial class Assignment : BusinessBase, IDisposable, IVEHasBrokenRules
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Refresh
private List _RefreshAssignments = new List();
private void AddToRefreshList(List refreshAssignments)
{
if (IsDirty)
refreshAssignments.Add(this);
}
private void BuildRefreshList()
{
_RefreshAssignments = new List();
AddToRefreshList(_RefreshAssignments);
}
private void ProcessRefreshList()
{
foreach (Assignment tmp in _RefreshAssignments)
{
AssignmentInfo.Refresh(tmp);
if (tmp._MyFolder != null) FolderInfo.Refresh(tmp._MyFolder);
if (tmp._MyGroup != null) GroupInfo.Refresh(tmp._MyGroup);
if (tmp._MyRole != null) RoleInfo.Refresh(tmp._MyRole);
}
}
#endregion
#region Collection
private static List _CacheList = new List();
protected static void AddToCache(Assignment assignment)
{
if (!_CacheList.Contains(assignment)) _CacheList.Add(assignment); // In AddToCache
}
protected static void RemoveFromCache(Assignment assignment)
{
while (_CacheList.Contains(assignment)) _CacheList.Remove(assignment); // In RemoveFromCache
}
private static Dictionary> _CacheByPrimaryKey = new Dictionary>();
private static void ConvertListToDictionary()
{
List remove = new List();
foreach (Assignment tmp in _CacheList)
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.AID.ToString()))
{
_CacheByPrimaryKey[tmp.AID.ToString()] = new List(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.AID.ToString()].Add(tmp); // Add to Primary Key list
remove.Add(tmp);
}
foreach (Assignment tmp in remove)
RemoveFromCache(tmp);
}
protected static Assignment GetCachedByPrimaryKey(int aid)
{
ConvertListToDictionary();
string key = aid.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 static int _nextAID = -1;
public static int NextAID
{
get { return _nextAID--; }
}
private int _AID;
[System.ComponentModel.DataObjectField(true, true)]
public int AID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("AID", true);
return _AID;
}
}
private int _GID;
public int GID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID;
}
}
private Group _MyGroup;
public Group MyGroup
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyGroup", true);
if (_MyGroup != value)
{
_MyGroup = value;
PropertyHasChanged();
}
}
}
private int _RID;
public int RID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID;
return _RID;
}
}
private Role _MyRole;
public Role MyRole
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyRole", true);
if (_MyRole != value)
{
_MyRole = value;
PropertyHasChanged();
}
}
}
private int _FolderID;
public int FolderID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID;
}
}
private Folder _MyFolder;
public Folder MyFolder
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("MyFolder", true);
if (_MyFolder != value)
{
_MyFolder = value;
PropertyHasChanged();
}
}
}
private string _StartDate = string.Empty;
public string StartDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("StartDate", true);
return _StartDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty;
_StartDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_StartDate != tmp.ToString())
{
_StartDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private string _EndDate = string.Empty;
public string EndDate
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("EndDate", true);
return _EndDate;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty;
_EndDate = value;
try
{
SmartDate tmp = new SmartDate(value);
if (_EndDate != tmp.ToString())
{
_EndDate = tmp.ToString();
// TODO: Any Cross Property Validation
}
}
catch
{
}
PropertyHasChanged();
}
}
private DateTime _DTS = new DateTime();
public DateTime DTS
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("DTS", true);
return _DTS;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("DTS", true);
if (_DTS != value)
{
_DTS = value;
PropertyHasChanged();
}
}
}
private string _UsrID = string.Empty;
public string UsrID
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("UsrID", true);
return _UsrID;
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set
{
CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty;
if (_UsrID != value)
{
_UsrID = value;
PropertyHasChanged();
}
}
}
private byte[] _LastChanged = new byte[8];//timestamp
public override bool IsDirty
{
get
{
if ( base.IsDirty )
return true;
return IsDirtyList(new List