Compare commits

..

No commits in common. "8248bd8e47a034a9b3ebc768db58486b4f9f6e8a" and "f2d330bd0e0d6fee2323dbe2521468dcd26c1dba" have entirely different histories.

254 changed files with 163231 additions and 159736 deletions

View File

@ -200,7 +200,6 @@
this.txtResults.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.txtResults.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtResults.Size = new System.Drawing.Size(489, 473); this.txtResults.Size = new System.Drawing.Size(489, 473);
this.txtResults.TabIndex = 4; this.txtResults.TabIndex = 4;
this.txtResults.TextChanged += new System.EventHandler(this.txtResults_TextChanged);
// //
// panel1 // panel1
// //
@ -313,7 +312,6 @@
this.txtProcess.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.txtProcess.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtProcess.Size = new System.Drawing.Size(291, 375); this.txtProcess.Size = new System.Drawing.Size(291, 375);
this.txtProcess.TabIndex = 5; this.txtProcess.TabIndex = 5;
this.txtProcess.TextChanged += new System.EventHandler(this.txtProcess_TextChanged);
// //
// pbProcess // pbProcess
// //
@ -342,7 +340,7 @@
this.panel3.Dock = System.Windows.Forms.DockStyle.Top; this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 23); this.panel3.Location = new System.Drawing.Point(0, 23);
this.panel3.Name = "panel3"; this.panel3.Name = "panel3";
this.panel3.Padding = new System.Windows.Forms.Padding(6); this.panel3.Padding = new System.Windows.Forms.Padding(6, 6, 6, 6);
this.panel3.Size = new System.Drawing.Size(291, 79); this.panel3.Size = new System.Drawing.Size(291, 79);
this.panel3.TabIndex = 2; this.panel3.TabIndex = 2;
// //
@ -355,7 +353,7 @@
this.pnlLater.Enabled = false; this.pnlLater.Enabled = false;
this.pnlLater.Location = new System.Drawing.Point(6, 23); this.pnlLater.Location = new System.Drawing.Point(6, 23);
this.pnlLater.Name = "pnlLater"; this.pnlLater.Name = "pnlLater";
this.pnlLater.Padding = new System.Windows.Forms.Padding(6); this.pnlLater.Padding = new System.Windows.Forms.Padding(6, 6, 6, 6);
this.pnlLater.Size = new System.Drawing.Size(279, 37); this.pnlLater.Size = new System.Drawing.Size(279, 37);
this.pnlLater.TabIndex = 3; this.pnlLater.TabIndex = 3;
// //
@ -486,7 +484,7 @@
this.sideNavItmExit}); this.sideNavItmExit});
this.sideNav1.Location = new System.Drawing.Point(0, 0); this.sideNav1.Location = new System.Drawing.Point(0, 0);
this.sideNav1.Name = "sideNav1"; this.sideNav1.Name = "sideNav1";
this.sideNav1.Padding = new System.Windows.Forms.Padding(1); this.sideNav1.Padding = new System.Windows.Forms.Padding(1, 1, 1, 1);
this.sideNav1.Size = new System.Drawing.Size(385, 525); this.sideNav1.Size = new System.Drawing.Size(385, 525);
this.sideNav1.TabIndex = 3; this.sideNav1.TabIndex = 3;
this.sideNav1.Text = "sideNav1"; this.sideNav1.Text = "sideNav1";
@ -503,7 +501,7 @@
this.sideNavPanel4.Location = new System.Drawing.Point(81, 31); this.sideNavPanel4.Location = new System.Drawing.Point(81, 31);
this.sideNavPanel4.MinimumSize = new System.Drawing.Size(0, 493); this.sideNavPanel4.MinimumSize = new System.Drawing.Size(0, 493);
this.sideNavPanel4.Name = "sideNavPanel4"; this.sideNavPanel4.Name = "sideNavPanel4";
this.sideNavPanel4.Size = new System.Drawing.Size(299, 493); this.sideNavPanel4.Size = new System.Drawing.Size(300, 493);
this.sideNavPanel4.TabIndex = 27; this.sideNavPanel4.TabIndex = 27;
// //
// swDeleteFolder // swDeleteFolder
@ -574,7 +572,7 @@
this.myTVdel.Dock = System.Windows.Forms.DockStyle.Bottom; this.myTVdel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.myTVdel.Location = new System.Drawing.Point(0, 126); this.myTVdel.Location = new System.Drawing.Point(0, 126);
this.myTVdel.Name = "myTVdel"; this.myTVdel.Name = "myTVdel";
this.myTVdel.Size = new System.Drawing.Size(299, 367); this.myTVdel.Size = new System.Drawing.Size(300, 367);
this.myTVdel.TabIndex = 34; this.myTVdel.TabIndex = 34;
this.myTVdel.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.myTV_AfterCheck_DelAnn); this.myTVdel.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.myTV_AfterCheck_DelAnn);
// //
@ -587,7 +585,7 @@
this.btnDeleteItems.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; this.btnDeleteItems.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnDeleteItems.Location = new System.Drawing.Point(39, 98); this.btnDeleteItems.Location = new System.Drawing.Point(39, 98);
this.btnDeleteItems.Name = "btnDeleteItems"; this.btnDeleteItems.Name = "btnDeleteItems";
this.btnDeleteItems.Size = new System.Drawing.Size(220, 23); this.btnDeleteItems.Size = new System.Drawing.Size(221, 23);
this.btnDeleteItems.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnDeleteItems.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.superTooltip1.SetSuperTooltip(this.btnDeleteItems, new DevComponents.DotNetBar.SuperTooltipInfo("Process Deletions", "", resources.GetString("btnDeleteItems.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(200, 175))); this.superTooltip1.SetSuperTooltip(this.btnDeleteItems, new DevComponents.DotNetBar.SuperTooltipInfo("Process Deletions", "", resources.GetString("btnDeleteItems.SuperTooltip"), null, null, DevComponents.DotNetBar.eTooltipColor.Gray, true, true, new System.Drawing.Size(200, 175)));
this.btnDeleteItems.TabIndex = 35; this.btnDeleteItems.TabIndex = 35;
@ -651,7 +649,7 @@
this.warningBox5.CloseButtonVisible = false; this.warningBox5.CloseButtonVisible = false;
this.warningBox5.Image = ((System.Drawing.Image)(resources.GetObject("warningBox5.Image"))); this.warningBox5.Image = ((System.Drawing.Image)(resources.GetObject("warningBox5.Image")));
this.warningBox5.Location = new System.Drawing.Point(17, 145); this.warningBox5.Location = new System.Drawing.Point(17, 145);
this.warningBox5.Margin = new System.Windows.Forms.Padding(4); this.warningBox5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.warningBox5.Name = "warningBox5"; this.warningBox5.Name = "warningBox5";
this.warningBox5.OptionsButtonVisible = false; this.warningBox5.OptionsButtonVisible = false;
this.warningBox5.Size = new System.Drawing.Size(262, 32); this.warningBox5.Size = new System.Drawing.Size(262, 32);
@ -735,7 +733,7 @@
this.warningBox1.CloseButtonVisible = false; this.warningBox1.CloseButtonVisible = false;
this.warningBox1.Image = ((System.Drawing.Image)(resources.GetObject("warningBox1.Image"))); this.warningBox1.Image = ((System.Drawing.Image)(resources.GetObject("warningBox1.Image")));
this.warningBox1.Location = new System.Drawing.Point(17, 181); this.warningBox1.Location = new System.Drawing.Point(17, 181);
this.warningBox1.Margin = new System.Windows.Forms.Padding(4); this.warningBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.warningBox1.Name = "warningBox1"; this.warningBox1.Name = "warningBox1";
this.warningBox1.OptionsButtonVisible = false; this.warningBox1.OptionsButtonVisible = false;
this.warningBox1.Size = new System.Drawing.Size(262, 43); this.warningBox1.Size = new System.Drawing.Size(262, 43);
@ -784,7 +782,7 @@
this.warningBox3.CloseButtonVisible = false; this.warningBox3.CloseButtonVisible = false;
this.warningBox3.Image = ((System.Drawing.Image)(resources.GetObject("warningBox3.Image"))); this.warningBox3.Image = ((System.Drawing.Image)(resources.GetObject("warningBox3.Image")));
this.warningBox3.Location = new System.Drawing.Point(17, 207); this.warningBox3.Location = new System.Drawing.Point(17, 207);
this.warningBox3.Margin = new System.Windows.Forms.Padding(4); this.warningBox3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.warningBox3.Name = "warningBox3"; this.warningBox3.Name = "warningBox3";
this.warningBox3.OptionsButtonVisible = false; this.warningBox3.OptionsButtonVisible = false;
this.warningBox3.Size = new System.Drawing.Size(264, 32); this.warningBox3.Size = new System.Drawing.Size(264, 32);
@ -988,7 +986,7 @@
this.warningBox4.CloseButtonVisible = false; this.warningBox4.CloseButtonVisible = false;
this.warningBox4.Image = ((System.Drawing.Image)(resources.GetObject("warningBox4.Image"))); this.warningBox4.Image = ((System.Drawing.Image)(resources.GetObject("warningBox4.Image")));
this.warningBox4.Location = new System.Drawing.Point(12, 264); this.warningBox4.Location = new System.Drawing.Point(12, 264);
this.warningBox4.Margin = new System.Windows.Forms.Padding(4); this.warningBox4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.warningBox4.Name = "warningBox4"; this.warningBox4.Name = "warningBox4";
this.warningBox4.OptionsButtonVisible = false; this.warningBox4.OptionsButtonVisible = false;
this.warningBox4.Size = new System.Drawing.Size(264, 32); this.warningBox4.Size = new System.Drawing.Size(264, 32);
@ -1001,7 +999,7 @@
this.warningBox2.CloseButtonVisible = false; this.warningBox2.CloseButtonVisible = false;
this.warningBox2.Image = ((System.Drawing.Image)(resources.GetObject("warningBox2.Image"))); this.warningBox2.Image = ((System.Drawing.Image)(resources.GetObject("warningBox2.Image")));
this.warningBox2.Location = new System.Drawing.Point(12, 302); this.warningBox2.Location = new System.Drawing.Point(12, 302);
this.warningBox2.Margin = new System.Windows.Forms.Padding(4); this.warningBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.warningBox2.Name = "warningBox2"; this.warningBox2.Name = "warningBox2";
this.warningBox2.OptionsButtonVisible = false; this.warningBox2.OptionsButtonVisible = false;
this.warningBox2.Size = new System.Drawing.Size(264, 43); this.warningBox2.Size = new System.Drawing.Size(264, 43);

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
@ -8,6 +10,7 @@ using System.IO;
using Volian.Controls.Library; using Volian.Controls.Library;
using DevComponents.DotNetBar; using DevComponents.DotNetBar;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
using Volian.Controls.Library;
using System.Linq; using System.Linq;
namespace VEPROMS namespace VEPROMS
@ -339,8 +342,6 @@ namespace VEPROMS
pbProcess.PerformStep(); pbProcess.PerformStep();
Application.DoEvents(); Application.DoEvents();
} }
ClearCache();
} }
Application.DoEvents(); Application.DoEvents();
@ -388,23 +389,6 @@ namespace VEPROMS
this.Cursor = Cursors.Default; this.Cursor = Cursors.Default;
} }
//C2025-011 RO Update Admin Tool Memory Enhancements
//Clear what we can from the cache
//runs after each section
private void ClearCache()
{
txtProcess.AppendText("Reclaiming memory used during previous sections.");
PartInfo.ClearPartInfoCache();
ItemInfo.ClearItemInfoCache();
Item.ClearItemCache();
ContentInfo.ClearContentInfoCache();
GridInfo.ClearGridInfoCache();
GC.Collect();
GC.WaitForPendingFinalizers();
}
//C2022-028 check for Bad RO Links - we will check all of the RO links found in procedure step text //C2022-028 check for Bad RO Links - we will check all of the RO links found in procedure step text
//B2022-144 Allow to check individual procedures for bad RO links //B2022-144 Allow to check individual procedures for bad RO links
private void CheckROLinks() private void CheckROLinks()
@ -1018,9 +1002,6 @@ namespace VEPROMS
txtResults.AppendText(Environment.NewLine); txtResults.AppendText(Environment.NewLine);
txtResults.AppendText(Environment.NewLine); txtResults.AppendText(Environment.NewLine);
} }
//C2025-011 RO Update Admin Tool Memory Enhancements
//clear the list since no longer using it
myItems.Clear();
DateTime pEnd = DateTime.Now; DateTime pEnd = DateTime.Now;
txtProcess.AppendText(string.Format("Completed: {0}", pEnd.ToString("MM/dd/yyyy @ HH:mm"))); txtProcess.AppendText(string.Format("Completed: {0}", pEnd.ToString("MM/dd/yyyy @ HH:mm")));
txtProcess.AppendText(Environment.NewLine); txtProcess.AppendText(Environment.NewLine);
@ -1107,7 +1088,6 @@ namespace VEPROMS
} }
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.RefreshROFst(dv, roFstInfo, DoProgressBarRefresh, txtProcess); ROFst newrofst = ROFstInfo.RefreshROFst(dv, roFstInfo, DoProgressBarRefresh, txtProcess);
//ROFst newrofst = ROFstInfo.RefreshROFst(dv, roFstInfo, DoProgressBarRefresh, null);
roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate); roFstInfo.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
} }
@ -1996,20 +1976,7 @@ namespace VEPROMS
pil.Add(myProcedures[tn]); pil.Add(myProcedures[tn]);
return pil; return pil;
} }
}
//C2025-011 RO Update Admin Tool Memory Enhancements
private void txtProcess_TextChanged(object sender, EventArgs e)
{
//clears the stack to help with memory - should never need to undo text changes to this.
txtProcess.ClearUndo();
}
private void txtResults_TextChanged(object sender, EventArgs e)
{
//clears the stack to help with memory - should never need to undo text changes to this.
txtResults.ClearUndo();
}
}
} }

View File

@ -49,35 +49,29 @@ namespace VEPROMS.CSLA.Library
{ {
if (DocVersionAssociations == null || DocVersionAssociations.Count == 0) return false; if (DocVersionAssociations == null || DocVersionAssociations.Count == 0) return false;
using (ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID)) ROFstInfo roFstInfo = ROFstInfo.GetJustROFst(DocVersionAssociations[0].ROFstID);
{
using (RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID))
{
string rofstPath = rdi.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) return false;
FileInfo fiRofst = new FileInfo(rofstPath); RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
string rofstPath = rdi.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath)) return false;
// if the database Ro.Fst is newer or if the files have identical DTS, FileInfo fiRofst = new FileInfo(rofstPath);
// assume that they are the same file.
if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
// next see if the data is the same size, i.e. byte count of record and byte count // if the database Ro.Fst is newer or if the files have identical DTS,
// of file. If different sizes, the date/time stamp check will hold. // assume that they are the same file.
// B2022-026 RO Memory reduction - new logic if (roFstInfo.DTS >= fiRofst.LastWriteTimeUtc) return false;
var bytes = ROFSTLookup.GetRofstLookupBytes(roFstInfo.ROFstID);
if (bytes != null && fiRofst.Length != bytes.Length) // next see if the data is the same size, i.e. byte count of record and byte count
return fiRofst.LastWriteTimeUtc > roFstInfo.DTS; // of file. If different sizes, the date/time stamp check will hold.
// B2022-026 RO Memory reduction - new logic
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's var bytes = ROFSTLookup.GetRofstLookupBytes(roFstInfo.ROFstID);
// rofsts of the size of the file & compare bytes.
return ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length);
}
}
if (bytes != null && fiRofst.Length != bytes.Length)
return fiRofst.LastWriteTimeUtc > roFstInfo.DTS;
// if we can't tell by the DTS or size, compare the contents. Get all of the rodb's
// rofsts of the size of the file & compare bytes.
return ROFstInfoList.ROFstDiffBySize(rofstPath, rdi.RODbID, (int)fiRofst.Length);
} }
} }
public bool ROfstLastCompleted public bool ROfstLastCompleted

View File

@ -40,17 +40,6 @@ namespace VEPROMS.CSLA.Library
Console.WriteLine("- - - - - -"); Console.WriteLine("- - - - - -");
} }
//C2025-011 RO Update Admin Tool Memory Enhancements
//clears everything in cache - to run between sections in the Admin Tool to reclaim memory
public static void ClearItemCache()
{
_CacheByPrimaryKey.Clear();
while (_CacheList.Count > 0)
{
_CacheList[0].DisposeOfContent = true;
_CacheList[0].Dispose();
}
}
public override string ToString() public override string ToString()
{ {
return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim(); return string.Format("{0} {1}", MyContent.Number, MyContent.Text).Trim();
@ -337,32 +326,6 @@ namespace VEPROMS.CSLA.Library
#region ItemInfo #region ItemInfo
public partial class ItemInfo : IVEDrillDownReadOnly public partial class ItemInfo : IVEDrillDownReadOnly
{ {
//C2025-011 RO Update Admin Tool Memory Enhancements
//clears everything in cache - to run between sections in the Admin Tool to reclaim memory
public static void ClearItemInfoCache()
{
while (_CacheByPrimaryKey.Count > 0)
{
var ii = _CacheByPrimaryKey.FirstOrDefault();
while (ii.Value.Count > 0)
{
if (ii.Value[0]?.MyContent?.ContentParts != null)
{ foreach (PartInfo pi in ii.Value[0]?.MyContent?.ContentParts) pi.Dispose(); }
ii.Value[0].Dispose();
}
_CacheByPrimaryKey.Remove(ii.Key);
}
while (_CacheList.Count > 0)
{
if (_CacheList[0]?.MyContent?.ContentParts != null)
{foreach (PartInfo pi in _CacheList[0]?.MyContent?.ContentParts) pi.Dispose(); }
_CacheList[0].Dispose();
}
}
private bool _PrintAllAtOnce = false; private bool _PrintAllAtOnce = false;
public bool PrintAllAtOnce public bool PrintAllAtOnce
@ -2528,19 +2491,15 @@ namespace VEPROMS.CSLA.Library
} }
public ItemInfo LastChild(E_FromType partType) public ItemInfo LastChild(E_FromType partType)
{ {
using (ItemInfoList myitems = Lookup((int)partType)) ItemInfoList myitems = Lookup((int)partType);
{ if (myitems != null) return myitems[myitems.Count - 1];
if (myitems != null) return myitems[myitems.Count - 1]; return null;
return null;
}
} }
public ItemInfo FirstChild(E_FromType partType) public ItemInfo FirstChild(E_FromType partType)
{ {
using (ItemInfoList myitems = Lookup((int)partType)) ItemInfoList myitems = Lookup((int)partType);
{ if (myitems != null) return myitems[0];
if (myitems != null) return myitems[0]; return null;
return null;
}
} }
public bool HasAncestor(ItemInfo ancestor) public bool HasAncestor(ItemInfo ancestor)
{ {
@ -3904,33 +3863,30 @@ namespace VEPROMS.CSLA.Library
} }
#endregion #endregion
#region IVEReadOnlyItem #region IVEReadOnlyItem
PartInfoList _PartInfoList;
public System.Collections.IList GetChildren() public System.Collections.IList GetChildren()
{ {
using (PartInfoList _PartInfoList = this.MyContent.ContentParts) _PartInfoList = this.MyContent.ContentParts;
{ if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps"))
if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps")) return _PartInfoList[0].GetChildren();
return _PartInfoList[0].GetChildren(); return _PartInfoList;
return _PartInfoList;
}
} }
public System.Collections.IList GetChildren(bool allParts) public System.Collections.IList GetChildren(bool allParts)
{ {
using (PartInfoList _PartInfoList = this.MyContent.ContentParts) _PartInfoList = this.MyContent.ContentParts;
{ if (allParts)
if (allParts) {
{ if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps"))
if (_PartInfoList.Count == 1 && ((IsProcedure && _PartInfoList[0].ToString() == "Sections") || _PartInfoList[0].ToString() == "Steps"))
return _PartInfoList[0].GetChildren(); return _PartInfoList[0].GetChildren();
return _PartInfoList; return _PartInfoList;
} }
else // Steps and Sections only else // Steps and Sections only
{ {
for (int i = 0; i < _PartInfoList.Count; i++) for (int i = 0; i < _PartInfoList.Count; i++)
if (_PartInfoList[i].ToString() == "Sections" || _PartInfoList[i].ToString() == "Steps") if (_PartInfoList[i].ToString() == "Sections" || _PartInfoList[i].ToString() == "Steps")
return _PartInfoList[i].GetChildren(); return _PartInfoList[i].GetChildren();
return null; return null;
}
} }
} }
//public bool ChildrenAreLoaded //public bool ChildrenAreLoaded
@ -6229,8 +6185,8 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new MoveItemCriteria(itemID, index))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new MoveItemCriteria(itemID, index));
{ return tmp; } return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6242,15 +6198,13 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListCriteria(itemID, type))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListCriteria(itemID, type));
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); #if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList ContentInfoList.GetList(itemID); // Performance - Load All Content
ContentInfoList.GetList(itemID); // Performance - Load All Content #endif
#endif return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6261,16 +6215,13 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranToListCriteria())) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranToListCriteria());
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); #if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList ContentInfoList.GetList(itemID); // Performance - Load All Content
ContentInfoList.GetList(itemID); // Performance - Load All Content #endif
#endif return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6281,15 +6232,13 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranFromListCriteria())) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemTranFromListCriteria());
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); #if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList ContentInfoList.GetList(itemID); // Performance - Load All Content
ContentInfoList.GetList(itemID); // Performance - Load All Content #endif
#endif return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6300,15 +6249,13 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListPartTypeCriteria(fromType))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListPartTypeCriteria(fromType));
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); #if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList
#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList ContentInfoList.GetList(itemID); // Performance - Load All Content
ContentInfoList.GetList(itemID); // Performance - Load All Content #endif
#endif return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6793,8 +6740,8 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedTextDifferencesCriteria(procItem.ItemID))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedTextDifferencesCriteria(procItem.ItemID));
{ return tmp; } return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6862,8 +6809,8 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedMissingCriteria(srcItem.ItemID, enhType))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListEnhancedMissingCriteria(srcItem.ItemID, enhType));
{ return tmp; } return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -6932,13 +6879,11 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListSearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, byWordPrefix, byWordSuffix))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListSearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, byWordPrefix, byWordSuffix));
{ tmp.SourceOfList = "Search";
tmp.SourceOfList = "Search"; ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -7093,12 +7038,10 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROSearchCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROSearchCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix));
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -7199,12 +7142,10 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListAnnotationSearchCriteria(docVersionList, stepTypeList, annotationTypeList, searchString, caseSensitive, unitPrefix))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListAnnotationSearchCriteria(docVersionList, stepTypeList, annotationTypeList, searchString, caseSensitive, unitPrefix));
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -7325,12 +7266,10 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListTransitionSearchCriteria(docVersionList, tranType, tranCategory, stepTypeList))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListTransitionSearchCriteria(docVersionList, tranType, tranCategory, stepTypeList));
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -7416,12 +7355,10 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROReportCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListROReportCriteria(docVersionList, stepTypeList, roSearchString, unitPrefix));
{ ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -7523,13 +7460,11 @@ namespace VEPROMS.CSLA.Library
{ {
try try
{ {
using (ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListApplicabilitySearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, applicSetting))) ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ItemListApplicabilitySearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, applicSetting));
{ tmp.SourceOfList = "Search";
tmp.SourceOfList = "Search"; ItemInfo.AddList(tmp);
ItemInfo.AddList(tmp); tmp.AddEvents();
tmp.AddEvents(); return tmp;
return tmp;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -8179,30 +8114,27 @@ namespace VEPROMS.CSLA.Library
// get list of differences from sql. This list does not resolve links and may have other rtf commands. // get list of differences from sql. This list does not resolve links and may have other rtf commands.
// also this list is source items, not enhanced. // also this list is source items, not enhanced.
ItemInfoList iil = ItemInfoList.GetListEnhancedTextDifferences(this);
if (iil == null || iil.Count == 0) return null; // no differences were found.
using (ItemInfoList iil = ItemInfoList.GetListEnhancedTextDifferences(this)) // from sql list, get display text of source items & compare to this procedure's items. This
// will determine true 'text' differences. Then return this list.
ItemInfoList retiil = null; // new ItemInfoList(null);
foreach (ItemInfo ii in iil)
{ {
if (iil == null || iil.Count == 0) return null; // no differences were found. EnhancedDocuments seds = ii.GetMyEnhancedDocuments();
if (seds != null && seds.Count != 0)
// from sql list, get display text of source items & compare to this procedure's items. This
// will determine true 'text' differences. Then return this list.
ItemInfoList retiil = null; // new ItemInfoList(null);
foreach (ItemInfo ii in iil)
{ {
EnhancedDocuments seds = ii.GetMyEnhancedDocuments();
if (seds != null && seds.Count != 0)
{
ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID); ItemInfo srcItem = ItemInfo.Get(seds[0].ItemID);
// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. Null reference check // B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced. Null reference check
if (srcItem != null && srcItem.DisplayTextKeepSpecialChars != ii.DisplayTextKeepSpecialChars) if (srcItem != null && srcItem.DisplayTextKeepSpecialChars != ii.DisplayTextKeepSpecialChars)
{ {
if (retiil == null) retiil = new ItemInfoList(ii); if (retiil == null) retiil = new ItemInfoList(ii);
else retiil.AddItem(ii); else retiil.AddItem(ii);
}
} }
} }
return retiil;
} }
return retiil;
} }
public void EnhancedProcedureRefreshTextDifferences(ItemInfoList iil) public void EnhancedProcedureRefreshTextDifferences(ItemInfoList iil)
{ {

View File

@ -84,6 +84,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("LastChanged", true);
return _LastChanged; return _LastChanged;
} }
set { _LastChanged = value; } set { _LastChanged = value; }

View File

@ -80,6 +80,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("LastChanged", true);
return _LastChanged; return _LastChanged;
} }
set { _LastChanged = value; } set { _LastChanged = value; }

View File

@ -108,6 +108,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID", true);
return _AnnotationID; return _AnnotationID;
} }
} }
@ -117,6 +118,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -127,12 +129,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
@ -147,6 +151,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID; return _TypeID;
} }
@ -157,12 +162,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationType.Get(_TypeID);
return _MyAnnotationType; return _MyAnnotationType;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyAnnotationType", true);
if (_MyAnnotationType != value) if (_MyAnnotationType != value)
{ {
_MyAnnotationType = value; _MyAnnotationType = value;
@ -177,11 +184,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_RtfText != value) if (_RtfText != value)
{ {
@ -196,11 +205,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_SearchText != value) if (_SearchText != value)
{ {
@ -215,11 +226,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -234,11 +247,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -252,11 +267,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {

View File

@ -106,6 +106,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AuditID", true);
return _AuditID; return _AuditID;
} }
} }
@ -115,11 +116,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID", true);
return _AnnotationID; return _AnnotationID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("AnnotationID", true);
if (_AnnotationID != value) if (_AnnotationID != value)
{ {
_AnnotationID = value; _AnnotationID = value;
@ -133,11 +136,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID", true);
return _ItemID; return _ItemID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("ItemID", true);
if (_ItemID != value) if (_ItemID != value)
{ {
_ItemID = value; _ItemID = value;
@ -151,11 +156,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID", true);
return _TypeID; return _TypeID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("TypeID", true);
if (_TypeID != value) if (_TypeID != value)
{ {
_TypeID = value; _TypeID = value;
@ -169,11 +176,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_RtfText != value) if (_RtfText != value)
{ {
@ -188,11 +197,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_SearchText != value) if (_SearchText != value)
{ {
@ -207,11 +218,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -226,11 +239,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -244,11 +259,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -263,11 +280,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DeleteStatus", true);
return _DeleteStatus; return _DeleteStatus;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DeleteStatus", true);
if (_DeleteStatus != value) if (_DeleteStatus != value)
{ {
_DeleteStatus = value; _DeleteStatus = value;

View File

@ -96,6 +96,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AuditID", true);
return _AuditID; return _AuditID;
} }
} }
@ -105,6 +106,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID", true);
return _AnnotationID; return _AnnotationID;
} }
} }
@ -114,6 +116,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID", true);
return _ItemID; return _ItemID;
} }
} }
@ -123,6 +126,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID", true);
return _TypeID; return _TypeID;
} }
} }
@ -132,6 +136,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
} }
@ -141,6 +146,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
} }
@ -150,6 +156,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -159,6 +166,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -168,6 +176,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -177,6 +186,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DeleteStatus", true);
return _DeleteStatus; return _DeleteStatus;
} }
} }

View File

@ -109,6 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID", true);
return _AnnotationID; return _AnnotationID;
} }
} }
@ -118,6 +119,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -128,6 +130,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
return _MyItem; return _MyItem;
} }
@ -138,6 +141,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID", true);
if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID; if (_MyAnnotationType != null) _TypeID = _MyAnnotationType.TypeID;
return _TypeID; return _TypeID;
} }
@ -148,6 +152,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotationType", true);
if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID); if (_MyAnnotationType == null && _TypeID != 0) _MyAnnotationType = AnnotationTypeInfo.Get(_TypeID);
return _MyAnnotationType; return _MyAnnotationType;
} }
@ -158,6 +163,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
} }
@ -167,6 +173,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
} }
@ -176,6 +183,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -185,6 +193,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -194,6 +203,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }

View File

@ -129,6 +129,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID", true);
return _TypeID; return _TypeID;
} }
} }
@ -138,11 +139,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name", true);
return _Name; return _Name;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Name", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Name != value) if (_Name != value)
{ {
@ -157,11 +160,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -176,11 +181,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -194,11 +201,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -217,6 +226,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotationCount", true);
return _AnnotationTypeAnnotationCount; return _AnnotationTypeAnnotationCount;
} }
} }
@ -230,6 +240,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotations", true);
if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null)) if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null))
_AnnotationTypeAnnotations = AnnotationTypeAnnotations.GetByTypeID(TypeID); _AnnotationTypeAnnotations = AnnotationTypeAnnotations.GetByTypeID(TypeID);
if (_AnnotationTypeAnnotationCount < 0 ) if (_AnnotationTypeAnnotationCount < 0 )

View File

@ -43,6 +43,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationID", true);
if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID; if (_MyAnnotation != null) _AnnotationID = _MyAnnotation.AnnotationID;
return _AnnotationID; return _AnnotationID;
} }
@ -54,6 +55,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyAnnotation", true);
if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID); if (_MyAnnotation == null && _AnnotationID != 0) _MyAnnotation = Annotation.Get(_AnnotationID);
return _MyAnnotation; return _MyAnnotation;
} }
@ -64,6 +66,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("ItemID", true);
if (_MyItem != null) _ItemID = _MyItem.ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
return _ItemID; return _ItemID;
} }
@ -74,12 +77,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyItem", true);
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
return _MyItem; return _MyItem;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyItem", true);
if (_MyItem != value) if (_MyItem != value)
{ {
_MyItem = value; _MyItem = value;
@ -94,11 +99,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RtfText", true);
return _RtfText; return _RtfText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("RtfText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_RtfText != value) if (_RtfText != value)
{ {
@ -113,11 +120,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("SearchText", true);
return _SearchText; return _SearchText;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("SearchText", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_SearchText != value) if (_SearchText != value)
{ {
@ -132,11 +141,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("Config", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_Config != value) if (_Config != value)
{ {
@ -151,11 +162,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -169,11 +182,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UserID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UserID != value) if (_UserID != value)
{ {
@ -189,6 +204,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_PreviousID", true);
return _Item_PreviousID; return _Item_PreviousID;
} }
} }
@ -198,6 +214,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_ContentID", true);
return _Item_ContentID; return _Item_ContentID;
} }
} }
@ -207,6 +224,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_DTS", true);
return _Item_DTS; return _Item_DTS;
} }
} }
@ -216,6 +234,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Item_UserID", true);
return _Item_UserID; return _Item_UserID;
} }
} }

View File

@ -96,6 +96,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("TypeID", true);
return _TypeID; return _TypeID;
} }
} }
@ -105,6 +106,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Name", true);
return _Name; return _Name;
} }
} }
@ -114,6 +116,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("Config", true);
return _Config; return _Config;
} }
} }
@ -123,6 +126,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
} }
@ -132,6 +136,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
@ -144,6 +149,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotationCount", true);
if (_AnnotationTypeAnnotationCount < 0) if (_AnnotationTypeAnnotationCount < 0)
_AnnotationTypeAnnotationCount = AnnotationTypeAnnotations.Count; _AnnotationTypeAnnotationCount = AnnotationTypeAnnotations.Count;
return _AnnotationTypeAnnotationCount; return _AnnotationTypeAnnotationCount;
@ -156,6 +162,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AnnotationTypeAnnotations", true);
if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null)) if (_AnnotationTypeAnnotationCount < 0 || (_AnnotationTypeAnnotationCount > 0 && _AnnotationTypeAnnotations == null))
_AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID); _AnnotationTypeAnnotations = AnnotationInfoList.GetByTypeID(_TypeID);
if (_AnnotationTypeAnnotationCount < 0) if (_AnnotationTypeAnnotationCount < 0)

View File

@ -109,6 +109,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("AID", true);
return _AID; return _AID;
} }
} }
@ -118,6 +119,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("GID", true);
if (_MyGroup != null) _GID = _MyGroup.GID; if (_MyGroup != null) _GID = _MyGroup.GID;
return _GID; return _GID;
} }
@ -128,12 +130,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyGroup", true);
if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID); if (_MyGroup == null && _GID != 0) _MyGroup = Group.Get(_GID);
return _MyGroup; return _MyGroup;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyGroup", true);
if (_MyGroup != value) if (_MyGroup != value)
{ {
_MyGroup = value; _MyGroup = value;
@ -148,6 +152,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("RID", true);
if (_MyRole != null) _RID = _MyRole.RID; if (_MyRole != null) _RID = _MyRole.RID;
return _RID; return _RID;
} }
@ -158,12 +163,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyRole", true);
if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID); if (_MyRole == null && _RID != 0) _MyRole = Role.Get(_RID);
return _MyRole; return _MyRole;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyRole", true);
if (_MyRole != value) if (_MyRole != value)
{ {
_MyRole = value; _MyRole = value;
@ -178,6 +185,7 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("FolderID", true);
if (_MyFolder != null) _FolderID = _MyFolder.FolderID; if (_MyFolder != null) _FolderID = _MyFolder.FolderID;
return _FolderID; return _FolderID;
} }
@ -188,12 +196,14 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("MyFolder", true);
if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID); if (_MyFolder == null && _FolderID != 0) _MyFolder = Folder.Get(_FolderID);
return _MyFolder; return _MyFolder;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("MyFolder", true);
if (_MyFolder != value) if (_MyFolder != value)
{ {
_MyFolder = value; _MyFolder = value;
@ -208,11 +218,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("StartDate", true);
return _StartDate; return _StartDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("StartDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_StartDate = value; _StartDate = value;
try try
@ -236,11 +248,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("EndDate", true);
return _EndDate; return _EndDate;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("EndDate", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
_EndDate = value; _EndDate = value;
try try
@ -264,11 +278,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("DTS", true);
return _DTS; return _DTS;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("DTS", true);
if (_DTS != value) if (_DTS != value)
{ {
_DTS = value; _DTS = value;
@ -282,11 +298,13 @@ namespace VEPROMS.CSLA.Library
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
CanReadProperty("UsrID", true);
return _UsrID; return _UsrID;
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set set
{ {
CanWriteProperty("UsrID", true);
if (value == null) value = string.Empty; if (value == null) value = string.Empty;
if (_UsrID != value) if (_UsrID != value)
{ {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,424 +19,432 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void AssociationInfoEvent(object sender); public delegate void AssociationInfoEvent(object sender);
/// <summary> /// <summary>
/// AssociationInfo Generated by MyGeneration using the CSLA Object Mapping template /// AssociationInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(AssociationInfoConverter))] [TypeConverter(typeof(AssociationInfoConverter))]
public partial class AssociationInfo : ReadOnlyBase<AssociationInfo>, IDisposable public partial class AssociationInfo : ReadOnlyBase<AssociationInfo>, IDisposable
{ {
public event AssociationInfoEvent Changed; public event AssociationInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<AssociationInfo> _CacheList = new List<AssociationInfo>(); private static List<AssociationInfo> _CacheList = new List<AssociationInfo>();
protected static void AddToCache(AssociationInfo associationInfo) protected static void AddToCache(AssociationInfo associationInfo)
{ {
if (!_CacheList.Contains(associationInfo)) _CacheList.Add(associationInfo); // In AddToCache if (!_CacheList.Contains(associationInfo)) _CacheList.Add(associationInfo); // In AddToCache
} }
protected static void RemoveFromCache(AssociationInfo associationInfo) protected static void RemoveFromCache(AssociationInfo associationInfo)
{ {
while (_CacheList.Contains(associationInfo)) _CacheList.Remove(associationInfo); // In RemoveFromCache while (_CacheList.Contains(associationInfo)) _CacheList.Remove(associationInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<AssociationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssociationInfo>>(); private static Dictionary<string, List<AssociationInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AssociationInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move AssociationInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move AssociationInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
AssociationInfo tmp = _CacheList[0]; // Get the first AssociationInfo AssociationInfo tmp = _CacheList[0]; // Get the first AssociationInfo
string pKey = tmp.AssociationID.ToString(); string pKey = tmp.AssociationID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<AssociationInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<AssociationInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first AssociationInfo _CacheList.RemoveAt(0); // Remove the first AssociationInfo
} }
} }
internal static void AddList(AssociationInfoList lst) internal static void AddList(AssociationInfoList lst)
{ {
foreach (AssociationInfo item in lst) AddToCache(item); foreach (AssociationInfo item in lst) AddToCache(item);
} }
protected static AssociationInfo GetCachedByPrimaryKey(int associationID) protected static AssociationInfo GetCachedByPrimaryKey(int associationID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = associationID.ToString(); string key = associationID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Association _Editable; protected Association _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _AssociationID; private int _AssociationID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int AssociationID public int AssociationID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AssociationID; CanReadProperty("AssociationID", true);
} return _AssociationID;
} }
private int _VersionID; }
public int VersionID private int _VersionID;
{ public int VersionID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID; {
return _VersionID; CanReadProperty("VersionID", true);
} if (_MyDocVersion != null) _VersionID = _MyDocVersion.VersionID;
} return _VersionID;
private DocVersionInfo _MyDocVersion; }
public DocVersionInfo MyDocVersion }
{ private DocVersionInfo _MyDocVersion;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public DocVersionInfo MyDocVersion
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersionInfo.Get(_VersionID); get
return _MyDocVersion; {
} CanReadProperty("MyDocVersion", true);
} if (_MyDocVersion == null && _VersionID != 0) _MyDocVersion = DocVersionInfo.Get(_VersionID);
private int _ROFstID; return _MyDocVersion;
public int ROFstID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _ROFstID;
get public int ROFstID
{ {
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ROFstID; get
} {
} CanReadProperty("ROFstID", true);
private ROFstInfo _MyROFst; if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
public ROFstInfo MyROFst return _ROFstID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private ROFstInfo _MyROFst;
{ public ROFstInfo MyROFst
//if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID); {
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.GetJustROFst(_ROFstID);// Improve performance by not loading all ROImages [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _MyROFst; get
} {
} CanReadProperty("MyROFst", true);
private string _Config = string.Empty; //if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID);
public string Config if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.GetJustROFst(_ROFstID);// Improve performance by not loading all ROImages
{ return _MyROFst;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
// CSLATODO: Replace base AssociationInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current AssociationInfo</returns> CanReadProperty("UserID", true);
//public override string ToString() return _UserID;
//{ }
// return base.ToString(); }
//} // CSLATODO: Replace base AssociationInfo.ToString function as necessary
// CSLATODO: Check AssociationInfo.GetIdValue to assure that the ID returned is unique /// <summary>
/// <summary> /// Overrides Base ToString
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// </summary>
/// </summary> /// <returns>A string representation of current AssociationInfo</returns>
/// <returns>A Unique ID for the current AssociationInfo</returns> //public override string ToString()
protected override object GetIdValue() //{
{ // return base.ToString();
return MyAssociationInfoUnique; // Absolutely Unique ID //}
} // CSLATODO: Check AssociationInfo.GetIdValue to assure that the ID returned is unique
#endregion /// <summary>
#region Factory Methods /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int _AssociationInfoUnique = 0; /// </summary>
private static int AssociationInfoUnique /// <returns>A Unique ID for the current AssociationInfo</returns>
{ get { return ++_AssociationInfoUnique; } } protected override object GetIdValue()
private int _MyAssociationInfoUnique = AssociationInfoUnique; {
public int MyAssociationInfoUnique // Absolutely Unique ID - Info return MyAssociationInfoUnique; // Absolutely Unique ID
{ get { return _MyAssociationInfoUnique; } } }
protected AssociationInfo() #endregion
{/* require use of factory methods */ #region Factory Methods
AddToCache(this); private static int _AssociationInfoUnique = 0;
} private static int AssociationInfoUnique
private bool _Disposed = false; { get { return ++_AssociationInfoUnique; } }
private static int _CountCreated = 0; private int _MyAssociationInfoUnique = AssociationInfoUnique;
private static int _CountDisposed = 0; public int MyAssociationInfoUnique // Absolutely Unique ID - Info
private static int _CountFinalized = 0; { get { return _MyAssociationInfoUnique; } }
private static int IncrementCountCreated protected AssociationInfo()
{ get { return ++_CountCreated; } } {/* require use of factory methods */
private int _CountWhenCreated = IncrementCountCreated; AddToCache(this);
public static int CountCreated }
{ get { return _CountCreated; } } private bool _Disposed = false;
public static int CountNotDisposed private static int _CountCreated = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountDisposed = 0;
public static int CountNotFinalized private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int IncrementCountCreated
~AssociationInfo() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
_CountFinalized++; public static int CountCreated
} { get { return _CountCreated; } }
public void Dispose() public static int CountNotDisposed
{ { get { return _CountCreated - _CountDisposed; } }
if (_Disposed) return; public static int CountNotFinalized
_CountDisposed++; { get { return _CountCreated - _CountFinalized; } }
_Disposed = true; ~AssociationInfo()
RemoveFromCache(this); {
if (!_CacheByPrimaryKey.ContainsKey(AssociationID.ToString())) return; _CountFinalized++;
List<AssociationInfo> listAssociationInfo = _CacheByPrimaryKey[AssociationID.ToString()]; // Get the list of items }
while (listAssociationInfo.Contains(this)) listAssociationInfo.Remove(this); // Remove the item from the list public void Dispose()
if (listAssociationInfo.Count == 0) // If there are no items left in the list {
_CacheByPrimaryKey.Remove(AssociationID.ToString()); // remove the list if (_Disposed) return;
} _CountDisposed++;
public virtual Association Get() _Disposed = true;
{ RemoveFromCache(this);
return _Editable = Association.Get(_AssociationID); if (!_CacheByPrimaryKey.ContainsKey(AssociationID.ToString())) return;
} List<AssociationInfo> listAssociationInfo = _CacheByPrimaryKey[AssociationID.ToString()]; // Get the list of items
public static void Refresh(Association tmp) while (listAssociationInfo.Contains(this)) listAssociationInfo.Remove(this); // Remove the item from the list
{ if (listAssociationInfo.Count == 0) // If there are no items left in the list
string key = tmp.AssociationID.ToString(); _CacheByPrimaryKey.Remove(AssociationID.ToString()); // remove the list
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) public virtual Association Get()
foreach (AssociationInfo tmpInfo in _CacheByPrimaryKey[key]) {
tmpInfo.RefreshFields(tmp); return _Editable = Association.Get(_AssociationID);
} }
protected virtual void RefreshFields(Association tmp) public static void Refresh(Association tmp)
{ {
if (_VersionID != tmp.VersionID) string key = tmp.AssociationID.ToString();
{ ConvertListToDictionary();
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_VersionID = tmp.VersionID; // Update the value foreach (AssociationInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyDocVersion = null; // Reset list so that the next line gets a new list }
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for new value protected virtual void RefreshFields(Association tmp)
if (_ROFstID != tmp.ROFstID) {
{ if (_VersionID != tmp.VersionID)
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for old value {
_ROFstID = tmp.ROFstID; // Update the value if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for old value
} _VersionID = tmp.VersionID; // Update the value
_MyROFst = null; // Reset list so that the next line gets a new list }
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for new value _MyDocVersion = null; // Reset list so that the next line gets a new list
_Config = tmp.Config; if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for new value
_DTS = tmp.DTS; if (_ROFstID != tmp.ROFstID)
_UserID = tmp.UserID; {
_AssociationInfoExtension.Refresh(this); if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for old value
OnChange();// raise an event _ROFstID = tmp.ROFstID; // Update the value
} }
public static void Refresh(DocVersionAssociation tmp) _MyROFst = null; // Reset list so that the next line gets a new list
{ if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for new value
string key = tmp.AssociationID.ToString(); _Config = tmp.Config;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (AssociationInfo tmpInfo in _CacheByPrimaryKey[key]) _AssociationInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(DocVersionAssociation tmp) public static void Refresh(DocVersionAssociation tmp)
{ {
if (_ROFstID != tmp.ROFstID) string key = tmp.AssociationID.ToString();
{ ConvertListToDictionary();
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_ROFstID = tmp.ROFstID; // Update the value foreach (AssociationInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyROFst = null; // Reset list so that the next line gets a new list }
if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for new value protected virtual void RefreshFields(DocVersionAssociation tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_ROFstID != tmp.ROFstID)
_UserID = tmp.UserID; {
_AssociationInfoExtension.Refresh(this); if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for old value
OnChange();// raise an event _ROFstID = tmp.ROFstID; // Update the value
} }
public static void Refresh(ROFstAssociation tmp) _MyROFst = null; // Reset list so that the next line gets a new list
{ if (MyROFst != null) MyROFst.RefreshROFstAssociations(); // Update List for new value
string key = tmp.AssociationID.ToString(); _Config = tmp.Config;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (AssociationInfo tmpInfo in _CacheByPrimaryKey[key]) _AssociationInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(ROFstAssociation tmp) public static void Refresh(ROFstAssociation tmp)
{ {
if (_VersionID != tmp.VersionID) string key = tmp.AssociationID.ToString();
{ ConvertListToDictionary();
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_VersionID = tmp.VersionID; // Update the value foreach (AssociationInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyDocVersion = null; // Reset list so that the next line gets a new list }
if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for new value protected virtual void RefreshFields(ROFstAssociation tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_VersionID != tmp.VersionID)
_UserID = tmp.UserID; {
_AssociationInfoExtension.Refresh(this); if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for old value
OnChange();// raise an event _VersionID = tmp.VersionID; // Update the value
} }
public static AssociationInfo Get(int associationID) _MyDocVersion = null; // Reset list so that the next line gets a new list
{ if (MyDocVersion != null) MyDocVersion.RefreshDocVersionAssociations(); // Update List for new value
//if (!CanGetObject()) _Config = tmp.Config;
// throw new System.Security.SecurityException("User not authorized to view a Association"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _AssociationInfoExtension.Refresh(this);
AssociationInfo tmp = GetCachedByPrimaryKey(associationID); OnChange();// raise an event
if (tmp == null) }
{ public static AssociationInfo Get(int associationID)
tmp = DataPortal.Fetch<AssociationInfo>(new PKCriteria(associationID)); {
AddToCache(tmp); //if (!CanGetObject())
} // throw new System.Security.SecurityException("User not authorized to view a Association");
if (tmp.ErrorMessage == "No Record Found") try
{ {
tmp.Dispose(); // Clean-up AssociationInfo AssociationInfo tmp = GetCachedByPrimaryKey(associationID);
tmp = null; if (tmp == null)
} {
return tmp; tmp = DataPortal.Fetch<AssociationInfo>(new PKCriteria(associationID));
} AddToCache(tmp);
catch (Exception ex) }
{ if (tmp.ErrorMessage == "No Record Found")
throw new DbCslaException("Error on AssociationInfo.Get", ex); {
} tmp.Dispose(); // Clean-up AssociationInfo
} tmp = null;
#endregion }
#region Data Access Portal return tmp;
internal AssociationInfo(SafeDataReader dr) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssociationInfo.Constructor", GetHashCode()); {
try throw new DbCslaException("Error on AssociationInfo.Get", ex);
{ }
ReadData(dr); }
} #endregion
catch (Exception ex) #region Data Access Portal
{ internal AssociationInfo(SafeDataReader dr)
if (_MyLog.IsErrorEnabled) _MyLog.Error("AssociationInfo.Constructor", ex); {
throw new DbCslaException("AssociationInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssociationInfo.Constructor", GetHashCode());
} try
} {
[Serializable()] ReadData(dr);
protected class PKCriteria }
{ catch (Exception ex)
private int _AssociationID; {
public int AssociationID if (_MyLog.IsErrorEnabled) _MyLog.Error("AssociationInfo.Constructor", ex);
{ get { return _AssociationID; } } throw new DbCslaException("AssociationInfo.Constructor", ex);
public PKCriteria(int associationID) }
{ }
_AssociationID = associationID; [Serializable()]
} protected class PKCriteria
} {
private void ReadData(SafeDataReader dr) private int _AssociationID;
{ public int AssociationID
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssociationInfo.ReadData", GetHashCode()); { get { return _AssociationID; } }
try public PKCriteria(int associationID)
{ {
_AssociationID = dr.GetInt32("AssociationID"); _AssociationID = associationID;
_VersionID = dr.GetInt32("VersionID"); }
_ROFstID = dr.GetInt32("ROFstID"); }
_Config = dr.GetString("Config"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssociationInfo.ReadData", GetHashCode());
} try
catch (Exception ex) {
{ _AssociationID = dr.GetInt32("AssociationID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("AssociationInfo.ReadData", ex); _VersionID = dr.GetInt32("VersionID");
_ErrorMessage = ex.Message; _ROFstID = dr.GetInt32("ROFstID");
throw new DbCslaException("AssociationInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssociationInfo.DataPortal_Fetch", GetHashCode()); {
try if (_MyLog.IsErrorEnabled) _MyLog.Error("AssociationInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
using (SqlConnection cn = Database.VEPROMS_SqlConnection) throw new DbCslaException("AssociationInfo.ReadData", ex);
{ }
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) private void DataPortal_Fetch(PKCriteria criteria)
{ {
cm.CommandType = CommandType.StoredProcedure; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AssociationInfo.DataPortal_Fetch", GetHashCode());
cm.CommandText = "getAssociation"; try
cm.Parameters.AddWithValue("@AssociationID", criteria.AssociationID); {
cm.CommandTimeout = Database.DefaultTimeout; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ ApplicationContext.LocalContext["cn"] = cn;
if (!dr.Read()) using (SqlCommand cm = cn.CreateCommand())
{ {
_ErrorMessage = "No Record Found"; cm.CommandType = CommandType.StoredProcedure;
return; cm.CommandText = "getAssociation";
} cm.Parameters.AddWithValue("@AssociationID", criteria.AssociationID);
ReadData(dr); cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
// removing of item only needed for local data portal if (!dr.Read())
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); _ErrorMessage = "No Record Found";
} return;
} }
catch (Exception ex) ReadData(dr);
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("AssociationInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; // removing of item only needed for local data portal
throw new DbCslaException("AssociationInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
} }
#endregion }
// Standard Refresh catch (Exception ex)
#region extension {
AssociationInfoExtension _AssociationInfoExtension = new AssociationInfoExtension(); if (_MyLog.IsErrorEnabled) _MyLog.Error("AssociationInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
partial class AssociationInfoExtension : extensionBase { } throw new DbCslaException("AssociationInfo.DataPortal_Fetch", ex);
[Serializable()] }
class extensionBase }
{ #endregion
// Default Refresh // Standard Refresh
public virtual void Refresh(AssociationInfo tmp) { } #region extension
} AssociationInfoExtension _AssociationInfoExtension = new AssociationInfoExtension();
#endregion [Serializable()]
} // Class partial class AssociationInfoExtension : extensionBase { }
#region Converter [Serializable()]
internal class AssociationInfoConverter : ExpandableObjectConverter class extensionBase
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) // Default Refresh
{ public virtual void Refresh(AssociationInfo tmp) { }
if (destType == typeof(string) && value is AssociationInfo) }
{ #endregion
// Return the ToString value } // Class
return ((AssociationInfo)value).ToString(); #region Converter
} internal class AssociationInfoConverter : ExpandableObjectConverter
return base.ConvertTo(context, culture, value, destType); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
#endregion if (destType == typeof(string) && value is AssociationInfo)
{
// Return the ToString value
return ((AssociationInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,423 +19,431 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void CheckInfoEvent(object sender); public delegate void CheckInfoEvent(object sender);
/// <summary> /// <summary>
/// CheckInfo Generated by MyGeneration using the CSLA Object Mapping template /// CheckInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(CheckInfoConverter))] [TypeConverter(typeof(CheckInfoConverter))]
public partial class CheckInfo : ReadOnlyBase<CheckInfo>, IDisposable public partial class CheckInfo : ReadOnlyBase<CheckInfo>, IDisposable
{ {
public event CheckInfoEvent Changed; public event CheckInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<CheckInfo> _CacheList = new List<CheckInfo>(); private static List<CheckInfo> _CacheList = new List<CheckInfo>();
protected static void AddToCache(CheckInfo checkInfo) protected static void AddToCache(CheckInfo checkInfo)
{ {
if (!_CacheList.Contains(checkInfo)) _CacheList.Add(checkInfo); // In AddToCache if (!_CacheList.Contains(checkInfo)) _CacheList.Add(checkInfo); // In AddToCache
} }
protected static void RemoveFromCache(CheckInfo checkInfo) protected static void RemoveFromCache(CheckInfo checkInfo)
{ {
while (_CacheList.Contains(checkInfo)) _CacheList.Remove(checkInfo); // In RemoveFromCache while (_CacheList.Contains(checkInfo)) _CacheList.Remove(checkInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<CheckInfo>> _CacheByPrimaryKey = new Dictionary<string, List<CheckInfo>>(); private static Dictionary<string, List<CheckInfo>> _CacheByPrimaryKey = new Dictionary<string, List<CheckInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move CheckInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move CheckInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
CheckInfo tmp = _CacheList[0]; // Get the first CheckInfo CheckInfo tmp = _CacheList[0]; // Get the first CheckInfo
string pKey = tmp.CheckID.ToString(); string pKey = tmp.CheckID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<CheckInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<CheckInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first CheckInfo _CacheList.RemoveAt(0); // Remove the first CheckInfo
} }
} }
internal static void AddList(CheckInfoList lst) internal static void AddList(CheckInfoList lst)
{ {
foreach (CheckInfo item in lst) AddToCache(item); foreach (CheckInfo item in lst) AddToCache(item);
} }
protected static CheckInfo GetCachedByPrimaryKey(int checkID) protected static CheckInfo GetCachedByPrimaryKey(int checkID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = checkID.ToString(); string key = checkID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Check _Editable; protected Check _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _CheckID; private int _CheckID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int CheckID public int CheckID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _CheckID; CanReadProperty("CheckID", true);
} return _CheckID;
} }
private int _RevisionID; }
public int RevisionID private int _RevisionID;
{ public int RevisionID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyRevision != null) _RevisionID = _MyRevision.RevisionID; {
return _RevisionID; CanReadProperty("RevisionID", true);
} if (_MyRevision != null) _RevisionID = _MyRevision.RevisionID;
} return _RevisionID;
private RevisionInfo _MyRevision; }
public RevisionInfo MyRevision }
{ private RevisionInfo _MyRevision;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public RevisionInfo MyRevision
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyRevision == null && _RevisionID != 0) _MyRevision = RevisionInfo.Get(_RevisionID); get
return _MyRevision; {
} CanReadProperty("MyRevision", true);
} if (_MyRevision == null && _RevisionID != 0) _MyRevision = RevisionInfo.Get(_RevisionID);
private int _StageID; return _MyRevision;
public int StageID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _StageID;
get public int StageID
{ {
if (_MyStage != null) _StageID = _MyStage.StageID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _StageID; get
} {
} CanReadProperty("StageID", true);
private StageInfo _MyStage; if (_MyStage != null) _StageID = _MyStage.StageID;
public StageInfo MyStage return _StageID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private StageInfo _MyStage;
{ public StageInfo MyStage
if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.GetJustStage(_StageID); {
return _MyStage; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _ConsistencyChecks = string.Empty; CanReadProperty("MyStage", true);
public string ConsistencyChecks if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.GetJustStage(_StageID);
{ return _MyStage;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _ConsistencyChecks = string.Empty;
return _ConsistencyChecks; public string ConsistencyChecks
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("ConsistencyChecks", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _ConsistencyChecks;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
// CSLATODO: Replace base CheckInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current CheckInfo</returns> CanReadProperty("UserID", true);
//public override string ToString() return _UserID;
//{ }
// return base.ToString(); }
//} // CSLATODO: Replace base CheckInfo.ToString function as necessary
// CSLATODO: Check CheckInfo.GetIdValue to assure that the ID returned is unique /// <summary>
/// <summary> /// Overrides Base ToString
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// </summary>
/// </summary> /// <returns>A string representation of current CheckInfo</returns>
/// <returns>A Unique ID for the current CheckInfo</returns> //public override string ToString()
protected override object GetIdValue() //{
{ // return base.ToString();
return MyCheckInfoUnique; // Absolutely Unique ID //}
} // CSLATODO: Check CheckInfo.GetIdValue to assure that the ID returned is unique
#endregion /// <summary>
#region Factory Methods /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int _CheckInfoUnique = 0; /// </summary>
private static int CheckInfoUnique /// <returns>A Unique ID for the current CheckInfo</returns>
{ get { return ++_CheckInfoUnique; } } protected override object GetIdValue()
private int _MyCheckInfoUnique = CheckInfoUnique; {
public int MyCheckInfoUnique // Absolutely Unique ID - Info return MyCheckInfoUnique; // Absolutely Unique ID
{ get { return _MyCheckInfoUnique; } } }
protected CheckInfo() #endregion
{/* require use of factory methods */ #region Factory Methods
AddToCache(this); private static int _CheckInfoUnique = 0;
} private static int CheckInfoUnique
private bool _Disposed = false; { get { return ++_CheckInfoUnique; } }
private static int _CountCreated = 0; private int _MyCheckInfoUnique = CheckInfoUnique;
private static int _CountDisposed = 0; public int MyCheckInfoUnique // Absolutely Unique ID - Info
private static int _CountFinalized = 0; { get { return _MyCheckInfoUnique; } }
private static int IncrementCountCreated protected CheckInfo()
{ get { return ++_CountCreated; } } {/* require use of factory methods */
private int _CountWhenCreated = IncrementCountCreated; AddToCache(this);
public static int CountCreated }
{ get { return _CountCreated; } } private bool _Disposed = false;
public static int CountNotDisposed private static int _CountCreated = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountDisposed = 0;
public static int CountNotFinalized private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int IncrementCountCreated
~CheckInfo() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
_CountFinalized++; public static int CountCreated
} { get { return _CountCreated; } }
public void Dispose() public static int CountNotDisposed
{ { get { return _CountCreated - _CountDisposed; } }
if (_Disposed) return; public static int CountNotFinalized
_CountDisposed++; { get { return _CountCreated - _CountFinalized; } }
_Disposed = true; ~CheckInfo()
RemoveFromCache(this); {
if (!_CacheByPrimaryKey.ContainsKey(CheckID.ToString())) return; _CountFinalized++;
List<CheckInfo> listCheckInfo = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items }
while (listCheckInfo.Contains(this)) listCheckInfo.Remove(this); // Remove the item from the list public void Dispose()
if (listCheckInfo.Count == 0) // If there are no items left in the list {
_CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list if (_Disposed) return;
} _CountDisposed++;
public virtual Check Get() _Disposed = true;
{ RemoveFromCache(this);
return _Editable = Check.Get(_CheckID); if (!_CacheByPrimaryKey.ContainsKey(CheckID.ToString())) return;
} List<CheckInfo> listCheckInfo = _CacheByPrimaryKey[CheckID.ToString()]; // Get the list of items
public static void Refresh(Check tmp) while (listCheckInfo.Contains(this)) listCheckInfo.Remove(this); // Remove the item from the list
{ if (listCheckInfo.Count == 0) // If there are no items left in the list
string key = tmp.CheckID.ToString(); _CacheByPrimaryKey.Remove(CheckID.ToString()); // remove the list
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) public virtual Check Get()
foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key]) {
tmpInfo.RefreshFields(tmp); return _Editable = Check.Get(_CheckID);
} }
protected virtual void RefreshFields(Check tmp) public static void Refresh(Check tmp)
{ {
if (_RevisionID != tmp.RevisionID) string key = tmp.CheckID.ToString();
{ ConvertListToDictionary();
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_RevisionID = tmp.RevisionID; // Update the value foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyRevision = null; // Reset list so that the next line gets a new list }
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for new value protected virtual void RefreshFields(Check tmp)
if (_StageID != tmp.StageID) {
{ if (_RevisionID != tmp.RevisionID)
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for old value {
_StageID = tmp.StageID; // Update the value if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for old value
} _RevisionID = tmp.RevisionID; // Update the value
_MyStage = null; // Reset list so that the next line gets a new list }
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for new value _MyRevision = null; // Reset list so that the next line gets a new list
_ConsistencyChecks = tmp.ConsistencyChecks; if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for new value
_DTS = tmp.DTS; if (_StageID != tmp.StageID)
_UserID = tmp.UserID; {
_CheckInfoExtension.Refresh(this); if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for old value
OnChange();// raise an event _StageID = tmp.StageID; // Update the value
} }
public static void Refresh(RevisionCheck tmp) _MyStage = null; // Reset list so that the next line gets a new list
{ if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for new value
string key = tmp.CheckID.ToString(); _ConsistencyChecks = tmp.ConsistencyChecks;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key]) _CheckInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(RevisionCheck tmp) public static void Refresh(RevisionCheck tmp)
{ {
if (_StageID != tmp.StageID) string key = tmp.CheckID.ToString();
{ ConvertListToDictionary();
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_StageID = tmp.StageID; // Update the value foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyStage = null; // Reset list so that the next line gets a new list }
if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for new value protected virtual void RefreshFields(RevisionCheck tmp)
_ConsistencyChecks = tmp.ConsistencyChecks; {
_DTS = tmp.DTS; if (_StageID != tmp.StageID)
_UserID = tmp.UserID; {
_CheckInfoExtension.Refresh(this); if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for old value
OnChange();// raise an event _StageID = tmp.StageID; // Update the value
} }
public static void Refresh(StageCheck tmp) _MyStage = null; // Reset list so that the next line gets a new list
{ if (MyStage != null) MyStage.RefreshStageChecks(); // Update List for new value
string key = tmp.CheckID.ToString(); _ConsistencyChecks = tmp.ConsistencyChecks;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key]) _CheckInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(StageCheck tmp) public static void Refresh(StageCheck tmp)
{ {
if (_RevisionID != tmp.RevisionID) string key = tmp.CheckID.ToString();
{ ConvertListToDictionary();
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_RevisionID = tmp.RevisionID; // Update the value foreach (CheckInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyRevision = null; // Reset list so that the next line gets a new list }
if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for new value protected virtual void RefreshFields(StageCheck tmp)
_ConsistencyChecks = tmp.ConsistencyChecks; {
_DTS = tmp.DTS; if (_RevisionID != tmp.RevisionID)
_UserID = tmp.UserID; {
_CheckInfoExtension.Refresh(this); if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for old value
OnChange();// raise an event _RevisionID = tmp.RevisionID; // Update the value
} }
public static CheckInfo Get(int checkID) _MyRevision = null; // Reset list so that the next line gets a new list
{ if (MyRevision != null) MyRevision.RefreshRevisionChecks(); // Update List for new value
//if (!CanGetObject()) _ConsistencyChecks = tmp.ConsistencyChecks;
// throw new System.Security.SecurityException("User not authorized to view a Check"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _CheckInfoExtension.Refresh(this);
CheckInfo tmp = GetCachedByPrimaryKey(checkID); OnChange();// raise an event
if (tmp == null) }
{ public static CheckInfo Get(int checkID)
tmp = DataPortal.Fetch<CheckInfo>(new PKCriteria(checkID)); {
AddToCache(tmp); //if (!CanGetObject())
} // throw new System.Security.SecurityException("User not authorized to view a Check");
if (tmp.ErrorMessage == "No Record Found") try
{ {
tmp.Dispose(); // Clean-up CheckInfo CheckInfo tmp = GetCachedByPrimaryKey(checkID);
tmp = null; if (tmp == null)
} {
return tmp; tmp = DataPortal.Fetch<CheckInfo>(new PKCriteria(checkID));
} AddToCache(tmp);
catch (Exception ex) }
{ if (tmp.ErrorMessage == "No Record Found")
throw new DbCslaException("Error on CheckInfo.Get", ex); {
} tmp.Dispose(); // Clean-up CheckInfo
} tmp = null;
#endregion }
#region Data Access Portal return tmp;
internal CheckInfo(SafeDataReader dr) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.Constructor", GetHashCode()); {
try throw new DbCslaException("Error on CheckInfo.Get", ex);
{ }
ReadData(dr); }
} #endregion
catch (Exception ex) #region Data Access Portal
{ internal CheckInfo(SafeDataReader dr)
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.Constructor", ex); {
throw new DbCslaException("CheckInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.Constructor", GetHashCode());
} try
} {
[Serializable()] ReadData(dr);
protected class PKCriteria }
{ catch (Exception ex)
private int _CheckID; {
public int CheckID if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.Constructor", ex);
{ get { return _CheckID; } } throw new DbCslaException("CheckInfo.Constructor", ex);
public PKCriteria(int checkID) }
{ }
_CheckID = checkID; [Serializable()]
} protected class PKCriteria
} {
private void ReadData(SafeDataReader dr) private int _CheckID;
{ public int CheckID
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.ReadData", GetHashCode()); { get { return _CheckID; } }
try public PKCriteria(int checkID)
{ {
_CheckID = dr.GetInt32("CheckID"); _CheckID = checkID;
_RevisionID = dr.GetInt32("RevisionID"); }
_StageID = dr.GetInt32("StageID"); }
_ConsistencyChecks = dr.GetString("ConsistencyChecks"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.ReadData", GetHashCode());
} try
catch (Exception ex) {
{ _CheckID = dr.GetInt32("CheckID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.ReadData", ex); _RevisionID = dr.GetInt32("RevisionID");
_ErrorMessage = ex.Message; _StageID = dr.GetInt32("StageID");
throw new DbCslaException("CheckInfo.ReadData", ex); _ConsistencyChecks = dr.GetString("ConsistencyChecks");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.DataPortal_Fetch", GetHashCode()); {
try if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
using (SqlConnection cn = Database.VEPROMS_SqlConnection) throw new DbCslaException("CheckInfo.ReadData", ex);
{ }
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) private void DataPortal_Fetch(PKCriteria criteria)
{ {
cm.CommandType = CommandType.StoredProcedure; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CheckInfo.DataPortal_Fetch", GetHashCode());
cm.CommandText = "getCheck"; try
cm.Parameters.AddWithValue("@CheckID", criteria.CheckID); {
cm.CommandTimeout = Database.DefaultTimeout; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ ApplicationContext.LocalContext["cn"] = cn;
if (!dr.Read()) using (SqlCommand cm = cn.CreateCommand())
{ {
_ErrorMessage = "No Record Found"; cm.CommandType = CommandType.StoredProcedure;
return; cm.CommandText = "getCheck";
} cm.Parameters.AddWithValue("@CheckID", criteria.CheckID);
ReadData(dr); cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
// removing of item only needed for local data portal if (!dr.Read())
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); _ErrorMessage = "No Record Found";
} return;
} }
catch (Exception ex) ReadData(dr);
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; // removing of item only needed for local data portal
throw new DbCslaException("CheckInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
} }
#endregion }
// Standard Refresh catch (Exception ex)
#region extension {
CheckInfoExtension _CheckInfoExtension = new CheckInfoExtension(); if (_MyLog.IsErrorEnabled) _MyLog.Error("CheckInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
partial class CheckInfoExtension : extensionBase { } throw new DbCslaException("CheckInfo.DataPortal_Fetch", ex);
[Serializable()] }
class extensionBase }
{ #endregion
// Default Refresh // Standard Refresh
public virtual void Refresh(CheckInfo tmp) { } #region extension
} CheckInfoExtension _CheckInfoExtension = new CheckInfoExtension();
#endregion [Serializable()]
} // Class partial class CheckInfoExtension : extensionBase { }
#region Converter [Serializable()]
internal class CheckInfoConverter : ExpandableObjectConverter class extensionBase
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) // Default Refresh
{ public virtual void Refresh(CheckInfo tmp) { }
if (destType == typeof(string) && value is CheckInfo) }
{ #endregion
// Return the ToString value } // Class
return ((CheckInfo)value).ToString(); #region Converter
} internal class CheckInfoConverter : ExpandableObjectConverter
return base.ConvertTo(context, culture, value, destType); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
#endregion if (destType == typeof(string) && value is CheckInfo)
{
// Return the ToString value
return ((CheckInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,405 +19,415 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ConnectionInfoEvent(object sender); public delegate void ConnectionInfoEvent(object sender);
/// <summary> /// <summary>
/// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template /// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ConnectionInfoConverter))] [TypeConverter(typeof(ConnectionInfoConverter))]
public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>, IDisposable public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>, IDisposable
{ {
public event ConnectionInfoEvent Changed; public event ConnectionInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<ConnectionInfo> _CacheList = new List<ConnectionInfo>(); private static List<ConnectionInfo> _CacheList = new List<ConnectionInfo>();
protected static void AddToCache(ConnectionInfo connectionInfo) protected static void AddToCache(ConnectionInfo connectionInfo)
{ {
if (!_CacheList.Contains(connectionInfo)) _CacheList.Add(connectionInfo); // In AddToCache if (!_CacheList.Contains(connectionInfo)) _CacheList.Add(connectionInfo); // In AddToCache
} }
protected static void RemoveFromCache(ConnectionInfo connectionInfo) protected static void RemoveFromCache(ConnectionInfo connectionInfo)
{ {
while (_CacheList.Contains(connectionInfo)) _CacheList.Remove(connectionInfo); // In RemoveFromCache while (_CacheList.Contains(connectionInfo)) _CacheList.Remove(connectionInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<ConnectionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ConnectionInfo>>(); private static Dictionary<string, List<ConnectionInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ConnectionInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move ConnectionInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move ConnectionInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
ConnectionInfo tmp = _CacheList[0]; // Get the first ConnectionInfo ConnectionInfo tmp = _CacheList[0]; // Get the first ConnectionInfo
string pKey = tmp.DBID.ToString(); string pKey = tmp.DBID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<ConnectionInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<ConnectionInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ConnectionInfo _CacheList.RemoveAt(0); // Remove the first ConnectionInfo
} }
} }
internal static void AddList(ConnectionInfoList lst) internal static void AddList(ConnectionInfoList lst)
{ {
foreach (ConnectionInfo item in lst) AddToCache(item); foreach (ConnectionInfo item in lst) AddToCache(item);
} }
protected static ConnectionInfo GetCachedByPrimaryKey(int dbid) protected static ConnectionInfo GetCachedByPrimaryKey(int dbid)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = dbid.ToString(); string key = dbid.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Connection _Editable; protected Connection _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _DBID; private int _DBID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DBID public int DBID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _DBID; CanReadProperty("DBID", true);
} return _DBID;
} }
private string _Name = string.Empty; }
public string Name private string _Name = string.Empty;
{ public string Name
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _Name; {
} CanReadProperty("Name", true);
} return _Name;
private string _Title = string.Empty; }
public string Title }
{ private string _Title = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Title
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Title; get
} {
} CanReadProperty("Title", true);
private string _ConnectionString = string.Empty; return _Title;
public string ConnectionString }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _ConnectionString = string.Empty;
get public string ConnectionString
{ {
return _ConnectionString; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private int _ServerType; CanReadProperty("ConnectionString", true);
/// <summary> return _ConnectionString;
/// 0 SQL Server }
/// </summary> }
public int ServerType private int _ServerType;
{ /// <summary>
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] /// 0 SQL Server
get /// </summary>
{ public int ServerType
return _ServerType; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _Config = string.Empty; {
public string Config CanReadProperty("ServerType", true);
{ return _ServerType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UsrID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UsrID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UsrID; }
} private string _UsrID = string.Empty;
} public string UsrID
private int _ConnectionFolderCount = 0; {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Count of ConnectionFolders for this Connection get
/// </summary> {
public int ConnectionFolderCount CanReadProperty("UsrID", true);
{ return _UsrID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int _ConnectionFolderCount = 0;
if (_ConnectionFolderCount < 0) /// <summary>
_ConnectionFolderCount = ConnectionFolders.Count; /// Count of ConnectionFolders for this Connection
return _ConnectionFolderCount; /// </summary>
} public int ConnectionFolderCount
} {
private FolderInfoList _ConnectionFolders = null; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[TypeConverter(typeof(FolderInfoListConverter))] get
public FolderInfoList ConnectionFolders {
{ CanReadProperty("ConnectionFolderCount", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_ConnectionFolderCount < 0)
get _ConnectionFolderCount = ConnectionFolders.Count;
{ return _ConnectionFolderCount;
if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null)) }
_ConnectionFolders = FolderInfoList.GetByDBID(_DBID); }
if (_ConnectionFolderCount < 0) private FolderInfoList _ConnectionFolders = null;
_ConnectionFolderCount = _ConnectionFolders.Count; [TypeConverter(typeof(FolderInfoListConverter))]
return _ConnectionFolders; public FolderInfoList ConnectionFolders
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void RefreshConnectionFolders() get
{ {
_ConnectionFolderCount = -1; CanReadProperty("ConnectionFolders", true);
ConvertListToDictionary(); if (_ConnectionFolderCount < 0 || (_ConnectionFolderCount > 0 && _ConnectionFolders == null))
if (_CacheByPrimaryKey.ContainsKey(_DBID.ToString())) _ConnectionFolders = FolderInfoList.GetByDBID(_DBID);
foreach (ConnectionInfo tmp in _CacheByPrimaryKey[_DBID.ToString()]) if (_ConnectionFolderCount < 0)
tmp._ConnectionFolderCount = -1; // This will cause the data to be requeried _ConnectionFolderCount = _ConnectionFolders.Count;
} return _ConnectionFolders;
// CSLATODO: Replace base ConnectionInfo.ToString function as necessary }
/// <summary> }
/// Overrides Base ToString public void RefreshConnectionFolders()
/// </summary> {
/// <returns>A string representation of current ConnectionInfo</returns> _ConnectionFolderCount = -1;
//public override string ToString() ConvertListToDictionary();
//{ if (_CacheByPrimaryKey.ContainsKey(_DBID.ToString()))
// return base.ToString(); foreach (ConnectionInfo tmp in _CacheByPrimaryKey[_DBID.ToString()])
//} tmp._ConnectionFolderCount = -1; // This will cause the data to be requeried
// CSLATODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base ConnectionInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current ConnectionInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current ConnectionInfo</returns>
{ //public override string ToString()
return MyConnectionInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique
private static int _ConnectionInfoUnique = 0; /// <summary>
private static int ConnectionInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_ConnectionInfoUnique; } } /// </summary>
private int _MyConnectionInfoUnique = ConnectionInfoUnique; /// <returns>A Unique ID for the current ConnectionInfo</returns>
public int MyConnectionInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyConnectionInfoUnique; } } {
protected ConnectionInfo() return MyConnectionInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
private bool _Disposed = false; private static int _ConnectionInfoUnique = 0;
private static int _CountCreated = 0; private static int ConnectionInfoUnique
private static int _CountDisposed = 0; { get { return ++_ConnectionInfoUnique; } }
private static int _CountFinalized = 0; private int _MyConnectionInfoUnique = ConnectionInfoUnique;
private static int IncrementCountCreated public int MyConnectionInfoUnique // Absolutely Unique ID - Info
{ get { return ++_CountCreated; } } { get { return _MyConnectionInfoUnique; } }
private int _CountWhenCreated = IncrementCountCreated; protected ConnectionInfo()
public static int CountCreated {/* require use of factory methods */
{ get { return _CountCreated; } } AddToCache(this);
public static int CountNotDisposed }
{ get { return _CountCreated - _CountDisposed; } } private bool _Disposed = false;
public static int CountNotFinalized private static int _CountCreated = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountDisposed = 0;
~ConnectionInfo() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
_CountFinalized++; { get { return ++_CountCreated; } }
} private int _CountWhenCreated = IncrementCountCreated;
public void Dispose() public static int CountCreated
{ { get { return _CountCreated; } }
if (_Disposed) return; public static int CountNotDisposed
_CountDisposed++; { get { return _CountCreated - _CountDisposed; } }
_Disposed = true; public static int CountNotFinalized
RemoveFromCache(this); { get { return _CountCreated - _CountFinalized; } }
if (!_CacheByPrimaryKey.ContainsKey(DBID.ToString())) return; ~ConnectionInfo()
List<ConnectionInfo> listConnectionInfo = _CacheByPrimaryKey[DBID.ToString()]; // Get the list of items {
while (listConnectionInfo.Contains(this)) listConnectionInfo.Remove(this); // Remove the item from the list _CountFinalized++;
if (listConnectionInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(DBID.ToString()); // remove the list public void Dispose()
} {
public virtual Connection Get() if (_Disposed) return;
{ _CountDisposed++;
return _Editable = Connection.Get(_DBID); _Disposed = true;
} RemoveFromCache(this);
public static void Refresh(Connection tmp) if (!_CacheByPrimaryKey.ContainsKey(DBID.ToString())) return;
{ List<ConnectionInfo> listConnectionInfo = _CacheByPrimaryKey[DBID.ToString()]; // Get the list of items
string key = tmp.DBID.ToString(); while (listConnectionInfo.Contains(this)) listConnectionInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listConnectionInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(DBID.ToString()); // remove the list
foreach (ConnectionInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual Connection Get()
} {
protected virtual void RefreshFields(Connection tmp) return _Editable = Connection.Get(_DBID);
{ }
_Name = tmp.Name; public static void Refresh(Connection tmp)
_Title = tmp.Title; {
_ConnectionString = tmp.ConnectionString; string key = tmp.DBID.ToString();
_ServerType = tmp.ServerType; ConvertListToDictionary();
_Config = tmp.Config; if (_CacheByPrimaryKey.ContainsKey(key))
_DTS = tmp.DTS; foreach (ConnectionInfo tmpInfo in _CacheByPrimaryKey[key])
_UsrID = tmp.UsrID; tmpInfo.RefreshFields(tmp);
_ConnectionInfoExtension.Refresh(this); }
OnChange();// raise an event protected virtual void RefreshFields(Connection tmp)
} {
public static ConnectionInfo Get(int dbid) _Name = tmp.Name;
{ _Title = tmp.Title;
//if (!CanGetObject()) _ConnectionString = tmp.ConnectionString;
// throw new System.Security.SecurityException("User not authorized to view a Connection"); _ServerType = tmp.ServerType;
try _Config = tmp.Config;
{ _DTS = tmp.DTS;
ConnectionInfo tmp = GetCachedByPrimaryKey(dbid); _UsrID = tmp.UsrID;
if (tmp == null) _ConnectionInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid)); }
AddToCache(tmp); public static ConnectionInfo Get(int dbid)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a Connection");
tmp.Dispose(); // Clean-up ConnectionInfo try
tmp = null; {
} ConnectionInfo tmp = GetCachedByPrimaryKey(dbid);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<ConnectionInfo>(new PKCriteria(dbid));
{ AddToCache(tmp);
throw new DbCslaException("Error on ConnectionInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up ConnectionInfo
#region Data Access Portal tmp = null;
internal ConnectionInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on ConnectionInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("ConnectionInfo.Constructor", ex); internal ConnectionInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private int _DBID; }
public int DBID catch (Exception ex)
{ get { return _DBID; } } {
public PKCriteria(int dbid) if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.Constructor", ex);
{ throw new DbCslaException("ConnectionInfo.Constructor", ex);
_DBID = dbid; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode()); private int _DBID;
try public int DBID
{ { get { return _DBID; } }
_DBID = dr.GetInt32("DBID"); public PKCriteria(int dbid)
_Name = dr.GetString("Name"); {
_Title = dr.GetString("Title"); _DBID = dbid;
_ConnectionString = dr.GetString("ConnectionString"); }
_ServerType = dr.GetInt32("ServerType"); }
_Config = dr.GetString("Config"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UsrID = dr.GetString("UsrID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.ReadData", GetHashCode());
_ConnectionFolderCount = dr.GetInt32("FolderCount"); try
} {
catch (Exception ex) _DBID = dr.GetInt32("DBID");
{ _Name = dr.GetString("Name");
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex); _Title = dr.GetString("Title");
_ErrorMessage = ex.Message; _ConnectionString = dr.GetString("ConnectionString");
throw new DbCslaException("ConnectionInfo.ReadData", ex); _ServerType = dr.GetInt32("ServerType");
} _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
private void DataPortal_Fetch(PKCriteria criteria) _UsrID = dr.GetString("UsrID");
{ _ConnectionFolderCount = dr.GetInt32("FolderCount");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("ConnectionInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getConnection"; {
cm.Parameters.AddWithValue("@DBID", criteria.DBID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ConnectionInfo.DataPortal_Fetch", GetHashCode());
cm.CommandTimeout = Database.DefaultTimeout; try
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
if (!dr.Read()) {
{ ApplicationContext.LocalContext["cn"] = cn;
_ErrorMessage = "No Record Found"; using (SqlCommand cm = cn.CreateCommand())
return; {
} cm.CommandType = CommandType.StoredProcedure;
ReadData(dr); cm.CommandText = "getConnection";
} cm.Parameters.AddWithValue("@DBID", criteria.DBID);
} cm.CommandTimeout = Database.DefaultTimeout;
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class ConnectionInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("ConnectionInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("ConnectionInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(ConnectionInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class ConnectionInfoExtension _ConnectionInfoExtension = new ConnectionInfoExtension();
#region Converter [Serializable()]
internal class ConnectionInfoConverter : ExpandableObjectConverter partial class ConnectionInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is ConnectionInfo) // Default Refresh
{ public virtual void Refresh(ConnectionInfo tmp) { }
// Return the ToString value }
return ((ConnectionInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class ConnectionInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ConnectionInfo)
{
// Return the ToString value
return ((ConnectionInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,387 +19,397 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ContentAuditInfoEvent(object sender); public delegate void ContentAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// ContentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// ContentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ContentAuditInfoConverter))] [TypeConverter(typeof(ContentAuditInfoConverter))]
public partial class ContentAuditInfo : ReadOnlyBase<ContentAuditInfo>, IDisposable public partial class ContentAuditInfo : ReadOnlyBase<ContentAuditInfo>, IDisposable
{ {
public event ContentAuditInfoEvent Changed; public event ContentAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<ContentAuditInfo> _CacheList = new List<ContentAuditInfo>(); private static List<ContentAuditInfo> _CacheList = new List<ContentAuditInfo>();
protected static void AddToCache(ContentAuditInfo contentAuditInfo) protected static void AddToCache(ContentAuditInfo contentAuditInfo)
{ {
if (!_CacheList.Contains(contentAuditInfo)) _CacheList.Add(contentAuditInfo); // In AddToCache if (!_CacheList.Contains(contentAuditInfo)) _CacheList.Add(contentAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(ContentAuditInfo contentAuditInfo) protected static void RemoveFromCache(ContentAuditInfo contentAuditInfo)
{ {
while (_CacheList.Contains(contentAuditInfo)) _CacheList.Remove(contentAuditInfo); // In RemoveFromCache while (_CacheList.Contains(contentAuditInfo)) _CacheList.Remove(contentAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<ContentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentAuditInfo>>(); private static Dictionary<string, List<ContentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move ContentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move ContentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
ContentAuditInfo tmp = _CacheList[0]; // Get the first ContentAuditInfo ContentAuditInfo tmp = _CacheList[0]; // Get the first ContentAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<ContentAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<ContentAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ContentAuditInfo _CacheList.RemoveAt(0); // Remove the first ContentAuditInfo
} }
} }
internal static void AddList(ContentAuditInfoList lst) internal static void AddList(ContentAuditInfoList lst)
{ {
foreach (ContentAuditInfo item in lst) AddToCache(item); foreach (ContentAuditInfo item in lst) AddToCache(item);
} }
protected static ContentAuditInfo GetCachedByPrimaryKey(long auditID) protected static ContentAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected ContentAudit _Editable; protected ContentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ContentID; {
} CanReadProperty("ContentID", true);
} return _ContentID;
private string _Number = string.Empty; }
public string Number }
{ private string _Number = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Number
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Number; get
} {
} CanReadProperty("Number", true);
private string _Text = string.Empty; return _Number;
public string Text }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Text = string.Empty;
get public string Text
{ {
return _Text; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private int? _Type; CanReadProperty("Text", true);
public int? Type return _Text;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private int? _Type;
{ public int? Type
return _Type; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private int? _FormatID; {
public int? FormatID CanReadProperty("Type", true);
{ return _Type;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int? _FormatID;
return _FormatID; public int? FormatID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _Config = string.Empty; get
public string Config {
{ CanReadProperty("FormatID", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _FormatID;
get }
{ }
return _Config; private string _Config = string.Empty;
} public string Config
} {
private DateTime _DTS = new DateTime(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public DateTime DTS get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("Config", true);
get return _Config;
{ }
return _DTS; }
} private DateTime _DTS = new DateTime();
} public DateTime DTS
private string _UserID = string.Empty; {
public string UserID [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("DTS", true);
{ return _DTS;
return _UserID; }
} }
} private string _UserID = string.Empty;
private int _DeleteStatus; public string UserID
public int DeleteStatus {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("UserID", true);
return _DeleteStatus; return _UserID;
} }
} }
// CSLATODO: Replace base ContentAuditInfo.ToString function as necessary private int _DeleteStatus;
/// <summary> public int DeleteStatus
/// Overrides Base ToString {
/// </summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <returns>A string representation of current ContentAuditInfo</returns> get
//public override string ToString() {
//{ CanReadProperty("DeleteStatus", true);
// return base.ToString(); return _DeleteStatus;
//} }
// CSLATODO: Check ContentAuditInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base ContentAuditInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current ContentAuditInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current ContentAuditInfo</returns>
{ //public override string ToString()
return MyContentAuditInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check ContentAuditInfo.GetIdValue to assure that the ID returned is unique
private static int _ContentAuditInfoUnique = 0; /// <summary>
private static int ContentAuditInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_ContentAuditInfoUnique; } } /// </summary>
private int _MyContentAuditInfoUnique = ContentAuditInfoUnique; /// <returns>A Unique ID for the current ContentAuditInfo</returns>
public int MyContentAuditInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyContentAuditInfoUnique; } } {
protected ContentAuditInfo() return MyContentAuditInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
private bool _Disposed = false; private static int _ContentAuditInfoUnique = 0;
private static int _CountCreated = 0; private static int ContentAuditInfoUnique
private static int _CountDisposed = 0; { get { return ++_ContentAuditInfoUnique; } }
private static int _CountFinalized = 0; private int _MyContentAuditInfoUnique = ContentAuditInfoUnique;
private static int IncrementCountCreated public int MyContentAuditInfoUnique // Absolutely Unique ID - Info
{ get { return ++_CountCreated; } } { get { return _MyContentAuditInfoUnique; } }
private int _CountWhenCreated = IncrementCountCreated; protected ContentAuditInfo()
public static int CountCreated {/* require use of factory methods */
{ get { return _CountCreated; } } AddToCache(this);
public static int CountNotDisposed }
{ get { return _CountCreated - _CountDisposed; } } private bool _Disposed = false;
public static int CountNotFinalized private static int _CountCreated = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountDisposed = 0;
~ContentAuditInfo() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
_CountFinalized++; { get { return ++_CountCreated; } }
} private int _CountWhenCreated = IncrementCountCreated;
public void Dispose() public static int CountCreated
{ { get { return _CountCreated; } }
if (_Disposed) return; public static int CountNotDisposed
_CountDisposed++; { get { return _CountCreated - _CountDisposed; } }
_Disposed = true; public static int CountNotFinalized
RemoveFromCache(this); { get { return _CountCreated - _CountFinalized; } }
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; ~ContentAuditInfo()
List<ContentAuditInfo> listContentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items {
while (listContentAuditInfo.Contains(this)) listContentAuditInfo.Remove(this); // Remove the item from the list _CountFinalized++;
if (listContentAuditInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list public void Dispose()
} {
public virtual ContentAudit Get() if (_Disposed) return;
{ _CountDisposed++;
return _Editable = ContentAudit.Get(_AuditID); _Disposed = true;
} RemoveFromCache(this);
public static void Refresh(ContentAudit tmp) if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
{ List<ContentAuditInfo> listContentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
string key = tmp.AuditID.ToString(); while (listContentAuditInfo.Contains(this)) listContentAuditInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listContentAuditInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
foreach (ContentAuditInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual ContentAudit Get()
} {
protected virtual void RefreshFields(ContentAudit tmp) return _Editable = ContentAudit.Get(_AuditID);
{ }
_ContentID = tmp.ContentID; public static void Refresh(ContentAudit tmp)
_Number = tmp.Number; {
_Text = tmp.Text; string key = tmp.AuditID.ToString();
_Type = tmp.Type; ConvertListToDictionary();
_FormatID = tmp.FormatID; if (_CacheByPrimaryKey.ContainsKey(key))
_Config = tmp.Config; foreach (ContentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(ContentAudit tmp)
_ContentAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ContentID = tmp.ContentID;
} _Number = tmp.Number;
public static ContentAuditInfo Get(long auditID) _Text = tmp.Text;
{ _Type = tmp.Type;
//if (!CanGetObject()) _FormatID = tmp.FormatID;
// throw new System.Security.SecurityException("User not authorized to view a ContentAudit"); _Config = tmp.Config;
try _DTS = tmp.DTS;
{ _UserID = tmp.UserID;
ContentAuditInfo tmp = GetCachedByPrimaryKey(auditID); _DeleteStatus = tmp.DeleteStatus;
if (tmp == null) _ContentAuditInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<ContentAuditInfo>(new PKCriteria(auditID)); }
AddToCache(tmp); public static ContentAuditInfo Get(long auditID)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a ContentAudit");
tmp.Dispose(); // Clean-up ContentAuditInfo try
tmp = null; {
} ContentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<ContentAuditInfo>(new PKCriteria(auditID));
{ AddToCache(tmp);
throw new DbCslaException("Error on ContentAuditInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up ContentAuditInfo
#region Data Access Portal tmp = null;
internal ContentAuditInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on ContentAuditInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("ContentAuditInfo.Constructor", ex); internal ContentAuditInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private long _AuditID; }
public long AuditID catch (Exception ex)
{ get { return _AuditID; } } {
public PKCriteria(long auditID) if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.Constructor", ex);
{ throw new DbCslaException("ContentAuditInfo.Constructor", ex);
_AuditID = auditID; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.ReadData", GetHashCode()); private long _AuditID;
try public long AuditID
{ { get { return _AuditID; } }
_AuditID = dr.GetInt64("AuditID"); public PKCriteria(long auditID)
_ContentID = dr.GetInt32("ContentID"); {
_Number = dr.GetString("Number"); _AuditID = auditID;
_Text = dr.GetString("Text"); }
_Type = (int?)dr.GetValue("Type"); }
_FormatID = (int?)dr.GetValue("FormatID"); private void ReadData(SafeDataReader dr)
_Config = dr.GetString("Config"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _Number = dr.GetString("Number");
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.ReadData", ex); _Text = dr.GetString("Text");
_ErrorMessage = ex.Message; _Type = (int?)dr.GetValue("Type");
throw new DbCslaException("ContentAuditInfo.ReadData", ex); _FormatID = (int?)dr.GetValue("FormatID");
} _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
private void DataPortal_Fetch(PKCriteria criteria) _UserID = dr.GetString("UserID");
{ _DeleteStatus = dr.GetInt32("DeleteStatus");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("ContentAuditInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getContentAudit"; {
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.DataPortal_Fetch", GetHashCode());
cm.CommandTimeout = Database.DefaultTimeout; try
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
if (!dr.Read()) {
{ ApplicationContext.LocalContext["cn"] = cn;
_ErrorMessage = "No Record Found"; using (SqlCommand cm = cn.CreateCommand())
return; {
} cm.CommandType = CommandType.StoredProcedure;
ReadData(dr); cm.CommandText = "getContentAudit";
} cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
} cm.CommandTimeout = Database.DefaultTimeout;
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("ContentAuditInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
ContentAuditInfoExtension _ContentAuditInfoExtension = new ContentAuditInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class ContentAuditInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("ContentAuditInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(ContentAuditInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class ContentAuditInfoExtension _ContentAuditInfoExtension = new ContentAuditInfoExtension();
#region Converter [Serializable()]
internal class ContentAuditInfoConverter : ExpandableObjectConverter partial class ContentAuditInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is ContentAuditInfo) // Default Refresh
{ public virtual void Refresh(ContentAuditInfo tmp) { }
// Return the ToString value }
return ((ContentAuditInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class ContentAuditInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentAuditInfo)
{
// Return the ToString value
return ((ContentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -20,444 +20,456 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// ContentDetail Generated by MyGeneration using the CSLA Object Mapping template /// ContentDetail Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ContentDetailConverter))] [TypeConverter(typeof(ContentDetailConverter))]
public partial class ContentDetail : BusinessBase<ContentDetail>, IVEHasBrokenRules, IDisposable public partial class ContentDetail : BusinessBase<ContentDetail>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _DetailID; private int _DetailID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DetailID public int DetailID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyDetail != null) _DetailID = _MyDetail.DetailID; CanReadProperty("DetailID", true);
return _DetailID; if (_MyDetail != null) _DetailID = _MyDetail.DetailID;
} return _DetailID;
} }
private Detail _MyDetail; }
[System.ComponentModel.DataObjectField(true, true)] private Detail _MyDetail;
public Detail MyDetail [System.ComponentModel.DataObjectField(true, true)]
{ public Detail MyDetail
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID); {
return _MyDetail; CanReadProperty("MyDetail", true);
} if (_MyDetail == null && _DetailID != 0) _MyDetail = Detail.Get(_DetailID);
} return _MyDetail;
private int _ItemType; }
public int ItemType }
{ private int _ItemType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int ItemType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ItemType; get
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("ItemType", true);
set return _ItemType;
{ }
if (_ItemType != value) [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ set
_ItemType = value; {
PropertyHasChanged(); CanWriteProperty("ItemType", true);
} if (_ItemType != value)
} {
} _ItemType = value;
private string _Text = string.Empty; PropertyHasChanged();
public string Text }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _Text = string.Empty;
{ public string Text
return _Text; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
set {
{ CanReadProperty("Text", true);
if (value == null) value = string.Empty; return _Text;
if (_Text != value) }
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_Text = value; set
PropertyHasChanged(); {
} CanWriteProperty("Text", true);
} if (value == null) value = string.Empty;
} if (_Text != value)
private string _Config = string.Empty; {
public string Config _Text = value;
{ PropertyHasChanged();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ }
return _Config; private string _Config = string.Empty;
} public string Config
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
set [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (value == null) value = string.Empty; {
if (_Config != value) CanReadProperty("Config", true);
{ return _Config;
_Config = value; }
PropertyHasChanged(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
} {
} CanWriteProperty("Config", true);
private DateTime _DTS = new DateTime(); if (value == null) value = string.Empty;
public DateTime DTS if (_Config != value)
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] _Config = value;
get PropertyHasChanged();
{ }
return _DTS; }
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private DateTime _DTS = new DateTime();
set public DateTime DTS
{ {
if (_DTS != value) [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
_DTS = value; {
PropertyHasChanged(); CanReadProperty("DTS", true);
} return _DTS;
} }
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _UserID = string.Empty; set
public string UserID {
{ CanWriteProperty("DTS", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_DTS != value)
get {
{ _DTS = value;
return _UserID; PropertyHasChanged();
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
set }
{ private string _UserID = string.Empty;
if (value == null) value = string.Empty; public string UserID
if (_UserID != value) {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_UserID = value; get
PropertyHasChanged(); {
} CanReadProperty("UserID", true);
} return _UserID;
} }
private byte[] _LastChanged = new byte[8];//timestamp [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
// CSLATODO: Check ContentDetail.GetIdValue to assure that the ID returned is unique set
/// <summary> {
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality CanWriteProperty("UserID", true);
/// </summary> if (value == null) value = string.Empty;
/// <returns>A Unique ID for the current ContentDetail</returns> if (_UserID != value)
protected override object GetIdValue() {
{ _UserID = value;
return MyContentDetailUnique; // Absolutely Unique ID PropertyHasChanged();
} }
// CSLATODO: Replace base ContentDetail.ToString function as necessary }
/// <summary> }
/// Overrides Base ToString private byte[] _LastChanged = new byte[8];//timestamp
/// </summary> // CSLATODO: Check ContentDetail.GetIdValue to assure that the ID returned is unique
/// <returns>A string representation of current ContentDetail</returns> /// <summary>
//public override string ToString() /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
//{ /// </summary>
// return base.ToString(); /// <returns>A Unique ID for the current ContentDetail</returns>
//} protected override object GetIdValue()
public override bool IsDirty {
{ return MyContentDetailUnique; // Absolutely Unique ID
get { return base.IsDirty; } }
} // CSLATODO: Replace base ContentDetail.ToString function as necessary
public bool IsDirtyList(List<object> list) /// <summary>
{ /// Overrides Base ToString
return base.IsDirty; /// </summary>
} /// <returns>A string representation of current ContentDetail</returns>
public override bool IsValid //public override string ToString()
{ //{
get { return (IsNew && !IsDirty) ? true : base.IsValid; } // return base.ToString();
} //}
public bool IsValidList(List<object> list) public override bool IsDirty
{ {
return (IsNew && !IsDirty) ? true : base.IsValid; get { return base.IsDirty; }
} }
#endregion public bool IsDirtyList(List<object> list)
#region ValidationRules {
[NonSerialized] return base.IsDirty;
private bool _CheckingBrokenRules = false; }
public IVEHasBrokenRules HasBrokenRules public override bool IsValid
{ {
get get { return (IsNew && !IsDirty) ? true : base.IsValid; }
{ }
if (_CheckingBrokenRules) return null; public bool IsValidList(List<object> list)
if (BrokenRulesCollection.Count > 0) return this; {
try return (IsNew && !IsDirty) ? true : base.IsValid;
{ }
_CheckingBrokenRules = true; #endregion
IVEHasBrokenRules hasBrokenRules = null; #region ValidationRules
return hasBrokenRules; [NonSerialized]
} private bool _CheckingBrokenRules = false;
finally public IVEHasBrokenRules HasBrokenRules
{ {
_CheckingBrokenRules = false; get
} {
} if (_CheckingBrokenRules) return null;
} if (BrokenRulesCollection.Count > 0) return this;
public BrokenRulesCollection BrokenRules try
{ {
get _CheckingBrokenRules = true;
{ IVEHasBrokenRules hasBrokenRules = null;
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; return hasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; }
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); finally
} {
} _CheckingBrokenRules = false;
protected override void AddBusinessRules() }
{ }
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringRequired, "Text"); public BrokenRulesCollection BrokenRules
ValidationRules.AddRule( {
Csla.Validation.CommonRules.StringMaxLength, get
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823)); {
ValidationRules.AddRule( IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
Csla.Validation.CommonRules.StringMaxLength, if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringRequired, "UserID"); }
ValidationRules.AddRule( protected override void AddBusinessRules()
Csla.Validation.CommonRules.StringMaxLength, {
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); ValidationRules.AddRule(
// CSLATODO: Add other validation rules Csla.Validation.CommonRules.StringRequired, "Text");
} ValidationRules.AddRule(
// Sample data comparison validation rule Csla.Validation.CommonRules.StringMaxLength,
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
//{ ValidationRules.AddRule(
// if (_started > _ended) Csla.Validation.CommonRules.StringMaxLength,
// { new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
// e.Description = "Start date can't be after end date"; ValidationRules.AddRule(
// return false; Csla.Validation.CommonRules.StringRequired, "UserID");
// } ValidationRules.AddRule(
// else Csla.Validation.CommonRules.StringMaxLength,
// return true; new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
//} // CSLATODO: Add other validation rules
#endregion }
#region Authorization Rules // Sample data comparison validation rule
protected override void AddAuthorizationRules() //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
{ //{
//CSLATODO: Who can read/write which fields // if (_started > _ended)
//AuthorizationRules.AllowRead(DetailID, "<Role(s)>"); // {
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>"); // e.Description = "Start date can't be after end date";
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>"); // return false;
//AuthorizationRules.AllowRead(Text, "<Role(s)>"); // }
//AuthorizationRules.AllowWrite(Text, "<Role(s)>"); // else
//AuthorizationRules.AllowRead(Config, "<Role(s)>"); // return true;
//AuthorizationRules.AllowWrite(Config, "<Role(s)>"); //}
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); #endregion
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); #region Authorization Rules
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); protected override void AddAuthorizationRules()
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); {
} //CSLATODO: Who can read/write which fields
public static bool CanAddObject() //AuthorizationRules.AllowRead(DetailID, "<Role(s)>");
{ //AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
// CSLATODO: Can Add Authorization //AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); //AuthorizationRules.AllowRead(Text, "<Role(s)>");
return true; //AuthorizationRules.AllowWrite(Text, "<Role(s)>");
} //AuthorizationRules.AllowRead(Config, "<Role(s)>");
public static bool CanGetObject() //AuthorizationRules.AllowWrite(Config, "<Role(s)>");
{ //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
// CSLATODO: CanGet Authorization //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
return true; //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
} //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
public static bool CanDeleteObject() }
{ public static bool CanAddObject()
// CSLATODO: CanDelete Authorization {
//bool result = false; // CSLATODO: Can Add Authorization
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; return true;
//return result; }
return true; public static bool CanGetObject()
} {
public static bool CanEditObject() // CSLATODO: CanGet Authorization
{ return true;
// CSLATODO: CanEdit Authorization }
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); public static bool CanDeleteObject()
return true; {
} // CSLATODO: CanDelete Authorization
#endregion //bool result = false;
#region Factory Methods //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
public int CurrentEditLevel //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
{ get { return EditLevel; } } //return result;
private static int _ContentDetailUnique = 0; return true;
private static int ContentDetailUnique }
{ get { return ++_ContentDetailUnique; } } public static bool CanEditObject()
private int _MyContentDetailUnique = ContentDetailUnique; {
public int MyContentDetailUnique // Absolutely Unique ID - Editable FK // CSLATODO: CanEdit Authorization
{ get { return _MyContentDetailUnique; } } //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
internal static ContentDetail New(int itemType, string text) return true;
{ }
return new ContentDetail(itemType, text); #endregion
} #region Factory Methods
internal static ContentDetail Get(SafeDataReader dr) public int CurrentEditLevel
{ { get { return EditLevel; } }
return new ContentDetail(dr); private static int _ContentDetailUnique = 0;
} private static int ContentDetailUnique
public ContentDetail() { get { return ++_ContentDetailUnique; } }
{ private int _MyContentDetailUnique = ContentDetailUnique;
MarkAsChild(); public int MyContentDetailUnique // Absolutely Unique ID - Editable FK
_DetailID = Detail.NextDetailID; { get { return _MyContentDetailUnique; } }
_DTS = _ContentDetailExtension.DefaultDTS; internal static ContentDetail New(int itemType, string text)
_UserID = _ContentDetailExtension.DefaultUserID; {
ValidationRules.CheckRules(); return new ContentDetail(itemType, text);
} }
private ContentDetail(int itemType, string text) internal static ContentDetail Get(SafeDataReader dr)
{ {
MarkAsChild(); return new ContentDetail(dr);
// CSLATODO: Add any initialization & defaults }
_DetailID = Detail.NextDetailID; public ContentDetail()
_DTS = _ContentDetailExtension.DefaultDTS; {
_UserID = _ContentDetailExtension.DefaultUserID; MarkAsChild();
_ItemType = itemType; _DetailID = Detail.NextDetailID;
_Text = text; _DTS = _ContentDetailExtension.DefaultDTS;
ValidationRules.CheckRules(); _UserID = _ContentDetailExtension.DefaultUserID;
} ValidationRules.CheckRules();
internal ContentDetail(SafeDataReader dr) }
{ private ContentDetail(int itemType, string text)
MarkAsChild(); {
Fetch(dr); MarkAsChild();
} // CSLATODO: Add any initialization & defaults
private bool _Disposed = false; _DetailID = Detail.NextDetailID;
private static int _CountCreated = 0; _DTS = _ContentDetailExtension.DefaultDTS;
private static int _CountDisposed = 0; _UserID = _ContentDetailExtension.DefaultUserID;
private static int _CountFinalized = 0; _ItemType = itemType;
private static int IncrementCountCreated _Text = text;
{ get { return ++_CountCreated; } } ValidationRules.CheckRules();
private int _CountWhenCreated = IncrementCountCreated; }
public static int CountCreated internal ContentDetail(SafeDataReader dr)
{ get { return _CountCreated; } } {
public static int CountNotDisposed MarkAsChild();
{ get { return _CountCreated - _CountDisposed; } } Fetch(dr);
public static int CountNotFinalized }
{ get { return _CountCreated - _CountFinalized; } } private bool _Disposed = false;
~ContentDetail() private static int _CountCreated = 0;
{ private static int _CountDisposed = 0;
_CountFinalized++; private static int _CountFinalized = 0;
} private static int IncrementCountCreated
public void Dispose() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
if (_Disposed) return; public static int CountCreated
_CountDisposed++; { get { return _CountCreated; } }
_Disposed = true; public static int CountNotDisposed
} { get { return _CountCreated - _CountDisposed; } }
#endregion public static int CountNotFinalized
#region Data Access Portal { get { return _CountCreated - _CountFinalized; } }
private void Fetch(SafeDataReader dr) ~ContentDetail()
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode()); _CountFinalized++;
try }
{ public void Dispose()
_DetailID = dr.GetInt32("DetailID"); {
_ItemType = dr.GetInt32("ItemType"); if (_Disposed) return;
_Text = dr.GetString("Text"); _CountDisposed++;
_Config = dr.GetString("Config"); _Disposed = true;
_DTS = dr.GetDateTime("DTS"); }
_UserID = dr.GetString("UserID"); #endregion
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); #region Data Access Portal
} private void Fetch(SafeDataReader dr)
catch (Exception ex) // FKItem Fetch {
{ if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentDetail.FetchDR", GetHashCode());
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentDetail.FetchDR", ex); try
throw new DbCslaException("ContentDetail.Fetch", ex); {
} _DetailID = dr.GetInt32("DetailID");
MarkOld(); _ItemType = dr.GetInt32("ItemType");
} _Text = dr.GetString("Text");
internal void Insert(Content myContent) _Config = dr.GetString("Config");
{ _DTS = dr.GetDateTime("DTS");
// if we're not dirty then don't update the database _UserID = dr.GetString("UserID");
if (!this.IsDirty) return; dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; }
_LastChanged = Detail.Add(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID); catch (Exception ex) // FKItem Fetch
MarkOld(); {
} if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentDetail.FetchDR", ex);
internal void Update(Content myContent) throw new DbCslaException("ContentDetail.Fetch", ex);
{ }
// if we're not dirty then don't update the database MarkOld();
if (!this.IsDirty) return; }
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; internal void Insert(Content myContent)
_LastChanged = Detail.Update(cn, ref _DetailID, myContent.ContentID, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged); {
MarkOld(); // if we're not dirty then don't update the database
} if (!this.IsDirty) return;
internal void DeleteSelf(Content myContent) SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
{ _LastChanged = Detail.Add(cn, ref _DetailID, myContent, _ItemType, _Text, _Config, _DTS, _UserID);
// if we're not dirty then don't update the database MarkOld();
if (!this.IsDirty) return; }
// if we're new then don't update the database internal void Update(Content myContent)
if (this.IsNew) return; {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; // if we're not dirty then don't update the database
Detail.Remove(cn, _DetailID); if (!this.IsDirty) return;
MarkNew(); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
} _LastChanged = Detail.Update(cn, ref _DetailID, myContent.ContentID, _ItemType, _Text, _Config, _DTS, _UserID, ref _LastChanged);
#endregion MarkOld();
// Standard Default Code }
#region extension internal void DeleteSelf(Content myContent)
ContentDetailExtension _ContentDetailExtension = new ContentDetailExtension(); {
[Serializable()] // if we're not dirty then don't update the database
partial class ContentDetailExtension : extensionBase if (!this.IsDirty) return;
{ // if we're new then don't update the database
} if (this.IsNew) return;
[Serializable()] SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
class extensionBase Detail.Remove(cn, _DetailID);
{ MarkNew();
// Default Values }
public virtual DateTime DefaultDTS #endregion
{ // Standard Default Code
get { return DateTime.Now; } #region extension
} ContentDetailExtension _ContentDetailExtension = new ContentDetailExtension();
public virtual string DefaultUserID [Serializable()]
{ partial class ContentDetailExtension : extensionBase
get { return Volian.Base.Library.VlnSettings.UserID; } {
} }
// Authorization Rules [Serializable()]
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) class extensionBase
{ {
// Needs to be overriden to add new authorization rules // Default Values
} public virtual DateTime DefaultDTS
// Instance Authorization Rules {
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) get { return DateTime.Now; }
{ }
// Needs to be overriden to add new authorization rules public virtual string DefaultUserID
} {
// Validation Rules get { return Volian.Base.Library.VlnSettings.UserID; }
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) }
{ // Authorization Rules
// Needs to be overriden to add new validation rules public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
} {
// InstanceValidation Rules // Needs to be overriden to add new authorization rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) }
{ // Instance Authorization Rules
// Needs to be overriden to add new validation rules public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
} {
} // Needs to be overriden to add new authorization rules
#endregion }
} // Class // Validation Rules
#region Converter public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
internal class ContentDetailConverter : ExpandableObjectConverter {
{ // Needs to be overriden to add new validation rules
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) }
{ // InstanceValidation Rules
if (destType == typeof(string) && value is ContentDetail) public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Return the ToString value // Needs to be overriden to add new validation rules
return ((ContentDetail)value).ToString(); }
} }
return base.ConvertTo(context, culture, value, destType); #endregion
} } // Class
} #region Converter
#endregion internal class ContentDetailConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentDetail)
{
// Return the ToString value
return ((ContentDetail)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -20,394 +20,403 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// ContentItem Generated by MyGeneration using the CSLA Object Mapping template /// ContentItem Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ContentItemConverter))] [TypeConverter(typeof(ContentItemConverter))]
public partial class ContentItem : BusinessBase<ContentItem>, IVEHasBrokenRules, IDisposable public partial class ContentItem : BusinessBase<ContentItem>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _ItemID; private int _ItemID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int ItemID public int ItemID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyItem != null) _ItemID = _MyItem.ItemID; CanReadProperty("ItemID", true);
return _ItemID; if (_MyItem != null) _ItemID = _MyItem.ItemID;
} return _ItemID;
} }
private Item _MyItem; }
[System.ComponentModel.DataObjectField(true, true)] private Item _MyItem;
public Item MyItem [System.ComponentModel.DataObjectField(true, true)]
{ public Item MyItem
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); {
return _MyItem; CanReadProperty("MyItem", true);
} if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
} return _MyItem;
private int? _PreviousID; }
public int? PreviousID }
{ private int? _PreviousID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int? PreviousID
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID; get
return _PreviousID; {
} CanReadProperty("PreviousID", true);
} if (_MyPrevious != null) _PreviousID = _MyPrevious.ItemID;
private Item _MyPrevious; return _PreviousID;
public Item MyPrevious }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private Item _MyPrevious;
get public Item MyPrevious
{ {
if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _MyPrevious; get
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("MyPrevious", true);
set if (_MyPrevious == null && _PreviousID != null) _MyPrevious = Item.Get((int)_PreviousID);
{ return _MyPrevious;
if ((_MyPrevious == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID)) }
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_MyPrevious = value; set
_PreviousID = (value == null ? null : (int?)value.ItemID); {
PropertyHasChanged(); CanWriteProperty("MyPrevious", true);
} if ((_MyPrevious == null ? _PreviousID : (int?)_MyPrevious.ItemID) != (value == null ? null : (int?)value.ItemID))
} {
} _MyPrevious = value;
private DateTime _DTS = new DateTime(); _PreviousID = (value == null ? null : (int?)value.ItemID);
public DateTime DTS PropertyHasChanged();
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private DateTime _DTS = new DateTime();
return _DTS; public DateTime DTS
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set get
{ {
if (_DTS != value) CanReadProperty("DTS", true);
{ return _DTS;
_DTS = value; }
PropertyHasChanged(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
} {
} CanWriteProperty("DTS", true);
private string _UserID = string.Empty; if (_DTS != value)
public string UserID {
{ _DTS = value;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] PropertyHasChanged();
get }
{ }
return _UserID; }
} private string _UserID = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string UserID
set {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (value == null) value = string.Empty; get
if (_UserID != value) {
{ CanReadProperty("UserID", true);
_UserID = value; return _UserID;
PropertyHasChanged(); }
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
} {
private byte[] _LastChanged = new byte[8];//timestamp CanWriteProperty("UserID", true);
// CSLATODO: Check ContentItem.GetIdValue to assure that the ID returned is unique if (value == null) value = string.Empty;
/// <summary> if (_UserID != value)
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality {
/// </summary> _UserID = value;
/// <returns>A Unique ID for the current ContentItem</returns> PropertyHasChanged();
protected override object GetIdValue() }
{ }
return MyContentItemUnique; // Absolutely Unique ID }
} private byte[] _LastChanged = new byte[8];//timestamp
// CSLATODO: Replace base ContentItem.ToString function as necessary // CSLATODO: Check ContentItem.GetIdValue to assure that the ID returned is unique
/// <summary> /// <summary>
/// Overrides Base ToString /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary> /// </summary>
/// <returns>A string representation of current ContentItem</returns> /// <returns>A Unique ID for the current ContentItem</returns>
//public override string ToString() protected override object GetIdValue()
//{ {
// return base.ToString(); return MyContentItemUnique; // Absolutely Unique ID
//} }
public override bool IsDirty // CSLATODO: Replace base ContentItem.ToString function as necessary
{ /// <summary>
get { return base.IsDirty; } /// Overrides Base ToString
} /// </summary>
public bool IsDirtyList(List<object> list) /// <returns>A string representation of current ContentItem</returns>
{ //public override string ToString()
return base.IsDirty; //{
} // return base.ToString();
public override bool IsValid //}
{ public override bool IsDirty
get { return (IsNew && !IsDirty) ? true : base.IsValid; } {
} get { return base.IsDirty; }
public bool IsValidList(List<object> list) }
{ public bool IsDirtyList(List<object> list)
return (IsNew && !IsDirty) ? true : base.IsValid; {
} return base.IsDirty;
#endregion }
#region ValidationRules public override bool IsValid
[NonSerialized] {
private bool _CheckingBrokenRules = false; get { return (IsNew && !IsDirty) ? true : base.IsValid; }
public IVEHasBrokenRules HasBrokenRules }
{ public bool IsValidList(List<object> list)
get {
{ return (IsNew && !IsDirty) ? true : base.IsValid;
if (_CheckingBrokenRules) return null; }
if (BrokenRulesCollection.Count > 0) return this; #endregion
try #region ValidationRules
{ [NonSerialized]
_CheckingBrokenRules = true; private bool _CheckingBrokenRules = false;
IVEHasBrokenRules hasBrokenRules = null; public IVEHasBrokenRules HasBrokenRules
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; {
return hasBrokenRules; get
} {
finally if (_CheckingBrokenRules) return null;
{ if (BrokenRulesCollection.Count > 0) return this;
_CheckingBrokenRules = false; try
} {
} _CheckingBrokenRules = true;
} IVEHasBrokenRules hasBrokenRules = null;
public BrokenRulesCollection BrokenRules if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
{ return hasBrokenRules;
get }
{ finally
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; {
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; _CheckingBrokenRules = false;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); }
} }
} }
protected override void AddBusinessRules() public BrokenRulesCollection BrokenRules
{ {
ValidationRules.AddRule( get
Csla.Validation.CommonRules.StringRequired, "UserID"); {
ValidationRules.AddRule( IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
Csla.Validation.CommonRules.StringMaxLength, if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
// CSLATODO: Add other validation rules }
} }
// Sample data comparison validation rule protected override void AddBusinessRules()
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) {
//{ ValidationRules.AddRule(
// if (_started > _ended) Csla.Validation.CommonRules.StringRequired, "UserID");
// { ValidationRules.AddRule(
// e.Description = "Start date can't be after end date"; Csla.Validation.CommonRules.StringMaxLength,
// return false; new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
// } // CSLATODO: Add other validation rules
// else }
// return true; // Sample data comparison validation rule
//} //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
#endregion //{
#region Authorization Rules // if (_started > _ended)
protected override void AddAuthorizationRules() // {
{ // e.Description = "Start date can't be after end date";
//CSLATODO: Who can read/write which fields // return false;
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>"); // }
//AuthorizationRules.AllowRead(PreviousID, "<Role(s)>"); // else
//AuthorizationRules.AllowWrite(PreviousID, "<Role(s)>"); // return true;
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); //}
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); #endregion
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); #region Authorization Rules
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); protected override void AddAuthorizationRules()
} {
public static bool CanAddObject() //CSLATODO: Who can read/write which fields
{ //AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
// CSLATODO: Can Add Authorization //AuthorizationRules.AllowRead(PreviousID, "<Role(s)>");
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); //AuthorizationRules.AllowWrite(PreviousID, "<Role(s)>");
return true; //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
} //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
public static bool CanGetObject() //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
{ //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
// CSLATODO: CanGet Authorization }
return true; public static bool CanAddObject()
} {
public static bool CanDeleteObject() // CSLATODO: Can Add Authorization
{ //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
// CSLATODO: CanDelete Authorization return true;
//bool result = false; }
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; public static bool CanGetObject()
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; {
//return result; // CSLATODO: CanGet Authorization
return true; return true;
} }
public static bool CanEditObject() public static bool CanDeleteObject()
{ {
// CSLATODO: CanEdit Authorization // CSLATODO: CanDelete Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); //bool result = false;
return true; //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
} //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
#endregion //return result;
#region Factory Methods return true;
public int CurrentEditLevel }
{ get { return EditLevel; } } public static bool CanEditObject()
private static int _ContentItemUnique = 0; {
private static int ContentItemUnique // CSLATODO: CanEdit Authorization
{ get { return ++_ContentItemUnique; } } //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
private int _MyContentItemUnique = ContentItemUnique; return true;
public int MyContentItemUnique // Absolutely Unique ID - Editable FK }
{ get { return _MyContentItemUnique; } } #endregion
internal static ContentItem New() #region Factory Methods
{ public int CurrentEditLevel
return new ContentItem(); { get { return EditLevel; } }
} private static int _ContentItemUnique = 0;
internal static ContentItem Get(SafeDataReader dr) private static int ContentItemUnique
{ { get { return ++_ContentItemUnique; } }
return new ContentItem(dr); private int _MyContentItemUnique = ContentItemUnique;
} public int MyContentItemUnique // Absolutely Unique ID - Editable FK
public ContentItem() { get { return _MyContentItemUnique; } }
{ internal static ContentItem New()
MarkAsChild(); {
_ItemID = Item.NextItemID; return new ContentItem();
_DTS = _ContentItemExtension.DefaultDTS; }
_UserID = _ContentItemExtension.DefaultUserID; internal static ContentItem Get(SafeDataReader dr)
ValidationRules.CheckRules(); {
} return new ContentItem(dr);
internal ContentItem(SafeDataReader dr) }
{ public ContentItem()
MarkAsChild(); {
Fetch(dr); MarkAsChild();
} _ItemID = Item.NextItemID;
private bool _Disposed = false; _DTS = _ContentItemExtension.DefaultDTS;
private static int _CountCreated = 0; _UserID = _ContentItemExtension.DefaultUserID;
private static int _CountDisposed = 0; ValidationRules.CheckRules();
private static int _CountFinalized = 0; }
private static int IncrementCountCreated internal ContentItem(SafeDataReader dr)
{ get { return ++_CountCreated; } } {
private int _CountWhenCreated = IncrementCountCreated; MarkAsChild();
public static int CountCreated Fetch(dr);
{ get { return _CountCreated; } } }
public static int CountNotDisposed private bool _Disposed = false;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountCreated = 0;
public static int CountNotFinalized private static int _CountDisposed = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountFinalized = 0;
~ContentItem() private static int IncrementCountCreated
{ { get { return ++_CountCreated; } }
_CountFinalized++; private int _CountWhenCreated = IncrementCountCreated;
} public static int CountCreated
public void Dispose() { get { return _CountCreated; } }
{ public static int CountNotDisposed
if (_Disposed) return; { get { return _CountCreated - _CountDisposed; } }
_CountDisposed++; public static int CountNotFinalized
_Disposed = true; { get { return _CountCreated - _CountFinalized; } }
} ~ContentItem()
#endregion {
#region Data Access Portal _CountFinalized++;
private void Fetch(SafeDataReader dr) }
{ public void Dispose()
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode()); {
try if (_Disposed) return;
{ _CountDisposed++;
_ItemID = dr.GetInt32("ItemID"); _Disposed = true;
_PreviousID = (int?)dr.GetValue("PreviousID"); }
_DTS = dr.GetDateTime("DTS"); #endregion
_UserID = dr.GetString("UserID"); #region Data Access Portal
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); private void Fetch(SafeDataReader dr)
} {
catch (Exception ex) // FKItem Fetch if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentItem.FetchDR", GetHashCode());
{ try
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItem.FetchDR", ex); {
throw new DbCslaException("ContentItem.Fetch", ex); _ItemID = dr.GetInt32("ItemID");
} _PreviousID = (int?)dr.GetValue("PreviousID");
MarkOld(); _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
internal void Insert(Content myContent) dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
{ }
// if we're not dirty then don't update the database catch (Exception ex) // FKItem Fetch
if (!this.IsDirty) return; {
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentItem.FetchDR", ex);
_LastChanged = Item.Add(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID); throw new DbCslaException("ContentItem.Fetch", ex);
MarkOld(); }
} MarkOld();
internal void Update(Content myContent) }
{ internal void Insert(Content myContent)
// if we're not dirty then don't update the database {
if (!this.IsDirty) return; // if we're not dirty then don't update the database
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; if (!this.IsDirty) return;
_LastChanged = Item.Update(cn, ref _ItemID, _PreviousID, myContent.ContentID, _DTS, _UserID, ref _LastChanged); SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
MarkOld(); _LastChanged = Item.Add(cn, ref _ItemID, Item.Get((int)_PreviousID), myContent, _DTS, _UserID);
} MarkOld();
internal void DeleteSelf(Content myContent) }
{ internal void Update(Content myContent)
// if we're not dirty then don't update the database {
if (!this.IsDirty) return; // if we're not dirty then don't update the database
// if we're new then don't update the database if (!this.IsDirty) return;
if (this.IsNew) return; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; _LastChanged = Item.Update(cn, ref _ItemID, _PreviousID, myContent.ContentID, _DTS, _UserID, ref _LastChanged);
Item.Remove(cn, _ItemID); MarkOld();
MarkNew(); }
} internal void DeleteSelf(Content myContent)
#endregion {
// Standard Default Code // if we're not dirty then don't update the database
#region extension if (!this.IsDirty) return;
ContentItemExtension _ContentItemExtension = new ContentItemExtension(); // if we're new then don't update the database
[Serializable()] if (this.IsNew) return;
partial class ContentItemExtension : extensionBase SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
{ Item.Remove(cn, _ItemID);
} MarkNew();
[Serializable()] }
class extensionBase #endregion
{ // Standard Default Code
// Default Values #region extension
public virtual DateTime DefaultDTS ContentItemExtension _ContentItemExtension = new ContentItemExtension();
{ [Serializable()]
get { return DateTime.Now; } partial class ContentItemExtension : extensionBase
} {
public virtual string DefaultUserID }
{ [Serializable()]
get { return Volian.Base.Library.VlnSettings.UserID; } class extensionBase
} {
// Authorization Rules // Default Values
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual DateTime DefaultDTS
{ {
// Needs to be overriden to add new authorization rules get { return DateTime.Now; }
} }
// Instance Authorization Rules public virtual string DefaultUserID
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) {
{ get { return Volian.Base.Library.VlnSettings.UserID; }
// Needs to be overriden to add new authorization rules }
} // Authorization Rules
// Validation Rules public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) {
{ // Needs to be overriden to add new authorization rules
// Needs to be overriden to add new validation rules }
} // Instance Authorization Rules
// InstanceValidation Rules public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) {
{ // Needs to be overriden to add new authorization rules
// Needs to be overriden to add new validation rules }
} // Validation Rules
} public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
#endregion {
} // Class // Needs to be overriden to add new validation rules
#region Converter }
internal class ContentItemConverter : ExpandableObjectConverter // InstanceValidation Rules
{ public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) {
{ // Needs to be overriden to add new validation rules
if (destType == typeof(string) && value is ContentItem) }
{ }
// Return the ToString value #endregion
return ((ContentItem)value).ToString(); } // Class
} #region Converter
return base.ConvertTo(context, culture, value, destType); internal class ContentItemConverter : ExpandableObjectConverter
} {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
#endregion {
if (destType == typeof(string) && value is ContentItem)
{
// Return the ToString value
return ((ContentItem)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -20,458 +20,470 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// ContentPart Generated by MyGeneration using the CSLA Object Mapping template /// ContentPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ContentPartConverter))] [TypeConverter(typeof(ContentPartConverter))]
public partial class ContentPart : BusinessBase<ContentPart>, IVEHasBrokenRules, IDisposable public partial class ContentPart : BusinessBase<ContentPart>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _FromType; private int _FromType;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int FromType public int FromType
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _FromType; CanReadProperty("FromType", true);
} return _FromType;
} }
private int _ItemID; }
public int ItemID private int _ItemID;
{ public int ItemID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyItem != null) _ItemID = _MyItem.ItemID; {
return _ItemID; CanReadProperty("ItemID", true);
} if (_MyItem != null) _ItemID = _MyItem.ItemID;
} return _ItemID;
private Item _MyItem; }
public Item MyItem }
{ private Item _MyItem;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public Item MyItem
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID); get
return _MyItem; {
} CanReadProperty("MyItem", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_MyItem == null && _ItemID != 0) _MyItem = Item.Get(_ItemID);
set return _MyItem;
{ }
if (_MyItem != value) [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ set
_MyItem = value; {
_ItemID = value.ItemID;// Update underlying data field CanWriteProperty("MyItem", true);
PropertyHasChanged(); if (_MyItem != value)
} {
} _MyItem = value;
} _ItemID = value.ItemID;// Update underlying data field
private DateTime _DTS = new DateTime(); PropertyHasChanged();
public DateTime DTS }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTS = new DateTime();
{ public DateTime DTS
return _DTS; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
set {
{ CanReadProperty("DTS", true);
if (_DTS != value) return _DTS;
{ }
_DTS = value; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
PropertyHasChanged(); set
} {
} CanWriteProperty("DTS", true);
} if (_DTS != value)
private string _UserID = string.Empty; {
public string UserID _DTS = value;
{ PropertyHasChanged();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ }
return _UserID; private string _UserID = string.Empty;
} public string UserID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
set [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (value == null) value = string.Empty; {
if (_UserID != value) CanReadProperty("UserID", true);
{ return _UserID;
_UserID = value; }
PropertyHasChanged(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
} {
} CanWriteProperty("UserID", true);
private byte[] _LastChanged = new byte[8];//timestamp if (value == null) value = string.Empty;
private int? _Item_PreviousID; if (_UserID != value)
public int? Item_PreviousID {
{ _UserID = value;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] PropertyHasChanged();
get }
{ }
return _Item_PreviousID; }
} private byte[] _LastChanged = new byte[8];//timestamp
} private int? _Item_PreviousID;
private int _Item_ContentID; public int? Item_PreviousID
public int Item_ContentID {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("Item_PreviousID", true);
return _Item_ContentID; return _Item_PreviousID;
} }
} }
private DateTime _Item_DTS = new DateTime(); private int _Item_ContentID;
public DateTime Item_DTS public int Item_ContentID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _Item_DTS; CanReadProperty("Item_ContentID", true);
} return _Item_ContentID;
} }
private string _Item_UserID = string.Empty; }
public string Item_UserID private DateTime _Item_DTS = new DateTime();
{ public DateTime Item_DTS
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _Item_UserID; {
} CanReadProperty("Item_DTS", true);
} return _Item_DTS;
// CSLATODO: Check ContentPart.GetIdValue to assure that the ID returned is unique }
/// <summary> }
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality private string _Item_UserID = string.Empty;
/// </summary> public string Item_UserID
/// <returns>A Unique ID for the current ContentPart</returns> {
protected override object GetIdValue() [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return MyContentPartUnique; // Absolutely Unique ID {
} CanReadProperty("Item_UserID", true);
// CSLATODO: Replace base ContentPart.ToString function as necessary return _Item_UserID;
/// <summary> }
/// Overrides Base ToString }
/// </summary> // CSLATODO: Check ContentPart.GetIdValue to assure that the ID returned is unique
/// <returns>A string representation of current ContentPart</returns> /// <summary>
//public override string ToString() /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
//{ /// </summary>
// return base.ToString(); /// <returns>A Unique ID for the current ContentPart</returns>
//} protected override object GetIdValue()
public override bool IsDirty {
{ return MyContentPartUnique; // Absolutely Unique ID
get }
{ // CSLATODO: Replace base ContentPart.ToString function as necessary
if (base.IsDirty) /// <summary>
return true; /// Overrides Base ToString
return IsDirtyList(new List<object>()); /// </summary>
} /// <returns>A string representation of current ContentPart</returns>
} //public override string ToString()
public bool IsDirtyList(List<object> list) //{
{ // return base.ToString();
if (base.IsDirty || list.Contains(this)) //}
return base.IsDirty; public override bool IsDirty
list.Add(this); {
return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirtyList(list)); get
} {
public override bool IsValid if ( base.IsDirty )
{ return true;
get { return IsValidList(new List<object>()); } return IsDirtyList(new List<object>());
} }
public bool IsValidList(List<object> list) }
{ public bool IsDirtyList(List<object> list)
if (list.Contains(this)) {
return (IsNew && !IsDirty) ? true : base.IsValid; if (base.IsDirty || list.Contains(this))
list.Add(this); return base.IsDirty;
return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValidList(list)); list.Add(this);
} return base.IsDirty || (_MyItem == null ? false : _MyItem.IsDirtyList(list));
#endregion }
#region ValidationRules public override bool IsValid
[NonSerialized] {
private bool _CheckingBrokenRules = false; get { return IsValidList(new List<object>()); }
public IVEHasBrokenRules HasBrokenRules }
{ public bool IsValidList(List<object> list)
get {
{ if(list.Contains(this))
if (_CheckingBrokenRules) return null; return (IsNew && !IsDirty) ? true : base.IsValid;
if (BrokenRulesCollection.Count > 0) return this; list.Add(this);
try return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyItem == null ? true : _MyItem.IsValidList(list));
{ }
_CheckingBrokenRules = true; #endregion
IVEHasBrokenRules hasBrokenRules = null; #region ValidationRules
if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules; [NonSerialized]
return hasBrokenRules; private bool _CheckingBrokenRules = false;
} public IVEHasBrokenRules HasBrokenRules
finally {
{ get
_CheckingBrokenRules = false; {
} if (_CheckingBrokenRules) return null;
} if (BrokenRulesCollection.Count > 0) return this;
} try
public BrokenRulesCollection BrokenRules {
{ _CheckingBrokenRules = true;
get IVEHasBrokenRules hasBrokenRules = null;
{ if (_MyItem != null && (hasBrokenRules = _MyItem.HasBrokenRules) != null) return hasBrokenRules;
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; return hasBrokenRules;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; }
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); finally
} {
} _CheckingBrokenRules = false;
protected override void AddBusinessRules() }
{ }
ValidationRules.AddRule<ContentPart>(MyItemRequired, "MyItem"); }
ValidationRules.AddRule( public BrokenRulesCollection BrokenRules
Csla.Validation.CommonRules.StringRequired, "UserID"); {
ValidationRules.AddRule( get
Csla.Validation.CommonRules.StringMaxLength, {
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
// CSLATODO: Add other validation rules if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
} return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
private static bool MyItemRequired(ContentPart target, Csla.Validation.RuleArgs e) }
{ }
if (target._ItemID == 0 && target._MyItem == null) // Required field missing protected override void AddBusinessRules()
{ {
e.Description = "Required"; ValidationRules.AddRule<ContentPart>(MyItemRequired, "MyItem");
return false; ValidationRules.AddRule(
} Csla.Validation.CommonRules.StringRequired, "UserID");
return true; ValidationRules.AddRule(
} Csla.Validation.CommonRules.StringMaxLength,
// Sample data comparison validation rule new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) // CSLATODO: Add other validation rules
//{ }
// if (_started > _ended) private static bool MyItemRequired(ContentPart target, Csla.Validation.RuleArgs e)
// { {
// e.Description = "Start date can't be after end date"; if (target._ItemID == 0 && target._MyItem == null) // Required field missing
// return false; {
// } e.Description = "Required";
// else return false;
// return true; }
//} return true;
#endregion }
#region Authorization Rules // Sample data comparison validation rule
protected override void AddAuthorizationRules() //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
{ //{
//CSLATODO: Who can read/write which fields // if (_started > _ended)
//AuthorizationRules.AllowRead(FromType, "<Role(s)>"); // {
//AuthorizationRules.AllowRead(ItemID, "<Role(s)>"); // e.Description = "Start date can't be after end date";
//AuthorizationRules.AllowWrite(ItemID, "<Role(s)>"); // return false;
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); // }
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); // else
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); // return true;
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); //}
} #endregion
public static bool CanAddObject() #region Authorization Rules
{ protected override void AddAuthorizationRules()
// CSLATODO: Can Add Authorization {
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); //CSLATODO: Who can read/write which fields
return true; //AuthorizationRules.AllowRead(FromType, "<Role(s)>");
} //AuthorizationRules.AllowRead(ItemID, "<Role(s)>");
public static bool CanGetObject() //AuthorizationRules.AllowWrite(ItemID, "<Role(s)>");
{ //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
// CSLATODO: CanGet Authorization //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
return true; //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
} //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
public static bool CanDeleteObject() }
{ public static bool CanAddObject()
// CSLATODO: CanDelete Authorization {
//bool result = false; // CSLATODO: Can Add Authorization
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; return true;
//return result; }
return true; public static bool CanGetObject()
} {
public static bool CanEditObject() // CSLATODO: CanGet Authorization
{ return true;
// CSLATODO: CanEdit Authorization }
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); public static bool CanDeleteObject()
return true; {
} // CSLATODO: CanDelete Authorization
#endregion //bool result = false;
#region Factory Methods //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
public int CurrentEditLevel //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
{ get { return EditLevel; } } //return result;
private static int _ContentPartUnique = 0; return true;
private static int ContentPartUnique }
{ get { return ++_ContentPartUnique; } } public static bool CanEditObject()
private int _MyContentPartUnique = ContentPartUnique; {
public int MyContentPartUnique // Absolutely Unique ID - Editable FK // CSLATODO: CanEdit Authorization
{ get { return _MyContentPartUnique; } } //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
internal static ContentPart New(int fromType, Item myItem) return true;
{ }
return new ContentPart(fromType, myItem); #endregion
} #region Factory Methods
internal static ContentPart Get(SafeDataReader dr) public int CurrentEditLevel
{ { get { return EditLevel; } }
return new ContentPart(dr); private static int _ContentPartUnique = 0;
} private static int ContentPartUnique
public ContentPart() { get { return ++_ContentPartUnique; } }
{ private int _MyContentPartUnique = ContentPartUnique;
MarkAsChild(); public int MyContentPartUnique // Absolutely Unique ID - Editable FK
{ get { return _MyContentPartUnique; } }
internal static ContentPart New(int fromType, Item myItem)
{
return new ContentPart(fromType, myItem);
}
internal static ContentPart Get(SafeDataReader dr)
{
return new ContentPart(dr);
}
public ContentPart()
{
MarkAsChild();
_DTS = _ContentPartExtension.DefaultDTS; _DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID; _UserID = _ContentPartExtension.DefaultUserID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
private ContentPart(int fromType, Item myItem) private ContentPart(int fromType, Item myItem)
{ {
MarkAsChild(); MarkAsChild();
// CSLATODO: Add any initialization & defaults // CSLATODO: Add any initialization & defaults
_DTS = _ContentPartExtension.DefaultDTS; _DTS = _ContentPartExtension.DefaultDTS;
_UserID = _ContentPartExtension.DefaultUserID; _UserID = _ContentPartExtension.DefaultUserID;
_FromType = fromType; _FromType = fromType;
_MyItem = myItem; _MyItem = myItem;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ContentPart(SafeDataReader dr) internal ContentPart(SafeDataReader dr)
{ {
MarkAsChild(); MarkAsChild();
Fetch(dr); Fetch(dr);
} }
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~ContentPart() ~ContentPart()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++; _CountDisposed++;
_Disposed = true; _Disposed = true;
if (_MyItem != null) if (_MyItem != null)
{ {
_MyItem.Dispose(); _MyItem.Dispose();
_MyItem = null; _MyItem = null;
} }
} }
#endregion #endregion
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentPart.FetchDR", GetHashCode());
try try
{ {
_FromType = dr.GetInt32("FromType"); _FromType = dr.GetInt32("FromType");
_ItemID = dr.GetInt32("ItemID"); _ItemID = dr.GetInt32("ItemID");
_DTS = dr.GetDateTime("DTS"); _DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID"); _UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Item_PreviousID = (int?)dr.GetValue("Item_PreviousID"); _Item_PreviousID = (int?)dr.GetValue("Item_PreviousID");
_Item_ContentID = dr.GetInt32("Item_ContentID"); _Item_ContentID = dr.GetInt32("Item_ContentID");
_Item_DTS = dr.GetDateTime("Item_DTS"); _Item_DTS = dr.GetDateTime("Item_DTS");
_Item_UserID = dr.GetString("Item_UserID"); _Item_UserID = dr.GetString("Item_UserID");
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentPart.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentPart.FetchDR", ex);
throw new DbCslaException("ContentPart.Fetch", ex); throw new DbCslaException("ContentPart.Fetch", ex);
} }
MarkOld(); MarkOld();
} }
internal void Insert(Content myContent) internal void Insert(Content myContent)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, myContent, _FromType, _MyItem, _DTS, _UserID); _LastChanged = Part.Add(cn, myContent, _FromType, _MyItem, _DTS, _UserID);
MarkOld(); MarkOld();
} }
internal void Update(Content myContent) internal void Update(Content myContent)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, myContent.ContentID, _FromType, _ItemID, _DTS, _UserID, ref _LastChanged); _LastChanged = Part.Update(cn, myContent.ContentID, _FromType, _ItemID, _DTS, _UserID, ref _LastChanged);
MarkOld(); MarkOld();
} }
internal void DeleteSelf(Content myContent) internal void DeleteSelf(Content myContent)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
// if we're new then don't update the database // if we're new then don't update the database
if (this.IsNew) return; if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Part.Remove(cn, myContent.ContentID, _FromType); Part.Remove(cn, myContent.ContentID, _FromType);
MarkNew(); MarkNew();
} }
#endregion #endregion
// Standard Default Code // Standard Default Code
#region extension #region extension
ContentPartExtension _ContentPartExtension = new ContentPartExtension(); ContentPartExtension _ContentPartExtension = new ContentPartExtension();
[Serializable()] [Serializable()]
partial class ContentPartExtension : extensionBase partial class ContentPartExtension : extensionBase
{ {
} }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {
// Default Values // Default Values
public virtual DateTime DefaultDTS public virtual DateTime DefaultDTS
{ {
get { return DateTime.Now; } get { return DateTime.Now; }
} }
public virtual string DefaultUserID public virtual string DefaultUserID
{ {
get { return Volian.Base.Library.VlnSettings.UserID; } get { return Volian.Base.Library.VlnSettings.UserID; }
} }
// Authorization Rules // Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Instance Authorization Rules // Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Validation Rules // Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
// InstanceValidation Rules // InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
} }
#endregion #endregion
} // Class } // Class
#region Converter #region Converter
internal class ContentPartConverter : ExpandableObjectConverter internal class ContentPartConverter : ExpandableObjectConverter
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
if (destType == typeof(string) && value is ContentPart) if (destType == typeof(string) && value is ContentPart)
{ {
// Return the ToString value // Return the ToString value
return ((ContentPart)value).ToString(); return ((ContentPart)value).ToString();
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
} }
#endregion #endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,366 +19,376 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void AnnotationAuditInfoEvent(object sender); public delegate void AnnotationAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// AnnotationAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// AnnotationAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(AnnotationAuditInfoConverter))] [TypeConverter(typeof(AnnotationAuditInfoConverter))]
public partial class AnnotationAuditInfo : ReadOnlyBase<AnnotationAuditInfo>, IDisposable public partial class AnnotationAuditInfo : ReadOnlyBase<AnnotationAuditInfo>, IDisposable
{ {
public event AnnotationAuditInfoEvent Changed; public event AnnotationAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<AnnotationAuditInfo> _CacheList = new List<AnnotationAuditInfo>(); private static List<AnnotationAuditInfo> _CacheList = new List<AnnotationAuditInfo>();
protected static void AddToCache(AnnotationAuditInfo annotationAuditInfo) protected static void AddToCache(AnnotationAuditInfo annotationAuditInfo)
{ {
if (!_CacheList.Contains(annotationAuditInfo)) _CacheList.Add(annotationAuditInfo); // In AddToCache if (!_CacheList.Contains(annotationAuditInfo)) _CacheList.Add(annotationAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(AnnotationAuditInfo annotationAuditInfo) protected static void RemoveFromCache(AnnotationAuditInfo annotationAuditInfo)
{ {
while (_CacheList.Contains(annotationAuditInfo)) _CacheList.Remove(annotationAuditInfo); // In RemoveFromCache while (_CacheList.Contains(annotationAuditInfo)) _CacheList.Remove(annotationAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<AnnotationAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAuditInfo>>(); private static Dictionary<string, List<AnnotationAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<AnnotationAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move AnnotationAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move AnnotationAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
AnnotationAuditInfo tmp = _CacheList[0]; // Get the first AnnotationAuditInfo AnnotationAuditInfo tmp = _CacheList[0]; // Get the first AnnotationAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<AnnotationAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<AnnotationAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first AnnotationAuditInfo _CacheList.RemoveAt(0); // Remove the first AnnotationAuditInfo
} }
} }
internal static void AddList(AnnotationAuditInfoList lst) internal static void AddList(AnnotationAuditInfoList lst)
{ {
foreach (AnnotationAuditInfo item in lst) AddToCache(item); foreach (AnnotationAuditInfo item in lst) AddToCache(item);
} }
protected static AnnotationAuditInfo GetCachedByPrimaryKey(long auditID) protected static AnnotationAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected AnnotationAudit _Editable; protected AnnotationAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _AnnotationID; }
public int AnnotationID private int _AnnotationID;
{ public int AnnotationID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _AnnotationID; {
} CanReadProperty("AnnotationID", true);
} return _AnnotationID;
private int _ItemID; }
public int ItemID }
{ private int _ItemID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int ItemID
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ItemID; get
} {
} CanReadProperty("ItemID", true);
private int _TypeID; return _ItemID;
public int TypeID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _TypeID;
get public int TypeID
{ {
return _TypeID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _RtfText = string.Empty; CanReadProperty("TypeID", true);
public string RtfText return _TypeID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _RtfText = string.Empty;
{ public string RtfText
return _RtfText; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _SearchText = string.Empty; {
public string SearchText CanReadProperty("RtfText", true);
{ return _RtfText;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _SearchText = string.Empty;
return _SearchText; public string SearchText
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _Config = string.Empty; get
public string Config {
{ CanReadProperty("SearchText", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _SearchText;
get }
{ }
return _Config; private string _Config = string.Empty;
} public string Config
} {
private DateTime _DTS = new DateTime(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public DateTime DTS get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("Config", true);
get return _Config;
{ }
return _DTS; }
} private DateTime _DTS = new DateTime();
} public DateTime DTS
private string _UserID = string.Empty; {
public string UserID [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("DTS", true);
{ return _DTS;
return _UserID; }
} }
} private string _UserID = string.Empty;
private int _DeleteStatus; public string UserID
public int DeleteStatus {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("UserID", true);
return _DeleteStatus; return _UserID;
} }
} }
// CSLATODO: Replace base AnnotationAuditInfo.ToString function as necessary private int _DeleteStatus;
/// <summary> public int DeleteStatus
/// Overrides Base ToString {
/// </summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <returns>A string representation of current AnnotationAuditInfo</returns> get
//public override string ToString() {
//{ CanReadProperty("DeleteStatus", true);
// return base.ToString(); return _DeleteStatus;
//} }
// CSLATODO: Check AnnotationAuditInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base AnnotationAuditInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current AnnotationAuditInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current AnnotationAuditInfo</returns>
{ //public override string ToString()
return MyAnnotationAuditInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check AnnotationAuditInfo.GetIdValue to assure that the ID returned is unique
private static int _AnnotationAuditInfoUnique = 0; /// <summary>
private static int AnnotationAuditInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_AnnotationAuditInfoUnique; } } /// </summary>
private int _MyAnnotationAuditInfoUnique = AnnotationAuditInfoUnique; /// <returns>A Unique ID for the current AnnotationAuditInfo</returns>
public int MyAnnotationAuditInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyAnnotationAuditInfoUnique; } } {
protected AnnotationAuditInfo() return MyAnnotationAuditInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
public void Dispose() private static int _AnnotationAuditInfoUnique = 0;
{ private static int AnnotationAuditInfoUnique
RemoveFromCache(this); { get { return ++_AnnotationAuditInfoUnique; } }
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; private int _MyAnnotationAuditInfoUnique = AnnotationAuditInfoUnique;
List<AnnotationAuditInfo> listAnnotationAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items public int MyAnnotationAuditInfoUnique // Absolutely Unique ID - Info
while (listAnnotationAuditInfo.Contains(this)) listAnnotationAuditInfo.Remove(this); // Remove the item from the list { get { return _MyAnnotationAuditInfoUnique; } }
if (listAnnotationAuditInfo.Count == 0) // If there are no items left in the list protected AnnotationAuditInfo()
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list {/* require use of factory methods */
} AddToCache(this);
public virtual AnnotationAudit Get() }
{ public void Dispose()
return _Editable = AnnotationAudit.Get(_AuditID); {
} RemoveFromCache(this);
public static void Refresh(AnnotationAudit tmp) if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
{ List<AnnotationAuditInfo> listAnnotationAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
string key = tmp.AuditID.ToString(); while (listAnnotationAuditInfo.Contains(this)) listAnnotationAuditInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listAnnotationAuditInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
foreach (AnnotationAuditInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual AnnotationAudit Get()
} {
protected virtual void RefreshFields(AnnotationAudit tmp) return _Editable = AnnotationAudit.Get(_AuditID);
{ }
_AnnotationID = tmp.AnnotationID; public static void Refresh(AnnotationAudit tmp)
_ItemID = tmp.ItemID; {
_TypeID = tmp.TypeID; string key = tmp.AuditID.ToString();
_RtfText = tmp.RtfText; ConvertListToDictionary();
_SearchText = tmp.SearchText; if (_CacheByPrimaryKey.ContainsKey(key))
_Config = tmp.Config; foreach (AnnotationAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(AnnotationAudit tmp)
_AnnotationAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _AnnotationID = tmp.AnnotationID;
} _ItemID = tmp.ItemID;
public static AnnotationAuditInfo Get(long auditID) _TypeID = tmp.TypeID;
{ _RtfText = tmp.RtfText;
//if (!CanGetObject()) _SearchText = tmp.SearchText;
// throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit"); _Config = tmp.Config;
try _DTS = tmp.DTS;
{ _UserID = tmp.UserID;
AnnotationAuditInfo tmp = GetCachedByPrimaryKey(auditID); _DeleteStatus = tmp.DeleteStatus;
if (tmp == null) _AnnotationAuditInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<AnnotationAuditInfo>(new PKCriteria(auditID)); }
AddToCache(tmp); public static AnnotationAuditInfo Get(long auditID)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a AnnotationAudit");
tmp.Dispose(); // Clean-up AnnotationAuditInfo try
tmp = null; {
} AnnotationAuditInfo tmp = GetCachedByPrimaryKey(auditID);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<AnnotationAuditInfo>(new PKCriteria(auditID));
{ AddToCache(tmp);
throw new DbCslaException("Error on AnnotationAuditInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up AnnotationAuditInfo
#region Data Access Portal tmp = null;
internal AnnotationAuditInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on AnnotationAuditInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("AnnotationAuditInfo.Constructor", ex); internal AnnotationAuditInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private long _AuditID; }
public long AuditID catch (Exception ex)
{ get { return _AuditID; } } {
public PKCriteria(long auditID) if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.Constructor", ex);
{ throw new DbCslaException("AnnotationAuditInfo.Constructor", ex);
_AuditID = auditID; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.ReadData", GetHashCode()); private long _AuditID;
try public long AuditID
{ { get { return _AuditID; } }
_AuditID = dr.GetInt64("AuditID"); public PKCriteria(long auditID)
_AnnotationID = dr.GetInt32("AnnotationID"); {
_ItemID = dr.GetInt32("ItemID"); _AuditID = auditID;
_TypeID = dr.GetInt32("TypeID"); }
_RtfText = dr.GetString("RtfText"); }
_SearchText = dr.GetString("SearchText"); private void ReadData(SafeDataReader dr)
_Config = dr.GetString("Config"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _AnnotationID = dr.GetInt32("AnnotationID");
{ _ItemID = dr.GetInt32("ItemID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.ReadData", ex); _TypeID = dr.GetInt32("TypeID");
_ErrorMessage = ex.Message; _RtfText = dr.GetString("RtfText");
throw new DbCslaException("AnnotationAuditInfo.ReadData", ex); _SearchText = dr.GetString("SearchText");
} _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
private void DataPortal_Fetch(PKCriteria criteria) _UserID = dr.GetString("UserID");
{ _DeleteStatus = dr.GetInt32("DeleteStatus");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("AnnotationAuditInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getAnnotationAudit"; {
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationAuditInfo.DataPortal_Fetch", GetHashCode());
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) try
{ {
if (!dr.Read()) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
_ErrorMessage = "No Record Found"; ApplicationContext.LocalContext["cn"] = cn;
return; using (SqlCommand cm = cn.CreateCommand())
} {
ReadData(dr); cm.CommandType = CommandType.StoredProcedure;
} cm.CommandText = "getAnnotationAudit";
} cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("AnnotationAuditInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
AnnotationAuditInfoExtension _AnnotationAuditInfoExtension = new AnnotationAuditInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class AnnotationAuditInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("AnnotationAuditInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("AnnotationAuditInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(AnnotationAuditInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class AnnotationAuditInfoExtension _AnnotationAuditInfoExtension = new AnnotationAuditInfoExtension();
#region Converter [Serializable()]
internal class AnnotationAuditInfoConverter : ExpandableObjectConverter partial class AnnotationAuditInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is AnnotationAuditInfo) // Default Refresh
{ public virtual void Refresh(AnnotationAuditInfo tmp) { }
// Return the ToString value }
return ((AnnotationAuditInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class AnnotationAuditInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is AnnotationAuditInfo)
{
// Return the ToString value
return ((AnnotationAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,366 +19,376 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ContentAuditInfoEvent(object sender); public delegate void ContentAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// ContentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// ContentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ContentAuditInfoConverter))] [TypeConverter(typeof(ContentAuditInfoConverter))]
public partial class ContentAuditInfo : ReadOnlyBase<ContentAuditInfo>, IDisposable public partial class ContentAuditInfo : ReadOnlyBase<ContentAuditInfo>, IDisposable
{ {
public event ContentAuditInfoEvent Changed; public event ContentAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<ContentAuditInfo> _CacheList = new List<ContentAuditInfo>(); private static List<ContentAuditInfo> _CacheList = new List<ContentAuditInfo>();
protected static void AddToCache(ContentAuditInfo contentAuditInfo) protected static void AddToCache(ContentAuditInfo contentAuditInfo)
{ {
if (!_CacheList.Contains(contentAuditInfo)) _CacheList.Add(contentAuditInfo); // In AddToCache if (!_CacheList.Contains(contentAuditInfo)) _CacheList.Add(contentAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(ContentAuditInfo contentAuditInfo) protected static void RemoveFromCache(ContentAuditInfo contentAuditInfo)
{ {
while (_CacheList.Contains(contentAuditInfo)) _CacheList.Remove(contentAuditInfo); // In RemoveFromCache while (_CacheList.Contains(contentAuditInfo)) _CacheList.Remove(contentAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<ContentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentAuditInfo>>(); private static Dictionary<string, List<ContentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ContentAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move ContentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move ContentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
ContentAuditInfo tmp = _CacheList[0]; // Get the first ContentAuditInfo ContentAuditInfo tmp = _CacheList[0]; // Get the first ContentAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<ContentAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<ContentAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ContentAuditInfo _CacheList.RemoveAt(0); // Remove the first ContentAuditInfo
} }
} }
internal static void AddList(ContentAuditInfoList lst) internal static void AddList(ContentAuditInfoList lst)
{ {
foreach (ContentAuditInfo item in lst) AddToCache(item); foreach (ContentAuditInfo item in lst) AddToCache(item);
} }
protected static ContentAuditInfo GetCachedByPrimaryKey(long auditID) protected static ContentAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected ContentAudit _Editable; protected ContentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ContentID; {
} CanReadProperty("ContentID", true);
} return _ContentID;
private string _Number = string.Empty; }
public string Number }
{ private string _Number = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Number
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Number; get
} {
} CanReadProperty("Number", true);
private string _Text = string.Empty; return _Number;
public string Text }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Text = string.Empty;
get public string Text
{ {
return _Text; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private int? _Type; CanReadProperty("Text", true);
public int? Type return _Text;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private int? _Type;
{ public int? Type
return _Type; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private int? _FormatID; {
public int? FormatID CanReadProperty("Type", true);
{ return _Type;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int? _FormatID;
return _FormatID; public int? FormatID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _Config = string.Empty; get
public string Config {
{ CanReadProperty("FormatID", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _FormatID;
get }
{ }
return _Config; private string _Config = string.Empty;
} public string Config
} {
private DateTime _DTS = new DateTime(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public DateTime DTS get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("Config", true);
get return _Config;
{ }
return _DTS; }
} private DateTime _DTS = new DateTime();
} public DateTime DTS
private string _UserID = string.Empty; {
public string UserID [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("DTS", true);
{ return _DTS;
return _UserID; }
} }
} private string _UserID = string.Empty;
private int _DeleteStatus; public string UserID
public int DeleteStatus {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("UserID", true);
return _DeleteStatus; return _UserID;
} }
} }
// CSLATODO: Replace base ContentAuditInfo.ToString function as necessary private int _DeleteStatus;
/// <summary> public int DeleteStatus
/// Overrides Base ToString {
/// </summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <returns>A string representation of current ContentAuditInfo</returns> get
//public override string ToString() {
//{ CanReadProperty("DeleteStatus", true);
// return base.ToString(); return _DeleteStatus;
//} }
// CSLATODO: Check ContentAuditInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base ContentAuditInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current ContentAuditInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current ContentAuditInfo</returns>
{ //public override string ToString()
return MyContentAuditInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check ContentAuditInfo.GetIdValue to assure that the ID returned is unique
private static int _ContentAuditInfoUnique = 0; /// <summary>
private static int ContentAuditInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_ContentAuditInfoUnique; } } /// </summary>
private int _MyContentAuditInfoUnique = ContentAuditInfoUnique; /// <returns>A Unique ID for the current ContentAuditInfo</returns>
public int MyContentAuditInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyContentAuditInfoUnique; } } {
protected ContentAuditInfo() return MyContentAuditInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
public void Dispose() private static int _ContentAuditInfoUnique = 0;
{ private static int ContentAuditInfoUnique
RemoveFromCache(this); { get { return ++_ContentAuditInfoUnique; } }
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; private int _MyContentAuditInfoUnique = ContentAuditInfoUnique;
List<ContentAuditInfo> listContentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items public int MyContentAuditInfoUnique // Absolutely Unique ID - Info
while (listContentAuditInfo.Contains(this)) listContentAuditInfo.Remove(this); // Remove the item from the list { get { return _MyContentAuditInfoUnique; } }
if (listContentAuditInfo.Count == 0) // If there are no items left in the list protected ContentAuditInfo()
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list {/* require use of factory methods */
} AddToCache(this);
public virtual ContentAudit Get() }
{ public void Dispose()
return _Editable = ContentAudit.Get(_AuditID); {
} RemoveFromCache(this);
public static void Refresh(ContentAudit tmp) if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
{ List<ContentAuditInfo> listContentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
string key = tmp.AuditID.ToString(); while (listContentAuditInfo.Contains(this)) listContentAuditInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listContentAuditInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
foreach (ContentAuditInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual ContentAudit Get()
} {
protected virtual void RefreshFields(ContentAudit tmp) return _Editable = ContentAudit.Get(_AuditID);
{ }
_ContentID = tmp.ContentID; public static void Refresh(ContentAudit tmp)
_Number = tmp.Number; {
_Text = tmp.Text; string key = tmp.AuditID.ToString();
_Type = tmp.Type; ConvertListToDictionary();
_FormatID = tmp.FormatID; if (_CacheByPrimaryKey.ContainsKey(key))
_Config = tmp.Config; foreach (ContentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(ContentAudit tmp)
_ContentAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ContentID = tmp.ContentID;
} _Number = tmp.Number;
public static ContentAuditInfo Get(long auditID) _Text = tmp.Text;
{ _Type = tmp.Type;
//if (!CanGetObject()) _FormatID = tmp.FormatID;
// throw new System.Security.SecurityException("User not authorized to view a ContentAudit"); _Config = tmp.Config;
try _DTS = tmp.DTS;
{ _UserID = tmp.UserID;
ContentAuditInfo tmp = GetCachedByPrimaryKey(auditID); _DeleteStatus = tmp.DeleteStatus;
if (tmp == null) _ContentAuditInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<ContentAuditInfo>(new PKCriteria(auditID)); }
AddToCache(tmp); public static ContentAuditInfo Get(long auditID)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a ContentAudit");
tmp.Dispose(); // Clean-up ContentAuditInfo try
tmp = null; {
} ContentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<ContentAuditInfo>(new PKCriteria(auditID));
{ AddToCache(tmp);
throw new DbCslaException("Error on ContentAuditInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up ContentAuditInfo
#region Data Access Portal tmp = null;
internal ContentAuditInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on ContentAuditInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("ContentAuditInfo.Constructor", ex); internal ContentAuditInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private long _AuditID; }
public long AuditID catch (Exception ex)
{ get { return _AuditID; } } {
public PKCriteria(long auditID) if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.Constructor", ex);
{ throw new DbCslaException("ContentAuditInfo.Constructor", ex);
_AuditID = auditID; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.ReadData", GetHashCode()); private long _AuditID;
try public long AuditID
{ { get { return _AuditID; } }
_AuditID = dr.GetInt64("AuditID"); public PKCriteria(long auditID)
_ContentID = dr.GetInt32("ContentID"); {
_Number = dr.GetString("Number"); _AuditID = auditID;
_Text = dr.GetString("Text"); }
_Type = (int?)dr.GetValue("Type"); }
_FormatID = (int?)dr.GetValue("FormatID"); private void ReadData(SafeDataReader dr)
_Config = dr.GetString("Config"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _Number = dr.GetString("Number");
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.ReadData", ex); _Text = dr.GetString("Text");
_ErrorMessage = ex.Message; _Type = (int?)dr.GetValue("Type");
throw new DbCslaException("ContentAuditInfo.ReadData", ex); _FormatID = (int?)dr.GetValue("FormatID");
} _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
private void DataPortal_Fetch(PKCriteria criteria) _UserID = dr.GetString("UserID");
{ _DeleteStatus = dr.GetInt32("DeleteStatus");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("ContentAuditInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getContentAudit"; {
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentAuditInfo.DataPortal_Fetch", GetHashCode());
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) try
{ {
if (!dr.Read()) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
_ErrorMessage = "No Record Found"; ApplicationContext.LocalContext["cn"] = cn;
return; using (SqlCommand cm = cn.CreateCommand())
} {
ReadData(dr); cm.CommandType = CommandType.StoredProcedure;
} cm.CommandText = "getContentAudit";
} cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("ContentAuditInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
ContentAuditInfoExtension _ContentAuditInfoExtension = new ContentAuditInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class ContentAuditInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentAuditInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("ContentAuditInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(ContentAuditInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class ContentAuditInfoExtension _ContentAuditInfoExtension = new ContentAuditInfoExtension();
#region Converter [Serializable()]
internal class ContentAuditInfoConverter : ExpandableObjectConverter partial class ContentAuditInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is ContentAuditInfo) // Default Refresh
{ public virtual void Refresh(ContentAuditInfo tmp) { }
// Return the ToString value }
return ((ContentAuditInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class ContentAuditInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is ContentAuditInfo)
{
// Return the ToString value
return ((ContentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,377 +19,388 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void DocumentAuditInfoEvent(object sender); public delegate void DocumentAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// DocumentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// DocumentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DocumentAuditInfoConverter))] [TypeConverter(typeof(DocumentAuditInfoConverter))]
public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable
{ {
public event DocumentAuditInfoEvent Changed; public event DocumentAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>(); private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>();
protected static void AddToCache(DocumentAuditInfo documentAuditInfo) protected static void AddToCache(DocumentAuditInfo documentAuditInfo)
{ {
if (!_CacheList.Contains(documentAuditInfo)) _CacheList.Add(documentAuditInfo); // In AddToCache if (!_CacheList.Contains(documentAuditInfo)) _CacheList.Add(documentAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(DocumentAuditInfo documentAuditInfo) protected static void RemoveFromCache(DocumentAuditInfo documentAuditInfo)
{ {
while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>(); private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move DocumentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move DocumentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
DocumentAuditInfo tmp = _CacheList[0]; // Get the first DocumentAuditInfo DocumentAuditInfo tmp = _CacheList[0]; // Get the first DocumentAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<DocumentAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<DocumentAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DocumentAuditInfo _CacheList.RemoveAt(0); // Remove the first DocumentAuditInfo
} }
} }
internal static void AddList(DocumentAuditInfoList lst) internal static void AddList(DocumentAuditInfoList lst)
{ {
foreach (DocumentAuditInfo item in lst) AddToCache(item); foreach (DocumentAuditInfo item in lst) AddToCache(item);
} }
protected static DocumentAuditInfo GetCachedByPrimaryKey(long auditID) protected static DocumentAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected DocumentAudit _Editable; protected DocumentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _DocID; }
public int DocID private int _DocID;
{ public int DocID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _DocID; {
} CanReadProperty("DocID", true);
} return _DocID;
private string _LibTitle = string.Empty; }
public string LibTitle }
{ private string _LibTitle = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string LibTitle
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _LibTitle; get
} {
} CanReadProperty("LibTitle", true);
private byte[] _DocContent; return _LibTitle;
public byte[] DocContent }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private byte[] _DocContent;
get public byte[] DocContent
{ {
return _DocContent; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _DocAscii = string.Empty; CanReadProperty("DocContent", true);
public string DocAscii return _DocContent;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _DocAscii = string.Empty;
{ public string DocAscii
return _DocAscii; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _Config = string.Empty; {
public string Config CanReadProperty("DocAscii", true);
{ return _DocAscii;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
private string _FileExtension = string.Empty; {
public string FileExtension [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("UserID", true);
{ return _UserID;
return _FileExtension; }
} }
} private string _FileExtension = string.Empty;
private byte[] _DocPdf; public string FileExtension
public byte[] DocPdf {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("FileExtension", true);
return _DocPdf; return _FileExtension;
} }
} }
private int _DeleteStatus; private byte[] _DocPdf;
public int DeleteStatus public byte[] DocPdf
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _DeleteStatus; CanReadProperty("DocPdf", true);
} return _DocPdf;
} }
// CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary }
/// <summary> private int _DeleteStatus;
/// Overrides Base ToString public int DeleteStatus
/// </summary> {
/// <returns>A string representation of current DocumentAuditInfo</returns> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
//public override string ToString() get
//{ {
// return base.ToString(); CanReadProperty("DeleteStatus", true);
//} return _DeleteStatus;
// CSLATODO: Check DocumentAuditInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> }
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality // CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary
/// </summary> /// <summary>
/// <returns>A Unique ID for the current DocumentAuditInfo</returns> /// Overrides Base ToString
protected override object GetIdValue() /// </summary>
{ /// <returns>A string representation of current DocumentAuditInfo</returns>
return MyDocumentAuditInfoUnique; // Absolutely Unique ID //public override string ToString()
} //{
#endregion // return base.ToString();
#region Factory Methods //}
private static int _DocumentAuditInfoUnique = 0; // CSLATODO: Check DocumentAuditInfo.GetIdValue to assure that the ID returned is unique
private static int DocumentAuditInfoUnique /// <summary>
{ get { return ++_DocumentAuditInfoUnique; } } /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique; /// </summary>
public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info /// <returns>A Unique ID for the current DocumentAuditInfo</returns>
{ get { return _MyDocumentAuditInfoUnique; } } protected override object GetIdValue()
protected DocumentAuditInfo() {
{/* require use of factory methods */ return MyDocumentAuditInfoUnique; // Absolutely Unique ID
AddToCache(this); }
} #endregion
public void Dispose() #region Factory Methods
{ private static int _DocumentAuditInfoUnique = 0;
RemoveFromCache(this); private static int DocumentAuditInfoUnique
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; { get { return ++_DocumentAuditInfoUnique; } }
List<DocumentAuditInfo> listDocumentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique;
while (listDocumentAuditInfo.Contains(this)) listDocumentAuditInfo.Remove(this); // Remove the item from the list public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info
if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list { get { return _MyDocumentAuditInfoUnique; } }
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list protected DocumentAuditInfo()
} {/* require use of factory methods */
public virtual DocumentAudit Get() AddToCache(this);
{ }
return _Editable = DocumentAudit.Get(_AuditID); public void Dispose()
} {
public static void Refresh(DocumentAudit tmp) RemoveFromCache(this);
{ if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
string key = tmp.AuditID.ToString(); List<DocumentAuditInfo> listDocumentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
ConvertListToDictionary(); while (listDocumentAuditInfo.Contains(this)) listDocumentAuditInfo.Remove(this); // Remove the item from the list
if (_CacheByPrimaryKey.ContainsKey(key)) if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list
foreach (DocumentAuditInfo tmpInfo in _CacheByPrimaryKey[key]) _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
tmpInfo.RefreshFields(tmp); }
} public virtual DocumentAudit Get()
protected virtual void RefreshFields(DocumentAudit tmp) {
{ return _Editable = DocumentAudit.Get(_AuditID);
_DocID = tmp.DocID; }
_LibTitle = tmp.LibTitle; public static void Refresh(DocumentAudit tmp)
_DocContent = tmp.DocContent; {
_DocAscii = tmp.DocAscii; string key = tmp.AuditID.ToString();
_Config = tmp.Config; ConvertListToDictionary();
_DTS = tmp.DTS; if (_CacheByPrimaryKey.ContainsKey(key))
_UserID = tmp.UserID; foreach (DocumentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_FileExtension = tmp.FileExtension; tmpInfo.RefreshFields(tmp);
_DocPdf = tmp.DocPdf; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(DocumentAudit tmp)
_DocumentAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _DocID = tmp.DocID;
} _LibTitle = tmp.LibTitle;
public static DocumentAuditInfo Get(long auditID) _DocContent = tmp.DocContent;
{ _DocAscii = tmp.DocAscii;
//if (!CanGetObject()) _Config = tmp.Config;
// throw new System.Security.SecurityException("User not authorized to view a DocumentAudit"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _FileExtension = tmp.FileExtension;
DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID); _DocPdf = tmp.DocPdf;
if (tmp == null) _DeleteStatus = tmp.DeleteStatus;
{ _DocumentAuditInfoExtension.Refresh(this);
tmp = DataPortal.Fetch<DocumentAuditInfo>(new PKCriteria(auditID)); OnChange();// raise an event
AddToCache(tmp); }
} public static DocumentAuditInfo Get(long auditID)
if (tmp.ErrorMessage == "No Record Found") {
{ //if (!CanGetObject())
tmp.Dispose(); // Clean-up DocumentAuditInfo // throw new System.Security.SecurityException("User not authorized to view a DocumentAudit");
tmp = null; try
} {
return tmp; DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
} if (tmp == null)
catch (Exception ex) {
{ tmp = DataPortal.Fetch<DocumentAuditInfo>(new PKCriteria(auditID));
throw new DbCslaException("Error on DocumentAuditInfo.Get", ex); AddToCache(tmp);
} }
} if (tmp.ErrorMessage == "No Record Found")
#endregion {
#region Data Access Portal tmp.Dispose(); // Clean-up DocumentAuditInfo
internal DocumentAuditInfo(SafeDataReader dr) tmp = null;
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.Constructor", GetHashCode()); return tmp;
try }
{ catch (Exception ex)
ReadData(dr); {
} throw new DbCslaException("Error on DocumentAuditInfo.Get", ex);
catch (Exception ex) }
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.Constructor", ex); #endregion
throw new DbCslaException("DocumentAuditInfo.Constructor", ex); #region Data Access Portal
} internal DocumentAuditInfo(SafeDataReader dr)
} {
[Serializable()] if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.Constructor", GetHashCode());
protected class PKCriteria try
{ {
private long _AuditID; ReadData(dr);
public long AuditID }
{ get { return _AuditID; } } catch (Exception ex)
public PKCriteria(long auditID) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.Constructor", ex);
_AuditID = auditID; throw new DbCslaException("DocumentAuditInfo.Constructor", ex);
} }
} }
private void ReadData(SafeDataReader dr) [Serializable()]
{ protected class PKCriteria
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.ReadData", GetHashCode()); {
try private long _AuditID;
{ public long AuditID
_AuditID = dr.GetInt64("AuditID"); { get { return _AuditID; } }
_DocID = dr.GetInt32("DocID"); public PKCriteria(long auditID)
_LibTitle = dr.GetString("LibTitle"); {
_DocContent = (byte[])dr.GetValue("DocContent"); _AuditID = auditID;
_DocAscii = dr.GetString("DocAscii"); }
_Config = dr.GetString("Config"); }
_DTS = dr.GetDateTime("DTS"); private void ReadData(SafeDataReader dr)
_UserID = dr.GetString("UserID"); {
_FileExtension = dr.GetString("FileExtension"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.ReadData", GetHashCode());
_DocPdf = (byte[])dr.GetValue("DocPdf"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _DocID = dr.GetInt32("DocID");
{ _LibTitle = dr.GetString("LibTitle");
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.ReadData", ex); _DocContent = (byte[])dr.GetValue("DocContent");
_ErrorMessage = ex.Message; _DocAscii = dr.GetString("DocAscii");
throw new DbCslaException("DocumentAuditInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) _FileExtension = dr.GetString("FileExtension");
{ _DocPdf = (byte[])dr.GetValue("DocPdf");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.DataPortal_Fetch", GetHashCode()); _DeleteStatus = dr.GetInt32("DeleteStatus");
try }
{ catch (Exception ex)
using (SqlConnection cn = Database.VEPROMS_SqlConnection) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.ReadData", ex);
ApplicationContext.LocalContext["cn"] = cn; _ErrorMessage = ex.Message;
using (SqlCommand cm = cn.CreateCommand()) throw new DbCslaException("DocumentAuditInfo.ReadData", ex);
{ }
cm.CommandType = CommandType.StoredProcedure; }
cm.CommandText = "getDocumentAudit"; private void DataPortal_Fetch(PKCriteria criteria)
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.DataPortal_Fetch", GetHashCode());
{ try
if (!dr.Read()) {
{ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
_ErrorMessage = "No Record Found"; {
return; ApplicationContext.LocalContext["cn"] = cn;
} using (SqlCommand cm = cn.CreateCommand())
ReadData(dr); {
} cm.CommandType = CommandType.StoredProcedure;
} cm.CommandText = "getDocumentAudit";
// removing of item only needed for local data portal cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
ApplicationContext.LocalContext.Remove("cn"); {
} if (!dr.Read())
} {
catch (Exception ex) _ErrorMessage = "No Record Found";
{ return;
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; ReadData(dr);
throw new DbCslaException("DocumentAuditInfo.DataPortal_Fetch", ex); }
} }
} // removing of item only needed for local data portal
#endregion if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
// Standard Refresh ApplicationContext.LocalContext.Remove("cn");
#region extension }
DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension(); }
[Serializable()] catch (Exception ex)
partial class DocumentAuditInfoExtension : extensionBase { } {
[Serializable()] if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.DataPortal_Fetch", ex);
class extensionBase _ErrorMessage = ex.Message;
{ throw new DbCslaException("DocumentAuditInfo.DataPortal_Fetch", ex);
// Default Refresh }
public virtual void Refresh(DocumentAuditInfo tmp) { } }
} #endregion
#endregion // Standard Refresh
} // Class #region extension
#region Converter DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension();
internal class DocumentAuditInfoConverter : ExpandableObjectConverter [Serializable()]
{ partial class DocumentAuditInfoExtension : extensionBase { }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) [Serializable()]
{ class extensionBase
if (destType == typeof(string) && value is DocumentAuditInfo) {
{ // Default Refresh
// Return the ToString value public virtual void Refresh(DocumentAuditInfo tmp) { }
return ((DocumentAuditInfo)value).ToString(); }
} #endregion
return base.ConvertTo(context, culture, value, destType); } // Class
} #region Converter
} internal class DocumentAuditInfoConverter : ExpandableObjectConverter
#endregion {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentAuditInfo)
{
// Return the ToString value
return ((DocumentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,436 +19,445 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void DROUsageInfoEvent(object sender); public delegate void DROUsageInfoEvent(object sender);
/// <summary> /// <summary>
/// DROUsageInfo Generated by MyGeneration using the CSLA Object Mapping template /// DROUsageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DROUsageInfoConverter))] [TypeConverter(typeof(DROUsageInfoConverter))]
public partial class DROUsageInfo : ReadOnlyBase<DROUsageInfo>, IDisposable public partial class DROUsageInfo : ReadOnlyBase<DROUsageInfo>, IDisposable
{ {
public event DROUsageInfoEvent Changed; public event DROUsageInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<DROUsageInfo> _CacheList = new List<DROUsageInfo>(); private static List<DROUsageInfo> _CacheList = new List<DROUsageInfo>();
protected static void AddToCache(DROUsageInfo dROUsageInfo) protected static void AddToCache(DROUsageInfo dROUsageInfo)
{ {
if (!_CacheList.Contains(dROUsageInfo)) _CacheList.Add(dROUsageInfo); // In AddToCache if (!_CacheList.Contains(dROUsageInfo)) _CacheList.Add(dROUsageInfo); // In AddToCache
} }
protected static void RemoveFromCache(DROUsageInfo dROUsageInfo) protected static void RemoveFromCache(DROUsageInfo dROUsageInfo)
{ {
while (_CacheList.Contains(dROUsageInfo)) _CacheList.Remove(dROUsageInfo); // In RemoveFromCache while (_CacheList.Contains(dROUsageInfo)) _CacheList.Remove(dROUsageInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<DROUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsageInfo>>(); private static Dictionary<string, List<DROUsageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DROUsageInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move DROUsageInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move DROUsageInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
DROUsageInfo tmp = _CacheList[0]; // Get the first DROUsageInfo DROUsageInfo tmp = _CacheList[0]; // Get the first DROUsageInfo
string pKey = tmp.DROUsageID.ToString(); string pKey = tmp.DROUsageID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<DROUsageInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<DROUsageInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DROUsageInfo _CacheList.RemoveAt(0); // Remove the first DROUsageInfo
} }
} }
internal static void AddList(DROUsageInfoList lst) internal static void AddList(DROUsageInfoList lst)
{ {
foreach (DROUsageInfo item in lst) AddToCache(item); foreach (DROUsageInfo item in lst) AddToCache(item);
} }
protected static DROUsageInfo GetCachedByPrimaryKey(int dROUsageID) protected static DROUsageInfo GetCachedByPrimaryKey(int dROUsageID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = dROUsageID.ToString(); string key = dROUsageID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected DROUsage _Editable; protected DROUsage _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _DROUsageID; private int _DROUsageID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DROUsageID public int DROUsageID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _DROUsageID; CanReadProperty("DROUsageID", true);
} return _DROUsageID;
} }
private int _DocID; }
public int DocID private int _DocID;
{ public int DocID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyDocument != null) _DocID = _MyDocument.DocID; {
return _DocID; CanReadProperty("DocID", true);
} if (_MyDocument != null) _DocID = _MyDocument.DocID;
} return _DocID;
private DocumentInfo _MyDocument; }
public DocumentInfo MyDocument }
{ private DocumentInfo _MyDocument;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public DocumentInfo MyDocument
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID); get
return _MyDocument; {
} CanReadProperty("MyDocument", true);
} if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
private string _ROID = string.Empty; return _MyDocument;
public string ROID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _ROID = string.Empty;
get public string ROID
{ {
return _ROID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _Config = string.Empty; CanReadProperty("ROID", true);
public string Config return _ROID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _Config = string.Empty;
{ public string Config
return _Config; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private DateTime _DTS = new DateTime(); {
public DateTime DTS CanReadProperty("Config", true);
{ return _Config;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private DateTime _DTS = new DateTime();
return _DTS; public DateTime DTS
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _UserID = string.Empty; get
public string UserID {
{ CanReadProperty("DTS", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _DTS;
get }
{ }
return _UserID; private string _UserID = string.Empty;
} public string UserID
} {
private int _RODbID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public int RODbID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("UserID", true);
get return _UserID;
{ }
if (_MyRODb != null) _RODbID = _MyRODb.RODbID; }
return _RODbID; private int _RODbID;
} public int RODbID
} {
private RODbInfo _MyRODb; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public RODbInfo MyRODb get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("RODbID", true);
get if (_MyRODb != null) _RODbID = _MyRODb.RODbID;
{ return _RODbID;
if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID); }
return _MyRODb; }
} private RODbInfo _MyRODb;
} public RODbInfo MyRODb
// CSLATODO: Replace base DROUsageInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current DROUsageInfo</returns> CanReadProperty("MyRODb", true);
//public override string ToString() if (_MyRODb == null && _RODbID != 0) _MyRODb = RODbInfo.Get(_RODbID);
//{ return _MyRODb;
// return base.ToString(); }
//} }
// CSLATODO: Check DROUsageInfo.GetIdValue to assure that the ID returned is unique // CSLATODO: Replace base DROUsageInfo.ToString function as necessary
/// <summary> /// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// Overrides Base ToString
/// </summary> /// </summary>
/// <returns>A Unique ID for the current DROUsageInfo</returns> /// <returns>A string representation of current DROUsageInfo</returns>
protected override object GetIdValue() //public override string ToString()
{ //{
return MyDROUsageInfoUnique; // Absolutely Unique ID // return base.ToString();
} //}
#endregion // CSLATODO: Check DROUsageInfo.GetIdValue to assure that the ID returned is unique
#region Factory Methods /// <summary>
private static int _DROUsageInfoUnique = 0; /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int DROUsageInfoUnique /// </summary>
{ get { return ++_DROUsageInfoUnique; } } /// <returns>A Unique ID for the current DROUsageInfo</returns>
private int _MyDROUsageInfoUnique = DROUsageInfoUnique; protected override object GetIdValue()
public int MyDROUsageInfoUnique // Absolutely Unique ID - Info {
{ get { return _MyDROUsageInfoUnique; } } return MyDROUsageInfoUnique; // Absolutely Unique ID
protected DROUsageInfo() }
{/* require use of factory methods */ #endregion
AddToCache(this); #region Factory Methods
} private static int _DROUsageInfoUnique = 0;
private bool _Disposed = false; private static int DROUsageInfoUnique
private static int _CountCreated = 0; { get { return ++_DROUsageInfoUnique; } }
private static int _CountDisposed = 0; private int _MyDROUsageInfoUnique = DROUsageInfoUnique;
private static int _CountFinalized = 0; public int MyDROUsageInfoUnique // Absolutely Unique ID - Info
private static int IncrementCountCreated { get { return _MyDROUsageInfoUnique; } }
{ get { return ++_CountCreated; } } protected DROUsageInfo()
private int _CountWhenCreated = IncrementCountCreated; {/* require use of factory methods */
public static int CountCreated AddToCache(this);
{ get { return _CountCreated; } } }
public static int CountNotDisposed private bool _Disposed = false;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountCreated = 0;
public static int CountNotFinalized private static int _CountDisposed = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountFinalized = 0;
~DROUsageInfo() private static int IncrementCountCreated
{ { get { return ++_CountCreated; } }
_CountFinalized++; private int _CountWhenCreated = IncrementCountCreated;
} public static int CountCreated
public void Dispose() { get { return _CountCreated; } }
{ public static int CountNotDisposed
if (_Disposed) return; { get { return _CountCreated - _CountDisposed; } }
_CountDisposed++; public static int CountNotFinalized
_Disposed = true; { get { return _CountCreated - _CountFinalized; } }
RemoveFromCache(this); ~DROUsageInfo()
if (!_CacheByPrimaryKey.ContainsKey(DROUsageID.ToString())) return; {
List<DROUsageInfo> listDROUsageInfo = _CacheByPrimaryKey[DROUsageID.ToString()]; // Get the list of items _CountFinalized++;
while (listDROUsageInfo.Contains(this)) listDROUsageInfo.Remove(this); // Remove the item from the list }
if (listDROUsageInfo.Count == 0) // If there are no items left in the list public void Dispose()
_CacheByPrimaryKey.Remove(DROUsageID.ToString()); // remove the list {
} if (_Disposed) return;
public virtual DROUsage Get() _CountDisposed++;
{ _Disposed = true;
return _Editable = DROUsage.Get(_DROUsageID); RemoveFromCache(this);
} if (!_CacheByPrimaryKey.ContainsKey(DROUsageID.ToString())) return;
public static void Refresh(DROUsage tmp) List<DROUsageInfo> listDROUsageInfo = _CacheByPrimaryKey[DROUsageID.ToString()]; // Get the list of items
{ while (listDROUsageInfo.Contains(this)) listDROUsageInfo.Remove(this); // Remove the item from the list
string key = tmp.DROUsageID.ToString(); if (listDROUsageInfo.Count == 0) // If there are no items left in the list
ConvertListToDictionary(); _CacheByPrimaryKey.Remove(DROUsageID.ToString()); // remove the list
if (_CacheByPrimaryKey.ContainsKey(key)) }
foreach (DROUsageInfo tmpInfo in _CacheByPrimaryKey[key]) public virtual DROUsage Get()
tmpInfo.RefreshFields(tmp); {
} return _Editable = DROUsage.Get(_DROUsageID);
protected virtual void RefreshFields(DROUsage tmp) }
{ public static void Refresh(DROUsage tmp)
if (_DocID != tmp.DocID) {
{ string key = tmp.DROUsageID.ToString();
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value ConvertListToDictionary();
_DocID = tmp.DocID; // Update the value if (_CacheByPrimaryKey.ContainsKey(key))
} foreach (DROUsageInfo tmpInfo in _CacheByPrimaryKey[key])
_MyDocument = null; // Reset list so that the next line gets a new list tmpInfo.RefreshFields(tmp);
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value }
_ROID = tmp.ROID; protected virtual void RefreshFields(DROUsage tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_DocID != tmp.DocID)
_UserID = tmp.UserID; {
if (_RODbID != tmp.RODbID) if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value
{ _DocID = tmp.DocID; // Update the value
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value }
_RODbID = tmp.RODbID; // Update the value _MyDocument = null; // Reset list so that the next line gets a new list
} if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value
_MyRODb = null; // Reset list so that the next line gets a new list _ROID = tmp.ROID;
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for new value _Config = tmp.Config;
_DROUsageInfoExtension.Refresh(this); _DTS = tmp.DTS;
OnChange();// raise an event _UserID = tmp.UserID;
} if (_RODbID != tmp.RODbID)
public static void Refresh(DocumentDROUsage tmp) {
{ if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value
string key = tmp.DROUsageID.ToString(); _RODbID = tmp.RODbID; // Update the value
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) _MyRODb = null; // Reset list so that the next line gets a new list
foreach (DROUsageInfo tmpInfo in _CacheByPrimaryKey[key]) if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for new value
tmpInfo.RefreshFields(tmp); _DROUsageInfoExtension.Refresh(this);
} OnChange();// raise an event
protected virtual void RefreshFields(DocumentDROUsage tmp) }
{ public static void Refresh(DocumentDROUsage tmp)
_ROID = tmp.ROID; {
_Config = tmp.Config; string key = tmp.DROUsageID.ToString();
_DTS = tmp.DTS; ConvertListToDictionary();
_UserID = tmp.UserID; if (_CacheByPrimaryKey.ContainsKey(key))
if (_RODbID != tmp.RODbID) foreach (DROUsageInfo tmpInfo in _CacheByPrimaryKey[key])
{ tmpInfo.RefreshFields(tmp);
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value }
_RODbID = tmp.RODbID; // Update the value protected virtual void RefreshFields(DocumentDROUsage tmp)
} {
_MyRODb = null; // Reset list so that the next line gets a new list _ROID = tmp.ROID;
if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for new value _Config = tmp.Config;
_DROUsageInfoExtension.Refresh(this); _DTS = tmp.DTS;
OnChange();// raise an event _UserID = tmp.UserID;
} if (_RODbID != tmp.RODbID)
public static void Refresh(RODbDROUsage tmp) {
{ if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for old value
string key = tmp.DROUsageID.ToString(); _RODbID = tmp.RODbID; // Update the value
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) _MyRODb = null; // Reset list so that the next line gets a new list
foreach (DROUsageInfo tmpInfo in _CacheByPrimaryKey[key]) if (MyRODb != null) MyRODb.RefreshRODbDROUsages(); // Update List for new value
tmpInfo.RefreshFields(tmp); _DROUsageInfoExtension.Refresh(this);
} OnChange();// raise an event
protected virtual void RefreshFields(RODbDROUsage tmp) }
{ public static void Refresh(RODbDROUsage tmp)
if (_DocID != tmp.DocID) {
{ string key = tmp.DROUsageID.ToString();
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value ConvertListToDictionary();
_DocID = tmp.DocID; // Update the value if (_CacheByPrimaryKey.ContainsKey(key))
} foreach (DROUsageInfo tmpInfo in _CacheByPrimaryKey[key])
_MyDocument = null; // Reset list so that the next line gets a new list tmpInfo.RefreshFields(tmp);
if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value }
_ROID = tmp.ROID; protected virtual void RefreshFields(RODbDROUsage tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_DocID != tmp.DocID)
_UserID = tmp.UserID; {
_DROUsageInfoExtension.Refresh(this); if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for old value
OnChange();// raise an event _DocID = tmp.DocID; // Update the value
} }
public static DROUsageInfo Get(int dROUsageID) _MyDocument = null; // Reset list so that the next line gets a new list
{ if (MyDocument != null) MyDocument.RefreshDocumentDROUsages(); // Update List for new value
//if (!CanGetObject()) _ROID = tmp.ROID;
// throw new System.Security.SecurityException("User not authorized to view a DROUsage"); _Config = tmp.Config;
try _DTS = tmp.DTS;
{ _UserID = tmp.UserID;
DROUsageInfo tmp = GetCachedByPrimaryKey(dROUsageID); _DROUsageInfoExtension.Refresh(this);
if (tmp == null) OnChange();// raise an event
{ }
tmp = DataPortal.Fetch<DROUsageInfo>(new PKCriteria(dROUsageID)); public static DROUsageInfo Get(int dROUsageID)
AddToCache(tmp); {
} //if (!CanGetObject())
if (tmp.ErrorMessage == "No Record Found") // throw new System.Security.SecurityException("User not authorized to view a DROUsage");
{ try
tmp.Dispose(); // Clean-up DROUsageInfo {
tmp = null; DROUsageInfo tmp = GetCachedByPrimaryKey(dROUsageID);
} if (tmp == null)
return tmp; {
} tmp = DataPortal.Fetch<DROUsageInfo>(new PKCriteria(dROUsageID));
catch (Exception ex) AddToCache(tmp);
{ }
throw new DbCslaException("Error on DROUsageInfo.Get", ex); if (tmp.ErrorMessage == "No Record Found")
} {
} tmp.Dispose(); // Clean-up DROUsageInfo
#endregion tmp = null;
#region Data Access Portal }
internal DROUsageInfo(SafeDataReader dr) return tmp;
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfo.Constructor", GetHashCode()); catch (Exception ex)
try {
{ throw new DbCslaException("Error on DROUsageInfo.Get", ex);
ReadData(dr); }
} }
catch (Exception ex) #endregion
{ #region Data Access Portal
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfo.Constructor", ex); internal DROUsageInfo(SafeDataReader dr)
throw new DbCslaException("DROUsageInfo.Constructor", ex); {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfo.Constructor", GetHashCode());
} try
[Serializable()] {
protected class PKCriteria ReadData(dr);
{ }
private int _DROUsageID; catch (Exception ex)
public int DROUsageID {
{ get { return _DROUsageID; } } if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfo.Constructor", ex);
public PKCriteria(int dROUsageID) throw new DbCslaException("DROUsageInfo.Constructor", ex);
{ }
_DROUsageID = dROUsageID; }
} [Serializable()]
} protected class PKCriteria
private void ReadData(SafeDataReader dr) {
{ private int _DROUsageID;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfo.ReadData", GetHashCode()); public int DROUsageID
try { get { return _DROUsageID; } }
{ public PKCriteria(int dROUsageID)
_DROUsageID = dr.GetInt32("DROUsageID"); {
_DocID = dr.GetInt32("DocID"); _DROUsageID = dROUsageID;
_ROID = dr.GetString("ROID"); }
_Config = dr.GetString("Config"); }
_DTS = dr.GetDateTime("DTS"); private void ReadData(SafeDataReader dr)
_UserID = dr.GetString("UserID"); {
_RODbID = dr.GetInt32("RODbID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfo.ReadData", GetHashCode());
} try
catch (Exception ex) {
{ _DROUsageID = dr.GetInt32("DROUsageID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfo.ReadData", ex); _DocID = dr.GetInt32("DocID");
_ErrorMessage = ex.Message; _ROID = dr.GetString("ROID");
throw new DbCslaException("DROUsageInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) _RODbID = dr.GetInt32("RODbID");
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfo.DataPortal_Fetch", GetHashCode()); catch (Exception ex)
try {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfo.ReadData", ex);
using (SqlConnection cn = Database.VEPROMS_SqlConnection) _ErrorMessage = ex.Message;
{ throw new DbCslaException("DROUsageInfo.ReadData", ex);
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) }
{ private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandType = CommandType.StoredProcedure; {
cm.CommandText = "getDROUsage"; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DROUsageInfo.DataPortal_Fetch", GetHashCode());
cm.Parameters.AddWithValue("@DROUsageID", criteria.DROUsageID); try
cm.CommandTimeout = Database.DefaultTimeout; {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
if (!dr.Read()) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
_ErrorMessage = "No Record Found"; {
return; cm.CommandType = CommandType.StoredProcedure;
} cm.CommandText = "getDROUsage";
ReadData(dr); cm.Parameters.AddWithValue("@DROUsageID", criteria.DROUsageID);
} cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// removing of item only needed for local data portal {
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) if (!dr.Read())
ApplicationContext.LocalContext.Remove("cn"); {
} _ErrorMessage = "No Record Found";
} return;
catch (Exception ex) }
{ ReadData(dr);
if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; }
throw new DbCslaException("DROUsageInfo.DataPortal_Fetch", ex); // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
#endregion }
// Standard Refresh }
#region extension catch (Exception ex)
DROUsageInfoExtension _DROUsageInfoExtension = new DROUsageInfoExtension(); {
[Serializable()] if (_MyLog.IsErrorEnabled) _MyLog.Error("DROUsageInfo.DataPortal_Fetch", ex);
partial class DROUsageInfoExtension : extensionBase { } _ErrorMessage = ex.Message;
[Serializable()] throw new DbCslaException("DROUsageInfo.DataPortal_Fetch", ex);
class extensionBase }
{ }
// Default Refresh #endregion
public virtual void Refresh(DROUsageInfo tmp) { } // Standard Refresh
} #region extension
#endregion DROUsageInfoExtension _DROUsageInfoExtension = new DROUsageInfoExtension();
} // Class [Serializable()]
#region Converter partial class DROUsageInfoExtension : extensionBase { }
internal class DROUsageInfoConverter : ExpandableObjectConverter [Serializable()]
{ class extensionBase
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) {
{ // Default Refresh
if (destType == typeof(string) && value is DROUsageInfo) public virtual void Refresh(DROUsageInfo tmp) { }
{ }
// Return the ToString value #endregion
return ((DROUsageInfo)value).ToString(); } // Class
} #region Converter
return base.ConvertTo(context, culture, value, destType); internal class DROUsageInfoConverter : ExpandableObjectConverter
} {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
#endregion {
if (destType == typeof(string) && value is DROUsageInfo)
{
// Return the ToString value
return ((DROUsageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,389 +19,397 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void DetailInfoEvent(object sender); public delegate void DetailInfoEvent(object sender);
/// <summary> /// <summary>
/// DetailInfo Generated by MyGeneration using the CSLA Object Mapping template /// DetailInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DetailInfoConverter))] [TypeConverter(typeof(DetailInfoConverter))]
public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable public partial class DetailInfo : ReadOnlyBase<DetailInfo>, IDisposable
{ {
public event DetailInfoEvent Changed; public event DetailInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<DetailInfo> _CacheList = new List<DetailInfo>(); private static List<DetailInfo> _CacheList = new List<DetailInfo>();
protected static void AddToCache(DetailInfo detailInfo) protected static void AddToCache(DetailInfo detailInfo)
{ {
if (!_CacheList.Contains(detailInfo)) _CacheList.Add(detailInfo); // In AddToCache if (!_CacheList.Contains(detailInfo)) _CacheList.Add(detailInfo); // In AddToCache
} }
protected static void RemoveFromCache(DetailInfo detailInfo) protected static void RemoveFromCache(DetailInfo detailInfo)
{ {
while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache while (_CacheList.Contains(detailInfo)) _CacheList.Remove(detailInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>(); private static Dictionary<string, List<DetailInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DetailInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move DetailInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move DetailInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
DetailInfo tmp = _CacheList[0]; // Get the first DetailInfo DetailInfo tmp = _CacheList[0]; // Get the first DetailInfo
string pKey = tmp.DetailID.ToString(); string pKey = tmp.DetailID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<DetailInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<DetailInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DetailInfo _CacheList.RemoveAt(0); // Remove the first DetailInfo
} }
} }
internal static void AddList(DetailInfoList lst) internal static void AddList(DetailInfoList lst)
{ {
foreach (DetailInfo item in lst) AddToCache(item); foreach (DetailInfo item in lst) AddToCache(item);
} }
protected static DetailInfo GetCachedByPrimaryKey(int detailID) protected static DetailInfo GetCachedByPrimaryKey(int detailID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = detailID.ToString(); string key = detailID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Detail _Editable; protected Detail _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _DetailID; private int _DetailID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DetailID public int DetailID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _DetailID; CanReadProperty("DetailID", true);
} return _DetailID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyContent != null) _ContentID = _MyContent.ContentID; {
return _ContentID; CanReadProperty("ContentID", true);
} if (_MyContent != null) _ContentID = _MyContent.ContentID;
} return _ContentID;
private ContentInfo _MyContent; }
public ContentInfo MyContent }
{ private ContentInfo _MyContent;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public ContentInfo MyContent
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); get
return _MyContent; {
} CanReadProperty("MyContent", true);
} if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
private int _ItemType; return _MyContent;
public int ItemType }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _ItemType;
get public int ItemType
{ {
return _ItemType; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _Text = string.Empty; CanReadProperty("ItemType", true);
public string Text return _ItemType;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _Text = string.Empty;
{ public string Text
return _Text; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _Config = string.Empty; {
public string Config CanReadProperty("Text", true);
{ return _Text;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
// CSLATODO: Replace base DetailInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current DetailInfo</returns> CanReadProperty("UserID", true);
//public override string ToString() return _UserID;
//{ }
// return base.ToString(); }
//} // CSLATODO: Replace base DetailInfo.ToString function as necessary
// CSLATODO: Check DetailInfo.GetIdValue to assure that the ID returned is unique /// <summary>
/// <summary> /// Overrides Base ToString
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// </summary>
/// </summary> /// <returns>A string representation of current DetailInfo</returns>
/// <returns>A Unique ID for the current DetailInfo</returns> //public override string ToString()
protected override object GetIdValue() //{
{ // return base.ToString();
return MyDetailInfoUnique; // Absolutely Unique ID //}
} // CSLATODO: Check DetailInfo.GetIdValue to assure that the ID returned is unique
#endregion /// <summary>
#region Factory Methods /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int _DetailInfoUnique = 0; /// </summary>
private static int DetailInfoUnique /// <returns>A Unique ID for the current DetailInfo</returns>
{ get { return ++_DetailInfoUnique; } } protected override object GetIdValue()
private int _MyDetailInfoUnique = DetailInfoUnique; {
public int MyDetailInfoUnique // Absolutely Unique ID - Info return MyDetailInfoUnique; // Absolutely Unique ID
{ get { return _MyDetailInfoUnique; } } }
protected DetailInfo() #endregion
{/* require use of factory methods */ #region Factory Methods
AddToCache(this); private static int _DetailInfoUnique = 0;
} private static int DetailInfoUnique
private bool _Disposed = false; { get { return ++_DetailInfoUnique; } }
private static int _CountCreated = 0; private int _MyDetailInfoUnique = DetailInfoUnique;
private static int _CountDisposed = 0; public int MyDetailInfoUnique // Absolutely Unique ID - Info
private static int _CountFinalized = 0; { get { return _MyDetailInfoUnique; } }
private static int IncrementCountCreated protected DetailInfo()
{ get { return ++_CountCreated; } } {/* require use of factory methods */
private int _CountWhenCreated = IncrementCountCreated; AddToCache(this);
public static int CountCreated }
{ get { return _CountCreated; } } private bool _Disposed = false;
public static int CountNotDisposed private static int _CountCreated = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountDisposed = 0;
public static int CountNotFinalized private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int IncrementCountCreated
~DetailInfo() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
_CountFinalized++; public static int CountCreated
} { get { return _CountCreated; } }
public void Dispose() public static int CountNotDisposed
{ { get { return _CountCreated - _CountDisposed; } }
if (_Disposed) return; public static int CountNotFinalized
_CountDisposed++; { get { return _CountCreated - _CountFinalized; } }
_Disposed = true; ~DetailInfo()
RemoveFromCache(this); {
if (!_CacheByPrimaryKey.ContainsKey(DetailID.ToString())) return; _CountFinalized++;
List<DetailInfo> listDetailInfo = _CacheByPrimaryKey[DetailID.ToString()]; // Get the list of items }
while (listDetailInfo.Contains(this)) listDetailInfo.Remove(this); // Remove the item from the list public void Dispose()
if (listDetailInfo.Count == 0) // If there are no items left in the list {
_CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list if (_Disposed) return;
} _CountDisposed++;
public virtual Detail Get() _Disposed = true;
{ RemoveFromCache(this);
return _Editable = Detail.Get(_DetailID); if (!_CacheByPrimaryKey.ContainsKey(DetailID.ToString())) return;
} List<DetailInfo> listDetailInfo = _CacheByPrimaryKey[DetailID.ToString()]; // Get the list of items
public static void Refresh(Detail tmp) while (listDetailInfo.Contains(this)) listDetailInfo.Remove(this); // Remove the item from the list
{ if (listDetailInfo.Count == 0) // If there are no items left in the list
string key = tmp.DetailID.ToString(); _CacheByPrimaryKey.Remove(DetailID.ToString()); // remove the list
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) public virtual Detail Get()
foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key]) {
tmpInfo.RefreshFields(tmp); return _Editable = Detail.Get(_DetailID);
} }
protected virtual void RefreshFields(Detail tmp) public static void Refresh(Detail tmp)
{ {
if (_ContentID != tmp.ContentID) string key = tmp.DetailID.ToString();
{ ConvertListToDictionary();
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_ContentID = tmp.ContentID; // Update the value foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyContent = null; // Reset list so that the next line gets a new list }
if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value protected virtual void RefreshFields(Detail tmp)
_ItemType = tmp.ItemType; {
_Text = tmp.Text; if (_ContentID != tmp.ContentID)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for old value
_UserID = tmp.UserID; _ContentID = tmp.ContentID; // Update the value
_DetailInfoExtension.Refresh(this); }
OnChange();// raise an event _MyContent = null; // Reset list so that the next line gets a new list
} if (MyContent != null) MyContent.RefreshContentDetails(); // Update List for new value
public static void Refresh(ContentDetail tmp) _ItemType = tmp.ItemType;
{ _Text = tmp.Text;
string key = tmp.DetailID.ToString(); _Config = tmp.Config;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key]) _DetailInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(ContentDetail tmp) public static void Refresh(ContentDetail tmp)
{ {
_ItemType = tmp.ItemType; string key = tmp.DetailID.ToString();
_Text = tmp.Text; ConvertListToDictionary();
_Config = tmp.Config; if (_CacheByPrimaryKey.ContainsKey(key))
_DTS = tmp.DTS; foreach (DetailInfo tmpInfo in _CacheByPrimaryKey[key])
_UserID = tmp.UserID; tmpInfo.RefreshFields(tmp);
_DetailInfoExtension.Refresh(this); }
OnChange();// raise an event protected virtual void RefreshFields(ContentDetail tmp)
} {
public static DetailInfo Get(int detailID) _ItemType = tmp.ItemType;
{ _Text = tmp.Text;
//if (!CanGetObject()) _Config = tmp.Config;
// throw new System.Security.SecurityException("User not authorized to view a Detail"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _DetailInfoExtension.Refresh(this);
DetailInfo tmp = GetCachedByPrimaryKey(detailID); OnChange();// raise an event
if (tmp == null) }
{ public static DetailInfo Get(int detailID)
tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID)); {
AddToCache(tmp); //if (!CanGetObject())
} // throw new System.Security.SecurityException("User not authorized to view a Detail");
if (tmp.ErrorMessage == "No Record Found") try
{ {
tmp.Dispose(); // Clean-up DetailInfo DetailInfo tmp = GetCachedByPrimaryKey(detailID);
tmp = null; if (tmp == null)
} {
return tmp; tmp = DataPortal.Fetch<DetailInfo>(new PKCriteria(detailID));
} AddToCache(tmp);
catch (Exception ex) }
{ if (tmp.ErrorMessage == "No Record Found")
throw new DbCslaException("Error on DetailInfo.Get", ex); {
} tmp.Dispose(); // Clean-up DetailInfo
} tmp = null;
#endregion }
#region Data Access Portal return tmp;
internal DetailInfo(SafeDataReader dr) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode()); {
try throw new DbCslaException("Error on DetailInfo.Get", ex);
{ }
ReadData(dr); }
} #endregion
catch (Exception ex) #region Data Access Portal
{ internal DetailInfo(SafeDataReader dr)
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.Constructor", ex); {
throw new DbCslaException("DetailInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.Constructor", GetHashCode());
} try
} {
[Serializable()] ReadData(dr);
protected class PKCriteria }
{ catch (Exception ex)
private int _DetailID; {
public int DetailID if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.Constructor", ex);
{ get { return _DetailID; } } throw new DbCslaException("DetailInfo.Constructor", ex);
public PKCriteria(int detailID) }
{ }
_DetailID = detailID; [Serializable()]
} protected class PKCriteria
} {
private void ReadData(SafeDataReader dr) private int _DetailID;
{ public int DetailID
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode()); { get { return _DetailID; } }
try public PKCriteria(int detailID)
{ {
_DetailID = dr.GetInt32("DetailID"); _DetailID = detailID;
_ContentID = dr.GetInt32("ContentID"); }
_ItemType = dr.GetInt32("ItemType"); }
_Text = dr.GetString("Text"); private void ReadData(SafeDataReader dr)
_Config = dr.GetString("Config"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
} {
catch (Exception ex) _DetailID = dr.GetInt32("DetailID");
{ _ContentID = dr.GetInt32("ContentID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.ReadData", ex); _ItemType = dr.GetInt32("ItemType");
_ErrorMessage = ex.Message; _Text = dr.GetString("Text");
throw new DbCslaException("DetailInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.DataPortal_Fetch", GetHashCode()); {
try if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
using (SqlConnection cn = Database.VEPROMS_SqlConnection) throw new DbCslaException("DetailInfo.ReadData", ex);
{ }
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) private void DataPortal_Fetch(PKCriteria criteria)
{ {
cm.CommandType = CommandType.StoredProcedure; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DetailInfo.DataPortal_Fetch", GetHashCode());
cm.CommandText = "getDetail"; try
cm.Parameters.AddWithValue("@DetailID", criteria.DetailID); {
cm.CommandTimeout = Database.DefaultTimeout; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ ApplicationContext.LocalContext["cn"] = cn;
if (!dr.Read()) using (SqlCommand cm = cn.CreateCommand())
{ {
_ErrorMessage = "No Record Found"; cm.CommandType = CommandType.StoredProcedure;
return; cm.CommandText = "getDetail";
} cm.Parameters.AddWithValue("@DetailID", criteria.DetailID);
ReadData(dr); cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
// removing of item only needed for local data portal if (!dr.Read())
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); _ErrorMessage = "No Record Found";
} return;
} }
catch (Exception ex) ReadData(dr);
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; // removing of item only needed for local data portal
throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
} }
#endregion }
// Standard Refresh catch (Exception ex)
#region extension {
DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension(); if (_MyLog.IsErrorEnabled) _MyLog.Error("DetailInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
partial class DetailInfoExtension : extensionBase { } throw new DbCslaException("DetailInfo.DataPortal_Fetch", ex);
[Serializable()] }
class extensionBase }
{ #endregion
// Default Refresh // Standard Refresh
public virtual void Refresh(DetailInfo tmp) { } #region extension
} DetailInfoExtension _DetailInfoExtension = new DetailInfoExtension();
#endregion [Serializable()]
} // Class partial class DetailInfoExtension : extensionBase { }
#region Converter [Serializable()]
internal class DetailInfoConverter : ExpandableObjectConverter class extensionBase
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) // Default Refresh
{ public virtual void Refresh(DetailInfo tmp) { }
if (destType == typeof(string) && value is DetailInfo) }
{ #endregion
// Return the ToString value } // Class
return ((DetailInfo)value).ToString(); #region Converter
} internal class DetailInfoConverter : ExpandableObjectConverter
return base.ConvertTo(context, culture, value, destType); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
#endregion if (destType == typeof(string) && value is DetailInfo)
{
// Return the ToString value
return ((DetailInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,387 +19,397 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void DocumentAuditInfoEvent(object sender); public delegate void DocumentAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// DocumentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// DocumentAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DocumentAuditInfoConverter))] [TypeConverter(typeof(DocumentAuditInfoConverter))]
public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable public partial class DocumentAuditInfo : ReadOnlyBase<DocumentAuditInfo>, IDisposable
{ {
public event DocumentAuditInfoEvent Changed; public event DocumentAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>(); private static List<DocumentAuditInfo> _CacheList = new List<DocumentAuditInfo>();
protected static void AddToCache(DocumentAuditInfo documentAuditInfo) protected static void AddToCache(DocumentAuditInfo documentAuditInfo)
{ {
if (!_CacheList.Contains(documentAuditInfo)) _CacheList.Add(documentAuditInfo); // In AddToCache if (!_CacheList.Contains(documentAuditInfo)) _CacheList.Add(documentAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(DocumentAuditInfo documentAuditInfo) protected static void RemoveFromCache(DocumentAuditInfo documentAuditInfo)
{ {
while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache while (_CacheList.Contains(documentAuditInfo)) _CacheList.Remove(documentAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>(); private static Dictionary<string, List<DocumentAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move DocumentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move DocumentAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
DocumentAuditInfo tmp = _CacheList[0]; // Get the first DocumentAuditInfo DocumentAuditInfo tmp = _CacheList[0]; // Get the first DocumentAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<DocumentAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<DocumentAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DocumentAuditInfo _CacheList.RemoveAt(0); // Remove the first DocumentAuditInfo
} }
} }
internal static void AddList(DocumentAuditInfoList lst) internal static void AddList(DocumentAuditInfoList lst)
{ {
foreach (DocumentAuditInfo item in lst) AddToCache(item); foreach (DocumentAuditInfo item in lst) AddToCache(item);
} }
protected static DocumentAuditInfo GetCachedByPrimaryKey(long auditID) protected static DocumentAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected DocumentAudit _Editable; protected DocumentAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _DocID; }
public int DocID private int _DocID;
{ public int DocID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _DocID; {
} CanReadProperty("DocID", true);
} return _DocID;
private string _LibTitle = string.Empty; }
public string LibTitle }
{ private string _LibTitle = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string LibTitle
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _LibTitle; get
} {
} CanReadProperty("LibTitle", true);
private byte[] _DocContent; return _LibTitle;
public byte[] DocContent }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private byte[] _DocContent;
get public byte[] DocContent
{ {
return _DocContent; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _DocAscii = string.Empty; CanReadProperty("DocContent", true);
public string DocAscii return _DocContent;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _DocAscii = string.Empty;
{ public string DocAscii
return _DocAscii; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _Config = string.Empty; {
public string Config CanReadProperty("DocAscii", true);
{ return _DocAscii;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
private string _FileExtension = string.Empty; {
public string FileExtension [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("UserID", true);
{ return _UserID;
return _FileExtension; }
} }
} private string _FileExtension = string.Empty;
private int _DeleteStatus; public string FileExtension
public int DeleteStatus {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("FileExtension", true);
return _DeleteStatus; return _FileExtension;
} }
} }
// CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary private int _DeleteStatus;
/// <summary> public int DeleteStatus
/// Overrides Base ToString {
/// </summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <returns>A string representation of current DocumentAuditInfo</returns> get
//public override string ToString() {
//{ CanReadProperty("DeleteStatus", true);
// return base.ToString(); return _DeleteStatus;
//} }
// CSLATODO: Check DocumentAuditInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base DocumentAuditInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current DocumentAuditInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current DocumentAuditInfo</returns>
{ //public override string ToString()
return MyDocumentAuditInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check DocumentAuditInfo.GetIdValue to assure that the ID returned is unique
private static int _DocumentAuditInfoUnique = 0; /// <summary>
private static int DocumentAuditInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_DocumentAuditInfoUnique; } } /// </summary>
private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique; /// <returns>A Unique ID for the current DocumentAuditInfo</returns>
public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyDocumentAuditInfoUnique; } } {
protected DocumentAuditInfo() return MyDocumentAuditInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
private bool _Disposed = false; private static int _DocumentAuditInfoUnique = 0;
private static int _CountCreated = 0; private static int DocumentAuditInfoUnique
private static int _CountDisposed = 0; { get { return ++_DocumentAuditInfoUnique; } }
private static int _CountFinalized = 0; private int _MyDocumentAuditInfoUnique = DocumentAuditInfoUnique;
private static int IncrementCountCreated public int MyDocumentAuditInfoUnique // Absolutely Unique ID - Info
{ get { return ++_CountCreated; } } { get { return _MyDocumentAuditInfoUnique; } }
private int _CountWhenCreated = IncrementCountCreated; protected DocumentAuditInfo()
public static int CountCreated {/* require use of factory methods */
{ get { return _CountCreated; } } AddToCache(this);
public static int CountNotDisposed }
{ get { return _CountCreated - _CountDisposed; } } private bool _Disposed = false;
public static int CountNotFinalized private static int _CountCreated = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountDisposed = 0;
~DocumentAuditInfo() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
_CountFinalized++; { get { return ++_CountCreated; } }
} private int _CountWhenCreated = IncrementCountCreated;
public void Dispose() public static int CountCreated
{ { get { return _CountCreated; } }
if (_Disposed) return; public static int CountNotDisposed
_CountDisposed++; { get { return _CountCreated - _CountDisposed; } }
_Disposed = true; public static int CountNotFinalized
RemoveFromCache(this); { get { return _CountCreated - _CountFinalized; } }
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; ~DocumentAuditInfo()
List<DocumentAuditInfo> listDocumentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items {
while (listDocumentAuditInfo.Contains(this)) listDocumentAuditInfo.Remove(this); // Remove the item from the list _CountFinalized++;
if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list public void Dispose()
} {
public virtual DocumentAudit Get() if (_Disposed) return;
{ _CountDisposed++;
return _Editable = DocumentAudit.Get(_AuditID); _Disposed = true;
} RemoveFromCache(this);
public static void Refresh(DocumentAudit tmp) if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
{ List<DocumentAuditInfo> listDocumentAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
string key = tmp.AuditID.ToString(); while (listDocumentAuditInfo.Contains(this)) listDocumentAuditInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listDocumentAuditInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
foreach (DocumentAuditInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual DocumentAudit Get()
} {
protected virtual void RefreshFields(DocumentAudit tmp) return _Editable = DocumentAudit.Get(_AuditID);
{ }
_DocID = tmp.DocID; public static void Refresh(DocumentAudit tmp)
_LibTitle = tmp.LibTitle; {
_DocContent = tmp.DocContent; string key = tmp.AuditID.ToString();
_DocAscii = tmp.DocAscii; ConvertListToDictionary();
_Config = tmp.Config; if (_CacheByPrimaryKey.ContainsKey(key))
_DTS = tmp.DTS; foreach (DocumentAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_UserID = tmp.UserID; tmpInfo.RefreshFields(tmp);
_FileExtension = tmp.FileExtension; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(DocumentAudit tmp)
_DocumentAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _DocID = tmp.DocID;
} _LibTitle = tmp.LibTitle;
public static DocumentAuditInfo Get(long auditID) _DocContent = tmp.DocContent;
{ _DocAscii = tmp.DocAscii;
//if (!CanGetObject()) _Config = tmp.Config;
// throw new System.Security.SecurityException("User not authorized to view a DocumentAudit"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _FileExtension = tmp.FileExtension;
DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID); _DeleteStatus = tmp.DeleteStatus;
if (tmp == null) _DocumentAuditInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<DocumentAuditInfo>(new PKCriteria(auditID)); }
AddToCache(tmp); public static DocumentAuditInfo Get(long auditID)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a DocumentAudit");
tmp.Dispose(); // Clean-up DocumentAuditInfo try
tmp = null; {
} DocumentAuditInfo tmp = GetCachedByPrimaryKey(auditID);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<DocumentAuditInfo>(new PKCriteria(auditID));
{ AddToCache(tmp);
throw new DbCslaException("Error on DocumentAuditInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up DocumentAuditInfo
#region Data Access Portal tmp = null;
internal DocumentAuditInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on DocumentAuditInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("DocumentAuditInfo.Constructor", ex); internal DocumentAuditInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private long _AuditID; }
public long AuditID catch (Exception ex)
{ get { return _AuditID; } } {
public PKCriteria(long auditID) if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.Constructor", ex);
{ throw new DbCslaException("DocumentAuditInfo.Constructor", ex);
_AuditID = auditID; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.ReadData", GetHashCode()); private long _AuditID;
try public long AuditID
{ { get { return _AuditID; } }
_AuditID = dr.GetInt64("AuditID"); public PKCriteria(long auditID)
_DocID = dr.GetInt32("DocID"); {
_LibTitle = dr.GetString("LibTitle"); _AuditID = auditID;
_DocContent = (byte[])dr.GetValue("DocContent"); }
_DocAscii = dr.GetString("DocAscii"); }
_Config = dr.GetString("Config"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.ReadData", GetHashCode());
_FileExtension = dr.GetString("FileExtension"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _DocID = dr.GetInt32("DocID");
{ _LibTitle = dr.GetString("LibTitle");
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.ReadData", ex); _DocContent = (byte[])dr.GetValue("DocContent");
_ErrorMessage = ex.Message; _DocAscii = dr.GetString("DocAscii");
throw new DbCslaException("DocumentAuditInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) _FileExtension = dr.GetString("FileExtension");
{ _DeleteStatus = dr.GetInt32("DeleteStatus");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("DocumentAuditInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getDocumentAudit"; {
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentAuditInfo.DataPortal_Fetch", GetHashCode());
cm.CommandTimeout = Database.DefaultTimeout; try
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
if (!dr.Read()) {
{ ApplicationContext.LocalContext["cn"] = cn;
_ErrorMessage = "No Record Found"; using (SqlCommand cm = cn.CreateCommand())
return; {
} cm.CommandType = CommandType.StoredProcedure;
ReadData(dr); cm.CommandText = "getDocumentAudit";
} cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
} cm.CommandTimeout = Database.DefaultTimeout;
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("DocumentAuditInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class DocumentAuditInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentAuditInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("DocumentAuditInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(DocumentAuditInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class DocumentAuditInfoExtension _DocumentAuditInfoExtension = new DocumentAuditInfoExtension();
#region Converter [Serializable()]
internal class DocumentAuditInfoConverter : ExpandableObjectConverter partial class DocumentAuditInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is DocumentAuditInfo) // Default Refresh
{ public virtual void Refresh(DocumentAuditInfo tmp) { }
// Return the ToString value }
return ((DocumentAuditInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class DocumentAuditInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentAuditInfo)
{
// Return the ToString value
return ((DocumentAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -20,445 +20,458 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// DocumentEntry Generated by MyGeneration using the CSLA Object Mapping template /// DocumentEntry Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DocumentEntryConverter))] [TypeConverter(typeof(DocumentEntryConverter))]
public partial class DocumentEntry : BusinessBase<DocumentEntry>, IVEHasBrokenRules, IDisposable public partial class DocumentEntry : BusinessBase<DocumentEntry>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _ContentID; private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int ContentID public int ContentID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyEntry != null) _ContentID = _MyEntry.ContentID; CanReadProperty("ContentID", true);
return _ContentID; if (_MyEntry != null) _ContentID = _MyEntry.ContentID;
} return _ContentID;
} }
private Entry _MyEntry; }
[System.ComponentModel.DataObjectField(true, true)] private Entry _MyEntry;
public Entry MyEntry [System.ComponentModel.DataObjectField(true, true)]
{ public Entry MyEntry
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID); {
return _MyEntry; CanReadProperty("MyEntry", true);
} if (_MyEntry == null && _ContentID != 0) _MyEntry = Entry.Get(_ContentID);
} return _MyEntry;
private DateTime _DTS = new DateTime(); }
public DateTime DTS }
{ private DateTime _DTS = new DateTime();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public DateTime DTS
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _DTS; get
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
set return _DTS;
{ }
if (_DTS != value) [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ set
_DTS = value; {
PropertyHasChanged(); CanWriteProperty("DTS", true);
} if (_DTS != value)
} {
} _DTS = value;
private string _UserID = string.Empty; PropertyHasChanged();
public string UserID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _UserID = string.Empty;
{ public string UserID
return _UserID; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
set {
{ CanReadProperty("UserID", true);
if (value == null) value = string.Empty; return _UserID;
if (_UserID != value) }
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_UserID = value; set
PropertyHasChanged(); {
} CanWriteProperty("UserID", true);
} if (value == null) value = string.Empty;
} if (_UserID != value)
private byte[] _LastChanged = new byte[8];//timestamp {
private string _Content_Number = string.Empty; _UserID = value;
/// <summary> PropertyHasChanged();
/// Increased from 30 to 256 to support RTF symbols }
/// </summary> }
public string Content_Number }
{ private byte[] _LastChanged = new byte[8];//timestamp
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Content_Number = string.Empty;
get /// <summary>
{ /// Increased from 30 to 256 to support RTF symbols
return _Content_Number; /// </summary>
} public string Content_Number
} {
private string _Content_Text = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string Content_Text get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("Content_Number", true);
get return _Content_Number;
{ }
return _Content_Text; }
} private string _Content_Text = string.Empty;
} public string Content_Text
private int? _Content_Type; {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// 0 - Procedure, 10000 - Section, 20000 Step get
/// </summary> {
public int? Content_Type CanReadProperty("Content_Text", true);
{ return _Content_Text;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int? _Content_Type;
return _Content_Type; /// <summary>
} /// 0 - Procedure, 10000 - Section, 20000 Step
} /// </summary>
private int? _Content_FormatID; public int? Content_Type
public int? Content_FormatID {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("Content_Type", true);
return _Content_FormatID; return _Content_Type;
} }
} }
private string _Content_Config = string.Empty; private int? _Content_FormatID;
public string Content_Config public int? Content_FormatID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _Content_Config; CanReadProperty("Content_FormatID", true);
} return _Content_FormatID;
} }
private DateTime _Content_DTS = new DateTime(); }
public DateTime Content_DTS private string _Content_Config = string.Empty;
{ public string Content_Config
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _Content_DTS; {
} CanReadProperty("Content_Config", true);
} return _Content_Config;
private string _Content_UserID = string.Empty; }
public string Content_UserID }
{ private DateTime _Content_DTS = new DateTime();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public DateTime Content_DTS
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Content_UserID; get
} {
} CanReadProperty("Content_DTS", true);
// CSLATODO: Check DocumentEntry.GetIdValue to assure that the ID returned is unique return _Content_DTS;
/// <summary> }
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality }
/// </summary> private string _Content_UserID = string.Empty;
/// <returns>A Unique ID for the current DocumentEntry</returns> public string Content_UserID
protected override object GetIdValue() {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return MyDocumentEntryUnique; // Absolutely Unique ID get
} {
// CSLATODO: Replace base DocumentEntry.ToString function as necessary CanReadProperty("Content_UserID", true);
/// <summary> return _Content_UserID;
/// Overrides Base ToString }
/// </summary> }
/// <returns>A string representation of current DocumentEntry</returns> // CSLATODO: Check DocumentEntry.GetIdValue to assure that the ID returned is unique
//public override string ToString() /// <summary>
//{ /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
// return base.ToString(); /// </summary>
//} /// <returns>A Unique ID for the current DocumentEntry</returns>
public override bool IsDirty protected override object GetIdValue()
{ {
get { return base.IsDirty; } return MyDocumentEntryUnique; // Absolutely Unique ID
} }
public bool IsDirtyList(List<object> list) // CSLATODO: Replace base DocumentEntry.ToString function as necessary
{ /// <summary>
return base.IsDirty; /// Overrides Base ToString
} /// </summary>
public override bool IsValid /// <returns>A string representation of current DocumentEntry</returns>
{ //public override string ToString()
get { return (IsNew && !IsDirty) ? true : base.IsValid; } //{
} // return base.ToString();
public bool IsValidList(List<object> list) //}
{ public override bool IsDirty
return (IsNew && !IsDirty) ? true : base.IsValid; {
} get { return base.IsDirty; }
#endregion }
#region ValidationRules public bool IsDirtyList(List<object> list)
[NonSerialized] {
private bool _CheckingBrokenRules = false; return base.IsDirty;
public IVEHasBrokenRules HasBrokenRules }
{ public override bool IsValid
get {
{ get { return (IsNew && !IsDirty) ? true : base.IsValid; }
if (_CheckingBrokenRules) return null; }
if (BrokenRulesCollection.Count > 0) return this; public bool IsValidList(List<object> list)
try {
{ return (IsNew && !IsDirty) ? true : base.IsValid;
_CheckingBrokenRules = true; }
IVEHasBrokenRules hasBrokenRules = null; #endregion
return hasBrokenRules; #region ValidationRules
} [NonSerialized]
finally private bool _CheckingBrokenRules = false;
{ public IVEHasBrokenRules HasBrokenRules
_CheckingBrokenRules = false; {
} get
} {
} if (_CheckingBrokenRules) return null;
public BrokenRulesCollection BrokenRules if (BrokenRulesCollection.Count > 0) return this;
{ try
get {
{ _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = null;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; return hasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); }
} finally
} {
protected override void AddBusinessRules() _CheckingBrokenRules = false;
{ }
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringRequired, "UserID"); }
ValidationRules.AddRule( public BrokenRulesCollection BrokenRules
Csla.Validation.CommonRules.StringMaxLength, {
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); get
// CSLATODO: Add other validation rules {
} IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
// Sample data comparison validation rule if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
//{ }
// if (_started > _ended) }
// { protected override void AddBusinessRules()
// e.Description = "Start date can't be after end date"; {
// return false; ValidationRules.AddRule(
// } Csla.Validation.CommonRules.StringRequired, "UserID");
// else ValidationRules.AddRule(
// return true; Csla.Validation.CommonRules.StringMaxLength,
//} new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
#endregion // CSLATODO: Add other validation rules
#region Authorization Rules }
protected override void AddAuthorizationRules() // Sample data comparison validation rule
{ //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//CSLATODO: Who can read/write which fields //{
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>"); // if (_started > _ended)
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); // {
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); // e.Description = "Start date can't be after end date";
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); // return false;
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); // }
} // else
public static bool CanAddObject() // return true;
{ //}
// CSLATODO: Can Add Authorization #endregion
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); #region Authorization Rules
return true; protected override void AddAuthorizationRules()
} {
public static bool CanGetObject() //CSLATODO: Who can read/write which fields
{ //AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
// CSLATODO: CanGet Authorization //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
return true; //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
} //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
public static bool CanDeleteObject() //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
{ }
// CSLATODO: CanDelete Authorization public static bool CanAddObject()
//bool result = false; {
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; // CSLATODO: Can Add Authorization
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
//return result; return true;
return true; }
} public static bool CanGetObject()
public static bool CanEditObject() {
{ // CSLATODO: CanGet Authorization
// CSLATODO: CanEdit Authorization return true;
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); }
return true; public static bool CanDeleteObject()
} {
#endregion // CSLATODO: CanDelete Authorization
#region Factory Methods //bool result = false;
public int CurrentEditLevel //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
{ get { return EditLevel; } } //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
private static int _DocumentEntryUnique = 0; //return result;
private static int DocumentEntryUnique return true;
{ get { return ++_DocumentEntryUnique; } } }
private int _MyDocumentEntryUnique = DocumentEntryUnique; public static bool CanEditObject()
public int MyDocumentEntryUnique // Absolutely Unique ID - Editable FK {
{ get { return _MyDocumentEntryUnique; } } // CSLATODO: CanEdit Authorization
internal static DocumentEntry New(Entry myEntry) //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
{ return true;
return new DocumentEntry(myEntry); }
} #endregion
internal static DocumentEntry Get(SafeDataReader dr) #region Factory Methods
{ public int CurrentEditLevel
return new DocumentEntry(dr); { get { return EditLevel; } }
} private static int _DocumentEntryUnique = 0;
public DocumentEntry() private static int DocumentEntryUnique
{ { get { return ++_DocumentEntryUnique; } }
MarkAsChild(); private int _MyDocumentEntryUnique = DocumentEntryUnique;
public int MyDocumentEntryUnique // Absolutely Unique ID - Editable FK
{ get { return _MyDocumentEntryUnique; } }
internal static DocumentEntry New(Entry myEntry)
{
return new DocumentEntry(myEntry);
}
internal static DocumentEntry Get(SafeDataReader dr)
{
return new DocumentEntry(dr);
}
public DocumentEntry()
{
MarkAsChild();
_DTS = _DocumentEntryExtension.DefaultDTS; _DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID; _UserID = _DocumentEntryExtension.DefaultUserID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
private DocumentEntry(Entry myEntry) private DocumentEntry(Entry myEntry)
{ {
MarkAsChild(); MarkAsChild();
// CSLATODO: Add any initialization & defaults // CSLATODO: Add any initialization & defaults
_DTS = _DocumentEntryExtension.DefaultDTS; _DTS = _DocumentEntryExtension.DefaultDTS;
_UserID = _DocumentEntryExtension.DefaultUserID; _UserID = _DocumentEntryExtension.DefaultUserID;
_MyEntry = myEntry; _MyEntry = myEntry;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal DocumentEntry(SafeDataReader dr) internal DocumentEntry(SafeDataReader dr)
{ {
MarkAsChild(); MarkAsChild();
Fetch(dr); Fetch(dr);
} }
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~DocumentEntry() ~DocumentEntry()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++; _CountDisposed++;
_Disposed = true; _Disposed = true;
} }
#endregion #endregion
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentEntry.FetchDR", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
_DTS = dr.GetDateTime("DTS"); _DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID"); _UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number"); _Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text"); _Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type"); _Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID"); _Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config"); _Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS"); _Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID"); _Content_UserID = dr.GetString("Content_UserID");
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntry.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentEntry.FetchDR", ex);
throw new DbCslaException("DocumentEntry.Fetch", ex); throw new DbCslaException("DocumentEntry.Fetch", ex);
} }
MarkOld(); MarkOld();
} }
internal void Insert(Document myDocument) internal void Insert(Document myDocument)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID); _LastChanged = Entry.Add(cn, _MyEntry.MyContent, myDocument, _DTS, _UserID);
MarkOld(); MarkOld();
} }
internal void Update(Document myDocument) internal void Update(Document myDocument)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Entry.Update(cn, _ContentID, myDocument.DocID, _DTS, _UserID, ref _LastChanged); _LastChanged = Entry.Update(cn, _ContentID, myDocument.DocID, _DTS, _UserID, ref _LastChanged);
MarkOld(); MarkOld();
} }
internal void DeleteSelf(Document myDocument) internal void DeleteSelf(Document myDocument)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
// if we're new then don't update the database // if we're new then don't update the database
if (this.IsNew) return; if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Entry.Remove(cn, _ContentID); Entry.Remove(cn, _ContentID);
MarkNew(); MarkNew();
} }
#endregion #endregion
// Standard Default Code // Standard Default Code
#region extension #region extension
DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension(); DocumentEntryExtension _DocumentEntryExtension = new DocumentEntryExtension();
[Serializable()] [Serializable()]
partial class DocumentEntryExtension : extensionBase partial class DocumentEntryExtension : extensionBase
{ {
} }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {
// Default Values // Default Values
public virtual DateTime DefaultDTS public virtual DateTime DefaultDTS
{ {
get { return DateTime.Now; } get { return DateTime.Now; }
} }
public virtual string DefaultUserID public virtual string DefaultUserID
{ {
get { return Volian.Base.Library.VlnSettings.UserID; } get { return Volian.Base.Library.VlnSettings.UserID; }
} }
// Authorization Rules // Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Instance Authorization Rules // Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Validation Rules // Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
// InstanceValidation Rules // InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
} }
#endregion #endregion
} // Class } // Class
#region Converter #region Converter
internal class DocumentEntryConverter : ExpandableObjectConverter internal class DocumentEntryConverter : ExpandableObjectConverter
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
if (destType == typeof(string) && value is DocumentEntry) if (destType == typeof(string) && value is DocumentEntry)
{ {
// Return the ToString value // Return the ToString value
return ((DocumentEntry)value).ToString(); return ((DocumentEntry)value).ToString();
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
} }
#endregion #endregion
} // Namespace } // Namespace

View File

@ -19,482 +19,496 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void DocumentInfoEvent(object sender); public delegate void DocumentInfoEvent(object sender);
/// <summary> /// <summary>
/// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template /// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DocumentInfoConverter))] [TypeConverter(typeof(DocumentInfoConverter))]
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>, IDisposable
{ {
public event DocumentInfoEvent Changed; public event DocumentInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<DocumentInfo> _CacheList = new List<DocumentInfo>(); private static List<DocumentInfo> _CacheList = new List<DocumentInfo>();
protected static void AddToCache(DocumentInfo documentInfo) protected static void AddToCache(DocumentInfo documentInfo)
{ {
if (!_CacheList.Contains(documentInfo)) _CacheList.Add(documentInfo); // In AddToCache if (!_CacheList.Contains(documentInfo)) _CacheList.Add(documentInfo); // In AddToCache
} }
protected static void RemoveFromCache(DocumentInfo documentInfo) protected static void RemoveFromCache(DocumentInfo documentInfo)
{ {
while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache while (_CacheList.Contains(documentInfo)) _CacheList.Remove(documentInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>(); private static Dictionary<string, List<DocumentInfo>> _CacheByPrimaryKey = new Dictionary<string, List<DocumentInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move DocumentInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move DocumentInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
DocumentInfo tmp = _CacheList[0]; // Get the first DocumentInfo DocumentInfo tmp = _CacheList[0]; // Get the first DocumentInfo
string pKey = tmp.DocID.ToString(); string pKey = tmp.DocID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<DocumentInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<DocumentInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first DocumentInfo _CacheList.RemoveAt(0); // Remove the first DocumentInfo
} }
} }
internal static void AddList(DocumentInfoList lst) internal static void AddList(DocumentInfoList lst)
{ {
foreach (DocumentInfo item in lst) AddToCache(item); foreach (DocumentInfo item in lst) AddToCache(item);
} }
protected static DocumentInfo GetCachedByPrimaryKey(int docID) protected static DocumentInfo GetCachedByPrimaryKey(int docID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = docID.ToString(); string key = docID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Document _Editable; protected Document _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _DocID; private int _DocID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DocID public int DocID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _DocID; CanReadProperty("DocID", true);
} return _DocID;
} }
private string _LibTitle = string.Empty; }
public string LibTitle private string _LibTitle = string.Empty;
{ public string LibTitle
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _LibTitle; {
} CanReadProperty("LibTitle", true);
} return _LibTitle;
private byte[] _DocContent; }
/// <summary> }
/// Actual content of a Word Document (RTF, DOC or XML Format) private byte[] _DocContent;
/// </summary> /// <summary>
public byte[] DocContent /// Actual content of a Word Document (RTF, DOC or XML Format)
{ /// </summary>
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public byte[] DocContent
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _DocContent; get
} {
} CanReadProperty("DocContent", true);
private string _DocAscii = string.Empty; return _DocContent;
/// <summary> }
/// Used for searching }
/// </summary> private string _DocAscii = string.Empty;
public string DocAscii /// <summary>
{ /// Used for searching
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] /// </summary>
get public string DocAscii
{ {
return _DocAscii; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _Config = string.Empty; CanReadProperty("DocAscii", true);
public string Config return _DocAscii;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _Config = string.Empty;
{ public string Config
return _Config; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private DateTime _DTS = new DateTime(); {
public DateTime DTS CanReadProperty("Config", true);
{ return _Config;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private DateTime _DTS = new DateTime();
return _DTS; public DateTime DTS
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _UserID = string.Empty; get
public string UserID {
{ CanReadProperty("DTS", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _DTS;
get }
{ }
return _UserID; private string _UserID = string.Empty;
} public string UserID
} {
private string _FileExtension = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string FileExtension get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("UserID", true);
get return _UserID;
{ }
return _FileExtension; }
} private string _FileExtension = string.Empty;
} public string FileExtension
private int _DocumentDROUsageCount = 0; {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Count of DocumentDROUsages for this Document get
/// </summary> {
public int DocumentDROUsageCount CanReadProperty("FileExtension", true);
{ return _FileExtension;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int _DocumentDROUsageCount = 0;
if (_DocumentDROUsageCount < 0) /// <summary>
_DocumentDROUsageCount = DocumentDROUsages.Count; /// Count of DocumentDROUsages for this Document
return _DocumentDROUsageCount; /// </summary>
} public int DocumentDROUsageCount
} {
private DROUsageInfoList _DocumentDROUsages = null; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[TypeConverter(typeof(DROUsageInfoListConverter))] get
public DROUsageInfoList DocumentDROUsages {
{ CanReadProperty("DocumentDROUsageCount", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_DocumentDROUsageCount < 0)
get _DocumentDROUsageCount = DocumentDROUsages.Count;
{ return _DocumentDROUsageCount;
if (_DocumentDROUsageCount < 0 || (_DocumentDROUsageCount > 0 && _DocumentDROUsages == null)) }
_DocumentDROUsages = DROUsageInfoList.GetByDocID(_DocID); }
if (_DocumentDROUsageCount < 0) private DROUsageInfoList _DocumentDROUsages = null;
_DocumentDROUsageCount = _DocumentDROUsages.Count; [TypeConverter(typeof(DROUsageInfoListConverter))]
return _DocumentDROUsages; public DROUsageInfoList DocumentDROUsages
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void RefreshDocumentDROUsages() get
{ {
_DocumentDROUsageCount = -1; CanReadProperty("DocumentDROUsages", true);
ConvertListToDictionary(); if (_DocumentDROUsageCount < 0 || (_DocumentDROUsageCount > 0 && _DocumentDROUsages == null))
if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString())) _DocumentDROUsages = DROUsageInfoList.GetByDocID(_DocID);
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()]) if (_DocumentDROUsageCount < 0)
tmp._DocumentDROUsageCount = -1; // This will cause the data to be requeried _DocumentDROUsageCount = _DocumentDROUsages.Count;
} return _DocumentDROUsages;
private int _DocumentEntryCount = 0; }
/// <summary> }
/// Count of DocumentEntries for this Document public void RefreshDocumentDROUsages()
/// </summary> {
public int DocumentEntryCount _DocumentDROUsageCount = -1;
{ ConvertListToDictionary();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString()))
get foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
{ tmp._DocumentDROUsageCount = -1; // This will cause the data to be requeried
if (_DocumentEntryCount < 0) }
_DocumentEntryCount = DocumentEntries.Count; private int _DocumentEntryCount = 0;
return _DocumentEntryCount; /// <summary>
} /// Count of DocumentEntries for this Document
} /// </summary>
private EntryInfoList _DocumentEntries = null; public int DocumentEntryCount
[TypeConverter(typeof(EntryInfoListConverter))] {
public EntryInfoList DocumentEntries [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("DocumentEntryCount", true);
{ if (_DocumentEntryCount < 0)
if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null)) _DocumentEntryCount = DocumentEntries.Count;
_DocumentEntries = EntryInfoList.GetByDocID(_DocID); return _DocumentEntryCount;
if (_DocumentEntryCount < 0) }
_DocumentEntryCount = _DocumentEntries.Count; }
return _DocumentEntries; private EntryInfoList _DocumentEntries = null;
} [TypeConverter(typeof(EntryInfoListConverter))]
} public EntryInfoList DocumentEntries
public void RefreshDocumentEntries() {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_DocumentEntryCount = -1; get
ConvertListToDictionary(); {
if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString())) CanReadProperty("DocumentEntries", true);
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()]) if (_DocumentEntryCount < 0 || (_DocumentEntryCount > 0 && _DocumentEntries == null))
tmp._DocumentEntryCount = -1; // This will cause the data to be requeried _DocumentEntries = EntryInfoList.GetByDocID(_DocID);
} if (_DocumentEntryCount < 0)
private int _DocumentPdfCount = 0; _DocumentEntryCount = _DocumentEntries.Count;
/// <summary> return _DocumentEntries;
/// Count of DocumentPdfs for this Document }
/// </summary> }
public int DocumentPdfCount public void RefreshDocumentEntries()
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] _DocumentEntryCount = -1;
get ConvertListToDictionary();
{ if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString()))
if (_DocumentPdfCount < 0) foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
_DocumentPdfCount = DocumentPdfs.Count; tmp._DocumentEntryCount = -1; // This will cause the data to be requeried
return _DocumentPdfCount; }
} private int _DocumentPdfCount = 0;
} /// <summary>
private PdfInfoList _DocumentPdfs = null; /// Count of DocumentPdfs for this Document
[TypeConverter(typeof(PdfInfoListConverter))] /// </summary>
public PdfInfoList DocumentPdfs public int DocumentPdfCount
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_DocumentPdfCount < 0 || (_DocumentPdfCount > 0 && _DocumentPdfs == null)) CanReadProperty("DocumentPdfCount", true);
_DocumentPdfs = PdfInfoList.GetByDocID(_DocID); if (_DocumentPdfCount < 0)
if (_DocumentPdfCount < 0) _DocumentPdfCount = DocumentPdfs.Count;
_DocumentPdfCount = _DocumentPdfs.Count; return _DocumentPdfCount;
return _DocumentPdfs; }
} }
} private PdfInfoList _DocumentPdfs = null;
public void RefreshDocumentPdfs() [TypeConverter(typeof(PdfInfoListConverter))]
{ public PdfInfoList DocumentPdfs
_DocumentPdfCount = -1; {
ConvertListToDictionary(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString())) get
foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()]) {
tmp._DocumentPdfCount = -1; // This will cause the data to be requeried CanReadProperty("DocumentPdfs", true);
} if (_DocumentPdfCount < 0 || (_DocumentPdfCount > 0 && _DocumentPdfs == null))
// CSLATODO: Replace base DocumentInfo.ToString function as necessary _DocumentPdfs = PdfInfoList.GetByDocID(_DocID);
/// <summary> if (_DocumentPdfCount < 0)
/// Overrides Base ToString _DocumentPdfCount = _DocumentPdfs.Count;
/// </summary> return _DocumentPdfs;
/// <returns>A string representation of current DocumentInfo</returns> }
//public override string ToString() }
//{ public void RefreshDocumentPdfs()
// return base.ToString(); {
//} _DocumentPdfCount = -1;
// CSLATODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique ConvertListToDictionary();
/// <summary> if (_CacheByPrimaryKey.ContainsKey(_DocID.ToString()))
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality foreach (DocumentInfo tmp in _CacheByPrimaryKey[_DocID.ToString()])
/// </summary> tmp._DocumentPdfCount = -1; // This will cause the data to be requeried
/// <returns>A Unique ID for the current DocumentInfo</returns> }
protected override object GetIdValue() // CSLATODO: Replace base DocumentInfo.ToString function as necessary
{ /// <summary>
return MyDocumentInfoUnique; // Absolutely Unique ID /// Overrides Base ToString
} /// </summary>
#endregion /// <returns>A string representation of current DocumentInfo</returns>
#region Factory Methods //public override string ToString()
private static int _DocumentInfoUnique = 0; //{
private static int DocumentInfoUnique // return base.ToString();
{ get { return ++_DocumentInfoUnique; } } //}
private int _MyDocumentInfoUnique = DocumentInfoUnique; // CSLATODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique
public int MyDocumentInfoUnique // Absolutely Unique ID - Info /// <summary>
{ get { return _MyDocumentInfoUnique; } } /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
protected DocumentInfo() /// </summary>
{/* require use of factory methods */ /// <returns>A Unique ID for the current DocumentInfo</returns>
AddToCache(this); protected override object GetIdValue()
} {
private bool _Disposed = false; return MyDocumentInfoUnique; // Absolutely Unique ID
private static int _CountCreated = 0; }
private static int _CountDisposed = 0; #endregion
private static int _CountFinalized = 0; #region Factory Methods
private static int IncrementCountCreated private static int _DocumentInfoUnique = 0;
{ get { return ++_CountCreated; } } private static int DocumentInfoUnique
private int _CountWhenCreated = IncrementCountCreated; { get { return ++_DocumentInfoUnique; } }
public static int CountCreated private int _MyDocumentInfoUnique = DocumentInfoUnique;
{ get { return _CountCreated; } } public int MyDocumentInfoUnique // Absolutely Unique ID - Info
public static int CountNotDisposed { get { return _MyDocumentInfoUnique; } }
{ get { return _CountCreated - _CountDisposed; } } protected DocumentInfo()
public static int CountNotFinalized {/* require use of factory methods */
{ get { return _CountCreated - _CountFinalized; } } AddToCache(this);
~DocumentInfo() }
{ private bool _Disposed = false;
_CountFinalized++; private static int _CountCreated = 0;
} private static int _CountDisposed = 0;
public void Dispose() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
if (_Disposed) return; { get { return ++_CountCreated; } }
_CountDisposed++; private int _CountWhenCreated = IncrementCountCreated;
_Disposed = true; public static int CountCreated
RemoveFromCache(this); { get { return _CountCreated; } }
if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString())) return; public static int CountNotDisposed
List<DocumentInfo> listDocumentInfo = _CacheByPrimaryKey[DocID.ToString()]; // Get the list of items { get { return _CountCreated - _CountDisposed; } }
while (listDocumentInfo.Contains(this)) listDocumentInfo.Remove(this); // Remove the item from the list public static int CountNotFinalized
if (listDocumentInfo.Count == 0) // If there are no items left in the list { get { return _CountCreated - _CountFinalized; } }
_CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list ~DocumentInfo()
} {
public virtual Document Get() _CountFinalized++;
{ }
return _Editable = Document.Get(_DocID); public void Dispose()
} {
public static void Refresh(Document tmp) if (_Disposed) return;
{ _CountDisposed++;
string key = tmp.DocID.ToString(); _Disposed = true;
ConvertListToDictionary(); RemoveFromCache(this);
if (_CacheByPrimaryKey.ContainsKey(key)) if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString())) return;
foreach (DocumentInfo tmpInfo in _CacheByPrimaryKey[key]) List<DocumentInfo> listDocumentInfo = _CacheByPrimaryKey[DocID.ToString()]; // Get the list of items
tmpInfo.RefreshFields(tmp); while (listDocumentInfo.Contains(this)) listDocumentInfo.Remove(this); // Remove the item from the list
} if (listDocumentInfo.Count == 0) // If there are no items left in the list
protected virtual void RefreshFields(Document tmp) _CacheByPrimaryKey.Remove(DocID.ToString()); // remove the list
{ }
_LibTitle = tmp.LibTitle; public virtual Document Get()
_DocContent = tmp.DocContent; {
_DocAscii = tmp.DocAscii; return _Editable = Document.Get(_DocID);
_Config = tmp.Config; }
_DTS = tmp.DTS; public static void Refresh(Document tmp)
_UserID = tmp.UserID; {
_FileExtension = tmp.FileExtension; string key = tmp.DocID.ToString();
_DocumentInfoExtension.Refresh(this); ConvertListToDictionary();
OnChange();// raise an event if (_CacheByPrimaryKey.ContainsKey(key))
} foreach (DocumentInfo tmpInfo in _CacheByPrimaryKey[key])
public static DocumentInfo Get(int docID) tmpInfo.RefreshFields(tmp);
{ }
//if (!CanGetObject()) protected virtual void RefreshFields(Document tmp)
// throw new System.Security.SecurityException("User not authorized to view a Document"); {
try _LibTitle = tmp.LibTitle;
{ _DocContent = tmp.DocContent;
DocumentInfo tmp = GetCachedByPrimaryKey(docID); _DocAscii = tmp.DocAscii;
if (tmp == null) _Config = tmp.Config;
{ _DTS = tmp.DTS;
tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID)); _UserID = tmp.UserID;
AddToCache(tmp); _FileExtension = tmp.FileExtension;
} _DocumentInfoExtension.Refresh(this);
if (tmp.ErrorMessage == "No Record Found") OnChange();// raise an event
{ }
tmp.Dispose(); // Clean-up DocumentInfo public static DocumentInfo Get(int docID)
tmp = null; {
} //if (!CanGetObject())
return tmp; // throw new System.Security.SecurityException("User not authorized to view a Document");
} try
catch (Exception ex) {
{ DocumentInfo tmp = GetCachedByPrimaryKey(docID);
throw new DbCslaException("Error on DocumentInfo.Get", ex); if (tmp == null)
} {
} tmp = DataPortal.Fetch<DocumentInfo>(new PKCriteria(docID));
#endregion AddToCache(tmp);
#region Data Access Portal }
internal DocumentInfo(SafeDataReader dr) if (tmp.ErrorMessage == "No Record Found")
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode()); tmp.Dispose(); // Clean-up DocumentInfo
try tmp = null;
{ }
ReadData(dr); return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.Constructor", ex); throw new DbCslaException("Error on DocumentInfo.Get", ex);
throw new DbCslaException("DocumentInfo.Constructor", ex); }
} }
} #endregion
[Serializable()] #region Data Access Portal
protected class PKCriteria internal DocumentInfo(SafeDataReader dr)
{ {
private int _DocID; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.Constructor", GetHashCode());
public int DocID try
{ get { return _DocID; } } {
public PKCriteria(int docID) ReadData(dr);
{ }
_DocID = docID; catch (Exception ex)
} {
} if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.Constructor", ex);
private void ReadData(SafeDataReader dr) throw new DbCslaException("DocumentInfo.Constructor", ex);
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode()); }
try [Serializable()]
{ protected class PKCriteria
_DocID = dr.GetInt32("DocID"); {
_LibTitle = dr.GetString("LibTitle"); private int _DocID;
_DocContent = (byte[])dr.GetValue("DocContent"); public int DocID
_DocAscii = dr.GetString("DocAscii"); { get { return _DocID; } }
_Config = dr.GetString("Config"); public PKCriteria(int docID)
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); _DocID = docID;
_FileExtension = dr.GetString("FileExtension"); }
_DocumentDROUsageCount = dr.GetInt32("DROUsageCount"); }
_DocumentEntryCount = dr.GetInt32("EntryCount"); private void ReadData(SafeDataReader dr)
_DocumentPdfCount = dr.GetInt32("PdfCount"); {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.ReadData", GetHashCode());
catch (Exception ex) try
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.ReadData", ex); _DocID = dr.GetInt32("DocID");
_ErrorMessage = ex.Message; _LibTitle = dr.GetString("LibTitle");
throw new DbCslaException("DocumentInfo.ReadData", ex); _DocContent = (byte[])dr.GetValue("DocContent");
} _DocAscii = dr.GetString("DocAscii");
} _Config = dr.GetString("Config");
private void DataPortal_Fetch(PKCriteria criteria) _DTS = dr.GetDateTime("DTS");
{ _UserID = dr.GetString("UserID");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.DataPortal_Fetch", GetHashCode()); _FileExtension = dr.GetString("FileExtension");
try _DocumentDROUsageCount = dr.GetInt32("DROUsageCount");
{ _DocumentEntryCount = dr.GetInt32("EntryCount");
using (SqlConnection cn = Database.VEPROMS_SqlConnection) _DocumentPdfCount = dr.GetInt32("PdfCount");
{ }
ApplicationContext.LocalContext["cn"] = cn; catch (Exception ex)
using (SqlCommand cm = cn.CreateCommand()) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.ReadData", ex);
cm.CommandType = CommandType.StoredProcedure; _ErrorMessage = ex.Message;
cm.CommandText = "getDocument"; throw new DbCslaException("DocumentInfo.ReadData", ex);
cm.Parameters.AddWithValue("@DocID", criteria.DocID); }
cm.CommandTimeout = Database.DefaultTimeout; }
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) private void DataPortal_Fetch(PKCriteria criteria)
{ {
if (!dr.Read()) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentInfo.DataPortal_Fetch", GetHashCode());
{ try
_ErrorMessage = "No Record Found"; {
return; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
} {
ReadData(dr); ApplicationContext.LocalContext["cn"] = cn;
} using (SqlCommand cm = cn.CreateCommand())
} {
// removing of item only needed for local data portal cm.CommandType = CommandType.StoredProcedure;
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) cm.CommandText = "getDocument";
ApplicationContext.LocalContext.Remove("cn"); cm.Parameters.AddWithValue("@DocID", criteria.DocID);
} cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
catch (Exception ex) {
{ if (!dr.Read())
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.DataPortal_Fetch", ex); {
_ErrorMessage = ex.Message; _ErrorMessage = "No Record Found";
throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex); return;
} }
} ReadData(dr);
#endregion }
// Standard Refresh }
#region extension // removing of item only needed for local data portal
DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension(); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
[Serializable()] ApplicationContext.LocalContext.Remove("cn");
partial class DocumentInfoExtension : extensionBase { } }
[Serializable()] }
class extensionBase catch (Exception ex)
{ {
// Default Refresh if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentInfo.DataPortal_Fetch", ex);
public virtual void Refresh(DocumentInfo tmp) { } _ErrorMessage = ex.Message;
} throw new DbCslaException("DocumentInfo.DataPortal_Fetch", ex);
#endregion }
} // Class }
#region Converter #endregion
internal class DocumentInfoConverter : ExpandableObjectConverter // Standard Refresh
{ #region extension
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) DocumentInfoExtension _DocumentInfoExtension = new DocumentInfoExtension();
{ [Serializable()]
if (destType == typeof(string) && value is DocumentInfo) partial class DocumentInfoExtension : extensionBase { }
{ [Serializable()]
// Return the ToString value class extensionBase
return ((DocumentInfo)value).ToString(); {
} // Default Refresh
return base.ConvertTo(context, culture, value, destType); public virtual void Refresh(DocumentInfo tmp) { }
} }
} #endregion
#endregion } // Class
#region Converter
internal class DocumentInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is DocumentInfo)
{
// Return the ToString value
return ((DocumentInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -20,458 +20,471 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// DocumentPdf Generated by MyGeneration using the CSLA Object Mapping template /// DocumentPdf Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(DocumentPdfConverter))] [TypeConverter(typeof(DocumentPdfConverter))]
public partial class DocumentPdf : BusinessBase<DocumentPdf>, IVEHasBrokenRules, IDisposable public partial class DocumentPdf : BusinessBase<DocumentPdf>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _DebugStatus; private int _DebugStatus;
/// <summary> /// <summary>
/// > 0 for Debug /// > 0 for Debug
/// </summary> /// </summary>
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DebugStatus public int DebugStatus
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _DebugStatus; CanReadProperty("DebugStatus", true);
} return _DebugStatus;
} }
private int _TopRow; }
[System.ComponentModel.DataObjectField(true, true)] private int _TopRow;
public int TopRow [System.ComponentModel.DataObjectField(true, true)]
{ public int TopRow
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _TopRow; {
} CanReadProperty("TopRow", true);
} return _TopRow;
private int _PageLength; }
[System.ComponentModel.DataObjectField(true, true)] }
public int PageLength private int _PageLength;
{ [System.ComponentModel.DataObjectField(true, true)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int PageLength
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _PageLength; get
} {
} CanReadProperty("PageLength", true);
private int _LeftMargin; return _PageLength;
[System.ComponentModel.DataObjectField(true, true)] }
public int LeftMargin }
{ private int _LeftMargin;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.ComponentModel.DataObjectField(true, true)]
get public int LeftMargin
{ {
return _LeftMargin; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private int _PageWidth; CanReadProperty("LeftMargin", true);
[System.ComponentModel.DataObjectField(true, true)] return _LeftMargin;
public int PageWidth }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _PageWidth;
get [System.ComponentModel.DataObjectField(true, true)]
{ public int PageWidth
return _PageWidth; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private double _PageCount; {
/// <summary> CanReadProperty("PageWidth", true);
/// Count of whole and partial pages return _PageWidth;
/// </summary> }
public double PageCount }
{ private double _PageCount;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] /// <summary>
get /// Count of whole and partial pages
{ /// </summary>
return _PageCount; public double PageCount
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set get
{ {
if (_PageCount != value) CanReadProperty("PageCount", true);
{ return _PageCount;
_PageCount = value; }
PropertyHasChanged(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
} {
} CanWriteProperty("PageCount", true);
private byte[] _DocPdf; if (_PageCount != value)
public byte[] DocPdf {
{ _PageCount = value;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] PropertyHasChanged();
get }
{ }
return _DocPdf; }
} private byte[] _DocPdf;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public byte[] DocPdf
set {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_DocPdf != value) get
{ {
_DocPdf = value; CanReadProperty("DocPdf", true);
PropertyHasChanged(); return _DocPdf;
} }
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
private DateTime _DTS = new DateTime(); {
public DateTime DTS CanWriteProperty("DocPdf", true);
{ if (_DocPdf != value)
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get _DocPdf = value;
{ PropertyHasChanged();
return _DTS; }
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
set private DateTime _DTS = new DateTime();
{ public DateTime DTS
if (_DTS != value) {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_DTS = value; get
PropertyHasChanged(); {
} CanReadProperty("DTS", true);
} return _DTS;
} }
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID set
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanWriteProperty("DTS", true);
get if (_DTS != value)
{ {
return _UserID; _DTS = value;
} PropertyHasChanged();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
set }
{ }
if (value == null) value = string.Empty; private string _UserID = string.Empty;
if (_UserID != value) public string UserID
{ {
_UserID = value; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
PropertyHasChanged(); get
} {
} CanReadProperty("UserID", true);
} return _UserID;
private byte[] _LastChanged = new byte[8];//timestamp }
// CSLATODO: Check DocumentPdf.GetIdValue to assure that the ID returned is unique [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <summary> set
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality {
/// </summary> CanWriteProperty("UserID", true);
/// <returns>A Unique ID for the current DocumentPdf</returns> if (value == null) value = string.Empty;
protected override object GetIdValue() if (_UserID != value)
{ {
return MyDocumentPdfUnique; // Absolutely Unique ID _UserID = value;
} PropertyHasChanged();
// CSLATODO: Replace base DocumentPdf.ToString function as necessary }
/// <summary> }
/// Overrides Base ToString }
/// </summary> private byte[] _LastChanged = new byte[8];//timestamp
/// <returns>A string representation of current DocumentPdf</returns> // CSLATODO: Check DocumentPdf.GetIdValue to assure that the ID returned is unique
//public override string ToString() /// <summary>
//{ /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
// return base.ToString(); /// </summary>
//} /// <returns>A Unique ID for the current DocumentPdf</returns>
public override bool IsDirty protected override object GetIdValue()
{ {
get { return base.IsDirty; } return MyDocumentPdfUnique; // Absolutely Unique ID
} }
public bool IsDirtyList(List<object> list) // CSLATODO: Replace base DocumentPdf.ToString function as necessary
{ /// <summary>
return base.IsDirty; /// Overrides Base ToString
} /// </summary>
public override bool IsValid /// <returns>A string representation of current DocumentPdf</returns>
{ //public override string ToString()
get { return (IsNew && !IsDirty) ? true : base.IsValid; } //{
} // return base.ToString();
public bool IsValidList(List<object> list) //}
{ public override bool IsDirty
return (IsNew && !IsDirty) ? true : base.IsValid; {
} get { return base.IsDirty; }
#endregion }
#region ValidationRules public bool IsDirtyList(List<object> list)
[NonSerialized] {
private bool _CheckingBrokenRules = false; return base.IsDirty;
public IVEHasBrokenRules HasBrokenRules }
{ public override bool IsValid
get {
{ get { return (IsNew && !IsDirty) ? true : base.IsValid; }
if (_CheckingBrokenRules) return null; }
if (BrokenRulesCollection.Count > 0) return this; public bool IsValidList(List<object> list)
try {
{ return (IsNew && !IsDirty) ? true : base.IsValid;
_CheckingBrokenRules = true; }
IVEHasBrokenRules hasBrokenRules = null; #endregion
return hasBrokenRules; #region ValidationRules
} [NonSerialized]
finally private bool _CheckingBrokenRules = false;
{ public IVEHasBrokenRules HasBrokenRules
_CheckingBrokenRules = false; {
} get
} {
} if (_CheckingBrokenRules) return null;
public BrokenRulesCollection BrokenRules if (BrokenRulesCollection.Count > 0) return this;
{ try
get {
{ _CheckingBrokenRules = true;
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; IVEHasBrokenRules hasBrokenRules = null;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; return hasBrokenRules;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); }
} finally
} {
protected override void AddBusinessRules() _CheckingBrokenRules = false;
{ }
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringRequired, "UserID"); }
ValidationRules.AddRule( public BrokenRulesCollection BrokenRules
Csla.Validation.CommonRules.StringMaxLength, {
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); get
// CSLATODO: Add other validation rules {
} IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
// Sample data comparison validation rule if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
//{ }
// if (_started > _ended) }
// { protected override void AddBusinessRules()
// e.Description = "Start date can't be after end date"; {
// return false; ValidationRules.AddRule(
// } Csla.Validation.CommonRules.StringRequired, "UserID");
// else ValidationRules.AddRule(
// return true; Csla.Validation.CommonRules.StringMaxLength,
//} new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
#endregion // CSLATODO: Add other validation rules
#region Authorization Rules }
protected override void AddAuthorizationRules() // Sample data comparison validation rule
{ //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//CSLATODO: Who can read/write which fields //{
//AuthorizationRules.AllowRead(DebugStatus, "<Role(s)>"); // if (_started > _ended)
//AuthorizationRules.AllowRead(TopRow, "<Role(s)>"); // {
//AuthorizationRules.AllowRead(PageLength, "<Role(s)>"); // e.Description = "Start date can't be after end date";
//AuthorizationRules.AllowRead(LeftMargin, "<Role(s)>"); // return false;
//AuthorizationRules.AllowRead(PageWidth, "<Role(s)>"); // }
//AuthorizationRules.AllowRead(PageCount, "<Role(s)>"); // else
//AuthorizationRules.AllowWrite(PageCount, "<Role(s)>"); // return true;
//AuthorizationRules.AllowRead(DocPdf, "<Role(s)>"); //}
//AuthorizationRules.AllowWrite(DocPdf, "<Role(s)>"); #endregion
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); #region Authorization Rules
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); protected override void AddAuthorizationRules()
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); {
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); //CSLATODO: Who can read/write which fields
} //AuthorizationRules.AllowRead(DebugStatus, "<Role(s)>");
public static bool CanAddObject() //AuthorizationRules.AllowRead(TopRow, "<Role(s)>");
{ //AuthorizationRules.AllowRead(PageLength, "<Role(s)>");
// CSLATODO: Can Add Authorization //AuthorizationRules.AllowRead(LeftMargin, "<Role(s)>");
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); //AuthorizationRules.AllowRead(PageWidth, "<Role(s)>");
return true; //AuthorizationRules.AllowRead(PageCount, "<Role(s)>");
} //AuthorizationRules.AllowWrite(PageCount, "<Role(s)>");
public static bool CanGetObject() //AuthorizationRules.AllowRead(DocPdf, "<Role(s)>");
{ //AuthorizationRules.AllowWrite(DocPdf, "<Role(s)>");
// CSLATODO: CanGet Authorization //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
return true; //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
} //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
public static bool CanDeleteObject() //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
{ }
// CSLATODO: CanDelete Authorization public static bool CanAddObject()
//bool result = false; {
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; // CSLATODO: Can Add Authorization
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
//return result; return true;
return true; }
} public static bool CanGetObject()
public static bool CanEditObject() {
{ // CSLATODO: CanGet Authorization
// CSLATODO: CanEdit Authorization return true;
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); }
return true; public static bool CanDeleteObject()
} {
#endregion // CSLATODO: CanDelete Authorization
#region Factory Methods //bool result = false;
public int CurrentEditLevel //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
{ get { return EditLevel; } } //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
private static int _DocumentPdfUnique = 0; //return result;
private static int DocumentPdfUnique return true;
{ get { return ++_DocumentPdfUnique; } } }
private int _MyDocumentPdfUnique = DocumentPdfUnique; public static bool CanEditObject()
public int MyDocumentPdfUnique // Absolutely Unique ID - Editable FK {
{ get { return _MyDocumentPdfUnique; } } // CSLATODO: CanEdit Authorization
internal static DocumentPdf New(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
{ return true;
return new DocumentPdf(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount); }
} #endregion
internal static DocumentPdf Get(SafeDataReader dr) #region Factory Methods
{ public int CurrentEditLevel
return new DocumentPdf(dr); { get { return EditLevel; } }
} private static int _DocumentPdfUnique = 0;
public DocumentPdf() private static int DocumentPdfUnique
{ { get { return ++_DocumentPdfUnique; } }
MarkAsChild(); private int _MyDocumentPdfUnique = DocumentPdfUnique;
public int MyDocumentPdfUnique // Absolutely Unique ID - Editable FK
{ get { return _MyDocumentPdfUnique; } }
internal static DocumentPdf New(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount)
{
return new DocumentPdf(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount);
}
internal static DocumentPdf Get(SafeDataReader dr)
{
return new DocumentPdf(dr);
}
public DocumentPdf()
{
MarkAsChild();
_DTS = _DocumentPdfExtension.DefaultDTS; _DTS = _DocumentPdfExtension.DefaultDTS;
_UserID = _DocumentPdfExtension.DefaultUserID; _UserID = _DocumentPdfExtension.DefaultUserID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
private DocumentPdf(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) private DocumentPdf(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount)
{ {
MarkAsChild(); MarkAsChild();
// CSLATODO: Add any initialization & defaults // CSLATODO: Add any initialization & defaults
_DTS = _DocumentPdfExtension.DefaultDTS; _DTS = _DocumentPdfExtension.DefaultDTS;
_UserID = _DocumentPdfExtension.DefaultUserID; _UserID = _DocumentPdfExtension.DefaultUserID;
_DebugStatus = debugStatus; _DebugStatus = debugStatus;
_TopRow = topRow; _TopRow = topRow;
_PageLength = pageLength; _PageLength = pageLength;
_LeftMargin = leftMargin; _LeftMargin = leftMargin;
_PageWidth = pageWidth; _PageWidth = pageWidth;
_PageCount = pageCount; _PageCount = pageCount;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal DocumentPdf(SafeDataReader dr) internal DocumentPdf(SafeDataReader dr)
{ {
MarkAsChild(); MarkAsChild();
Fetch(dr); Fetch(dr);
} }
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~DocumentPdf() ~DocumentPdf()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++; _CountDisposed++;
_Disposed = true; _Disposed = true;
} }
#endregion #endregion
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentPdf.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentPdf.FetchDR", GetHashCode());
try try
{ {
_DebugStatus = dr.GetInt32("DebugStatus"); _DebugStatus = dr.GetInt32("DebugStatus");
_TopRow = dr.GetInt32("TopRow"); _TopRow = dr.GetInt32("TopRow");
_PageLength = dr.GetInt32("PageLength"); _PageLength = dr.GetInt32("PageLength");
_LeftMargin = dr.GetInt32("LeftMargin"); _LeftMargin = dr.GetInt32("LeftMargin");
_PageWidth = dr.GetInt32("PageWidth"); _PageWidth = dr.GetInt32("PageWidth");
_PageCount = dr.GetDouble("PageCount"); _PageCount = dr.GetDouble("PageCount");
_DocPdf = (byte[])dr.GetValue("DocPdf"); _DocPdf = (byte[])dr.GetValue("DocPdf");
_DTS = dr.GetDateTime("DTS"); _DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID"); _UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentPdf.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentPdf.FetchDR", ex);
throw new DbCslaException("DocumentPdf.Fetch", ex); throw new DbCslaException("DocumentPdf.Fetch", ex);
} }
MarkOld(); MarkOld();
} }
internal void Insert(Document myDocument) internal void Insert(Document myDocument)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Pdf.Add(cn, myDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID); _LastChanged = Pdf.Add(cn, myDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID);
MarkOld(); MarkOld();
} }
internal void Update(Document myDocument) internal void Update(Document myDocument)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Pdf.Update(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged); _LastChanged = Pdf.Update(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged);
MarkOld(); MarkOld();
} }
internal void DeleteSelf(Document myDocument) internal void DeleteSelf(Document myDocument)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
// if we're new then don't update the database // if we're new then don't update the database
if (this.IsNew) return; if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Pdf.Remove(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth); Pdf.Remove(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth);
MarkNew(); MarkNew();
} }
#endregion #endregion
// Standard Default Code // Standard Default Code
#region extension #region extension
DocumentPdfExtension _DocumentPdfExtension = new DocumentPdfExtension(); DocumentPdfExtension _DocumentPdfExtension = new DocumentPdfExtension();
[Serializable()] [Serializable()]
partial class DocumentPdfExtension : extensionBase partial class DocumentPdfExtension : extensionBase
{ {
} }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {
// Default Values // Default Values
public virtual DateTime DefaultDTS public virtual DateTime DefaultDTS
{ {
get { return DateTime.Now; } get { return DateTime.Now; }
} }
public virtual string DefaultUserID public virtual string DefaultUserID
{ {
get { return Volian.Base.Library.VlnSettings.UserID; } get { return Volian.Base.Library.VlnSettings.UserID; }
} }
// Authorization Rules // Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Instance Authorization Rules // Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Validation Rules // Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
// InstanceValidation Rules // InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
} }
#endregion #endregion
} // Class } // Class
#region Converter #region Converter
internal class DocumentPdfConverter : ExpandableObjectConverter internal class DocumentPdfConverter : ExpandableObjectConverter
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
if (destType == typeof(string) && value is DocumentPdf) if (destType == typeof(string) && value is DocumentPdf)
{ {
// Return the ToString value // Return the ToString value
return ((DocumentPdf)value).ToString(); return ((DocumentPdf)value).ToString();
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
} }
#endregion #endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,343 +19,349 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void EntryAuditInfoEvent(object sender); public delegate void EntryAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// EntryAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// EntryAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(EntryAuditInfoConverter))] [TypeConverter(typeof(EntryAuditInfoConverter))]
public partial class EntryAuditInfo : ReadOnlyBase<EntryAuditInfo>, IDisposable public partial class EntryAuditInfo : ReadOnlyBase<EntryAuditInfo>, IDisposable
{ {
public event EntryAuditInfoEvent Changed; public event EntryAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<EntryAuditInfo> _CacheList = new List<EntryAuditInfo>(); private static List<EntryAuditInfo> _CacheList = new List<EntryAuditInfo>();
protected static void AddToCache(EntryAuditInfo entryAuditInfo) protected static void AddToCache(EntryAuditInfo entryAuditInfo)
{ {
if (!_CacheList.Contains(entryAuditInfo)) _CacheList.Add(entryAuditInfo); // In AddToCache if (!_CacheList.Contains(entryAuditInfo)) _CacheList.Add(entryAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(EntryAuditInfo entryAuditInfo) protected static void RemoveFromCache(EntryAuditInfo entryAuditInfo)
{ {
while (_CacheList.Contains(entryAuditInfo)) _CacheList.Remove(entryAuditInfo); // In RemoveFromCache while (_CacheList.Contains(entryAuditInfo)) _CacheList.Remove(entryAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<EntryAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAuditInfo>>(); private static Dictionary<string, List<EntryAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move EntryAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move EntryAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
EntryAuditInfo tmp = _CacheList[0]; // Get the first EntryAuditInfo EntryAuditInfo tmp = _CacheList[0]; // Get the first EntryAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<EntryAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<EntryAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first EntryAuditInfo _CacheList.RemoveAt(0); // Remove the first EntryAuditInfo
} }
} }
internal static void AddList(EntryAuditInfoList lst) internal static void AddList(EntryAuditInfoList lst)
{ {
foreach (EntryAuditInfo item in lst) AddToCache(item); foreach (EntryAuditInfo item in lst) AddToCache(item);
} }
protected static EntryAuditInfo GetCachedByPrimaryKey(long auditID) protected static EntryAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected EntryAudit _Editable; protected EntryAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ContentID; {
} CanReadProperty("ContentID", true);
} return _ContentID;
private int _DocID; }
public int DocID }
{ private int _DocID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int DocID
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _DocID; get
} {
} CanReadProperty("DocID", true);
private DateTime _DTS = new DateTime(); return _DocID;
public DateTime DTS }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private DateTime _DTS = new DateTime();
get public DateTime DTS
{ {
return _DTS; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _UserID = string.Empty; CanReadProperty("DTS", true);
public string UserID return _DTS;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _UserID = string.Empty;
{ public string UserID
return _UserID; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private int _DeleteStatus; {
public int DeleteStatus CanReadProperty("UserID", true);
{ return _UserID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int _DeleteStatus;
return _DeleteStatus; public int DeleteStatus
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
// CSLATODO: Replace base EntryAuditInfo.ToString function as necessary get
/// <summary> {
/// Overrides Base ToString CanReadProperty("DeleteStatus", true);
/// </summary> return _DeleteStatus;
/// <returns>A string representation of current EntryAuditInfo</returns> }
//public override string ToString() }
//{ // CSLATODO: Replace base EntryAuditInfo.ToString function as necessary
// return base.ToString(); /// <summary>
//} /// Overrides Base ToString
// CSLATODO: Check EntryAuditInfo.GetIdValue to assure that the ID returned is unique /// </summary>
/// <summary> /// <returns>A string representation of current EntryAuditInfo</returns>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality //public override string ToString()
/// </summary> //{
/// <returns>A Unique ID for the current EntryAuditInfo</returns> // return base.ToString();
protected override object GetIdValue() //}
{ // CSLATODO: Check EntryAuditInfo.GetIdValue to assure that the ID returned is unique
return MyEntryAuditInfoUnique; // Absolutely Unique ID /// <summary>
} /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
#endregion /// </summary>
#region Factory Methods /// <returns>A Unique ID for the current EntryAuditInfo</returns>
private static int _EntryAuditInfoUnique = 0; protected override object GetIdValue()
private static int EntryAuditInfoUnique {
{ get { return ++_EntryAuditInfoUnique; } } return MyEntryAuditInfoUnique; // Absolutely Unique ID
private int _MyEntryAuditInfoUnique = EntryAuditInfoUnique; }
public int MyEntryAuditInfoUnique // Absolutely Unique ID - Info #endregion
{ get { return _MyEntryAuditInfoUnique; } } #region Factory Methods
protected EntryAuditInfo() private static int _EntryAuditInfoUnique = 0;
{/* require use of factory methods */ private static int EntryAuditInfoUnique
AddToCache(this); { get { return ++_EntryAuditInfoUnique; } }
} private int _MyEntryAuditInfoUnique = EntryAuditInfoUnique;
private bool _Disposed = false; public int MyEntryAuditInfoUnique // Absolutely Unique ID - Info
private static int _CountCreated = 0; { get { return _MyEntryAuditInfoUnique; } }
private static int _CountDisposed = 0; protected EntryAuditInfo()
private static int _CountFinalized = 0; {/* require use of factory methods */
private static int IncrementCountCreated AddToCache(this);
{ get { return ++_CountCreated; } } }
private int _CountWhenCreated = IncrementCountCreated; private bool _Disposed = false;
public static int CountCreated private static int _CountCreated = 0;
{ get { return _CountCreated; } } private static int _CountDisposed = 0;
public static int CountNotDisposed private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int IncrementCountCreated
public static int CountNotFinalized { get { return ++_CountCreated; } }
{ get { return _CountCreated - _CountFinalized; } } private int _CountWhenCreated = IncrementCountCreated;
~EntryAuditInfo() public static int CountCreated
{ { get { return _CountCreated; } }
_CountFinalized++; public static int CountNotDisposed
} { get { return _CountCreated - _CountDisposed; } }
public void Dispose() public static int CountNotFinalized
{ { get { return _CountCreated - _CountFinalized; } }
if (_Disposed) return; ~EntryAuditInfo()
_CountDisposed++; {
_Disposed = true; _CountFinalized++;
RemoveFromCache(this); }
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; public void Dispose()
List<EntryAuditInfo> listEntryAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items {
while (listEntryAuditInfo.Contains(this)) listEntryAuditInfo.Remove(this); // Remove the item from the list if (_Disposed) return;
if (listEntryAuditInfo.Count == 0) // If there are no items left in the list _CountDisposed++;
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list _Disposed = true;
} RemoveFromCache(this);
public virtual EntryAudit Get() if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
{ List<EntryAuditInfo> listEntryAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
return _Editable = EntryAudit.Get(_AuditID); while (listEntryAuditInfo.Contains(this)) listEntryAuditInfo.Remove(this); // Remove the item from the list
} if (listEntryAuditInfo.Count == 0) // If there are no items left in the list
public static void Refresh(EntryAudit tmp) _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
{ }
string key = tmp.AuditID.ToString(); public virtual EntryAudit Get()
ConvertListToDictionary(); {
if (_CacheByPrimaryKey.ContainsKey(key)) return _Editable = EntryAudit.Get(_AuditID);
foreach (EntryAuditInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public static void Refresh(EntryAudit tmp)
} {
protected virtual void RefreshFields(EntryAudit tmp) string key = tmp.AuditID.ToString();
{ ConvertListToDictionary();
_ContentID = tmp.ContentID; if (_CacheByPrimaryKey.ContainsKey(key))
_DocID = tmp.DocID; foreach (EntryAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(EntryAudit tmp)
_EntryAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ContentID = tmp.ContentID;
} _DocID = tmp.DocID;
public static EntryAuditInfo Get(long auditID) _DTS = tmp.DTS;
{ _UserID = tmp.UserID;
//if (!CanGetObject()) _DeleteStatus = tmp.DeleteStatus;
// throw new System.Security.SecurityException("User not authorized to view a EntryAudit"); _EntryAuditInfoExtension.Refresh(this);
try OnChange();// raise an event
{ }
EntryAuditInfo tmp = GetCachedByPrimaryKey(auditID); public static EntryAuditInfo Get(long auditID)
if (tmp == null) {
{ //if (!CanGetObject())
tmp = DataPortal.Fetch<EntryAuditInfo>(new PKCriteria(auditID)); // throw new System.Security.SecurityException("User not authorized to view a EntryAudit");
AddToCache(tmp); try
} {
if (tmp.ErrorMessage == "No Record Found") EntryAuditInfo tmp = GetCachedByPrimaryKey(auditID);
{ if (tmp == null)
tmp.Dispose(); // Clean-up EntryAuditInfo {
tmp = null; tmp = DataPortal.Fetch<EntryAuditInfo>(new PKCriteria(auditID));
} AddToCache(tmp);
return tmp; }
} if (tmp.ErrorMessage == "No Record Found")
catch (Exception ex) {
{ tmp.Dispose(); // Clean-up EntryAuditInfo
throw new DbCslaException("Error on EntryAuditInfo.Get", ex); tmp = null;
} }
} return tmp;
#endregion }
#region Data Access Portal catch (Exception ex)
internal EntryAuditInfo(SafeDataReader dr) {
{ throw new DbCslaException("Error on EntryAuditInfo.Get", ex);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.Constructor", GetHashCode()); }
try }
{ #endregion
ReadData(dr); #region Data Access Portal
} internal EntryAuditInfo(SafeDataReader dr)
catch (Exception ex) {
{ if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.Constructor", GetHashCode());
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.Constructor", ex); try
throw new DbCslaException("EntryAuditInfo.Constructor", ex); {
} ReadData(dr);
} }
[Serializable()] catch (Exception ex)
protected class PKCriteria {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.Constructor", ex);
private long _AuditID; throw new DbCslaException("EntryAuditInfo.Constructor", ex);
public long AuditID }
{ get { return _AuditID; } } }
public PKCriteria(long auditID) [Serializable()]
{ protected class PKCriteria
_AuditID = auditID; {
} private long _AuditID;
} public long AuditID
private void ReadData(SafeDataReader dr) { get { return _AuditID; } }
{ public PKCriteria(long auditID)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.ReadData", GetHashCode()); {
try _AuditID = auditID;
{ }
_AuditID = dr.GetInt64("AuditID"); }
_ContentID = dr.GetInt32("ContentID"); private void ReadData(SafeDataReader dr)
_DocID = dr.GetInt32("DocID"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _DocID = dr.GetInt32("DocID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.ReadData", ex); _DTS = dr.GetDateTime("DTS");
_ErrorMessage = ex.Message; _UserID = dr.GetString("UserID");
throw new DbCslaException("EntryAuditInfo.ReadData", ex); _DeleteStatus = dr.GetInt32("DeleteStatus");
} }
} catch (Exception ex)
private void DataPortal_Fetch(PKCriteria criteria) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.ReadData", ex);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.DataPortal_Fetch", GetHashCode()); _ErrorMessage = ex.Message;
try throw new DbCslaException("EntryAuditInfo.ReadData", ex);
{ }
using (SqlConnection cn = Database.VEPROMS_SqlConnection) }
{ private void DataPortal_Fetch(PKCriteria criteria)
ApplicationContext.LocalContext["cn"] = cn; {
using (SqlCommand cm = cn.CreateCommand()) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryAuditInfo.DataPortal_Fetch", GetHashCode());
{ try
cm.CommandType = CommandType.StoredProcedure; {
cm.CommandText = "getEntryAudit"; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); {
cm.CommandTimeout = Database.DefaultTimeout; ApplicationContext.LocalContext["cn"] = cn;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SqlCommand cm = cn.CreateCommand())
{ {
if (!dr.Read()) cm.CommandType = CommandType.StoredProcedure;
{ cm.CommandText = "getEntryAudit";
_ErrorMessage = "No Record Found"; cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
return; cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
ReadData(dr); {
} if (!dr.Read())
} {
// removing of item only needed for local data portal _ErrorMessage = "No Record Found";
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) return;
ApplicationContext.LocalContext.Remove("cn"); }
} ReadData(dr);
} }
catch (Exception ex) }
{ // removing of item only needed for local data portal
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
_ErrorMessage = ex.Message; ApplicationContext.LocalContext.Remove("cn");
throw new DbCslaException("EntryAuditInfo.DataPortal_Fetch", ex); }
} }
} catch (Exception ex)
#endregion {
// Standard Refresh if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryAuditInfo.DataPortal_Fetch", ex);
#region extension _ErrorMessage = ex.Message;
EntryAuditInfoExtension _EntryAuditInfoExtension = new EntryAuditInfoExtension(); throw new DbCslaException("EntryAuditInfo.DataPortal_Fetch", ex);
[Serializable()] }
partial class EntryAuditInfoExtension : extensionBase { } }
[Serializable()] #endregion
class extensionBase // Standard Refresh
{ #region extension
// Default Refresh EntryAuditInfoExtension _EntryAuditInfoExtension = new EntryAuditInfoExtension();
public virtual void Refresh(EntryAuditInfo tmp) { } [Serializable()]
} partial class EntryAuditInfoExtension : extensionBase { }
#endregion [Serializable()]
} // Class class extensionBase
#region Converter {
internal class EntryAuditInfoConverter : ExpandableObjectConverter // Default Refresh
{ public virtual void Refresh(EntryAuditInfo tmp) { }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) }
{ #endregion
if (destType == typeof(string) && value is EntryAuditInfo) } // Class
{ #region Converter
// Return the ToString value internal class EntryAuditInfoConverter : ExpandableObjectConverter
return ((EntryAuditInfo)value).ToString(); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
return base.ConvertTo(context, culture, value, destType); {
} if (destType == typeof(string) && value is EntryAuditInfo)
} {
#endregion // Return the ToString value
return ((EntryAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -19,365 +19,371 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void EntryInfoEvent(object sender); public delegate void EntryInfoEvent(object sender);
/// <summary> /// <summary>
/// EntryInfo Generated by MyGeneration using the CSLA Object Mapping template /// EntryInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(EntryInfoConverter))] [TypeConverter(typeof(EntryInfoConverter))]
public partial class EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable public partial class EntryInfo : ReadOnlyBase<EntryInfo>, IDisposable
{ {
public event EntryInfoEvent Changed; public event EntryInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<EntryInfo> _CacheList = new List<EntryInfo>(); private static List<EntryInfo> _CacheList = new List<EntryInfo>();
protected static void AddToCache(EntryInfo entryInfo) protected static void AddToCache(EntryInfo entryInfo)
{ {
if (!_CacheList.Contains(entryInfo)) _CacheList.Add(entryInfo); // In AddToCache if (!_CacheList.Contains(entryInfo)) _CacheList.Add(entryInfo); // In AddToCache
} }
protected static void RemoveFromCache(EntryInfo entryInfo) protected static void RemoveFromCache(EntryInfo entryInfo)
{ {
while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache while (_CacheList.Contains(entryInfo)) _CacheList.Remove(entryInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>(); private static Dictionary<string, List<EntryInfo>> _CacheByPrimaryKey = new Dictionary<string, List<EntryInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move EntryInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move EntryInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
EntryInfo tmp = _CacheList[0]; // Get the first EntryInfo EntryInfo tmp = _CacheList[0]; // Get the first EntryInfo
string pKey = tmp.ContentID.ToString(); string pKey = tmp.ContentID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<EntryInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<EntryInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first EntryInfo _CacheList.RemoveAt(0); // Remove the first EntryInfo
} }
} }
internal static void AddList(EntryInfoList lst) internal static void AddList(EntryInfoList lst)
{ {
foreach (EntryInfo item in lst) AddToCache(item); foreach (EntryInfo item in lst) AddToCache(item);
} }
protected static EntryInfo GetCachedByPrimaryKey(int contentID) protected static EntryInfo GetCachedByPrimaryKey(int contentID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Entry _Editable; protected Entry _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _ContentID; private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int ContentID public int ContentID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyContent != null) _ContentID = _MyContent.ContentID; CanReadProperty("ContentID", true);
return _ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
} return _ContentID;
} }
private ContentInfo _MyContent; }
[System.ComponentModel.DataObjectField(true, true)] private ContentInfo _MyContent;
public ContentInfo MyContent [System.ComponentModel.DataObjectField(true, true)]
{ public ContentInfo MyContent
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); {
return _MyContent; CanReadProperty("MyContent", true);
} if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
} return _MyContent;
private int _DocID; }
public int DocID }
{ private int _DocID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int DocID
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyDocument != null) _DocID = _MyDocument.DocID; get
return _DocID; {
} CanReadProperty("DocID", true);
} if (_MyDocument != null) _DocID = _MyDocument.DocID;
private DocumentInfo _MyDocument; return _DocID;
public DocumentInfo MyDocument }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private DocumentInfo _MyDocument;
get public DocumentInfo MyDocument
{ {
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _MyDocument; get
} {
} CanReadProperty("MyDocument", true);
private DateTime _DTS = new DateTime(); if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
public DateTime DTS return _MyDocument;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTS = new DateTime();
{ public DateTime DTS
return _DTS; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _UserID = string.Empty; {
public string UserID CanReadProperty("DTS", true);
{ return _DTS;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _UserID = string.Empty;
return _UserID; public string UserID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
// CSLATODO: Replace base EntryInfo.ToString function as necessary get
/// <summary> {
/// Overrides Base ToString CanReadProperty("UserID", true);
/// </summary> return _UserID;
/// <returns>A string representation of current EntryInfo</returns> }
//public override string ToString() }
//{ // CSLATODO: Replace base EntryInfo.ToString function as necessary
// return base.ToString(); /// <summary>
//} /// Overrides Base ToString
// CSLATODO: Check EntryInfo.GetIdValue to assure that the ID returned is unique /// </summary>
/// <summary> /// <returns>A string representation of current EntryInfo</returns>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality //public override string ToString()
/// </summary> //{
/// <returns>A Unique ID for the current EntryInfo</returns> // return base.ToString();
protected override object GetIdValue() //}
{ // CSLATODO: Check EntryInfo.GetIdValue to assure that the ID returned is unique
return MyEntryInfoUnique; // Absolutely Unique ID /// <summary>
} /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
#endregion /// </summary>
#region Factory Methods /// <returns>A Unique ID for the current EntryInfo</returns>
private static int _EntryInfoUnique = 0; protected override object GetIdValue()
private static int EntryInfoUnique {
{ get { return ++_EntryInfoUnique; } } return MyEntryInfoUnique; // Absolutely Unique ID
private int _MyEntryInfoUnique = EntryInfoUnique; }
public int MyEntryInfoUnique // Absolutely Unique ID - Info #endregion
{ get { return _MyEntryInfoUnique; } } #region Factory Methods
protected EntryInfo() private static int _EntryInfoUnique = 0;
{/* require use of factory methods */ private static int EntryInfoUnique
AddToCache(this); { get { return ++_EntryInfoUnique; } }
} private int _MyEntryInfoUnique = EntryInfoUnique;
private bool _Disposed = false; public int MyEntryInfoUnique // Absolutely Unique ID - Info
private static int _CountCreated = 0; { get { return _MyEntryInfoUnique; } }
private static int _CountDisposed = 0; protected EntryInfo()
private static int _CountFinalized = 0; {/* require use of factory methods */
private static int IncrementCountCreated AddToCache(this);
{ get { return ++_CountCreated; } } }
private int _CountWhenCreated = IncrementCountCreated; private bool _Disposed = false;
public static int CountCreated private static int _CountCreated = 0;
{ get { return _CountCreated; } } private static int _CountDisposed = 0;
public static int CountNotDisposed private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int IncrementCountCreated
public static int CountNotFinalized { get { return ++_CountCreated; } }
{ get { return _CountCreated - _CountFinalized; } } private int _CountWhenCreated = IncrementCountCreated;
~EntryInfo() public static int CountCreated
{ { get { return _CountCreated; } }
_CountFinalized++; public static int CountNotDisposed
} { get { return _CountCreated - _CountDisposed; } }
public void Dispose() public static int CountNotFinalized
{ { get { return _CountCreated - _CountFinalized; } }
if (_Disposed) return; ~EntryInfo()
_CountDisposed++; {
_Disposed = true; _CountFinalized++;
RemoveFromCache(this); }
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return; public void Dispose()
List<EntryInfo> listEntryInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items {
while (listEntryInfo.Contains(this)) listEntryInfo.Remove(this); // Remove the item from the list if (_Disposed) return;
if (listEntryInfo.Count == 0) // If there are no items left in the list _CountDisposed++;
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list _Disposed = true;
} RemoveFromCache(this);
public virtual Entry Get() if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
{ List<EntryInfo> listEntryInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
return _Editable = Entry.Get(_ContentID); while (listEntryInfo.Contains(this)) listEntryInfo.Remove(this); // Remove the item from the list
} if (listEntryInfo.Count == 0) // If there are no items left in the list
public static void Refresh(Entry tmp) _CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
{ }
string key = tmp.ContentID.ToString(); public virtual Entry Get()
ConvertListToDictionary(); {
if (_CacheByPrimaryKey.ContainsKey(key)) return _Editable = Entry.Get(_ContentID);
foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public static void Refresh(Entry tmp)
} {
protected virtual void RefreshFields(Entry tmp) string key = tmp.ContentID.ToString();
{ ConvertListToDictionary();
if (_DocID != tmp.DocID) if (_CacheByPrimaryKey.ContainsKey(key))
{ foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key])
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for old value tmpInfo.RefreshFields(tmp);
_DocID = tmp.DocID; // Update the value }
} protected virtual void RefreshFields(Entry tmp)
_MyDocument = null; // Reset list so that the next line gets a new list {
if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value if (_DocID != tmp.DocID)
_DTS = tmp.DTS; {
_UserID = tmp.UserID; if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for old value
_EntryInfoExtension.Refresh(this); _DocID = tmp.DocID; // Update the value
OnChange();// raise an event }
} _MyDocument = null; // Reset list so that the next line gets a new list
public static void Refresh(DocumentEntry tmp) if (MyDocument != null) MyDocument.RefreshDocumentEntries(); // Update List for new value
{ _DTS = tmp.DTS;
string key = tmp.ContentID.ToString(); _UserID = tmp.UserID;
ConvertListToDictionary(); _EntryInfoExtension.Refresh(this);
if (_CacheByPrimaryKey.ContainsKey(key)) OnChange();// raise an event
foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public static void Refresh(DocumentEntry tmp)
} {
protected virtual void RefreshFields(DocumentEntry tmp) string key = tmp.ContentID.ToString();
{ ConvertListToDictionary();
_DTS = tmp.DTS; if (_CacheByPrimaryKey.ContainsKey(key))
_UserID = tmp.UserID; foreach (EntryInfo tmpInfo in _CacheByPrimaryKey[key])
_EntryInfoExtension.Refresh(this); tmpInfo.RefreshFields(tmp);
OnChange();// raise an event }
} protected virtual void RefreshFields(DocumentEntry tmp)
public static EntryInfo Get(int contentID) {
{ _DTS = tmp.DTS;
//if (!CanGetObject()) _UserID = tmp.UserID;
// throw new System.Security.SecurityException("User not authorized to view a Entry"); _EntryInfoExtension.Refresh(this);
try OnChange();// raise an event
{ }
EntryInfo tmp = GetCachedByPrimaryKey(contentID); public static EntryInfo Get(int contentID)
if (tmp == null) {
{ //if (!CanGetObject())
tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID)); // throw new System.Security.SecurityException("User not authorized to view a Entry");
AddToCache(tmp); try
} {
if (tmp.ErrorMessage == "No Record Found") EntryInfo tmp = GetCachedByPrimaryKey(contentID);
{ if (tmp == null)
tmp.Dispose(); // Clean-up EntryInfo {
tmp = null; tmp = DataPortal.Fetch<EntryInfo>(new PKCriteria(contentID));
} AddToCache(tmp);
return tmp; }
} if (tmp.ErrorMessage == "No Record Found")
catch (Exception ex) {
{ tmp.Dispose(); // Clean-up EntryInfo
throw new DbCslaException("Error on EntryInfo.Get", ex); tmp = null;
} }
} return tmp;
#endregion }
#region Data Access Portal catch (Exception ex)
internal EntryInfo(SafeDataReader dr) {
{ throw new DbCslaException("Error on EntryInfo.Get", ex);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode()); }
try }
{ #endregion
ReadData(dr); #region Data Access Portal
} internal EntryInfo(SafeDataReader dr)
catch (Exception ex) {
{ if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.Constructor", GetHashCode());
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.Constructor", ex); try
throw new DbCslaException("EntryInfo.Constructor", ex); {
} ReadData(dr);
} }
[Serializable()] catch (Exception ex)
protected class PKCriteria {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.Constructor", ex);
private int _ContentID; throw new DbCslaException("EntryInfo.Constructor", ex);
public int ContentID }
{ get { return _ContentID; } } }
public PKCriteria(int contentID) [Serializable()]
{ protected class PKCriteria
_ContentID = contentID; {
} private int _ContentID;
} public int ContentID
private void ReadData(SafeDataReader dr) { get { return _ContentID; } }
{ public PKCriteria(int contentID)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode()); {
try _ContentID = contentID;
{ }
_ContentID = dr.GetInt32("ContentID"); }
_DocID = dr.GetInt32("DocID"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.ReadData", GetHashCode());
} try
catch (Exception ex) {
{ _ContentID = dr.GetInt32("ContentID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex); _DocID = dr.GetInt32("DocID");
_ErrorMessage = ex.Message; _DTS = dr.GetDateTime("DTS");
throw new DbCslaException("EntryInfo.ReadData", ex); _UserID = dr.GetString("UserID");
} }
} catch (Exception ex)
private void DataPortal_Fetch(PKCriteria criteria) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.ReadData", ex);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode()); _ErrorMessage = ex.Message;
try throw new DbCslaException("EntryInfo.ReadData", ex);
{ }
using (SqlConnection cn = Database.VEPROMS_SqlConnection) }
{ private void DataPortal_Fetch(PKCriteria criteria)
ApplicationContext.LocalContext["cn"] = cn; {
using (SqlCommand cm = cn.CreateCommand()) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] EntryInfo.DataPortal_Fetch", GetHashCode());
{ try
cm.CommandType = CommandType.StoredProcedure; {
cm.CommandText = "getEntry"; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); {
cm.CommandTimeout = Database.DefaultTimeout; ApplicationContext.LocalContext["cn"] = cn;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SqlCommand cm = cn.CreateCommand())
{ {
if (!dr.Read()) cm.CommandType = CommandType.StoredProcedure;
{ cm.CommandText = "getEntry";
_ErrorMessage = "No Record Found"; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
return; cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
ReadData(dr); {
} if (!dr.Read())
} {
// removing of item only needed for local data portal _ErrorMessage = "No Record Found";
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) return;
ApplicationContext.LocalContext.Remove("cn"); }
} ReadData(dr);
} }
catch (Exception ex) }
{ // removing of item only needed for local data portal
if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
_ErrorMessage = ex.Message; ApplicationContext.LocalContext.Remove("cn");
throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex); }
} }
} catch (Exception ex)
#endregion {
// Standard Refresh if (_MyLog.IsErrorEnabled) _MyLog.Error("EntryInfo.DataPortal_Fetch", ex);
#region extension _ErrorMessage = ex.Message;
EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension(); throw new DbCslaException("EntryInfo.DataPortal_Fetch", ex);
[Serializable()] }
partial class EntryInfoExtension : extensionBase { } }
[Serializable()] #endregion
class extensionBase // Standard Refresh
{ #region extension
// Default Refresh EntryInfoExtension _EntryInfoExtension = new EntryInfoExtension();
public virtual void Refresh(EntryInfo tmp) { } [Serializable()]
} partial class EntryInfoExtension : extensionBase { }
#endregion [Serializable()]
} // Class class extensionBase
#region Converter {
internal class EntryInfoConverter : ExpandableObjectConverter // Default Refresh
{ public virtual void Refresh(EntryInfo tmp) { }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) }
{ #endregion
if (destType == typeof(string) && value is EntryInfo) } // Class
{ #region Converter
// Return the ToString value internal class EntryInfoConverter : ExpandableObjectConverter
return ((EntryInfo)value).ToString(); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
return base.ConvertTo(context, culture, value, destType); {
} if (destType == typeof(string) && value is EntryInfo)
} {
#endregion // Return the ToString value
return ((EntryInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,437 +19,446 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void FigureInfoEvent(object sender); public delegate void FigureInfoEvent(object sender);
/// <summary> /// <summary>
/// FigureInfo Generated by MyGeneration using the CSLA Object Mapping template /// FigureInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(FigureInfoConverter))] [TypeConverter(typeof(FigureInfoConverter))]
public partial class FigureInfo : ReadOnlyBase<FigureInfo>, IDisposable public partial class FigureInfo : ReadOnlyBase<FigureInfo>, IDisposable
{ {
public event FigureInfoEvent Changed; public event FigureInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<FigureInfo> _CacheList = new List<FigureInfo>(); private static List<FigureInfo> _CacheList = new List<FigureInfo>();
protected static void AddToCache(FigureInfo figureInfo) protected static void AddToCache(FigureInfo figureInfo)
{ {
if (!_CacheList.Contains(figureInfo)) _CacheList.Add(figureInfo); // In AddToCache if (!_CacheList.Contains(figureInfo)) _CacheList.Add(figureInfo); // In AddToCache
} }
protected static void RemoveFromCache(FigureInfo figureInfo) protected static void RemoveFromCache(FigureInfo figureInfo)
{ {
while (_CacheList.Contains(figureInfo)) _CacheList.Remove(figureInfo); // In RemoveFromCache while (_CacheList.Contains(figureInfo)) _CacheList.Remove(figureInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<FigureInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FigureInfo>>(); private static Dictionary<string, List<FigureInfo>> _CacheByPrimaryKey = new Dictionary<string, List<FigureInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move FigureInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move FigureInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
FigureInfo tmp = _CacheList[0]; // Get the first FigureInfo FigureInfo tmp = _CacheList[0]; // Get the first FigureInfo
string pKey = tmp.FigureID.ToString(); string pKey = tmp.FigureID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<FigureInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<FigureInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first FigureInfo _CacheList.RemoveAt(0); // Remove the first FigureInfo
} }
} }
internal static void AddList(FigureInfoList lst) internal static void AddList(FigureInfoList lst)
{ {
foreach (FigureInfo item in lst) AddToCache(item); foreach (FigureInfo item in lst) AddToCache(item);
} }
protected static FigureInfo GetCachedByPrimaryKey(int figureID) protected static FigureInfo GetCachedByPrimaryKey(int figureID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = figureID.ToString(); string key = figureID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Figure _Editable; protected Figure _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _FigureID; private int _FigureID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int FigureID public int FigureID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _FigureID; CanReadProperty("FigureID", true);
} return _FigureID;
} }
private int _ROFstID; }
public int ROFstID private int _ROFstID;
{ public int ROFstID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID; {
return _ROFstID; CanReadProperty("ROFstID", true);
} if (_MyROFst != null) _ROFstID = _MyROFst.ROFstID;
} return _ROFstID;
private ROFstInfo _MyROFst; }
public ROFstInfo MyROFst }
{ private ROFstInfo _MyROFst;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public ROFstInfo MyROFst
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID); get
return _MyROFst; {
} CanReadProperty("MyROFst", true);
} if (_MyROFst == null && _ROFstID != 0) _MyROFst = ROFstInfo.Get(_ROFstID);
private int _ImageID; return _MyROFst;
public int ImageID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _ImageID;
get public int ImageID
{ {
if (_MyROImage != null) _ImageID = _MyROImage.ImageID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ImageID; get
} {
} CanReadProperty("ImageID", true);
private ROImageInfo _MyROImage; if (_MyROImage != null) _ImageID = _MyROImage.ImageID;
public ROImageInfo MyROImage return _ImageID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private ROImageInfo _MyROImage;
{ public ROImageInfo MyROImage
if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImageInfo.Get(_ImageID); {
return _MyROImage; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _Config = string.Empty; CanReadProperty("MyROImage", true);
public string Config if (_MyROImage == null && _ImageID != 0) _MyROImage = ROImageInfo.Get(_ImageID);
{ return _MyROImage;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
// CSLATODO: Replace base FigureInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current FigureInfo</returns> CanReadProperty("UserID", true);
//public override string ToString() return _UserID;
//{ }
// return base.ToString(); }
//} // CSLATODO: Replace base FigureInfo.ToString function as necessary
// CSLATODO: Check FigureInfo.GetIdValue to assure that the ID returned is unique /// <summary>
/// <summary> /// Overrides Base ToString
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// </summary>
/// </summary> /// <returns>A string representation of current FigureInfo</returns>
/// <returns>A Unique ID for the current FigureInfo</returns> //public override string ToString()
protected override object GetIdValue() //{
{ // return base.ToString();
return MyFigureInfoUnique; // Absolutely Unique ID //}
} // CSLATODO: Check FigureInfo.GetIdValue to assure that the ID returned is unique
#endregion /// <summary>
#region Factory Methods /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int _FigureInfoUnique = 0; /// </summary>
private static int FigureInfoUnique /// <returns>A Unique ID for the current FigureInfo</returns>
{ get { return ++_FigureInfoUnique; } } protected override object GetIdValue()
private int _MyFigureInfoUnique = FigureInfoUnique; {
public int MyFigureInfoUnique // Absolutely Unique ID - Info return MyFigureInfoUnique; // Absolutely Unique ID
{ get { return _MyFigureInfoUnique; } } }
protected FigureInfo() #endregion
{/* require use of factory methods */ #region Factory Methods
AddToCache(this); private static int _FigureInfoUnique = 0;
} private static int FigureInfoUnique
private bool _Disposed = false; { get { return ++_FigureInfoUnique; } }
private static int _CountCreated = 0; private int _MyFigureInfoUnique = FigureInfoUnique;
private static int _CountDisposed = 0; public int MyFigureInfoUnique // Absolutely Unique ID - Info
private static int _CountFinalized = 0; { get { return _MyFigureInfoUnique; } }
private static int IncrementCountCreated protected FigureInfo()
{ get { return ++_CountCreated; } } {/* require use of factory methods */
private int _CountWhenCreated = IncrementCountCreated; AddToCache(this);
public static int CountCreated }
{ get { return _CountCreated; } } private bool _Disposed = false;
public static int CountNotDisposed private static int _CountCreated = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountDisposed = 0;
public static int CountNotFinalized private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int IncrementCountCreated
~FigureInfo() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
_CountFinalized++; public static int CountCreated
} { get { return _CountCreated; } }
public void Dispose() public static int CountNotDisposed
{ { get { return _CountCreated - _CountDisposed; } }
if (_Disposed) return; public static int CountNotFinalized
_CountDisposed++; { get { return _CountCreated - _CountFinalized; } }
_Disposed = true; ~FigureInfo()
RemoveFromCache(this); {
if (!_CacheByPrimaryKey.ContainsKey(FigureID.ToString())) return; _CountFinalized++;
List<FigureInfo> listFigureInfo = _CacheByPrimaryKey[FigureID.ToString()]; // Get the list of items }
while (listFigureInfo.Contains(this)) listFigureInfo.Remove(this); // Remove the item from the list public void Dispose()
if (listFigureInfo.Count == 0) // If there are no items left in the list {
_CacheByPrimaryKey.Remove(FigureID.ToString()); // remove the list if (_Disposed) return;
} _CountDisposed++;
public virtual Figure Get() _Disposed = true;
{ RemoveFromCache(this);
return _Editable = Figure.Get(_FigureID); if (!_CacheByPrimaryKey.ContainsKey(FigureID.ToString())) return;
} List<FigureInfo> listFigureInfo = _CacheByPrimaryKey[FigureID.ToString()]; // Get the list of items
public static void Refresh(Figure tmp) while (listFigureInfo.Contains(this)) listFigureInfo.Remove(this); // Remove the item from the list
{ if (listFigureInfo.Count == 0) // If there are no items left in the list
string key = tmp.FigureID.ToString(); _CacheByPrimaryKey.Remove(FigureID.ToString()); // remove the list
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) public virtual Figure Get()
foreach (FigureInfo tmpInfo in _CacheByPrimaryKey[key]) {
tmpInfo.RefreshFields(tmp); return _Editable = Figure.Get(_FigureID);
} }
protected virtual void RefreshFields(Figure tmp) public static void Refresh(Figure tmp)
{ {
if (_ROFstID != tmp.ROFstID) string key = tmp.FigureID.ToString();
{ ConvertListToDictionary();
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_ROFstID = tmp.ROFstID; // Update the value foreach (FigureInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyROFst = null; // Reset list so that the next line gets a new list }
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value protected virtual void RefreshFields(Figure tmp)
if (_ImageID != tmp.ImageID) {
{ if (_ROFstID != tmp.ROFstID)
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value {
_ImageID = tmp.ImageID; // Update the value if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value
} _ROFstID = tmp.ROFstID; // Update the value
_MyROImage = null; // Reset list so that the next line gets a new list }
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value _MyROFst = null; // Reset list so that the next line gets a new list
_Config = tmp.Config; if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value
_DTS = tmp.DTS; if (_ImageID != tmp.ImageID)
_UserID = tmp.UserID; {
_FigureInfoExtension.Refresh(this); if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value
OnChange();// raise an event _ImageID = tmp.ImageID; // Update the value
} }
public static void Refresh(ROFstFigure tmp) _MyROImage = null; // Reset list so that the next line gets a new list
{ if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value
string key = tmp.FigureID.ToString(); _Config = tmp.Config;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (FigureInfo tmpInfo in _CacheByPrimaryKey[key]) _FigureInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(ROFstFigure tmp) public static void Refresh(ROFstFigure tmp)
{ {
if (_ImageID != tmp.ImageID) string key = tmp.FigureID.ToString();
{ ConvertListToDictionary();
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_ImageID = tmp.ImageID; // Update the value foreach (FigureInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyROImage = null; // Reset list so that the next line gets a new list }
if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value protected virtual void RefreshFields(ROFstFigure tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_ImageID != tmp.ImageID)
_UserID = tmp.UserID; {
_FigureInfoExtension.Refresh(this); if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for old value
OnChange();// raise an event _ImageID = tmp.ImageID; // Update the value
} }
public static void Refresh(ROImageFigure tmp) _MyROImage = null; // Reset list so that the next line gets a new list
{ if (MyROImage != null) MyROImage.RefreshROImageFigures(); // Update List for new value
string key = tmp.FigureID.ToString(); _Config = tmp.Config;
ConvertListToDictionary(); _DTS = tmp.DTS;
if (_CacheByPrimaryKey.ContainsKey(key)) _UserID = tmp.UserID;
foreach (FigureInfo tmpInfo in _CacheByPrimaryKey[key]) _FigureInfoExtension.Refresh(this);
tmpInfo.RefreshFields(tmp); OnChange();// raise an event
} }
protected virtual void RefreshFields(ROImageFigure tmp) public static void Refresh(ROImageFigure tmp)
{ {
if (_ROFstID != tmp.ROFstID) string key = tmp.FigureID.ToString();
{ ConvertListToDictionary();
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value if (_CacheByPrimaryKey.ContainsKey(key))
_ROFstID = tmp.ROFstID; // Update the value foreach (FigureInfo tmpInfo in _CacheByPrimaryKey[key])
} tmpInfo.RefreshFields(tmp);
_MyROFst = null; // Reset list so that the next line gets a new list }
if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value protected virtual void RefreshFields(ROImageFigure tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_ROFstID != tmp.ROFstID)
_UserID = tmp.UserID; {
_FigureInfoExtension.Refresh(this); if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for old value
OnChange();// raise an event _ROFstID = tmp.ROFstID; // Update the value
} }
public static FigureInfo Get(int figureID) _MyROFst = null; // Reset list so that the next line gets a new list
{ if (MyROFst != null) MyROFst.RefreshROFstFigures(); // Update List for new value
//if (!CanGetObject()) _Config = tmp.Config;
// throw new System.Security.SecurityException("User not authorized to view a Figure"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _FigureInfoExtension.Refresh(this);
FigureInfo tmp = GetCachedByPrimaryKey(figureID); OnChange();// raise an event
if (tmp == null) }
{ public static FigureInfo Get(int figureID)
tmp = DataPortal.Fetch<FigureInfo>(new PKCriteria(figureID)); {
AddToCache(tmp); //if (!CanGetObject())
} // throw new System.Security.SecurityException("User not authorized to view a Figure");
if (tmp.ErrorMessage == "No Record Found") try
{ {
tmp.Dispose(); // Clean-up FigureInfo FigureInfo tmp = GetCachedByPrimaryKey(figureID);
tmp = null; if (tmp == null)
} {
return tmp; tmp = DataPortal.Fetch<FigureInfo>(new PKCriteria(figureID));
} AddToCache(tmp);
catch (Exception ex) }
{ if (tmp.ErrorMessage == "No Record Found")
throw new DbCslaException("Error on FigureInfo.Get", ex); {
} tmp.Dispose(); // Clean-up FigureInfo
} tmp = null;
#endregion }
#region Data Access Portal return tmp;
internal FigureInfo(SafeDataReader dr) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.Constructor", GetHashCode()); {
try throw new DbCslaException("Error on FigureInfo.Get", ex);
{ }
ReadData(dr); }
} #endregion
catch (Exception ex) #region Data Access Portal
{ internal FigureInfo(SafeDataReader dr)
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfo.Constructor", ex); {
throw new DbCslaException("FigureInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.Constructor", GetHashCode());
} try
} {
[Serializable()] ReadData(dr);
protected class PKCriteria }
{ catch (Exception ex)
private int _FigureID; {
public int FigureID if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfo.Constructor", ex);
{ get { return _FigureID; } } throw new DbCslaException("FigureInfo.Constructor", ex);
public PKCriteria(int figureID) }
{ }
_FigureID = figureID; [Serializable()]
} protected class PKCriteria
} {
private string _ROImage_FileName = string.Empty; private int _FigureID;
public string ROImage_FileName public int FigureID
{ { get { return _FigureID; } }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public PKCriteria(int figureID)
get {
{ _FigureID = figureID;
return _ROImage_FileName; }
} }
} private string _ROImage_FileName = string.Empty;
private void ReadData(SafeDataReader dr) public string ROImage_FileName
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.ReadData", GetHashCode()); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
try get
{ {
_FigureID = dr.GetInt32("FigureID"); CanReadProperty("ROImage_FileName", true);
_ROFstID = dr.GetInt32("ROFstID"); return _ROImage_FileName;
_ImageID = dr.GetInt32("ImageID"); }
_Config = dr.GetString("Config"); }
_DTS = dr.GetDateTime("DTS"); private void ReadData(SafeDataReader dr)
_UserID = dr.GetString("UserID"); {
for (int i = 0; i < dr.FieldCount; i++) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.ReadData", GetHashCode());
{ try
if (dr.GetName(i) == "ROImage_FileName") {
_ROImage_FileName = dr.GetString("ROImage_FileName"); _FigureID = dr.GetInt32("FigureID");
} _ROFstID = dr.GetInt32("ROFstID");
} _ImageID = dr.GetInt32("ImageID");
catch (Exception ex) _Config = dr.GetString("Config");
{ _DTS = dr.GetDateTime("DTS");
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfo.ReadData", ex); _UserID = dr.GetString("UserID");
_ErrorMessage = ex.Message; for (int i = 0; i < dr.FieldCount; i++)
throw new DbCslaException("FigureInfo.ReadData", ex); {
} if (dr.GetName(i) == "ROImage_FileName")
} _ROImage_FileName = dr.GetString("ROImage_FileName");
private void DataPortal_Fetch(PKCriteria criteria) }
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.DataPortal_Fetch", GetHashCode()); catch (Exception ex)
try {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfo.ReadData", ex);
using (SqlConnection cn = Database.VEPROMS_SqlConnection) _ErrorMessage = ex.Message;
{ throw new DbCslaException("FigureInfo.ReadData", ex);
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) }
{ private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandType = CommandType.StoredProcedure; {
cm.CommandText = "getFigure"; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FigureInfo.DataPortal_Fetch", GetHashCode());
cm.Parameters.AddWithValue("@FigureID", criteria.FigureID); try
cm.CommandTimeout = Database.DefaultTimeout; {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
if (!dr.Read()) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
_ErrorMessage = "No Record Found"; {
return; cm.CommandType = CommandType.StoredProcedure;
} cm.CommandText = "getFigure";
ReadData(dr); cm.Parameters.AddWithValue("@FigureID", criteria.FigureID);
} cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// removing of item only needed for local data portal {
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) if (!dr.Read())
ApplicationContext.LocalContext.Remove("cn"); {
} _ErrorMessage = "No Record Found";
} return;
catch (Exception ex) }
{ ReadData(dr);
if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; }
throw new DbCslaException("FigureInfo.DataPortal_Fetch", ex); // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
#endregion }
// Standard Refresh }
#region extension catch (Exception ex)
FigureInfoExtension _FigureInfoExtension = new FigureInfoExtension(); {
[Serializable()] if (_MyLog.IsErrorEnabled) _MyLog.Error("FigureInfo.DataPortal_Fetch", ex);
partial class FigureInfoExtension : extensionBase { } _ErrorMessage = ex.Message;
[Serializable()] throw new DbCslaException("FigureInfo.DataPortal_Fetch", ex);
class extensionBase }
{ }
// Default Refresh #endregion
public virtual void Refresh(FigureInfo tmp) { } // Standard Refresh
} #region extension
#endregion FigureInfoExtension _FigureInfoExtension = new FigureInfoExtension();
} // Class [Serializable()]
#region Converter partial class FigureInfoExtension : extensionBase { }
internal class FigureInfoConverter : ExpandableObjectConverter [Serializable()]
{ class extensionBase
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) {
{ // Default Refresh
if (destType == typeof(string) && value is FigureInfo) public virtual void Refresh(FigureInfo tmp) { }
{ }
// Return the ToString value #endregion
return ((FigureInfo)value).ToString(); } // Class
} #region Converter
return base.ConvertTo(context, culture, value, destType); internal class FigureInfoConverter : ExpandableObjectConverter
} {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
#endregion {
if (destType == typeof(string) && value is FigureInfo)
{
// Return the ToString value
return ((FigureInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -20,462 +20,476 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// FormatContent Generated by MyGeneration using the CSLA Object Mapping template /// FormatContent Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(FormatContentConverter))] [TypeConverter(typeof(FormatContentConverter))]
public partial class FormatContent : BusinessBase<FormatContent>, IVEHasBrokenRules, IDisposable public partial class FormatContent : BusinessBase<FormatContent>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _ContentID; private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int ContentID public int ContentID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyContent != null) _ContentID = _MyContent.ContentID; CanReadProperty("ContentID", true);
return _ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
} return _ContentID;
} }
private Content _MyContent; }
[System.ComponentModel.DataObjectField(true, true)] private Content _MyContent;
public Content MyContent [System.ComponentModel.DataObjectField(true, true)]
{ public Content MyContent
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); {
return _MyContent; CanReadProperty("MyContent", true);
} if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
} return _MyContent;
private string _Number = string.Empty; }
/// <summary> }
/// Increased from 30 to 256 to support RTF symbols private string _Number = string.Empty;
/// </summary> /// <summary>
public string Number /// Increased from 30 to 256 to support RTF symbols
{ /// </summary>
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Number
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Number; get
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("Number", true);
set return _Number;
{ }
if (value == null) value = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_Number != value) set
{ {
_Number = value; CanWriteProperty("Number", true);
PropertyHasChanged(); if (value == null) value = string.Empty;
} if (_Number != value)
} {
} _Number = value;
private string _Text = string.Empty; PropertyHasChanged();
public string Text }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private string _Text = string.Empty;
{ public string Text
return _Text; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
set {
{ CanReadProperty("Text", true);
if (value == null) value = string.Empty; return _Text;
if (_Text != value) }
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_Text = value; set
PropertyHasChanged(); {
} CanWriteProperty("Text", true);
} if (value == null) value = string.Empty;
} if (_Text != value)
private int? _Type; {
/// <summary> _Text = value;
/// 0 - Procedure, 10000 - Section, 20000 Step PropertyHasChanged();
/// </summary> }
public int? Type }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int? _Type;
get /// <summary>
{ /// 0 - Procedure, 10000 - Section, 20000 Step
return _Type; /// </summary>
} public int? Type
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
set [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_Type != value) {
{ CanReadProperty("Type", true);
_Type = value; return _Type;
PropertyHasChanged(); }
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
} {
private string _Config = string.Empty; CanWriteProperty("Type", true);
public string Config if (_Type != value)
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] _Type = value;
get PropertyHasChanged();
{ }
return _Config; }
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Config = string.Empty;
set public string Config
{ {
if (value == null) value = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_Config != value) get
{ {
_Config = value; CanReadProperty("Config", true);
PropertyHasChanged(); return _Config;
} }
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} set
private DateTime _DTS = new DateTime(); {
public DateTime DTS CanWriteProperty("Config", true);
{ if (value == null) value = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_Config != value)
get {
{ _Config = value;
return _DTS; PropertyHasChanged();
} }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
set }
{ private DateTime _DTS = new DateTime();
if (_DTS != value) public DateTime DTS
{ {
_DTS = value; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
PropertyHasChanged(); get
} {
} CanReadProperty("DTS", true);
} return _DTS;
private string _UserID = string.Empty; }
public string UserID [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ set
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanWriteProperty("DTS", true);
{ if (_DTS != value)
return _UserID; {
} _DTS = value;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] PropertyHasChanged();
set }
{ }
if (value == null) value = string.Empty; }
if (_UserID != value) private string _UserID = string.Empty;
{ public string UserID
_UserID = value; {
PropertyHasChanged(); [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
} CanReadProperty("UserID", true);
private byte[] _LastChanged = new byte[8];//timestamp return _UserID;
// CSLATODO: Check FormatContent.GetIdValue to assure that the ID returned is unique }
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality set
/// </summary> {
/// <returns>A Unique ID for the current FormatContent</returns> CanWriteProperty("UserID", true);
protected override object GetIdValue() if (value == null) value = string.Empty;
{ if (_UserID != value)
return MyFormatContentUnique; // Absolutely Unique ID {
} _UserID = value;
// CSLATODO: Replace base FormatContent.ToString function as necessary PropertyHasChanged();
/// <summary> }
/// Overrides Base ToString }
/// </summary> }
/// <returns>A string representation of current FormatContent</returns> private byte[] _LastChanged = new byte[8];//timestamp
//public override string ToString() // CSLATODO: Check FormatContent.GetIdValue to assure that the ID returned is unique
//{ /// <summary>
// return base.ToString(); /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
//} /// </summary>
public override bool IsDirty /// <returns>A Unique ID for the current FormatContent</returns>
{ protected override object GetIdValue()
get { return base.IsDirty; } {
} return MyFormatContentUnique; // Absolutely Unique ID
public bool IsDirtyList(List<object> list) }
{ // CSLATODO: Replace base FormatContent.ToString function as necessary
return base.IsDirty; /// <summary>
} /// Overrides Base ToString
public override bool IsValid /// </summary>
{ /// <returns>A string representation of current FormatContent</returns>
get { return (IsNew && !IsDirty) ? true : base.IsValid; } //public override string ToString()
} //{
public bool IsValidList(List<object> list) // return base.ToString();
{ //}
return (IsNew && !IsDirty) ? true : base.IsValid; public override bool IsDirty
} {
#endregion get { return base.IsDirty; }
#region ValidationRules }
[NonSerialized] public bool IsDirtyList(List<object> list)
private bool _CheckingBrokenRules = false; {
public IVEHasBrokenRules HasBrokenRules return base.IsDirty;
{ }
get public override bool IsValid
{ {
if (_CheckingBrokenRules) return null; get { return (IsNew && !IsDirty) ? true : base.IsValid; }
if (BrokenRulesCollection.Count > 0) return this; }
try public bool IsValidList(List<object> list)
{ {
_CheckingBrokenRules = true; return (IsNew && !IsDirty) ? true : base.IsValid;
IVEHasBrokenRules hasBrokenRules = null; }
return hasBrokenRules; #endregion
} #region ValidationRules
finally [NonSerialized]
{ private bool _CheckingBrokenRules = false;
_CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules
} {
} get
} {
public BrokenRulesCollection BrokenRules if (_CheckingBrokenRules) return null;
{ if (BrokenRulesCollection.Count > 0) return this;
get try
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; _CheckingBrokenRules = true;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; IVEHasBrokenRules hasBrokenRules = null;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return hasBrokenRules;
} }
} finally
protected override void AddBusinessRules() {
{ _CheckingBrokenRules = false;
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringMaxLength, }
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 256)); }
ValidationRules.AddRule( public BrokenRulesCollection BrokenRules
Csla.Validation.CommonRules.StringMaxLength, {
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823)); get
ValidationRules.AddRule( {
Csla.Validation.CommonRules.StringMaxLength, IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
ValidationRules.AddRule( return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
Csla.Validation.CommonRules.StringRequired, "UserID"); }
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringMaxLength, protected override void AddBusinessRules()
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); {
// CSLATODO: Add other validation rules ValidationRules.AddRule(
} Csla.Validation.CommonRules.StringMaxLength,
// Sample data comparison validation rule new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 256));
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) ValidationRules.AddRule(
//{ Csla.Validation.CommonRules.StringMaxLength,
// if (_started > _ended) new Csla.Validation.CommonRules.MaxLengthRuleArgs("Text", 1073741823));
// { ValidationRules.AddRule(
// e.Description = "Start date can't be after end date"; Csla.Validation.CommonRules.StringMaxLength,
// return false; new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
// } ValidationRules.AddRule(
// else Csla.Validation.CommonRules.StringRequired, "UserID");
// return true; ValidationRules.AddRule(
//} Csla.Validation.CommonRules.StringMaxLength,
#endregion new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
#region Authorization Rules // CSLATODO: Add other validation rules
protected override void AddAuthorizationRules() }
{ // Sample data comparison validation rule
//CSLATODO: Who can read/write which fields //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>"); //{
//AuthorizationRules.AllowRead(Number, "<Role(s)>"); // if (_started > _ended)
//AuthorizationRules.AllowWrite(Number, "<Role(s)>"); // {
//AuthorizationRules.AllowRead(Text, "<Role(s)>"); // e.Description = "Start date can't be after end date";
//AuthorizationRules.AllowWrite(Text, "<Role(s)>"); // return false;
//AuthorizationRules.AllowRead(Type, "<Role(s)>"); // }
//AuthorizationRules.AllowWrite(Type, "<Role(s)>"); // else
//AuthorizationRules.AllowRead(Config, "<Role(s)>"); // return true;
//AuthorizationRules.AllowWrite(Config, "<Role(s)>"); //}
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); #endregion
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); #region Authorization Rules
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); protected override void AddAuthorizationRules()
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); {
} //CSLATODO: Who can read/write which fields
public static bool CanAddObject() //AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
{ //AuthorizationRules.AllowRead(Number, "<Role(s)>");
// CSLATODO: Can Add Authorization //AuthorizationRules.AllowWrite(Number, "<Role(s)>");
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); //AuthorizationRules.AllowRead(Text, "<Role(s)>");
return true; //AuthorizationRules.AllowWrite(Text, "<Role(s)>");
} //AuthorizationRules.AllowRead(Type, "<Role(s)>");
public static bool CanGetObject() //AuthorizationRules.AllowWrite(Type, "<Role(s)>");
{ //AuthorizationRules.AllowRead(Config, "<Role(s)>");
// CSLATODO: CanGet Authorization //AuthorizationRules.AllowWrite(Config, "<Role(s)>");
return true; //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
} //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
public static bool CanDeleteObject() //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
{ //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
// CSLATODO: CanDelete Authorization }
//bool result = false; public static bool CanAddObject()
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; {
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; // CSLATODO: Can Add Authorization
//return result; //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true; return true;
} }
public static bool CanEditObject() public static bool CanGetObject()
{ {
// CSLATODO: CanEdit Authorization // CSLATODO: CanGet Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); return true;
return true; }
} public static bool CanDeleteObject()
#endregion {
#region Factory Methods // CSLATODO: CanDelete Authorization
public int CurrentEditLevel //bool result = false;
{ get { return EditLevel; } } //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
private static int _FormatContentUnique = 0; //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
private static int FormatContentUnique //return result;
{ get { return ++_FormatContentUnique; } } return true;
private int _MyFormatContentUnique = FormatContentUnique; }
public int MyFormatContentUnique // Absolutely Unique ID - Editable FK public static bool CanEditObject()
{ get { return _MyFormatContentUnique; } } {
internal static FormatContent New() // CSLATODO: CanEdit Authorization
{ //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return new FormatContent(); return true;
} }
internal static FormatContent Get(SafeDataReader dr) #endregion
{ #region Factory Methods
return new FormatContent(dr); public int CurrentEditLevel
} { get { return EditLevel; } }
public FormatContent() private static int _FormatContentUnique = 0;
{ private static int FormatContentUnique
MarkAsChild(); { get { return ++_FormatContentUnique; } }
_ContentID = Content.NextContentID; private int _MyFormatContentUnique = FormatContentUnique;
_DTS = _FormatContentExtension.DefaultDTS; public int MyFormatContentUnique // Absolutely Unique ID - Editable FK
_UserID = _FormatContentExtension.DefaultUserID; { get { return _MyFormatContentUnique; } }
ValidationRules.CheckRules(); internal static FormatContent New()
} {
internal FormatContent(SafeDataReader dr) return new FormatContent();
{ }
MarkAsChild(); internal static FormatContent Get(SafeDataReader dr)
Fetch(dr); {
} return new FormatContent(dr);
private bool _Disposed = false; }
private static int _CountCreated = 0; public FormatContent()
private static int _CountDisposed = 0; {
private static int _CountFinalized = 0; MarkAsChild();
private static int IncrementCountCreated _ContentID = Content.NextContentID;
{ get { return ++_CountCreated; } } _DTS = _FormatContentExtension.DefaultDTS;
private int _CountWhenCreated = IncrementCountCreated; _UserID = _FormatContentExtension.DefaultUserID;
public static int CountCreated ValidationRules.CheckRules();
{ get { return _CountCreated; } } }
public static int CountNotDisposed internal FormatContent(SafeDataReader dr)
{ get { return _CountCreated - _CountDisposed; } } {
public static int CountNotFinalized MarkAsChild();
{ get { return _CountCreated - _CountFinalized; } } Fetch(dr);
~FormatContent() }
{ private bool _Disposed = false;
_CountFinalized++; private static int _CountCreated = 0;
} private static int _CountDisposed = 0;
public void Dispose() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
if (_Disposed) return; { get { return ++_CountCreated; } }
_CountDisposed++; private int _CountWhenCreated = IncrementCountCreated;
_Disposed = true; public static int CountCreated
} { get { return _CountCreated; } }
#endregion public static int CountNotDisposed
#region Data Access Portal { get { return _CountCreated - _CountDisposed; } }
private void Fetch(SafeDataReader dr) public static int CountNotFinalized
{ { get { return _CountCreated - _CountFinalized; } }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode()); ~FormatContent()
try {
{ _CountFinalized++;
_ContentID = dr.GetInt32("ContentID"); }
_Number = dr.GetString("Number"); public void Dispose()
_Text = dr.GetString("Text"); {
_Type = (int?)dr.GetValue("Type"); if (_Disposed) return;
_Config = dr.GetString("Config"); _CountDisposed++;
_DTS = dr.GetDateTime("DTS"); _Disposed = true;
_UserID = dr.GetString("UserID"); }
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); #endregion
} #region Data Access Portal
catch (Exception ex) // FKItem Fetch private void Fetch(SafeDataReader dr)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContent.FetchDR", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatContent.FetchDR", GetHashCode());
throw new DbCslaException("FormatContent.Fetch", ex); try
} {
MarkOld(); _ContentID = dr.GetInt32("ContentID");
} _Number = dr.GetString("Number");
internal void Insert(Format myFormat) _Text = dr.GetString("Text");
{ _Type = (int?)dr.GetValue("Type");
// if we're not dirty then don't update the database _Config = dr.GetString("Config");
if (!this.IsDirty) return; _DTS = dr.GetDateTime("DTS");
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; _UserID = dr.GetString("UserID");
_LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID); dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
MarkOld(); }
} catch (Exception ex) // FKItem Fetch
internal void Update(Format myFormat) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("FormatContent.FetchDR", ex);
// if we're not dirty then don't update the database throw new DbCslaException("FormatContent.Fetch", ex);
if (!this.IsDirty) return; }
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; MarkOld();
_LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat != null ? (int?)myFormat.FormatID : (int?)null, _Config, _DTS, _UserID, ref _LastChanged); }
MarkOld(); internal void Insert(Format myFormat)
} {
internal void DeleteSelf(Format myFormat) // if we're not dirty then don't update the database
{ if (!this.IsDirty) return;
// if we're not dirty then don't update the database SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
if (!this.IsDirty) return; _LastChanged = Content.Add(cn, ref _ContentID, _Number, _Text, _Type, myFormat, _Config, _DTS, _UserID);
// if we're new then don't update the database MarkOld();
if (this.IsNew) return; }
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; internal void Update(Format myFormat)
Content.Remove(cn, _ContentID); {
MarkNew(); // if we're not dirty then don't update the database
} if (!this.IsDirty) return;
#endregion SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
// Standard Default Code _LastChanged = Content.Update(cn, ref _ContentID, _Number, _Text, _Type, myFormat != null ? (int?) myFormat.FormatID : (int?) null, _Config, _DTS, _UserID, ref _LastChanged);
#region extension MarkOld();
FormatContentExtension _FormatContentExtension = new FormatContentExtension(); }
[Serializable()] internal void DeleteSelf(Format myFormat)
partial class FormatContentExtension : extensionBase {
{ // if we're not dirty then don't update the database
} if (!this.IsDirty) return;
[Serializable()] // if we're new then don't update the database
class extensionBase if (this.IsNew) return;
{ SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
// Default Values Content.Remove(cn, _ContentID);
public virtual DateTime DefaultDTS MarkNew();
{ }
get { return DateTime.Now; } #endregion
} // Standard Default Code
public virtual string DefaultUserID #region extension
{ FormatContentExtension _FormatContentExtension = new FormatContentExtension();
get { return Volian.Base.Library.VlnSettings.UserID; } [Serializable()]
} partial class FormatContentExtension : extensionBase
// Authorization Rules {
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) }
{ [Serializable()]
// Needs to be overriden to add new authorization rules class extensionBase
} {
// Instance Authorization Rules // Default Values
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual DateTime DefaultDTS
{ {
// Needs to be overriden to add new authorization rules get { return DateTime.Now; }
} }
// Validation Rules public virtual string DefaultUserID
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) {
{ get { return Volian.Base.Library.VlnSettings.UserID; }
// Needs to be overriden to add new validation rules }
} // Authorization Rules
// InstanceValidation Rules public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) {
{ // Needs to be overriden to add new authorization rules
// Needs to be overriden to add new validation rules }
} // Instance Authorization Rules
} public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
#endregion {
} // Class // Needs to be overriden to add new authorization rules
#region Converter }
internal class FormatContentConverter : ExpandableObjectConverter // Validation Rules
{ public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) {
{ // Needs to be overriden to add new validation rules
if (destType == typeof(string) && value is FormatContent) }
{ // InstanceValidation Rules
// Return the ToString value public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
return ((FormatContent)value).ToString(); {
} // Needs to be overriden to add new validation rules
return base.ConvertTo(context, culture, value, destType); }
} }
} #endregion
#endregion } // Class
#region Converter
internal class FormatContentConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is FormatContent)
{
// Return the ToString value
return ((FormatContent)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,365 +19,373 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void GridAuditInfoEvent(object sender); public delegate void GridAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// GridAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// GridAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(GridAuditInfoConverter))] [TypeConverter(typeof(GridAuditInfoConverter))]
public partial class GridAuditInfo : ReadOnlyBase<GridAuditInfo>, IDisposable public partial class GridAuditInfo : ReadOnlyBase<GridAuditInfo>, IDisposable
{ {
public event GridAuditInfoEvent Changed; public event GridAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<GridAuditInfo> _CacheList = new List<GridAuditInfo>(); private static List<GridAuditInfo> _CacheList = new List<GridAuditInfo>();
protected static void AddToCache(GridAuditInfo gridAuditInfo) protected static void AddToCache(GridAuditInfo gridAuditInfo)
{ {
if (!_CacheList.Contains(gridAuditInfo)) _CacheList.Add(gridAuditInfo); // In AddToCache if (!_CacheList.Contains(gridAuditInfo)) _CacheList.Add(gridAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(GridAuditInfo gridAuditInfo) protected static void RemoveFromCache(GridAuditInfo gridAuditInfo)
{ {
while (_CacheList.Contains(gridAuditInfo)) _CacheList.Remove(gridAuditInfo); // In RemoveFromCache while (_CacheList.Contains(gridAuditInfo)) _CacheList.Remove(gridAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<GridAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridAuditInfo>>(); private static Dictionary<string, List<GridAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move GridAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move GridAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
GridAuditInfo tmp = _CacheList[0]; // Get the first GridAuditInfo GridAuditInfo tmp = _CacheList[0]; // Get the first GridAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<GridAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<GridAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first GridAuditInfo _CacheList.RemoveAt(0); // Remove the first GridAuditInfo
} }
} }
internal static void AddList(GridAuditInfoList lst) internal static void AddList(GridAuditInfoList lst)
{ {
foreach (GridAuditInfo item in lst) AddToCache(item); foreach (GridAuditInfo item in lst) AddToCache(item);
} }
protected static GridAuditInfo GetCachedByPrimaryKey(long auditID) protected static GridAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected GridAudit _Editable; protected GridAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ContentID; {
} CanReadProperty("ContentID", true);
} return _ContentID;
private string _Data = string.Empty; }
public string Data }
{ private string _Data = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Data
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Data; get
} {
} CanReadProperty("Data", true);
private string _Config = string.Empty; return _Data;
public string Config }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Config = string.Empty;
get public string Config
{ {
return _Config; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private DateTime _DTS = new DateTime(); CanReadProperty("Config", true);
public DateTime DTS return _Config;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTS = new DateTime();
{ public DateTime DTS
return _DTS; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _UserID = string.Empty; {
public string UserID CanReadProperty("DTS", true);
{ return _DTS;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _UserID = string.Empty;
return _UserID; public string UserID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _DeleteStatus; get
public int DeleteStatus {
{ CanReadProperty("UserID", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _UserID;
get }
{ }
return _DeleteStatus; private int _DeleteStatus;
} public int DeleteStatus
} {
private long _ContentAuditID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public long ContentAuditID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DeleteStatus", true);
get return _DeleteStatus;
{ }
return _ContentAuditID; }
} private long _ContentAuditID;
} public long ContentAuditID
// CSLATODO: Replace base GridAuditInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current GridAuditInfo</returns> CanReadProperty("ContentAuditID", true);
//public override string ToString() return _ContentAuditID;
//{ }
// return base.ToString(); }
//} // CSLATODO: Replace base GridAuditInfo.ToString function as necessary
// CSLATODO: Check GridAuditInfo.GetIdValue to assure that the ID returned is unique /// <summary>
/// <summary> /// Overrides Base ToString
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// </summary>
/// </summary> /// <returns>A string representation of current GridAuditInfo</returns>
/// <returns>A Unique ID for the current GridAuditInfo</returns> //public override string ToString()
protected override object GetIdValue() //{
{ // return base.ToString();
return MyGridAuditInfoUnique; // Absolutely Unique ID //}
} // CSLATODO: Check GridAuditInfo.GetIdValue to assure that the ID returned is unique
#endregion /// <summary>
#region Factory Methods /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int _GridAuditInfoUnique = 0; /// </summary>
private static int GridAuditInfoUnique /// <returns>A Unique ID for the current GridAuditInfo</returns>
{ get { return ++_GridAuditInfoUnique; } } protected override object GetIdValue()
private int _MyGridAuditInfoUnique = GridAuditInfoUnique; {
public int MyGridAuditInfoUnique // Absolutely Unique ID - Info return MyGridAuditInfoUnique; // Absolutely Unique ID
{ get { return _MyGridAuditInfoUnique; } } }
protected GridAuditInfo() #endregion
{/* require use of factory methods */ #region Factory Methods
AddToCache(this); private static int _GridAuditInfoUnique = 0;
} private static int GridAuditInfoUnique
private bool _Disposed = false; { get { return ++_GridAuditInfoUnique; } }
private static int _CountCreated = 0; private int _MyGridAuditInfoUnique = GridAuditInfoUnique;
private static int _CountDisposed = 0; public int MyGridAuditInfoUnique // Absolutely Unique ID - Info
private static int _CountFinalized = 0; { get { return _MyGridAuditInfoUnique; } }
private static int IncrementCountCreated protected GridAuditInfo()
{ get { return ++_CountCreated; } } {/* require use of factory methods */
private int _CountWhenCreated = IncrementCountCreated; AddToCache(this);
public static int CountCreated }
{ get { return _CountCreated; } } private bool _Disposed = false;
public static int CountNotDisposed private static int _CountCreated = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountDisposed = 0;
public static int CountNotFinalized private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int IncrementCountCreated
~GridAuditInfo() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
_CountFinalized++; public static int CountCreated
} { get { return _CountCreated; } }
public void Dispose() public static int CountNotDisposed
{ { get { return _CountCreated - _CountDisposed; } }
if (_Disposed) return; public static int CountNotFinalized
_CountDisposed++; { get { return _CountCreated - _CountFinalized; } }
_Disposed = true; ~GridAuditInfo()
RemoveFromCache(this); {
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; _CountFinalized++;
List<GridAuditInfo> listGridAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items }
while (listGridAuditInfo.Contains(this)) listGridAuditInfo.Remove(this); // Remove the item from the list public void Dispose()
if (listGridAuditInfo.Count == 0) // If there are no items left in the list {
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list if (_Disposed) return;
} _CountDisposed++;
public virtual GridAudit Get() _Disposed = true;
{ RemoveFromCache(this);
return _Editable = GridAudit.Get(_AuditID); if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
} List<GridAuditInfo> listGridAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
public static void Refresh(GridAudit tmp) while (listGridAuditInfo.Contains(this)) listGridAuditInfo.Remove(this); // Remove the item from the list
{ if (listGridAuditInfo.Count == 0) // If there are no items left in the list
string key = tmp.AuditID.ToString(); _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) public virtual GridAudit Get()
foreach (GridAuditInfo tmpInfo in _CacheByPrimaryKey[key]) {
tmpInfo.RefreshFields(tmp); return _Editable = GridAudit.Get(_AuditID);
} }
protected virtual void RefreshFields(GridAudit tmp) public static void Refresh(GridAudit tmp)
{ {
_ContentID = tmp.ContentID; string key = tmp.AuditID.ToString();
_Data = tmp.Data; ConvertListToDictionary();
_Config = tmp.Config; if (_CacheByPrimaryKey.ContainsKey(key))
_DTS = tmp.DTS; foreach (GridAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_UserID = tmp.UserID; tmpInfo.RefreshFields(tmp);
_DeleteStatus = tmp.DeleteStatus; }
_ContentAuditID = tmp.ContentAuditID; protected virtual void RefreshFields(GridAudit tmp)
_GridAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ContentID = tmp.ContentID;
} _Data = tmp.Data;
public static GridAuditInfo Get(long auditID) _Config = tmp.Config;
{ _DTS = tmp.DTS;
//if (!CanGetObject()) _UserID = tmp.UserID;
// throw new System.Security.SecurityException("User not authorized to view a GridAudit"); _DeleteStatus = tmp.DeleteStatus;
try _ContentAuditID = tmp.ContentAuditID;
{ _GridAuditInfoExtension.Refresh(this);
GridAuditInfo tmp = GetCachedByPrimaryKey(auditID); OnChange();// raise an event
if (tmp == null) }
{ public static GridAuditInfo Get(long auditID)
tmp = DataPortal.Fetch<GridAuditInfo>(new PKCriteria(auditID)); {
AddToCache(tmp); //if (!CanGetObject())
} // throw new System.Security.SecurityException("User not authorized to view a GridAudit");
if (tmp.ErrorMessage == "No Record Found") try
{ {
tmp.Dispose(); // Clean-up GridAuditInfo GridAuditInfo tmp = GetCachedByPrimaryKey(auditID);
tmp = null; if (tmp == null)
} {
return tmp; tmp = DataPortal.Fetch<GridAuditInfo>(new PKCriteria(auditID));
} AddToCache(tmp);
catch (Exception ex) }
{ if (tmp.ErrorMessage == "No Record Found")
throw new DbCslaException("Error on GridAuditInfo.Get", ex); {
} tmp.Dispose(); // Clean-up GridAuditInfo
} tmp = null;
#endregion }
#region Data Access Portal return tmp;
internal GridAuditInfo(SafeDataReader dr) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.Constructor", GetHashCode()); {
try throw new DbCslaException("Error on GridAuditInfo.Get", ex);
{ }
ReadData(dr); }
} #endregion
catch (Exception ex) #region Data Access Portal
{ internal GridAuditInfo(SafeDataReader dr)
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.Constructor", ex); {
throw new DbCslaException("GridAuditInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.Constructor", GetHashCode());
} try
} {
[Serializable()] ReadData(dr);
protected class PKCriteria }
{ catch (Exception ex)
private long _AuditID; {
public long AuditID if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.Constructor", ex);
{ get { return _AuditID; } } throw new DbCslaException("GridAuditInfo.Constructor", ex);
public PKCriteria(long auditID) }
{ }
_AuditID = auditID; [Serializable()]
} protected class PKCriteria
} {
private void ReadData(SafeDataReader dr) private long _AuditID;
{ public long AuditID
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.ReadData", GetHashCode()); { get { return _AuditID; } }
try public PKCriteria(long auditID)
{ {
_AuditID = dr.GetInt64("AuditID"); _AuditID = auditID;
_ContentID = dr.GetInt32("ContentID"); }
_Data = dr.GetString("Data"); }
_Config = dr.GetString("Config"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.ReadData", GetHashCode());
_DeleteStatus = dr.GetInt32("DeleteStatus"); try
_ContentAuditID = dr.GetInt64("ContentAuditID"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _Data = dr.GetString("Data");
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.ReadData", ex); _Config = dr.GetString("Config");
_ErrorMessage = ex.Message; _DTS = dr.GetDateTime("DTS");
throw new DbCslaException("GridAuditInfo.ReadData", ex); _UserID = dr.GetString("UserID");
} _DeleteStatus = dr.GetInt32("DeleteStatus");
} _ContentAuditID = dr.GetInt64("ContentAuditID");
private void DataPortal_Fetch(PKCriteria criteria) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.DataPortal_Fetch", GetHashCode()); {
try if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
using (SqlConnection cn = Database.VEPROMS_SqlConnection) throw new DbCslaException("GridAuditInfo.ReadData", ex);
{ }
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) private void DataPortal_Fetch(PKCriteria criteria)
{ {
cm.CommandType = CommandType.StoredProcedure; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridAuditInfo.DataPortal_Fetch", GetHashCode());
cm.CommandText = "getGridAudit"; try
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); {
cm.CommandTimeout = Database.DefaultTimeout; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ ApplicationContext.LocalContext["cn"] = cn;
if (!dr.Read()) using (SqlCommand cm = cn.CreateCommand())
{ {
_ErrorMessage = "No Record Found"; cm.CommandType = CommandType.StoredProcedure;
return; cm.CommandText = "getGridAudit";
} cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
ReadData(dr); cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
// removing of item only needed for local data portal if (!dr.Read())
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); _ErrorMessage = "No Record Found";
} return;
} }
catch (Exception ex) ReadData(dr);
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; // removing of item only needed for local data portal
throw new DbCslaException("GridAuditInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
} }
#endregion }
// Standard Refresh catch (Exception ex)
#region extension {
GridAuditInfoExtension _GridAuditInfoExtension = new GridAuditInfoExtension(); if (_MyLog.IsErrorEnabled) _MyLog.Error("GridAuditInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
partial class GridAuditInfoExtension : extensionBase { } throw new DbCslaException("GridAuditInfo.DataPortal_Fetch", ex);
[Serializable()] }
class extensionBase }
{ #endregion
// Default Refresh // Standard Refresh
public virtual void Refresh(GridAuditInfo tmp) { } #region extension
} GridAuditInfoExtension _GridAuditInfoExtension = new GridAuditInfoExtension();
#endregion [Serializable()]
} // Class partial class GridAuditInfoExtension : extensionBase { }
#region Converter [Serializable()]
internal class GridAuditInfoConverter : ExpandableObjectConverter class extensionBase
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) // Default Refresh
{ public virtual void Refresh(GridAuditInfo tmp) { }
if (destType == typeof(string) && value is GridAuditInfo) }
{ #endregion
// Return the ToString value } // Class
return ((GridAuditInfo)value).ToString(); #region Converter
} internal class GridAuditInfoConverter : ExpandableObjectConverter
return base.ConvertTo(context, culture, value, destType); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
#endregion if (destType == typeof(string) && value is GridAuditInfo)
{
// Return the ToString value
return ((GridAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -17,364 +17,348 @@ using System.Configuration;
using System.IO; using System.IO;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void GridInfoEvent(object sender); public delegate void GridInfoEvent(object sender);
/// <summary> /// <summary>
/// GridInfo Generated by MyGeneration using the CSLA Object Mapping template /// GridInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(GridInfoConverter))] [TypeConverter(typeof(GridInfoConverter))]
public partial class GridInfo : ReadOnlyBase<GridInfo>, IDisposable public partial class GridInfo : ReadOnlyBase<GridInfo>, IDisposable
{ {
public event GridInfoEvent Changed; public event GridInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<GridInfo> _CacheList = new List<GridInfo>(); private static List<GridInfo> _CacheList = new List<GridInfo>();
protected static void AddToCache(GridInfo gridInfo) protected static void AddToCache(GridInfo gridInfo)
{ {
if (!_CacheList.Contains(gridInfo)) _CacheList.Add(gridInfo); // In AddToCache if (!_CacheList.Contains(gridInfo)) _CacheList.Add(gridInfo); // In AddToCache
} }
protected static void RemoveFromCache(GridInfo gridInfo) protected static void RemoveFromCache(GridInfo gridInfo)
{ {
while (_CacheList.Contains(gridInfo)) _CacheList.Remove(gridInfo); // In RemoveFromCache while (_CacheList.Contains(gridInfo)) _CacheList.Remove(gridInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<GridInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridInfo>>(); private static Dictionary<string, List<GridInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GridInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move GridInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move GridInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
GridInfo tmp = _CacheList[0]; // Get the first GridInfo GridInfo tmp = _CacheList[0]; // Get the first GridInfo
string pKey = tmp.ContentID.ToString(); string pKey = tmp.ContentID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<GridInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<GridInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first GridInfo _CacheList.RemoveAt(0); // Remove the first GridInfo
} }
} }
protected static GridInfo GetCachedByPrimaryKey(int contentID) protected static GridInfo GetCachedByPrimaryKey(int contentID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion
public static void ClearGridInfoCache() #region Business Methods
{ private string _ErrorMessage = string.Empty;
while (_CacheByPrimaryKey.Count > 0) public string ErrorMessage
{ {
var ii = _CacheByPrimaryKey.FirstOrDefault(); get { return _ErrorMessage; }
}
while (ii.Value.Count > 0) protected Grid _Editable;
{ private IVEHasBrokenRules HasBrokenRules
if (ii.Value[0]?.MyContent?.ContentParts != null) {
{ foreach (PartInfo pi in ii.Value[0]?.MyContent?.ContentParts) pi.Dispose(); } get
ii.Value[0].Dispose(); {
} IVEHasBrokenRules hasBrokenRules = null;
_CacheByPrimaryKey.Remove(ii.Key); if (_Editable != null)
} hasBrokenRules = _Editable.HasBrokenRules;
while (_CacheList.Count > 0) return hasBrokenRules;
{ }
_CacheList[0].Dispose(); }
} private int _ContentID;
} [System.ComponentModel.DataObjectField(true, true)]
#endregion public int ContentID
#region Business Methods {
private string _ErrorMessage = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string ErrorMessage get
{ {
get { return _ErrorMessage; } CanReadProperty("ContentID", true);
} if (_MyContent != null) _ContentID = _MyContent.ContentID;
protected Grid _Editable; return _ContentID;
private IVEHasBrokenRules HasBrokenRules }
{ }
get private ContentInfo _MyContent;
{ [System.ComponentModel.DataObjectField(true, true)]
IVEHasBrokenRules hasBrokenRules = null; public ContentInfo MyContent
if (_Editable != null) {
hasBrokenRules = _Editable.HasBrokenRules; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return hasBrokenRules; get
} {
} CanReadProperty("MyContent", true);
private int _ContentID; if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
[System.ComponentModel.DataObjectField(true, true)] return _MyContent;
public int ContentID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Data = string.Empty;
get public string Data
{ {
if (_MyContent != null) _ContentID = _MyContent.ContentID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ContentID; get
} {
} CanReadProperty("Data", true);
private ContentInfo _MyContent; return _Data;
[System.ComponentModel.DataObjectField(true, true)] }
public ContentInfo MyContent }
{ private string _Config = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Config
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); get
return _MyContent; {
} CanReadProperty("Config", true);
} return _Config;
private string _Data = string.Empty; }
public string Data }
{ private DateTime _DTS = new DateTime();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public DateTime DTS
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Data; get
} {
} CanReadProperty("DTS", true);
private string _Config = string.Empty; return _DTS;
public string Config }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _UserID = string.Empty;
get public string UserID
{ {
return _Config; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private DateTime _DTS = new DateTime(); CanReadProperty("UserID", true);
public DateTime DTS return _UserID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get // CSLATODO: Replace base GridInfo.ToString function as necessary
{ /// <summary>
return _DTS; /// Overrides Base ToString
} /// </summary>
} /// <returns>A string representation of current GridInfo</returns>
private string _UserID = string.Empty; //public override string ToString()
public string UserID //{
{ // return base.ToString();
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] //}
get // CSLATODO: Check GridInfo.GetIdValue to assure that the ID returned is unique
{ /// <summary>
return _UserID; /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
} /// </summary>
} /// <returns>A Unique ID for the current GridInfo</returns>
// CSLATODO: Replace base GridInfo.ToString function as necessary protected override object GetIdValue()
/// <summary> {
/// Overrides Base ToString return MyGridInfoUnique; // Absolutely Unique ID
/// </summary> }
/// <returns>A string representation of current GridInfo</returns> #endregion
//public override string ToString() #region Factory Methods
//{ private static int _GridInfoUnique = 0;
// return base.ToString(); private static int GridInfoUnique
//} { get { return ++_GridInfoUnique; } }
// CSLATODO: Check GridInfo.GetIdValue to assure that the ID returned is unique private int _MyGridInfoUnique = GridInfoUnique;
/// <summary> public int MyGridInfoUnique // Absolutely Unique ID - Info
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality { get { return _MyGridInfoUnique; } }
/// </summary> protected GridInfo()
/// <returns>A Unique ID for the current GridInfo</returns> {/* require use of factory methods */
protected override object GetIdValue() AddToCache(this);
{ }
return MyGridInfoUnique; // Absolutely Unique ID private bool _Disposed = false;
} private static int _CountCreated = 0;
#endregion private static int _CountDisposed = 0;
#region Factory Methods private static int _CountFinalized = 0;
private static int _GridInfoUnique = 0; private static int IncrementCountCreated
private static int GridInfoUnique { get { return ++_CountCreated; } }
{ get { return ++_GridInfoUnique; } } private int _CountWhenCreated = IncrementCountCreated;
private int _MyGridInfoUnique = GridInfoUnique; public static int CountCreated
public int MyGridInfoUnique // Absolutely Unique ID - Info { get { return _CountCreated; } }
{ get { return _MyGridInfoUnique; } } public static int CountNotDisposed
protected GridInfo() { get { return _CountCreated - _CountDisposed; } }
{/* require use of factory methods */ public static int CountNotFinalized
AddToCache(this); { get { return _CountCreated - _CountFinalized; } }
} ~GridInfo()
private bool _Disposed = false; {
private static int _CountCreated = 0; _CountFinalized++;
private static int _CountDisposed = 0; }
private static int _CountFinalized = 0; public void Dispose()
private static int IncrementCountCreated {
{ get { return ++_CountCreated; } } if (_Disposed) return;
private int _CountWhenCreated = IncrementCountCreated; _CountDisposed++;
public static int CountCreated _Disposed = true;
{ get { return _CountCreated; } } RemoveFromCache(this);
public static int CountNotDisposed if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
{ get { return _CountCreated - _CountDisposed; } } List<GridInfo> listGridInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
public static int CountNotFinalized while (listGridInfo.Contains(this)) listGridInfo.Remove(this); // Remove the item from the list
{ get { return _CountCreated - _CountFinalized; } } if (listGridInfo.Count == 0) // If there are no items left in the list
~GridInfo() _CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
{ }
_CountFinalized++; public virtual Grid Get()
} {
public void Dispose() return _Editable = Grid.Get(_ContentID);
{ }
if (_Disposed) return; public static void Refresh(Grid tmp)
_CountDisposed++; {
_Disposed = true; string key = tmp.ContentID.ToString();
RemoveFromCache(this); ConvertListToDictionary();
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return; if (_CacheByPrimaryKey.ContainsKey(key))
List<GridInfo> listGridInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items foreach (GridInfo tmpInfo in _CacheByPrimaryKey[key])
while (listGridInfo.Contains(this)) listGridInfo.Remove(this); // Remove the item from the list tmpInfo.RefreshFields(tmp);
if (listGridInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list protected virtual void RefreshFields(Grid tmp)
} {
public virtual Grid Get() _Data = tmp.Data;
{ _Config = tmp.Config;
return _Editable = Grid.Get(_ContentID); _DTS = tmp.DTS;
} _UserID = tmp.UserID;
public static void Refresh(Grid tmp) _GridInfoExtension.Refresh(this);
{ OnChange();// raise an event
string key = tmp.ContentID.ToString(); }
ConvertListToDictionary(); public static GridInfo Get(int contentID)
if (_CacheByPrimaryKey.ContainsKey(key)) {
foreach (GridInfo tmpInfo in _CacheByPrimaryKey[key]) //if (!CanGetObject())
tmpInfo.RefreshFields(tmp); // throw new System.Security.SecurityException("User not authorized to view a Grid");
} try
protected virtual void RefreshFields(Grid tmp) {
{ GridInfo tmp = GetCachedByPrimaryKey(contentID);
_Data = tmp.Data; if (tmp == null)
_Config = tmp.Config; {
_DTS = tmp.DTS; tmp = DataPortal.Fetch<GridInfo>(new PKCriteria(contentID));
_UserID = tmp.UserID; AddToCache(tmp);
_GridInfoExtension.Refresh(this); }
OnChange();// raise an event if (tmp.ErrorMessage == "No Record Found")
} {
public static GridInfo Get(int contentID) tmp.Dispose(); // Clean-up GridInfo
{ tmp = null;
//if (!CanGetObject()) }
// throw new System.Security.SecurityException("User not authorized to view a Grid"); return tmp;
try }
{ catch (Exception ex)
GridInfo tmp = GetCachedByPrimaryKey(contentID); {
if (tmp == null) throw new DbCslaException("Error on GridInfo.Get", ex);
{ }
tmp = DataPortal.Fetch<GridInfo>(new PKCriteria(contentID)); }
AddToCache(tmp); #endregion
} #region Data Access Portal
if (tmp.ErrorMessage == "No Record Found") internal GridInfo(SafeDataReader dr)
{ {
tmp.Dispose(); // Clean-up GridInfo if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfo.Constructor", GetHashCode());
tmp = null; try
} {
return tmp; ReadData(dr);
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on GridInfo.Get", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfo.Constructor", ex);
} throw new DbCslaException("GridInfo.Constructor", ex);
} }
#endregion }
#region Data Access Portal [Serializable()]
internal GridInfo(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfo.Constructor", GetHashCode()); private int _ContentID;
try public int ContentID
{ { get { return _ContentID; } }
ReadData(dr); public PKCriteria(int contentID)
} {
catch (Exception ex) _ContentID = contentID;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfo.Constructor", ex); }
throw new DbCslaException("GridInfo.Constructor", ex); private void ReadData(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfo.ReadData", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ _ContentID = dr.GetInt32("ContentID");
private int _ContentID; _Data = dr.GetString("Data");
public int ContentID _Config = dr.GetString("Config");
{ get { return _ContentID; } } _DTS = dr.GetDateTime("DTS");
public PKCriteria(int contentID) _UserID = dr.GetString("UserID");
{ }
_ContentID = contentID; catch (Exception ex)
} {
} if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfo.ReadData", ex);
private void ReadData(SafeDataReader dr) _ErrorMessage = ex.Message;
{ throw new DbCslaException("GridInfo.ReadData", ex);
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfo.ReadData", GetHashCode()); }
try }
{ private void DataPortal_Fetch(PKCriteria criteria)
_ContentID = dr.GetInt32("ContentID"); {
_Data = dr.GetString("Data"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfo.DataPortal_Fetch", GetHashCode());
_Config = dr.GetString("Config"); try
_DTS = dr.GetDateTime("DTS"); {
_UserID = dr.GetString("UserID"); using (SqlConnection cn = Database.VEPROMS_SqlConnection)
} {
catch (Exception ex) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfo.ReadData", ex); {
_ErrorMessage = ex.Message; cm.CommandType = CommandType.StoredProcedure;
throw new DbCslaException("GridInfo.ReadData", ex); cm.CommandText = "getGrid";
} cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
} cm.CommandTimeout = Database.DefaultTimeout;
private void DataPortal_Fetch(PKCriteria criteria) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfo.DataPortal_Fetch", GetHashCode()); if (!dr.Read())
try {
{ _ErrorMessage = "No Record Found";
using (SqlConnection cn = Database.VEPROMS_SqlConnection) return;
{ }
ApplicationContext.LocalContext["cn"] = cn; ReadData(dr);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; // removing of item only needed for local data portal
cm.CommandText = "getGrid"; if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); ApplicationContext.LocalContext.Remove("cn");
cm.CommandTimeout = Database.DefaultTimeout; }
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) }
{ catch (Exception ex)
if (!dr.Read()) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfo.DataPortal_Fetch", ex);
_ErrorMessage = "No Record Found"; _ErrorMessage = ex.Message;
return; throw new DbCslaException("GridInfo.DataPortal_Fetch", ex);
} }
ReadData(dr); }
} #endregion
} // Standard Refresh
// removing of item only needed for local data portal #region extension
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) GridInfoExtension _GridInfoExtension = new GridInfoExtension();
ApplicationContext.LocalContext.Remove("cn"); [Serializable()]
} partial class GridInfoExtension : extensionBase { }
} [Serializable()]
catch (Exception ex) class extensionBase
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfo.DataPortal_Fetch", ex); // Default Refresh
_ErrorMessage = ex.Message; public virtual void Refresh(GridInfo tmp) { }
throw new DbCslaException("GridInfo.DataPortal_Fetch", ex); }
} #endregion
} } // Class
#endregion #region Converter
// Standard Refresh internal class GridInfoConverter : ExpandableObjectConverter
#region extension {
GridInfoExtension _GridInfoExtension = new GridInfoExtension(); public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
[Serializable()] {
partial class GridInfoExtension : extensionBase { } if (destType == typeof(string) && value is GridInfo)
[Serializable()] {
class extensionBase // Return the ToString value
{ return ((GridInfo)value).ToString();
// Default Refresh }
public virtual void Refresh(GridInfo tmp) { } return base.ConvertTo(context, culture, value, destType);
} }
#endregion }
} // Class #endregion
#region Converter
internal class GridInfoConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GridInfo)
{
// Return the ToString value
return ((GridInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,417 +19,427 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void GroupInfoEvent(object sender); public delegate void GroupInfoEvent(object sender);
/// <summary> /// <summary>
/// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template /// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(GroupInfoConverter))] [TypeConverter(typeof(GroupInfoConverter))]
public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable public partial class GroupInfo : ReadOnlyBase<GroupInfo>, IDisposable
{ {
public event GroupInfoEvent Changed; public event GroupInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<GroupInfo> _CacheList = new List<GroupInfo>(); private static List<GroupInfo> _CacheList = new List<GroupInfo>();
protected static void AddToCache(GroupInfo groupInfo) protected static void AddToCache(GroupInfo groupInfo)
{ {
if (!_CacheList.Contains(groupInfo)) _CacheList.Add(groupInfo); // In AddToCache if (!_CacheList.Contains(groupInfo)) _CacheList.Add(groupInfo); // In AddToCache
} }
protected static void RemoveFromCache(GroupInfo groupInfo) protected static void RemoveFromCache(GroupInfo groupInfo)
{ {
while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache while (_CacheList.Contains(groupInfo)) _CacheList.Remove(groupInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>(); private static Dictionary<string, List<GroupInfo>> _CacheByPrimaryKey = new Dictionary<string, List<GroupInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move GroupInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move GroupInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
GroupInfo tmp = _CacheList[0]; // Get the first GroupInfo GroupInfo tmp = _CacheList[0]; // Get the first GroupInfo
string pKey = tmp.GID.ToString(); string pKey = tmp.GID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<GroupInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<GroupInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first GroupInfo _CacheList.RemoveAt(0); // Remove the first GroupInfo
} }
} }
internal static void AddList(GroupInfoList lst) internal static void AddList(GroupInfoList lst)
{ {
foreach (GroupInfo item in lst) AddToCache(item); foreach (GroupInfo item in lst) AddToCache(item);
} }
protected static GroupInfo GetCachedByPrimaryKey(int gid) protected static GroupInfo GetCachedByPrimaryKey(int gid)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = gid.ToString(); string key = gid.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Group _Editable; protected Group _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _GID; private int _GID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int GID public int GID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _GID; CanReadProperty("GID", true);
} return _GID;
} }
private string _GroupName = string.Empty; }
public string GroupName private string _GroupName = string.Empty;
{ public string GroupName
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _GroupName; {
} CanReadProperty("GroupName", true);
} return _GroupName;
private int? _GroupType; }
public int? GroupType }
{ private int? _GroupType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int? GroupType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _GroupType; get
} {
} CanReadProperty("GroupType", true);
private string _Config = string.Empty; return _GroupType;
public string Config }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _Config = string.Empty;
get public string Config
{ {
return _Config; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private DateTime _DTS = new DateTime(); CanReadProperty("Config", true);
public DateTime DTS return _Config;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTS = new DateTime();
{ public DateTime DTS
return _DTS; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _UsrID = string.Empty; {
public string UsrID CanReadProperty("DTS", true);
{ return _DTS;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _UsrID = string.Empty;
return _UsrID; public string UsrID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _GroupAssignmentCount = 0; get
/// <summary> {
/// Count of GroupAssignments for this Group CanReadProperty("UsrID", true);
/// </summary> return _UsrID;
public int GroupAssignmentCount }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _GroupAssignmentCount = 0;
get /// <summary>
{ /// Count of GroupAssignments for this Group
if (_GroupAssignmentCount < 0) /// </summary>
_GroupAssignmentCount = GroupAssignments.Count; public int GroupAssignmentCount
return _GroupAssignmentCount; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private AssignmentInfoList _GroupAssignments = null; {
[TypeConverter(typeof(AssignmentInfoListConverter))] CanReadProperty("GroupAssignmentCount", true);
public AssignmentInfoList GroupAssignments if (_GroupAssignmentCount < 0)
{ _GroupAssignmentCount = GroupAssignments.Count;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _GroupAssignmentCount;
get }
{ }
if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null)) private AssignmentInfoList _GroupAssignments = null;
_GroupAssignments = AssignmentInfoList.GetByGID(_GID); [TypeConverter(typeof(AssignmentInfoListConverter))]
if (_GroupAssignmentCount < 0) public AssignmentInfoList GroupAssignments
_GroupAssignmentCount = _GroupAssignments.Count; {
return _GroupAssignments; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
public void RefreshGroupAssignments() CanReadProperty("GroupAssignments", true);
{ if (_GroupAssignmentCount < 0 || (_GroupAssignmentCount > 0 && _GroupAssignments == null))
_GroupAssignmentCount = -1; _GroupAssignments = AssignmentInfoList.GetByGID(_GID);
ConvertListToDictionary(); if (_GroupAssignmentCount < 0)
if (_CacheByPrimaryKey.ContainsKey(_GID.ToString())) _GroupAssignmentCount = _GroupAssignments.Count;
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()]) return _GroupAssignments;
tmp._GroupAssignmentCount = -1; // This will cause the data to be requeried }
} }
private int _GroupMembershipCount = 0; public void RefreshGroupAssignments()
/// <summary> {
/// Count of GroupMemberships for this Group _GroupAssignmentCount = -1;
/// </summary> ConvertListToDictionary();
public int GroupMembershipCount if (_CacheByPrimaryKey.ContainsKey(_GID.ToString()))
{ foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] tmp._GroupAssignmentCount = -1; // This will cause the data to be requeried
get }
{ private int _GroupMembershipCount = 0;
if (_GroupMembershipCount < 0) /// <summary>
_GroupMembershipCount = GroupMemberships.Count; /// Count of GroupMemberships for this Group
return _GroupMembershipCount; /// </summary>
} public int GroupMembershipCount
} {
private MembershipInfoList _GroupMemberships = null; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[TypeConverter(typeof(MembershipInfoListConverter))] get
public MembershipInfoList GroupMemberships {
{ CanReadProperty("GroupMembershipCount", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_GroupMembershipCount < 0)
get _GroupMembershipCount = GroupMemberships.Count;
{ return _GroupMembershipCount;
if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null)) }
_GroupMemberships = MembershipInfoList.GetByGID(_GID); }
if (_GroupMembershipCount < 0) private MembershipInfoList _GroupMemberships = null;
_GroupMembershipCount = _GroupMemberships.Count; [TypeConverter(typeof(MembershipInfoListConverter))]
return _GroupMemberships; public MembershipInfoList GroupMemberships
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public void RefreshGroupMemberships() get
{ {
_GroupMembershipCount = -1; CanReadProperty("GroupMemberships", true);
ConvertListToDictionary(); if (_GroupMembershipCount < 0 || (_GroupMembershipCount > 0 && _GroupMemberships == null))
if (_CacheByPrimaryKey.ContainsKey(_GID.ToString())) _GroupMemberships = MembershipInfoList.GetByGID(_GID);
foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()]) if (_GroupMembershipCount < 0)
tmp._GroupMembershipCount = -1; // This will cause the data to be requeried _GroupMembershipCount = _GroupMemberships.Count;
} return _GroupMemberships;
// CSLATODO: Replace base GroupInfo.ToString function as necessary }
/// <summary> }
/// Overrides Base ToString public void RefreshGroupMemberships()
/// </summary> {
/// <returns>A string representation of current GroupInfo</returns> _GroupMembershipCount = -1;
//public override string ToString() ConvertListToDictionary();
//{ if (_CacheByPrimaryKey.ContainsKey(_GID.ToString()))
// return base.ToString(); foreach (GroupInfo tmp in _CacheByPrimaryKey[_GID.ToString()])
//} tmp._GroupMembershipCount = -1; // This will cause the data to be requeried
// CSLATODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base GroupInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current GroupInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current GroupInfo</returns>
{ //public override string ToString()
return MyGroupInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique
private static int _GroupInfoUnique = 0; /// <summary>
private static int GroupInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_GroupInfoUnique; } } /// </summary>
private int _MyGroupInfoUnique = GroupInfoUnique; /// <returns>A Unique ID for the current GroupInfo</returns>
public int MyGroupInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyGroupInfoUnique; } } {
protected GroupInfo() return MyGroupInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
private bool _Disposed = false; private static int _GroupInfoUnique = 0;
private static int _CountCreated = 0; private static int GroupInfoUnique
private static int _CountDisposed = 0; { get { return ++_GroupInfoUnique; } }
private static int _CountFinalized = 0; private int _MyGroupInfoUnique = GroupInfoUnique;
private static int IncrementCountCreated public int MyGroupInfoUnique // Absolutely Unique ID - Info
{ get { return ++_CountCreated; } } { get { return _MyGroupInfoUnique; } }
private int _CountWhenCreated = IncrementCountCreated; protected GroupInfo()
public static int CountCreated {/* require use of factory methods */
{ get { return _CountCreated; } } AddToCache(this);
public static int CountNotDisposed }
{ get { return _CountCreated - _CountDisposed; } } private bool _Disposed = false;
public static int CountNotFinalized private static int _CountCreated = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountDisposed = 0;
~GroupInfo() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
_CountFinalized++; { get { return ++_CountCreated; } }
} private int _CountWhenCreated = IncrementCountCreated;
public void Dispose() public static int CountCreated
{ { get { return _CountCreated; } }
if (_Disposed) return; public static int CountNotDisposed
_CountDisposed++; { get { return _CountCreated - _CountDisposed; } }
_Disposed = true; public static int CountNotFinalized
RemoveFromCache(this); { get { return _CountCreated - _CountFinalized; } }
if (!_CacheByPrimaryKey.ContainsKey(GID.ToString())) return; ~GroupInfo()
List<GroupInfo> listGroupInfo = _CacheByPrimaryKey[GID.ToString()]; // Get the list of items {
while (listGroupInfo.Contains(this)) listGroupInfo.Remove(this); // Remove the item from the list _CountFinalized++;
if (listGroupInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(GID.ToString()); // remove the list public void Dispose()
} {
public virtual Group Get() if (_Disposed) return;
{ _CountDisposed++;
return _Editable = Group.Get(_GID); _Disposed = true;
} RemoveFromCache(this);
public static void Refresh(Group tmp) if (!_CacheByPrimaryKey.ContainsKey(GID.ToString())) return;
{ List<GroupInfo> listGroupInfo = _CacheByPrimaryKey[GID.ToString()]; // Get the list of items
string key = tmp.GID.ToString(); while (listGroupInfo.Contains(this)) listGroupInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listGroupInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(GID.ToString()); // remove the list
foreach (GroupInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual Group Get()
} {
protected virtual void RefreshFields(Group tmp) return _Editable = Group.Get(_GID);
{ }
_GroupName = tmp.GroupName; public static void Refresh(Group tmp)
_GroupType = tmp.GroupType; {
_Config = tmp.Config; string key = tmp.GID.ToString();
_DTS = tmp.DTS; ConvertListToDictionary();
_UsrID = tmp.UsrID; if (_CacheByPrimaryKey.ContainsKey(key))
_GroupInfoExtension.Refresh(this); foreach (GroupInfo tmpInfo in _CacheByPrimaryKey[key])
OnChange();// raise an event tmpInfo.RefreshFields(tmp);
} }
public static GroupInfo Get(int gid) protected virtual void RefreshFields(Group tmp)
{ {
//if (!CanGetObject()) _GroupName = tmp.GroupName;
// throw new System.Security.SecurityException("User not authorized to view a Group"); _GroupType = tmp.GroupType;
try _Config = tmp.Config;
{ _DTS = tmp.DTS;
GroupInfo tmp = GetCachedByPrimaryKey(gid); _UsrID = tmp.UsrID;
if (tmp == null) _GroupInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid)); }
AddToCache(tmp); public static GroupInfo Get(int gid)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a Group");
tmp.Dispose(); // Clean-up GroupInfo try
tmp = null; {
} GroupInfo tmp = GetCachedByPrimaryKey(gid);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<GroupInfo>(new PKCriteria(gid));
{ AddToCache(tmp);
throw new DbCslaException("Error on GroupInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up GroupInfo
#region Data Access Portal tmp = null;
internal GroupInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on GroupInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("GroupInfo.Constructor", ex); internal GroupInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private int _GID; }
public int GID catch (Exception ex)
{ get { return _GID; } } {
public PKCriteria(int gid) if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.Constructor", ex);
{ throw new DbCslaException("GroupInfo.Constructor", ex);
_GID = gid; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode()); private int _GID;
try public int GID
{ { get { return _GID; } }
_GID = dr.GetInt32("GID"); public PKCriteria(int gid)
_GroupName = dr.GetString("GroupName"); {
_GroupType = (int?)dr.GetValue("GroupType"); _GID = gid;
_Config = dr.GetString("Config"); }
_DTS = dr.GetDateTime("DTS"); }
_UsrID = dr.GetString("UsrID"); private void ReadData(SafeDataReader dr)
_GroupAssignmentCount = dr.GetInt32("AssignmentCount"); {
_GroupMembershipCount = dr.GetInt32("MembershipCount"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.ReadData", GetHashCode());
} try
catch (Exception ex) {
{ _GID = dr.GetInt32("GID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.ReadData", ex); _GroupName = dr.GetString("GroupName");
_ErrorMessage = ex.Message; _GroupType = (int?)dr.GetValue("GroupType");
throw new DbCslaException("GroupInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UsrID = dr.GetString("UsrID");
private void DataPortal_Fetch(PKCriteria criteria) _GroupAssignmentCount = dr.GetInt32("AssignmentCount");
{ _GroupMembershipCount = dr.GetInt32("MembershipCount");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("GroupInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getGroup"; {
cm.Parameters.AddWithValue("@GID", criteria.GID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GroupInfo.DataPortal_Fetch", GetHashCode());
cm.CommandTimeout = Database.DefaultTimeout; try
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
if (!dr.Read()) {
{ ApplicationContext.LocalContext["cn"] = cn;
_ErrorMessage = "No Record Found"; using (SqlCommand cm = cn.CreateCommand())
return; {
} cm.CommandType = CommandType.StoredProcedure;
ReadData(dr); cm.CommandText = "getGroup";
} cm.Parameters.AddWithValue("@GID", criteria.GID);
} cm.CommandTimeout = Database.DefaultTimeout;
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class GroupInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("GroupInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("GroupInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(GroupInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class GroupInfoExtension _GroupInfoExtension = new GroupInfoExtension();
#region Converter [Serializable()]
internal class GroupInfoConverter : ExpandableObjectConverter partial class GroupInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is GroupInfo) // Default Refresh
{ public virtual void Refresh(GroupInfo tmp) { }
// Return the ToString value }
return ((GroupInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class GroupInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is GroupInfo)
{
// Return the ToString value
return ((GroupInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,376 +19,385 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ImageAuditInfoEvent(object sender); public delegate void ImageAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// ImageAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// ImageAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ImageAuditInfoConverter))] [TypeConverter(typeof(ImageAuditInfoConverter))]
public partial class ImageAuditInfo : ReadOnlyBase<ImageAuditInfo>, IDisposable public partial class ImageAuditInfo : ReadOnlyBase<ImageAuditInfo>, IDisposable
{ {
public event ImageAuditInfoEvent Changed; public event ImageAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<ImageAuditInfo> _CacheList = new List<ImageAuditInfo>(); private static List<ImageAuditInfo> _CacheList = new List<ImageAuditInfo>();
protected static void AddToCache(ImageAuditInfo imageAuditInfo) protected static void AddToCache(ImageAuditInfo imageAuditInfo)
{ {
if (!_CacheList.Contains(imageAuditInfo)) _CacheList.Add(imageAuditInfo); // In AddToCache if (!_CacheList.Contains(imageAuditInfo)) _CacheList.Add(imageAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(ImageAuditInfo imageAuditInfo) protected static void RemoveFromCache(ImageAuditInfo imageAuditInfo)
{ {
while (_CacheList.Contains(imageAuditInfo)) _CacheList.Remove(imageAuditInfo); // In RemoveFromCache while (_CacheList.Contains(imageAuditInfo)) _CacheList.Remove(imageAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<ImageAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ImageAuditInfo>>(); private static Dictionary<string, List<ImageAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ImageAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move ImageAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move ImageAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
ImageAuditInfo tmp = _CacheList[0]; // Get the first ImageAuditInfo ImageAuditInfo tmp = _CacheList[0]; // Get the first ImageAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<ImageAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<ImageAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ImageAuditInfo _CacheList.RemoveAt(0); // Remove the first ImageAuditInfo
} }
} }
internal static void AddList(ImageAuditInfoList lst) internal static void AddList(ImageAuditInfoList lst)
{ {
foreach (ImageAuditInfo item in lst) AddToCache(item); foreach (ImageAuditInfo item in lst) AddToCache(item);
} }
protected static ImageAuditInfo GetCachedByPrimaryKey(long auditID) protected static ImageAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected ImageAudit _Editable; protected ImageAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ContentID; {
} CanReadProperty("ContentID", true);
} return _ContentID;
private int _ImageType; }
public int ImageType }
{ private int _ImageType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int ImageType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ImageType; get
} {
} CanReadProperty("ImageType", true);
private string _FileName = string.Empty; return _ImageType;
public string FileName }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _FileName = string.Empty;
get public string FileName
{ {
return _FileName; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private byte[] _Data; CanReadProperty("FileName", true);
public byte[] Data return _FileName;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private byte[] _Data;
{ public byte[] Data
return _Data; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _Config = string.Empty; {
public string Config CanReadProperty("Data", true);
{ return _Data;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
private int _DeleteStatus; {
public int DeleteStatus [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("UserID", true);
{ return _UserID;
return _DeleteStatus; }
} }
} private int _DeleteStatus;
// CSLATODO: Replace base ImageAuditInfo.ToString function as necessary public int DeleteStatus
/// <summary> {
/// Overrides Base ToString [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// </summary> get
/// <returns>A string representation of current ImageAuditInfo</returns> {
//public override string ToString() CanReadProperty("DeleteStatus", true);
//{ return _DeleteStatus;
// return base.ToString(); }
//} }
// CSLATODO: Check ImageAuditInfo.GetIdValue to assure that the ID returned is unique // CSLATODO: Replace base ImageAuditInfo.ToString function as necessary
/// <summary> /// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// Overrides Base ToString
/// </summary> /// </summary>
/// <returns>A Unique ID for the current ImageAuditInfo</returns> /// <returns>A string representation of current ImageAuditInfo</returns>
protected override object GetIdValue() //public override string ToString()
{ //{
return MyImageAuditInfoUnique; // Absolutely Unique ID // return base.ToString();
} //}
#endregion // CSLATODO: Check ImageAuditInfo.GetIdValue to assure that the ID returned is unique
#region Factory Methods /// <summary>
private static int _ImageAuditInfoUnique = 0; /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int ImageAuditInfoUnique /// </summary>
{ get { return ++_ImageAuditInfoUnique; } } /// <returns>A Unique ID for the current ImageAuditInfo</returns>
private int _MyImageAuditInfoUnique = ImageAuditInfoUnique; protected override object GetIdValue()
public int MyImageAuditInfoUnique // Absolutely Unique ID - Info {
{ get { return _MyImageAuditInfoUnique; } } return MyImageAuditInfoUnique; // Absolutely Unique ID
protected ImageAuditInfo() }
{/* require use of factory methods */ #endregion
AddToCache(this); #region Factory Methods
} private static int _ImageAuditInfoUnique = 0;
private bool _Disposed = false; private static int ImageAuditInfoUnique
private static int _CountCreated = 0; { get { return ++_ImageAuditInfoUnique; } }
private static int _CountDisposed = 0; private int _MyImageAuditInfoUnique = ImageAuditInfoUnique;
private static int _CountFinalized = 0; public int MyImageAuditInfoUnique // Absolutely Unique ID - Info
private static int IncrementCountCreated { get { return _MyImageAuditInfoUnique; } }
{ get { return ++_CountCreated; } } protected ImageAuditInfo()
private int _CountWhenCreated = IncrementCountCreated; {/* require use of factory methods */
public static int CountCreated AddToCache(this);
{ get { return _CountCreated; } } }
public static int CountNotDisposed private bool _Disposed = false;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountCreated = 0;
public static int CountNotFinalized private static int _CountDisposed = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountFinalized = 0;
~ImageAuditInfo() private static int IncrementCountCreated
{ { get { return ++_CountCreated; } }
_CountFinalized++; private int _CountWhenCreated = IncrementCountCreated;
} public static int CountCreated
public void Dispose() { get { return _CountCreated; } }
{ public static int CountNotDisposed
if (_Disposed) return; { get { return _CountCreated - _CountDisposed; } }
_CountDisposed++; public static int CountNotFinalized
_Disposed = true; { get { return _CountCreated - _CountFinalized; } }
RemoveFromCache(this); ~ImageAuditInfo()
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; {
List<ImageAuditInfo> listImageAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items _CountFinalized++;
while (listImageAuditInfo.Contains(this)) listImageAuditInfo.Remove(this); // Remove the item from the list }
if (listImageAuditInfo.Count == 0) // If there are no items left in the list public void Dispose()
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list {
} if (_Disposed) return;
public virtual ImageAudit Get() _CountDisposed++;
{ _Disposed = true;
return _Editable = ImageAudit.Get(_AuditID); RemoveFromCache(this);
} if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
public static void Refresh(ImageAudit tmp) List<ImageAuditInfo> listImageAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
{ while (listImageAuditInfo.Contains(this)) listImageAuditInfo.Remove(this); // Remove the item from the list
string key = tmp.AuditID.ToString(); if (listImageAuditInfo.Count == 0) // If there are no items left in the list
ConvertListToDictionary(); _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
if (_CacheByPrimaryKey.ContainsKey(key)) }
foreach (ImageAuditInfo tmpInfo in _CacheByPrimaryKey[key]) public virtual ImageAudit Get()
tmpInfo.RefreshFields(tmp); {
} return _Editable = ImageAudit.Get(_AuditID);
protected virtual void RefreshFields(ImageAudit tmp) }
{ public static void Refresh(ImageAudit tmp)
_ContentID = tmp.ContentID; {
_ImageType = tmp.ImageType; string key = tmp.AuditID.ToString();
_FileName = tmp.FileName; ConvertListToDictionary();
_Data = tmp.Data; if (_CacheByPrimaryKey.ContainsKey(key))
_Config = tmp.Config; foreach (ImageAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(ImageAudit tmp)
_ImageAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ContentID = tmp.ContentID;
} _ImageType = tmp.ImageType;
public static ImageAuditInfo Get(long auditID) _FileName = tmp.FileName;
{ _Data = tmp.Data;
//if (!CanGetObject()) _Config = tmp.Config;
// throw new System.Security.SecurityException("User not authorized to view a ImageAudit"); _DTS = tmp.DTS;
try _UserID = tmp.UserID;
{ _DeleteStatus = tmp.DeleteStatus;
ImageAuditInfo tmp = GetCachedByPrimaryKey(auditID); _ImageAuditInfoExtension.Refresh(this);
if (tmp == null) OnChange();// raise an event
{ }
tmp = DataPortal.Fetch<ImageAuditInfo>(new PKCriteria(auditID)); public static ImageAuditInfo Get(long auditID)
AddToCache(tmp); {
} //if (!CanGetObject())
if (tmp.ErrorMessage == "No Record Found") // throw new System.Security.SecurityException("User not authorized to view a ImageAudit");
{ try
tmp.Dispose(); // Clean-up ImageAuditInfo {
tmp = null; ImageAuditInfo tmp = GetCachedByPrimaryKey(auditID);
} if (tmp == null)
return tmp; {
} tmp = DataPortal.Fetch<ImageAuditInfo>(new PKCriteria(auditID));
catch (Exception ex) AddToCache(tmp);
{ }
throw new DbCslaException("Error on ImageAuditInfo.Get", ex); if (tmp.ErrorMessage == "No Record Found")
} {
} tmp.Dispose(); // Clean-up ImageAuditInfo
#endregion tmp = null;
#region Data Access Portal }
internal ImageAuditInfo(SafeDataReader dr) return tmp;
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.Constructor", GetHashCode()); catch (Exception ex)
try {
{ throw new DbCslaException("Error on ImageAuditInfo.Get", ex);
ReadData(dr); }
} }
catch (Exception ex) #endregion
{ #region Data Access Portal
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.Constructor", ex); internal ImageAuditInfo(SafeDataReader dr)
throw new DbCslaException("ImageAuditInfo.Constructor", ex); {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.Constructor", GetHashCode());
} try
[Serializable()] {
protected class PKCriteria ReadData(dr);
{ }
private long _AuditID; catch (Exception ex)
public long AuditID {
{ get { return _AuditID; } } if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.Constructor", ex);
public PKCriteria(long auditID) throw new DbCslaException("ImageAuditInfo.Constructor", ex);
{ }
_AuditID = auditID; }
} [Serializable()]
} protected class PKCriteria
private void ReadData(SafeDataReader dr) {
{ private long _AuditID;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.ReadData", GetHashCode()); public long AuditID
try { get { return _AuditID; } }
{ public PKCriteria(long auditID)
_AuditID = dr.GetInt64("AuditID"); {
_ContentID = dr.GetInt32("ContentID"); _AuditID = auditID;
_ImageType = dr.GetInt32("ImageType"); }
_FileName = dr.GetString("FileName"); }
_Data = (byte[])dr.GetValue("Data"); private void ReadData(SafeDataReader dr)
_Config = dr.GetString("Config"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _ImageType = dr.GetInt32("ImageType");
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.ReadData", ex); _FileName = dr.GetString("FileName");
_ErrorMessage = ex.Message; _Data = (byte[])dr.GetValue("Data");
throw new DbCslaException("ImageAuditInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) _DeleteStatus = dr.GetInt32("DeleteStatus");
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.DataPortal_Fetch", GetHashCode()); catch (Exception ex)
try {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.ReadData", ex);
using (SqlConnection cn = Database.VEPROMS_SqlConnection) _ErrorMessage = ex.Message;
{ throw new DbCslaException("ImageAuditInfo.ReadData", ex);
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) }
{ private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandType = CommandType.StoredProcedure; {
cm.CommandText = "getImageAudit"; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageAuditInfo.DataPortal_Fetch", GetHashCode());
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); try
cm.CommandTimeout = Database.DefaultTimeout; {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
if (!dr.Read()) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
_ErrorMessage = "No Record Found"; {
return; cm.CommandType = CommandType.StoredProcedure;
} cm.CommandText = "getImageAudit";
ReadData(dr); cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
} cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// removing of item only needed for local data portal {
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) if (!dr.Read())
ApplicationContext.LocalContext.Remove("cn"); {
} _ErrorMessage = "No Record Found";
} return;
catch (Exception ex) }
{ ReadData(dr);
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; }
throw new DbCslaException("ImageAuditInfo.DataPortal_Fetch", ex); // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
#endregion }
// Standard Refresh }
#region extension catch (Exception ex)
ImageAuditInfoExtension _ImageAuditInfoExtension = new ImageAuditInfoExtension(); {
[Serializable()] if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageAuditInfo.DataPortal_Fetch", ex);
partial class ImageAuditInfoExtension : extensionBase { } _ErrorMessage = ex.Message;
[Serializable()] throw new DbCslaException("ImageAuditInfo.DataPortal_Fetch", ex);
class extensionBase }
{ }
// Default Refresh #endregion
public virtual void Refresh(ImageAuditInfo tmp) { } // Standard Refresh
} #region extension
#endregion ImageAuditInfoExtension _ImageAuditInfoExtension = new ImageAuditInfoExtension();
} // Class [Serializable()]
#region Converter partial class ImageAuditInfoExtension : extensionBase { }
internal class ImageAuditInfoConverter : ExpandableObjectConverter [Serializable()]
{ class extensionBase
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) {
{ // Default Refresh
if (destType == typeof(string) && value is ImageAuditInfo) public virtual void Refresh(ImageAuditInfo tmp) { }
{ }
// Return the ToString value #endregion
return ((ImageAuditInfo)value).ToString(); } // Class
} #region Converter
return base.ConvertTo(context, culture, value, destType); internal class ImageAuditInfoConverter : ExpandableObjectConverter
} {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
#endregion {
if (destType == typeof(string) && value is ImageAuditInfo)
{
// Return the ToString value
return ((ImageAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -19,373 +19,381 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ImageInfoEvent(object sender); public delegate void ImageInfoEvent(object sender);
/// <summary> /// <summary>
/// ImageInfo Generated by MyGeneration using the CSLA Object Mapping template /// ImageInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ImageInfoConverter))] [TypeConverter(typeof(ImageInfoConverter))]
public partial class ImageInfo : ReadOnlyBase<ImageInfo>, IDisposable public partial class ImageInfo : ReadOnlyBase<ImageInfo>, IDisposable
{ {
public event ImageInfoEvent Changed; public event ImageInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<ImageInfo> _CacheList = new List<ImageInfo>(); private static List<ImageInfo> _CacheList = new List<ImageInfo>();
protected static void AddToCache(ImageInfo imageInfo) protected static void AddToCache(ImageInfo imageInfo)
{ {
if (!_CacheList.Contains(imageInfo)) _CacheList.Add(imageInfo); // In AddToCache if (!_CacheList.Contains(imageInfo)) _CacheList.Add(imageInfo); // In AddToCache
} }
protected static void RemoveFromCache(ImageInfo imageInfo) protected static void RemoveFromCache(ImageInfo imageInfo)
{ {
while (_CacheList.Contains(imageInfo)) _CacheList.Remove(imageInfo); // In RemoveFromCache while (_CacheList.Contains(imageInfo)) _CacheList.Remove(imageInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<ImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ImageInfo>>(); private static Dictionary<string, List<ImageInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ImageInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move ImageInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move ImageInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
ImageInfo tmp = _CacheList[0]; // Get the first ImageInfo ImageInfo tmp = _CacheList[0]; // Get the first ImageInfo
string pKey = tmp.ContentID.ToString(); string pKey = tmp.ContentID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<ImageInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<ImageInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ImageInfo _CacheList.RemoveAt(0); // Remove the first ImageInfo
} }
} }
protected static ImageInfo GetCachedByPrimaryKey(int contentID) protected static ImageInfo GetCachedByPrimaryKey(int contentID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString(); string key = contentID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Image _Editable; protected Image _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _ContentID; private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int ContentID public int ContentID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyContent != null) _ContentID = _MyContent.ContentID; CanReadProperty("ContentID", true);
return _ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
} return _ContentID;
} }
private ContentInfo _MyContent; }
[System.ComponentModel.DataObjectField(true, true)] private ContentInfo _MyContent;
public ContentInfo MyContent [System.ComponentModel.DataObjectField(true, true)]
{ public ContentInfo MyContent
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); {
return _MyContent; CanReadProperty("MyContent", true);
} if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
} return _MyContent;
private int _ImageType; }
/// <summary> }
/// 1 - Figure, 2 - Video, 3 - Audio private int _ImageType;
/// </summary> /// <summary>
public int ImageType /// 1 - Figure, 2 - Video, 3 - Audio
{ /// </summary>
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int ImageType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _ImageType; get
} {
} CanReadProperty("ImageType", true);
private string _FileName = string.Empty; return _ImageType;
public string FileName }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private string _FileName = string.Empty;
get public string FileName
{ {
return _FileName; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private byte[] _Data; CanReadProperty("FileName", true);
public byte[] Data return _FileName;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private byte[] _Data;
{ public byte[] Data
return _Data; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _Config = string.Empty; {
public string Config CanReadProperty("Data", true);
{ return _Data;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _Config = string.Empty;
return _Config; public string Config
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private DateTime _DTS = new DateTime(); get
public DateTime DTS {
{ CanReadProperty("Config", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Config;
get }
{ }
return _DTS; private DateTime _DTS = new DateTime();
} public DateTime DTS
} {
private string _UserID = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string UserID get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("DTS", true);
get return _DTS;
{ }
return _UserID; }
} private string _UserID = string.Empty;
} public string UserID
// CSLATODO: Replace base ImageInfo.ToString function as necessary {
/// <summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// Overrides Base ToString get
/// </summary> {
/// <returns>A string representation of current ImageInfo</returns> CanReadProperty("UserID", true);
//public override string ToString() return _UserID;
//{ }
// return base.ToString(); }
//} // CSLATODO: Replace base ImageInfo.ToString function as necessary
// CSLATODO: Check ImageInfo.GetIdValue to assure that the ID returned is unique /// <summary>
/// <summary> /// Overrides Base ToString
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// </summary>
/// </summary> /// <returns>A string representation of current ImageInfo</returns>
/// <returns>A Unique ID for the current ImageInfo</returns> //public override string ToString()
protected override object GetIdValue() //{
{ // return base.ToString();
return MyImageInfoUnique; // Absolutely Unique ID //}
} // CSLATODO: Check ImageInfo.GetIdValue to assure that the ID returned is unique
#endregion /// <summary>
#region Factory Methods /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private static int _ImageInfoUnique = 0; /// </summary>
private static int ImageInfoUnique /// <returns>A Unique ID for the current ImageInfo</returns>
{ get { return ++_ImageInfoUnique; } } protected override object GetIdValue()
private int _MyImageInfoUnique = ImageInfoUnique; {
public int MyImageInfoUnique // Absolutely Unique ID - Info return MyImageInfoUnique; // Absolutely Unique ID
{ get { return _MyImageInfoUnique; } } }
protected ImageInfo() #endregion
{/* require use of factory methods */ #region Factory Methods
AddToCache(this); private static int _ImageInfoUnique = 0;
} private static int ImageInfoUnique
private bool _Disposed = false; { get { return ++_ImageInfoUnique; } }
private static int _CountCreated = 0; private int _MyImageInfoUnique = ImageInfoUnique;
private static int _CountDisposed = 0; public int MyImageInfoUnique // Absolutely Unique ID - Info
private static int _CountFinalized = 0; { get { return _MyImageInfoUnique; } }
private static int IncrementCountCreated protected ImageInfo()
{ get { return ++_CountCreated; } } {/* require use of factory methods */
private int _CountWhenCreated = IncrementCountCreated; AddToCache(this);
public static int CountCreated }
{ get { return _CountCreated; } } private bool _Disposed = false;
public static int CountNotDisposed private static int _CountCreated = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountDisposed = 0;
public static int CountNotFinalized private static int _CountFinalized = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int IncrementCountCreated
~ImageInfo() { get { return ++_CountCreated; } }
{ private int _CountWhenCreated = IncrementCountCreated;
_CountFinalized++; public static int CountCreated
} { get { return _CountCreated; } }
public void Dispose() public static int CountNotDisposed
{ { get { return _CountCreated - _CountDisposed; } }
if (_Disposed) return; public static int CountNotFinalized
_CountDisposed++; { get { return _CountCreated - _CountFinalized; } }
_Disposed = true; ~ImageInfo()
RemoveFromCache(this); {
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return; _CountFinalized++;
List<ImageInfo> listImageInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items }
while (listImageInfo.Contains(this)) listImageInfo.Remove(this); // Remove the item from the list public void Dispose()
if (listImageInfo.Count == 0) // If there are no items left in the list {
_CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list if (_Disposed) return;
} _CountDisposed++;
public virtual Image Get() _Disposed = true;
{ RemoveFromCache(this);
return _Editable = Image.Get(_ContentID); if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString())) return;
} List<ImageInfo> listImageInfo = _CacheByPrimaryKey[ContentID.ToString()]; // Get the list of items
public static void Refresh(Image tmp) while (listImageInfo.Contains(this)) listImageInfo.Remove(this); // Remove the item from the list
{ if (listImageInfo.Count == 0) // If there are no items left in the list
string key = tmp.ContentID.ToString(); _CacheByPrimaryKey.Remove(ContentID.ToString()); // remove the list
ConvertListToDictionary(); }
if (_CacheByPrimaryKey.ContainsKey(key)) public virtual Image Get()
foreach (ImageInfo tmpInfo in _CacheByPrimaryKey[key]) {
tmpInfo.RefreshFields(tmp); return _Editable = Image.Get(_ContentID);
} }
protected virtual void RefreshFields(Image tmp) public static void Refresh(Image tmp)
{ {
_ImageType = tmp.ImageType; string key = tmp.ContentID.ToString();
_FileName = tmp.FileName; ConvertListToDictionary();
_Data = tmp.Data; if (_CacheByPrimaryKey.ContainsKey(key))
_Config = tmp.Config; foreach (ImageInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_ImageInfoExtension.Refresh(this); protected virtual void RefreshFields(Image tmp)
//RHM Removed 20090724 - Duplicates function of code above. {
// - Dispose caused error when a new step was added. _ImageType = tmp.ImageType;
// - Resequence of transitions did not work properly. _FileName = tmp.FileName;
// if(_MyContent != null) _Data = tmp.Data;
// { _Config = tmp.Config;
// _MyContent.Dispose();// Dispose related value _DTS = tmp.DTS;
// _MyContent = null;// Reset related value _UserID = tmp.UserID;
// } _ImageInfoExtension.Refresh(this);
OnChange();// raise an event //RHM Removed 20090724 - Duplicates function of code above.
} // - Dispose caused error when a new step was added.
public static ImageInfo Get(int contentID) // - Resequence of transitions did not work properly.
{ // if(_MyContent != null)
//if (!CanGetObject()) // {
// throw new System.Security.SecurityException("User not authorized to view a Image"); // _MyContent.Dispose();// Dispose related value
try // _MyContent = null;// Reset related value
{ // }
ImageInfo tmp = GetCachedByPrimaryKey(contentID); OnChange();// raise an event
if (tmp == null) }
{ public static ImageInfo Get(int contentID)
tmp = DataPortal.Fetch<ImageInfo>(new PKCriteria(contentID)); {
AddToCache(tmp); //if (!CanGetObject())
} // throw new System.Security.SecurityException("User not authorized to view a Image");
if (tmp.ErrorMessage == "No Record Found") try
{ {
tmp.Dispose(); // Clean-up ImageInfo ImageInfo tmp = GetCachedByPrimaryKey(contentID);
tmp = null; if (tmp == null)
} {
return tmp; tmp = DataPortal.Fetch<ImageInfo>(new PKCriteria(contentID));
} AddToCache(tmp);
catch (Exception ex) }
{ if (tmp.ErrorMessage == "No Record Found")
throw new DbCslaException("Error on ImageInfo.Get", ex); {
} tmp.Dispose(); // Clean-up ImageInfo
} tmp = null;
#endregion }
#region Data Access Portal return tmp;
internal ImageInfo(SafeDataReader dr) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageInfo.Constructor", GetHashCode()); {
try throw new DbCslaException("Error on ImageInfo.Get", ex);
{ }
ReadData(dr); }
} #endregion
catch (Exception ex) #region Data Access Portal
{ internal ImageInfo(SafeDataReader dr)
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageInfo.Constructor", ex); {
throw new DbCslaException("ImageInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageInfo.Constructor", GetHashCode());
} try
} {
[Serializable()] ReadData(dr);
protected class PKCriteria }
{ catch (Exception ex)
private int _ContentID; {
public int ContentID if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageInfo.Constructor", ex);
{ get { return _ContentID; } } throw new DbCslaException("ImageInfo.Constructor", ex);
public PKCriteria(int contentID) }
{ }
_ContentID = contentID; [Serializable()]
} protected class PKCriteria
} {
private void ReadData(SafeDataReader dr) private int _ContentID;
{ public int ContentID
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageInfo.ReadData", GetHashCode()); { get { return _ContentID; } }
try public PKCriteria(int contentID)
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = contentID;
_ImageType = dr.GetInt32("ImageType"); }
_FileName = dr.GetString("FileName"); }
_Data = (byte[])dr.GetValue("Data"); private void ReadData(SafeDataReader dr)
_Config = dr.GetString("Config"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
} {
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _ImageType = dr.GetInt32("ImageType");
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageInfo.ReadData", ex); _FileName = dr.GetString("FileName");
_ErrorMessage = ex.Message; _Data = (byte[])dr.GetValue("Data");
throw new DbCslaException("ImageInfo.ReadData", ex); _Config = dr.GetString("Config");
} _DTS = dr.GetDateTime("DTS");
} _UserID = dr.GetString("UserID");
private void DataPortal_Fetch(PKCriteria criteria) }
{ catch (Exception ex)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageInfo.DataPortal_Fetch", GetHashCode()); {
try if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
using (SqlConnection cn = Database.VEPROMS_SqlConnection) throw new DbCslaException("ImageInfo.ReadData", ex);
{ }
ApplicationContext.LocalContext["cn"] = cn; }
using (SqlCommand cm = cn.CreateCommand()) private void DataPortal_Fetch(PKCriteria criteria)
{ {
cm.CommandType = CommandType.StoredProcedure; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ImageInfo.DataPortal_Fetch", GetHashCode());
cm.CommandText = "getImage"; try
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); {
cm.CommandTimeout = Database.DefaultTimeout; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ ApplicationContext.LocalContext["cn"] = cn;
if (!dr.Read()) using (SqlCommand cm = cn.CreateCommand())
{ {
_ErrorMessage = "No Record Found"; cm.CommandType = CommandType.StoredProcedure;
return; cm.CommandText = "getImage";
} cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
ReadData(dr); cm.CommandTimeout = Database.DefaultTimeout;
} using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
// removing of item only needed for local data portal if (!dr.Read())
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); _ErrorMessage = "No Record Found";
} return;
} }
catch (Exception ex) ReadData(dr);
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; // removing of item only needed for local data portal
throw new DbCslaException("ImageInfo.DataPortal_Fetch", ex); if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
} ApplicationContext.LocalContext.Remove("cn");
} }
#endregion }
// Standard Refresh catch (Exception ex)
#region extension {
ImageInfoExtension _ImageInfoExtension = new ImageInfoExtension(); if (_MyLog.IsErrorEnabled) _MyLog.Error("ImageInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
partial class ImageInfoExtension : extensionBase { } throw new DbCslaException("ImageInfo.DataPortal_Fetch", ex);
[Serializable()] }
class extensionBase }
{ #endregion
// Default Refresh // Standard Refresh
public virtual void Refresh(ImageInfo tmp) { } #region extension
} ImageInfoExtension _ImageInfoExtension = new ImageInfoExtension();
#endregion [Serializable()]
} // Class partial class ImageInfoExtension : extensionBase { }
#region Converter [Serializable()]
internal class ImageInfoConverter : ExpandableObjectConverter class extensionBase
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) // Default Refresh
{ public virtual void Refresh(ImageInfo tmp) { }
if (destType == typeof(string) && value is ImageInfo) }
{ #endregion
// Return the ToString value } // Class
return ((ImageInfo)value).ToString(); #region Converter
} internal class ImageInfoConverter : ExpandableObjectConverter
return base.ConvertTo(context, culture, value, destType); {
} public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
#endregion if (destType == typeof(string) && value is ImageInfo)
{
// Return the ToString value
return ((ImageInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,354 +19,361 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void ItemAuditInfoEvent(object sender); public delegate void ItemAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// ItemAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// ItemAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ItemAuditInfoConverter))] [TypeConverter(typeof(ItemAuditInfoConverter))]
public partial class ItemAuditInfo : ReadOnlyBase<ItemAuditInfo>, IDisposable public partial class ItemAuditInfo : ReadOnlyBase<ItemAuditInfo>, IDisposable
{ {
public event ItemAuditInfoEvent Changed; public event ItemAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<ItemAuditInfo> _CacheList = new List<ItemAuditInfo>(); private static List<ItemAuditInfo> _CacheList = new List<ItemAuditInfo>();
protected static void AddToCache(ItemAuditInfo itemAuditInfo) protected static void AddToCache(ItemAuditInfo itemAuditInfo)
{ {
if (!_CacheList.Contains(itemAuditInfo)) _CacheList.Add(itemAuditInfo); // In AddToCache if (!_CacheList.Contains(itemAuditInfo)) _CacheList.Add(itemAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(ItemAuditInfo itemAuditInfo) protected static void RemoveFromCache(ItemAuditInfo itemAuditInfo)
{ {
while (_CacheList.Contains(itemAuditInfo)) _CacheList.Remove(itemAuditInfo); // In RemoveFromCache while (_CacheList.Contains(itemAuditInfo)) _CacheList.Remove(itemAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<ItemAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ItemAuditInfo>>(); private static Dictionary<string, List<ItemAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<ItemAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move ItemAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move ItemAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
ItemAuditInfo tmp = _CacheList[0]; // Get the first ItemAuditInfo ItemAuditInfo tmp = _CacheList[0]; // Get the first ItemAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<ItemAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<ItemAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first ItemAuditInfo _CacheList.RemoveAt(0); // Remove the first ItemAuditInfo
} }
} }
internal static void AddList(ItemAuditInfoList lst) internal static void AddList(ItemAuditInfoList lst)
{ {
foreach (ItemAuditInfo item in lst) AddToCache(item); foreach (ItemAuditInfo item in lst) AddToCache(item);
} }
protected static ItemAuditInfo GetCachedByPrimaryKey(long auditID) protected static ItemAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected ItemAudit _Editable; protected ItemAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ItemID; }
public int ItemID private int _ItemID;
{ public int ItemID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ItemID; {
} CanReadProperty("ItemID", true);
} return _ItemID;
private int? _PreviousID; }
public int? PreviousID }
{ private int? _PreviousID;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int? PreviousID
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _PreviousID; get
} {
} CanReadProperty("PreviousID", true);
private int _ContentID; return _PreviousID;
public int ContentID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _ContentID;
get public int ContentID
{ {
return _ContentID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private DateTime _DTS = new DateTime(); CanReadProperty("ContentID", true);
public DateTime DTS return _ContentID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTS = new DateTime();
{ public DateTime DTS
return _DTS; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _UserID = string.Empty; {
public string UserID CanReadProperty("DTS", true);
{ return _DTS;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _UserID = string.Empty;
return _UserID; public string UserID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _DeleteStatus; get
public int DeleteStatus {
{ CanReadProperty("UserID", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _UserID;
get }
{ }
return _DeleteStatus; private int _DeleteStatus;
} public int DeleteStatus
} {
// CSLATODO: Replace base ItemAuditInfo.ToString function as necessary [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <summary> get
/// Overrides Base ToString {
/// </summary> CanReadProperty("DeleteStatus", true);
/// <returns>A string representation of current ItemAuditInfo</returns> return _DeleteStatus;
//public override string ToString() }
//{ }
// return base.ToString(); // CSLATODO: Replace base ItemAuditInfo.ToString function as necessary
//} /// <summary>
// CSLATODO: Check ItemAuditInfo.GetIdValue to assure that the ID returned is unique /// Overrides Base ToString
/// <summary> /// </summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <returns>A string representation of current ItemAuditInfo</returns>
/// </summary> //public override string ToString()
/// <returns>A Unique ID for the current ItemAuditInfo</returns> //{
protected override object GetIdValue() // return base.ToString();
{ //}
return MyItemAuditInfoUnique; // Absolutely Unique ID // CSLATODO: Check ItemAuditInfo.GetIdValue to assure that the ID returned is unique
} /// <summary>
#endregion /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
#region Factory Methods /// </summary>
private static int _ItemAuditInfoUnique = 0; /// <returns>A Unique ID for the current ItemAuditInfo</returns>
private static int ItemAuditInfoUnique protected override object GetIdValue()
{ get { return ++_ItemAuditInfoUnique; } } {
private int _MyItemAuditInfoUnique = ItemAuditInfoUnique; return MyItemAuditInfoUnique; // Absolutely Unique ID
public int MyItemAuditInfoUnique // Absolutely Unique ID - Info }
{ get { return _MyItemAuditInfoUnique; } } #endregion
protected ItemAuditInfo() #region Factory Methods
{/* require use of factory methods */ private static int _ItemAuditInfoUnique = 0;
AddToCache(this); private static int ItemAuditInfoUnique
} { get { return ++_ItemAuditInfoUnique; } }
private bool _Disposed = false; private int _MyItemAuditInfoUnique = ItemAuditInfoUnique;
private static int _CountCreated = 0; public int MyItemAuditInfoUnique // Absolutely Unique ID - Info
private static int _CountDisposed = 0; { get { return _MyItemAuditInfoUnique; } }
private static int _CountFinalized = 0; protected ItemAuditInfo()
private static int IncrementCountCreated {/* require use of factory methods */
{ get { return ++_CountCreated; } } AddToCache(this);
private int _CountWhenCreated = IncrementCountCreated; }
public static int CountCreated private bool _Disposed = false;
{ get { return _CountCreated; } } private static int _CountCreated = 0;
public static int CountNotDisposed private static int _CountDisposed = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountFinalized = 0;
public static int CountNotFinalized private static int IncrementCountCreated
{ get { return _CountCreated - _CountFinalized; } } { get { return ++_CountCreated; } }
~ItemAuditInfo() private int _CountWhenCreated = IncrementCountCreated;
{ public static int CountCreated
_CountFinalized++; { get { return _CountCreated; } }
} public static int CountNotDisposed
public void Dispose() { get { return _CountCreated - _CountDisposed; } }
{ public static int CountNotFinalized
if (_Disposed) return; { get { return _CountCreated - _CountFinalized; } }
_CountDisposed++; ~ItemAuditInfo()
_Disposed = true; {
RemoveFromCache(this); _CountFinalized++;
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; }
List<ItemAuditInfo> listItemAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items public void Dispose()
while (listItemAuditInfo.Contains(this)) listItemAuditInfo.Remove(this); // Remove the item from the list {
if (listItemAuditInfo.Count == 0) // If there are no items left in the list if (_Disposed) return;
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list _CountDisposed++;
} _Disposed = true;
public virtual ItemAudit Get() RemoveFromCache(this);
{ if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
return _Editable = ItemAudit.Get(_AuditID); List<ItemAuditInfo> listItemAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
} while (listItemAuditInfo.Contains(this)) listItemAuditInfo.Remove(this); // Remove the item from the list
public static void Refresh(ItemAudit tmp) if (listItemAuditInfo.Count == 0) // If there are no items left in the list
{ _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
string key = tmp.AuditID.ToString(); }
ConvertListToDictionary(); public virtual ItemAudit Get()
if (_CacheByPrimaryKey.ContainsKey(key)) {
foreach (ItemAuditInfo tmpInfo in _CacheByPrimaryKey[key]) return _Editable = ItemAudit.Get(_AuditID);
tmpInfo.RefreshFields(tmp); }
} public static void Refresh(ItemAudit tmp)
protected virtual void RefreshFields(ItemAudit tmp) {
{ string key = tmp.AuditID.ToString();
_ItemID = tmp.ItemID; ConvertListToDictionary();
_PreviousID = tmp.PreviousID; if (_CacheByPrimaryKey.ContainsKey(key))
_ContentID = tmp.ContentID; foreach (ItemAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(ItemAudit tmp)
_ItemAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ItemID = tmp.ItemID;
} _PreviousID = tmp.PreviousID;
public static ItemAuditInfo Get(long auditID) _ContentID = tmp.ContentID;
{ _DTS = tmp.DTS;
//if (!CanGetObject()) _UserID = tmp.UserID;
// throw new System.Security.SecurityException("User not authorized to view a ItemAudit"); _DeleteStatus = tmp.DeleteStatus;
try _ItemAuditInfoExtension.Refresh(this);
{ OnChange();// raise an event
ItemAuditInfo tmp = GetCachedByPrimaryKey(auditID); }
if (tmp == null) public static ItemAuditInfo Get(long auditID)
{ {
tmp = DataPortal.Fetch<ItemAuditInfo>(new PKCriteria(auditID)); //if (!CanGetObject())
AddToCache(tmp); // throw new System.Security.SecurityException("User not authorized to view a ItemAudit");
} try
if (tmp.ErrorMessage == "No Record Found") {
{ ItemAuditInfo tmp = GetCachedByPrimaryKey(auditID);
tmp.Dispose(); // Clean-up ItemAuditInfo if (tmp == null)
tmp = null; {
} tmp = DataPortal.Fetch<ItemAuditInfo>(new PKCriteria(auditID));
return tmp; AddToCache(tmp);
} }
catch (Exception ex) if (tmp.ErrorMessage == "No Record Found")
{ {
throw new DbCslaException("Error on ItemAuditInfo.Get", ex); tmp.Dispose(); // Clean-up ItemAuditInfo
} tmp = null;
} }
#endregion return tmp;
#region Data Access Portal }
internal ItemAuditInfo(SafeDataReader dr) catch (Exception ex)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.Constructor", GetHashCode()); throw new DbCslaException("Error on ItemAuditInfo.Get", ex);
try }
{ }
ReadData(dr); #endregion
} #region Data Access Portal
catch (Exception ex) internal ItemAuditInfo(SafeDataReader dr)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.Constructor", GetHashCode());
throw new DbCslaException("ItemAuditInfo.Constructor", ex); try
} {
} ReadData(dr);
[Serializable()] }
protected class PKCriteria catch (Exception ex)
{ {
private long _AuditID; if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.Constructor", ex);
public long AuditID throw new DbCslaException("ItemAuditInfo.Constructor", ex);
{ get { return _AuditID; } } }
public PKCriteria(long auditID) }
{ [Serializable()]
_AuditID = auditID; protected class PKCriteria
} {
} private long _AuditID;
private void ReadData(SafeDataReader dr) public long AuditID
{ { get { return _AuditID; } }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.ReadData", GetHashCode()); public PKCriteria(long auditID)
try {
{ _AuditID = auditID;
_AuditID = dr.GetInt64("AuditID"); }
_ItemID = dr.GetInt32("ItemID"); }
_PreviousID = (int?)dr.GetValue("PreviousID"); private void ReadData(SafeDataReader dr)
_ContentID = dr.GetInt32("ContentID"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ItemID = dr.GetInt32("ItemID");
{ _PreviousID = (int?)dr.GetValue("PreviousID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.ReadData", ex); _ContentID = dr.GetInt32("ContentID");
_ErrorMessage = ex.Message; _DTS = dr.GetDateTime("DTS");
throw new DbCslaException("ItemAuditInfo.ReadData", ex); _UserID = dr.GetString("UserID");
} _DeleteStatus = dr.GetInt32("DeleteStatus");
} }
private void DataPortal_Fetch(PKCriteria criteria) catch (Exception ex)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.ReadData", ex);
try _ErrorMessage = ex.Message;
{ throw new DbCslaException("ItemAuditInfo.ReadData", ex);
using (SqlConnection cn = Database.VEPROMS_SqlConnection) }
{ }
ApplicationContext.LocalContext["cn"] = cn; private void DataPortal_Fetch(PKCriteria criteria)
using (SqlCommand cm = cn.CreateCommand()) {
{ if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemAuditInfo.DataPortal_Fetch", GetHashCode());
cm.CommandType = CommandType.StoredProcedure; try
cm.CommandText = "getItemAudit"; {
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); using (SqlConnection cn = Database.VEPROMS_SqlConnection)
cm.CommandTimeout = Database.DefaultTimeout; {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
if (!dr.Read()) {
{ cm.CommandType = CommandType.StoredProcedure;
_ErrorMessage = "No Record Found"; cm.CommandText = "getItemAudit";
return; cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
} cm.CommandTimeout = Database.DefaultTimeout;
ReadData(dr); using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
} if (!dr.Read())
// removing of item only needed for local data portal {
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) _ErrorMessage = "No Record Found";
ApplicationContext.LocalContext.Remove("cn"); return;
} }
} ReadData(dr);
catch (Exception ex) }
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.DataPortal_Fetch", ex); // removing of item only needed for local data portal
_ErrorMessage = ex.Message; if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
throw new DbCslaException("ItemAuditInfo.DataPortal_Fetch", ex); ApplicationContext.LocalContext.Remove("cn");
} }
} }
#endregion catch (Exception ex)
// Standard Refresh {
#region extension if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemAuditInfo.DataPortal_Fetch", ex);
ItemAuditInfoExtension _ItemAuditInfoExtension = new ItemAuditInfoExtension(); _ErrorMessage = ex.Message;
[Serializable()] throw new DbCslaException("ItemAuditInfo.DataPortal_Fetch", ex);
partial class ItemAuditInfoExtension : extensionBase { } }
[Serializable()] }
class extensionBase #endregion
{ // Standard Refresh
// Default Refresh #region extension
public virtual void Refresh(ItemAuditInfo tmp) { } ItemAuditInfoExtension _ItemAuditInfoExtension = new ItemAuditInfoExtension();
} [Serializable()]
#endregion partial class ItemAuditInfoExtension : extensionBase { }
} // Class [Serializable()]
#region Converter class extensionBase
internal class ItemAuditInfoConverter : ExpandableObjectConverter {
{ // Default Refresh
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public virtual void Refresh(ItemAuditInfo tmp) { }
{ }
if (destType == typeof(string) && value is ItemAuditInfo) #endregion
{ } // Class
// Return the ToString value #region Converter
return ((ItemAuditInfo)value).ToString(); internal class ItemAuditInfoConverter : ExpandableObjectConverter
} {
return base.ConvertTo(context, culture, value, destType); public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
} if (destType == typeof(string) && value is ItemAuditInfo)
#endregion {
// Return the ToString value
return ((ItemAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,373 +19,373 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// ItemInfoList Generated by MyGeneration using the CSLA Object Mapping template /// ItemInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ItemInfoListConverter))] [TypeConverter(typeof(ItemInfoListConverter))]
public partial class ItemInfoList : ReadOnlyListBase<ItemInfoList, ItemInfo>, ICustomTypeDescriptor, IDisposable public partial class ItemInfoList : ReadOnlyListBase<ItemInfoList, ItemInfo>, ICustomTypeDescriptor, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
internal new IList<ItemInfo> Items internal new IList<ItemInfo> Items
{ get { return base.Items; } } { get { return base.Items; } }
public void AddEvents() public void AddEvents()
{ {
foreach (ItemInfo tmp in this) foreach (ItemInfo tmp in this)
{ {
tmp.Changed += new ItemInfoEvent(tmp_Changed); tmp.Changed += new ItemInfoEvent(tmp_Changed);
tmp.Deleted += new ItemInfoEvent(tmp_Deleted); tmp.Deleted += new ItemInfoEvent(tmp_Deleted);
} }
} }
private bool _RefreshingList = false; private bool _RefreshingList = false;
public bool RefreshingList public bool RefreshingList
{ {
get { return _RefreshingList; } get { return _RefreshingList; }
set { _RefreshingList = value; } set { _RefreshingList = value; }
} }
void tmp_Deleted(object sender) void tmp_Deleted(object sender)
{ {
ItemInfo ii = sender as ItemInfo; ItemInfo ii = sender as ItemInfo;
if (ii != null) if (ii != null)
{ {
RefreshingList = true; RefreshingList = true;
IsReadOnly = false; IsReadOnly = false;
Remove(ii); Remove(ii);
IsReadOnly = true; IsReadOnly = true;
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, 0)); this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, 0));
RefreshingList = false; RefreshingList = false;
} }
} }
// sender can be either the current item changed, or the current item with one added before it (when an item is inserted) // sender can be either the current item changed, or the current item with one added before it (when an item is inserted)
void tmp_Changed(object sender) void tmp_Changed(object sender)
{ {
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
{ {
if (base[i] == sender) if (base[i] == sender)
{ {
// Added insert to fix when item is replaced and a 'delete' is done, the item needs inserted. Note // Added insert to fix when item is replaced and a 'delete' is done, the item needs inserted. Note
// that when text is modified, i.e. 'Changed', this code is not executed. Fixed B2016-130. // that when text is modified, i.e. 'Changed', this code is not executed. Fixed B2016-130.
RefreshingList = true; RefreshingList = true;
IsReadOnly = false; IsReadOnly = false;
// the following checks to see if the previous is this one, and if so, it is not an insert it is a change // the following checks to see if the previous is this one, and if so, it is not an insert it is a change
// On an insert, inserting from 'sender', MyPrevious is set as the new item. // On an insert, inserting from 'sender', MyPrevious is set as the new item.
if (SourceOfList != "Search" && (sender as ItemInfo).MyPrevious != null && i > 0 && base[i - 1].ItemID != (sender as ItemInfo).MyPrevious.ItemID) if (SourceOfList != "Search" && (sender as ItemInfo).MyPrevious != null && i > 0 && base[i - 1].ItemID != (sender as ItemInfo).MyPrevious.ItemID)
Items.Insert(i, (sender as ItemInfo).MyPrevious); Items.Insert(i, (sender as ItemInfo).MyPrevious);
IsReadOnly = true; IsReadOnly = true;
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i)); this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
RefreshingList = false; RefreshingList = false;
break; break;
} }
} }
} }
private string _SourceOfList; private string _SourceOfList;
public string SourceOfList public string SourceOfList
{ {
get { return _SourceOfList; } get { return _SourceOfList; }
set { _SourceOfList = value; } set { _SourceOfList = value; }
} }
//private void ShowList(string txt) //private void ShowList(string txt)
//{ //{
// Console.WriteLine("\r\n{0} - {1} - {2}: i, base[i].Ordinal, base[i].ItemID, base[i].DisplayText", txt, Count, SourceOfList); // Console.WriteLine("\r\n{0} - {1} - {2}: i, base[i].Ordinal, base[i].ItemID, base[i].DisplayText", txt, Count, SourceOfList);
// for (int i = 0; i < Count; i++) // for (int i = 0; i < Count; i++)
// { // {
// Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", i, base[i].Ordinal, base[i].ItemID, base[i].DisplayText, base[i].MyItemInfoUnique, base[i].Disposed); // Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", i, base[i].Ordinal, base[i].ItemID, base[i].DisplayText, base[i].MyItemInfoUnique, base[i].Disposed);
// } // }
//} //}
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~ItemInfoList() ~ItemInfoList()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_Disposed = true; _Disposed = true;
_CountDisposed++; _CountDisposed++;
foreach (ItemInfo tmp in this) foreach (ItemInfo tmp in this)
{ {
tmp.Changed -= tmp_Changed; tmp.Changed -= new ItemInfoEvent(tmp_Changed);
tmp.Deleted -= tmp_Deleted; tmp.Deleted -= new ItemInfoEvent(tmp_Deleted);
} }
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
public static ItemInfoList _ItemInfoList = null; public static ItemInfoList _ItemInfoList = null;
/// <summary> /// <summary>
/// Return a list of all ItemInfo. /// Return a list of all ItemInfo.
/// </summary> /// </summary>
public static ItemInfoList Get() public static ItemInfoList Get()
{ {
try try
{ {
if (_ItemInfoList != null) if (_ItemInfoList != null)
return _ItemInfoList; return _ItemInfoList;
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(); ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>();
ItemInfo.AddList(tmp); ItemInfo.AddList(tmp);
tmp.AddEvents(); tmp.AddEvents();
_ItemInfoList = tmp; _ItemInfoList = tmp;
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on ItemInfoList.Get", ex); throw new DbCslaException("Error on ItemInfoList.Get", ex);
} }
} }
/// <summary> /// <summary>
/// Reset the list of all ItemInfo. /// Reset the list of all ItemInfo.
/// </summary> /// </summary>
public static void Reset() public static void Reset()
{ {
_ItemInfoList = null; _ItemInfoList = null;
} }
// CSLATODO: Add alternative gets - // CSLATODO: Add alternative gets -
//public static ItemInfoList Get(<criteria>) //public static ItemInfoList Get(<criteria>)
//{ //{
// try // try
// { // {
// return DataPortal.Fetch<ItemInfoList>(new FilteredCriteria(<criteria>)); // return DataPortal.Fetch<ItemInfoList>(new FilteredCriteria(<criteria>));
// } // }
// catch (Exception ex) // catch (Exception ex)
// { // {
// throw new DbCslaException("Error on ItemInfoList.Get", ex); // throw new DbCslaException("Error on ItemInfoList.Get", ex);
// } // }
//} //}
public static ItemInfoList GetNext(int? previousID) public static ItemInfoList GetNext(int? previousID)
{ {
try try
{ {
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new PreviousIDCriteria(previousID)); ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new PreviousIDCriteria(previousID));
ItemInfo.AddList(tmp); ItemInfo.AddList(tmp);
tmp.AddEvents(); tmp.AddEvents();
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on ItemInfoList.GetNext", ex); throw new DbCslaException("Error on ItemInfoList.GetNext", ex);
} }
} }
public static ItemInfoList GetByContentID(int contentID) public static ItemInfoList GetByContentID(int contentID)
{ {
try try
{ {
ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ContentIDCriteria(contentID)); ItemInfoList tmp = DataPortal.Fetch<ItemInfoList>(new ContentIDCriteria(contentID));
ItemInfo.AddList(tmp); ItemInfo.AddList(tmp);
tmp.AddEvents(); tmp.AddEvents();
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on ItemInfoList.GetByContentID", ex); throw new DbCslaException("Error on ItemInfoList.GetByContentID", ex);
} }
} }
private ItemInfoList() private ItemInfoList()
{ /* require use of factory methods */ } { /* require use of factory methods */ }
#endregion #endregion
#region Data Access Portal #region Data Access Portal
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
cm.CommandType = CommandType.StoredProcedure; cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItems"; cm.CommandText = "getItems";
cm.CommandTimeout = Database.DefaultTimeout; cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
IsReadOnly = false; IsReadOnly = false;
while (dr.Read()) this.Add(new ItemInfo(dr)); while (dr.Read()) this.Add(new ItemInfo(dr));
IsReadOnly = true; IsReadOnly = true;
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
} }
[Serializable()] [Serializable()]
private class PreviousIDCriteria private class PreviousIDCriteria
{ {
public PreviousIDCriteria(int? previousID) public PreviousIDCriteria(int? previousID)
{ {
_PreviousID = previousID; _PreviousID = previousID;
} }
private int? _PreviousID; private int? _PreviousID;
public int? PreviousID public int? PreviousID
{ {
get { return _PreviousID; } get { return _PreviousID; }
set { _PreviousID = value; } set { _PreviousID = value; }
} }
} }
private void DataPortal_Fetch(PreviousIDCriteria criteria) private void DataPortal_Fetch(PreviousIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchPreviousID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchPreviousID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
cm.CommandType = CommandType.StoredProcedure; cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getNextItems"; cm.CommandText = "getNextItems";
cm.Parameters.AddWithValue("@PreviousID", criteria.PreviousID); cm.Parameters.AddWithValue("@PreviousID", criteria.PreviousID);
cm.CommandTimeout = Database.DefaultTimeout; cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
IsReadOnly = false; IsReadOnly = false;
while (dr.Read()) this.Add(new ItemInfo(dr)); while (dr.Read()) this.Add(new ItemInfo(dr));
IsReadOnly = true; IsReadOnly = true;
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_FetchPreviousID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_FetchPreviousID", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
} }
[Serializable()] [Serializable()]
private class ContentIDCriteria private class ContentIDCriteria
{ {
public ContentIDCriteria(int contentID) public ContentIDCriteria(int contentID)
{ {
_ContentID = contentID; _ContentID = contentID;
} }
private int _ContentID; private int _ContentID;
public int ContentID public int ContentID
{ {
get { return _ContentID; } get { return _ContentID; }
set { _ContentID = value; } set { _ContentID = value; }
} }
} }
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
cm.CommandType = CommandType.StoredProcedure; cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getItemsByContentID"; cm.CommandText = "getItemsByContentID";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.CommandTimeout = Database.DefaultTimeout; cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
IsReadOnly = false; IsReadOnly = false;
while (dr.Read()) this.Add(new ItemInfo(dr)); while (dr.Read()) this.Add(new ItemInfo(dr));
IsReadOnly = true; IsReadOnly = true;
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
} }
#endregion #endregion
#region ICustomTypeDescriptor impl #region ICustomTypeDescriptor impl
public String GetClassName() public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); } { return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes() public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); } { return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName() public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); } { return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter() public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); } { return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent() public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); } { return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty() public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); } { return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType) public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); } { return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes) public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); } { return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents() public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); } { return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd) public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; } { return this; }
/// <summary> /// <summary>
/// Called to get the properties of this type. Returns properties with certain /// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here. /// attributes. this restriction is not implemented here.
/// </summary> /// </summary>
/// <param name="attributes"></param> /// <param name="attributes"></param>
/// <returns></returns> /// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); } { return GetProperties(); }
/// <summary> /// <summary>
/// Called to get the properties of this type. /// Called to get the properties of this type.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public PropertyDescriptorCollection GetProperties() public PropertyDescriptorCollection GetProperties()
{ {
// Create a collection object to hold property descriptors // Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list // Iterate the list
for (int i = 0; i < this.Items.Count; i++) for (int i = 0; i < this.Items.Count; i++)
{ {
// Create a property descriptor for the item and add to the property descriptor collection // Create a property descriptor for the item and add to the property descriptor collection
ItemInfoListPropertyDescriptor pd = new ItemInfoListPropertyDescriptor(this, i); ItemInfoListPropertyDescriptor pd = new ItemInfoListPropertyDescriptor(this, i);
pds.Add(pd); pds.Add(pd);
} }
// return the property descriptor collection // return the property descriptor collection
return pds; return pds;
} }
#endregion #endregion
} // Class } // Class
#region Property Descriptor #region Property Descriptor
/// <summary> /// <summary>
/// Summary description for CollectionPropertyDescriptor. /// Summary description for CollectionPropertyDescriptor.
/// </summary> /// </summary>
public partial class ItemInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class ItemInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private ItemInfo Item { get { return (ItemInfo)_Item; } } private ItemInfo Item { get { return (ItemInfo)_Item; } }
public ItemInfoListPropertyDescriptor(ItemInfoList collection, int index) : base(collection, index) {; } public ItemInfoListPropertyDescriptor(ItemInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
internal class ItemInfoListConverter : ExpandableObjectConverter internal class ItemInfoListConverter : ExpandableObjectConverter
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
if (destType == typeof(string) && value is ItemInfoList) if (destType == typeof(string) && value is ItemInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((ItemInfoList)value).Items.Count.ToString() + " Items"; return ((ItemInfoList)value).Items.Count.ToString() + " Items";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
} }
#endregion #endregion
} // Namespace } // Namespace

View File

@ -20,458 +20,472 @@ using System.Collections.Generic;
using Csla.Validation; using Csla.Validation;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// ItemPart Generated by MyGeneration using the CSLA Object Mapping template /// ItemPart Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(ItemPartConverter))] [TypeConverter(typeof(ItemPartConverter))]
public partial class ItemPart : BusinessBase<ItemPart>, IVEHasBrokenRules, IDisposable public partial class ItemPart : BusinessBase<ItemPart>, IVEHasBrokenRules, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
private int _ContentID; private int _ContentID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int ContentID public int ContentID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyContent != null) _ContentID = _MyContent.ContentID; CanReadProperty("ContentID", true);
return _ContentID; if (_MyContent != null) _ContentID = _MyContent.ContentID;
} return _ContentID;
} }
private Content _MyContent; }
[System.ComponentModel.DataObjectField(true, true)] private Content _MyContent;
public Content MyContent [System.ComponentModel.DataObjectField(true, true)]
{ public Content MyContent
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID); {
return _MyContent; CanReadProperty("MyContent", true);
} if (_MyContent == null && _ContentID != 0) _MyContent = Content.Get(_ContentID);
} return _MyContent;
private int _FromType; }
[System.ComponentModel.DataObjectField(true, true)] }
public int FromType private int _FromType;
{ [System.ComponentModel.DataObjectField(true, true)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int FromType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _FromType; get
} {
} CanReadProperty("FromType", true);
private DateTime _DTS = new DateTime(); return _FromType;
public DateTime DTS }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private DateTime _DTS = new DateTime();
get public DateTime DTS
{ {
return _DTS; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
set CanReadProperty("DTS", true);
{ return _DTS;
if (_DTS != value) }
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
_DTS = value; set
PropertyHasChanged(); {
} CanWriteProperty("DTS", true);
} if (_DTS != value)
} {
private string _UserID = string.Empty; _DTS = value;
public string UserID PropertyHasChanged();
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _UserID = string.Empty;
return _UserID; public string UserID
} {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
set get
{ {
if (value == null) value = string.Empty; CanReadProperty("UserID", true);
if (_UserID != value) return _UserID;
{ }
_UserID = value; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
PropertyHasChanged(); set
} {
} CanWriteProperty("UserID", true);
} if (value == null) value = string.Empty;
private byte[] _LastChanged = new byte[8];//timestamp if (_UserID != value)
private string _Content_Number = string.Empty; {
/// <summary> _UserID = value;
/// Increased from 30 to 256 to support RTF symbols PropertyHasChanged();
/// </summary> }
public string Content_Number }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private byte[] _LastChanged = new byte[8];//timestamp
get private string _Content_Number = string.Empty;
{ /// <summary>
return _Content_Number; /// Increased from 30 to 256 to support RTF symbols
} /// </summary>
} public string Content_Number
private string _Content_Text = string.Empty; {
public string Content_Text [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("Content_Number", true);
{ return _Content_Number;
return _Content_Text; }
} }
} private string _Content_Text = string.Empty;
private int? _Content_Type; public string Content_Text
/// <summary> {
/// 0 - Procedure, 10000 - Section, 20000 Step [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// </summary> get
public int? Content_Type {
{ CanReadProperty("Content_Text", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _Content_Text;
get }
{ }
return _Content_Type; private int? _Content_Type;
} /// <summary>
} /// 0 - Procedure, 10000 - Section, 20000 Step
private int? _Content_FormatID; /// </summary>
public int? Content_FormatID public int? Content_Type
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _Content_FormatID; CanReadProperty("Content_Type", true);
} return _Content_Type;
} }
private string _Content_Config = string.Empty; }
public string Content_Config private int? _Content_FormatID;
{ public int? Content_FormatID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _Content_Config; {
} CanReadProperty("Content_FormatID", true);
} return _Content_FormatID;
private DateTime _Content_DTS = new DateTime(); }
public DateTime Content_DTS }
{ private string _Content_Config = string.Empty;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public string Content_Config
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _Content_DTS; get
} {
} CanReadProperty("Content_Config", true);
private string _Content_UserID = string.Empty; return _Content_Config;
public string Content_UserID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private DateTime _Content_DTS = new DateTime();
get public DateTime Content_DTS
{ {
return _Content_UserID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
// CSLATODO: Check ItemPart.GetIdValue to assure that the ID returned is unique CanReadProperty("Content_DTS", true);
/// <summary> return _Content_DTS;
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality }
/// </summary> }
/// <returns>A Unique ID for the current ItemPart</returns> private string _Content_UserID = string.Empty;
protected override object GetIdValue() public string Content_UserID
{ {
return MyItemPartUnique; // Absolutely Unique ID [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
// CSLATODO: Replace base ItemPart.ToString function as necessary {
/// <summary> CanReadProperty("Content_UserID", true);
/// Overrides Base ToString return _Content_UserID;
/// </summary> }
/// <returns>A string representation of current ItemPart</returns> }
//public override string ToString() // CSLATODO: Check ItemPart.GetIdValue to assure that the ID returned is unique
//{ /// <summary>
// return base.ToString(); /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
//} /// </summary>
public override bool IsDirty /// <returns>A Unique ID for the current ItemPart</returns>
{ protected override object GetIdValue()
get { return base.IsDirty; } {
} return MyItemPartUnique; // Absolutely Unique ID
public bool IsDirtyList(List<object> list) }
{ // CSLATODO: Replace base ItemPart.ToString function as necessary
return base.IsDirty; /// <summary>
} /// Overrides Base ToString
public override bool IsValid /// </summary>
{ /// <returns>A string representation of current ItemPart</returns>
get { return (IsNew && !IsDirty) ? true : base.IsValid; } //public override string ToString()
} //{
public bool IsValidList(List<object> list) // return base.ToString();
{ //}
return (IsNew && !IsDirty) ? true : base.IsValid; public override bool IsDirty
} {
#endregion get { return base.IsDirty; }
#region ValidationRules }
[NonSerialized] public bool IsDirtyList(List<object> list)
private bool _CheckingBrokenRules = false; {
public IVEHasBrokenRules HasBrokenRules return base.IsDirty;
{ }
get public override bool IsValid
{ {
if (_CheckingBrokenRules) return null; get { return (IsNew && !IsDirty) ? true : base.IsValid; }
if (BrokenRulesCollection.Count > 0) return this; }
try public bool IsValidList(List<object> list)
{ {
_CheckingBrokenRules = true; return (IsNew && !IsDirty) ? true : base.IsValid;
IVEHasBrokenRules hasBrokenRules = null; }
return hasBrokenRules; #endregion
} #region ValidationRules
finally [NonSerialized]
{ private bool _CheckingBrokenRules = false;
_CheckingBrokenRules = false; public IVEHasBrokenRules HasBrokenRules
} {
} get
} {
public BrokenRulesCollection BrokenRules if (_CheckingBrokenRules) return null;
{ if (BrokenRulesCollection.Count > 0) return this;
get try
{ {
IVEHasBrokenRules hasBrokenRules = HasBrokenRules; _CheckingBrokenRules = true;
if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; IVEHasBrokenRules hasBrokenRules = null;
return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); return hasBrokenRules;
} }
} finally
protected override void AddBusinessRules() {
{ _CheckingBrokenRules = false;
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringRequired, "UserID"); }
ValidationRules.AddRule( }
Csla.Validation.CommonRules.StringMaxLength, public BrokenRulesCollection BrokenRules
new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); {
// CSLATODO: Add other validation rules get
} {
// Sample data comparison validation rule IVEHasBrokenRules hasBrokenRules = HasBrokenRules;
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) if (this.Equals(hasBrokenRules)) return BrokenRulesCollection;
//{ return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null);
// if (_started > _ended) }
// { }
// e.Description = "Start date can't be after end date"; protected override void AddBusinessRules()
// return false; {
// } ValidationRules.AddRule(
// else Csla.Validation.CommonRules.StringRequired, "UserID");
// return true; ValidationRules.AddRule(
//} Csla.Validation.CommonRules.StringMaxLength,
#endregion new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100));
#region Authorization Rules // CSLATODO: Add other validation rules
protected override void AddAuthorizationRules() }
{ // Sample data comparison validation rule
//CSLATODO: Who can read/write which fields //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>"); //{
//AuthorizationRules.AllowRead(FromType, "<Role(s)>"); // if (_started > _ended)
//AuthorizationRules.AllowRead(DTS, "<Role(s)>"); // {
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>"); // e.Description = "Start date can't be after end date";
//AuthorizationRules.AllowRead(UserID, "<Role(s)>"); // return false;
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>"); // }
} // else
public static bool CanAddObject() // return true;
{ //}
// CSLATODO: Can Add Authorization #endregion
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); #region Authorization Rules
return true; protected override void AddAuthorizationRules()
} {
public static bool CanGetObject() //CSLATODO: Who can read/write which fields
{ //AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
// CSLATODO: CanGet Authorization //AuthorizationRules.AllowRead(FromType, "<Role(s)>");
return true; //AuthorizationRules.AllowRead(DTS, "<Role(s)>");
} //AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
public static bool CanDeleteObject() //AuthorizationRules.AllowRead(UserID, "<Role(s)>");
{ //AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
// CSLATODO: CanDelete Authorization }
//bool result = false; public static bool CanAddObject()
//if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; {
//if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; // CSLATODO: Can Add Authorization
//return result; //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return true; return true;
} }
public static bool CanEditObject() public static bool CanGetObject()
{ {
// CSLATODO: CanEdit Authorization // CSLATODO: CanGet Authorization
//return Csla.ApplicationContext.User.IsInRole("ProjectManager"); return true;
return true; }
} public static bool CanDeleteObject()
#endregion {
#region Factory Methods // CSLATODO: CanDelete Authorization
public int CurrentEditLevel //bool result = false;
{ get { return EditLevel; } } //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true;
private static int _ItemPartUnique = 0; //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true;
private static int ItemPartUnique //return result;
{ get { return ++_ItemPartUnique; } } return true;
private int _MyItemPartUnique = ItemPartUnique; }
public int MyItemPartUnique // Absolutely Unique ID - Editable FK public static bool CanEditObject()
{ get { return _MyItemPartUnique; } } {
internal static ItemPart New(Content myContent, int fromType) // CSLATODO: CanEdit Authorization
{ //return Csla.ApplicationContext.User.IsInRole("ProjectManager");
return new ItemPart(myContent, fromType); return true;
} }
internal static ItemPart Get(SafeDataReader dr) #endregion
{ #region Factory Methods
return new ItemPart(dr); public int CurrentEditLevel
} { get { return EditLevel; } }
public ItemPart() private static int _ItemPartUnique = 0;
{ private static int ItemPartUnique
MarkAsChild(); { get { return ++_ItemPartUnique; } }
private int _MyItemPartUnique = ItemPartUnique;
public int MyItemPartUnique // Absolutely Unique ID - Editable FK
{ get { return _MyItemPartUnique; } }
internal static ItemPart New(Content myContent, int fromType)
{
return new ItemPart(myContent, fromType);
}
internal static ItemPart Get(SafeDataReader dr)
{
return new ItemPart(dr);
}
public ItemPart()
{
MarkAsChild();
_DTS = _ItemPartExtension.DefaultDTS; _DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID; _UserID = _ItemPartExtension.DefaultUserID;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
private ItemPart(Content myContent, int fromType) private ItemPart(Content myContent, int fromType)
{ {
MarkAsChild(); MarkAsChild();
// CSLATODO: Add any initialization & defaults // CSLATODO: Add any initialization & defaults
_DTS = _ItemPartExtension.DefaultDTS; _DTS = _ItemPartExtension.DefaultDTS;
_UserID = _ItemPartExtension.DefaultUserID; _UserID = _ItemPartExtension.DefaultUserID;
_MyContent = myContent; _MyContent = myContent;
_FromType = fromType; _FromType = fromType;
ValidationRules.CheckRules(); ValidationRules.CheckRules();
} }
internal ItemPart(SafeDataReader dr) internal ItemPart(SafeDataReader dr)
{ {
MarkAsChild(); MarkAsChild();
Fetch(dr); Fetch(dr);
} }
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~ItemPart() ~ItemPart()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++; _CountDisposed++;
_Disposed = true; _Disposed = true;
} }
#endregion #endregion
#region Data Access Portal #region Data Access Portal
private void Fetch(SafeDataReader dr) private void Fetch(SafeDataReader dr)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemPart.FetchDR", GetHashCode());
try try
{ {
_ContentID = dr.GetInt32("ContentID"); _ContentID = dr.GetInt32("ContentID");
_FromType = dr.GetInt32("FromType"); _FromType = dr.GetInt32("FromType");
_DTS = dr.GetDateTime("DTS"); _DTS = dr.GetDateTime("DTS");
_UserID = dr.GetString("UserID"); _UserID = dr.GetString("UserID");
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
_Content_Number = dr.GetString("Content_Number"); _Content_Number = dr.GetString("Content_Number");
_Content_Text = dr.GetString("Content_Text"); _Content_Text = dr.GetString("Content_Text");
_Content_Type = (int?)dr.GetValue("Content_Type"); _Content_Type = (int?)dr.GetValue("Content_Type");
_Content_FormatID = (int?)dr.GetValue("Content_FormatID"); _Content_FormatID = (int?)dr.GetValue("Content_FormatID");
_Content_Config = dr.GetString("Content_Config"); _Content_Config = dr.GetString("Content_Config");
_Content_DTS = dr.GetDateTime("Content_DTS"); _Content_DTS = dr.GetDateTime("Content_DTS");
_Content_UserID = dr.GetString("Content_UserID"); _Content_UserID = dr.GetString("Content_UserID");
} }
catch (Exception ex) // FKItem Fetch catch (Exception ex) // FKItem Fetch
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemPart.FetchDR", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemPart.FetchDR", ex);
throw new DbCslaException("ItemPart.Fetch", ex); throw new DbCslaException("ItemPart.Fetch", ex);
} }
MarkOld(); MarkOld();
} }
internal void Insert(Item myItem) internal void Insert(Item myItem)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Add(cn, _MyContent, _FromType, myItem, _DTS, _UserID); _LastChanged = Part.Add(cn, _MyContent, _FromType, myItem, _DTS, _UserID);
MarkOld(); MarkOld();
} }
internal void Update(Item myItem) internal void Update(Item myItem)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
_LastChanged = Part.Update(cn, _ContentID, _FromType, myItem.ItemID, _DTS, _UserID, ref _LastChanged); _LastChanged = Part.Update(cn, _ContentID, _FromType, myItem.ItemID, _DTS, _UserID, ref _LastChanged);
MarkOld(); MarkOld();
} }
internal void DeleteSelf(Item myItem) internal void DeleteSelf(Item myItem)
{ {
// if we're not dirty then don't update the database // if we're not dirty then don't update the database
if (!this.IsDirty) return; if (!this.IsDirty) return;
// if we're new then don't update the database // if we're new then don't update the database
if (this.IsNew) return; if (this.IsNew) return;
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
Part.Remove(cn, _ContentID, _FromType); Part.Remove(cn, _ContentID, _FromType);
MarkNew(); MarkNew();
} }
#endregion #endregion
// Standard Default Code // Standard Default Code
#region extension #region extension
ItemPartExtension _ItemPartExtension = new ItemPartExtension(); ItemPartExtension _ItemPartExtension = new ItemPartExtension();
[Serializable()] [Serializable()]
partial class ItemPartExtension : extensionBase partial class ItemPartExtension : extensionBase
{ {
} }
[Serializable()] [Serializable()]
class extensionBase class extensionBase
{ {
// Default Values // Default Values
public virtual DateTime DefaultDTS public virtual DateTime DefaultDTS
{ {
get { return DateTime.Now; } get { return DateTime.Now; }
} }
public virtual string DefaultUserID public virtual string DefaultUserID
{ {
get { return Volian.Base.Library.VlnSettings.UserID; } get { return Volian.Base.Library.VlnSettings.UserID; }
} }
// Authorization Rules // Authorization Rules
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Instance Authorization Rules // Instance Authorization Rules
public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules)
{ {
// Needs to be overriden to add new authorization rules // Needs to be overriden to add new authorization rules
} }
// Validation Rules // Validation Rules
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
// InstanceValidation Rules // InstanceValidation Rules
public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules)
{ {
// Needs to be overriden to add new validation rules // Needs to be overriden to add new validation rules
} }
} }
#endregion #endregion
} // Class } // Class
#region Converter #region Converter
internal class ItemPartConverter : ExpandableObjectConverter internal class ItemPartConverter : ExpandableObjectConverter
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
if (destType == typeof(string) && value is ItemPart) if (destType == typeof(string) && value is ItemPart)
{ {
// Return the ToString value // Return the ToString value
return ((ItemPart)value).ToString(); return ((ItemPart)value).ToString();
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
} }
#endregion #endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,449 +19,459 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void MembershipInfoEvent(object sender); public delegate void MembershipInfoEvent(object sender);
/// <summary> /// <summary>
/// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template /// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(MembershipInfoConverter))] [TypeConverter(typeof(MembershipInfoConverter))]
public partial class MembershipInfo : ReadOnlyBase<MembershipInfo>, IDisposable public partial class MembershipInfo : ReadOnlyBase<MembershipInfo>, IDisposable
{ {
public event MembershipInfoEvent Changed; public event MembershipInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<MembershipInfo> _CacheList = new List<MembershipInfo>(); private static List<MembershipInfo> _CacheList = new List<MembershipInfo>();
protected static void AddToCache(MembershipInfo membershipInfo) protected static void AddToCache(MembershipInfo membershipInfo)
{ {
if (!_CacheList.Contains(membershipInfo)) _CacheList.Add(membershipInfo); // In AddToCache if (!_CacheList.Contains(membershipInfo)) _CacheList.Add(membershipInfo); // In AddToCache
} }
protected static void RemoveFromCache(MembershipInfo membershipInfo) protected static void RemoveFromCache(MembershipInfo membershipInfo)
{ {
while (_CacheList.Contains(membershipInfo)) _CacheList.Remove(membershipInfo); // In RemoveFromCache while (_CacheList.Contains(membershipInfo)) _CacheList.Remove(membershipInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<MembershipInfo>> _CacheByPrimaryKey = new Dictionary<string, List<MembershipInfo>>(); private static Dictionary<string, List<MembershipInfo>> _CacheByPrimaryKey = new Dictionary<string, List<MembershipInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move MembershipInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move MembershipInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
MembershipInfo tmp = _CacheList[0]; // Get the first MembershipInfo MembershipInfo tmp = _CacheList[0]; // Get the first MembershipInfo
string pKey = tmp.UGID.ToString(); string pKey = tmp.UGID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<MembershipInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<MembershipInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first MembershipInfo _CacheList.RemoveAt(0); // Remove the first MembershipInfo
} }
} }
internal static void AddList(MembershipInfoList lst) internal static void AddList(MembershipInfoList lst)
{ {
foreach (MembershipInfo item in lst) AddToCache(item); foreach (MembershipInfo item in lst) AddToCache(item);
} }
protected static MembershipInfo GetCachedByPrimaryKey(int ugid) protected static MembershipInfo GetCachedByPrimaryKey(int ugid)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = ugid.ToString(); string key = ugid.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Membership _Editable; protected Membership _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _UGID; private int _UGID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int UGID public int UGID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _UGID; CanReadProperty("UGID", true);
} return _UGID;
} }
private int _UID; }
public int UID private int _UID;
{ public int UID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyUser != null) _UID = _MyUser.UID; {
return _UID; CanReadProperty("UID", true);
} if (_MyUser != null) _UID = _MyUser.UID;
} return _UID;
private UserInfo _MyUser; }
public UserInfo MyUser }
{ private UserInfo _MyUser;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public UserInfo MyUser
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID); get
return _MyUser; {
} CanReadProperty("MyUser", true);
} if (_MyUser == null && _UID != 0) _MyUser = UserInfo.Get(_UID);
private int _GID; return _MyUser;
public int GID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _GID;
get public int GID
{ {
if (_MyGroup != null) _GID = _MyGroup.GID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _GID; get
} {
} CanReadProperty("GID", true);
private GroupInfo _MyGroup; if (_MyGroup != null) _GID = _MyGroup.GID;
public GroupInfo MyGroup return _GID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private GroupInfo _MyGroup;
{ public GroupInfo MyGroup
if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID); {
return _MyGroup; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private string _StartDate = string.Empty; CanReadProperty("MyGroup", true);
public string StartDate if (_MyGroup == null && _GID != 0) _MyGroup = GroupInfo.Get(_GID);
{ return _MyGroup;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _StartDate = string.Empty;
return _StartDate; public string StartDate
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private string _EndDate = string.Empty; get
public string EndDate {
{ CanReadProperty("StartDate", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _StartDate;
get }
{ }
return _EndDate; private string _EndDate = string.Empty;
} public string EndDate
} {
private string _Config = string.Empty; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public string Config get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("EndDate", true);
get return _EndDate;
{ }
return _Config; }
} private string _Config = string.Empty;
} public string Config
private DateTime _DTS = new DateTime(); {
public DateTime DTS [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("Config", true);
{ return _Config;
return _DTS; }
} }
} private DateTime _DTS = new DateTime();
private string _UsrID = string.Empty; public DateTime DTS
public string UsrID {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("DTS", true);
return _UsrID; return _DTS;
} }
} }
// CSLATODO: Replace base MembershipInfo.ToString function as necessary private string _UsrID = string.Empty;
/// <summary> public string UsrID
/// Overrides Base ToString {
/// </summary> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <returns>A string representation of current MembershipInfo</returns> get
//public override string ToString() {
//{ CanReadProperty("UsrID", true);
// return base.ToString(); return _UsrID;
//} }
// CSLATODO: Check MembershipInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> // CSLATODO: Replace base MembershipInfo.ToString function as necessary
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <summary>
/// </summary> /// Overrides Base ToString
/// <returns>A Unique ID for the current MembershipInfo</returns> /// </summary>
protected override object GetIdValue() /// <returns>A string representation of current MembershipInfo</returns>
{ //public override string ToString()
return MyMembershipInfoUnique; // Absolutely Unique ID //{
} // return base.ToString();
#endregion //}
#region Factory Methods // CSLATODO: Check MembershipInfo.GetIdValue to assure that the ID returned is unique
private static int _MembershipInfoUnique = 0; /// <summary>
private static int MembershipInfoUnique /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
{ get { return ++_MembershipInfoUnique; } } /// </summary>
private int _MyMembershipInfoUnique = MembershipInfoUnique; /// <returns>A Unique ID for the current MembershipInfo</returns>
public int MyMembershipInfoUnique // Absolutely Unique ID - Info protected override object GetIdValue()
{ get { return _MyMembershipInfoUnique; } } {
protected MembershipInfo() return MyMembershipInfoUnique; // Absolutely Unique ID
{/* require use of factory methods */ }
AddToCache(this); #endregion
} #region Factory Methods
private bool _Disposed = false; private static int _MembershipInfoUnique = 0;
private static int _CountCreated = 0; private static int MembershipInfoUnique
private static int _CountDisposed = 0; { get { return ++_MembershipInfoUnique; } }
private static int _CountFinalized = 0; private int _MyMembershipInfoUnique = MembershipInfoUnique;
private static int IncrementCountCreated public int MyMembershipInfoUnique // Absolutely Unique ID - Info
{ get { return ++_CountCreated; } } { get { return _MyMembershipInfoUnique; } }
private int _CountWhenCreated = IncrementCountCreated; protected MembershipInfo()
public static int CountCreated {/* require use of factory methods */
{ get { return _CountCreated; } } AddToCache(this);
public static int CountNotDisposed }
{ get { return _CountCreated - _CountDisposed; } } private bool _Disposed = false;
public static int CountNotFinalized private static int _CountCreated = 0;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountDisposed = 0;
~MembershipInfo() private static int _CountFinalized = 0;
{ private static int IncrementCountCreated
_CountFinalized++; { get { return ++_CountCreated; } }
} private int _CountWhenCreated = IncrementCountCreated;
public void Dispose() public static int CountCreated
{ { get { return _CountCreated; } }
if (_Disposed) return; public static int CountNotDisposed
_CountDisposed++; { get { return _CountCreated - _CountDisposed; } }
_Disposed = true; public static int CountNotFinalized
RemoveFromCache(this); { get { return _CountCreated - _CountFinalized; } }
if (!_CacheByPrimaryKey.ContainsKey(UGID.ToString())) return; ~MembershipInfo()
List<MembershipInfo> listMembershipInfo = _CacheByPrimaryKey[UGID.ToString()]; // Get the list of items {
while (listMembershipInfo.Contains(this)) listMembershipInfo.Remove(this); // Remove the item from the list _CountFinalized++;
if (listMembershipInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list public void Dispose()
} {
public virtual Membership Get() if (_Disposed) return;
{ _CountDisposed++;
return _Editable = Membership.Get(_UGID); _Disposed = true;
} RemoveFromCache(this);
public static void Refresh(Membership tmp) if (!_CacheByPrimaryKey.ContainsKey(UGID.ToString())) return;
{ List<MembershipInfo> listMembershipInfo = _CacheByPrimaryKey[UGID.ToString()]; // Get the list of items
string key = tmp.UGID.ToString(); while (listMembershipInfo.Contains(this)) listMembershipInfo.Remove(this); // Remove the item from the list
ConvertListToDictionary(); if (listMembershipInfo.Count == 0) // If there are no items left in the list
if (_CacheByPrimaryKey.ContainsKey(key)) _CacheByPrimaryKey.Remove(UGID.ToString()); // remove the list
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); public virtual Membership Get()
} {
protected virtual void RefreshFields(Membership tmp) return _Editable = Membership.Get(_UGID);
{ }
if (_UID != tmp.UID) public static void Refresh(Membership tmp)
{ {
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value string key = tmp.UGID.ToString();
_UID = tmp.UID; // Update the value ConvertListToDictionary();
} if (_CacheByPrimaryKey.ContainsKey(key))
_MyUser = null; // Reset list so that the next line gets a new list foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value tmpInfo.RefreshFields(tmp);
if (_GID != tmp.GID) }
{ protected virtual void RefreshFields(Membership tmp)
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value {
_GID = tmp.GID; // Update the value if (_UID != tmp.UID)
} {
_MyGroup = null; // Reset list so that the next line gets a new list if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value _UID = tmp.UID; // Update the value
_StartDate = tmp.StartDate; }
_EndDate = tmp.EndDate; _MyUser = null; // Reset list so that the next line gets a new list
_Config = tmp.Config; if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
_DTS = tmp.DTS; if (_GID != tmp.GID)
_UsrID = tmp.UsrID; {
_MembershipInfoExtension.Refresh(this); if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
OnChange();// raise an event _GID = tmp.GID; // Update the value
} }
public static void Refresh(GroupMembership tmp) _MyGroup = null; // Reset list so that the next line gets a new list
{ if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
string key = tmp.UGID.ToString(); _StartDate = tmp.StartDate;
ConvertListToDictionary(); _EndDate = tmp.EndDate;
if (_CacheByPrimaryKey.ContainsKey(key)) _Config = tmp.Config;
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key]) _DTS = tmp.DTS;
tmpInfo.RefreshFields(tmp); _UsrID = tmp.UsrID;
} _MembershipInfoExtension.Refresh(this);
protected virtual void RefreshFields(GroupMembership tmp) OnChange();// raise an event
{ }
if (_UID != tmp.UID) public static void Refresh(GroupMembership tmp)
{ {
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value string key = tmp.UGID.ToString();
_UID = tmp.UID; // Update the value ConvertListToDictionary();
} if (_CacheByPrimaryKey.ContainsKey(key))
_MyUser = null; // Reset list so that the next line gets a new list foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value tmpInfo.RefreshFields(tmp);
_StartDate = tmp.StartDate; }
_EndDate = tmp.EndDate; protected virtual void RefreshFields(GroupMembership tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_UID != tmp.UID)
_UsrID = tmp.UsrID; {
_MembershipInfoExtension.Refresh(this); if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for old value
OnChange();// raise an event _UID = tmp.UID; // Update the value
} }
public static void Refresh(UserMembership tmp) _MyUser = null; // Reset list so that the next line gets a new list
{ if (MyUser != null) MyUser.RefreshUserMemberships(); // Update List for new value
string key = tmp.UGID.ToString(); _StartDate = tmp.StartDate;
ConvertListToDictionary(); _EndDate = tmp.EndDate;
if (_CacheByPrimaryKey.ContainsKey(key)) _Config = tmp.Config;
foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key]) _DTS = tmp.DTS;
tmpInfo.RefreshFields(tmp); _UsrID = tmp.UsrID;
} _MembershipInfoExtension.Refresh(this);
protected virtual void RefreshFields(UserMembership tmp) OnChange();// raise an event
{ }
if (_GID != tmp.GID) public static void Refresh(UserMembership tmp)
{ {
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value string key = tmp.UGID.ToString();
_GID = tmp.GID; // Update the value ConvertListToDictionary();
} if (_CacheByPrimaryKey.ContainsKey(key))
_MyGroup = null; // Reset list so that the next line gets a new list foreach (MembershipInfo tmpInfo in _CacheByPrimaryKey[key])
if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value tmpInfo.RefreshFields(tmp);
_StartDate = tmp.StartDate; }
_EndDate = tmp.EndDate; protected virtual void RefreshFields(UserMembership tmp)
_Config = tmp.Config; {
_DTS = tmp.DTS; if (_GID != tmp.GID)
_UsrID = tmp.UsrID; {
_MembershipInfoExtension.Refresh(this); if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for old value
OnChange();// raise an event _GID = tmp.GID; // Update the value
} }
public static MembershipInfo Get(int ugid) _MyGroup = null; // Reset list so that the next line gets a new list
{ if (MyGroup != null) MyGroup.RefreshGroupMemberships(); // Update List for new value
//if (!CanGetObject()) _StartDate = tmp.StartDate;
// throw new System.Security.SecurityException("User not authorized to view a Membership"); _EndDate = tmp.EndDate;
try _Config = tmp.Config;
{ _DTS = tmp.DTS;
MembershipInfo tmp = GetCachedByPrimaryKey(ugid); _UsrID = tmp.UsrID;
if (tmp == null) _MembershipInfoExtension.Refresh(this);
{ OnChange();// raise an event
tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid)); }
AddToCache(tmp); public static MembershipInfo Get(int ugid)
} {
if (tmp.ErrorMessage == "No Record Found") //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a Membership");
tmp.Dispose(); // Clean-up MembershipInfo try
tmp = null; {
} MembershipInfo tmp = GetCachedByPrimaryKey(ugid);
return tmp; if (tmp == null)
} {
catch (Exception ex) tmp = DataPortal.Fetch<MembershipInfo>(new PKCriteria(ugid));
{ AddToCache(tmp);
throw new DbCslaException("Error on MembershipInfo.Get", ex); }
} if (tmp.ErrorMessage == "No Record Found")
} {
#endregion tmp.Dispose(); // Clean-up MembershipInfo
#region Data Access Portal tmp = null;
internal MembershipInfo(SafeDataReader dr) }
{ return tmp;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode()); }
try catch (Exception ex)
{ {
ReadData(dr); throw new DbCslaException("Error on MembershipInfo.Get", ex);
} }
catch (Exception ex) }
{ #endregion
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.Constructor", ex); #region Data Access Portal
throw new DbCslaException("MembershipInfo.Constructor", ex); internal MembershipInfo(SafeDataReader dr)
} {
} if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.Constructor", GetHashCode());
[Serializable()] try
protected class PKCriteria {
{ ReadData(dr);
private int _UGID; }
public int UGID catch (Exception ex)
{ get { return _UGID; } } {
public PKCriteria(int ugid) if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.Constructor", ex);
{ throw new DbCslaException("MembershipInfo.Constructor", ex);
_UGID = ugid; }
} }
} [Serializable()]
private void ReadData(SafeDataReader dr) protected class PKCriteria
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode()); private int _UGID;
try public int UGID
{ { get { return _UGID; } }
_UGID = dr.GetInt32("UGID"); public PKCriteria(int ugid)
_UID = dr.GetInt32("UID"); {
_GID = dr.GetInt32("GID"); _UGID = ugid;
_StartDate = dr.GetSmartDate("StartDate").Text; }
_EndDate = dr.GetSmartDate("EndDate").Text; }
_Config = dr.GetString("Config"); private void ReadData(SafeDataReader dr)
_DTS = dr.GetDateTime("DTS"); {
_UsrID = dr.GetString("UsrID"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.ReadData", GetHashCode());
} try
catch (Exception ex) {
{ _UGID = dr.GetInt32("UGID");
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex); _UID = dr.GetInt32("UID");
_ErrorMessage = ex.Message; _GID = dr.GetInt32("GID");
throw new DbCslaException("MembershipInfo.ReadData", ex); _StartDate = dr.GetSmartDate("StartDate").Text;
} _EndDate = dr.GetSmartDate("EndDate").Text;
} _Config = dr.GetString("Config");
private void DataPortal_Fetch(PKCriteria criteria) _DTS = dr.GetDateTime("DTS");
{ _UsrID = dr.GetString("UsrID");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.DataPortal_Fetch", GetHashCode()); }
try catch (Exception ex)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
ApplicationContext.LocalContext["cn"] = cn; throw new DbCslaException("MembershipInfo.ReadData", ex);
using (SqlCommand cm = cn.CreateCommand()) }
{ }
cm.CommandType = CommandType.StoredProcedure; private void DataPortal_Fetch(PKCriteria criteria)
cm.CommandText = "getMembership"; {
cm.Parameters.AddWithValue("@UGID", criteria.UGID); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] MembershipInfo.DataPortal_Fetch", GetHashCode());
cm.CommandTimeout = Database.DefaultTimeout; try
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ using (SqlConnection cn = Database.VEPROMS_SqlConnection)
if (!dr.Read()) {
{ ApplicationContext.LocalContext["cn"] = cn;
_ErrorMessage = "No Record Found"; using (SqlCommand cm = cn.CreateCommand())
return; {
} cm.CommandType = CommandType.StoredProcedure;
ReadData(dr); cm.CommandText = "getMembership";
} cm.Parameters.AddWithValue("@UGID", criteria.UGID);
} cm.CommandTimeout = Database.DefaultTimeout;
// removing of item only needed for local data portal using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) {
ApplicationContext.LocalContext.Remove("cn"); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
catch (Exception ex) return;
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.DataPortal_Fetch", ex); ReadData(dr);
_ErrorMessage = ex.Message; }
throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
#endregion ApplicationContext.LocalContext.Remove("cn");
// Standard Refresh }
#region extension }
MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension(); catch (Exception ex)
[Serializable()] {
partial class MembershipInfoExtension : extensionBase { } if (_MyLog.IsErrorEnabled) _MyLog.Error("MembershipInfo.DataPortal_Fetch", ex);
[Serializable()] _ErrorMessage = ex.Message;
class extensionBase throw new DbCslaException("MembershipInfo.DataPortal_Fetch", ex);
{ }
// Default Refresh }
public virtual void Refresh(MembershipInfo tmp) { } #endregion
} // Standard Refresh
#endregion #region extension
} // Class MembershipInfoExtension _MembershipInfoExtension = new MembershipInfoExtension();
#region Converter [Serializable()]
internal class MembershipInfoConverter : ExpandableObjectConverter partial class MembershipInfoExtension : extensionBase { }
{ [Serializable()]
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) class extensionBase
{ {
if (destType == typeof(string) && value is MembershipInfo) // Default Refresh
{ public virtual void Refresh(MembershipInfo tmp) { }
// Return the ToString value }
return ((MembershipInfo)value).ToString(); #endregion
} } // Class
return base.ConvertTo(context, culture, value, destType); #region Converter
} internal class MembershipInfoConverter : ExpandableObjectConverter
} {
#endregion public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is MembershipInfo)
{
// Return the ToString value
return ((MembershipInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,332 +19,337 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void OwnerInfoEvent(object sender); public delegate void OwnerInfoEvent(object sender);
/// <summary> /// <summary>
/// OwnerInfo Generated by MyGeneration using the CSLA Object Mapping template /// OwnerInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(OwnerInfoConverter))] [TypeConverter(typeof(OwnerInfoConverter))]
public partial class OwnerInfo : ReadOnlyBase<OwnerInfo>, IDisposable public partial class OwnerInfo : ReadOnlyBase<OwnerInfo>, IDisposable
{ {
public event OwnerInfoEvent Changed; public event OwnerInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<OwnerInfo> _CacheList = new List<OwnerInfo>(); private static List<OwnerInfo> _CacheList = new List<OwnerInfo>();
protected static void AddToCache(OwnerInfo ownerInfo) protected static void AddToCache(OwnerInfo ownerInfo)
{ {
if (!_CacheList.Contains(ownerInfo)) _CacheList.Add(ownerInfo); // In AddToCache if (!_CacheList.Contains(ownerInfo)) _CacheList.Add(ownerInfo); // In AddToCache
} }
protected static void RemoveFromCache(OwnerInfo ownerInfo) protected static void RemoveFromCache(OwnerInfo ownerInfo)
{ {
while (_CacheList.Contains(ownerInfo)) _CacheList.Remove(ownerInfo); // In RemoveFromCache while (_CacheList.Contains(ownerInfo)) _CacheList.Remove(ownerInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<OwnerInfo>> _CacheByPrimaryKey = new Dictionary<string, List<OwnerInfo>>(); private static Dictionary<string, List<OwnerInfo>> _CacheByPrimaryKey = new Dictionary<string, List<OwnerInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move OwnerInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move OwnerInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
OwnerInfo tmp = _CacheList[0]; // Get the first OwnerInfo OwnerInfo tmp = _CacheList[0]; // Get the first OwnerInfo
string pKey = tmp.OwnerID.ToString(); string pKey = tmp.OwnerID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<OwnerInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<OwnerInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first OwnerInfo _CacheList.RemoveAt(0); // Remove the first OwnerInfo
} }
} }
internal static void AddList(OwnerInfoList lst) internal static void AddList(OwnerInfoList lst)
{ {
foreach (OwnerInfo item in lst) AddToCache(item); foreach (OwnerInfo item in lst) AddToCache(item);
} }
protected static OwnerInfo GetCachedByPrimaryKey(int ownerID) protected static OwnerInfo GetCachedByPrimaryKey(int ownerID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = ownerID.ToString(); string key = ownerID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Owner _Editable; protected Owner _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _OwnerID; private int _OwnerID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int OwnerID public int OwnerID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _OwnerID; CanReadProperty("OwnerID", true);
} return _OwnerID;
} }
private int _SessionID; }
public int SessionID private int _SessionID;
{ public int SessionID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _SessionID; {
} CanReadProperty("SessionID", true);
} return _SessionID;
private byte _OwnerType; }
public byte OwnerType }
{ private byte _OwnerType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public byte OwnerType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _OwnerType; get
} {
} CanReadProperty("OwnerType", true);
private int _OwnerItemID; return _OwnerType;
public int OwnerItemID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _OwnerItemID;
get public int OwnerItemID
{ {
return _OwnerItemID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private DateTime _DTSStart = new DateTime(); CanReadProperty("OwnerItemID", true);
public DateTime DTSStart return _OwnerItemID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTSStart = new DateTime();
{ public DateTime DTSStart
return _DTSStart; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
// CSLATODO: Replace base OwnerInfo.ToString function as necessary {
/// <summary> CanReadProperty("DTSStart", true);
/// Overrides Base ToString return _DTSStart;
/// </summary> }
/// <returns>A string representation of current OwnerInfo</returns> }
//public override string ToString() // CSLATODO: Replace base OwnerInfo.ToString function as necessary
//{ /// <summary>
// return base.ToString(); /// Overrides Base ToString
//} /// </summary>
// CSLATODO: Check OwnerInfo.GetIdValue to assure that the ID returned is unique /// <returns>A string representation of current OwnerInfo</returns>
/// <summary> //public override string ToString()
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality //{
/// </summary> // return base.ToString();
/// <returns>A Unique ID for the current OwnerInfo</returns> //}
protected override object GetIdValue() // CSLATODO: Check OwnerInfo.GetIdValue to assure that the ID returned is unique
{ /// <summary>
return MyOwnerInfoUnique; // Absolutely Unique ID /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
} /// </summary>
#endregion /// <returns>A Unique ID for the current OwnerInfo</returns>
#region Factory Methods protected override object GetIdValue()
private static int _OwnerInfoUnique = 0; {
private static int OwnerInfoUnique return MyOwnerInfoUnique; // Absolutely Unique ID
{ get { return ++_OwnerInfoUnique; } } }
private int _MyOwnerInfoUnique = OwnerInfoUnique; #endregion
public int MyOwnerInfoUnique // Absolutely Unique ID - Info #region Factory Methods
{ get { return _MyOwnerInfoUnique; } } private static int _OwnerInfoUnique = 0;
protected OwnerInfo() private static int OwnerInfoUnique
{/* require use of factory methods */ { get { return ++_OwnerInfoUnique; } }
AddToCache(this); private int _MyOwnerInfoUnique = OwnerInfoUnique;
} public int MyOwnerInfoUnique // Absolutely Unique ID - Info
private bool _Disposed = false; { get { return _MyOwnerInfoUnique; } }
private static int _CountCreated = 0; protected OwnerInfo()
private static int _CountDisposed = 0; {/* require use of factory methods */
private static int _CountFinalized = 0; AddToCache(this);
private static int IncrementCountCreated }
{ get { return ++_CountCreated; } } private bool _Disposed = false;
private int _CountWhenCreated = IncrementCountCreated; private static int _CountCreated = 0;
public static int CountCreated private static int _CountDisposed = 0;
{ get { return _CountCreated; } } private static int _CountFinalized = 0;
public static int CountNotDisposed private static int IncrementCountCreated
{ get { return _CountCreated - _CountDisposed; } } { get { return ++_CountCreated; } }
public static int CountNotFinalized private int _CountWhenCreated = IncrementCountCreated;
{ get { return _CountCreated - _CountFinalized; } } public static int CountCreated
~OwnerInfo() { get { return _CountCreated; } }
{ public static int CountNotDisposed
_CountFinalized++; { get { return _CountCreated - _CountDisposed; } }
} public static int CountNotFinalized
public void Dispose() { get { return _CountCreated - _CountFinalized; } }
{ ~OwnerInfo()
if (_Disposed) return; {
_CountDisposed++; _CountFinalized++;
_Disposed = true; }
RemoveFromCache(this); public void Dispose()
if (!_CacheByPrimaryKey.ContainsKey(OwnerID.ToString())) return; {
List<OwnerInfo> listOwnerInfo = _CacheByPrimaryKey[OwnerID.ToString()]; // Get the list of items if (_Disposed) return;
while (listOwnerInfo.Contains(this)) listOwnerInfo.Remove(this); // Remove the item from the list _CountDisposed++;
if (listOwnerInfo.Count == 0) // If there are no items left in the list _Disposed = true;
_CacheByPrimaryKey.Remove(OwnerID.ToString()); // remove the list RemoveFromCache(this);
} if (!_CacheByPrimaryKey.ContainsKey(OwnerID.ToString())) return;
public virtual Owner Get() List<OwnerInfo> listOwnerInfo = _CacheByPrimaryKey[OwnerID.ToString()]; // Get the list of items
{ while (listOwnerInfo.Contains(this)) listOwnerInfo.Remove(this); // Remove the item from the list
return _Editable = Owner.Get(_OwnerID); if (listOwnerInfo.Count == 0) // If there are no items left in the list
} _CacheByPrimaryKey.Remove(OwnerID.ToString()); // remove the list
public static void Refresh(Owner tmp) }
{ public virtual Owner Get()
string key = tmp.OwnerID.ToString(); {
ConvertListToDictionary(); return _Editable = Owner.Get(_OwnerID);
if (_CacheByPrimaryKey.ContainsKey(key)) }
foreach (OwnerInfo tmpInfo in _CacheByPrimaryKey[key]) public static void Refresh(Owner tmp)
tmpInfo.RefreshFields(tmp); {
} string key = tmp.OwnerID.ToString();
protected virtual void RefreshFields(Owner tmp) ConvertListToDictionary();
{ if (_CacheByPrimaryKey.ContainsKey(key))
_SessionID = tmp.SessionID; foreach (OwnerInfo tmpInfo in _CacheByPrimaryKey[key])
_OwnerType = tmp.OwnerType; tmpInfo.RefreshFields(tmp);
_OwnerItemID = tmp.OwnerItemID; }
_DTSStart = tmp.DTSStart; protected virtual void RefreshFields(Owner tmp)
_OwnerInfoExtension.Refresh(this); {
OnChange();// raise an event _SessionID = tmp.SessionID;
} _OwnerType = tmp.OwnerType;
public static OwnerInfo Get(int ownerID) _OwnerItemID = tmp.OwnerItemID;
{ _DTSStart = tmp.DTSStart;
//if (!CanGetObject()) _OwnerInfoExtension.Refresh(this);
// throw new System.Security.SecurityException("User not authorized to view a Owner"); OnChange();// raise an event
try }
{ public static OwnerInfo Get(int ownerID)
OwnerInfo tmp = GetCachedByPrimaryKey(ownerID); {
if (tmp == null) //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a Owner");
tmp = DataPortal.Fetch<OwnerInfo>(new PKCriteria(ownerID)); try
AddToCache(tmp); {
} OwnerInfo tmp = GetCachedByPrimaryKey(ownerID);
if (tmp.ErrorMessage == "No Record Found") if (tmp == null)
{ {
tmp.Dispose(); // Clean-up OwnerInfo tmp = DataPortal.Fetch<OwnerInfo>(new PKCriteria(ownerID));
tmp = null; AddToCache(tmp);
} }
return tmp; if (tmp.ErrorMessage == "No Record Found")
} {
catch (Exception ex) tmp.Dispose(); // Clean-up OwnerInfo
{ tmp = null;
throw new DbCslaException("Error on OwnerInfo.Get", ex); }
} return tmp;
} }
#endregion catch (Exception ex)
#region Data Access Portal {
internal OwnerInfo(SafeDataReader dr) throw new DbCslaException("Error on OwnerInfo.Get", ex);
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.Constructor", GetHashCode()); }
try #endregion
{ #region Data Access Portal
ReadData(dr); internal OwnerInfo(SafeDataReader dr)
} {
catch (Exception ex) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.Constructor", GetHashCode());
{ try
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.Constructor", ex); {
throw new DbCslaException("OwnerInfo.Constructor", ex); ReadData(dr);
} }
} catch (Exception ex)
[Serializable()] {
protected class PKCriteria if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.Constructor", ex);
{ throw new DbCslaException("OwnerInfo.Constructor", ex);
private int _OwnerID; }
public int OwnerID }
{ get { return _OwnerID; } } [Serializable()]
public PKCriteria(int ownerID) protected class PKCriteria
{ {
_OwnerID = ownerID; private int _OwnerID;
} public int OwnerID
} { get { return _OwnerID; } }
private void ReadData(SafeDataReader dr) public PKCriteria(int ownerID)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.ReadData", GetHashCode()); _OwnerID = ownerID;
try }
{ }
_OwnerID = dr.GetInt32("OwnerID"); private void ReadData(SafeDataReader dr)
_SessionID = dr.GetInt32("SessionID"); {
_OwnerType = dr.GetByte("OwnerType"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.ReadData", GetHashCode());
_OwnerItemID = dr.GetInt32("OwnerItemID"); try
_DTSStart = dr.GetDateTime("DTSStart"); {
} _OwnerID = dr.GetInt32("OwnerID");
catch (Exception ex) _SessionID = dr.GetInt32("SessionID");
{ _OwnerType = dr.GetByte("OwnerType");
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.ReadData", ex); _OwnerItemID = dr.GetInt32("OwnerItemID");
_ErrorMessage = ex.Message; _DTSStart = dr.GetDateTime("DTSStart");
throw new DbCslaException("OwnerInfo.ReadData", ex); }
} catch (Exception ex)
} {
private void DataPortal_Fetch(PKCriteria criteria) if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.DataPortal_Fetch", GetHashCode()); throw new DbCslaException("OwnerInfo.ReadData", ex);
try }
{ }
using (SqlConnection cn = Database.VEPROMS_SqlConnection) private void DataPortal_Fetch(PKCriteria criteria)
{ {
ApplicationContext.LocalContext["cn"] = cn; if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.DataPortal_Fetch", GetHashCode());
using (SqlCommand cm = cn.CreateCommand()) try
{ {
cm.CommandType = CommandType.StoredProcedure; using (SqlConnection cn = Database.VEPROMS_SqlConnection)
cm.CommandTimeout = Database.SQLTimeout; {
cm.CommandText = "getOwner"; ApplicationContext.LocalContext["cn"] = cn;
cm.Parameters.AddWithValue("@OwnerID", criteria.OwnerID); using (SqlCommand cm = cn.CreateCommand())
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) {
{ cm.CommandType = CommandType.StoredProcedure;
if (!dr.Read()) cm.CommandTimeout = Database.SQLTimeout;
{ cm.CommandText = "getOwner";
_ErrorMessage = "No Record Found"; cm.Parameters.AddWithValue("@OwnerID", criteria.OwnerID);
return; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
ReadData(dr); if (!dr.Read())
} {
} _ErrorMessage = "No Record Found";
// removing of item only needed for local data portal return;
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) }
ApplicationContext.LocalContext.Remove("cn"); ReadData(dr);
} }
} }
catch (Exception ex) // removing of item only needed for local data portal
{ if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.DataPortal_Fetch", ex); ApplicationContext.LocalContext.Remove("cn");
_ErrorMessage = ex.Message; }
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex); }
} catch (Exception ex)
} {
#endregion if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfo.DataPortal_Fetch", ex);
// Standard Refresh _ErrorMessage = ex.Message;
#region extension throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
OwnerInfoExtension _OwnerInfoExtension = new OwnerInfoExtension(); }
[Serializable()] }
partial class OwnerInfoExtension : extensionBase { } #endregion
[Serializable()] // Standard Refresh
class extensionBase #region extension
{ OwnerInfoExtension _OwnerInfoExtension = new OwnerInfoExtension();
// Default Refresh [Serializable()]
public virtual void Refresh(OwnerInfo tmp) { } partial class OwnerInfoExtension : extensionBase { }
} [Serializable()]
#endregion class extensionBase
} // Class {
#region Converter // Default Refresh
internal class OwnerInfoConverter : ExpandableObjectConverter public virtual void Refresh(OwnerInfo tmp) { }
{ }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) #endregion
{ } // Class
if (destType == typeof(string) && value is OwnerInfo) #region Converter
{ internal class OwnerInfoConverter : ExpandableObjectConverter
// Return the ToString value {
return ((OwnerInfo)value).ToString(); public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
return base.ConvertTo(context, culture, value, destType); if (destType == typeof(string) && value is OwnerInfo)
} {
} // Return the ToString value
#endregion return ((OwnerInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,354 +19,361 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void PartAuditInfoEvent(object sender); public delegate void PartAuditInfoEvent(object sender);
/// <summary> /// <summary>
/// PartAuditInfo Generated by MyGeneration using the CSLA Object Mapping template /// PartAuditInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(PartAuditInfoConverter))] [TypeConverter(typeof(PartAuditInfoConverter))]
public partial class PartAuditInfo : ReadOnlyBase<PartAuditInfo>, IDisposable public partial class PartAuditInfo : ReadOnlyBase<PartAuditInfo>, IDisposable
{ {
public event PartAuditInfoEvent Changed; public event PartAuditInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<PartAuditInfo> _CacheList = new List<PartAuditInfo>(); private static List<PartAuditInfo> _CacheList = new List<PartAuditInfo>();
protected static void AddToCache(PartAuditInfo partAuditInfo) protected static void AddToCache(PartAuditInfo partAuditInfo)
{ {
if (!_CacheList.Contains(partAuditInfo)) _CacheList.Add(partAuditInfo); // In AddToCache if (!_CacheList.Contains(partAuditInfo)) _CacheList.Add(partAuditInfo); // In AddToCache
} }
protected static void RemoveFromCache(PartAuditInfo partAuditInfo) protected static void RemoveFromCache(PartAuditInfo partAuditInfo)
{ {
while (_CacheList.Contains(partAuditInfo)) _CacheList.Remove(partAuditInfo); // In RemoveFromCache while (_CacheList.Contains(partAuditInfo)) _CacheList.Remove(partAuditInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<PartAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartAuditInfo>>(); private static Dictionary<string, List<PartAuditInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartAuditInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move PartAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move PartAuditInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
PartAuditInfo tmp = _CacheList[0]; // Get the first PartAuditInfo PartAuditInfo tmp = _CacheList[0]; // Get the first PartAuditInfo
string pKey = tmp.AuditID.ToString(); string pKey = tmp.AuditID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<PartAuditInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<PartAuditInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first PartAuditInfo _CacheList.RemoveAt(0); // Remove the first PartAuditInfo
} }
} }
internal static void AddList(PartAuditInfoList lst) internal static void AddList(PartAuditInfoList lst)
{ {
foreach (PartAuditInfo item in lst) AddToCache(item); foreach (PartAuditInfo item in lst) AddToCache(item);
} }
protected static PartAuditInfo GetCachedByPrimaryKey(long auditID) protected static PartAuditInfo GetCachedByPrimaryKey(long auditID)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = auditID.ToString(); string key = auditID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected PartAudit _Editable; protected PartAudit _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private long _AuditID; private long _AuditID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public long AuditID public long AuditID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _AuditID; CanReadProperty("AuditID", true);
} return _AuditID;
} }
private int _ContentID; }
public int ContentID private int _ContentID;
{ public int ContentID
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
return _ContentID; {
} CanReadProperty("ContentID", true);
} return _ContentID;
private int _FromType; }
public int FromType }
{ private int _FromType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int FromType
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _FromType; get
} {
} CanReadProperty("FromType", true);
private int _ItemID; return _FromType;
public int ItemID }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _ItemID;
get public int ItemID
{ {
return _ItemID; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private DateTime _DTS = new DateTime(); CanReadProperty("ItemID", true);
public DateTime DTS return _ItemID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private DateTime _DTS = new DateTime();
{ public DateTime DTS
return _DTS; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private string _UserID = string.Empty; {
public string UserID CanReadProperty("DTS", true);
{ return _DTS;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private string _UserID = string.Empty;
return _UserID; public string UserID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _DeleteStatus; get
public int DeleteStatus {
{ CanReadProperty("UserID", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] return _UserID;
get }
{ }
return _DeleteStatus; private int _DeleteStatus;
} public int DeleteStatus
} {
// CSLATODO: Replace base PartAuditInfo.ToString function as necessary [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <summary> get
/// Overrides Base ToString {
/// </summary> CanReadProperty("DeleteStatus", true);
/// <returns>A string representation of current PartAuditInfo</returns> return _DeleteStatus;
//public override string ToString() }
//{ }
// return base.ToString(); // CSLATODO: Replace base PartAuditInfo.ToString function as necessary
//} /// <summary>
// CSLATODO: Check PartAuditInfo.GetIdValue to assure that the ID returned is unique /// Overrides Base ToString
/// <summary> /// </summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// <returns>A string representation of current PartAuditInfo</returns>
/// </summary> //public override string ToString()
/// <returns>A Unique ID for the current PartAuditInfo</returns> //{
protected override object GetIdValue() // return base.ToString();
{ //}
return MyPartAuditInfoUnique; // Absolutely Unique ID // CSLATODO: Check PartAuditInfo.GetIdValue to assure that the ID returned is unique
} /// <summary>
#endregion /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
#region Factory Methods /// </summary>
private static int _PartAuditInfoUnique = 0; /// <returns>A Unique ID for the current PartAuditInfo</returns>
private static int PartAuditInfoUnique protected override object GetIdValue()
{ get { return ++_PartAuditInfoUnique; } } {
private int _MyPartAuditInfoUnique = PartAuditInfoUnique; return MyPartAuditInfoUnique; // Absolutely Unique ID
public int MyPartAuditInfoUnique // Absolutely Unique ID - Info }
{ get { return _MyPartAuditInfoUnique; } } #endregion
protected PartAuditInfo() #region Factory Methods
{/* require use of factory methods */ private static int _PartAuditInfoUnique = 0;
AddToCache(this); private static int PartAuditInfoUnique
} { get { return ++_PartAuditInfoUnique; } }
private bool _Disposed = false; private int _MyPartAuditInfoUnique = PartAuditInfoUnique;
private static int _CountCreated = 0; public int MyPartAuditInfoUnique // Absolutely Unique ID - Info
private static int _CountDisposed = 0; { get { return _MyPartAuditInfoUnique; } }
private static int _CountFinalized = 0; protected PartAuditInfo()
private static int IncrementCountCreated {/* require use of factory methods */
{ get { return ++_CountCreated; } } AddToCache(this);
private int _CountWhenCreated = IncrementCountCreated; }
public static int CountCreated private bool _Disposed = false;
{ get { return _CountCreated; } } private static int _CountCreated = 0;
public static int CountNotDisposed private static int _CountDisposed = 0;
{ get { return _CountCreated - _CountDisposed; } } private static int _CountFinalized = 0;
public static int CountNotFinalized private static int IncrementCountCreated
{ get { return _CountCreated - _CountFinalized; } } { get { return ++_CountCreated; } }
~PartAuditInfo() private int _CountWhenCreated = IncrementCountCreated;
{ public static int CountCreated
_CountFinalized++; { get { return _CountCreated; } }
} public static int CountNotDisposed
public void Dispose() { get { return _CountCreated - _CountDisposed; } }
{ public static int CountNotFinalized
if (_Disposed) return; { get { return _CountCreated - _CountFinalized; } }
_CountDisposed++; ~PartAuditInfo()
_Disposed = true; {
RemoveFromCache(this); _CountFinalized++;
if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return; }
List<PartAuditInfo> listPartAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items public void Dispose()
while (listPartAuditInfo.Contains(this)) listPartAuditInfo.Remove(this); // Remove the item from the list {
if (listPartAuditInfo.Count == 0) // If there are no items left in the list if (_Disposed) return;
_CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list _CountDisposed++;
} _Disposed = true;
public virtual PartAudit Get() RemoveFromCache(this);
{ if (!_CacheByPrimaryKey.ContainsKey(AuditID.ToString())) return;
return _Editable = PartAudit.Get(_AuditID); List<PartAuditInfo> listPartAuditInfo = _CacheByPrimaryKey[AuditID.ToString()]; // Get the list of items
} while (listPartAuditInfo.Contains(this)) listPartAuditInfo.Remove(this); // Remove the item from the list
public static void Refresh(PartAudit tmp) if (listPartAuditInfo.Count == 0) // If there are no items left in the list
{ _CacheByPrimaryKey.Remove(AuditID.ToString()); // remove the list
string key = tmp.AuditID.ToString(); }
ConvertListToDictionary(); public virtual PartAudit Get()
if (_CacheByPrimaryKey.ContainsKey(key)) {
foreach (PartAuditInfo tmpInfo in _CacheByPrimaryKey[key]) return _Editable = PartAudit.Get(_AuditID);
tmpInfo.RefreshFields(tmp); }
} public static void Refresh(PartAudit tmp)
protected virtual void RefreshFields(PartAudit tmp) {
{ string key = tmp.AuditID.ToString();
_ContentID = tmp.ContentID; ConvertListToDictionary();
_FromType = tmp.FromType; if (_CacheByPrimaryKey.ContainsKey(key))
_ItemID = tmp.ItemID; foreach (PartAuditInfo tmpInfo in _CacheByPrimaryKey[key])
_DTS = tmp.DTS; tmpInfo.RefreshFields(tmp);
_UserID = tmp.UserID; }
_DeleteStatus = tmp.DeleteStatus; protected virtual void RefreshFields(PartAudit tmp)
_PartAuditInfoExtension.Refresh(this); {
OnChange();// raise an event _ContentID = tmp.ContentID;
} _FromType = tmp.FromType;
public static PartAuditInfo Get(long auditID) _ItemID = tmp.ItemID;
{ _DTS = tmp.DTS;
//if (!CanGetObject()) _UserID = tmp.UserID;
// throw new System.Security.SecurityException("User not authorized to view a PartAudit"); _DeleteStatus = tmp.DeleteStatus;
try _PartAuditInfoExtension.Refresh(this);
{ OnChange();// raise an event
PartAuditInfo tmp = GetCachedByPrimaryKey(auditID); }
if (tmp == null) public static PartAuditInfo Get(long auditID)
{ {
tmp = DataPortal.Fetch<PartAuditInfo>(new PKCriteria(auditID)); //if (!CanGetObject())
AddToCache(tmp); // throw new System.Security.SecurityException("User not authorized to view a PartAudit");
} try
if (tmp.ErrorMessage == "No Record Found") {
{ PartAuditInfo tmp = GetCachedByPrimaryKey(auditID);
tmp.Dispose(); // Clean-up PartAuditInfo if (tmp == null)
tmp = null; {
} tmp = DataPortal.Fetch<PartAuditInfo>(new PKCriteria(auditID));
return tmp; AddToCache(tmp);
} }
catch (Exception ex) if (tmp.ErrorMessage == "No Record Found")
{ {
throw new DbCslaException("Error on PartAuditInfo.Get", ex); tmp.Dispose(); // Clean-up PartAuditInfo
} tmp = null;
} }
#endregion return tmp;
#region Data Access Portal }
internal PartAuditInfo(SafeDataReader dr) catch (Exception ex)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.Constructor", GetHashCode()); throw new DbCslaException("Error on PartAuditInfo.Get", ex);
try }
{ }
ReadData(dr); #endregion
} #region Data Access Portal
catch (Exception ex) internal PartAuditInfo(SafeDataReader dr)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.Constructor", ex); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.Constructor", GetHashCode());
throw new DbCslaException("PartAuditInfo.Constructor", ex); try
} {
} ReadData(dr);
[Serializable()] }
protected class PKCriteria catch (Exception ex)
{ {
private long _AuditID; if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.Constructor", ex);
public long AuditID throw new DbCslaException("PartAuditInfo.Constructor", ex);
{ get { return _AuditID; } } }
public PKCriteria(long auditID) }
{ [Serializable()]
_AuditID = auditID; protected class PKCriteria
} {
} private long _AuditID;
private void ReadData(SafeDataReader dr) public long AuditID
{ { get { return _AuditID; } }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.ReadData", GetHashCode()); public PKCriteria(long auditID)
try {
{ _AuditID = auditID;
_AuditID = dr.GetInt64("AuditID"); }
_ContentID = dr.GetInt32("ContentID"); }
_FromType = dr.GetInt32("FromType"); private void ReadData(SafeDataReader dr)
_ItemID = dr.GetInt32("ItemID"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
_DeleteStatus = dr.GetInt32("DeleteStatus"); {
} _AuditID = dr.GetInt64("AuditID");
catch (Exception ex) _ContentID = dr.GetInt32("ContentID");
{ _FromType = dr.GetInt32("FromType");
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.ReadData", ex); _ItemID = dr.GetInt32("ItemID");
_ErrorMessage = ex.Message; _DTS = dr.GetDateTime("DTS");
throw new DbCslaException("PartAuditInfo.ReadData", ex); _UserID = dr.GetString("UserID");
} _DeleteStatus = dr.GetInt32("DeleteStatus");
} }
private void DataPortal_Fetch(PKCriteria criteria) catch (Exception ex)
{ {
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.ReadData", ex);
try _ErrorMessage = ex.Message;
{ throw new DbCslaException("PartAuditInfo.ReadData", ex);
using (SqlConnection cn = Database.VEPROMS_SqlConnection) }
{ }
ApplicationContext.LocalContext["cn"] = cn; private void DataPortal_Fetch(PKCriteria criteria)
using (SqlCommand cm = cn.CreateCommand()) {
{ if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartAuditInfo.DataPortal_Fetch", GetHashCode());
cm.CommandType = CommandType.StoredProcedure; try
cm.CommandText = "getPartAudit"; {
cm.Parameters.AddWithValue("@AuditID", criteria.AuditID); using (SqlConnection cn = Database.VEPROMS_SqlConnection)
cm.CommandTimeout = Database.DefaultTimeout; {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
if (!dr.Read()) {
{ cm.CommandType = CommandType.StoredProcedure;
_ErrorMessage = "No Record Found"; cm.CommandText = "getPartAudit";
return; cm.Parameters.AddWithValue("@AuditID", criteria.AuditID);
} cm.CommandTimeout = Database.DefaultTimeout;
ReadData(dr); using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
} {
} if (!dr.Read())
// removing of item only needed for local data portal {
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) _ErrorMessage = "No Record Found";
ApplicationContext.LocalContext.Remove("cn"); return;
} }
} ReadData(dr);
catch (Exception ex) }
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.DataPortal_Fetch", ex); // removing of item only needed for local data portal
_ErrorMessage = ex.Message; if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
throw new DbCslaException("PartAuditInfo.DataPortal_Fetch", ex); ApplicationContext.LocalContext.Remove("cn");
} }
} }
#endregion catch (Exception ex)
// Standard Refresh {
#region extension if (_MyLog.IsErrorEnabled) _MyLog.Error("PartAuditInfo.DataPortal_Fetch", ex);
PartAuditInfoExtension _PartAuditInfoExtension = new PartAuditInfoExtension(); _ErrorMessage = ex.Message;
[Serializable()] throw new DbCslaException("PartAuditInfo.DataPortal_Fetch", ex);
partial class PartAuditInfoExtension : extensionBase { } }
[Serializable()] }
class extensionBase #endregion
{ // Standard Refresh
// Default Refresh #region extension
public virtual void Refresh(PartAuditInfo tmp) { } PartAuditInfoExtension _PartAuditInfoExtension = new PartAuditInfoExtension();
} [Serializable()]
#endregion partial class PartAuditInfoExtension : extensionBase { }
} // Class [Serializable()]
#region Converter class extensionBase
internal class PartAuditInfoConverter : ExpandableObjectConverter {
{ // Default Refresh
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public virtual void Refresh(PartAuditInfo tmp) { }
{ }
if (destType == typeof(string) && value is PartAuditInfo) #endregion
{ } // Class
// Return the ToString value #region Converter
return ((PartAuditInfo)value).ToString(); internal class PartAuditInfoConverter : ExpandableObjectConverter
} {
return base.ConvertTo(context, culture, value, destType); public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
} {
} if (destType == typeof(string) && value is PartAuditInfo)
#endregion {
// Return the ToString value
return ((PartAuditInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

View File

@ -19,412 +19,410 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void PartInfoEvent(object sender); public delegate void PartInfoEvent(object sender);
/// <summary> /// <summary>
/// PartInfo Generated by MyGeneration using the CSLA Object Mapping template /// PartInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(PartInfoConverter))] [TypeConverter(typeof(PartInfoConverter))]
public partial class PartInfo : ReadOnlyBase<PartInfo>, IDisposable public partial class PartInfo : ReadOnlyBase<PartInfo>, IDisposable
{ {
public event PartInfoEvent Changed; public event PartInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<PartInfo> _CacheList = new List<PartInfo>(); private static List<PartInfo> _CacheList = new List<PartInfo>();
protected static void AddToCache(PartInfo partInfo) protected static void AddToCache(PartInfo partInfo)
{ {
if (!_CacheList.Contains(partInfo)) _CacheList.Add(partInfo); // In AddToCache if (!_CacheList.Contains(partInfo)) _CacheList.Add(partInfo); // In AddToCache
} }
protected static void RemoveFromCache(PartInfo partInfo) protected static void RemoveFromCache(PartInfo partInfo)
{ {
while (_CacheList.Contains(partInfo)) _CacheList.Remove(partInfo); // In RemoveFromCache while (_CacheList.Contains(partInfo)) _CacheList.Remove(partInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>(); private static Dictionary<string, List<PartInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PartInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move PartInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move PartInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
PartInfo tmp = _CacheList[0]; // Get the first PartInfo PartInfo tmp = _CacheList[0]; // Get the first PartInfo
string pKey = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString(); string pKey = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<PartInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<PartInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first PartInfo _CacheList.RemoveAt(0); // Remove the first PartInfo
} }
} }
internal static void AddList(PartInfoList lst) internal static void AddList(PartInfoList lst)
{ {
foreach (PartInfo item in lst) AddToCache(item); foreach (PartInfo item in lst) AddToCache(item);
} }
protected static PartInfo GetCachedByPrimaryKey(int contentID, int fromType) protected static PartInfo GetCachedByPrimaryKey(int contentID, int fromType)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = contentID.ToString() + "_" + fromType.ToString(); string key = contentID.ToString() + "_" + fromType.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
public static void ClearPartInfoCache() #endregion
{ #region Business Methods
_CacheByPrimaryKey.Clear(); private string _ErrorMessage = string.Empty;
while (_CacheList.Count > 0) public string ErrorMessage
{ _CacheList[0].Dispose(); } {
get { return _ErrorMessage; }
} }
#endregion protected Part _Editable;
#region Business Methods private IVEHasBrokenRules HasBrokenRules
private string _ErrorMessage = string.Empty; {
public string ErrorMessage get
{ {
get { return _ErrorMessage; } IVEHasBrokenRules hasBrokenRules = null;
} if (_Editable != null)
protected Part _Editable; hasBrokenRules = _Editable.HasBrokenRules;
private IVEHasBrokenRules HasBrokenRules return hasBrokenRules;
{ }
get }
{ private int _ContentID;
IVEHasBrokenRules hasBrokenRules = null; [System.ComponentModel.DataObjectField(true, true)]
if (_Editable != null) public int ContentID
hasBrokenRules = _Editable.HasBrokenRules; {
return hasBrokenRules; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private int _ContentID; CanReadProperty("ContentID", true);
[System.ComponentModel.DataObjectField(true, true)] if (_MyContent != null) _ContentID = _MyContent.ContentID;
public int ContentID return _ContentID;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private ContentInfo _MyContent;
{ [System.ComponentModel.DataObjectField(true, true)]
if (_MyContent != null) _ContentID = _MyContent.ContentID; public ContentInfo MyContent
return _ContentID; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private ContentInfo _MyContent; {
[System.ComponentModel.DataObjectField(true, true)] CanReadProperty("MyContent", true);
public ContentInfo MyContent if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID);
{ return _MyContent;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int _FromType;
if (_MyContent == null && _ContentID != 0) _MyContent = ContentInfo.Get(_ContentID); [System.ComponentModel.DataObjectField(true, true)]
return _MyContent; public int FromType
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _FromType; get
[System.ComponentModel.DataObjectField(true, true)] {
public int FromType CanReadProperty("FromType", true);
{ return _FromType;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int _ItemID;
return _FromType; public int ItemID
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _ItemID; get
public int ItemID {
{ CanReadProperty("ItemID", true);
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] if (_MyItem != null) _ItemID = _MyItem.ItemID;
get return _ItemID;
{ }
if (_MyItem != null) _ItemID = _MyItem.ItemID; }
return _ItemID; private ItemInfo _MyItem;
} public ItemInfo MyItem
} {
private ItemInfo _MyItem; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
public ItemInfo MyItem get
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] CanReadProperty("MyItem", true);
get if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID);
{ return _MyItem;
if (_MyItem == null && _ItemID != 0) _MyItem = ItemInfo.Get(_ItemID); }
return _MyItem; }
} private DateTime _DTS = new DateTime();
} public DateTime DTS
private DateTime _DTS = new DateTime(); {
public DateTime DTS [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("DTS", true);
{ return _DTS;
return _DTS; }
} }
} private string _UserID = string.Empty;
private string _UserID = string.Empty; public string UserID
public string UserID {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("UserID", true);
return _UserID; return _UserID;
} }
} }
// CSLATODO: Replace base PartInfo.ToString function as necessary // CSLATODO: Replace base PartInfo.ToString function as necessary
/// <summary> /// <summary>
/// Overrides Base ToString /// Overrides Base ToString
/// </summary> /// </summary>
/// <returns>A string representation of current PartInfo</returns> /// <returns>A string representation of current PartInfo</returns>
//public override string ToString() //public override string ToString()
//{ //{
// return base.ToString(); // return base.ToString();
//} //}
// CSLATODO: Check PartInfo.GetIdValue to assure that the ID returned is unique // CSLATODO: Check PartInfo.GetIdValue to assure that the ID returned is unique
/// <summary> /// <summary>
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
/// </summary> /// </summary>
/// <returns>A Unique ID for the current PartInfo</returns> /// <returns>A Unique ID for the current PartInfo</returns>
protected override object GetIdValue() protected override object GetIdValue()
{ {
return MyPartInfoUnique; // Absolutely Unique ID return MyPartInfoUnique; // Absolutely Unique ID
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
private static int _PartInfoUnique = 0; private static int _PartInfoUnique = 0;
private static int PartInfoUnique private static int PartInfoUnique
{ get { return ++_PartInfoUnique; } } { get { return ++_PartInfoUnique; } }
private int _MyPartInfoUnique = PartInfoUnique; private int _MyPartInfoUnique = PartInfoUnique;
public int MyPartInfoUnique // Absolutely Unique ID - Info public int MyPartInfoUnique // Absolutely Unique ID - Info
{ get { return _MyPartInfoUnique; } } { get { return _MyPartInfoUnique; } }
protected PartInfo() protected PartInfo()
{/* require use of factory methods */ {/* require use of factory methods */
AddToCache(this); AddToCache(this);
} }
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~PartInfo() ~PartInfo()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++; _CountDisposed++;
_Disposed = true; _Disposed = true;
Changed = null; RemoveFromCache(this);
_MyItems?.Dispose(); if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return;
RemoveFromCache(this); List<PartInfo> listPartInfo = _CacheByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items
if (!_CacheByPrimaryKey.ContainsKey(ContentID.ToString() + "_" + FromType.ToString())) return; while (listPartInfo.Contains(this)) listPartInfo.Remove(this); // Remove the item from the list
List<PartInfo> listPartInfo = _CacheByPrimaryKey[ContentID.ToString() + "_" + FromType.ToString()]; // Get the list of items if (listPartInfo.Count == 0) // If there are no items left in the list
while (listPartInfo.Contains(this)) listPartInfo.Remove(this); // Remove the item from the list _CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list
if (listPartInfo.Count == 0) // If there are no items left in the list }
_CacheByPrimaryKey.Remove(ContentID.ToString() + "_" + FromType.ToString()); // remove the list public virtual Part Get()
} {
public virtual Part Get() return _Editable = Part.Get(_ContentID, _FromType);
{ }
return _Editable = Part.Get(_ContentID, _FromType); public static void Refresh(Part tmp)
} {
public static void Refresh(Part tmp) string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
{ ConvertListToDictionary();
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString(); if (_CacheByPrimaryKey.ContainsKey(key))
ConvertListToDictionary(); foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key)) tmpInfo.RefreshFields(tmp);
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); protected virtual void RefreshFields(Part tmp)
} {
protected virtual void RefreshFields(Part tmp) if (_ItemID != tmp.ItemID)
{ {
if (_ItemID != tmp.ItemID) if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
{ _ItemID = tmp.ItemID; // Update the value
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value }
_ItemID = tmp.ItemID; // Update the value _MyItem = null; // Reset list so that the next line gets a new list
} if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_MyItem = null; // Reset list so that the next line gets a new list _DTS = tmp.DTS;
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value _UserID = tmp.UserID;
_DTS = tmp.DTS; _PartInfoExtension.Refresh(this);
_UserID = tmp.UserID; OnChange();// raise an event
_PartInfoExtension.Refresh(this); }
OnChange();// raise an event public static void Refresh(Content myContent, ContentPart tmp)
} {
public static void Refresh(Content myContent, ContentPart tmp) string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString();
{ ConvertListToDictionary();
string key = myContent.ContentID.ToString() + "_" + tmp.FromType.ToString(); if (_CacheByPrimaryKey.ContainsKey(key))
ConvertListToDictionary(); foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key)) tmpInfo.RefreshFields(tmp);
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); protected virtual void RefreshFields(ContentPart tmp)
} {
protected virtual void RefreshFields(ContentPart tmp) if (_ItemID != tmp.ItemID)
{ {
if (_ItemID != tmp.ItemID) if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value
{ _ItemID = tmp.ItemID; // Update the value
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for old value }
_ItemID = tmp.ItemID; // Update the value _MyItem = null; // Reset list so that the next line gets a new list
} if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value
_MyItem = null; // Reset list so that the next line gets a new list _DTS = tmp.DTS;
if (MyItem != null) MyItem.RefreshItemParts(); // Update List for new value _UserID = tmp.UserID;
_DTS = tmp.DTS; _PartInfoExtension.Refresh(this);
_UserID = tmp.UserID; OnChange();// raise an event
_PartInfoExtension.Refresh(this); }
OnChange();// raise an event public static void Refresh(ItemPart tmp)
} {
public static void Refresh(ItemPart tmp) string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString();
{ ConvertListToDictionary();
string key = tmp.ContentID.ToString() + "_" + tmp.FromType.ToString(); if (_CacheByPrimaryKey.ContainsKey(key))
ConvertListToDictionary(); foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key])
if (_CacheByPrimaryKey.ContainsKey(key)) tmpInfo.RefreshFields(tmp);
foreach (PartInfo tmpInfo in _CacheByPrimaryKey[key]) }
tmpInfo.RefreshFields(tmp); protected virtual void RefreshFields(ItemPart tmp)
} {
protected virtual void RefreshFields(ItemPart tmp) _DTS = tmp.DTS;
{ _UserID = tmp.UserID;
_DTS = tmp.DTS; _PartInfoExtension.Refresh(this);
_UserID = tmp.UserID; OnChange();// raise an event
_PartInfoExtension.Refresh(this); }
OnChange();// raise an event public static PartInfo Get(int contentID, int fromType)
} {
public static PartInfo Get(int contentID, int fromType) //if (!CanGetObject())
{ // throw new System.Security.SecurityException("User not authorized to view a Part");
//if (!CanGetObject()) try
// throw new System.Security.SecurityException("User not authorized to view a Part"); {
try PartInfo tmp = GetCachedByPrimaryKey(contentID, fromType);
{ if (tmp == null)
PartInfo tmp = GetCachedByPrimaryKey(contentID, fromType); {
if (tmp == null) tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType));
{ AddToCache(tmp);
tmp = DataPortal.Fetch<PartInfo>(new PKCriteria(contentID, fromType)); }
AddToCache(tmp); if (tmp.ErrorMessage == "No Record Found")
} {
if (tmp.ErrorMessage == "No Record Found") tmp.Dispose(); // Clean-up PartInfo
{ tmp = null;
tmp.Dispose(); // Clean-up PartInfo }
tmp = null; return tmp;
} }
return tmp; catch (Exception ex)
} {
catch (Exception ex) throw new DbCslaException("Error on PartInfo.Get", ex);
{ }
throw new DbCslaException("Error on PartInfo.Get", ex); }
} #endregion
} #region Data Access Portal
#endregion internal PartInfo(SafeDataReader dr)
#region Data Access Portal {
internal PartInfo(SafeDataReader dr) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode());
{ try
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.Constructor", GetHashCode()); {
try ReadData(dr);
{ }
ReadData(dr); catch (Exception ex)
} {
catch (Exception ex) if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex);
{ throw new DbCslaException("PartInfo.Constructor", ex);
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.Constructor", ex); }
throw new DbCslaException("PartInfo.Constructor", ex); }
} [Serializable()]
} protected class PKCriteria
[Serializable()] {
protected class PKCriteria private int _ContentID;
{ public int ContentID
private int _ContentID; { get { return _ContentID; } }
public int ContentID private int _FromType;
{ get { return _ContentID; } } public int FromType
private int _FromType; { get { return _FromType; } }
public int FromType public PKCriteria(int contentID, int fromType)
{ get { return _FromType; } } {
public PKCriteria(int contentID, int fromType) _ContentID = contentID;
{ _FromType = fromType;
_ContentID = contentID; }
_FromType = fromType; }
} private void ReadData(SafeDataReader dr)
} {
private void ReadData(SafeDataReader dr) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode());
{ try
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.ReadData", GetHashCode()); {
try _ContentID = dr.GetInt32("ContentID");
{ _FromType = dr.GetInt32("FromType");
_ContentID = dr.GetInt32("ContentID"); _ItemID = dr.GetInt32("ItemID");
_FromType = dr.GetInt32("FromType"); _DTS = dr.GetDateTime("DTS");
_ItemID = dr.GetInt32("ItemID"); _UserID = dr.GetString("UserID");
_DTS = dr.GetDateTime("DTS"); }
_UserID = dr.GetString("UserID"); catch (Exception ex)
} {
catch (Exception ex) if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex);
{ _ErrorMessage = ex.Message;
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.ReadData", ex); throw new DbCslaException("PartInfo.ReadData", ex);
_ErrorMessage = ex.Message; }
throw new DbCslaException("PartInfo.ReadData", ex); }
} private void DataPortal_Fetch(PKCriteria criteria)
} {
private void DataPortal_Fetch(PKCriteria criteria) if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.DataPortal_Fetch", GetHashCode());
{ try
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfo.DataPortal_Fetch", GetHashCode()); {
try using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) ApplicationContext.LocalContext["cn"] = cn;
{ using (SqlCommand cm = cn.CreateCommand())
ApplicationContext.LocalContext["cn"] = cn; {
using (SqlCommand cm = cn.CreateCommand()) cm.CommandType = CommandType.StoredProcedure;
{ cm.CommandText = "getPart";
cm.CommandType = CommandType.StoredProcedure; cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.CommandText = "getPart"; cm.Parameters.AddWithValue("@FromType", criteria.FromType);
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.CommandTimeout = Database.DefaultTimeout;
cm.Parameters.AddWithValue("@FromType", criteria.FromType); using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
cm.CommandTimeout = Database.DefaultTimeout; {
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) if (!dr.Read())
{ {
if (!dr.Read()) _ErrorMessage = "No Record Found";
{ return;
_ErrorMessage = "No Record Found"; }
return; ReadData(dr);
} }
ReadData(dr); }
} // removing of item only needed for local data portal
} if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
// removing of item only needed for local data portal ApplicationContext.LocalContext.Remove("cn");
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) }
ApplicationContext.LocalContext.Remove("cn"); }
} catch (Exception ex)
} {
catch (Exception ex) if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.DataPortal_Fetch", ex);
{ _ErrorMessage = ex.Message;
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfo.DataPortal_Fetch", ex); throw new DbCslaException("PartInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message; }
throw new DbCslaException("PartInfo.DataPortal_Fetch", ex); }
} #endregion
} // Standard Refresh
#endregion #region extension
// Standard Refresh PartInfoExtension _PartInfoExtension = new PartInfoExtension();
#region extension [Serializable()]
PartInfoExtension _PartInfoExtension = new PartInfoExtension(); partial class PartInfoExtension : extensionBase { }
[Serializable()] [Serializable()]
partial class PartInfoExtension : extensionBase { } class extensionBase
[Serializable()] {
class extensionBase // Default Refresh
{ public virtual void Refresh(PartInfo tmp) { }
// Default Refresh }
public virtual void Refresh(PartInfo tmp) { } #endregion
} } // Class
#endregion #region Converter
} // Class internal class PartInfoConverter : ExpandableObjectConverter
#region Converter {
internal class PartInfoConverter : ExpandableObjectConverter public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) if (destType == typeof(string) && value is PartInfo)
{ {
if (destType == typeof(string) && value is PartInfo) // Return the ToString value
{ return ((PartInfo)value).ToString();
// Return the ToString value }
return ((PartInfo)value).ToString(); return base.ConvertTo(context, culture, value, destType);
} }
return base.ConvertTo(context, culture, value, destType); }
} #endregion
}
#endregion
} // Namespace } // Namespace

View File

@ -19,324 +19,324 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
/// <summary> /// <summary>
/// PartInfoList Generated by MyGeneration using the CSLA Object Mapping template /// PartInfoList Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(PartInfoListConverter))] [TypeConverter(typeof(PartInfoListConverter))]
public partial class PartInfoList : ReadOnlyListBase<PartInfoList, PartInfo>, ICustomTypeDescriptor, IDisposable public partial class PartInfoList : ReadOnlyListBase<PartInfoList, PartInfo>, ICustomTypeDescriptor, IDisposable
{ {
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Business Methods #region Business Methods
internal new IList<PartInfo> Items internal new IList<PartInfo> Items
{ get { return base.Items; } } { get { return base.Items; } }
public void AddEvents() public void AddEvents()
{ {
foreach (PartInfo tmp in this) foreach (PartInfo tmp in this)
{ {
tmp.Changed += new PartInfoEvent(tmp_Changed); tmp.Changed += new PartInfoEvent(tmp_Changed);
} }
} }
void tmp_Changed(object sender) void tmp_Changed(object sender)
{ {
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
{ {
if (base[i] == sender) if (base[i] == sender)
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i)); this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i));
} }
} }
private bool _Disposed = false; private bool _Disposed = false;
private static int _CountCreated = 0; private static int _CountCreated = 0;
private static int _CountDisposed = 0; private static int _CountDisposed = 0;
private static int _CountFinalized = 0; private static int _CountFinalized = 0;
private static int IncrementCountCreated private static int IncrementCountCreated
{ get { return ++_CountCreated; } } { get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated; private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated public static int CountCreated
{ get { return _CountCreated; } } { get { return _CountCreated; } }
public static int CountNotDisposed public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } } { get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } } { get { return _CountCreated - _CountFinalized; } }
~PartInfoList() ~PartInfoList()
{ {
_CountFinalized++; _CountFinalized++;
} }
public void Dispose() public void Dispose()
{ {
if (_Disposed) return; if (_Disposed) return;
_CountDisposed++; _CountDisposed++;
_Disposed = true; _Disposed = true;
foreach (PartInfo tmp in this) foreach (PartInfo tmp in this)
{ {
tmp.Changed -= tmp_Changed; tmp.Changed -= new PartInfoEvent(tmp_Changed);
} }
} }
#endregion #endregion
#region Factory Methods #region Factory Methods
public static PartInfoList _PartInfoList = null; public static PartInfoList _PartInfoList = null;
/// <summary> /// <summary>
/// Return a list of all PartInfo. /// Return a list of all PartInfo.
/// </summary> /// </summary>
public static PartInfoList Get() public static PartInfoList Get()
{ {
try try
{ {
if (_PartInfoList != null) if (_PartInfoList != null)
return _PartInfoList; return _PartInfoList;
PartInfoList tmp = DataPortal.Fetch<PartInfoList>(); PartInfoList tmp = DataPortal.Fetch<PartInfoList>();
PartInfo.AddList(tmp); PartInfo.AddList(tmp);
tmp.AddEvents(); tmp.AddEvents();
_PartInfoList = tmp; _PartInfoList = tmp;
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on PartInfoList.Get", ex); throw new DbCslaException("Error on PartInfoList.Get", ex);
} }
} }
/// <summary> /// <summary>
/// Reset the list of all PartInfo. /// Reset the list of all PartInfo.
/// </summary> /// </summary>
public static void Reset() public static void Reset()
{ {
_PartInfoList = null; _PartInfoList = null;
} }
// CSLATODO: Add alternative gets - // CSLATODO: Add alternative gets -
//public static PartInfoList Get(<criteria>) //public static PartInfoList Get(<criteria>)
//{ //{
// try // try
// { // {
// return DataPortal.Fetch<PartInfoList>(new FilteredCriteria(<criteria>)); // return DataPortal.Fetch<PartInfoList>(new FilteredCriteria(<criteria>));
// } // }
// catch (Exception ex) // catch (Exception ex)
// { // {
// throw new DbCslaException("Error on PartInfoList.Get", ex); // throw new DbCslaException("Error on PartInfoList.Get", ex);
// } // }
//} //}
public static PartInfoList GetByContentID(int contentID) public static PartInfoList GetByContentID(int contentID)
{ {
try try
{ {
PartInfoList tmp = DataPortal.Fetch<PartInfoList>(new ContentIDCriteria(contentID)); PartInfoList tmp = DataPortal.Fetch<PartInfoList>(new ContentIDCriteria(contentID));
PartInfo.AddList(tmp); PartInfo.AddList(tmp);
tmp.AddEvents(); tmp.AddEvents();
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on PartInfoList.GetByContentID", ex); throw new DbCslaException("Error on PartInfoList.GetByContentID", ex);
} }
} }
public static PartInfoList GetByItemID(int itemID) public static PartInfoList GetByItemID(int itemID)
{ {
try try
{ {
PartInfoList tmp = DataPortal.Fetch<PartInfoList>(new ItemIDCriteria(itemID)); PartInfoList tmp = DataPortal.Fetch<PartInfoList>(new ItemIDCriteria(itemID));
PartInfo.AddList(tmp); PartInfo.AddList(tmp);
tmp.AddEvents(); tmp.AddEvents();
return tmp; return tmp;
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new DbCslaException("Error on PartInfoList.GetByItemID", ex); throw new DbCslaException("Error on PartInfoList.GetByItemID", ex);
} }
} }
private PartInfoList() private PartInfoList()
{ /* require use of factory methods */ } { /* require use of factory methods */ }
#endregion #endregion
#region Data Access Portal #region Data Access Portal
private void DataPortal_Fetch() private void DataPortal_Fetch()
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_Fetch", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_Fetch", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
cm.CommandType = CommandType.StoredProcedure; cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getParts"; cm.CommandText = "getParts";
cm.CommandTimeout = Database.DefaultTimeout; cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
IsReadOnly = false; IsReadOnly = false;
while (dr.Read()) this.Add(new PartInfo(dr)); while (dr.Read()) this.Add(new PartInfo(dr));
IsReadOnly = true; IsReadOnly = true;
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_Fetch", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
} }
[Serializable()] [Serializable()]
private class ContentIDCriteria private class ContentIDCriteria
{ {
public ContentIDCriteria(int contentID) public ContentIDCriteria(int contentID)
{ {
_ContentID = contentID; _ContentID = contentID;
} }
private int _ContentID; private int _ContentID;
public int ContentID public int ContentID
{ {
get { return _ContentID; } get { return _ContentID; }
set { _ContentID = value; } set { _ContentID = value; }
} }
} }
private void DataPortal_Fetch(ContentIDCriteria criteria) private void DataPortal_Fetch(ContentIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchContentID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchContentID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
cm.CommandType = CommandType.StoredProcedure; cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPartsByContentID"; cm.CommandText = "getPartsByContentID";
cm.Parameters.AddWithValue("@ContentID", criteria.ContentID); cm.Parameters.AddWithValue("@ContentID", criteria.ContentID);
cm.CommandTimeout = Database.DefaultTimeout; cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
IsReadOnly = false; IsReadOnly = false;
while (dr.Read()) this.Add(new PartInfo(dr)); while (dr.Read()) this.Add(new PartInfo(dr));
IsReadOnly = true; IsReadOnly = true;
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_FetchContentID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_FetchContentID", ex);
throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
} }
[Serializable()] [Serializable()]
private class ItemIDCriteria private class ItemIDCriteria
{ {
public ItemIDCriteria(int itemID) public ItemIDCriteria(int itemID)
{ {
_ItemID = itemID; _ItemID = itemID;
} }
private int _ItemID; private int _ItemID;
public int ItemID public int ItemID
{ {
get { return _ItemID; } get { return _ItemID; }
set { _ItemID = value; } set { _ItemID = value; }
} }
} }
private void DataPortal_Fetch(ItemIDCriteria criteria) private void DataPortal_Fetch(ItemIDCriteria criteria)
{ {
this.RaiseListChangedEvents = false; this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchItemID", GetHashCode()); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PartInfoList.DataPortal_FetchItemID", GetHashCode());
try try
{ {
using (SqlConnection cn = Database.VEPROMS_SqlConnection) using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{ {
using (SqlCommand cm = cn.CreateCommand()) using (SqlCommand cm = cn.CreateCommand())
{ {
cm.CommandType = CommandType.StoredProcedure; cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getPartsByItemID"; cm.CommandText = "getPartsByItemID";
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
cm.CommandTimeout = Database.DefaultTimeout; cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{ {
IsReadOnly = false; IsReadOnly = false;
while (dr.Read()) this.Add(new PartInfo(dr)); while (dr.Read()) this.Add(new PartInfo(dr));
IsReadOnly = true; IsReadOnly = true;
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_FetchItemID", ex); if (_MyLog.IsErrorEnabled) _MyLog.Error("PartInfoList.DataPortal_FetchItemID", ex);
throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex); throw new DbCslaException("PartInfoList.DataPortal_Fetch", ex);
} }
this.RaiseListChangedEvents = true; this.RaiseListChangedEvents = true;
} }
#endregion #endregion
#region ICustomTypeDescriptor impl #region ICustomTypeDescriptor impl
public String GetClassName() public String GetClassName()
{ return TypeDescriptor.GetClassName(this, true); } { return TypeDescriptor.GetClassName(this, true); }
public AttributeCollection GetAttributes() public AttributeCollection GetAttributes()
{ return TypeDescriptor.GetAttributes(this, true); } { return TypeDescriptor.GetAttributes(this, true); }
public String GetComponentName() public String GetComponentName()
{ return TypeDescriptor.GetComponentName(this, true); } { return TypeDescriptor.GetComponentName(this, true); }
public TypeConverter GetConverter() public TypeConverter GetConverter()
{ return TypeDescriptor.GetConverter(this, true); } { return TypeDescriptor.GetConverter(this, true); }
public EventDescriptor GetDefaultEvent() public EventDescriptor GetDefaultEvent()
{ return TypeDescriptor.GetDefaultEvent(this, true); } { return TypeDescriptor.GetDefaultEvent(this, true); }
public PropertyDescriptor GetDefaultProperty() public PropertyDescriptor GetDefaultProperty()
{ return TypeDescriptor.GetDefaultProperty(this, true); } { return TypeDescriptor.GetDefaultProperty(this, true); }
public object GetEditor(Type editorBaseType) public object GetEditor(Type editorBaseType)
{ return TypeDescriptor.GetEditor(this, editorBaseType, true); } { return TypeDescriptor.GetEditor(this, editorBaseType, true); }
public EventDescriptorCollection GetEvents(Attribute[] attributes) public EventDescriptorCollection GetEvents(Attribute[] attributes)
{ return TypeDescriptor.GetEvents(this, attributes, true); } { return TypeDescriptor.GetEvents(this, attributes, true); }
public EventDescriptorCollection GetEvents() public EventDescriptorCollection GetEvents()
{ return TypeDescriptor.GetEvents(this, true); } { return TypeDescriptor.GetEvents(this, true); }
public object GetPropertyOwner(PropertyDescriptor pd) public object GetPropertyOwner(PropertyDescriptor pd)
{ return this; } { return this; }
/// <summary> /// <summary>
/// Called to get the properties of this type. Returns properties with certain /// Called to get the properties of this type. Returns properties with certain
/// attributes. this restriction is not implemented here. /// attributes. this restriction is not implemented here.
/// </summary> /// </summary>
/// <param name="attributes"></param> /// <param name="attributes"></param>
/// <returns></returns> /// <returns></returns>
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{ return GetProperties(); } { return GetProperties(); }
/// <summary> /// <summary>
/// Called to get the properties of this type. /// Called to get the properties of this type.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public PropertyDescriptorCollection GetProperties() public PropertyDescriptorCollection GetProperties()
{ {
// Create a collection object to hold property descriptors // Create a collection object to hold property descriptors
PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
// Iterate the list // Iterate the list
for (int i = 0; i < this.Items.Count; i++) for (int i = 0; i < this.Items.Count; i++)
{ {
// Create a property descriptor for the item and add to the property descriptor collection // Create a property descriptor for the item and add to the property descriptor collection
PartInfoListPropertyDescriptor pd = new PartInfoListPropertyDescriptor(this, i); PartInfoListPropertyDescriptor pd = new PartInfoListPropertyDescriptor(this, i);
pds.Add(pd); pds.Add(pd);
} }
// return the property descriptor collection // return the property descriptor collection
return pds; return pds;
} }
#endregion #endregion
} // Class } // Class
#region Property Descriptor #region Property Descriptor
/// <summary> /// <summary>
/// Summary description for CollectionPropertyDescriptor. /// Summary description for CollectionPropertyDescriptor.
/// </summary> /// </summary>
public partial class PartInfoListPropertyDescriptor : vlnListPropertyDescriptor public partial class PartInfoListPropertyDescriptor : vlnListPropertyDescriptor
{ {
private PartInfo Item { get { return (PartInfo)_Item; } } private PartInfo Item { get { return (PartInfo)_Item; } }
public PartInfoListPropertyDescriptor(PartInfoList collection, int index) : base(collection, index) {; } public PartInfoListPropertyDescriptor(PartInfoList collection, int index) : base(collection, index) { ;}
} }
#endregion #endregion
#region Converter #region Converter
internal class PartInfoListConverter : ExpandableObjectConverter internal class PartInfoListConverter : ExpandableObjectConverter
{ {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{ {
if (destType == typeof(string) && value is PartInfoList) if (destType == typeof(string) && value is PartInfoList)
{ {
// Return department and department role separated by comma. // Return department and department role separated by comma.
return ((PartInfoList)value).Items.Count.ToString() + " Parts"; return ((PartInfoList)value).Items.Count.ToString() + " Parts";
} }
return base.ConvertTo(context, culture, value, destType); return base.ConvertTo(context, culture, value, destType);
} }
} }
#endregion #endregion
} // Namespace } // Namespace

File diff suppressed because it is too large Load Diff

View File

@ -19,460 +19,471 @@ using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
namespace VEPROMS.CSLA.Library namespace VEPROMS.CSLA.Library
{ {
public delegate void PdfInfoEvent(object sender); public delegate void PdfInfoEvent(object sender);
/// <summary> /// <summary>
/// PdfInfo Generated by MyGeneration using the CSLA Object Mapping template /// PdfInfo Generated by MyGeneration using the CSLA Object Mapping template
/// </summary> /// </summary>
[Serializable()] [Serializable()]
[TypeConverter(typeof(PdfInfoConverter))] [TypeConverter(typeof(PdfInfoConverter))]
public partial class PdfInfo : ReadOnlyBase<PdfInfo>, IDisposable public partial class PdfInfo : ReadOnlyBase<PdfInfo>, IDisposable
{ {
public event PdfInfoEvent Changed; public event PdfInfoEvent Changed;
private void OnChange() private void OnChange()
{ {
if (Changed != null) Changed(this); if (Changed != null) Changed(this);
} }
#region Log4Net #region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion #endregion
#region Collection #region Collection
private static List<PdfInfo> _CacheList = new List<PdfInfo>(); private static List<PdfInfo> _CacheList = new List<PdfInfo>();
protected static void AddToCache(PdfInfo pdfInfo) protected static void AddToCache(PdfInfo pdfInfo)
{ {
if (!_CacheList.Contains(pdfInfo)) _CacheList.Add(pdfInfo); // In AddToCache if (!_CacheList.Contains(pdfInfo)) _CacheList.Add(pdfInfo); // In AddToCache
} }
protected static void RemoveFromCache(PdfInfo pdfInfo) protected static void RemoveFromCache(PdfInfo pdfInfo)
{ {
while (_CacheList.Contains(pdfInfo)) _CacheList.Remove(pdfInfo); // In RemoveFromCache while (_CacheList.Contains(pdfInfo)) _CacheList.Remove(pdfInfo); // In RemoveFromCache
} }
private static Dictionary<string, List<PdfInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PdfInfo>>(); private static Dictionary<string, List<PdfInfo>> _CacheByPrimaryKey = new Dictionary<string, List<PdfInfo>>();
private static void ConvertListToDictionary() private static void ConvertListToDictionary()
{ {
while (_CacheList.Count > 0) // Move PdfInfo(s) from temporary _CacheList to _CacheByPrimaryKey while (_CacheList.Count > 0) // Move PdfInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{ {
PdfInfo tmp = _CacheList[0]; // Get the first PdfInfo PdfInfo tmp = _CacheList[0]; // Get the first PdfInfo
string pKey = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); string pKey = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey)) if (!_CacheByPrimaryKey.ContainsKey(pKey))
{ {
_CacheByPrimaryKey[pKey] = new List<PdfInfo>(); // Add new list for PrimaryKey _CacheByPrimaryKey[pKey] = new List<PdfInfo>(); // Add new list for PrimaryKey
} }
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheList.RemoveAt(0); // Remove the first PdfInfo _CacheList.RemoveAt(0); // Remove the first PdfInfo
} }
} }
internal static void AddList(PdfInfoList lst) internal static void AddList(PdfInfoList lst)
{ {
foreach (PdfInfo item in lst) AddToCache(item); foreach (PdfInfo item in lst) AddToCache(item);
} }
protected static PdfInfo GetCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) protected static PdfInfo GetCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString(); string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0];
return null; return null;
} }
// B2023-024 PROMS was using old cached PDF data when printing Word sections. // B2023-024 PROMS was using old cached PDF data when printing Word sections.
// Added this method to clear the PDF print cache for a specified section. // Added this method to clear the PDF print cache for a specified section.
// This is called from RemovePDFFromCache() in PDFExt.cs // This is called from RemovePDFFromCache() in PDFExt.cs
protected static void RemoveFromCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) protected static void RemoveFromCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
{ {
ConvertListToDictionary(); ConvertListToDictionary();
string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString(); string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString();
if (_CacheByPrimaryKey.ContainsKey(key)) if (_CacheByPrimaryKey.ContainsKey(key))
{ {
_CacheByPrimaryKey.Remove(key); _CacheByPrimaryKey.Remove(key);
} }
return; return;
} }
#endregion #endregion
#region Business Methods #region Business Methods
private string _ErrorMessage = string.Empty; private string _ErrorMessage = string.Empty;
public string ErrorMessage public string ErrorMessage
{ {
get { return _ErrorMessage; } get { return _ErrorMessage; }
} }
protected Pdf _Editable; protected Pdf _Editable;
private IVEHasBrokenRules HasBrokenRules private IVEHasBrokenRules HasBrokenRules
{ {
get get
{ {
IVEHasBrokenRules hasBrokenRules = null; IVEHasBrokenRules hasBrokenRules = null;
if (_Editable != null) if (_Editable != null)
hasBrokenRules = _Editable.HasBrokenRules; hasBrokenRules = _Editable.HasBrokenRules;
return hasBrokenRules; return hasBrokenRules;
} }
} }
private int _DocID; private int _DocID;
[System.ComponentModel.DataObjectField(true, true)] [System.ComponentModel.DataObjectField(true, true)]
public int DocID public int DocID
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
if (_MyDocument != null) _DocID = _MyDocument.DocID; CanReadProperty("DocID", true);
return _DocID; if (_MyDocument != null) _DocID = _MyDocument.DocID;
} return _DocID;
} }
private DocumentInfo _MyDocument; }
[System.ComponentModel.DataObjectField(true, true)] private DocumentInfo _MyDocument;
public DocumentInfo MyDocument [System.ComponentModel.DataObjectField(true, true)]
{ public DocumentInfo MyDocument
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID); {
return _MyDocument; CanReadProperty("MyDocument", true);
} if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID);
} return _MyDocument;
private int _DebugStatus; }
/// <summary> }
/// > 0 for Debug private int _DebugStatus;
/// </summary> /// <summary>
[System.ComponentModel.DataObjectField(true, true)] /// > 0 for Debug
public int DebugStatus /// </summary>
{ [System.ComponentModel.DataObjectField(true, true)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] public int DebugStatus
get {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
return _DebugStatus; get
} {
} CanReadProperty("DebugStatus", true);
private int _TopRow; return _DebugStatus;
[System.ComponentModel.DataObjectField(true, true)] }
public int TopRow }
{ private int _TopRow;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.ComponentModel.DataObjectField(true, true)]
get public int TopRow
{ {
return _TopRow; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
} {
private int _PageLength; CanReadProperty("TopRow", true);
[System.ComponentModel.DataObjectField(true, true)] return _TopRow;
public int PageLength }
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private int _PageLength;
get [System.ComponentModel.DataObjectField(true, true)]
{ public int PageLength
return _PageLength; {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
} get
private int _LeftMargin; {
[System.ComponentModel.DataObjectField(true, true)] CanReadProperty("PageLength", true);
public int LeftMargin return _PageLength;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private int _LeftMargin;
{ [System.ComponentModel.DataObjectField(true, true)]
return _LeftMargin; public int LeftMargin
} {
} [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
private int _PageWidth; get
[System.ComponentModel.DataObjectField(true, true)] {
public int PageWidth CanReadProperty("LeftMargin", true);
{ return _LeftMargin;
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get }
{ private int _PageWidth;
return _PageWidth; [System.ComponentModel.DataObjectField(true, true)]
} public int PageWidth
} {
private double _PageCount; [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
/// <summary> get
/// Count of whole and partial pages {
/// </summary> CanReadProperty("PageWidth", true);
public double PageCount return _PageWidth;
{ }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] }
get private double _PageCount;
{ /// <summary>
return _PageCount; /// Count of whole and partial pages
} /// </summary>
} public double PageCount
private byte[] _DocPdf; {
public byte[] DocPdf [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
{ get
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] {
get CanReadProperty("PageCount", true);
{ return _PageCount;
return _DocPdf; }
} }
} private byte[] _DocPdf;
private DateTime _DTS = new DateTime(); public byte[] DocPdf
public DateTime DTS {
{ [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] get
get {
{ CanReadProperty("DocPdf", true);
return _DTS; return _DocPdf;
} }
} }
private string _UserID = string.Empty; private DateTime _DTS = new DateTime();
public string UserID public DateTime DTS
{ {
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get get
{ {
return _UserID; CanReadProperty("DTS", true);
} return _DTS;
} }
// CSLATODO: Replace base PdfInfo.ToString function as necessary }
/// <summary> private string _UserID = string.Empty;
/// Overrides Base ToString public string UserID
/// </summary> {
/// <returns>A string representation of current PdfInfo</returns> [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
//public override string ToString() get
//{ {
// return base.ToString(); CanReadProperty("UserID", true);
//} return _UserID;
// CSLATODO: Check PdfInfo.GetIdValue to assure that the ID returned is unique }
/// <summary> }
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality // CSLATODO: Replace base PdfInfo.ToString function as necessary
/// </summary> /// <summary>
/// <returns>A Unique ID for the current PdfInfo</returns> /// Overrides Base ToString
protected override object GetIdValue() /// </summary>
{ /// <returns>A string representation of current PdfInfo</returns>
return MyPdfInfoUnique; // Absolutely Unique ID //public override string ToString()
} //{
#endregion // return base.ToString();
#region Factory Methods //}
private static int _PdfInfoUnique = 0; // CSLATODO: Check PdfInfo.GetIdValue to assure that the ID returned is unique
private static int PdfInfoUnique /// <summary>
{ get { return ++_PdfInfoUnique; } } /// Overrides Base GetIdValue - Used internally by CSLA to determine equality
private int _MyPdfInfoUnique = PdfInfoUnique; /// </summary>
public int MyPdfInfoUnique // Absolutely Unique ID - Info /// <returns>A Unique ID for the current PdfInfo</returns>
{ get { return _MyPdfInfoUnique; } } protected override object GetIdValue()
protected PdfInfo() {
{/* require use of factory methods */ return MyPdfInfoUnique; // Absolutely Unique ID
AddToCache(this); }
} #endregion
private bool _Disposed = false; #region Factory Methods
private static int _CountCreated = 0; private static int _PdfInfoUnique = 0;
private static int _CountDisposed = 0; private static int PdfInfoUnique
private static int _CountFinalized = 0; { get { return ++_PdfInfoUnique; } }
private static int IncrementCountCreated private int _MyPdfInfoUnique = PdfInfoUnique;
{ get { return ++_CountCreated; } } public int MyPdfInfoUnique // Absolutely Unique ID - Info
private int _CountWhenCreated = IncrementCountCreated; { get { return _MyPdfInfoUnique; } }
public static int CountCreated protected PdfInfo()
{ get { return _CountCreated; } } {/* require use of factory methods */
public static int CountNotDisposed AddToCache(this);
{ get { return _CountCreated - _CountDisposed; } } }
public static int CountNotFinalized private bool _Disposed = false;
{ get { return _CountCreated - _CountFinalized; } } private static int _CountCreated = 0;
~PdfInfo() private static int _CountDisposed = 0;
{ private static int _CountFinalized = 0;
_CountFinalized++; private static int IncrementCountCreated
} { get { return ++_CountCreated; } }
public void Dispose() private int _CountWhenCreated = IncrementCountCreated;
{ public static int CountCreated
if (_Disposed) return; { get { return _CountCreated; } }
_CountDisposed++; public static int CountNotDisposed
_Disposed = true; { get { return _CountCreated - _CountDisposed; } }
RemoveFromCache(this); public static int CountNotFinalized
if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString())) return; { get { return _CountCreated - _CountFinalized; } }
List<PdfInfo> listPdfInfo = _CacheByPrimaryKey[DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()]; // Get the list of items ~PdfInfo()
while (listPdfInfo.Contains(this)) listPdfInfo.Remove(this); // Remove the item from the list {
if (listPdfInfo.Count == 0) // If there are no items left in the list _CountFinalized++;
_CacheByPrimaryKey.Remove(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()); // remove the list }
} public void Dispose()
public virtual Pdf Get() {
{ if (_Disposed) return;
return _Editable = Pdf.Get(_DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth); _CountDisposed++;
} _Disposed = true;
public static void Refresh(Pdf tmp) RemoveFromCache(this);
{ if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString())) return;
string key = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); List<PdfInfo> listPdfInfo = _CacheByPrimaryKey[DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()]; // Get the list of items
ConvertListToDictionary(); while (listPdfInfo.Contains(this)) listPdfInfo.Remove(this); // Remove the item from the list
if (_CacheByPrimaryKey.ContainsKey(key)) if (listPdfInfo.Count == 0) // If there are no items left in the list
foreach (PdfInfo tmpInfo in _CacheByPrimaryKey[key]) _CacheByPrimaryKey.Remove(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()); // remove the list
tmpInfo.RefreshFields(tmp); }
} public virtual Pdf Get()
protected virtual void RefreshFields(Pdf tmp) {
{ return _Editable = Pdf.Get(_DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth);
_PageCount = tmp.PageCount; }
_DocPdf = tmp.DocPdf; public static void Refresh(Pdf tmp)
_DTS = tmp.DTS; {
_UserID = tmp.UserID; string key = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString();
_PdfInfoExtension.Refresh(this); ConvertListToDictionary();
OnChange();// raise an event if (_CacheByPrimaryKey.ContainsKey(key))
} foreach (PdfInfo tmpInfo in _CacheByPrimaryKey[key])
public static void Refresh(Document myDocument, DocumentPdf tmp) tmpInfo.RefreshFields(tmp);
{ }
string key = myDocument.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); protected virtual void RefreshFields(Pdf tmp)
ConvertListToDictionary(); {
if (_CacheByPrimaryKey.ContainsKey(key)) _PageCount = tmp.PageCount;
foreach (PdfInfo tmpInfo in _CacheByPrimaryKey[key]) _DocPdf = tmp.DocPdf;
tmpInfo.RefreshFields(tmp); _DTS = tmp.DTS;
} _UserID = tmp.UserID;
protected virtual void RefreshFields(DocumentPdf tmp) _PdfInfoExtension.Refresh(this);
{ OnChange();// raise an event
_PageCount = tmp.PageCount; }
_DocPdf = tmp.DocPdf; public static void Refresh(Document myDocument, DocumentPdf tmp)
_DTS = tmp.DTS; {
_UserID = tmp.UserID; string key = myDocument.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString();
_PdfInfoExtension.Refresh(this); ConvertListToDictionary();
OnChange();// raise an event if (_CacheByPrimaryKey.ContainsKey(key))
} foreach (PdfInfo tmpInfo in _CacheByPrimaryKey[key])
public static PdfInfo Get(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) tmpInfo.RefreshFields(tmp);
{ }
//if (!CanGetObject()) protected virtual void RefreshFields(DocumentPdf tmp)
// throw new System.Security.SecurityException("User not authorized to view a Pdf"); {
try _PageCount = tmp.PageCount;
{ _DocPdf = tmp.DocPdf;
PdfInfo tmp = GetCachedByPrimaryKey(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth); _DTS = tmp.DTS;
if (tmp == null) _UserID = tmp.UserID;
{ _PdfInfoExtension.Refresh(this);
tmp = DataPortal.Fetch<PdfInfo>(new PKCriteria(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth)); OnChange();// raise an event
if (tmp.DocID > 0) AddToCache(tmp); }
} public static PdfInfo Get(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
if (tmp.ErrorMessage == "No Record Found") {
{ //if (!CanGetObject())
tmp.Dispose(); // Clean-up PdfInfo // throw new System.Security.SecurityException("User not authorized to view a Pdf");
tmp = null; try
} {
return tmp; PdfInfo tmp = GetCachedByPrimaryKey(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth);
} if (tmp == null)
catch (Exception ex) {
{ tmp = DataPortal.Fetch<PdfInfo>(new PKCriteria(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth));
throw new DbCslaException("Error on PdfInfo.Get", ex); if (tmp.DocID > 0) AddToCache(tmp);
} }
} if (tmp.ErrorMessage == "No Record Found")
#endregion {
#region Data Access Portal tmp.Dispose(); // Clean-up PdfInfo
internal PdfInfo(SafeDataReader dr) tmp = null;
{ }
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.Constructor", GetHashCode()); return tmp;
try }
{ catch (Exception ex)
ReadData(dr); {
} throw new DbCslaException("Error on PdfInfo.Get", ex);
catch (Exception ex) }
{ }
if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.Constructor", ex); #endregion
throw new DbCslaException("PdfInfo.Constructor", ex); #region Data Access Portal
} internal PdfInfo(SafeDataReader dr)
} {
[Serializable()] if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.Constructor", GetHashCode());
protected class PKCriteria try
{ {
private int _DocID; ReadData(dr);
public int DocID }
{ get { return _DocID; } } catch (Exception ex)
private int _DebugStatus; {
public int DebugStatus if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.Constructor", ex);
{ get { return _DebugStatus; } } throw new DbCslaException("PdfInfo.Constructor", ex);
private int _TopRow; }
public int TopRow }
{ get { return _TopRow; } } [Serializable()]
private int _PageLength; protected class PKCriteria
public int PageLength {
{ get { return _PageLength; } } private int _DocID;
private int _LeftMargin; public int DocID
public int LeftMargin { get { return _DocID; } }
{ get { return _LeftMargin; } } private int _DebugStatus;
private int _PageWidth; public int DebugStatus
public int PageWidth { get { return _DebugStatus; } }
{ get { return _PageWidth; } } private int _TopRow;
public PKCriteria(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) public int TopRow
{ { get { return _TopRow; } }
_DocID = docID; private int _PageLength;
_DebugStatus = debugStatus; public int PageLength
_TopRow = topRow; { get { return _PageLength; } }
_PageLength = pageLength; private int _LeftMargin;
_LeftMargin = leftMargin; public int LeftMargin
_PageWidth = pageWidth; { get { return _LeftMargin; } }
} private int _PageWidth;
} public int PageWidth
private void ReadData(SafeDataReader dr) { get { return _PageWidth; } }
{ public PKCriteria(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth)
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.ReadData", GetHashCode()); {
try _DocID = docID;
{ _DebugStatus = debugStatus;
_DocID = dr.GetInt32("DocID"); _TopRow = topRow;
_DebugStatus = dr.GetInt32("DebugStatus"); _PageLength = pageLength;
_TopRow = dr.GetInt32("TopRow"); _LeftMargin = leftMargin;
_PageLength = dr.GetInt32("PageLength"); _PageWidth = pageWidth;
_LeftMargin = dr.GetInt32("LeftMargin"); }
_PageWidth = dr.GetInt32("PageWidth"); }
_PageCount = dr.GetDouble("PageCount"); private void ReadData(SafeDataReader dr)
_DocPdf = (byte[])dr.GetValue("DocPdf"); {
_DTS = dr.GetDateTime("DTS"); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.ReadData", GetHashCode());
_UserID = dr.GetString("UserID"); try
} {
catch (Exception ex) _DocID = dr.GetInt32("DocID");
{ _DebugStatus = dr.GetInt32("DebugStatus");
if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.ReadData", ex); _TopRow = dr.GetInt32("TopRow");
_ErrorMessage = ex.Message; _PageLength = dr.GetInt32("PageLength");
throw new DbCslaException("PdfInfo.ReadData", ex); _LeftMargin = dr.GetInt32("LeftMargin");
} _PageWidth = dr.GetInt32("PageWidth");
} _PageCount = dr.GetDouble("PageCount");
private void DataPortal_Fetch(PKCriteria criteria) _DocPdf = (byte[])dr.GetValue("DocPdf");
{ _DTS = dr.GetDateTime("DTS");
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.DataPortal_Fetch", GetHashCode()); _UserID = dr.GetString("UserID");
try }
{ catch (Exception ex)
using (SqlConnection cn = Database.VEPROMS_SqlConnection) {
{ if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.ReadData", ex);
ApplicationContext.LocalContext["cn"] = cn; _ErrorMessage = ex.Message;
using (SqlCommand cm = cn.CreateCommand()) throw new DbCslaException("PdfInfo.ReadData", ex);
{ }
cm.CommandType = CommandType.StoredProcedure; }
cm.CommandText = "getPdf"; private void DataPortal_Fetch(PKCriteria criteria)
cm.Parameters.AddWithValue("@DocID", criteria.DocID); {
cm.Parameters.AddWithValue("@DebugStatus", criteria.DebugStatus); if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.DataPortal_Fetch", GetHashCode());
cm.Parameters.AddWithValue("@TopRow", criteria.TopRow); try
cm.Parameters.AddWithValue("@PageLength", criteria.PageLength); {
cm.Parameters.AddWithValue("@LeftMargin", criteria.LeftMargin); using (SqlConnection cn = Database.VEPROMS_SqlConnection)
cm.Parameters.AddWithValue("@PageWidth", criteria.PageWidth); {
cm.CommandTimeout = Database.DefaultTimeout; ApplicationContext.LocalContext["cn"] = cn;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) using (SqlCommand cm = cn.CreateCommand())
{ {
if (!dr.Read()) cm.CommandType = CommandType.StoredProcedure;
{ cm.CommandText = "getPdf";
_ErrorMessage = "No Record Found"; cm.Parameters.AddWithValue("@DocID", criteria.DocID);
return; cm.Parameters.AddWithValue("@DebugStatus", criteria.DebugStatus);
} cm.Parameters.AddWithValue("@TopRow", criteria.TopRow);
ReadData(dr); cm.Parameters.AddWithValue("@PageLength", criteria.PageLength);
} cm.Parameters.AddWithValue("@LeftMargin", criteria.LeftMargin);
} cm.Parameters.AddWithValue("@PageWidth", criteria.PageWidth);
// removing of item only needed for local data portal cm.CommandTimeout = Database.DefaultTimeout;
if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
ApplicationContext.LocalContext.Remove("cn"); {
} if (!dr.Read())
} {
catch (Exception ex) _ErrorMessage = "No Record Found";
{ return;
if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.DataPortal_Fetch", ex); }
_ErrorMessage = ex.Message; ReadData(dr);
throw new DbCslaException("PdfInfo.DataPortal_Fetch", ex); }
} }
} // removing of item only needed for local data portal
#endregion if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
// Standard Refresh ApplicationContext.LocalContext.Remove("cn");
#region extension }
PdfInfoExtension _PdfInfoExtension = new PdfInfoExtension(); }
[Serializable()] catch (Exception ex)
partial class PdfInfoExtension : extensionBase { } {
[Serializable()] if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.DataPortal_Fetch", ex);
class extensionBase _ErrorMessage = ex.Message;
{ throw new DbCslaException("PdfInfo.DataPortal_Fetch", ex);
// Default Refresh }
public virtual void Refresh(PdfInfo tmp) { } }
} #endregion
#endregion // Standard Refresh
} // Class #region extension
#region Converter PdfInfoExtension _PdfInfoExtension = new PdfInfoExtension();
internal class PdfInfoConverter : ExpandableObjectConverter [Serializable()]
{ partial class PdfInfoExtension : extensionBase { }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) [Serializable()]
{ class extensionBase
if (destType == typeof(string) && value is PdfInfo) {
{ // Default Refresh
// Return the ToString value public virtual void Refresh(PdfInfo tmp) { }
return ((PdfInfo)value).ToString(); }
} #endregion
return base.ConvertTo(context, culture, value, destType); } // Class
} #region Converter
} internal class PdfInfoConverter : ExpandableObjectConverter
#endregion {
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
{
if (destType == typeof(string) && value is PdfInfo)
{
// Return the ToString value
return ((PdfInfo)value).ToString();
}
return base.ConvertTo(context, culture, value, destType);
}
}
#endregion
} // Namespace } // Namespace

Some files were not shown because too many files have changed in this diff Show More