This commit is contained in:
2006-11-14 14:33:33 +00:00
commit a0cad33b0f
180 changed files with 40199 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using System.Collections;
namespace Volian.CSLA.Library
{
[Serializable]
public class HLStepInfo : VEReadOnlyBase<HLStepInfo>
{
#region Business methods
private int _item;
public int Item
{
get { return _item; }
}
public string Number
{
get { return (1+_item).ToString().PadLeft(3,' '); }
}
public override string ToString()
{
return Number + " - " + _name;
}
protected override void LoadChildren(int id)
{
// TODO: Load High Level Steps - if ContentType = ??
}
public override bool HasChildren()
{
return false;
}
#endregion
#region Constructors
public HLStepInfo()
{ /* require use of factory methods */ }
internal HLStepInfo(int id, string name, int item)
{
_id = id;
_name = name;
_item = item;
}
#endregion
}
}

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using Csla;
using System.Data;
using Csla.Data;
namespace Volian.CSLA.Library
{
[Serializable()]
public class HLStepInfoList : VEReadOnlyListBase<HLStepInfoList, HLStepInfo>
{
#region Factory Methods
protected HLStepInfoList()
{ /* require use of factory methods */ }
#endregion
#region Item Specific Data Access
/// <summary>
/// This is the SQL Command Definition
/// </summary>
/// <param name="cm">SQL Command</param>
/// <param name="criteria">Criteria for this object</param>
protected override void SetupSelect(SqlCommand cm, Criteria criteria)
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ListHLSteps";
cm.Parameters.AddWithValue("@StructID", criteria.Id);
}
/// <summary>
/// This saves each item to the list from the Database
/// </summary>
/// <param name="dr">SafeDataReader used to load items</param>
protected override void CreateItem(SafeDataReader dr)
{
try
{
HLStepInfo info = new HLStepInfo(
dr.GetInt32("StructureID"),
dr.GetString("TextM"),
dr.GetInt32("Item")
);
this.Add(info);
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception: {1} Message: {2}\r\nInner Exception:{3}",
new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name,
ex.GetType().ToString(), ex.Message, ex.InnerException);
}
}
#endregion
}
}

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using System.Collections;
namespace Volian.CSLA.Library
{
[Serializable]
public class VEReadOnlyBase<T> : ReadOnlyBase<T>, IVEReadOnlyItem
where T : ReadOnlyBase<T>
{
#region Generic methods
protected int _id = 0;
protected string _name = string.Empty;
protected IList _children = null;
public IList GetChildren()
{
if (_children == null)LoadChildren(Id);
return _children;
}
public bool GetChildrenLoaded()
{
return _children != null;
}
public virtual bool HasChildren()
{
return true;//Not sure whether to default this to true or false
}
public int Id
{
get { return _id; }
}
public string Name
{
get { return _name; }
}
protected override object GetIdValue()
{
return _id;
}
#endregion
#region Item Specific
public override string ToString()
{
return _name;
}
protected virtual void LoadChildren(int id)
{
}
#endregion
#region Constructors
public VEReadOnlyBase()
{ /* require use of factory methods */ }
#endregion
}
//public class VERODataPath : VEReadOnlyBase<VERODataPath>
//{
// private VERODataPath() : base() { ;}
// public VERODataPath(int id, string name) : base(id, name) { ;}
//}
//public class VEROPlant : VEReadOnlyBase<VEROPlant>
//{
// private VEROPlant() : base() { ;}
// public VEROPlant(int id, string name) : base(id, name) { ;}
//}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace Volian.CSLA.Library
{
public interface IVEReadOnlyItem
{
IList GetChildren(); // Returns a list of Business Objects
bool GetChildrenLoaded(); // Have the Business Objects been Loaded
bool HasChildren(); // Identifies if Children are available
// Ideas Authorization
//bool CanLock();
//bool CanUnlock();
//bool CanOpen();
//bool CanEdit();
//bool CanAdmin();
// Ideas Security
//bool Lock(string msg);
//bool Unlock();
}
}

View File

@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using Csla;
using System.Data;
using Csla.Data;
using System.IO;
using log4net;
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace Volian.CSLA.Library
{
[Serializable()]
public class VEReadOnlyListBase<T, C> : ReadOnlyListBase<T, C>
where T : VEReadOnlyListBase<T, C>
where C : VEReadOnlyBase<C>, new()
{
#region Log4Net
protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
#region Authorization Rules
public static bool CanGetObject()
{
// TODO: customize to check user role
//return ApplicationContext.User.IsInRole("");
return true;
}
#endregion
#region Generic Factory Methods
public static T Get(int id)
{
return DataPortal.Fetch<T>(new Criteria(id));
}
protected VEReadOnlyListBase()
{ /* require use of factory methods */ }
#endregion
#region Generic Data Access
[Serializable()]
protected class Criteria
{
private int _id;
public int Id
{
get { return _id; }
}
public Criteria(int id)
{
_id = id;
}
}
protected void DataPortal_Fetch(Criteria criteria)
{
this.RaiseListChangedEvents = false;
// if (log.IsDebugEnabled) log.Debug(this.GetType().ToString());
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
SetupSelect(cm, criteria);
SqlDataReader drRaw = cm.ExecuteReader();
using (SafeDataReader dr = new SafeDataReader(drRaw))
{
IsReadOnly = false;
while (dr.Read())
{
CreateItem(dr);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
//System.Diagnostics.StackFrame[] sf = new System.Diagnostics.StackTrace().GetFrames();
//string sMsg = string.Format("{0}.{1} Exception: {2} \r\n Message: {3}\r\n Inner Exception:{4}",
// this.GetType().ToString(), sf[0].GetMethod().Name,
// ex.GetType().ToString(), ex.Message, ex.InnerException);
//System.Diagnostics.EventLog.WriteEntry("VEReadOnlyListBase", sMsg);
//Console.WriteLine(sMsg);
if(log.IsErrorEnabled)log.Error("Fetch Error", ex);
}
this.RaiseListChangedEvents = true;
}
#endregion
#region Item Specific Virtual Data Access
protected virtual void SetupSelect(SqlCommand cm, Criteria criteria) { ;}
protected virtual void CreateItem(SafeDataReader dr) { ;}
#endregion
}
}

View File

@@ -0,0 +1,199 @@
using System;
using System.Collections.Generic;
using System.Text;
using Volian.CSLA.Library;
using System.Windows.Forms;
using Csla;
using System.Collections;
namespace Volian.CSLA.Library
{
public abstract class VETreeNode : TreeNode
{
#region Business Methods
protected IVEReadOnlyItem _VEObject;
public IVEReadOnlyItem VEObject
{
get { return _VEObject; }
set
{
_VEObject = value;
base.Text = _VEObject.ToString();
ResetNode();
}
}
public void Refresh()
{
if (_VEObject != null)
Text = _VEObject.ToString();
}
// Only load the Children Once
protected bool _ChildrenLoaded = false;
public bool ChildrenLoaded
{
get { return _ChildrenLoaded; }
}
// Reset Node
public void CloseNode()
{
ResetNode();
}
private void ResetNode()
{
if (_VEObject!=null && _VEObject.HasChildren())
{
_ChildrenLoaded = false;// Reset the children loaded flag
this.Nodes.Add("Dummy");// Add a Dummy Node so that the item will appear to be expanable.
}
else
{
_ChildrenLoaded = true;// Reset the children loaded flag
}
// ToDo: Need to reset object as well
}
public void RefreshNode()
{
ResetNode();// Drop Children
LoadChildren();// Load Children
}
public abstract void LoadChildren();
//public IVEReadOnlyItem GetCsla()
//{
// return _VEObject;
//}
#endregion
#region Factory Methods
// Constructors
public VETreeNode() : base("NoText") { ; }
public VETreeNode(IVEReadOnlyItem o)
: base(o.ToString())
{
_VEObject = o;// Save the BusinessObject
ResetNode();
}
public VETreeNode(string s)
: base(s)
{
_VEObject = null;// Save the BusinessObject
ResetNode();
}
#endregion
}
public class VETreeNodeBase<T> : VETreeNode
where T : VETreeNode, new()
{
#region Factory Methods
public VETreeNodeBase(string s) : base(s) { ;}
public VETreeNodeBase(IVEReadOnlyItem o) : base(o) { ;}
protected VETreeNodeBase() : base() { ;}
public override void LoadChildren()
{
if (!_ChildrenLoaded)
{
this.Nodes.Clear();
IList ol = _VEObject.GetChildren();
if (ol != null)
{
foreach (IVEReadOnlyItem o in ol)
{
try
{
T tmp = new T();
tmp.VEObject = o;
this.Nodes.Add(tmp);
}
catch (Exception ex)
{
Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
}
}
}
_ChildrenLoaded = true;
}
}
#endregion
}
public class VEFolder : VETreeNodeBase<VEVersion>
{
public static VEFolder LoadTree()
{
VEFolder root = null;
FolderInfoList fil = FolderInfoList.Get();
Dictionary<int, VEFolder> dicMissing = new Dictionary<int, VEFolder>();
Dictionary<int, VEFolder> dicExists = new Dictionary<int, VEFolder>();
foreach (FolderInfo fi in fil)
{
VEFolder ftp = null;
if (dicExists.ContainsKey(fi.ParentID))
{
ftp = dicExists[fi.ParentID];
}
else
{
if (fi.ParentID != 0)
{
ftp = new VEFolder(fi.ParentID.ToString());
dicMissing.Add(fi.ParentID, ftp);
dicExists.Add(fi.ParentID, ftp);
}
}
VEFolder ft = null;
if (dicMissing.ContainsKey(fi.FolderID))
{
ft = dicMissing[fi.FolderID];
ft.VEObject = fi;
dicMissing.Remove(fi.FolderID);
}
else
{
ft = new VEFolder(fi);
dicExists.Add(fi.FolderID, ft);
}
if (fi.ParentID == 0)
root = ft;
else
ftp.Nodes.Add(ft);
}
//root.FindTree = dicExists;
return root;
}
private VEFolder(string s) : base(s) { ;}
public VEFolder(IVEReadOnlyItem o) : base(o) { ;}
}
public class VEVersion : VETreeNodeBase<VEProcedure> { }
public class VEProcedure : VETreeNodeBase<VESection>
{
public override void LoadChildren()
{
if (!_ChildrenLoaded)
{
this.Nodes.Clear();
Dictionary<string, VESection> dicSect = new Dictionary<string, VESection>();
SectionInfoList ol = (SectionInfoList)_VEObject.GetChildren();
if (ol != null)
{
foreach (SectionInfo o in ol)
{
try
{
VESection tmp = new VESection();
tmp.VEObject = o;
if (dicSect.ContainsKey(o.PPath))
dicSect[o.PPath].Nodes.Add(tmp);
else
this.Nodes.Add(tmp);
dicSect[o.Path] = tmp;
}
catch (Exception ex)
{
Console.WriteLine("{0}\r\n{1}", ex.Message, ex.InnerException);
}
}
}
_ChildrenLoaded = true;
}
}
}
public class VESection : VETreeNodeBase<VEStep> { }
public class VEStep : VETreeNodeBase<VEStep> { }
}