commit a0cad33b0f6d0d0752ba148ed115faa3c9888807 Author: Kathy Date: Tue Nov 14 14:33:33 2006 +0000 diff --git a/PROMS/proms/DataLoader/App.config b/PROMS/proms/DataLoader/App.config new file mode 100644 index 00000000..9c834cfe --- /dev/null +++ b/PROMS/proms/DataLoader/App.config @@ -0,0 +1,71 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PROMS/proms/DataLoader/ClassDiagram1.cd b/PROMS/proms/DataLoader/ClassDiagram1.cd new file mode 100644 index 00000000..0519ecba --- /dev/null +++ b/PROMS/proms/DataLoader/ClassDiagram1.cd @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/PROMS/proms/DataLoader/ConfigInfo.cs b/PROMS/proms/DataLoader/ConfigInfo.cs new file mode 100644 index 00000000..054d3986 --- /dev/null +++ b/PROMS/proms/DataLoader/ConfigInfo.cs @@ -0,0 +1,79 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace DataLoader +{ + class ConfigInfo + { + private XmlDocument xmldoc; + public ConfigInfo(string xml) + { + xmldoc = new XmlDocument(); + if (xml == null) + xmldoc.LoadXml(""); + else + xmldoc.LoadXml(xml); + } + + public ConfigInfo(string xml, string ename, string aname, string avalue) + { + xmldoc = new XmlDocument(); + if (xml == null) + xmldoc.LoadXml(""); + else + xmldoc.LoadXml(xml); + AddItem(ename, aname.Replace(' ','_'), avalue); + } + public bool AddItem(string ename, string aname, string avalue) + { + if (aname != null && aname != "") + { + //if (xmldoc == null) + //{ + // xmldoc = new XmlDocument(); + // xmldoc.AppendChild(xmldoc.CreateElement("ConfigInfo")); + //} + // see if ename element exists, use it to add attributes, + // otherwise, create the element. + + XmlNode nxml = null; + XmlNodeList xl = xmldoc.DocumentElement.SelectNodes(string.Format("//{0}", ename)); + switch (xl.Count) + { + case 0: // No nodes found + nxml = xmldoc.DocumentElement.AppendChild(xmldoc.CreateElement(ename)); + break; + default: // Found the node + nxml = xl[0]; + if (nxml.GetType() != typeof(XmlElement)) + { + frmLoader.log.ErrorFormat("Invalid xml element type when migrating config data - element = {0}, name = {1} , value = {2}", ename, aname, avalue); + return false; + } + break; + } + XmlAttribute xa = nxml.Attributes.Append(xmldoc.CreateAttribute(aname.Replace(' ', '_'))); + xa.Value = avalue; + return true; + } + return false; + } + public override string ToString() + { + if (xmldoc != null) return xmldoc.InnerXml; + else return null; + } + + } +} diff --git a/PROMS/proms/DataLoader/CurSet.cs b/PROMS/proms/DataLoader/CurSet.cs new file mode 100644 index 00000000..c458037b --- /dev/null +++ b/PROMS/proms/DataLoader/CurSet.cs @@ -0,0 +1,110 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.IO; +using System.Collections; +using System.Text; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Serialization; +using Volian.CSLA.Library; + +namespace Utils +{ + /// + /// Summary description for CurSet. + /// + public class CurSet + { + private int NUMCBTEXTYPE = 5; // number of changebar text types. + public string PathName; + + public CurSet(string pname) + { + PathName = pname; + } + + private string ReadTheString(BinaryReader bw, int maxlen) + { + StringBuilder retStr = new StringBuilder(maxlen+1); + // read a series of characters until a null is found. + char ac; + bool done = false; + while(done==false) + { + ac = bw.ReadChar(); + if (ac=='\0') + done=true; + else + retStr.Append(ac); + } + return retStr.ToString(); + } + + public FolderConfig Convert(FolderConfig cfg) + { + BinaryReader br; + ArrayList DefaultUserCBMsg = new ArrayList(2); + FileStream fs; + FileInfo fi = new FileInfo(PathName); + try + { + fs = fi.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite ); + br = new BinaryReader(fs,System.Text.ASCIIEncoding.ASCII); + } + catch (Exception e) + { + DataLoader.frmLoader.log.ErrorFormat("Error migrating Curset.dat, error = {0}", e.Message); + return cfg; + } + + try + { + sbyte tmpsbyte; + string tmpstring; + tmpsbyte=br.ReadSByte(); // DefaultDestination not used + + // the next byte has three settings embedded in it, the type of change + // bar (Print_ChangeBar), the change bar location and its text. + tmpsbyte= br.ReadSByte(); + cfg.Print_ChangeBar = (FolderConfig.PrintChangeBar)((int)tmpsbyte > 2 ? 3 : (int)tmpsbyte); + cfg.Print_ChangeBarLoc = (FolderConfig.PrintChangeBarLoc)((tmpsbyte-3)/NUMCBTEXTYPE); + int ts = (tmpsbyte-3)%NUMCBTEXTYPE; + cfg.Print_ChangeBarText = (FolderConfig.PrintChangeBarText)((tmpsbyte-3)%NUMCBTEXTYPE); + cfg.Print_NumCopies=br.ReadSByte(); + cfg.Print_Pagination=(FolderConfig.PrintPagination) br.ReadSByte(); + tmpstring = ReadTheString(br,4); // DefaultPrinter not used + cfg.Format_Plant = ReadTheString(br,10); + tmpstring = ReadTheString(br, 128); // DefaultDestFName not used + tmpsbyte = br.ReadSByte(); // DefaultPlotterType not used + tmpsbyte = br.ReadSByte(); // DefaultPlotterPort not used + tmpsbyte = br.ReadSByte(); // DefaultCIEType not used. + for (int i=0;i<8;i++) // DefPenColors[8] not used + tmpsbyte = br.ReadSByte(); + cfg.Print_Watermark = (FolderConfig.PrintWatermark)br.ReadSByte(); + cfg.Print_UserCBMess1 = ReadTheString(br, 10); + cfg.Print_UserCBMess2 = ReadTheString(br, 10); + tmpsbyte = br.ReadSByte(); // DontPrintStatusTree not used + cfg.Print_UserFormat = ReadTheString(br, 10); + tmpsbyte = br.ReadSByte(); + cfg.Print_DisableDuplex = tmpsbyte == 0 ? false : true; + br.Close(); + } + catch(Exception e) + { + if(br!=null) br.Close(); + DataLoader.frmLoader.log.ErrorFormat("Error migrating Curset.dat, error = {0}", e.Message); + } + fs.Close(); + return cfg; + } + } +} diff --git a/PROMS/proms/DataLoader/DataLoader.csproj b/PROMS/proms/DataLoader/DataLoader.csproj new file mode 100644 index 00000000..63725d6b --- /dev/null +++ b/PROMS/proms/DataLoader/DataLoader.csproj @@ -0,0 +1,166 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE} + WinExe + Properties + DataLoader + DataLoader + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\veproms\bin\Csla.dll + + + False + ..\..\..\..\veproms\bin\IniReader.dll + + + False + ..\..\..\..\veproms\bin\log4net.dll + + + False + ..\..\..\..\veproms\bin\MSWord.dll + + + + + + + + + False + ..\..\..\..\veproms\bin\vlnObject.dll + + + False + ..\..\..\..\veproms\bin\vlnServerLibrary.dll + + + False + ..\..\..\..\veproms\bin\Volian.CSLA.Library.dll + + + + + + + + Form + + + Form + + + frmLoader.cs + + + Form + + + GroupProp.cs + + + Form + + + + + Form + + + + Form + + + + + Designer + frmLoader.cs + + + Designer + GroupProp.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + Form + + + + + + Form + + + Form + + + Form + + + + Form + + + Form + + + Form + + + + + \ No newline at end of file diff --git a/PROMS/proms/DataLoader/DataLoader.csproj.vspscc b/PROMS/proms/DataLoader/DataLoader.csproj.vspscc new file mode 100644 index 00000000..f42fb8a2 --- /dev/null +++ b/PROMS/proms/DataLoader/DataLoader.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:DataLoader" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/DataLoader/DocVersions.cs b/PROMS/proms/DataLoader/DocVersions.cs new file mode 100644 index 00000000..a2f7df0a --- /dev/null +++ b/PROMS/proms/DataLoader/DocVersions.cs @@ -0,0 +1,61 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private Int32 MigrateDocVersion(string pth) + { + + Int32 iStructureID = 0; + // Open connection + OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pth + ";Extended Properties=dBase III;Persist Security Info=False"); + // load rofst (use it later).... + rofst = new ROFST(pth + "\\ro.fst"); + // Migrate library documents + MigrateLibDocs(cn, pth); + // Initialize Dictionaries + dicTrans_StrDone = new Dictionary(); + dicTrans_StrIds = new Dictionary(); + // Process Procedures + iStructureID = MigrateProcedures(cn,pth); + // Show any Missing Transtitons (i.e. Transitions which have not been processed) + ShowMissingTransitions(); + log.InfoFormat("Completed Migration of {0}",pth); + MessageBox.Show("Completed Migration of " + pth); + rofst.Close(); + cn.Close(); + dicTrans_StrDone.Clear(); + dicTrans_StrDone = null; + return iStructureID; + } + private Volian.CSLA.Library.VersionTypeEnum DocVersionType(string s) + { + if (s.EndsWith("approved")) return Volian.CSLA.Library.VersionTypeEnum.Approved; + if (s.EndsWith("chgsht")) return Volian.CSLA.Library.VersionTypeEnum.Revision; + if (s.EndsWith("tmpchg")) return Volian.CSLA.Library.VersionTypeEnum.Temporary; + return Volian.CSLA.Library.VersionTypeEnum.WorkingDraft; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/Documents.cs b/PROMS/proms/DataLoader/Documents.cs new file mode 100644 index 00000000..cea9db33 --- /dev/null +++ b/PROMS/proms/DataLoader/Documents.cs @@ -0,0 +1,114 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.MSWord; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private void SaveSectionDocument(string fname, string stpseq, ref byte ctype, ref int cid) + { + int docid = SaveWordDoc(fname); + switch (docid) + { + case 0: + // could add the following back in - but many of these may be put out in the log, and + // don't supply any pertinent info. + //log.InfoFormat("Timing problem for save of word document, will retry. oldstepsequence = {0}", stpseq); + break; + case -1: + log.ErrorFormat("Could not complete save of word document, oldstepsequence = {0}", stpseq); + break; + default: + ctype = 2; + cid = docid; + break; + } + } + private int SaveWordDoc(string fname, string title, ConfigInfo ci) + { + int docid = 0; + if (System.IO.File.Exists(fname)) + { + if (cbSaveDoc.Checked) + { + WordDoc d = new WordDoc(fname); + string temppath = Path.GetTempFileName(); + string s = d.Save(temppath); + d.Close(); + WaitMS(wms); + docid = SaveDoc(temppath, title, ci); + File.Delete(temppath); + } + else + { + if (cbSaveRTF.Checked) + docid = SaveDoc(fname, title, ci); + } + } + return docid; + } + private int SaveWordDoc(string temppath) + { + return SaveWordDoc(temppath, String.Empty, null); + } + private int SaveTheDoc(string temppath, string title, ConfigInfo ci) + { + try + { + FileStream fs = File.Open(temppath, FileMode.Open, FileAccess.Read, FileShare.None); + long len = fs.Length + 1; + byte[] ByteArray = new byte[len]; + int nBytesRead = fs.Read(ByteArray, 0, (int)len); + fs.Close(); + string t1 = (title == null || title == "") ? "notitle" : title; + Document doc = Document.MakeDocument(t1, ByteArray, null, ci == null ? null : ci.ToString()); + return doc.DocID; + } + // for an io exception, keep trying + catch (IOException) + { + Wait(2); + return 0; + } + catch (Exception ex) + { + log.Error("Save Word Doc"); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + return -1; + } + + } + private int SaveDoc(string temppath, string title, ConfigInfo ci) + { + int done = 0; + int ntry = 0; + while (done == 0 && ntry < 4) + { + ntry++; + done = SaveTheDoc(temppath, title, ci); + } + return done; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/FolderTreeNode.cs b/PROMS/proms/DataLoader/FolderTreeNode.cs new file mode 100644 index 00000000..f65671e9 --- /dev/null +++ b/PROMS/proms/DataLoader/FolderTreeNode.cs @@ -0,0 +1,110 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Collections.Generic; +using System.Text; +using Volian.CSLA.Library; +using Csla; +using System.Windows.Forms; + +namespace DataLoader +{ + public class FolderTreeNode : TreeNode + { + FolderTreeNode(string s) : base(s) + { + this.Name="ID:" + s; + } + FolderTreeNode(FolderInfo folderinfo) + : base(folderinfo.Name) + { + _folderinfo = folderinfo; + this.Name = "ID:" + folderinfo.FolderID.ToString(); + } + private FolderInfo _folderinfo; + public FolderInfo FolderInfo + { + get { return _folderinfo; } + set + { + _folderinfo = value; + } + } + private Dictionary _findTree = null; + private Dictionary FindTree + { + get { return _findTree; } + set { _findTree = value; } + } + public FolderTreeNode FindTreeNode(int folderID) + { + if (_findTree != null) return _findTree[folderID]; + return null; + } + public static FolderTreeNode BuildTreeList() + { + FolderTreeNode root = null; + FolderInfoList fil = FolderInfoList.Get(); + Dictionary dicMissing = new Dictionary(); + Dictionary dicExists = new Dictionary(); + foreach (FolderInfo fi in fil) + { + FolderTreeNode ftp = null; + if (dicExists.ContainsKey(fi.ParentID)) + { + ftp = dicExists[fi.ParentID]; + // dicNeedToLoad.Remove(ftp); + } + else + { + if (fi.ParentID != 0) + { + ftp = new FolderTreeNode(fi.ParentID.ToString()); + dicMissing.Add(fi.ParentID, ftp); + dicExists.Add(fi.ParentID, ftp); + if (fi.DocVersionCount > 0) + { + TreeNode tn = new TreeNode("dummy"); + tn.Tag = "dummy"; + ftp.Nodes.Add(tn); + } + } + } + FolderTreeNode ft = null; + if (dicMissing.ContainsKey(fi.FolderID)) + { + ft = dicMissing[fi.FolderID]; + ft.FolderInfo = fi; + dicMissing.Remove(fi.FolderID); + } + else + { + ft = new FolderTreeNode(fi); + if (fi.DocVersionCount > 0) + { + TreeNode tn = new TreeNode("dummy"); + tn.Tag = "dummy"; + ft.Nodes.Add(tn); + } + dicExists.Add(fi.FolderID, ft); + //dicNeedToLoad.Add(ft); + } + ft.Tag = fi; + if (fi.ParentID == 0) + root = ft; + else + ftp.Nodes.Add(ft); + } + root.FindTree = dicExists; + return root; + } + } +} + diff --git a/PROMS/proms/DataLoader/GroupProp.Designer.cs b/PROMS/proms/DataLoader/GroupProp.Designer.cs new file mode 100644 index 00000000..87548d7f --- /dev/null +++ b/PROMS/proms/DataLoader/GroupProp.Designer.cs @@ -0,0 +1,110 @@ +namespace DataLoader +{ + partial class GroupProp + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.lbGroups = new System.Windows.Forms.ListBox(); + this.pg = new System.Windows.Forms.PropertyGrid(); + this.btnSave = new System.Windows.Forms.Button(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.lbGroups); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.pg); + this.splitContainer1.Panel2.Controls.Add(this.btnSave); + this.splitContainer1.Size = new System.Drawing.Size(629, 290); + this.splitContainer1.SplitterDistance = 209; + this.splitContainer1.TabIndex = 0; + // + // lbGroups + // + this.lbGroups.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbGroups.FormattingEnabled = true; + this.lbGroups.Location = new System.Drawing.Point(0, 0); + this.lbGroups.Name = "lbGroups"; + this.lbGroups.Size = new System.Drawing.Size(209, 290); + this.lbGroups.TabIndex = 0; + this.lbGroups.Click += new System.EventHandler(this.lbGroups_Click); + // + // pg + // + this.pg.Dock = System.Windows.Forms.DockStyle.Fill; + this.pg.Location = new System.Drawing.Point(0, 23); + this.pg.Name = "pg"; + this.pg.Size = new System.Drawing.Size(416, 267); + this.pg.TabIndex = 0; + // + // btnSave + // + this.btnSave.Dock = System.Windows.Forms.DockStyle.Top; + this.btnSave.Location = new System.Drawing.Point(0, 0); + this.btnSave.Name = "btnSave"; + this.btnSave.Size = new System.Drawing.Size(416, 23); + this.btnSave.TabIndex = 1; + this.btnSave.Text = "Save"; + this.btnSave.UseVisualStyleBackColor = true; + this.btnSave.Click += new System.EventHandler(this.btnSave_Click); + // + // GroupProp + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(629, 290); + this.Controls.Add(this.splitContainer1); + this.Name = "GroupProp"; + this.Text = "GroupProp"; + this.Load += new System.EventHandler(this.GroupProp_Load); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.ListBox lbGroups; + private System.Windows.Forms.PropertyGrid pg; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/GroupProp.cs b/PROMS/proms/DataLoader/GroupProp.cs new file mode 100644 index 00000000..5e21bea1 --- /dev/null +++ b/PROMS/proms/DataLoader/GroupProp.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using Csla; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class GroupProp : Form + { + GroupInfoList glst; + Group grp; + public GroupProp() + { + InitializeComponent(); + } + private void GroupProp_Load(object sender, EventArgs e) + { + lbGroups.Dock = DockStyle.Fill; + glst = GroupInfoList.Get(); + lbGroups.DataSource = glst; + lbGroups.DisplayMember = "GroupName"; + lbGroups.ValueMember = "GID"; + SetGroup(); + } + private void lbGroups_Click(object sender, EventArgs e) + { + SetGroup(); + Console.WriteLine("Group ID = {0}", lbGroups.SelectedValue); + } + private void SetGroup() + { + grp = glst[lbGroups.SelectedIndex].Get(); + pg.SelectedObject = grp; + } + private void btnSave_Click(object sender, EventArgs e) + { + grp.Save(); + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/GroupProp.resx b/PROMS/proms/DataLoader/GroupProp.resx new file mode 100644 index 00000000..19dc0dd8 --- /dev/null +++ b/PROMS/proms/DataLoader/GroupProp.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/proms/DataLoader/LibDoc.cs b/PROMS/proms/DataLoader/LibDoc.cs new file mode 100644 index 00000000..770f7040 --- /dev/null +++ b/PROMS/proms/DataLoader/LibDoc.cs @@ -0,0 +1,153 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.MSWord; +using vlnObjectLibrary; +using vlnServerLibrary; +using Org.Mentalis.Files; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private void UpdateLabelsLibDocs(int incLib, int incUsages) + { + if (incLib == 0 && incUsages == 0)//Reset + { + lblTime.Tag = DateTime.Now; + pbProc.Value = 0; + pbSect.Value = 0; + } + else + { + pbProc.Value += incLib; + pbSect.Value += incUsages; + } + lblProc.Text = string.Format("{0} Lib Docs", pbProc.Value); + lblSection.Text = string.Format("{0} Usages", pbSect.Value); + lblStep.Text = ""; + TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ((DateTime)lblTime.Tag).Ticks); + lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds); + Application.DoEvents(); + } + private void MigrateLibDocs(OleDbConnection cn, string pth) + { + // Get all of the library documents - the first list has the entire list of files + // found within the rtffiles folder, the second list contains usages from the 'tran' + // file. During processing for procedures/sections occurs, the used library documents + // will be migrated. After that, any remaining library documents will be added to + // the section table without a reference from the structuretbl. + Dictionary dicLibDocSect = new Dictionary(); + UpdateLabelsLibDocs(0, 0); + if (Directory.Exists(pth + "\\rtffiles")) + { + DirectoryInfo di = new DirectoryInfo(pth + "\\RTFFILES"); + FileInfo[] fis = di.GetFiles("DOC_*.LIB"); + pbProc.Maximum = fis.Length; + foreach (FileInfo fi in fis) + { + UpdateLabelsLibDocs(1, 0); + dicLibDocSect[fi.Name.Substring(0, 8).ToUpper()] = MigrateLibDoc(fi); + } + } + dicLibDocRef = new Dictionary(); + OleDbDataAdapter da_doc = new OleDbDataAdapter("select [FROMNUMBER], [FROMSEQUEN], [TONUMBER] from [tran] where [TONUMBER] LIKE 'doc_%' or [TONUMBER] like 'DOC_%'", cn); + DataSet ds_doc = new DataSet(); + da_doc.Fill(ds_doc); + pbSect.Maximum = ds_doc.Tables[0].Rows.Count; + foreach (DataRow dr_doc in ds_doc.Tables[0].Rows) + { + UpdateLabelsLibDocs(0, 1); + string key = dr_doc["FROMNUMBER"].ToString().PadRight(20) + dr_doc["FROMSEQUEN"].ToString().PadRight(10); + if (!dicLibDocSect.ContainsKey(dr_doc["TONUMBER"].ToString().ToUpper())) + log.ErrorFormat("Error setting library document references: {0}", dr_doc["TONUMBER"].ToString().ToUpper()); + else + dicLibDocRef[key] = dicLibDocSect[dr_doc["TONUMBER"].ToString().ToUpper()]; + } + da_doc.Dispose(); + } + private int MigrateLibDoc(FileInfo fi) + { + ConfigInfo ci = new ConfigInfo(null); + string title = null; // for docname, remove the '.lib', i.e. substring(0,8) + DateTime dts = DateTime.Now; + string tmpRtfFileName = GetLibDocData(fi, ci, ref title); + int Docid = SaveWordDoc(tmpRtfFileName, title, ci); + File.Delete(tmpRtfFileName); + return Docid; + } + private string LoadFromLib(BinaryReader br) + { + int nchar = br.ReadInt16(); + if (nchar > 0) + { + string tmp = new string(br.ReadChars(nchar)); + return tmp.Substring(0, tmp.Length - 1); // remove null at end. + } + return null; + } + private string GetLibDocData(FileInfo fi, ConfigInfo ci, ref string title) + { + title = null; + // get the number, title, etc from the file. + // use the path to open the file & read the title & comment + DateTime dts = fi.LastWriteTime; + FileStream fs = fi.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + BinaryReader br = new BinaryReader(fs, System.Text.ASCIIEncoding.ASCII); + string tmpRtfFileName = Path.GetTempFileName(); + FileStream tmpfile = new FileStream(tmpRtfFileName, FileMode.Create); + BinaryWriter bw = new BinaryWriter(tmpfile, System.Text.Encoding.ASCII); + int cntPage = br.ReadInt16(); + if (cntPage != -1) + { // Not End of File + ci.AddItem("Section", "NumPages", cntPage.ToString()); + string ldtitle = LoadFromLib(br); + if (ldtitle != null && ldtitle != "") title = ldtitle; + ci.AddItem("LibDoc", "Comment", LoadFromLib(br)); + long l = br.BaseStream.Length - br.BaseStream.Position; + byte[] buf = new byte[l]; + br.Read(buf, 0, (int)l); + bw.Write(buf, 0, (int)l); + // TODO: Check with KBR to see if she needed read/write this way + // I can't remember. + //byte ac; + //bool done = false; + //while (done == false) + //{ + // if (br.PeekChar() > 0) + // { + // ac = br.ReadByte(); + // bw.Write(ac); + // } + // else + // done = true; + //} + br.Close(); + fs.Close(); + bw.Close(); + tmpfile.Close(); + WaitMS(wms); // give it some time to close the tempfile before adding section + File.SetLastWriteTime(tmpRtfFileName, dts); + } + return tmpRtfFileName; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/LoadConfig.cs b/PROMS/proms/DataLoader/LoadConfig.cs new file mode 100644 index 00000000..627b8f07 --- /dev/null +++ b/PROMS/proms/DataLoader/LoadConfig.cs @@ -0,0 +1,198 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace Config +{ + public class ConfigFile + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region MigrateStrings + // the following lists are used for storing the element and attribute names + // for migrating of ini & cfg files. The names stored in these lists are + // those that should be migrated. If not in this list, the data (either element + // or attribute name) is prefaced with a 'z'. At some point in the future, those + // names with a 'z' will be removed. + public List listIni_EleName = new List(); + public List listIni_AttrName = new List(); + private void SetIniEleName() + { + // veproms.ini + listIni_EleName.Add("graphics"); + listIni_EleName.Add("color"); + listIni_EleName.Add("print"); + listIni_EleName.Add("startup"); + listIni_EleName.Add("data integrity"); + listIni_EleName.Add("wordprocessor"); + listIni_EleName.Add("procedurelisttabstops"); + + // proc.ini + listIni_EleName.Add("rodefaults"); + listIni_EleName.Add("display"); + listIni_EleName.Add("backgrounddefaults"); + + // .cfg + listIni_EleName.Add("spelldictionary"); + // listIni_EleName.Add("wordprocessor"); - already in here. + } + + private void SetIniAttrName() + { + //veproms.ini + listIni_AttrName.Add("defaultext"); + listIni_AttrName.Add("ro"); + listIni_AttrName.Add("editbackground"); + listIni_AttrName.Add("black"); + listIni_AttrName.Add("blue"); + listIni_AttrName.Add("green"); + listIni_AttrName.Add("cyan"); + listIni_AttrName.Add("red"); + listIni_AttrName.Add("magenta"); + listIni_AttrName.Add("brown"); + listIni_AttrName.Add("lightgray"); + listIni_AttrName.Add("darkgray"); + listIni_AttrName.Add("ligthblue"); + listIni_AttrName.Add("lightgreen"); + listIni_AttrName.Add("lightcyan"); + listIni_AttrName.Add("lightred"); + listIni_AttrName.Add("lightmagenta"); + listIni_AttrName.Add("yellow"); + listIni_AttrName.Add("white"); + listIni_AttrName.Add("underlinewidth"); + listIni_AttrName.Add("verticalOffset"); + listIni_AttrName.Add("strokewidth"); + listIni_AttrName.Add("strokewidthbold"); + listIni_AttrName.Add("messageboxtitle"); + listIni_AttrName.Add("messagefile"); + listIni_AttrName.Add("enableindexcheck"); + listIni_AttrName.Add("wordwrap"); + listIni_AttrName.Add("procedurenumbertab"); + listIni_AttrName.Add("proceduretitletab"); + + // proc.ini + listIni_AttrName.Add("setpoint"); + listIni_AttrName.Add("graphics"); + listIni_AttrName.Add("ropath"); + listIni_AttrName.Add("display"); + listIni_AttrName.Add("sectiontitle"); + listIni_AttrName.Add("sectionnumber"); + + // .cfg + listIni_AttrName.Add("custom"); + listIni_AttrName.Add("page"); + listIni_AttrName.Add("toolbar"); + listIni_AttrName.Add("paragraph"); + listIni_AttrName.Add("ruler"); + listIni_AttrName.Add("userphone1"); + listIni_AttrName.Add("userphone2"); + listIni_AttrName.Add("userloc1"); + listIni_AttrName.Add("userloc2"); + } + #endregion + #region LoadDataCode + public ConfigFile() + { + } + public void LoadUsrCfg(User user) + { + string cmdline = System.Environment.CommandLine; + string cfgpath = cmdline.Substring(1, cmdline.LastIndexOf("\\") - 1) + "\\config"; + if (!Directory.Exists(cfgpath)) + { + log.Info("No user cfgs found in config directory - did not migrate any user cfgs"); + return; + } + DirectoryInfo di = new DirectoryInfo(cfgpath); + FileInfo[] fis = di.GetFiles("*.cfg"); + + foreach (FileInfo fi in fis) + { + string cfgname = fi.Name.Substring(0, fi.Name.IndexOf(".")); + if (cfgname.ToUpper() == user.UserID.ToUpper()) + { + // Get Users table fields by reading the cfg file into a buffer & looking + // for the UserNetworkId and UserName fields. + StreamReader myReader = new StreamReader(fi.FullName); + string sLine; + string UserLogin = null; + string UserName = null; + int indx = -1; + while ((sLine = myReader.ReadLine()) != null && (UserLogin == null || UserName == null)) + { + if (sLine.Length > 0 && sLine.Substring(0, 1) != ";") + { + if ((indx = sLine.ToLower().IndexOf("usernetworkid")) >= 0) + { + indx = sLine.IndexOf("=", indx + 13); + UserLogin = sLine.Substring(indx + 1, sLine.Length - indx - 1).Trim(); + } + else if ((indx = sLine.ToLower().IndexOf("username")) >= 0) + { + indx = sLine.IndexOf("=", indx + 8); + UserName = sLine.Substring(indx + 1, sLine.Length - indx - 1).Trim(); + } + } + } + myReader.Close(); + + // get the xml to set the config field + XmlDocument d = IniToXml(fi.FullName); + user.Config = d == null ? null : d.InnerXml; + user.UserLogin = UserLogin; + user.UserName = UserName; + user.CFGName = cfgname; + break; + } + } + } + + public XmlDocument LoadSystemIni() + { + string cmdline = System.Environment.CommandLine; + string inipath = cmdline.Substring(1, cmdline.LastIndexOf("\\") - 1) + "\\veproms.ini"; + if (!File.Exists(inipath)) + { + log.InfoFormat("Did not migrate {0} - file not found", inipath); + return null; + } + XmlDocument d = IniToXml(inipath); + return d; + } + + public XmlDocument IniToXml(string path) + { + FileInfo fi = new FileInfo(path); + if (fi.Exists) + { + PrivateProfile ppCfg; + if (listIni_AttrName == null || listIni_AttrName.Count == 0) SetIniAttrName(); + if (listIni_EleName == null || listIni_EleName.Count == 0) SetIniEleName(); + ppCfg = new PrivateProfile(path, listIni_EleName, listIni_AttrName); + return ppCfg.XML(); + } + return null; + } + #endregion + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/LoadTreeDB.cs b/PROMS/proms/DataLoader/LoadTreeDB.cs new file mode 100644 index 00000000..b1cefd92 --- /dev/null +++ b/PROMS/proms/DataLoader/LoadTreeDB.cs @@ -0,0 +1,111 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; +using vlnObjectLibrary; +using vlnServerLibrary; +using Org.Mentalis.Files; +using Config; +using Utils; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private List vlnDataPathFolders() // was vlnDataPath + { + List dpf = new List(); + // Get path to config file + string sCfg = Environment.GetEnvironmentVariable("veconfig"); + IniReader cfg = new IniReader(sCfg); + // Get DataPath + string sDP = cfg.ReadString("menu", "DataPath"); + // Split DataPath into directories + foreach (string s1 in sDP.Split(";".ToCharArray())) + { + if (s1.Length > 0) + { + string[] s2 = s1.Split(",".ToCharArray()); + Folder fld = Folder.MakeFolder(sysFolder.FolderID, dbConn.DBID, s2[1], s2[0], null); + dpf.Add(fld); + } + } + return dpf; + } + private int cslaObject(vlnObject vb, int dbid, int parentid, TreeNode tn) + { + switch (vb.Type) + { + case "plant": + case "set": + Folder fld = Folder.MakeFolder(parentid, dbid, vb.Title, vb.Path, string.Empty); + tn.Tag = fld; + return fld.FolderID; + case "version": + ConfigFile cfg = new ConfigFile(); + + XmlDocument d = cfg.IniToXml(vb.Path + "\\proc.ini"); + FolderConfig fld_cfg = new FolderConfig(d==null?"":d.InnerXml); + // translate curset.dat into xml & add to d (somehow). + string csfile = string.Format("{0}\\curset.dat",vb.Path); + if (File.Exists(csfile)) + { + CurSet cs = new CurSet(csfile); + try + { + fld_cfg = cs.Convert(fld_cfg); + } + catch (Exception ex) + { + log.ErrorFormat("error in convert curset.dat, ex = {0}", ex.Message); + } + } + string titlepath = vb.Path + "\\" + "Title"; + FileInfo fi = new FileInfo(titlepath); + string thetitle = vb.Title; + if (File.Exists(titlepath)) + { + StreamReader myReader = new StreamReader(titlepath); + thetitle = myReader.ReadLine(); + myReader.Close(); + } + DocVersion v = DocVersion.MakeDocVersion(parentid, (int)DocVersionType(vb.Path.ToLower()), thetitle, vb.Path, 0, fld_cfg == null ? null : fld_cfg.ToString()); + tn.Tag = v; + return v.VersionID; + } + return 0; + } + private void MigrateChildren(vlnObject vb, vlnServer vs, int dbid, int parentid, TreeNode tn) + { + if (vb.Type != "version") + { + vb.LoadChildren(vs.GetChildren(vb.ToString())); + List lv = vb.Children; + foreach (vlnObject vbc in lv) + { + TreeNode tnc = tn.Nodes.Add(vbc.Title); + int idc = cslaObject(vbc, dbid, parentid, tnc); + MigrateChildren(vbc, vs, dbid, idc, tnc); + } + } + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/LoadTreeNh.cs b/PROMS/proms/DataLoader/LoadTreeNh.cs new file mode 100644 index 00000000..83e44b49 --- /dev/null +++ b/PROMS/proms/DataLoader/LoadTreeNh.cs @@ -0,0 +1,43 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private bool LoadChildren(FolderInfo fld, TreeNode tn) + { + tn.Nodes.Clear(); + bool bLoaded = true; + foreach (DocVersionInfo fdv in fld.DocVersions) + { + TreeNode tnc = tn.Nodes.Add(fdv.Title); + tnc.Tag = fdv; + tnc.Checked = fdv.StructureID != 0; + bLoaded &= tnc.Checked; + } + return bLoaded; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/PrivateProfile.cs b/PROMS/proms/DataLoader/PrivateProfile.cs new file mode 100644 index 00000000..0310fce3 --- /dev/null +++ b/PROMS/proms/DataLoader/PrivateProfile.cs @@ -0,0 +1,274 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.IO; +using System.Xml; +using System.Collections.Specialized; +using System.Collections.Generic; + +namespace Config +{ + /// + /// PrivateProfile opens a private profile string and stores it's contents in an xml document. + /// + public class PrivateProfile + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + + private string ppName; + private XmlDocument ppXml; + private List attr; + private List ele; + + private XmlNode AddNode(XmlNode xParent, string sName, string sValue ) + { + XmlNode nd=AddNode(xParent,sName); + nd.Value=sValue; + return nd; + } + private XmlNode AddNode(XmlNode xParent, string sName) + { + XmlNode nd; + // Add a node + string tsName = sName.Replace(' ', '_'); + nd=xParent.OwnerDocument.CreateNode(System.Xml.XmlNodeType.Element,tsName,""); + xParent.AppendChild(nd); + return nd; + } + private void AddAttribute(XmlNode xParent, string sName, string sValue ) + { + XmlNode xa=xParent.Attributes.GetNamedItem(sName); + // bug fix. 09/15/03 + // If there was a space after an equal sign, that space character + // was becomming part of the value string (reading the user.CFG file). + // This was giving us a "Must have semi-colon" error message. + // We now strip spaces before and after any Attribute that is written. + sValue = sValue.Trim(' '); + sName = sName.Replace(' ', '_'); + + // Add an attribute + if(sValue=="") + { + if(xa != null) + { + xParent.Attributes.RemoveNamedItem(sName); + } + } + else + { + if(xa == null) + { + xa = xParent.OwnerDocument.CreateNode(System.Xml.XmlNodeType.Attribute ,sName,""); + xParent.Attributes.SetNamedItem(xa); + } + xa.Value=sValue; + } + + } + private XmlNode AddSection(XmlNode xParent, string sSection ) + { + // get the name. If it's not in the 'migrated elements' list, then + // preface the name with a 'z'. + string elename = sSection.Substring(1, sSection.IndexOf("]") - 1); + while(elename.IndexOf(' ')>-1) elename = elename.Remove(elename.IndexOf(' '),1); + if (!ele.Contains(elename.ToLower())) elename = 'z' + elename; + // Add a section [name] + XmlNode nd = AddNode(xParent, elename); + //AddAttribute(nd,"name",sSection.Substring(1,sSection.IndexOf("]")-1)); + return nd; + } + private XmlNode AddSection_UC(XmlNode xParent, string sSection ) + { + // Add a section [name] + string name_uc = sSection.Substring(1,sSection.IndexOf("]")-1).ToUpper() + "__UC"; + XmlNode nd =AddNode(xParent,name_uc); + // AddAttribute(nd,"name",name_uc); + return nd; + } + private void AddComment(XmlNode xParent, string sComment) + { + + if(xParent.ChildNodes.Count > 0) + { + XmlNode ndlast=xParent.ChildNodes.Item(xParent.ChildNodes.Count-1); + if(ndlast.Name=="comment") + { + XmlNode xa = ndlast.Attributes.GetNamedItem("text"); + xa.Value=xa.Value + "\r\n" + sComment; + return; + } + } + // Add a comment text + XmlNode nd =AddNode(xParent,"comment"); + AddAttribute(nd,"text",sComment); + } + private void AddLine(XmlNode xParent, string sLine) + { + // Add a comment text + XmlNode nd =AddNode(xParent,"line"); + AddAttribute(nd,"text",sLine); + } + private void AddParam(XmlNode xParent, string sParam) + { + int i = sParam.IndexOf("="); + // get the name. If it's not in the 'migrated attribute' list, then + // preface the name with a 'z'. + string attrname = sParam.Substring(0, i); + while (attrname.IndexOf(' ') > -1) attrname = attrname.Remove(attrname.IndexOf(' '), 1); + if (!attr.Contains(attrname.ToLower())) attrname = 'z' + attrname; + string sValue=sParam.Substring(i+1); + string sName = attrname.Trim(' '); + AddAttribute(xParent, sName, sValue); + } + private void AddParam_UC(XmlNode xParent, string sParam) + { + int i = sParam.IndexOf("="); + // add a param name=value + string sName=sParam.Substring(0,i); + string sValue=sParam.Substring(i+1); + //XmlNode nd =AddNode(xParent,"paramUC"); + sName = sName.Trim(' '); + AddAttribute(xParent, sName, sValue); + //AddAttribute(nd,"name",sName.ToUpper()+"__UC"); + //AddAttribute(nd,"value",sValue); + } + private void LoadXML() + { + string sLine; + ppXml.LoadXml("");// initialize ppXml + XmlNode xmlTop=ppXml.DocumentElement; + XmlNode xmlNd=ppXml.DocumentElement; + //XmlNode xmlNd_UC=ppXml.DocumentElement; + StreamReader myReader = new StreamReader(ppName);// Open file + while( (sLine = myReader.ReadLine())!= null)// read line-by-line + { + // add structure + try + { + if (sLine.Length > 0) + { + switch (sLine.Substring(0, 1)) + { + case "[": + xmlNd = AddSection(xmlTop, sLine); + //xmlNd_UC=AddSection_UC(xmlTop, sLine); + break; + case ";": + //AddComment(xmlNd, sLine); + break; + default: + if (sLine.IndexOf("=") >= 0) + { + AddParam(xmlNd, sLine); + //AddParam_UC(xmlNd_UC, sLine); + } + else + { + //AddLine(xmlNd, sLine); + } + break; + } + } + } + catch (Exception ex) + { + log.ErrorFormat("error parsing .INI file: {0} - Directory: {1}", ex.Message,ppName); + } + } + myReader.Close(); + } + public PrivateProfile(string sFileName, List listIni_EleName, List listIni_AttrName) + { + ppName=sFileName; + ppXml= new XmlDocument(); + attr = listIni_AttrName; + ele = listIni_EleName; + LoadXML(); + } + ~PrivateProfile() + { + // Clean-up + // + } + public string PrettyNode(XmlNode nd,int level) + { + string retval=""; + string prefix=new string(' ',level*2); + if(nd.ChildNodes.Count > 0) + { + retval = prefix + "<" + nd.Name; + for(int i=0;i"; + for(int i=0;i"; + } + else + { + retval = prefix + "<" + nd.Name; + for(int i=0;i"; + } + return retval; + } + public string PrettyXML() + { + return PrettyNode(ppXml.DocumentElement,0); + } + public XmlDocument XML() + { + // return XML Document + return ppXml; + } + public override string ToString() + { + // return string + return ""; + } + public void Save() + { + SaveAs(ppName); + } + public void SaveAs(string sName) + { + } + public string Attr(string sPath) + { + string retval=""; + XmlNode xn = ppXml.SelectSingleNode(sPath); + if(xn != null) + { + string quots = xn.Value; + if (quots.Substring(0,1)=="\"" && quots.Substring(quots.Length-1,1)=="\"") + retval = quots.Substring(1,quots.Length-2); + else + retval=xn.Value; + } + return retval; + } + + public string Attr(string sSection, string sParameter) + { + string findstr = "/ini/sectionUC[@name='" + sSection.ToUpper() + "__UC']/paramUC[@name='" + sParameter.ToUpper() + "__UC']/@value"; + return Attr(findstr); + } + } +} diff --git a/PROMS/proms/DataLoader/Procedures.cs b/PROMS/proms/DataLoader/Procedures.cs new file mode 100644 index 00000000..c80ac4f9 --- /dev/null +++ b/PROMS/proms/DataLoader/Procedures.cs @@ -0,0 +1,189 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private Int32 MigrateProcedure(OleDbConnection cn, DataRow dr, Byte FromType, Int32 FromID, string pth) + { + dicOldStepSequence = new Dictionary(); + Stack SubSectLevels = new Stack(); // levels of subsections + ProcFileName = dr["Entry"].ToString(); + ProcNumber = dr["Number"].ToString(); + DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString()); + string userid = dr["initials"].ToString().Trim(); + + ConfigInfo ci = null; + string tstr = dr["Proccode"].ToString(); + if (tstr != null && tstr != "") + { + ci = new ConfigInfo(null); + ci.AddItem("Procedure", "ProcCode", tstr); + } + tstr = dr["Series"].ToString(); + if (tstr != null && tstr != "") + { + if (ci == null) ci = new ConfigInfo(null); + ci.AddItem("Procedure", "Series", tstr); + } + + DataSet ds = new DataSet(); + DataTable dt = null; + + // See if there is PSI and if so, add it to the xml. + OleDbDataAdapter dapsi = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where [STEP] is null", cn); + dapsi.Fill(ds); + dt = ds.Tables[0]; + + if (dt.Rows.Count > 0) + { + DataRow drpsi = dt.Rows[0]; + string psistr = drpsi["TEXTM"].ToString(); + if (psistr != null && psistr != "") + { + StringReader strrd = new StringReader(psistr); + + string sLine; + if (ci == null) ci = new ConfigInfo(null); + while ((sLine = strrd.ReadLine()) != null) + { + int indx = sLine.IndexOf(' '); + string nm = null; + string vl = null; + if (indx < 0) + nm = sLine; + else + { + nm = sLine.Substring(0, indx); + vl = sLine.Substring(indx+1, sLine.Length-indx-1); + } + ci.AddItem("PSI", nm, vl==null?null:vl); + } + } + } + dapsi.Dispose(); + + // Note, for now the data from the format field will be saved. Later, xpath, ?? + EditSectId = 0; + + Byte FrType = 2; + Int32 FrID = 0;// str.Structureid; + Procedure prc = Procedure.MakeProcedure(TextConvert.ConvertText(dr["Number"].ToString()), TextConvert.ConvertText(dr["Title"].ToString()), ci==null?null:ci.ToString(), null, 0, 0, dts, userid); + Structure str = Structure.MakeStructure(FromType, FromID, 1, prc.ProcID, dts, userid); + UpdateLabels(1, 0, 0); + //OleDbDataAdapter da = new OleDbDataAdapter("select * from (select asc(mid(sequence,2,1)) as locb,* from [" + dr["entry"] + "] where sequence like ' %') order by locb asc", cn); + OleDbDataAdapter da = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where sequence like ' %'", cn); + try + { + LoadSection(ds, da, dr["entry"].ToString()); + da.SelectCommand.CommandText = "select * from [" + dr["entry"] + "] where step not like ' '"; + da.Fill(ds, "Steps"); + dt = ds.Tables["Steps"]; + dt.CaseSensitive = true; + ds.Tables["Steps"].CaseSensitive = true; + dt.Columns.Add("CStep", System.Type.GetType("System.String")); + dt.Columns.Add("CSequence", System.Type.GetType("System.String")); + // set the cstep & csequence - couldn't do it in the add because it needed a sql function + foreach (DataRow drw in ds.Tables["Steps"].Rows) + { + drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString()); + drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString()); + } + dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48"); + dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)"); + dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48"); + } + catch (Exception ex) + { + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + log.Error(ex.StackTrace); + } + + Dictionary dicSecCount = new Dictionary(); + Dictionary dicSecID = new Dictionary(); + pbSect.Maximum = ds.Tables["Sections"].Rows.Count; + pbSect.Value = 0; + + DataTable dtsect = ds.Tables["Sections"]; + dtsect.CaseSensitive = true; + DataView dv = new DataView(dtsect, "", "locb", DataViewRowState.CurrentRows); + foreach (DataRowView drw in dv) + { + FrID = MigrateSection(prc, cn, drw, ds.Tables["Steps"], FrType, FrID, dicSecCount.Count > 0 ? true : false, pth); + if (prc.StructureID == 0) + { + prc.StructureID = FrID; + prc.Save(true); //force update + } + FrType = 0; + dicSecID[dicSecCount.Count] = FrID; + if (dicSecCount.Count > 0) + { + if ((dicSecCount[dicSecCount.Count]) == 1) + { + dicSecCount.Remove(dicSecCount.Count); + FrID = dicSecID[dicSecCount.Count]; + } + else + { + dicSecCount[dicSecCount.Count] = dicSecCount[dicSecCount.Count] - 1; + } + } + int subSecs = drw["Sequence"].ToString().PadRight(12, ' ')[5] - 48; + if (subSecs > 0) + { + dicSecCount[dicSecCount.Count + 1] = subSecs; + FrType = 2; + } + } + if (EditSectId != 0) + { + prc.StructureStart = EditSectId; + EditSectId = 0; + prc.Save(true); // force update + } + return str.StructureID; + } + private Int32 MigrateProcedures(OleDbConnection cn, string pth) + { + // Loop through Set File for each Procedure + OleDbDataAdapter da = new OleDbDataAdapter("Select * from [set] where entry is not null", cn); + DataSet ds = new DataSet(); + da.Fill(ds); + Byte FrType = 1; + Int32 FrID = 0; + Int32 FirstID = 0; + pbProc.Maximum = ds.Tables[0].Rows.Count; + UpdateLabels(0, 0, 0); + foreach (DataRow dr in ds.Tables[0].Rows) + { + FrID = MigrateProcedure(cn, dr, FrType, FrID, pth); + if (FirstID == 0) FirstID = FrID; + FrType = 0; + } + da.Dispose(); + return FirstID; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/Program.cs b/PROMS/proms/DataLoader/Program.cs new file mode 100644 index 00000000..5ba04ba7 --- /dev/null +++ b/PROMS/proms/DataLoader/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + + +namespace DataLoader +{ + static class Program + { + // + //The main entry point for the application. + // + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmLoader()); + } + } +} diff --git a/PROMS/proms/DataLoader/Properties/AssemblyInfo.cs b/PROMS/proms/DataLoader/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..ee29bd60 --- /dev/null +++ b/PROMS/proms/DataLoader/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DataLoader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("DataLoader")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bcf6964e-0a2b-4e99-8dde-2dd62366294c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/DataLoader/Properties/Resources.Designer.cs b/PROMS/proms/DataLoader/Properties/Resources.Designer.cs new file mode 100644 index 00000000..d83fa092 --- /dev/null +++ b/PROMS/proms/DataLoader/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DataLoader.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DataLoader.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/PROMS/proms/DataLoader/Properties/Resources.resx b/PROMS/proms/DataLoader/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/PROMS/proms/DataLoader/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/proms/DataLoader/Properties/Settings.Designer.cs b/PROMS/proms/DataLoader/Properties/Settings.Designer.cs new file mode 100644 index 00000000..9802b8b8 --- /dev/null +++ b/PROMS/proms/DataLoader/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DataLoader.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/PROMS/proms/DataLoader/Properties/Settings.settings b/PROMS/proms/DataLoader/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/PROMS/proms/DataLoader/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/PROMS/proms/DataLoader/ROFST.cs b/PROMS/proms/DataLoader/ROFST.cs new file mode 100644 index 00000000..4698cb21 --- /dev/null +++ b/PROMS/proms/DataLoader/ROFST.cs @@ -0,0 +1,251 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Text; +using System.IO; +using System.Xml.Serialization; +using System.Xml; +using System.Xml.XPath; + +namespace DataLoader +{ + public class ROFST + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + [Serializable] + public struct roHdr + { + public int hSize; + public int hYear; + public byte hMonth; + public byte hDay; + public int hcYear; + public byte hcMonth; + public byte hcDay; + public byte hcHour; + public byte hcMin; + public byte hcSec; + public byte hcHund; + public rodbi[] myDbs; + }; + [Serializable] + public struct rodbi + { + public int dbiID; + public int dbiType; + public int dbiAW; + public string dbiTitle; + public string dbiAP; + public int ID; + public int ParentID; + public rochild[] children; + }; + public struct rogrp + { + public int ID; + public int ParentID; + public rochild[] children; + public string value; + public string appid; + }; + public struct rochild + { + public int ID; + public int ParentID; + public int type; + public string title; + public string roid; + public string appid; + public string value; + public rochild[] children; + }; + private roHdr myHdr; + private int TableID; + private string fstPath; + private HybridDictionary dicRos; + + public ROFST(string path) + { + fstPath = path; + if (!File.Exists(fstPath)) + { + log.ErrorFormat("RO FST Does not exist: {0}", path); + return; + } + dicRos = new HybridDictionary(); + ParseIntoDictionary(); + } + + public void Close() + { + // remove the dictionary + dicRos.Clear(); + dicRos = null; + } + + // this only gets rochild values. Later we may want another + // dictionary to get groups. + public string GetRoValue(string ROID) + { + // Use the ROID to get the value from the dictionary + if (dicRos.Contains(ROID)) + { + rochild rochld = (rochild)dicRos[ROID]; + return rochld.value; + } + return null; + } + + private int StringLength(byte[] ab, int offset) + { + int i = 0; + while (ab[i + offset] != 0) i++; + return i; + } + private rogrp LoadGroup(byte[] ab, int offset) + { + rogrp myGrp = new rogrp(); + myGrp.ID = BitConverter.ToInt32(ab, offset); + myGrp.ParentID = BitConverter.ToInt32(ab, offset + 4); + int howmany = BitConverter.ToInt16(ab, offset + 8); + if (howmany > 0) + { + myGrp.children = new rochild[howmany]; + int myOffset = offset + 10; + for (int i = 0; i < myGrp.children.Length; i++) + { + int childOffset = BitConverter.ToInt32(ab, myOffset); + rochild tmp = new rochild(); + //tmp.offset=BitConverter.ToInt32(ab,myOffset); + tmp.type = BitConverter.ToInt16(ab, myOffset + 4); + int slen = StringLength(ab, myOffset + 6); + tmp.title = Encoding.Default.GetString(ab, myOffset + 6, slen); + myOffset += (7 + slen); + rogrp tmpg = LoadGroup(ab, childOffset); + tmp.ID = tmpg.ID; + tmp.ParentID = tmpg.ParentID; + tmp.children = tmpg.children; + tmp.value = tmpg.value; + tmp.appid = tmpg.appid; + tmp.roid = TableID.ToString("X4") + tmp.ID.ToString("X8"); + dicRos.Add(tmp.roid, tmp); + int j; + for (j = i - 1; j >= 0 && tmp.ID < myGrp.children[j].ID; j--) + { + myGrp.children[j + 1] = myGrp.children[j]; + } + myGrp.children[j + 1] = tmp; + } + } + else + { + int slen = StringLength(ab, offset + 12); + myGrp.value = Encoding.Default.GetString(ab, offset + 12, slen); + int slen2 = StringLength(ab, offset + 13 + slen); + myGrp.appid = Encoding.Default.GetString(ab, offset + 13 + slen, slen2); + } + return myGrp; + } + + private void ParseIntoDictionary() + { + FileStream fsIn = new FileStream(fstPath, FileMode.Open,FileAccess.Read, FileShare.Read); + // Create an instance of StreamReader that can read + // characters from the FileStream. + BinaryReader r = new BinaryReader(fsIn); + byte[] ab = r.ReadBytes((int)fsIn.Length); + r.Close(); + + myHdr.hSize = BitConverter.ToInt32(ab, 0); + myHdr.hYear = BitConverter.ToInt16(ab, 4); + myHdr.hMonth = ab[6]; + myHdr.hDay = ab[7]; + myHdr.hcYear = BitConverter.ToInt16(ab, 8); + myHdr.hcMonth = ab[10]; + myHdr.hcDay = ab[11]; + myHdr.hcHour = ab[12]; + myHdr.hcMin = ab[13]; + myHdr.hcSec = ab[14]; + myHdr.hcHund = ab[15]; + int hdrOffset = BitConverter.ToInt32(ab, 16); + int howbig = BitConverter.ToInt32(ab, hdrOffset); + int dbs = BitConverter.ToInt16(ab, hdrOffset + 4); + myHdr.myDbs = new rodbi[dbs]; + for (int i = 0; i < dbs; i++) + { + int offset = hdrOffset + 6 + (i * 30); + myHdr.myDbs[i].dbiID = BitConverter.ToInt16(ab, offset + 0); + TableID = myHdr.myDbs[i].dbiID; + myHdr.myDbs[i].dbiType = BitConverter.ToInt16(ab, offset + 2); + myHdr.myDbs[i].dbiAW = BitConverter.ToInt16(ab, offset + 4); + rogrp tmp = LoadGroup(ab, BitConverter.ToInt32(ab, offset + 6)); + myHdr.myDbs[i].ID = tmp.ID; + myHdr.myDbs[i].children = tmp.children; + int iPtr = BitConverter.ToInt32(ab, offset + 22) + hdrOffset + 6; + myHdr.myDbs[i].dbiTitle = Encoding.Default.GetString(ab, iPtr, StringLength(ab, iPtr)); + iPtr = BitConverter.ToInt32(ab, offset + 26) + hdrOffset + 6; + myHdr.myDbs[i].dbiAP = Encoding.Default.GetString(ab, iPtr, StringLength(ab, iPtr)); + } + } + + public bool SaveToXml(string fname) + { + try + { + StreamWriter swxml = new StreamWriter(fname); + XmlSerializer mySer = new XmlSerializer(typeof(roHdr)); + mySer.Serialize(swxml, myHdr); + swxml.Close(); + + } + catch (Exception ex) + { + log.ErrorFormat("Error writing to file: {0}", ex.Message); + return false; + } + return true; + } + + + public XmlDocument GetXmlFromFile(string fname) + { + FileStream xmlIn = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read); + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.Load(xmlIn); + xmlIn.Close(); + return xmlDoc; + } + + public string GetValueFromXml(XmlDocument xmlDoc, string ROID) + { + // use roid as xpath to get data. + try + { + string xpath_roid = "//rochild[roid = \"" + ROID.Substring(0, 12) + "\"]/value"; + XmlNode valnd = xmlDoc.SelectSingleNode(xpath_roid); + if (valnd == null) return null; + return valnd.InnerText; + } + catch (Exception ex) + { + log.ErrorFormat("Cannot find ro in XmlDocument "); + log.ErrorFormat("roid = {0}", ROID); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + } + return null; + } + + } +} diff --git a/PROMS/proms/DataLoader/RefObjs.cs b/PROMS/proms/DataLoader/RefObjs.cs new file mode 100644 index 00000000..d3b865af --- /dev/null +++ b/PROMS/proms/DataLoader/RefObjs.cs @@ -0,0 +1,92 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private void AddRoUsage(int structId, string ROID) + { + RoUsage ro = RoUsage.MakeRoUsage(structId, ROID); + ro.StructureID = structId; + ro.ROID = ROID; + } + private string MigrateRos(OleDbConnection cn, string textm, string seqcvt, int structId) + { + StringBuilder rotxt = new StringBuilder(); + int instance = 0; + int beg = 0; + DataTable dt = null; + DataSet ds = null; + OleDbDataAdapter da = null; + //TODO: ZSteps + string cmd = "SELECT * FROM USAGERO WHERE [NUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [SEQUENCE] ='" + seqcvt + "' ORDER BY [INSTANCE]"; + da = new OleDbDataAdapter(cmd, cn); + // get usage records for the ROID. + ds = new DataSet(); + try + { + da.Fill(ds); + dt = ds.Tables[0]; + dt.CaseSensitive = true; + } + catch (Exception ex) + { + log.Error("Error getting RO Usages"); + log.ErrorFormat("proc number = {0}, oldstepsequence = {1}",ProcNumber, seqcvt); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + return textm; + } + int tok = textm.IndexOf('\x15'); + while (tok > -1) + { + // found a token, add the roid & value into the string and + // add an ro usage for it. + rotxt.Append(textm.Substring(beg, tok - beg)); + DataRow dr = dt.Rows[instance]; + string ROID = dr["ROID"].ToString(); + AddRoUsage(structId, ROID); + rotxt.Append("\x15{{"); + rotxt.Append(ROID); + rotxt.Append("}{"); + + string val = rofst.GetRoValue(ROID.Substring(0, 12)); + rotxt.Append(val); + rotxt.Append("}}"); + instance++; + beg = tok + 1; + if (beg > textm.Length) + { + tok = -1; + da.Dispose(); + } + else + tok = textm.IndexOf('\x15', beg); + } + if (beg < textm.Length - 1) + rotxt.Append(textm.Substring(beg, textm.Length - beg)); + + return rotxt.ToString(); + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/SecObj.cs b/PROMS/proms/DataLoader/SecObj.cs new file mode 100644 index 00000000..16222344 --- /dev/null +++ b/PROMS/proms/DataLoader/SecObj.cs @@ -0,0 +1,913 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Windows.Forms; +using System.Text; +using Volian.CSLA.Library; +using Config; + +namespace DataLoader +{ + /// + /// Summary description for Security. + /// + /// + #region OldVeSamClasses + // do a temp plant - we may keep this for loading in data. It will be migrated + // to a folders record. + #region Options + public class PlantOptions + { + private UInt16 _id; + private UInt32 _plopts; + public List poList = new List(); + + public UInt16 Id + { + get {return _id;} + set {if (_id != value) _id = value;} + } + + public UInt32 Options + { + get {return _plopts;} + set {if (_plopts != value) _plopts = value;} + } + } + public class ProcOptions + { + private UInt16 _id; + private UInt16 _selected; + public UInt32 [] Options = new UInt32[4]; + + public UInt16 Id + { + get {return _id;} + set {if (_id != value)_id = value;} + } + public UInt16 Selected + { + get {return _selected;} + set {if (_selected != value)_selected = value;} + } + } + #endregion + #region OldFolders + public class Plant + { + private string _name; + private string _path; + private UInt16 _id; + public Dictionary psDic = new Dictionary(); + + public string Name + { + get {return _name;} + set + { + if (value == null) value = string.Empty; + if (_name != value) _name = value; + } + } + public string Path + { + get {return _path;} + set + { + if (value == null) value = string.Empty; + if (_path != value)_path = value; + } + } + public UInt16 Id + { + get {return _id;} + set {if (_id != value) _id = value;} + } + + public Plant() { } + public Plant(string nm, string pth, UInt16 idn) + { + _name = nm; + _path = pth; + _id = idn; + } + } + + public class ProcSet + { + private string _name; + private string _path; + private UInt16 _id; + public string Name + { + get {return _name;} + set + { + if (value == null) value = string.Empty; + if (_name != value)_name = value; + } + } + public string Path + { + get {return _path;} + set + { + if (value == null) value = string.Empty; + if (_path != value)_path = value; + } + } + public UInt16 Id + { + get {return _id;} + set {if (_id != value) _id = value;} + } + public ProcSet() { } + + public ProcSet(string nm, string pth, UInt16 idn) + { + _name = nm; + _path = pth; + _id = idn; + } + } + #endregion + #region OldUser + // The OldUser class stores data from the vesam input. The User class migrates + // and saves data to the new sql database. + public class OldUser + { + private UInt32 _systemopts; + private string _username; + private bool _blockaccessflag = false; + public List PlantOpts = new List(); + + public UInt32 SystemOpts + { + get { return _systemopts; } + set { if (_systemopts != value) _systemopts = value; } + } + public string UserName + { + get { return _username; } + set + { + if (value == null) value = string.Empty; + if (_username != value) _username = value; + } + } + + public bool BlockAccessFlag + { + get { return _blockaccessflag; } + set { if (_blockaccessflag != value) _blockaccessflag = value; } + } + + public bool PermissionToManageFlag + { + get { return (_systemopts & VESamOpt.DOCMAINT)==0?false:true; } + //set { if (_permissiontomanageflag != value) _permissiontomanageflag = value; } + } + + public bool SystemAdminFlag + { + get { return (_systemopts & VESamOpt.SYSADMIN)==0 ? false:true; } + //set { if (_systemadminflag != value) _systemadminflag = value; } + } + + public bool PermissionToLockFlag + { + get { return (_systemopts & VESamOpt.LOCKSYSTEM)==0 ? false:true; } + //set { if (_permissiontolockflag != value) _permissiontolockflag = value; } + } + + public bool RoEditorFlag + { + get { return (_systemopts & VESamOpt.ROEDITOR) == 0 ? false : true; } + } + + public OldUser(string nm) + { + _username = nm; + } + } + #endregion + #region VESam + public class VESamOpt + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + public const long VIEW = 0x00000001L; + public const long PRINT = 0x00000002L; + public const long PRINTDRAFT = 0x00000004L; + public const long PRINTCHANGES = 0x00000008L; + public const long EDIT = 0x00000010L; + public const long SEARCH = 0x00000020L; + public const long STANDARDSTEPS = 0x00000040L; + public const long APPROVE = 0x00000080L; + public const long APPROVESINGLE = 0x00000100L; + public const long LIBRARYDOCS = 0x00000200L; + public const long ADDMODDEL = 0x00000400L; + public const long CLEAN = 0x00000800L; + public const long LOCKPROC = 0x00001000L; + public const long LOCKSET = 0x00000001L; + public const long UCF = 0x00000002L; + public const long LOCKSYSTEM = 0x00000001L; + public const long DOCMAINT = 0x00000002L; + public const long ROEDITOR = 0x00000004L; + public const long SYSADMIN = 0x00000008L; + + public const int SUPERUSER = 1000; + public const long SUPERACCESS = 0xFFFFFFFFL; + + private bool _blockAccess; + public int userid = -1; + public string initials; + private const string samoptname = "vesam.opt"; + public FileStream fs; + public BinaryReader bw; + public bool isDemoMode = false; + List plntList = new List(); + List userList = new List(); + Dictionary plntDic = new Dictionary(); + + public bool BlockAccess + { + get { return _blockAccess; } + set { if (_blockAccess != value) _blockAccess = value; } + } + + public bool OpenFile(string oname) + { + try + { + fs = new FileStream(oname, FileMode.Open, FileAccess.Read, FileShare.Read, 1, false); + bw = new BinaryReader(fs); + return true; + } + catch (Exception e) + { + MessageBox.Show(e.Message, "Security File"); + return false; + } + } + + public void CloseFile() + { + bw.Close(); + fs.Close(); + bw = null; + fs = null; + } + public Dictionary LoadPlants() + { + UInt16 ui16; + UInt32 ui32; + + try + { + byte x; + + // read past some header stuff. + for (int jj = 0; jj < 8; jj++) x = bw.ReadByte(); + + long nxtPl = bw.ReadUInt32(); + uint nmPlant = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + + // not needed here, but need to read past this... + long nxtUs = bw.ReadUInt32(); + uint nmUser = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + long nxtGr = bw.ReadUInt32(); + uint nmGrp = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + + BlockAccess = bw.ReadUInt16()==0?false:true; + + string pname, ppth; + for (int i = 0; i < nmPlant; i++) + { + if (nxtPl == 0xFFFFFFFEL) + { + log.Error("Reading in VESAM options file - cannot find next plant in list"); + break; + } + fs.Seek(nxtPl, SeekOrigin.Begin); + nxtPl = bw.ReadUInt32(); + + Plant pl = new Plant(); + pl.Id = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + + byte[] stmp = new byte[256]; + stmp = bw.ReadBytes(ui16); + pname = Encoding.ASCII.GetString(stmp, 0, ui16); + pl.Name = pname; + ui16 = bw.ReadUInt16(); + stmp = bw.ReadBytes(ui16); + ppth = Encoding.ASCII.GetString(stmp, 0, ui16); + pl.Path = ppth; + + // read in any sets within this plant. + UInt16 nmPrcDr = bw.ReadUInt16(); + ui32 = bw.ReadUInt32(); + UInt32 nxtPr = bw.ReadUInt32(); + + for (int j = 0; j < nmPrcDr; j++) + { + ProcSet ps = new ProcSet(); + ps.Id = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + stmp = bw.ReadBytes(ui16); + pname = Encoding.ASCII.GetString(stmp, 0, ui16); + ps.Name = pname; + ui16 = bw.ReadUInt16(); + stmp = bw.ReadBytes(ui16); + ppth = Encoding.ASCII.GetString(stmp, 0, ui16); + ps.Path = ppth; + ui32 = bw.ReadUInt32(); + if (nxtPr == 0xFFFFFFFDL && j + 1 < nmPrcDr) + { + log.ErrorFormat("Loading vesam.opt - procedure sets for {0}", ps.Name); + return null; + } + try + { + pl.psDic.Add(ps.Id, ps); + } + catch (Exception ex) + { + log.ErrorFormat("Adding to set dictionary - {0}. Error: {1}" + ps.Path, ex.Message); + } + if (nxtPr != 0xFFFFFFFDL) + { + fs.Seek(nxtPr, SeekOrigin.Begin); + nxtPr = bw.ReadUInt32(); + } + } + try + { + if (!plntDic.ContainsKey(pl.Id))plntDic.Add(pl.Id, pl); + } + catch (Exception ex) + { + log.ErrorFormat("Adding to plant dictionary - {0}. Error: {1}", pl.Path, ex.Message); + } + } + } + catch (Exception ex) + { + log.ErrorFormat("Loading plants from vesam.opt: {0}", ex.Message); + return null; + } + return plntDic; + } + public List LoadUserList() + { + UInt16 ui16; + UInt32 ui32; + try + { + byte x; + + fs.Seek(0, SeekOrigin.Begin); + // read past some header stuff. + for (int jj = 0; jj < 8; jj++) x = bw.ReadByte(); + long nxtPl = bw.ReadUInt32(); + uint nmPlant = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + + // get info in header for users + long nxtUs = bw.ReadUInt32(); + uint nmUser = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + long nxtGr = bw.ReadUInt32(); + uint nmGrp = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); + + bool localblockAccess = bw.ReadUInt16()==0?false:true; + // Now read in all of the user information + UInt16 uid; + string fName, fPass; + for (int i = 0; i < nmUser; i++) + { + if (nxtUs == 0xFFFFFFFCL && i + 1 < nmUser) + { + log.Error("Loading vesam.opt - reading in user list."); + return null; + } + + fs.Seek((long)nxtUs, SeekOrigin.Begin); + nxtUs = bw.ReadUInt32(); + uid = bw.ReadUInt16(); + ui16 = bw.ReadUInt16(); // user's group? + + byte[] test = new byte[10]; + test = bw.ReadBytes(10); + + // get ve-proms (vesam) username & password + fName = Encoding.ASCII.GetString(test, 0, 10); + int indx = fName.IndexOf("\0"); + string fNameTrim = fName.Substring(0, indx); + test = bw.ReadBytes(10); + fPass = Encoding.ASCII.GetString(test, 0, 10); + indx = fPass.IndexOf("\0"); + string fPassTrim = fPass.Substring(0, indx); + OldUser usr = new OldUser(fNameTrim); + usr.SystemOpts = bw.ReadUInt32(); + usr.BlockAccessFlag = localblockAccess; + ui32 = bw.ReadUInt32(); + + // now get plant & proc set options. + nmPlant = bw.ReadUInt16(); + for (int j = 0; j < nmPlant; j++) + { + PlantOptions plO = new PlantOptions(); + plO.Id = bw.ReadUInt16(); + plO.Options = bw.ReadUInt32(); + ui32 = bw.ReadUInt32(); + UInt16 nmPrcDr = bw.ReadUInt16(); + for (int k = 0; k < nmPrcDr; k++) + { + ProcOptions prO = new ProcOptions(); + prO.Id = bw.ReadUInt16(); + prO.Selected = bw.ReadUInt16(); + for (int kk = 0; kk < 4; kk++) prO.Options[kk] = bw.ReadUInt32(); + plO.poList.Add(prO); + } + usr.PlantOpts.Add(plO); + } + userList.Add(usr); + } + } + catch (Exception ex) + { + log.ErrorFormat("Error Loading (old) User info from vesam.opt: {0}", ex.Message); + return null ; + } + return userList; + } + } + #endregion + #endregion + + #region SecurityMigration + public class Security + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + Dictionary plntDic = new Dictionary(); + List userList = new List(); + private string optfilename; + private string[] prflags ={ "Vfw", "Prnt", "Prnt Drft", "Prnt Chgs", "Edit", "Srch", "St Stp", "App", "App Sel", "Lib", "AMD", "Clean", "Lock" }; + private string[] sysflags ={ "NetworkLock", "SysMaint", "ROEditor", "SysAdmin" }; + #region NewMig + public Security(string pathname) + { + if (File.Exists(pathname) == false) + { + MessageBox.Show("Could not locate the Security Options file:\n\n" + pathname, "Security Access Error"); + optfilename = null; + return; + } + optfilename = pathname; + } + public bool Migrate() + { + VESamOpt vso = new VESamOpt(); + bool suc = vso.OpenFile(optfilename); + if (!suc) return false; + plntDic = vso.LoadPlants(); + if (plntDic == null) return false; + suc = VerifyFolders(plntDic); + if (!suc) return suc; + userList = vso.LoadUserList(); + if (userList == null) return false; + vso.CloseFile(); + vso = null; + log.Info("Original vesam.opt loaded successfully - next step is to migrate security information to new database"); + //WriteOutSummary(plntDic, userList); + suc = TranslateToNew(vso, plntDic, userList); + log.Info("Migrated vesam successfully"); + return suc ; + } + #endregion + #region WriteVESamSummary + private void WriteOutSummary(Dictionary plntDic, List userList) + { + foreach (OldUser usr in userList) + { + log.InfoFormat("User = {0}", usr.UserName); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 4; i++) + { + if ((usr.SystemOpts & (1L << i)) != 0) sb.Append(sysflags[i] + " "); + } + if (sb.Length > 0) log.InfoFormat(" System Options = {0}", sb.ToString()); + + // for now, don't worry about system options. + // for each plant, list any permissions of the plant or its proc sets. If + // none set, nothing will be listed. + foreach (PlantOptions po in usr.PlantOpts) + { + bool plntout = false; + Plant pl = (Plant)plntDic[po.Id]; + if (po.Options != 0) + { + plntout = true; + log.InfoFormat(" Plant = {0}. Options = {1}", pl.Name, po.Options); + } + foreach (ProcOptions psO in po.poList) + { + ProcSet ps = (ProcSet)pl.psDic[psO.Id]; + if (psO.Options[0] != 0 || psO.Options[1] != 0 || psO.Options[2] != 0 || psO.Options[3] != 0) + { + if (!plntout) log.InfoFormat(" Plant = {0}.", pl.Name); + log.InfoFormat(" Procedure Set = {0}", ps.Name); + sb.Length = 0; + int nm = 0; + for (int i1 = 0; i1 < 4; i1++) + { + for (int j1 = 0; j1 < 16; j1++) + { + if ((psO.Options[i1] & (1L << j1)) != 0) sb.Append(prflags[nm] + " "); + nm++; + } + } + if (sb.Length > 0) log.InfoFormat(" {0}", sb.ToString()); + } + } + } + } + + } + #endregion + #region MigrateCode + private string[] defaultRole ={ "Administrator", "User Administrator", "RO Manager", "Writer", "Reviewer", "Guest" }; + private string[] defaultRoleTitle = { "Manages Data - Backups, Approval etc.", "Maintains User Security", "Maintains Referenced Objects", "Can Edit", "Can potentially add comments", "Read-Only access to approved procedures" }; + // defaultPermData sets the permission data (Permissions table) - columns are + // PermLevel, VersionType, PermValue (Note for vesam migration, PermAD is always allow, i.e. 0) + private int[,] defaultPermData = { + {2, 3, 15}, // Administrator + {1, 3, 15}, // User Administrator + {3, 3, 15}, // RO Manager + {5, 1, 15}, // Writer + {7, 3, 15}, // Reviewer + {2, 2, 1}}; // Guest + + private int[] accessLevelSetup = { -1, 5, 4, 3, 0, 0, 2, 1 }; + private int[] accessLevelTrans; + + private Dictionary AddDefaultRoles() + { + Dictionary rdic = new Dictionary(); + try + { + accessLevelTrans = new int[accessLevelSetup.Length]; + for (int i = 0; i < 6; i++) + { + Role role = Role.New(); + role.Name = defaultRole[i]; + role.Title = defaultRoleTitle[i]; + role.Save(); + Permission perm = Permission.New(); + perm.RID = role.RID; + perm.PermLevel = defaultPermData[i, 0]; + perm.VersionType = defaultPermData[i, 1]; + perm.PermValue = defaultPermData[i, 2]; + perm.Save(); + rdic.Add(role.RID, role); + for (int j = 1; j < accessLevelSetup.Length; j++) + { + if (accessLevelSetup[j] == i) accessLevelTrans[j] = role.RID; + } + } + + } + catch (Exception ex) + { + log.ErrorFormat("Error setting default roles & permissions: {0}", ex.Message); + return null; + } + return rdic; + } + + public bool VerifyFolders(Dictionary dicPlants) + { + try + { + // For each folder from vesam, see if there is a matching folder already + // migrated... + + FolderInfoList fil = FolderInfoList.Get(); + // add the titles to a dictionary for quick checking + List folderlist = new List(); + foreach (FolderInfo fi in fil) + { + folderlist.Add(fi.Title.ToUpper()); + } + + foreach (ushort u in dicPlants.Keys) + { + Plant pl = dicPlants[u]; + bool foundplant = false; + if (folderlist.Contains(pl.Path.ToUpper())) foundplant=true; + + if (!foundplant) + log.InfoFormat("Plant from vesam.opt not found in folder data: {0}", pl.Path); + else // if found, check for sets + { + foreach (ushort uu in pl.psDic.Keys) + { + ProcSet pr = pl.psDic[uu]; + bool foundprocset = false; + foreach (FolderInfo fi in fil) + { + string tstpath = pl.Path.ToUpper() + "\\" + pr.Path.ToUpper(); + if (tstpath == fi.Title.ToUpper()) + { + foundprocset = true; + break; + } + } + if (!foundprocset) log.InfoFormat("Procedure Set from vesam.opt not found in folder data: {0}\\{1}", pl.Path, pr.Path); + } + } + } + } + catch (Exception ex) + { + log.ErrorFormat("error mapping vesam directories to data directories, error = {0}", ex.Message); + return false; + } + return true; + } + + private Dictionary LoadFolders() + { + FolderInfoList fldlist = FolderInfoList.Get(); + Dictionary fdic = new Dictionary(); + foreach (FolderInfo fi in fldlist) + { + fdic.Add(fi.Title.ToUpper(), fi.FolderID); + } + return fdic; + } + + private bool TranslateToNew(VESamOpt vso, Dictionary plntDic, List userList) + { + Dictionary rlpdic = AddDefaultRoles(); + AddUsrGrpAsgnRecs(plntDic, userList); + return true; + } + private string VersionName(string s) + { + return s.Substring(s.LastIndexOf(" - ") + 3); + } + private string SetName(string s) + { + return s.Substring(0, s.LastIndexOf(" - ")); + } + private string FixName(string s) + { + s = s.Replace(" - Working Draft (Unit 1)", " (Unit 1) - Working Draft"); + s = s.Replace(" - Working Draft (Unit 2)", " (Unit 2) - Working Draft"); + s = s.Replace(" - Current Approved Version", " - Approved Version"); + return s.Replace(" - Working Draft", " - Working Draft"); + } + private int CalcAccessLevel(int iBase, uint options, string sVersion) + { + if (sVersion == "Working Draft") + { + if (options == 0) return 0; + if ((options & 6528) != 0) return 5; + if ((options & 1024) != 0) return 4; + if ((options & 528) != 0) return 3; + return 2; + } + else + { + if (iBase != 0) return iBase; + else if (options != 0) return 1; + return 0; + } + } + private string SystemOption(uint options) + { + if ((options & 11) != 0) return "\"Admin\""; + if (options == 4) return "\"RO\""; + return ""; + } + private void AddAccessRights(Dictionary> dic, int folderId, int roleId) + { + if (!dic.ContainsKey(folderId)) dic[folderId] = new List(); + dic[folderId].Add(roleId); + } + private void AddUsrGrpAsgnRecs(Dictionary plntDic, List userList) + { + Dictionary> dicGroups = new Dictionary>(); + Dictionary dicGroupIds = new Dictionary(); + Dictionary dicOldFolders = new Dictionary(); + int oldFolderCount = 1; + dicOldFolders.Add("system", oldFolderCount++); + Dictionary dicNewFolders = LoadFolders(); + List lstVersions = new List(); + StringBuilder sb; + OldUser frst = userList[0]; + + string[] accessLevel = { "", "\"Guest\"", "\"Reviewer\"", "\"Writer\"", "\"Admin\"", "\"Admin\"" }; + foreach (OldUser usr in userList) + { + int sysAccess = 5; + Dictionary plantAccess = new Dictionary(); + + if ((usr.SystemOpts & 11) == 0) + { + foreach (PlantOptions po in usr.PlantOpts) + { + plantAccess[po] = 5; + Plant pl = (Plant)plntDic[po.Id]; + if (!dicOldFolders.ContainsKey(pl.Path.ToUpper()))dicOldFolders.Add(pl.Path.ToUpper(), oldFolderCount++); + string sSetLast = ""; + int iAccessLevel = 0; + + foreach (ProcOptions psO in po.poList) + { + ProcSet ps = null; + try + { + ps = (ProcSet)pl.psDic[psO.Id]; + } + catch (Exception ex) + { + MessageBox.Show("here"); + } + if (!dicOldFolders.ContainsKey(pl.Path.ToUpper()+"\\"+ps.Path.ToUpper()))dicOldFolders.Add(pl.Path.ToUpper()+"\\"+ps.Path.ToUpper(), oldFolderCount++); + string sName = FixName(ps.Name); + string sVersion = VersionName(sName); + string sSet = SetName(sName); + if (sSet != sSetLast) + { + if (sSetLast != "") + { + // if the proc access is lower than the plant, reset plant level. + if (iAccessLevel < plantAccess[po]) plantAccess[po] = iAccessLevel; + iAccessLevel = 0; + } + sSetLast = sSet; + } + iAccessLevel = CalcAccessLevel(iAccessLevel, psO.Options[0], sVersion); + } + // do one last check to see if plant level should be lowered. Also + // check if the system level should be lowered. + if (iAccessLevel < plantAccess[po]) plantAccess[po] = iAccessLevel; + if (plantAccess[po] < sysAccess) sysAccess = plantAccess[po]; + } + } + + // set the system level access, i.e. User Admin, System Admin & RO Editor roles if + // necessary. + int systemid = dicOldFolders["system"]; + + Dictionary> accessRights = new Dictionary>(); + if (usr.SystemOpts != 0) AddAccessRights(accessRights, systemid, accessLevelTrans[6]); // add ro editor + if ((usr.SystemOpts & 11) != 0) + { + AddAccessRights(accessRights, systemid, accessLevelTrans[5]); // add sys admin rights + AddAccessRights(accessRights, systemid, accessLevelTrans[7]); // and add user admin rights + } + else + { + // the user has a role at the system level that is not an admin, + // such as reviewer or guest - add it in. + if (sysAccess > 0) AddAccessRights(accessRights, systemid, accessLevelTrans[sysAccess]); + } + + sb = new StringBuilder(string.Format("{0},{1}", (usr.SystemOpts == 0 ? "" : "Admin"), accessLevel[sysAccess])); + + if ((usr.SystemOpts & 11) == 0) + { + foreach (PlantOptions po in usr.PlantOpts) + { + Plant pl = plntDic[po.Id]; + // Need logic for po.Options in combination with PlantAccess[po] + //sb.Append(string.Format(",{0}", po.Options)); + + if (plantAccess[po] > sysAccess) + { + AddAccessRights(accessRights, dicOldFolders[pl.Path.ToUpper()], accessLevelTrans[plantAccess[po]]); + sb.Append(string.Format(",{0}", accessLevel[plantAccess[po]])); + } + else + sb.Append(","); + string sSetLast = ""; + string sPathLast = ""; + int iAccessLevel = 0; + string sPath = ""; + foreach (ProcOptions psO in po.poList) + { + ProcSet ps = pl.psDic[psO.Id]; + string sName = FixName(ps.Name); + string sVersion = VersionName(sName); + if (sVersion == "Working Draft") sPath = pl.Path + "\\" + ps.Path; + string sSet = SetName(sName); + + if (sSet != sSetLast) + { + if (sSetLast != "") + { + if (iAccessLevel > plantAccess[po]) + { + AddAccessRights(accessRights, dicOldFolders[sPathLast.ToUpper()], accessLevelTrans[iAccessLevel]); + sb.Append(string.Format(",{0}", accessLevel[iAccessLevel])); + } + else + sb.Append(","); + iAccessLevel = 0; + } + sSetLast = sSet; + sPathLast = sPath; + } + iAccessLevel = CalcAccessLevel(iAccessLevel, psO.Options[0], sVersion); + } + + if (iAccessLevel > plantAccess[po]) + { + AddAccessRights(accessRights, dicOldFolders[sPathLast.ToUpper()], accessLevelTrans[iAccessLevel]); + sb.Append(string.Format(",{0}", accessLevel[iAccessLevel])); + } + else + sb.Append(","); + } + } + string s = sb.ToString(); + + if (!dicGroups.ContainsKey(s)) + { + dicGroups[s] = new List(); + Group grp = Group.New(); + grp.GroupName = "Group " + dicGroups.Count.ToString(); + int pathInData = -1; + foreach (int folderId in accessRights.Keys) + { + // see if this folderId exists in the data (rather + // than the list from vesam). If not, don't do an + // assignments record + pathInData = 0; + foreach (KeyValuePair kvp in dicOldFolders) + { + if (kvp.Value == folderId) + { + string path = kvp.Key; + if (dicNewFolders.ContainsKey(path.ToUpper())) + pathInData = dicNewFolders[path.ToUpper()]; + } + } + if (pathInData>0) + { + foreach (int roleId in accessRights[folderId]) + { + grp.GroupAssignments.Add(roleId, pathInData); + } + } + } + grp.Save(); + dicGroupIds[s] = grp.GID; + } + dicGroups[s].Add(usr.UserName); + } + + foreach (string s in dicGroups.Keys) + { + foreach (string sUser in dicGroups[s]) + { + // add user record & membership record. + User newusr = User.New(); + newusr.UserID = sUser; + ConfigFile cfg = new ConfigFile(); + cfg.LoadUsrCfg(newusr); + newusr.UserMemberships.Add(dicGroupIds[s]); + newusr.Save(); + } + + } + } + #endregion + } +#endregion +} diff --git a/PROMS/proms/DataLoader/Sections.cs b/PROMS/proms/DataLoader/Sections.cs new file mode 100644 index 00000000..ae586969 --- /dev/null +++ b/PROMS/proms/DataLoader/Sections.cs @@ -0,0 +1,383 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private Section AddSection(string Number, string Title, DateTime Dts, string Userid, ConfigInfo ci, string stpseq, string fmt, int libdocid, string pth) + { + UpdateLabels(0, 1, 0); + try + { + string Format = null; + + // do the format field, an xpath for the format & last part is column + // mode if a step section. + try + { + if (fmt != null && fmt != "") + { + if (fmt.IndexOf(' ') > -1) // will have spaces if it's a user format + { + string part1 = "/" + fmt.Substring(0, fmt.IndexOf(' ')) + "/"; + string part2 = "USER=" + fmt.Substring(fmt.LastIndexOf(' ') + 1, 2); + Format = part1 + part2; + } + else + Format = "/" + fmt; + } + } + catch (Exception ex) + { + log.ErrorFormat("Error getting format {0}", ex.Message); + } + // tack on the column mode: + if (stpseq != null && stpseq.Substring(1, 1) == "0" && stpseq.Substring(5, 1) != " ") Format = Format + "/COL=" + stpseq.Substring(5, 1); + + // find rtf file (or use the library document temp file) & read it into the field + // acccontent + int Contentid=0; + byte ContentType=0; + if (libdocid != 0 || stpseq.Substring(1, 1) != "0") + { + string fname = null; + if (libdocid != 0) + { + Contentid = libdocid; + ContentType = 2; + } + else + { + int num = Convert.ToInt32(stpseq[0]) - 64; + string thenum = num.ToString("d2"); + fname = string.Format("{0}\\rtffiles\\{1}.A{2}", pth, ProcFileName, thenum); + Application.DoEvents(); + SaveSectionDocument(fname, stpseq, ref ContentType, ref Contentid); + } + } + + Section sec = Section.MakeSection(Number, Title,ContentType, Contentid, Format, ci.ToString(), Dts, Userid); + dicOldStepSequence[sec] = stpseq; + return sec; + } + catch (Exception ex) + { + log.Error("Save Section"); + log.ErrorFormat("oldstepsequence = {0}", stpseq); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + log.ErrorFormat(ex.StackTrace); + } + return null; + } + private string SectTitle(OleDbConnection cn, DataRowView dr) + { + string tbuff = null; + string menustr = null; + bool UseMultiLineSectionTitle = false; // TODO KBR: format flag + if (UseMultiLineSectionTitle) + { + bool titleInMemo = false; + // for accessory pages... + if (dr["Step"].ToString().Substring(1, 1) != "0") + { + // The long section title is stored on a record with the "~" character. + // This was done since originally the actual accessory page data was stored in the memo + // field, so the long title could not be stored there, another record had to be used. + OleDbDataAdapter da = new OleDbDataAdapter("select * from " + ProcFileName + " where [Step] like '" + dr["Step"].ToString().Substring(0, 1) + "~';", cn); + DataSet ds = new DataSet(); + try + { + da.Fill(ds); + if (ds.Tables[0].Rows.Count == 1) + { + DataRow row = ds.Tables[0].Rows[0]; + tbuff = TextConvert.ConvertText(row["Textm"].ToString()); + if (tbuff != null || tbuff[0] != '\0') titleInMemo = true; + } + else // no long section title existed for this accessory page + tbuff = TextConvert.ConvertText(dr["Text"].ToString().PadRight(130, ' ').Substring(0, 75).TrimEnd()); + } + catch (Exception ex) + { + log.ErrorFormat("Error getting long section title {0}", ex.Message); + } + } + // For step sections, the long section title is stored on the section record + // (see above comment for accessory pages to see the difference) + else + { + tbuff = TextConvert.ConvertText(dr["TextM"].ToString().Trim()); + } + + //// TESTS were run & it looked like that whitespace was removed before saving, + //// so, put up a message box if find out otherwise.... + int nl = tbuff.IndexOf("\n"); + if (nl > -1) + MessageBox.Show("multiline text for section title, fix this!!"); + + //// remove newlines & any other escape/whitespace chars. + //int nl = tbuff.IndexOf("\n"); + //if (nl > -1 || titleInMemo) + //{ + + // string tmpstr = tbuff.Replace("\r", ""); + // tmpstr = tmpstr.Replace("\t", ""); + // tmpstr = tmpstr.Replace("\n", " "); + // // get rid of multiple spaces + // while (tmpstr.IndexOf(" ") > -1) tmpstr = tmpstr.Replace(" ", " "); + // tbuff = tmpstr; + // if (tbuff.Substring(tbuff.Length-1, 1) == " ") tbuff = tbuff.Substring(0, tbuff.Length - 1); + //} + //menustr = tbuff; + } + else + { // format does not include long section title + menustr = TextConvert.ConvertText(dr["Text"].ToString().PadRight(80, ' ').Substring(0, 75).TrimEnd()); + } + return menustr; + } + private Int32 MigrateSection(Procedure prc, OleDbConnection cn, DataRowView dr, DataTable dt, Byte FromType, Int32 FromID, bool isSubSection, string pth) + { + Int32 thesectid = 0; + bool islibdoc = false; + //bool hasxml = false; + string s = dr["text"].ToString().PadRight(130, ' '); + string num = s.Substring(85, 20).TrimEnd(); + string fmt = s.Substring(75, 10).TrimEnd(); + string title = SectTitle(cn, dr); + string init = dr["initials"].ToString().Trim(); + string sequence = dr["CSequence"].ToString().PadRight(10); + string step = dr["CStep"].ToString(); + int libDocid = 0; + + DateTime dts = GetDTS(dr["Date"].ToString(), dr["Time"].ToString()); + + ConfigInfo ci = new ConfigInfo(null); + // for steps sections... + // Step Section Header Format: + // A0 1X2S51 &Y + // ^^^^^^^^^^^^ + // ||||||||||||| + // ||||||||||||`- 'Y','N', or blank signals to print section header - lib/section/addsec.c + // |||||||||||`-- (bits) Auto Indent, Editable Data, Checkoff Header Type - lib/section/addsec.c + // ||||||||||`--- blank + // ||||||||`----- Link With Enhanced Document ' '-Default(not determined) 0-NO 1-YES + // |||||||`------ MetaSection - number of subsections is given + // ||||||`------- S-Separate(PageBreak); T-Continuous; ' '-Default + // |||||`-------- Column mode (1,2,3,' '-default) + // ||||`--------- X -only proc section; x -orig. proc; ' ' -other + // |||`---------- Position within the procedure + // ||`----------- ALWAYS leave blank + // |`------------ Step Section Header marker + // `------------- Internal section number (starts at A) + + if (step.Substring(1, 1) == "0") + { + // if this section has the original edit section flag (sequence[2]) save the id. + + // set pagination, continuous, separate. If blank, don't create attribute - uses format default. + if (sequence.Substring(4, 1) == "T") + { + ci.AddItem("Section", "Pagination", "C"); + //hasxml = SetXml(xmldoc, topElement, "Section", "Pagination", "C"); + } + else if (sequence.Substring(4, 1) == "S") + { + ci.AddItem("Section", "Pagination", "S"); + //hasxml = SetXml(xmldoc, topElement, "Section", "Pagination", "S"); + } + + // Step: linked to enhanced (!exist = N) + if (sequence.Substring(7, 1) == "1") + { + ci.AddItem("Step", "LnkEnh", "Y"); + //hasxml = SetXml(xmldoc, topElement, "Step", "LnkEnh", "Y"); + } + char cbittst = sequence.PadRight(10)[8]; + if (cbittst == ' ') cbittst = '\0'; + + // determine if TOC element (!exist = N) + if ((cbittst & TOC) > 1) + { + ci.AddItem("Section", "TOC", "Y"); + //hasxml = SetXml(xmldoc, topElement, "Section", "TOC", "Y"); + } + // determine if autogenerated section (!exist = N) + if ((cbittst & AUTOGEN) > 1) + { + ci.AddItem("Section", "AutoGen", "Y"); + //hasxml = SetXml(xmldoc, topElement, "Section", "AutoGen", "Y"); + } + + // Here are subsection flags, i.e. the following are only set if this + // is a subsection. + bool didsub = false; + if (isSubSection) + { + // Subsection: editable (!exist = Y) + if ((cbittst & EDDATA) > 0) + { + ci.AddItem("SubSection", "Edit", "N"); + //SetXml(xmldoc, topElement, "SubSection", "Edit", "N"); + } + + // Subsection: print section headers (!exist = Y) + if ((cbittst & PH) > 0) + { + didsub = true; + ci.AddItem("SubSection", "PH", "N"); + //SetXml(xmldoc, topElement, "SubSection", "PH", "N"); + } + + // Subsection: autoindent (!exist = Y) + if ((cbittst & AUTOIND) > 0) + { + ci.AddItem("SubSection", "AutoIndent", "N"); + //SetXml(xmldoc, topElement, "SubSection", "AutoIndent", "N"); + } + } + if (!didsub && sequence.Substring(4, 1) == "N") + { + ci.AddItem("SubSection", "PH", "N"); + //SetXml(xmldoc, topElement, "SubSection", "PH", "N"); + } + } + else + { + // Accessory Section Format: + // AI 1 2 + // ^^ ^ ^ + // || | | + // || | `- # of pages (ASCII value minus 48) + // || `--- Position within the procedure + // |`----- Acc. page type (A,I, or F) + // `------ Internal section number (starts at A) + ci.AddItem("Section", "NumPages", sequence.Substring(3, 1)); + //hasxml = SetXml(xmldoc, topElement, "Section", "NumPages", sequence.Substring(3, 1)); + + // see if it's a libdoc too.0 + string thekey = prc.Number.PadRight(20) + step.Substring(0, 1).PadRight(10); + if (dicLibDocRef.ContainsKey(thekey)) + { + // if it is a library document, see if the section record has already been + // saved. If it has, just use this section id, otherwise, create the + // section record with info from the library document file. + libDocid = dicLibDocRef[thekey]; + islibdoc = true; + } + } + + Section sec = AddSection(num, title, dts, init, ci, step + sequence, fmt, libDocid, pth); + thesectid = sec.SectID; + + // if this section has the original edit section flag (sequence[2]) save the id. + if (!islibdoc && step[1] == '0' && (sequence[2] == 'x' || sequence[2] == 'X')) + EditSectId = thesectid; + // ContentType (2 in the following call) are: + // 0 = structure, + // 1 = procedure, + // 2 = section, + // 3 = step + // 4 = branch + + // fromtype values are (see steps.cs too) + // 0 = next of same type + // 1 = procedure, + // 2 = section, + // 3 = caution + // 4 = note + // 5 = RNO + // 6 = substep + // 7 = table + + Structure str = AddStructure(FromType, FromID, 2, thesectid, step + sequence, dts, init); + // Process the Data Table - First look for High Level Steps + string sQry = string.Format("Step like '[{0}]%' and Sequence='S'", dr["Step"].ToString().Substring(0, 1)); + DataView dv = new DataView(dt, sQry, "StepNo", DataViewRowState.CurrentRows); + Byte FrType = 6; + Int32 FrID = 0; + pbStep.Maximum = dt.Rows.Count; + pbStep.Value = 0; + foreach (DataRowView drv in dv) + { + FrID = MigrateStep(cn, dt, drv, FrType, FrID); + if (sec.ContentID == 0) + { + sec.ContentID = FrID; + sec.ContentType = 1; + sec.Save(true); + } + FrType = 0; + } + return str.StructureID; + } + private void LoadSection(DataSet ds, OleDbDataAdapter da, string FileName) + { + try + { + da.Fill(ds, "Sections"); + DataTable dt = ds.Tables["Sections"]; + dt.CaseSensitive = true; + dt.Columns.Add("CStep", System.Type.GetType("System.String")); + dt.Columns.Add("CSequence", System.Type.GetType("System.String")); + // set the cstep & csequence - couldn't do it in the add because it needed a sql function + foreach (DataRow drw in ds.Tables["Sections"].Rows) + { + drw["CStep"] = TextConvert.ConvertSeq(drw["Step"].ToString()); + drw["CSequence"] = TextConvert.ConvertSeq(drw["Sequence"].ToString()); + } + dt.Columns.Add("StepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CStep,2,1),'System.Char'),'System.Int32')-48"); + dt.Columns.Add("Level", System.Type.GetType("System.Int32"), "Len(CSequence)"); + dt.Columns.Add("SubStepNo", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,Len(CSequence),1),'System.Char'),'System.Int32')-48"); + dt.Columns.Add("locb", System.Type.GetType("System.Int32"), "Convert(Convert(Substring(CSequence,2,1),'System.Char'),'System.Int32')-48"); + } + + catch (Exception ex) + { + FileInfo fi; + switch (ex.Message) + { + case "Index file not found.":// then delete inf file + fi = new FileInfo(tbSource.Text + "\\" + FileName + ".inf"); + fi.Delete(); + LoadSection(ds, da, FileName);// Try Again + break; + case "External table is not in the expected format.": // then pad dbt file with 128 zeros. + fi = new FileInfo(tbSource.Text + "\\" + FileName + ".dbt"); + FileStream fs = fi.OpenWrite(); + fs.Position = fs.Length; + byte[] buf = new byte[128]; + for (int i = 0; i < 128; i++) buf[i] = 0; + fs.Write(buf, 0, 128); + fs.Close(); + LoadSection(ds, da, FileName);// Try Again + break; + default: // Unrecognized error + log.ErrorFormat("File - {0}.DBF\r\n\r\n{1}\r\n\r\n{2}", FileName, ex.Message, ex.InnerException); + break; + } + } + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/Steps.cs b/PROMS/proms/DataLoader/Steps.cs new file mode 100644 index 00000000..948c562c --- /dev/null +++ b/PROMS/proms/DataLoader/Steps.cs @@ -0,0 +1,307 @@ +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private Step AddStep(OleDbConnection cn, string StepType, string Textm, string Recid, string stpseq, string structtype, int structid, DateTime dts, string userid) + { + Step stp = null; + UpdateLabels(0, 0, 1); + bool hasxml = false; + ConfigInfo ci = new ConfigInfo(null); + string stptext = null; + int tok = -1; + char[] chrarr = { '\x1', '\x2', '\x3', '\x5' }; + try + { + // the textm field has step text, but also may have other text stored + // with it with a 'token' as a separator (see below). + tok = Textm.IndexOfAny(chrarr); + if (tok < 0) + stptext = TextConvert.ConvertText(Textm); + else + stptext = TextConvert.ConvertText(Textm.Substring(0, tok)); + + string seqcvt = TextConvert.ConvertSeq(stpseq); + + // Figure marker - it should NEVER get here!!! + int tokfig = Textm.IndexOf('\xE8'); + if (tokfig > -1) + { + log.Error("Found a old style figure!"); + log.ErrorFormat("oldstepsequence = {0}", stpseq); + } + // Before we save it, handle RO & Transitions tokens. + int tokrt = Textm.IndexOf('\x15'); + if (tokrt > -1) stptext = MigrateRos(cn, stptext, seqcvt, structid); + + // 16-bit code has the following two defines. + // #define TransitionMarker 0xC2 + // #define ReferenceMarker 0xCB + // these two characters get converted (to unicode) from ado.net + // use the unicode chars. + char[] chrrotrn = { '\x252C', '\x2566' }; + tokrt = Textm.IndexOfAny(chrrotrn); + if (tokrt > -1) stptext = MigrateTrans(cn, stptext, seqcvt, structid); + TextM tm = TextM.MakeTextM(stptext); + stp = Step.MakeStep(StepType, tm.TextMID, null, dts, userid); + dicOldStepSequence[stp] = seqcvt; + } + catch (Exception ex) + { + log.Error("Save Step"); + log.ErrorFormat("oldstepsequence = {0}", stpseq); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + log.ErrorFormat(ex.StackTrace); + stp = null; + } + + // now add on any support pieces of text associated with the step. + // These include: + // '\1' comment + // '\2' multiple change ids and/or change message + // '\3' linked sequence + // '\3\3'override tab + // '\5' continuous action summary flag + + try + { + while (tok >= 0 && tok != Textm.Length) + { + int nxttok = Textm.IndexOfAny(chrarr, tok + 1); + char chr = Textm[tok]; + int typ = 0; + if (chr == '\x1') + typ = STP_COMMENT; + else if (chr == '\x2') + typ = STP_MULT_CHGID; + else if (chr == '\x3') + { + typ = STP_LNK_SEQ; + // check for a double \3 - override tab. + if (tok + 1 < Textm.Length) + { + char nxttokchr = Textm[tok + 1]; + if (nxttokchr == '\x3') + { + typ = STP_OVR_TAB; + tok++; // this was a double \3, get past 1st one. + nxttok = Textm.IndexOfAny(chrarr, tok + 1); + } + } + } + else if (chr == '\x5') + { + ci.AddItem("Step", "ContActSum", "True"); + //hasxml = SetXml(xmldoc, topElement, "Step", "ContActSum", "True"); + if (nxttok < 0) nxttok = Textm.Length; + } + + // if not xml, i.e. chr=='\x5', make a textm element + if (chr != '\x5') + { + if (nxttok < 0) nxttok = Textm.Length; + // if this is a sequence number - may need to convert hi-end chars + string str = null; + if (typ == STP_LNK_SEQ) + str = TextConvert.ConvertSeq(Textm.Substring(tok + 1, nxttok - tok - 1)); + else + str = Textm.Substring(tok + 1, nxttok - tok - 1); + //StepText stptxt = StepText.MakeStepText(typ, str, true); + //stptxt.ItemType = typ; + //stptxt.Textm = str; + //stp.StepStepTexts.Add( + } + tok = nxttok; + } + + // also see if a check-off needs added. + if (Recid[0] != '0') + { + string chkindx = Recid[0].ToString(); + ci.AddItem("Step", "CheckOffIndex", chkindx); + //hasxml = SetXml(xmldoc, topElement, "Step", "CheckOffIndex", chkindx); + } + + // here's where it knows if it's a linked step (or in processstep) + if (Recid[1] != '0') + { + // do linked step stuff. + } + + // if checkoffs or the continuous action summary flag, save the xml. + if (hasxml) + { + stp.Config = ci.ToString(); + stp.Save(true); + } + // if this has associated steptext, such as tab override or comment, + // save it. + //else if (stp.StepStepTexts.Count > 0) + // stp.Save(true); + } + catch (Exception ex) + { + log.Error("Save Step part 2"); + log.ErrorFormat("oldstepsequence = {0}", stpseq); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + log.ErrorFormat(ex.StackTrace); + } + return stp; + } + + // private void ProcessSubStep(DataTable dt,DataRowView drv,StepTbl stpP) + // { + // // TODO: Need logic for TextM Support + // StepTbl stp = AddStep(stpP,drv["Type"].ToString(),drv["Text"].ToString(),drv["Step"].ToString()+drv["sequence"].ToString()); + // // TODO: Logic to add Sub-steps + // string sPre = drv["Sequence"].ToString(); + // ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"[*!]?",stp);// Cautions and Notes + // ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"$",stp);// RNOs + // ProcessSubSteps(dt,drv["Step"].ToString(),sPre+"?",stp);// Substeps + // //ProcessSubSteps(dt,drv["Step"],"S_",stp);// Tables + // } + // private void ProcessSubSteps(DataTable dt,string step,string lookfor,StepTbl stp) + // { + // DataView dv = new DataView(dt,"Step='" + step + "' and Sequence like'" + lookfor + "'", + // "sequence",DataViewRowState.OriginalRows); + // foreach(DataRowView drv in dv) + // { + // ProcessSubStep(dt,drv,stp); + // } + // } + private string GetParent(string s) + { + string retval = "S"; + if (s.Length > 1) + { + int l = s.Length; + if ("!*".IndexOf(s[l - 2]) > -1) + { + if (l > 2) retval = s.Substring(0, l - 2); + } + else + { + retval = s.Substring(0, l - 1); + } + } + return retval; + } + private string GetStructType(string s) + { + string retval = "S"; + if (s.Length > 1) + { + int l = s.Length; + if ("!*".IndexOf(s[l - 2]) > -1) + { + if (s[l - 2] == '!') retval = "C"; + else retval = "N"; + } + else + { + if (s[l - 1] == '$') retval = "R"; + if (s[l - 1] == '#') retval = "T"; + } + } + return retval; + } + private Int32 MigrateStep(OleDbConnection cn, DataTable dt, DataRowView drv, Byte FromType, Int32 FromID) + { + try + { + int tmpid = 1; + + // Do the structure record first because usages from the step require a structure + // id. + string sType = GetStructType(drv["CSequence"].ToString()); + // Structures str = AddStructure(FromType, FromID, (byte)(3 + ("CNRST".IndexOf(sType))), tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(), + Structure str = AddStructure(FromType, FromID, 3, tmpid, drv["CStep"].ToString() + drv["CSequence"].ToString(), + GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString()); + Step stp = AddStep(cn, drv["Type"].ToString() + , (drv["textm"] == DBNull.Value ? drv["Text"].ToString() : drv["Textm"].ToString()) + , drv["Recid"].ToString(), drv["CStep"].ToString() + drv["CSequence"].ToString(), "S", str.StructureID + , GetDTS(drv["Date"].ToString(), drv["Time"].ToString()), drv["Initials"].ToString()); + str.ContentID = stp.StepID; + str.Save(true); + Dictionary dicStep = new Dictionary(); + dicStep[drv["CSequence"].ToString()] = stp; + Dictionary> dicStruct = new Dictionary>(); + Dictionary dicBase = new Dictionary(); + dicStruct[drv["CSequence"].ToString()] = dicBase; + dicBase[""] = str.StructureID; + // Logic to add Sub-steps + string sQry = "CStep = '" + drv["CStep"].ToString() + "' and CSequence <> 'S'"; + // sort order - for sections use currentrows. + DataView dv = new DataView(dt, sQry, "StepNo,Level,SubStepNo", DataViewRowState.CurrentRows); + //dataGrid1.DataSource=dv; + //Loop through DataView and add Steps one at a time + //Console.WriteLine("={0}",drv["Step"]); + Byte FrType = 0; + Int32 FrID = str.StructureID; + foreach (DataRowView drvs in dv) + { + //Console.WriteLine(">{0}",drvs["CStep"]); + + string sParent = GetParent(drvs["CSequence"].ToString()); + if (dicStep.ContainsKey(sParent)) + { + Step stpp = dicStep[sParent]; + sType = GetStructType(drvs["CSequence"].ToString()); + Dictionary dicStr = dicStruct[sParent]; + if (dicStr.ContainsKey(sType)) + { + FrID = (Int32)dicStr[sType]; + FrType = 0; + } + else + { + FrID = (Int32)dicStr[""]; + FrType = (byte)(3 + ("CNRST".IndexOf(sType))); + } + Structure str1 = AddStructure(FrType, FrID, 3, tmpid++, drvs["CStep"].ToString() + drvs["CSequence"].ToString(), + GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString()); + Step stpc = AddStep(cn, drvs["Type"].ToString() + , (drvs["textm"] == DBNull.Value ? drvs["Text"].ToString() : drvs["Textm"].ToString()) + , drv["Recid"].ToString(), drvs["CStep"].ToString() + drvs["CSequence"].ToString(), GetStructType(drvs["sequence"].ToString()), str1.StructureID + , GetDTS(drvs["Date"].ToString(), drvs["Time"].ToString()), drvs["Initials"].ToString()); + str1.ContentID = stpc.StepID; + str1.Save(true); + dicStep[drvs["CSequence"].ToString()] = stpc; + + dicBase = new Dictionary(); + dicStruct[drvs["CSequence"].ToString()] = dicBase; + dicBase[""] = str1.StructureID; + dicStr[sType] = str1.StructureID; + } + else + { + log.ErrorFormat("Parent {0} Could not be found for {1}", sParent, drvs["sequence"].ToString()); + } + } + return str.StructureID; + } + catch (Exception ex) + { + log.Error("PROCESS STEP"); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + log.ErrorFormat(ex.StackTrace); + return 0; + } + //return 0; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/Structures.cs b/PROMS/proms/DataLoader/Structures.cs new file mode 100644 index 00000000..752c6536 --- /dev/null +++ b/PROMS/proms/DataLoader/Structures.cs @@ -0,0 +1,70 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private Structure AddStructure(byte FromType, int FromID, byte ContentType, int ContentID, string stpseq, + DateTime dts, string userid) + { + Structure str = null; + string str_key = ProcNumber + "|"; + switch (ContentType) + { + case 1: + str_key += stpseq; + break; + case 2: + str_key += stpseq.Substring(0, 1)+"0"; + break; + default: + str_key += stpseq; + break; + } + if (dicTrans_StrIds.ContainsKey(str_key)) + { + str = Structure.Get(dicTrans_StrIds[str_key]); + str.FromID = FromID; + str.FromType = FromType; + str.ContentID = ContentID; + str.ContentType = ContentType; + str.DTS = dts; + str.UserID = (userid==null||userid=="")?"empty":userid; + str.Save(true); ; + dicTrans_StrIds.Remove(str_key); + } + else + { + str = Structure.MakeStructure(FromType, FromID, ContentType, ContentID, dts, userid); + } + if (dicTrans_StrDone.ContainsKey(str_key)) + log.ErrorFormat("Duplicate proc/sequence number during structure migration: {0}", str_key); + else + dicTrans_StrDone.Add(str_key, str.StructureID); + + return str; + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/TextConvert.cs b/PROMS/proms/DataLoader/TextConvert.cs new file mode 100644 index 00000000..09d1c533 --- /dev/null +++ b/PROMS/proms/DataLoader/TextConvert.cs @@ -0,0 +1,120 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace DataLoader +{ + public static class TextConvert + { + static TextConvert() + { + BuildDictionarySeq(); + BuildDictionaryText(); + } + + private static Dictionary dicChar; + public static void BuildDictionarySeq() + { + dicChar = new Dictionary(); + for (int i = 0; i < 128; i++) dicChar[i] = i; + dicChar[199] = 128; dicChar[252] = 129; dicChar[233] = 130; dicChar[226] = 131; + dicChar[228] = 132; dicChar[224] = 133; dicChar[229] = 134; dicChar[231] = 135; + dicChar[234] = 136; dicChar[235] = 137; dicChar[232] = 138; dicChar[239] = 139; + dicChar[238] = 140; dicChar[236] = 141; dicChar[196] = 142; dicChar[197] = 143; + dicChar[201] = 144; dicChar[230] = 145; dicChar[198] = 146; dicChar[244] = 147; + dicChar[246] = 148; dicChar[242] = 149; dicChar[251] = 150; dicChar[249] = 151; + dicChar[255] = 152; dicChar[214] = 153; dicChar[220] = 154; dicChar[162] = 155; + dicChar[163] = 156; dicChar[165] = 157; dicChar[8359] = 158; dicChar[402] = 159; + dicChar[225] = 160; dicChar[237] = 161; dicChar[243] = 162; dicChar[250] = 163; + dicChar[241] = 164; dicChar[209] = 165; dicChar[170] = 166; dicChar[186] = 167; + dicChar[191] = 168; dicChar[8976] = 169; dicChar[172] = 170; dicChar[189] = 171; + dicChar[188] = 172; dicChar[161] = 173; dicChar[171] = 174; dicChar[187] = 175; + dicChar[9617] = 176; dicChar[9618] = 177; dicChar[9619] = 178; dicChar[9474] = 179; + dicChar[9508] = 180; dicChar[9569] = 181; dicChar[9570] = 182; dicChar[9558] = 183; + dicChar[9557] = 184; dicChar[9571] = 185; dicChar[9553] = 186; dicChar[9559] = 187; + dicChar[9565] = 188; dicChar[9564] = 189; dicChar[9563] = 190; dicChar[9488] = 191; + dicChar[9492] = 192; dicChar[9524] = 193; dicChar[9516] = 194; dicChar[9500] = 195; + dicChar[9472] = 196; dicChar[9532] = 197; dicChar[9566] = 198; dicChar[9567] = 199; + dicChar[9562] = 200; dicChar[9556] = 201; dicChar[9577] = 202; dicChar[9574] = 203; + dicChar[9568] = 204; dicChar[9552] = 205; dicChar[9580] = 206; dicChar[9575] = 207; + dicChar[9576] = 208; dicChar[9572] = 209; dicChar[9573] = 210; dicChar[9561] = 211; + dicChar[9560] = 212; dicChar[9554] = 213; dicChar[9555] = 214; dicChar[9579] = 215; + dicChar[9578] = 216; dicChar[9496] = 217; dicChar[9484] = 218; dicChar[9608] = 219; + dicChar[9604] = 220; dicChar[9612] = 221; dicChar[9616] = 222; dicChar[9600] = 223; + dicChar[945] = 224; dicChar[223] = 225; dicChar[915] = 226; dicChar[960] = 227; + dicChar[931] = 228; dicChar[963] = 229; dicChar[181] = 230; dicChar[964] = 231; + dicChar[934] = 232; dicChar[920] = 233; dicChar[937] = 234; dicChar[948] = 235; + dicChar[8734] = 236; dicChar[966] = 237; dicChar[949] = 238; dicChar[8745] = 239; + dicChar[8801] = 240; dicChar[177] = 241; dicChar[8805] = 242; dicChar[8804] = 243; + dicChar[8992] = 244; dicChar[8993] = 245; dicChar[247] = 246; dicChar[8776] = 247; + dicChar[176] = 248; dicChar[8729] = 249; dicChar[183] = 250; dicChar[8730] = 251; + dicChar[8319] = 252; dicChar[178] = 253; dicChar[9632] = 254; dicChar[160] = 255; + } + public static string ConvertSeq(string s1) + { + Encoding Eibm437 = Encoding.GetEncoding(437); + Encoding Eunicode = Encoding.Unicode; + Decoder d = Eibm437.GetDecoder(); + Byte[] bs1 = Eunicode.GetBytes(s1); + Byte[] bs2 = Encoding.Convert(Eunicode, Eibm437, bs1); + char[] cs2 = new char[Eibm437.GetCharCount(bs2)]; + for (int i = 0; i < cs2.Length; i++) cs2[i] = (char)bs2[i]; + return new string(cs2); + } + + public static Regex Reg2; + public static void BuildDictionaryText() + { + dicChar = new Dictionary(); + dicChar[966] = 216; + dicChar[201] = 274; + dicChar[127] = 916; + dicChar[964] = 947; + dicChar[920] = 952; + dicChar[915] = 961; + dicChar[191] = 964; + dicChar[8801] = 8773; + dicChar[8734] = 8857; + dicChar[7] = 9679; + dicChar[8976] = 9830; + char[] creg = new char[dicChar.Count]; + int i = 0; + foreach (int ic in dicChar.Keys) + { + creg[i] = (char)ic; + i++; + } + Reg2 = new Regex("[" + new string(creg) + "]"); + } + public static string ReplaceChars(Match m) + { + char[] cs = m.Value.ToCharArray(); + for (int i = 0; i < cs.Length; i++) + { + if (dicChar.ContainsKey((int)(cs[i]))) + { + int iKey = (int)cs[i]; + int iValue = dicChar[iKey]; + cs[i] = (char)iValue; + } + } + return new string(cs); + } + public static string ConvertText(string s1) + { + string s2 = Reg2.Replace(s1, new MatchEvaluator(ReplaceChars)); + return s2; + } + } +} diff --git a/PROMS/proms/DataLoader/Transitions.cs b/PROMS/proms/DataLoader/Transitions.cs new file mode 100644 index 00000000..3cae776d --- /dev/null +++ b/PROMS/proms/DataLoader/Transitions.cs @@ -0,0 +1,139 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.CSLA.Library; + +namespace DataLoader +{ + public partial class frmLoader : Form + { + private int AddTrans(int fromId, DataRow dr) + { + //TODO: ZTransitions tr.Oldto = dr["OLDTO"].ToString(); + string thekey = dr["TONUMBER"].ToString() + "|" + dr["TOSEQUENCE"].ToString(); + string dti = dr["DTI"].ToString().PadRight(18, ' '); + string userid = dti.Substring(13, 5).Trim(); + DateTime dts = GetDTS(MakeDate(dti.Substring(0, 8).Trim()), dti.Substring(8, 5).Trim()); + // if it's in the dictionary of structure elements already migrated, just use this + // structure id, or if it's in the dictionary of structure elements that have + // not been migrated but a record was created from this code, use it. Otherwise + // create a new structure record and use its id, its data will be updated later. + // a structure record. + int toid; + if (dicTrans_StrDone.ContainsKey(thekey)) + toid = dicTrans_StrDone[thekey]; + else + { + if (dicTrans_StrIds.ContainsKey(thekey)) + toid = dicTrans_StrIds[thekey]; + else + { + Structure str = Structure.MakeStructure(0, 0, 0, 0); + toid = str.StructureID; + dicTrans_StrIds.Add(thekey, toid); + } + } + Transition tr = Transition.MakeTransition(fromId, toid, System.Convert.ToInt32(dr["TYPE"].ToString()),0,0,0,0,dts,userid); + return tr.TransitionId; + } + + private string MigrateTrans(OleDbConnection cn, string textm, string seqcvt, int structId) + { + StringBuilder trtxt = new StringBuilder(); + int instance = 0; + int beg = 0; + DataTable dt = null; + DataSet ds = null; + OleDbDataAdapter da = null; + + char[] chrtrn = { '\x252C', '\x2566' }; + int tok = textm.IndexOfAny(chrtrn); + if (tok > -1) + { + string cmd = "SELECT * FROM [tran] WHERE [FROMNUMBER]='" + ProcNumber.Replace("'", "''") + "' AND [FROMSEQUEN] ='" + seqcvt + "' ORDER BY [FROMINSTAN]"; + da = new OleDbDataAdapter(cmd, cn); + // get transition records for this step. + ds = new DataSet(); + try + { + da.Fill(ds); + dt = ds.Tables[0]; + dt.CaseSensitive = true; + } + catch (Exception ex) + { + log.Error("Error getting transitions"); + log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + return textm; + } + } + while (tok > -1) + { + // found a transition token, add the token and transition id into the string and + // add an transition record for it. Later there may be text added. + trtxt.Append(textm.Substring(beg, tok - beg)); + // we have too many tokens and not enough usage records - report an error... + if (instance >= dt.Rows.Count) + { + log.ErrorFormat("Error - ran out of usage records for step, check data "); + log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt); + } + else + { + DataRow dr = dt.Rows[instance]; + int trid = AddTrans(structId, dr); + trtxt.Append(textm[tok]); + trtxt.Append("{{"); + trtxt.Append(trid.ToString()); + trtxt.Append("}}"); + } + instance++; + beg = tok + 1; + if (beg > textm.Length) + { + tok = -1; + da.Dispose(); + } + else + tok = textm.IndexOfAny(chrtrn, beg); + } + if (beg < textm.Length - 1) + trtxt.Append(textm.Substring(beg, textm.Length - beg)); + if (dt.Rows.Count > instance + 1) + { + log.ErrorFormat("Error - extra usage records for step, check data "); + log.ErrorFormat("from number = {0} oldstepsequence = {1}", ProcNumber, seqcvt); + } + return trtxt.ToString(); + } + private void ShowMissingTransitions() + { + log.Info("Missing Transitions"); + foreach (string s in dicTrans_StrIds.Keys) + { + log.InfoFormat("{0} - {1}", s, dicTrans_StrIds[s]); + } + log.Info("End of Missing Transitions"); + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/frmLoader.Designer.cs b/PROMS/proms/DataLoader/frmLoader.Designer.cs new file mode 100644 index 00000000..8cc7822a --- /dev/null +++ b/PROMS/proms/DataLoader/frmLoader.Designer.cs @@ -0,0 +1,382 @@ +namespace DataLoader +{ + partial class frmLoader + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.sc = new System.Windows.Forms.SplitContainer(); + this.btnVETree_CSLA = new System.Windows.Forms.Button(); + this.btnBrowseVesam = new System.Windows.Forms.Button(); + this.tbVesamPath = new System.Windows.Forms.TextBox(); + this.btnVesam = new System.Windows.Forms.Button(); + this.btnLoadTreeCSLA = new System.Windows.Forms.Button(); + this.cbLazy = new System.Windows.Forms.CheckBox(); + this.btnConvertSelected = new System.Windows.Forms.Button(); + this.btnLoadTreeDB = new System.Windows.Forms.Button(); + this.cbPurgeData = new System.Windows.Forms.CheckBox(); + this.lblTime = new System.Windows.Forms.Label(); + this.pbStep = new System.Windows.Forms.ProgressBar(); + this.pbSect = new System.Windows.Forms.ProgressBar(); + this.pbProc = new System.Windows.Forms.ProgressBar(); + this.cbSaveDoc = new System.Windows.Forms.CheckBox(); + this.cbSaveRTF = new System.Windows.Forms.CheckBox(); + this.btnBrowse = new System.Windows.Forms.Button(); + this.tbSource = new System.Windows.Forms.TextBox(); + this.lblStep = new System.Windows.Forms.Label(); + this.lblSection = new System.Windows.Forms.Label(); + this.lblProc = new System.Windows.Forms.Label(); + this.btnConvert = new System.Windows.Forms.Button(); + this.tv = new System.Windows.Forms.TreeView(); + this.fbd = new System.Windows.Forms.FolderBrowserDialog(); + this.btnGroup = new System.Windows.Forms.Button(); + this.sc.Panel1.SuspendLayout(); + this.sc.Panel2.SuspendLayout(); + this.sc.SuspendLayout(); + this.SuspendLayout(); + // + // sc + // + this.sc.Dock = System.Windows.Forms.DockStyle.Fill; + this.sc.Location = new System.Drawing.Point(0, 0); + this.sc.Margin = new System.Windows.Forms.Padding(2); + this.sc.Name = "sc"; + this.sc.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // sc.Panel1 + // + this.sc.Panel1.Controls.Add(this.btnGroup); + this.sc.Panel1.Controls.Add(this.btnVETree_CSLA); + this.sc.Panel1.Controls.Add(this.btnBrowseVesam); + this.sc.Panel1.Controls.Add(this.tbVesamPath); + this.sc.Panel1.Controls.Add(this.btnVesam); + this.sc.Panel1.Controls.Add(this.btnLoadTreeCSLA); + this.sc.Panel1.Controls.Add(this.cbLazy); + this.sc.Panel1.Controls.Add(this.btnConvertSelected); + this.sc.Panel1.Controls.Add(this.btnLoadTreeDB); + this.sc.Panel1.Controls.Add(this.cbPurgeData); + this.sc.Panel1.Controls.Add(this.lblTime); + this.sc.Panel1.Controls.Add(this.pbStep); + this.sc.Panel1.Controls.Add(this.pbSect); + this.sc.Panel1.Controls.Add(this.pbProc); + this.sc.Panel1.Controls.Add(this.cbSaveDoc); + this.sc.Panel1.Controls.Add(this.cbSaveRTF); + this.sc.Panel1.Controls.Add(this.btnBrowse); + this.sc.Panel1.Controls.Add(this.tbSource); + this.sc.Panel1.Controls.Add(this.lblStep); + this.sc.Panel1.Controls.Add(this.lblSection); + this.sc.Panel1.Controls.Add(this.lblProc); + this.sc.Panel1.Controls.Add(this.btnConvert); + // + // sc.Panel2 + // + this.sc.Panel2.Controls.Add(this.tv); + this.sc.Size = new System.Drawing.Size(623, 413); + this.sc.SplitterDistance = 172; + this.sc.SplitterWidth = 3; + this.sc.TabIndex = 46; + // + // btnVETree_CSLA + // + this.btnVETree_CSLA.Location = new System.Drawing.Point(293, 121); + this.btnVETree_CSLA.Name = "btnVETree_CSLA"; + this.btnVETree_CSLA.Size = new System.Drawing.Size(145, 21); + this.btnVETree_CSLA.TabIndex = 68; + this.btnVETree_CSLA.Text = "Load VETree from CSLA"; + this.btnVETree_CSLA.UseVisualStyleBackColor = true; + this.btnVETree_CSLA.Click += new System.EventHandler(this.btnVETree_CSLA_Click); + // + // btnBrowseVesam + // + this.btnBrowseVesam.Location = new System.Drawing.Point(479, 150); + this.btnBrowseVesam.Margin = new System.Windows.Forms.Padding(2); + this.btnBrowseVesam.Name = "btnBrowseVesam"; + this.btnBrowseVesam.Size = new System.Drawing.Size(119, 19); + this.btnBrowseVesam.TabIndex = 67; + this.btnBrowseVesam.Text = "Browse for Vesam..."; + this.btnBrowseVesam.UseVisualStyleBackColor = true; + this.btnBrowseVesam.Click += new System.EventHandler(this.btnBrowseVesam_Click); + // + // tbVesamPath + // + this.tbVesamPath.Location = new System.Drawing.Point(114, 150); + this.tbVesamPath.Name = "tbVesamPath"; + this.tbVesamPath.Size = new System.Drawing.Size(353, 20); + this.tbVesamPath.TabIndex = 66; + this.tbVesamPath.Text = "e:\\ve-proms\\vesam.opt"; + // + // btnVesam + // + this.btnVesam.Location = new System.Drawing.Point(2, 148); + this.btnVesam.Name = "btnVesam"; + this.btnVesam.Size = new System.Drawing.Size(108, 21); + this.btnVesam.TabIndex = 65; + this.btnVesam.Text = "Convert Security"; + this.btnVesam.UseVisualStyleBackColor = true; + this.btnVesam.Click += new System.EventHandler(this.btnVesam_Click); + // + // btnLoadTreeCSLA + // + this.btnLoadTreeCSLA.Location = new System.Drawing.Point(295, 96); + this.btnLoadTreeCSLA.Name = "btnLoadTreeCSLA"; + this.btnLoadTreeCSLA.Size = new System.Drawing.Size(144, 20); + this.btnLoadTreeCSLA.TabIndex = 64; + this.btnLoadTreeCSLA.Text = "Load Tree from CSLA"; + this.btnLoadTreeCSLA.UseVisualStyleBackColor = true; + this.btnLoadTreeCSLA.Click += new System.EventHandler(this.btnLoadTreeCSLA_Click); + // + // cbLazy + // + this.cbLazy.AutoSize = true; + this.cbLazy.Checked = true; + this.cbLazy.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbLazy.Location = new System.Drawing.Point(11, 126); + this.cbLazy.Margin = new System.Windows.Forms.Padding(2); + this.cbLazy.Name = "cbLazy"; + this.cbLazy.Size = new System.Drawing.Size(75, 17); + this.cbLazy.TabIndex = 63; + this.cbLazy.Text = "Lazy Load"; + this.cbLazy.UseVisualStyleBackColor = true; + // + // btnConvertSelected + // + this.btnConvertSelected.Location = new System.Drawing.Point(170, 97); + this.btnConvertSelected.Margin = new System.Windows.Forms.Padding(2); + this.btnConvertSelected.Name = "btnConvertSelected"; + this.btnConvertSelected.Size = new System.Drawing.Size(108, 19); + this.btnConvertSelected.TabIndex = 62; + this.btnConvertSelected.Text = "Convert Selected"; + this.btnConvertSelected.UseVisualStyleBackColor = true; + this.btnConvertSelected.Click += new System.EventHandler(this.btnConvertSelected_Click); + // + // btnLoadTreeDB + // + this.btnLoadTreeDB.Location = new System.Drawing.Point(450, 97); + this.btnLoadTreeDB.Margin = new System.Windows.Forms.Padding(2); + this.btnLoadTreeDB.Name = "btnLoadTreeDB"; + this.btnLoadTreeDB.Size = new System.Drawing.Size(124, 19); + this.btnLoadTreeDB.TabIndex = 60; + this.btnLoadTreeDB.Text = "Load Tree from dBase"; + this.btnLoadTreeDB.UseVisualStyleBackColor = true; + this.btnLoadTreeDB.Click += new System.EventHandler(this.btnLoadTreeDB_Click); + // + // cbPurgeData + // + this.cbPurgeData.AutoSize = true; + this.cbPurgeData.Checked = true; + this.cbPurgeData.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbPurgeData.Location = new System.Drawing.Point(479, 75); + this.cbPurgeData.Margin = new System.Windows.Forms.Padding(2); + this.cbPurgeData.Name = "cbPurgeData"; + this.cbPurgeData.Size = new System.Drawing.Size(119, 17); + this.cbPurgeData.TabIndex = 59; + this.cbPurgeData.Text = "Purge Existing Data"; + this.cbPurgeData.UseVisualStyleBackColor = true; + // + // lblTime + // + this.lblTime.BackColor = System.Drawing.SystemColors.ButtonShadow; + this.lblTime.Location = new System.Drawing.Point(70, 92); + this.lblTime.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblTime.Name = "lblTime"; + this.lblTime.Size = new System.Drawing.Size(84, 20); + this.lblTime.TabIndex = 58; + // + // pbStep + // + this.pbStep.Location = new System.Drawing.Point(160, 76); + this.pbStep.Margin = new System.Windows.Forms.Padding(2); + this.pbStep.Name = "pbStep"; + this.pbStep.Size = new System.Drawing.Size(308, 15); + this.pbStep.TabIndex = 57; + // + // pbSect + // + this.pbSect.Location = new System.Drawing.Point(160, 56); + this.pbSect.Margin = new System.Windows.Forms.Padding(2); + this.pbSect.Name = "pbSect"; + this.pbSect.Size = new System.Drawing.Size(307, 15); + this.pbSect.TabIndex = 56; + // + // pbProc + // + this.pbProc.Location = new System.Drawing.Point(160, 37); + this.pbProc.Margin = new System.Windows.Forms.Padding(2); + this.pbProc.Name = "pbProc"; + this.pbProc.Size = new System.Drawing.Size(308, 15); + this.pbProc.TabIndex = 55; + // + // cbSaveDoc + // + this.cbSaveDoc.AutoSize = true; + this.cbSaveDoc.Checked = true; + this.cbSaveDoc.CheckState = System.Windows.Forms.CheckState.Checked; + this.cbSaveDoc.Location = new System.Drawing.Point(480, 34); + this.cbSaveDoc.Margin = new System.Windows.Forms.Padding(2); + this.cbSaveDoc.Name = "cbSaveDoc"; + this.cbSaveDoc.Size = new System.Drawing.Size(77, 17); + this.cbSaveDoc.TabIndex = 54; + this.cbSaveDoc.Text = "Save DOC"; + this.cbSaveDoc.UseVisualStyleBackColor = true; + this.cbSaveDoc.Click += new System.EventHandler(this.cbSaveDoc_Click); + // + // cbSaveRTF + // + this.cbSaveRTF.AutoSize = true; + this.cbSaveRTF.Location = new System.Drawing.Point(480, 54); + this.cbSaveRTF.Margin = new System.Windows.Forms.Padding(2); + this.cbSaveRTF.Name = "cbSaveRTF"; + this.cbSaveRTF.Size = new System.Drawing.Size(75, 17); + this.cbSaveRTF.TabIndex = 53; + this.cbSaveRTF.Text = "Save RTF"; + this.cbSaveRTF.UseVisualStyleBackColor = true; + this.cbSaveRTF.Click += new System.EventHandler(this.cbSaveRTF_Click); + // + // btnBrowse + // + this.btnBrowse.Location = new System.Drawing.Point(479, 10); + this.btnBrowse.Margin = new System.Windows.Forms.Padding(2); + this.btnBrowse.Name = "btnBrowse"; + this.btnBrowse.Size = new System.Drawing.Size(56, 19); + this.btnBrowse.TabIndex = 52; + this.btnBrowse.Text = "Browse..."; + this.btnBrowse.UseVisualStyleBackColor = true; + this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); + // + // tbSource + // + this.tbSource.Location = new System.Drawing.Point(71, 10); + this.tbSource.Margin = new System.Windows.Forms.Padding(2); + this.tbSource.Name = "tbSource"; + this.tbSource.Size = new System.Drawing.Size(397, 20); + this.tbSource.TabIndex = 51; + this.tbSource.Text = "i:\\vedata\\vewcnfp\\fp.prc"; + // + // lblStep + // + this.lblStep.BackColor = System.Drawing.SystemColors.ButtonShadow; + this.lblStep.Location = new System.Drawing.Point(70, 72); + this.lblStep.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblStep.Name = "lblStep"; + this.lblStep.Size = new System.Drawing.Size(84, 20); + this.lblStep.TabIndex = 49; + // + // lblSection + // + this.lblSection.BackColor = System.Drawing.SystemColors.ButtonShadow; + this.lblSection.Location = new System.Drawing.Point(70, 53); + this.lblSection.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblSection.Name = "lblSection"; + this.lblSection.Size = new System.Drawing.Size(84, 19); + this.lblSection.TabIndex = 48; + // + // lblProc + // + this.lblProc.BackColor = System.Drawing.SystemColors.ButtonShadow; + this.lblProc.Location = new System.Drawing.Point(70, 34); + this.lblProc.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.lblProc.Name = "lblProc"; + this.lblProc.Size = new System.Drawing.Size(84, 19); + this.lblProc.TabIndex = 47; + // + // btnConvert + // + this.btnConvert.Location = new System.Drawing.Point(2, 9); + this.btnConvert.Margin = new System.Windows.Forms.Padding(2); + this.btnConvert.Name = "btnConvert"; + this.btnConvert.Size = new System.Drawing.Size(56, 19); + this.btnConvert.TabIndex = 46; + this.btnConvert.Text = "Convert"; + this.btnConvert.Click += new System.EventHandler(this.btnConvert_Click); + // + // tv + // + this.tv.CheckBoxes = true; + this.tv.Dock = System.Windows.Forms.DockStyle.Bottom; + this.tv.Location = new System.Drawing.Point(0, 1); + this.tv.Margin = new System.Windows.Forms.Padding(2); + this.tv.Name = "tv"; + this.tv.Size = new System.Drawing.Size(623, 237); + this.tv.TabIndex = 24; + this.tv.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tv_BeforeExpand); + this.tv.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterSelect); + // + // btnGroup + // + this.btnGroup.Location = new System.Drawing.Point(505, 118); + this.btnGroup.Name = "btnGroup"; + this.btnGroup.Size = new System.Drawing.Size(75, 23); + this.btnGroup.TabIndex = 69; + this.btnGroup.Text = "Group"; + this.btnGroup.UseVisualStyleBackColor = true; + this.btnGroup.Click += new System.EventHandler(this.btnGroup_Click); + // + // frmLoader + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(623, 413); + this.Controls.Add(this.sc); + this.Margin = new System.Windows.Forms.Padding(2); + this.Name = "frmLoader"; + this.Text = "frmLoader"; + this.sc.Panel1.ResumeLayout(false); + this.sc.Panel1.PerformLayout(); + this.sc.Panel2.ResumeLayout(false); + this.sc.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer sc; + private System.Windows.Forms.CheckBox cbLazy; + private System.Windows.Forms.Button btnConvertSelected; + private System.Windows.Forms.Button btnLoadTreeDB; + private System.Windows.Forms.CheckBox cbPurgeData; + private System.Windows.Forms.Label lblTime; + private System.Windows.Forms.ProgressBar pbStep; + private System.Windows.Forms.ProgressBar pbSect; + private System.Windows.Forms.ProgressBar pbProc; + private System.Windows.Forms.CheckBox cbSaveDoc; + private System.Windows.Forms.CheckBox cbSaveRTF; + private System.Windows.Forms.Button btnBrowse; + private System.Windows.Forms.TextBox tbSource; + private System.Windows.Forms.Label lblStep; + private System.Windows.Forms.Label lblSection; + private System.Windows.Forms.Label lblProc; + private System.Windows.Forms.Button btnConvert; + private System.Windows.Forms.TreeView tv; + private System.Windows.Forms.FolderBrowserDialog fbd; + private System.Windows.Forms.Button btnLoadTreeCSLA; + private System.Windows.Forms.TextBox tbVesamPath; + private System.Windows.Forms.Button btnVesam; + private System.Windows.Forms.Button btnBrowseVesam; + private System.Windows.Forms.Button btnVETree_CSLA; + private System.Windows.Forms.Button btnGroup; + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/frmLoader.cs b/PROMS/proms/DataLoader/frmLoader.cs new file mode 100644 index 00000000..d7a8a183 --- /dev/null +++ b/PROMS/proms/DataLoader/frmLoader.cs @@ -0,0 +1,416 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Data.OleDb; +using System.Collections.Specialized; +using System.Collections.Generic; +using System.Xml; +using System.IO; +using System.Text; +using Volian.MSWord; +using vlnObjectLibrary; +using vlnServerLibrary; +using Volian.CSLA.Library; +using Config; + +[assembly: log4net.Config.XmlConfigurator(Watch = true)] + +namespace DataLoader +{ + public partial class frmLoader : Form + { + + #region Log4Net + public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region ClassProperties + private int wms = 500; + private static int EDDATA = 0x01; + private static int PH = 0x02; + private static int TOC = 0x04; + private static int AUTOIND = 0x08; + private static int AUTOGEN = 0x40; + + private static int STP_COMMENT = 0; + private static int STP_MULT_CHGID = 1; + private static int STP_LNK_SEQ = 2; + private static int STP_OVR_TAB = 3; + + private string ProcFileName; + private string ProcNumber; + private ROFST rofst; + private int EditSectId; + private Dictionary dicLibDocRef; + + // have a few variables for storing the database id record & the system record. + private Connection dbConn; + private Folder sysFolder; + FolderTreeNode _topnode; + + // the following two dictionaries are used to handle migration of the + // transitions... dicTrans_StrDone gets an entry for procnumber, sequence + // number and the new structure id as a step or section is created (transitions + // can go to steps or sections). When a transition is encountered, check this + // dictionary to see if the step or section was migrated & use the structureid + // for the step or section if it was migrated. When a transition is migrated where + // the 'to' has not been migrated yet, check if an entry exists in dicTrans_StrIds, + // if so, use the id listed here. If no entry exists in dicTrans_StrIds, create + // a structure table record and use the id as part of the 'to', and add an entry to + // dicTrans_StpIds to flag that the record was already created. As migrating sections + // and steps, check this dicTrans_StrIds to see if the structure record has already + // been create, if so use it and remove it from the dicTrans_StrIds dictionary, + // otherwise, create a new structure record. + private Dictionary dicTrans_StrDone; + private Dictionary dicTrans_StrIds; + private Dictionary dicOldStepSequence; + private Dictionary dicNeedToLoad; + private bool UseVeTree = false; + #endregion + public frmLoader() + { + InitializeComponent(); + lblTime.Tag = DateTime.Now; + switch (SystemInformation.ComputerName.ToUpper()) + { + case "KATHYXP": + //tbSource.Text = "G:\\VEIP2\\PROCS"; // basic data + //tbSource.Text = "G:\\VEFNP\\AOP1.PRC"; // test subsections, checkoffs, comments & continuous action flag + //tbSource.Text = "G:\\vecal\\eops.bck"; // test link seq STP_LNK_SEQ + tbSource.Text = "G:\\vehlp\\procs";// multiple change ids. + break; + case "RHMDESKTOP": + //tbSource.Text = @"I:\UNZIPPED ACTIVE BASELINE DATA\vehlp\Procs"; // Sub-sections + tbSource.Text = @"I:\veDATA\vehlp\Procs"; // Sub-sections + break; + default: + throw new Exception("Not configured for " + SystemInformation.ComputerName); + } + dicNeedToLoad = new Dictionary(); + } + private void btnConvertSelected_Click(object sender, EventArgs e) + { + if (UseVeTree) + { + VETreeNode tn = (VETreeNode)tv.SelectedNode; + if (tn == null) + { + MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected"); + return; + } + object o = tn.VEObject; + //object o = tn.Tag; + if (o.GetType() != typeof(DocVersionInfo)) + { + MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected"); + return; + } + DocVersion v = ((DocVersionInfo)o).Get(); + int istr = MigrateDocVersion(v.Title); + if (istr > 0) + { + + v.StructureID = istr; + v.Title = ""; + v.Save(true); // true forces save. + tn.Checked = true; + //TODO: Walk up structure and set check boxes appropriately. + } + } + else + { + TreeNode tn = tv.SelectedNode; + if (tn == null) + { + MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected"); + return; + } + object o = tn.Tag; + if (o.GetType() != typeof(DocVersion)) + { + MessageBox.Show("Must select a version node (working draft, approved, etc)", "No Node Selected"); + return; + } + DocVersion v = (DocVersion)o; + int istr = MigrateDocVersion(v.Title); + if (istr > 0) + { + + v.StructureID = istr; + v.Title = ""; + v.Save(true); // true forces save. + tn.Checked = true; + //TODO: Walk up structure and set check boxes appropriately. + } + } + } + private void tv_BeforeExpand(object sender, TreeViewCancelEventArgs e) + { + if (UseVeTree) + { + ((VETreeNode)e.Node).LoadChildren(); + return; + } + + TreeNode tn = e.Node; + object o = tn.Tag; + switch (o.GetType().ToString()) + { + case "Volian.CSLA.Library.FolderInfo": + FolderInfo fld = (FolderInfo)o; + if (fld.DocVersionCount>0) + tn.Checked = LoadChildren(fld, tn); // load docversions. + break; + default: + break; + } + } + private void tv_AfterSelect(object sender, TreeViewEventArgs e) + { + if (UseVeTree) return; + + TreeNode tn = e.Node; + object o = tn.Tag; + tn.Expand(); + if (o.GetType() == typeof(DocVersion)) tbSource.Text = ((DocVersion)o).Title; + } + + private bool LoadFolders() + { + try + { + // make the initial database connection record + dbConn = Connection.MakeConnection("Default", "Default", "Data Source=.\\SQLEXPRESS;Initial Catalog=VEPROMS;Integrated Security=True", 1, null); + ConfigFile cfg = new ConfigFile(); + + + XmlDocument d = cfg.LoadSystemIni(); + sysFolder = Folder.MakeFolder(0, dbConn.DBID, "system", "system", d.InnerXml); + + // This is to test the vln Libraries + List lfldr = vlnDataPathFolders(); + + List dp2 = new List(); + foreach (Folder fldr in lfldr) + { + TreeNode tn = tv.Nodes.Add(fldr.Name); + tn.Tag = fldr; + vlnObject vb = new vlnObject(null, "datapath", fldr.Name, fldr.Title); + dp2.Add(vb); + vlnServer vs = new vlnServer(); + MigrateChildren(vb, vs, fldr.DBID, fldr.FolderID, tn); + tn.Expand(); + } + } + catch (Exception ex) + { + log.ErrorFormat("Could not load data, error = {0}", ex.Message); + return false; + } + return true; + } + private void btnLoadTreeDB_Click(object sender, EventArgs e) + { + // When loading folders, i.e. the tree from dBase (old 16-bit) + // always clear the data + ClearData(); + bool suc = LoadFolders(); + } + + private void btnConvert_Click(object sender, System.EventArgs e) + { + bool success = true; + // if purge data, purge it all & reload folders & security. + if (cbPurgeData.Checked) + { + ClearData(); + success=LoadFolders(); + if (success)success=LoadSecurity(); + } + if (success) MigrateDocVersion(tbSource.Text); + } + private void UpdateLabels(int incPrc, int incSec, int incStp) + { + if (incPrc == 0 && incSec == 0 && incStp == 0)//Reset + { + lblTime.Tag = DateTime.Now; + pbProc.Value = 0; + pbSect.Value = 0; + pbStep.Value = 0; + } + else + { + try + { + pbProc.Value += incPrc; + pbSect.Value += incSec; + pbStep.Value += incStp; + } + catch (Exception ex) + { + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + } + } + lblProc.Text = string.Format("{0} Procedures", pbProc.Value); + lblSection.Text = string.Format("{0} Sections", pbSect.Value); + lblStep.Text = string.Format("{0} Steps", pbStep.Value); + //pbProc.Value = iPrc; + //pbSect.Value = iSec; + //pbStep.Value = iStp; + TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - ((DateTime)lblTime.Tag).Ticks); + lblTime.Text = string.Format("{0:D2}:{1:D2}:{2:D2} Elapsed", ts.Hours, ts.Minutes, ts.Seconds); + Application.DoEvents(); + } + private void btnBrowse_Click(object sender, EventArgs e) + { + fbd.SelectedPath = tbSource.Text; + if (fbd.ShowDialog() == DialogResult.OK) + tbSource.Text = fbd.SelectedPath; + } + private void cbSaveRTF_Click(object sender, EventArgs e) + { + if (cbSaveRTF.Checked) cbSaveDoc.Checked = false; + } + private void cbSaveDoc_Click(object sender, EventArgs e) + { + if (cbSaveDoc.Checked) cbSaveRTF.Checked = false; + } + private void Wait(int n) + { + DateTime dtw = DateTime.Now.AddSeconds(n); + while (DateTime.Now < dtw) + { + Application.DoEvents(); + } + } + private void WaitMS(int n) + { + DateTime dtw = DateTime.Now.AddMilliseconds(n); + while (DateTime.Now < dtw) + { + Application.DoEvents(); + } + } + private void ClearData() + { + Database.PurgeData(); + } + public static string MakeDate(string src) + { + if (src.Trim() == "") return null; + int[] DateOffset ={ 4, 5, 47, 6, 7, 47, 0, 1, 2, 3 }; // 47 = '/' + StringBuilder datebuff = new StringBuilder(10); + for (int i = 0; i < DateOffset.Length; i++) + { + if (DateOffset[i] < 9) + datebuff.Append(src[DateOffset[i]]); + else + datebuff.Append(System.Convert.ToChar(DateOffset[i])); + } + return datebuff.ToString(); + } + private DateTime GetDTS(string date, string time) + { + // Set the date/time stamp. If there is no 'date', set the date + // to 1/1/2000 (this can be changed!). If there is not 'time', + // set the time to 0:0:0 (midnight). + + DateTime dts = DateTime.Now; + string month = "01"; + string day = "01"; + string year = "2000"; + string hour = ""; + string minute = ""; + try + { + if (date != null && date != "") + { + int indx1 = date.IndexOf("/"); + month = date.Substring(0, indx1); + int indx2 = date.IndexOf("/", indx1 + 1); + day = date.Substring(indx1 + 1, indx2 - indx1 - 1); + year = date.Substring(indx2 + 1, 4); + } + if (time == null || time == "") + { + hour = "0"; + minute = "0"; + } + else + { + + hour = time.Substring(0, 2); + int indxc = time.IndexOfAny(":A-".ToCharArray()); + if (indxc == time.Length - 1) + minute = time.Substring(2, 2); + else + minute = time.Substring(indxc + 1, time.Length - indxc - 1); + } + dts = new DateTime(System.Convert.ToInt32(year), System.Convert.ToInt32(month), System.Convert.ToInt32(day), + System.Convert.ToInt32(hour), System.Convert.ToInt32(minute), 0); + } + catch (Exception ex) + { + log.ErrorFormat("DATE/TIME {0} {1}", date, time); + log.ErrorFormat("{0}\r\n\r\n{1}", ex.Message, ex.InnerException); + log.ErrorFormat(ex.StackTrace); + return dts; + } + return dts; + } + private void btnLoadTreeCSLA_Click(object sender, EventArgs e) + { + _topnode = FolderTreeNode.BuildTreeList(); + tv.Nodes.Add(_topnode); + tv.Nodes[0].Expand(); + UseVeTree = false; + } + + private void btnBrowseVesam_Click(object sender, EventArgs e) + { + fbd.SelectedPath = tbVesamPath.Text; + if (fbd.ShowDialog() == DialogResult.OK) + tbVesamPath.Text = fbd.SelectedPath; + } + + private bool LoadSecurity() + { + Security sec = new Security(tbVesamPath.Text); + return sec.Migrate(); + } + + private void btnVesam_Click(object sender, EventArgs e) + { + // if purge data, purge it all & reload folders. + if (cbPurgeData.Checked) + { + ClearData(); + LoadFolders(); + } + bool sec = LoadSecurity(); + } + + private void btnVETree_CSLA_Click(object sender, EventArgs e) + { + tv.Nodes.Add(VEFolder.LoadTree()); + UseVeTree = true; + } + + private void btnGroup_Click(object sender, EventArgs e) + { + GroupProp f = new GroupProp(); + f.ShowDialog(); + } + } +} \ No newline at end of file diff --git a/PROMS/proms/DataLoader/frmLoader.resx b/PROMS/proms/DataLoader/frmLoader.resx new file mode 100644 index 00000000..3edce43f --- /dev/null +++ b/PROMS/proms/DataLoader/frmLoader.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/PROMS/proms/Volian.CSLA.Library/Config/FolderConfig.cs b/PROMS/proms/Volian.CSLA.Library/Config/FolderConfig.cs new file mode 100644 index 00000000..c1aa9fbf --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Config/FolderConfig.cs @@ -0,0 +1,329 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel; + +namespace Volian.CSLA.Library +{ + [Serializable] + [TypeConverter(typeof(ExpandableObjectConverter))] + public class FolderConfig:INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + private void OnPropertyChanged(String info) + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(info)); + } + private XMLProperties _Xp; + private XMLProperties Xp + { + get { return _Xp; } + } + public FolderConfig(string xml) + { + if (xml == string.Empty) xml = ""; + _Xp = new XMLProperties(xml); + } + public FolderConfig() + { + _Xp = new XMLProperties(); + } + public override string ToString() + { + string s = _Xp.ToString(); + if (s == "" || s == "") return string.Empty; + return s; + } + #region FormatCategory + public enum FormatColumns : int + { + Default=0,OneColumn,TwoColumn,ThreeColumn,FourColumns + } + [Category("Format")] + [DisplayName("Column Layout")] + [RefreshProperties(RefreshProperties.All)] + [Description("Column Layout")] + public FormatColumns Format_Columns + { + get + { + string s = _Xp["format", "columns"]; + if (s == string.Empty) return (FormatColumns)0; + return (FormatColumns)int.Parse(_Xp["format", "columns"]); + //return Enum.Parse(typeof(FormatColumns),_Xp["format", "columns"]); + } + set + { + if (value == 0) _Xp["format", "columns"] = string.Empty; + else _Xp["format", "columns"] = ((int)value).ToString(); + OnPropertyChanged("Format_Columns"); + } + } + [Category("Format")] + [DisplayName("Plant Format Name")] + [RefreshProperties(RefreshProperties.All)] + [Description("Default Plant Format")] + public string Format_Plant + { + get + { return _Xp["format", "plant"]; + } + set + { + _Xp["format", "plant"] = value; + OnPropertyChanged("Format_Plant"); + } + } + #endregion + #region DefaultsCategory + [Category("Defaults")] + [DisplayName("Default Setpoint Prefix")] + [RefreshProperties(RefreshProperties.All)] + [Description("Default Setpoint Prefix")] + public string Default_SPPrefix + { + get { return _Xp["default", "spprefix"]; } + set + { + _Xp["default", "spprefix"] = value; + OnPropertyChanged("Default_SPPrefix"); + } + } + [Category("Defaults")] + [DisplayName("Default Image Prefix")] + [RefreshProperties(RefreshProperties.All)] + [Description("Default Image Prefix")] + public string Default_IMPrefix + { + get { return _Xp["default", "imprefix"]; } + set + { + _Xp["default", "imprefix"] = value; + OnPropertyChanged("RO_IMPrefix"); + } + } + #endregion + #region PrintSettingsCategory + [Category("Print Settings")] + [DisplayName("Number of Copies")] + [RefreshProperties(RefreshProperties.All)] + [Description("Number of Copies")] + public int Print_NumCopies + { + get + { + string s = _Xp["PrintSettings", "numcopies"]; + if (s == string.Empty) return 1; + return int.Parse(_Xp["PrintSettings", "numcopies"]); + } + set + { + _Xp["PrintSettings", "numcopies"] = value.ToString(); + OnPropertyChanged("Print_NumCopies"); + } + } + public enum PrintPagination : int + { + Free = 0, Fixed, Auto + } + [Category("Print Settings")] + [DisplayName("Pagination")] + [RefreshProperties(RefreshProperties.All)] + [Description("Pagination")] + public PrintPagination Print_Pagination + { + get + { + string s = _Xp["PrintSettings", "Pagination"]; + if (s == string.Empty) return PrintPagination.Auto; + return (PrintPagination)int.Parse(_Xp["PrintSettings", "Pagination"]); + } + set + { + if (value == PrintPagination.Auto) _Xp["PrintSettings", "Pagination"] = string.Empty; + else _Xp["PrintSettings", "Pagination"] = ((int)value).ToString(); + OnPropertyChanged("Print_Pagination"); + } + } + public enum PrintWatermark : int + { + None = 0, Reference, Draft, Master, Sample, InformationOnly + } + [Category("Print Settings")] + [DisplayName("Watermark")] + [RefreshProperties(RefreshProperties.All)] + [Description("Watermark")] + public PrintWatermark Print_Watermark + { + get + { + string s = _Xp["PrintSettings", "Watermark"]; + if (s == string.Empty) return PrintWatermark.Draft; + return (PrintWatermark)int.Parse(_Xp["PrintSettings", "Watermark"]); + } + set + { + if (value == PrintWatermark.Draft) _Xp["PrintSettings", "Watermark"] = string.Empty; + else _Xp["PrintSettings", "Watermark"] = ((int)value).ToString(); + OnPropertyChanged("Print_Watermark"); + } + } + [Category("Print Settings")] + [DisplayName("Disable Duplex Printing")] + [RefreshProperties(RefreshProperties.All)] + [Description("Disable Duplex Printing")] + public bool Print_DisableDuplex + { + get + { + string s = _Xp["PrintSettings", "disableduplex"]; + if (s == string.Empty) return false; + return bool.Parse(_Xp["PrintSettings", "disableduplex"]); + } + set + { + _Xp["PrintSettings", "disableduplex"] = value.ToString(); + OnPropertyChanged("Print_DisableDuplex"); + } + } + // Change Bar Use from 16-bit code: + // No Default + // Without Change Bars + // With Default Change Bars + // With User Specified Change Bars + public enum PrintChangeBar : int + { + NoDefault=0, Without, WithDefault, WithUserSpecified + } + [Category("Print Settings")] + [DisplayName("Change Bar")] + [RefreshProperties(RefreshProperties.All)] + [Description("Change Bar Use")] + public PrintChangeBar Print_ChangeBar + { + get + { + string s = _Xp["PrintSettings", "ChangeBar"]; + if (s == string.Empty) return PrintChangeBar.NoDefault; + return (PrintChangeBar)int.Parse(_Xp["PrintSettings", "ChangeBar"]); + } + set + { + if (value == PrintChangeBar.NoDefault) _Xp["PrintSettings", "ChangeBar"] = string.Empty; + else _Xp["PrintSettings", "ChangeBar"] = ((int)value).ToString(); + OnPropertyChanged("Print_ChangeBar"); + } + } + // User Specified Change Bar Location from16-bit code: + // With Text + // Outside Box + // AER on LEFT, RNO on Right + // To the Left of Text + public enum PrintChangeBarLoc : int + { + WithText = 0, OutsideBox, AERleftRNOright, LeftOfText + } + [Category("Print Settings")] + [DisplayName("Change Bar Location")] + [RefreshProperties(RefreshProperties.All)] + [Description("User Specified Change Bar Location")] + public PrintChangeBarLoc Print_ChangeBarLoc + { + get + { + string s = _Xp["PrintSettings", "ChangeBarLoc"]; + if (s == string.Empty) return PrintChangeBarLoc.WithText; + return (PrintChangeBarLoc)int.Parse(_Xp["PrintSettings", "ChangeBarLoc"]); + } + set + { + if (value == PrintChangeBarLoc.WithText) _Xp["PrintSettings", "ChangeBarLoc"] = string.Empty; + else _Xp["PrintSettings", "ChangeBarLoc"] = ((int)value).ToString(); + OnPropertyChanged("Print_ChangeBarLoc"); + } + } + + // Change Bar Text from16-bit code: + // Date and Change ID + // Revision Number + // Change ID + // No Change Bar Message + // User Defined Message + public enum PrintChangeBarText : int + { + DateChgID = 0, RevNum, ChgID, None, UserDef + } + [Category("Print Settings")] + [DisplayName("Change Bar Text")] + [RefreshProperties(RefreshProperties.All)] + [Description("Change Bar Text")] + public PrintChangeBarText Print_ChangeBarText + { + get + { + string s = _Xp["PrintSettings", "ChangeBarText"]; + if (s == string.Empty) return PrintChangeBarText.DateChgID; + return (PrintChangeBarText)int.Parse(_Xp["PrintSettings", "ChangeBarText"]); + } + set + { + if (value == PrintChangeBarText.DateChgID) _Xp["PrintSettings", "ChangeBarText"] = string.Empty; + else _Xp["PrintSettings", "ChangeBarText"] = ((int)value).ToString(); + OnPropertyChanged("Print_ChangeBarText"); + } + } + + [Category("Print Settings")] + [DisplayName("User Format")] + [RefreshProperties(RefreshProperties.All)] + [Description("User Format")] + public string Print_UserFormat + { + get + { + return _Xp["PrintSettings", "userformat"]; + } + set + { + _Xp["PrintSettings", "userformat"] = value; + OnPropertyChanged("Print_UserFormat"); + } + } + + [Category("Print Settings")] + [DisplayName("User Change Bar Message1")] + [RefreshProperties(RefreshProperties.All)] + [Description("User Change Bar Message1")] + public string Print_UserCBMess1 + { + get + { + return _Xp["PrintSettings", "usercbmess1"]; + } + set + { + _Xp["PrintSettings", "usercbmess1"] = value; + OnPropertyChanged("Print_UserCBMess1"); + } + } + + [Category("Print Settings")] + [DisplayName("User Change Bar Message2")] + [RefreshProperties(RefreshProperties.All)] + [Description("User Change Bar Message2")] + public string Print_UserCBMess2 + { + get + { + return _Xp["PrintSettings", "usercbmess2"]; + } + set + { + _Xp["PrintSettings", "usercbmess2"] = value; + OnPropertyChanged("Print_UserCBMess2"); + } + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Config/XMLProperties.cs b/PROMS/proms/Volian.CSLA.Library/Config/XMLProperties.cs new file mode 100644 index 00000000..50f4511d --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Config/XMLProperties.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.Serialization; +using System.Xml; + +namespace Volian.CSLA.Library +{ + [Serializable()] + class XMLProperties + { + #region Constructors + public XMLProperties() + { + _XmlContents = new XmlDocument(); + _XmlContents.LoadXml(""); + } + public XMLProperties(string xml) + { + _XmlContents = new XmlDocument(); + _XmlContents.LoadXml(xml); + } + #endregion + #region BusinessMethods + [NonSerialized] + XmlDocument _XmlContents; + public XmlDocument XmlContents + { + get { return _XmlContents; } + } + private XmlNode GetGroup(string group) + { + XmlNodeList xl = _XmlContents.DocumentElement.SelectNodes(string.Format("//{0}", group)); + switch (xl.Count) + { + case 0: // No nodes found + return null; + case 1: // Found the node + XmlNode xn = xl[0]; + if (xn.GetType() == typeof(XmlElement)) return xn; + throw new XmlPropertiesException("Retrieved {0} while looking for XmlElement //{1}", xn.GetType().ToString(), group); + default: // Found more than 1 node + throw new XmlPropertiesException("Found more than one node //{0}", group); + } + } + private XmlAttribute GetItem(XmlNode xx, string item) + { + XmlNodeList xl = xx.SelectNodes(string.Format("@{0}", item)); + switch (xl.Count) + { + case 0: // No nodes found + return null; + case 1: // Found the node + XmlNode xn = xl[0]; + if (xn.GetType() == typeof(XmlAttribute)) return (XmlAttribute)xn; + throw new XmlPropertiesException("Retrieved {0} while looking for XmlAttribute @{1}", xn.GetType().ToString(), item); + default: // Found more than 1 node + throw new XmlPropertiesException("Found more than one node @{0}", item); + } + } + public string this[string group, string item] + { + get + { + XmlNode xn = GetGroup(group); + if (xn == null) return string.Empty; + XmlNode xa = GetItem(xn, item); + if (xa == null) return string.Empty; + return xa.InnerText; + } + set + { + if (value == null) value = string.Empty; + XmlNode xn = GetGroup(group); + if (xn == null) + { + if (value != string.Empty)// Add Group and Item + { + xn = _XmlContents.DocumentElement.AppendChild(_XmlContents.CreateElement(group)); + XmlAttribute xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item)); + xa.Value = value; + } + } + else + { + XmlAttribute xa = GetItem(xn, item); + if (xa == null) + { + if (value != string.Empty) // Add Item + { + xa = xn.Attributes.Append(_XmlContents.CreateAttribute(item)); + xa.Value = value; + } + } + else + { + if (value != string.Empty) // Add Item + { + xa.Value = value; + } + else + { + xn.Attributes.Remove(xa); + if (xn.Attributes.Count == 0) + _XmlContents.DocumentElement.RemoveChild(xn); + } + } + } + } + } + public override string ToString() + { + return _XmlContents.OuterXml; + } + #endregion + #region XmlPropertiesException + public class XmlPropertiesException : Exception + { + public XmlPropertiesException() : base() { ;} + public XmlPropertiesException(string message) : base(message) { ;} + public XmlPropertiesException(string messageFormat,params object [] args) : base(string.Format(messageFormat,args)) { ;} + public XmlPropertiesException(SerializationInfo info, StreamingContext context) : base(info, context) { ;} + public XmlPropertiesException(string message,Exception innerException) : base(message, innerException) { ;} + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/DocVersionExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/DocVersionExt.cs new file mode 100644 index 00000000..a9d5ffdb --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/DocVersionExt.cs @@ -0,0 +1,31 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class DocVersion + { + public VersionTypeEnum eVersionType + { + get { return (VersionTypeEnum)_VersionType; } + set { _VersionType = (int)value; } + } + } + public enum VersionTypeEnum : int + { + WorkingDraft = 0, Temporary = 1, Revision = 128, Approved = 129 + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/DocVersionInfoExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/DocVersionInfoExt.cs new file mode 100644 index 00000000..c834e596 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/DocVersionInfoExt.cs @@ -0,0 +1,33 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class DocVersionInfo : ReadOnlyBase, IVEReadOnlyItem + { + #region IVEReadOnlyItem + ProcedureInfoList _pil = null; + public System.Collections.IList GetChildren() + { + if (_pil == null) + _pil = ProcedureInfoList.Get(StructureID); + return _pil; + } + public bool GetChildrenLoaded() + { + return _pil == null; + } + public bool HasChildren() + { + return StructureID > 0; + } + public override string ToString() + { + return string.Format("{0} - {1}", Name, Title); + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/FolderExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/FolderExt.cs new file mode 100644 index 00000000..d286256c --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/FolderExt.cs @@ -0,0 +1,44 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + public partial class Folder : BusinessBase + { + #region Folder Config + [NonSerialized] + private FolderConfig _FolderConfig; + public FolderConfig FolderConfig + { + get + { + if (_FolderConfig == null) + { + _FolderConfig = new FolderConfig(this.Config); + _FolderConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_FolderConfig_PropertyChanged); + } + return _FolderConfig; + } + } + private void _FolderConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + Config = _FolderConfig.ToString(); + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/FolderInfoExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/FolderInfoExt.cs new file mode 100644 index 00000000..3ce56de3 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/FolderInfoExt.cs @@ -0,0 +1,30 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class FolderInfo : ReadOnlyBase, IVEReadOnlyItem + { + #region IVEReadOnlyItem + public System.Collections.IList GetChildren() + { + return DocVersions; + } + public bool GetChildrenLoaded() + { + return _DocVersions == null; + } + public bool HasChildren() + { + return DocVersionCount > 0; + } + public override string ToString() + { + return string.Format("{0} - {1}", Name, Title); + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/ProcedureInfoExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/ProcedureInfoExt.cs new file mode 100644 index 00000000..f3c2815e --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/ProcedureInfoExt.cs @@ -0,0 +1,33 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class ProcedureInfo : ReadOnlyBase, IVEReadOnlyItem + { + #region IVEReadOnlyItem + SectionInfoList _sil = null; + public System.Collections.IList GetChildren() + { + if (_sil == null) + _sil = SectionInfoList.Get(StructureID); + return _sil; + } + public bool GetChildrenLoaded() + { + return _sil == null; + } + public bool HasChildren() + { + return StructureID > 0; + } + public override string ToString() + { + return string.Format("{0} - {1}", this.Number,this.Title); + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/ProcedureInfoListExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/ProcedureInfoListExt.cs new file mode 100644 index 00000000..5ba6ed1b --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/ProcedureInfoListExt.cs @@ -0,0 +1,72 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class ProcedureInfoList : ReadOnlyListBase + { + #region Factory Methods + public static ProcedureInfoList Get(int StructureID) + { + return DataPortal.Fetch(new StructureIDCriteria(StructureID)); + } + #endregion + #region Data Access + [Serializable()] + protected class StructureIDCriteria + { + private int _id; + public int Id + { + get { return _id; } + } + public StructureIDCriteria(int id) + { + _id = id; + } + } + protected void DataPortal_Fetch(StructureIDCriteria criteria) + { + this.RaiseListChangedEvents = false; + // if (log.IsDebugEnabled) log.Debug(this.GetType().ToString()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "vesp_ListProcsCSLA"; + cm.Parameters.AddWithValue("@StructID", criteria.Id); + SqlDataReader drRaw = cm.ExecuteReader(); + using (SafeDataReader dr = new SafeDataReader(drRaw)) + { + IsReadOnly = false; + while (dr.Read()) + { + ProcedureInfo info = new ProcedureInfo(dr); + this.Add(info); + } + 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 (Database.Log.IsErrorEnabled) Database.Log.Error("Fetch Error", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoExt.cs new file mode 100644 index 00000000..c6ec2576 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoExt.cs @@ -0,0 +1,86 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class SectionInfo : ReadOnlyBase, IVEReadOnlyItem + { + #region Business Methods + private string _PPath = string.Empty; + /// + /// Required to build tree PPath is the Parent Path calculated with a recursive query + /// + public string PPath + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PPath; + } + } + private string _Path = string.Empty; + /// + /// Required to build tree Path is the Current Path calculated with a recursive query + /// + public string Path + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Path; + } + } + #endregion + #region IVEReadOnlyItem + HLStepInfoList _hlsil = null; + public System.Collections.IList GetChildren() + { + if (_hlsil == null) + { + if(ContentType==1) + _hlsil = HLStepInfoList.Get(ContentID); + } + return _hlsil; + } + public bool GetChildrenLoaded() + { + return _hlsil == null; + } + public bool HasChildren() + { + return ContentType==1 && ContentID != 0; + } + public override string ToString() + { + return string.Format("{0} - {1}", this.Number, this.Title); + } + #endregion + #region Data Access Portal + /// + /// This loads the SectionInfo Record and adds the Path and PPath fields + /// + /// + /// + internal static SectionInfo ExtendedGet(SafeDataReader dr) + { + try + { + SectionInfo si = new SectionInfo(dr); + si._Path = dr.GetString("Path"); + si._PPath = dr.GetString("PPath"); + return si; + } + catch (Exception ex) + { + Database.LogException("SectionInfo.Constructor", ex); + throw new DbCslaException("SectionInfo.Constructor", ex); + } + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoListExt.cs b/PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoListExt.cs new file mode 100644 index 00000000..bfa14015 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoListExt.cs @@ -0,0 +1,77 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; + +namespace Volian.CSLA.Library +{ + public partial class SectionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Get SectionInfoList based upon starting Structure ID + /// + /// Starting structureID + /// + public static SectionInfoList Get(int StructureID) + { + return DataPortal.Fetch(new StructureIDCriteria(StructureID)); + } + #endregion + #region Generic Data Access + [Serializable()] + protected class StructureIDCriteria + { + private int _id; + public int Id + { + get { return _id; } + } + public StructureIDCriteria(int id) + { + _id = id; + } + } + protected void DataPortal_Fetch(StructureIDCriteria criteria) + { + this.RaiseListChangedEvents = false; + // if (log.IsDebugEnabled) log.Debug(this.GetType().ToString()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "vesp_ListSectsCSLA"; + cm.Parameters.AddWithValue("@StructID", criteria.Id); + SqlDataReader drRaw = cm.ExecuteReader(); + using (SafeDataReader dr = new SafeDataReader(drRaw)) + { + IsReadOnly = false; + while (dr.Read()) + { + SectionInfo info = SectionInfo.ExtendedGet(dr); + this.Add(info); + } + 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 (Database.Log.IsErrorEnabled) Database.Log.Error("Fetch Error", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Assignment.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Assignment.cs new file mode 100644 index 00000000..8ee443b9 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Assignment.cs @@ -0,0 +1,797 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Assignment Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Assignment : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextAID = -1; + public static int NextAID + { + get { return _nextAID--; } + } + private int _AID; + [System.ComponentModel.DataObjectField(true, true)] + public int AID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _AID; + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_GID != value) + { + _GID = value; + PropertyHasChanged(); + } + } + } + private int _RID; + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_RID != value) + { + _RID = value; + PropertyHasChanged(); + } + } + } + private int _FolderID; + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FolderID != value) + { + _FolderID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Assignment.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Assignment + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Assignment.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Assignment + protected override object GetIdValue() + { + return _AID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(AID, ""); + //AuthorizationRules.AllowRead(GID, ""); + //AuthorizationRules.AllowRead(RID, ""); + //AuthorizationRules.AllowRead(FolderID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(GID, ""); + //AuthorizationRules.AllowWrite(RID, ""); + //AuthorizationRules.AllowWrite(FolderID, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Assignment() + {/* require use of factory methods */} + public static Assignment New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Assignment"); + return DataPortal.Create(); + } + public static Assignment New(int gid, int rid, int folderID, string startDate, string endDate) + { + Assignment tmp = Assignment.New(); + tmp.GID = gid; + tmp.RID = rid; + tmp.FolderID = folderID; + tmp.StartDate = startDate; + tmp.EndDate = endDate; + return tmp; + } + public static Assignment MakeAssignment(int gid, int rid, int folderID, string startDate, string endDate) + { + Assignment tmp = Assignment.New(gid, rid, folderID, startDate, endDate); + tmp.Save(); + return tmp; + } + public static Assignment MakeAssignment(int gid, int rid, int folderID, string startDate, string endDate, DateTime dts, string usrID) + { + Assignment tmp = Assignment.New(gid, rid, folderID, startDate, endDate); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Assignment Get(int aid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Assignment"); + return DataPortal.Fetch(new PKCriteria(aid)); + } + public static Assignment Get(SafeDataReader dr) + { + if (dr.Read()) return new Assignment(dr); + return null; + } + private Assignment(SafeDataReader dr) + { + _AID = dr.GetInt32("AID"); + _GID = dr.GetInt32("GID"); + _RID = dr.GetInt32("RID"); + _FolderID = dr.GetInt32("FolderID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int aid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Assignment"); + DataPortal.Delete(new PKCriteria(aid)); + } + public override Assignment Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Assignment"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Assignment"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Assignment"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _AID; + public int AID + { get { return _AID; } } + public PKCriteria(int aid) + { + _AID = aid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _AID = NextAID; + // Database Defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getAssignment"; + cm.Parameters.AddWithValue("@AID", criteria.AID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _AID = dr.GetInt32("AID"); + _GID = dr.GetInt32("GID"); + _RID = dr.GetInt32("RID"); + _FolderID = dr.GetInt32("FolderID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Assignment.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Assignment.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addAssignment"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@GID", _GID); + cm.Parameters.AddWithValue("@RID", _RID); + cm.Parameters.AddWithValue("@FolderID", _FolderID); + cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue); + cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int); + param_AID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_AID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _AID = (int)cm.Parameters["@newAID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Assignment.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Assignment.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int aid, int gid, int rid, int folderID, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addAssignment"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@GID", gid); + cm.Parameters.AddWithValue("@RID", rid); + cm.Parameters.AddWithValue("@FolderID", folderID); + cm.Parameters.AddWithValue("@StartDate", startDate.DBValue); + cm.Parameters.AddWithValue("@EndDate", endDate.DBValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_AID = new SqlParameter("@newAID", SqlDbType.Int); + param_AID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_AID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + aid = (int)cm.Parameters["@newAID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Assignment.Add", ex); + throw new DbCslaException("Assignment.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateAssignment"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@AID", _AID); + cm.Parameters.AddWithValue("@GID", _GID); + cm.Parameters.AddWithValue("@RID", _RID); + cm.Parameters.AddWithValue("@FolderID", _FolderID); + cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue); + cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Assignment.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int aid, int gid, int rid, int folderID, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateAssignment"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@AID", aid); + cm.Parameters.AddWithValue("@GID", gid); + cm.Parameters.AddWithValue("@RID", rid); + cm.Parameters.AddWithValue("@FolderID", folderID); + cm.Parameters.AddWithValue("@StartDate", startDate.DBValue); + cm.Parameters.AddWithValue("@EndDate", endDate.DBValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Assignment.Update", ex); + throw new DbCslaException("Assignment.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_AID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteAssignment"; + cm.Parameters.AddWithValue("@AID", criteria.AID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Assignment.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Assignment.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int aid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteAssignment"; + // Input PK Fields + cm.Parameters.AddWithValue("@AID", aid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Assignment.Remove", ex); + throw new DbCslaException("Assignment.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int aid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(aid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _AID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int aid) + { + _AID = aid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsAssignment"; + cm.Parameters.AddWithValue("@AID", _AID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Assignment.DataPortal_Execute", ex); + throw new DbCslaException("Assignment.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create AssignmentExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Assignment +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfo.cs new file mode 100644 index 00000000..82aa22e5 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfo.cs @@ -0,0 +1,158 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// AssignmentInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class AssignmentInfo : ReadOnlyBase + { + #region Business Methods + private int _AID; + [System.ComponentModel.DataObjectField(true, true)] + public int AID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _AID; + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + } + private int _RID; + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + } + private int _FolderID; + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + // TODO: Replace base AssignmentInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current AssignmentInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check AssignmentInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current AssignmentInfo + protected override object GetIdValue() + { + return _AID; + } + #endregion + #region Factory Methods + private AssignmentInfo() + { /* require use of factory methods */ } + public Assignment Get() + { + return Assignment.Get(_AID); + } + #endregion + #region Data Access Portal + internal AssignmentInfo(SafeDataReader dr) + { + try + { + _AID = dr.GetInt32("AID"); + _GID = dr.GetInt32("GID"); + _RID = dr.GetInt32("RID"); + _FolderID = dr.GetInt32("FolderID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + } + catch (Exception ex) + { + Database.LogException("AssignmentInfo.Constructor", ex); + throw new DbCslaException("AssignmentInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfoList.cs new file mode 100644 index 00000000..0e344f27 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfoList.cs @@ -0,0 +1,214 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// AssignmentInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class AssignmentInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static AssignmentInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static AssignmentInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static AssignmentInfoList GetByFolder(int folderID) + { + return DataPortal.Fetch(new FolderCriteria(folderID)); + } + public static AssignmentInfoList GetByGroup(int gid) + { + return DataPortal.Fetch(new GroupCriteria(gid)); + } + public static AssignmentInfoList GetByRole(int rid) + { + return DataPortal.Fetch(new RoleCriteria(rid)); + } + private AssignmentInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getAssignments"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new AssignmentInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class FolderCriteria + { + public FolderCriteria(int folderID) + { + _FolderID = folderID; + } + private int _FolderID; + public int FolderID + { + get { return _FolderID; } + set { _FolderID = value; } + } + } + private void DataPortal_Fetch(FolderCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getAssignmentsByFolder"; + cm.Parameters.AddWithValue("@FolderID", criteria.FolderID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new AssignmentInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class GroupCriteria + { + public GroupCriteria(int gid) + { + _GID = gid; + } + private int _GID; + public int GID + { + get { return _GID; } + set { _GID = value; } + } + } + private void DataPortal_Fetch(GroupCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getAssignmentsByGroup"; + cm.Parameters.AddWithValue("@GID", criteria.GID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new AssignmentInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class RoleCriteria + { + public RoleCriteria(int rid) + { + _RID = rid; + } + private int _RID; + public int RID + { + get { return _RID; } + set { _RID = value; } + } + } + private void DataPortal_Fetch(RoleCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getAssignmentsByRole"; + cm.Parameters.AddWithValue("@RID", criteria.RID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new AssignmentInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("AssignmentInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("AssignmentInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Connection.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Connection.cs new file mode 100644 index 00000000..31146e87 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Connection.cs @@ -0,0 +1,792 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Connection Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Connection : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextDBID = -1; + public static int NextDBID + { + get { return _nextDBID--; } + } + private int _DBID; + [System.ComponentModel.DataObjectField(true, true)] + public int DBID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DBID; + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Name != value) + { + _Name = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private string _ConnectionString = string.Empty; + public string ConnectionString + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ConnectionString; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_ConnectionString != value) + { + _ConnectionString = value; + PropertyHasChanged(); + } + } + } + private int _ServerType; + /// + /// 0 SQL Server + /// + public int ServerType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ServerType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ServerType != value) + { + _ServerType = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private ConnectionFolders _ConnectionFolders = ConnectionFolders.New(); + /// + /// Related Field + /// + public ConnectionFolders ConnectionFolders + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ConnectionFolders; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _ConnectionFolders.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _ConnectionFolders.IsValid; } + } + // TODO: Replace base Connection.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Connection + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Connection.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Connection + protected override object GetIdValue() + { + return _DBID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("ConnectionString", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(DBID, ""); + //AuthorizationRules.AllowRead(Name, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowRead(ConnectionString, ""); + //AuthorizationRules.AllowRead(ServerType, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(Name, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowWrite(ConnectionString, ""); + //AuthorizationRules.AllowWrite(ServerType, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Connection() + {/* require use of factory methods */} + public static Connection New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Connection"); + return DataPortal.Create(); + } + public static Connection New(string name, string title, string connectionString, int serverType, string config) + { + Connection tmp = Connection.New(); + tmp.Name = name; + tmp.Title = title; + tmp.ConnectionString = connectionString; + tmp.ServerType = serverType; + tmp.Config = config; + return tmp; + } + public static Connection MakeConnection(string name, string title, string connectionString, int serverType, string config) + { + Connection tmp = Connection.New(name, title, connectionString, serverType, config); + tmp.Save(); + return tmp; + } + public static Connection MakeConnection(string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID) + { + Connection tmp = Connection.New(name, title, connectionString, serverType, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Connection Get(int dbid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Connection"); + return DataPortal.Fetch(new PKCriteria(dbid)); + } + public static Connection Get(SafeDataReader dr) + { + if (dr.Read()) return new Connection(dr); + return null; + } + private Connection(SafeDataReader dr) + { + _DBID = dr.GetInt32("DBID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _ConnectionString = dr.GetString("ConnectionString"); + _ServerType = dr.GetInt32("ServerType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int dbid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Connection"); + DataPortal.Delete(new PKCriteria(dbid)); + } + public override Connection Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Connection"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Connection"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Connection"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _DBID; + public int DBID + { get { return _DBID; } } + public PKCriteria(int dbid) + { + _DBID = dbid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _DBID = NextDBID; + // Database Defaults + _ServerType = ext.DefaultServerType; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getConnection"; + cm.Parameters.AddWithValue("@DBID", criteria.DBID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _DBID = dr.GetInt32("DBID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _ConnectionString = dr.GetString("ConnectionString"); + _ServerType = dr.GetInt32("ServerType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _ConnectionFolders = ConnectionFolders.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Connection.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Connection.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addConnection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@ConnectionString", _ConnectionString); + cm.Parameters.AddWithValue("@ServerType", _ServerType); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_DBID = new SqlParameter("@newDBID", SqlDbType.Int); + param_DBID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_DBID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _DBID = (int)cm.Parameters["@newDBID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _ConnectionFolders.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Connection.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Connection.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addConnection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@ConnectionString", connectionString); + cm.Parameters.AddWithValue("@ServerType", serverType); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_DBID = new SqlParameter("@newDBID", SqlDbType.Int); + param_DBID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_DBID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + dbid = (int)cm.Parameters["@newDBID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Connection.Add", ex); + throw new DbCslaException("Connection.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateConnection"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@DBID", _DBID); + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@ConnectionString", _ConnectionString); + cm.Parameters.AddWithValue("@ServerType", _ServerType); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _ConnectionFolders.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Connection.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int dbid, string name, string title, string connectionString, int serverType, string config, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateConnection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@DBID", dbid); + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@ConnectionString", connectionString); + cm.Parameters.AddWithValue("@ServerType", serverType); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Connection.Update", ex); + throw new DbCslaException("Connection.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_DBID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteConnection"; + cm.Parameters.AddWithValue("@DBID", criteria.DBID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Connection.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Connection.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int dbid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteConnection"; + // Input PK Fields + cm.Parameters.AddWithValue("@DBID", dbid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Connection.Remove", ex); + throw new DbCslaException("Connection.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int dbid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(dbid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _DBID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int dbid) + { + _DBID = dbid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsConnection"; + cm.Parameters.AddWithValue("@DBID", _DBID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Connection.DataPortal_Execute", ex); + throw new DbCslaException("Connection.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultServerType + { + get { return 1; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ConnectionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Connection +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultServerType +// { +// get { return 1; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolder.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolder.cs new file mode 100644 index 00000000..d43b92a4 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolder.cs @@ -0,0 +1,432 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ConnectionFolder Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ConnectionFolder : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _FolderID; + [System.ComponentModel.DataObjectField(true, true)] + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + } + private int _ParentID; + /// + /// {child Folders.FolderID} + /// + public int ParentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ParentID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ParentID != value) + { + _ParentID = value; + PropertyHasChanged(); + } + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Name != value) + { + _Name = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check ConnectionFolder.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ConnectionFolder + protected override object GetIdValue() + { + return _FolderID; + } + // TODO: Replace base ConnectionFolder.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ConnectionFolder + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Name"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(FolderID, ""); + //AuthorizationRules.AllowRead(ParentID, ""); + //AuthorizationRules.AllowWrite(ParentID, ""); + //AuthorizationRules.AllowRead(Name, ""); + //AuthorizationRules.AllowWrite(Name, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static ConnectionFolder New(string name) + { + return new ConnectionFolder(name); + } + internal static ConnectionFolder Get(SafeDataReader dr) + { + return new ConnectionFolder(dr); + } + public ConnectionFolder() + { + MarkAsChild(); + _FolderID = Folder.NextFolderID; + _ParentID = ext.DefaultParentID; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private ConnectionFolder(string name) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _ParentID = ext.DefaultParentID; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _Name = name; + } + private ConnectionFolder(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _FolderID = dr.GetInt32("FolderID"); + _ParentID = dr.GetInt32("ParentID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("ConnectionFolder.Fetch", ex); + throw new DbCslaException("ConnectionFolder.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Connection connection, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Folder.Add(cn, ref _FolderID, _ParentID, connection.DBID, _Name, _Title, _Config, _DTS, _UsrID); + MarkOld(); + } + internal void Update(Connection connection, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Folder.Update(cn, ref _FolderID, _ParentID, connection.DBID, _Name, _Title, _Config, _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Connection connection, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Folder.Remove(cn, _FolderID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultParentID + { + get { return 0; } + } + public virtual int DefaultDBID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ConnectionFolderExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class ConnectionFolder +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultParentID +// { +// get { return 0; } +// } +// public virtual int DefaultDBID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolders.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolders.cs new file mode 100644 index 00000000..26fe839e --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolders.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ConnectionFolders Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ConnectionFolders : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new ConnectionFolder this[int folderID] + { + get + { + foreach (ConnectionFolder folder in this) + if (folder.FolderID == folderID) + return folder; + return null; + } + } + public ConnectionFolder GetItem(int folderID) + { + foreach (ConnectionFolder folder in this) + if (folder.FolderID == folderID) + return folder; + return null; + } + public ConnectionFolder Add(string name) + { + ConnectionFolder folder = ConnectionFolder.New(name); + this.Add(folder); + return folder; + } + public void Remove(int folderID) + { + foreach (ConnectionFolder folder in this) + { + if (folder.FolderID == folderID) + { + Remove(folder); + break; + } + } + } + public bool Contains(int folderID) + { + foreach (ConnectionFolder folder in this) + if (folder.FolderID == folderID) + return true; + return false; + } + public bool ContainsDeleted(int folderID) + { + foreach (ConnectionFolder folder in DeletedList) + if (folder.FolderID == folderID) + return true; + return false; + } + #endregion + #region Factory Methods + internal static ConnectionFolders New() + { + return new ConnectionFolders(); + } + internal static ConnectionFolders Get(SafeDataReader dr) + { + return new ConnectionFolders(dr); + } + private ConnectionFolders() + { + MarkAsChild(); + } + private ConnectionFolders(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(ConnectionFolder.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Connection connection, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (ConnectionFolder obj in DeletedList) + obj.DeleteSelf(connection, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (ConnectionFolder obj in this) + { + if (obj.IsNew) + obj.Insert(connection, cn); + else + obj.Update(connection, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfo.cs new file mode 100644 index 00000000..e8fc57dc --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfo.cs @@ -0,0 +1,187 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ConnectionInfo : ReadOnlyBase + { + #region Business Methods + private int _DBID; + [System.ComponentModel.DataObjectField(true, true)] + public int DBID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DBID; + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + } + private string _ConnectionString = string.Empty; + public string ConnectionString + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ConnectionString; + } + } + private int _ServerType; + /// + /// 0 SQL Server + /// + public int ServerType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ServerType; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + private int _Foldercount = 0; + /// + /// Count of Folder for this Connection + /// + public int FolderCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Foldercount; + } + } + private FolderInfoList _Folders = null; + public FolderInfoList Folders + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Folders == null) + _Folders = FolderInfoList.GetByConnection(_DBID); + return _Folders; + } + } + // TODO: Replace base ConnectionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ConnectionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ConnectionInfo + protected override object GetIdValue() + { + return _DBID; + } + #endregion + #region Factory Methods + private ConnectionInfo() + { /* require use of factory methods */ } + public Connection Get() + { + return Connection.Get(_DBID); + } + #endregion + #region Data Access Portal + internal ConnectionInfo(SafeDataReader dr) + { + try + { + _DBID = dr.GetInt32("DBID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _ConnectionString = dr.GetString("ConnectionString"); + _ServerType = dr.GetInt32("ServerType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + _Foldercount = dr.GetInt32("FolderCount"); + } + catch (Exception ex) + { + Database.LogException("ConnectionInfo.Constructor", ex); + throw new DbCslaException("ConnectionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfoList.cs new file mode 100644 index 00000000..e224a7ef --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ConnectionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ConnectionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static ConnectionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static ConnectionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private ConnectionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getConnections"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ConnectionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ConnectionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ConnectionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Database.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Database.cs new file mode 100644 index 00000000..46397c55 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Database.cs @@ -0,0 +1,124 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Database Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public static partial class Database + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public static log4net.ILog Log + { + get { return log; } + } + #endregion + public static string VEPROMS_Connection + { + get + { + DateTime.Today.ToLongDateString(); + ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings["VEPROMS"]; + if (cs == null) + { + throw new ApplicationException("Database.cs Could not find connection VEPROMS"); + } + return cs.ConnectionString; + } + } + public static SqlConnection VEPROMS_SqlConnection + { + get + { + string strConn = VEPROMS_Connection; // If failure - Fail (Don't try to catch) + // Attempt to make a connection + try + { + SqlConnection cn = new SqlConnection(strConn); + cn.Open(); + return cn; + } + catch (SqlException exsql) + { + const string strAttachError = "An attempt to attach an auto-named database for file "; + if (exsql.Message.StartsWith(strAttachError)) + {// Check to see if the file is missing + string sFile = exsql.Message.Substring(strAttachError.Length); + sFile = sFile.Substring(0, sFile.IndexOf(" failed")); + // "An attempt to attach an auto-named database for file failed" + if (strConn.ToLower().IndexOf("user instance=true") < 0) + { + throw new ApplicationException("Connection String missing attribute: User Instance=True"); + } + if (File.Exists(sFile)) + { + throw new ApplicationException("Database file " + sFile + " Cannot be opened\r\n", exsql); + } + else + { + throw new FileNotFoundException("Database file " + sFile + " Not Found", exsql); + } + } + else + { + throw new ApplicationException("Failure on Connect", exsql); + } + } + catch (Exception ex)// Throw Application Exception on Failure + { + if (log.IsErrorEnabled) log.Error("Connection Error", ex); + throw new ApplicationException("Failure on Connect", ex); + } + } + } + public static void LogException(string s,Exception ex) + { + log.Error(s,ex); + int i = 0; + Console.WriteLine("Error - {0}", s); + for (; ex != null; ex = ex.InnerException) + { + Console.WriteLine("{0}{1} - {2}", "".PadLeft(i * 2), ex.GetType().ToString(), ex.Message); + } + } + public static void PurgeData() + { + try + { + SqlConnection cn = VEPROMS_SqlConnection; + SqlCommand cmd = new SqlCommand("purgedata", cn); + cmd.CommandType = CommandType.StoredProcedure; + cmd.ExecuteNonQuery(); + } + catch (Exception ex) + { + if (log.IsErrorEnabled) log.Error("Purge Error", ex); + throw new ApplicationException("Failure on Purge", ex); + } + } + } + public class DbCslaException : Exception + { + internal DbCslaException(string message, Exception innerException):base(message,innerException){;} + internal DbCslaException(string message) : base(message) { ;} + internal DbCslaException() : base() { ;} + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/DocVersion.cs b/PROMS/proms/Volian.CSLA.Library/Generated/DocVersion.cs new file mode 100644 index 00000000..2f4d8e24 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/DocVersion.cs @@ -0,0 +1,793 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// DocVersion Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class DocVersion : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextVersionID = -1; + public static int NextVersionID + { + get { return _nextVersionID--; } + } + private int _VersionID; + [System.ComponentModel.DataObjectField(true, true)] + public int VersionID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionID; + } + } + private int _FolderID; + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FolderID != value) + { + _FolderID = value; + PropertyHasChanged(); + } + } + } + private int _VersionType; + /// + /// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable) + /// + public int VersionType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_VersionType != value) + { + _VersionType = value; + PropertyHasChanged(); + } + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Name != value) + { + _Name = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_StructureID != value) + { + _StructureID = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base DocVersion.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current DocVersion + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check DocVersion.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current DocVersion + protected override object GetIdValue() + { + return _VersionID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Name"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(VersionID, ""); + //AuthorizationRules.AllowRead(FolderID, ""); + //AuthorizationRules.AllowRead(VersionType, ""); + //AuthorizationRules.AllowRead(Name, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowRead(StructureID, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(FolderID, ""); + //AuthorizationRules.AllowWrite(VersionType, ""); + //AuthorizationRules.AllowWrite(Name, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowWrite(StructureID, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private DocVersion() + {/* require use of factory methods */} + public static DocVersion New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a DocVersion"); + return DataPortal.Create(); + } + public static DocVersion New(int folderID, int versionType, string name, string title, int structureID, string config) + { + DocVersion tmp = DocVersion.New(); + tmp.FolderID = folderID; + tmp.VersionType = versionType; + tmp.Name = name; + tmp.Title = title; + tmp.StructureID = structureID; + tmp.Config = config; + return tmp; + } + public static DocVersion MakeDocVersion(int folderID, int versionType, string name, string title, int structureID, string config) + { + DocVersion tmp = DocVersion.New(folderID, versionType, name, title, structureID, config); + tmp.Save(); + return tmp; + } + public static DocVersion MakeDocVersion(int folderID, int versionType, string name, string title, int structureID, string config, DateTime dts, string userID) + { + DocVersion tmp = DocVersion.New(folderID, versionType, name, title, structureID, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static DocVersion Get(int versionID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a DocVersion"); + return DataPortal.Fetch(new PKCriteria(versionID)); + } + public static DocVersion Get(SafeDataReader dr) + { + if (dr.Read()) return new DocVersion(dr); + return null; + } + private DocVersion(SafeDataReader dr) + { + _VersionID = dr.GetInt32("VersionID"); + _FolderID = dr.GetInt32("FolderID"); + _VersionType = dr.GetInt32("VersionType"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _StructureID = dr.GetInt32("StructureID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int versionID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a DocVersion"); + DataPortal.Delete(new PKCriteria(versionID)); + } + public override DocVersion Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a DocVersion"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a DocVersion"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a DocVersion"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _VersionID; + public int VersionID + { get { return _VersionID; } } + public PKCriteria(int versionID) + { + _VersionID = versionID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _VersionID = NextVersionID; + // Database Defaults + _VersionType = ext.DefaultVersionType; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getDocVersion"; + cm.Parameters.AddWithValue("@VersionID", criteria.VersionID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _VersionID = dr.GetInt32("VersionID"); + _FolderID = dr.GetInt32("FolderID"); + _VersionType = dr.GetInt32("VersionType"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _StructureID = dr.GetInt32("StructureID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("DocVersion.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addDocVersion"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FolderID", _FolderID); + cm.Parameters.AddWithValue("@VersionType", _VersionType); + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int); + param_VersionID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_VersionID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _VersionID = (int)cm.Parameters["@newVersionID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("DocVersion.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int versionID, int folderID, int versionType, string name, string title, int structureID, string config, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addDocVersion"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FolderID", folderID); + cm.Parameters.AddWithValue("@VersionType", versionType); + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_VersionID = new SqlParameter("@newVersionID", SqlDbType.Int); + param_VersionID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_VersionID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + versionID = (int)cm.Parameters["@newVersionID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.Add", ex); + throw new DbCslaException("DocVersion.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateDocVersion"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@VersionID", _VersionID); + cm.Parameters.AddWithValue("@FolderID", _FolderID); + cm.Parameters.AddWithValue("@VersionType", _VersionType); + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int versionID, int folderID, int versionType, string name, string title, int structureID, string config, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateDocVersion"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@VersionID", versionID); + cm.Parameters.AddWithValue("@FolderID", folderID); + cm.Parameters.AddWithValue("@VersionType", versionType); + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.Update", ex); + throw new DbCslaException("DocVersion.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_VersionID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteDocVersion"; + cm.Parameters.AddWithValue("@VersionID", criteria.VersionID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("DocVersion.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int versionID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteDocVersion"; + // Input PK Fields + cm.Parameters.AddWithValue("@VersionID", versionID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.Remove", ex); + throw new DbCslaException("DocVersion.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int versionID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(versionID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _VersionID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int versionID) + { + _VersionID = versionID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsDocVersion"; + cm.Parameters.AddWithValue("@VersionID", _VersionID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("DocVersion.DataPortal_Execute", ex); + throw new DbCslaException("DocVersion.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultVersionType + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create DocVersionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class DocVersion +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultVersionType +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfo.cs new file mode 100644 index 00000000..621bb83c --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfo.cs @@ -0,0 +1,172 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// DocVersionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class DocVersionInfo : ReadOnlyBase + { + #region Business Methods + private int _VersionID; + [System.ComponentModel.DataObjectField(true, true)] + public int VersionID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionID; + } + } + private int _FolderID; + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + } + private int _VersionType; + /// + /// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable) + /// + public int VersionType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionType; + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + // TODO: Replace base DocVersionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current DocVersionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check DocVersionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current DocVersionInfo + protected override object GetIdValue() + { + return _VersionID; + } + #endregion + #region Factory Methods + private DocVersionInfo() + { /* require use of factory methods */ } + public DocVersion Get() + { + return DocVersion.Get(_VersionID); + } + #endregion + #region Data Access Portal + internal DocVersionInfo(SafeDataReader dr) + { + try + { + _VersionID = dr.GetInt32("VersionID"); + _FolderID = dr.GetInt32("FolderID"); + _VersionType = dr.GetInt32("VersionType"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _StructureID = dr.GetInt32("StructureID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + } + catch (Exception ex) + { + Database.LogException("DocVersionInfo.Constructor", ex); + throw new DbCslaException("DocVersionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfoList.cs new file mode 100644 index 00000000..8020d4f7 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// DocVersionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class DocVersionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static DocVersionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static DocVersionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static DocVersionInfoList GetByFolder(int folderID) + { + return DataPortal.Fetch(new FolderCriteria(folderID)); + } + private DocVersionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getDocVersions"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new DocVersionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("DocVersionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class FolderCriteria + { + public FolderCriteria(int folderID) + { + _FolderID = folderID; + } + private int _FolderID; + public int FolderID + { + get { return _FolderID; } + set { _FolderID = value; } + } + } + private void DataPortal_Fetch(FolderCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getDocVersionsByFolder"; + cm.Parameters.AddWithValue("@FolderID", criteria.FolderID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new DocVersionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("DocVersionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("DocVersionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Document.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Document.cs new file mode 100644 index 00000000..b1cd4ccc --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Document.cs @@ -0,0 +1,729 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Document Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Document : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextDocID = -1; + public static int NextDocID + { + get { return _nextDocID--; } + } + private int _DocID; + [System.ComponentModel.DataObjectField(true, true)] + public int DocID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocID; + } + } + private string _LibTitle = string.Empty; + public string LibTitle + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _LibTitle; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_LibTitle != value) + { + _LibTitle = value; + PropertyHasChanged(); + } + } + } + private byte[] _DocContent; + /// + /// Actual content of a Word Document (RTF, DOC or XML Format) + /// + public byte[] DocContent + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocContent; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DocContent != value) + { + _DocContent = value; + PropertyHasChanged(); + } + } + } + private string _DocAscii = string.Empty; + /// + /// Used for searching + /// + public string DocAscii + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocAscii; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_DocAscii != value) + { + _DocAscii = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Document.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Document + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Document.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Document + protected override object GetIdValue() + { + return _DocID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "LibTitle"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("LibTitle", 1024)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("DocAscii", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(DocID, ""); + //AuthorizationRules.AllowRead(LibTitle, ""); + //AuthorizationRules.AllowRead(DocContent, ""); + //AuthorizationRules.AllowRead(DocAscii, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(LibTitle, ""); + //AuthorizationRules.AllowWrite(DocContent, ""); + //AuthorizationRules.AllowWrite(DocAscii, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Document() + {/* require use of factory methods */} + public static Document New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Document"); + return DataPortal.Create(); + } + public static Document New(string libTitle, byte[] docContent, string docAscii, string config) + { + Document tmp = Document.New(); + tmp.LibTitle = libTitle; + tmp.DocContent = docContent; + tmp.DocAscii = docAscii; + tmp.Config = config; + return tmp; + } + public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config) + { + Document tmp = Document.New(libTitle, docContent, docAscii, config); + tmp.Save(); + return tmp; + } + public static Document MakeDocument(string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID) + { + Document tmp = Document.New(libTitle, docContent, docAscii, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static Document Get(int docID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Document"); + return DataPortal.Fetch(new PKCriteria(docID)); + } + public static Document Get(SafeDataReader dr) + { + if (dr.Read()) return new Document(dr); + return null; + } + private Document(SafeDataReader dr) + { + _DocID = dr.GetInt32("DocID"); + _LibTitle = dr.GetString("LibTitle"); + _DocContent = (byte[])dr.GetValue("DocContent"); + _DocAscii = dr.GetString("DocAscii"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int docID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Document"); + DataPortal.Delete(new PKCriteria(docID)); + } + public override Document Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Document"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Document"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Document"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _DocID; + public int DocID + { get { return _DocID; } } + public PKCriteria(int docID) + { + _DocID = docID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _DocID = NextDocID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getDocument"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _DocID = dr.GetInt32("DocID"); + _LibTitle = dr.GetString("LibTitle"); + _DocContent = (byte[])dr.GetValue("DocContent"); + _DocAscii = dr.GetString("DocAscii"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Document.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Document.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addDocument"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@LibTitle", _LibTitle); + cm.Parameters.AddWithValue("@DocContent", _DocContent); + cm.Parameters.AddWithValue("@DocAscii", _DocAscii); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int); + param_DocID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_DocID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _DocID = (int)cm.Parameters["@newDocID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Document.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Document.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addDocument"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@LibTitle", libTitle); + cm.Parameters.AddWithValue("@DocContent", docContent); + cm.Parameters.AddWithValue("@DocAscii", docAscii); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_DocID = new SqlParameter("@newDocID", SqlDbType.Int); + param_DocID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_DocID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + docID = (int)cm.Parameters["@newDocID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Document.Add", ex); + throw new DbCslaException("Document.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateDocument"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@DocID", _DocID); + cm.Parameters.AddWithValue("@LibTitle", _LibTitle); + cm.Parameters.AddWithValue("@DocContent", _DocContent); + cm.Parameters.AddWithValue("@DocAscii", _DocAscii); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Document.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int docID, string libTitle, byte[] docContent, string docAscii, string config, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateDocument"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@DocID", docID); + cm.Parameters.AddWithValue("@LibTitle", libTitle); + cm.Parameters.AddWithValue("@DocContent", docContent); + cm.Parameters.AddWithValue("@DocAscii", docAscii); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Document.Update", ex); + throw new DbCslaException("Document.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_DocID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteDocument"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Document.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Document.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int docID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteDocument"; + // Input PK Fields + cm.Parameters.AddWithValue("@DocID", docID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Document.Remove", ex); + throw new DbCslaException("Document.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int docID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(docID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _DocID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int docID) + { + _DocID = docID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsDocument"; + cm.Parameters.AddWithValue("@DocID", _DocID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Document.DataPortal_Execute", ex); + throw new DbCslaException("Document.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create DocumentExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Document +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfo.cs new file mode 100644 index 00000000..82a8028a --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfo.cs @@ -0,0 +1,153 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class DocumentInfo : ReadOnlyBase + { + #region Business Methods + private int _DocID; + [System.ComponentModel.DataObjectField(true, true)] + public int DocID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocID; + } + } + private string _LibTitle = string.Empty; + public string LibTitle + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _LibTitle; + } + } + private byte[] _DocContent; + /// + /// Actual content of a Word Document (RTF, DOC or XML Format) + /// + public byte[] DocContent + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocContent; + } + } + private string _DocAscii = string.Empty; + /// + /// Used for searching + /// + public string DocAscii + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocAscii; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + // TODO: Replace base DocumentInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current DocumentInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current DocumentInfo + protected override object GetIdValue() + { + return _DocID; + } + #endregion + #region Factory Methods + private DocumentInfo() + { /* require use of factory methods */ } + public Document Get() + { + return Document.Get(_DocID); + } + #endregion + #region Data Access Portal + internal DocumentInfo(SafeDataReader dr) + { + try + { + _DocID = dr.GetInt32("DocID"); + _LibTitle = dr.GetString("LibTitle"); + _DocContent = (byte[])dr.GetValue("DocContent"); + _DocAscii = dr.GetString("DocAscii"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + } + catch (Exception ex) + { + Database.LogException("DocumentInfo.Constructor", ex); + throw new DbCslaException("DocumentInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfoList.cs new file mode 100644 index 00000000..968c4680 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// DocumentInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class DocumentInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static DocumentInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static DocumentInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private DocumentInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getDocuments"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new DocumentInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("DocumentInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("DocumentInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Folder.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Folder.cs new file mode 100644 index 00000000..f4dd78f4 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Folder.cs @@ -0,0 +1,817 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Folder Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Folder : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextFolderID = -1; + public static int NextFolderID + { + get { return _nextFolderID--; } + } + private int _FolderID; + [System.ComponentModel.DataObjectField(true, true)] + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + } + private int _ParentID; + /// + /// {child Folders.FolderID} + /// + public int ParentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ParentID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ParentID != value) + { + _ParentID = value; + PropertyHasChanged(); + } + } + } + private int _DBID; + public int DBID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DBID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DBID != value) + { + _DBID = value; + PropertyHasChanged(); + } + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Name != value) + { + _Name = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private FolderAssignments _FolderAssignments = FolderAssignments.New(); + /// + /// Related Field + /// + public FolderAssignments FolderAssignments + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderAssignments; + } + } + private FolderDocVersions _FolderDocVersions = FolderDocVersions.New(); + /// + /// Related Field + /// + public FolderDocVersions FolderDocVersions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderDocVersions; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _FolderAssignments.IsDirty || _FolderDocVersions.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _FolderAssignments.IsValid && _FolderDocVersions.IsValid; } + } + // TODO: Replace base Folder.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Folder + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Folder.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Folder + protected override object GetIdValue() + { + return _FolderID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Name"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(FolderID, ""); + //AuthorizationRules.AllowRead(ParentID, ""); + //AuthorizationRules.AllowRead(DBID, ""); + //AuthorizationRules.AllowRead(Name, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(ParentID, ""); + //AuthorizationRules.AllowWrite(DBID, ""); + //AuthorizationRules.AllowWrite(Name, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Folder() + {/* require use of factory methods */} + public static Folder New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Folder"); + return DataPortal.Create(); + } + public static Folder New(int parentID, int dbid, string name, string title, string config) + { + Folder tmp = Folder.New(); + tmp.ParentID = parentID; + tmp.DBID = dbid; + tmp.Name = name; + tmp.Title = title; + tmp.Config = config; + return tmp; + } + public static Folder MakeFolder(int parentID, int dbid, string name, string title, string config) + { + Folder tmp = Folder.New(parentID, dbid, name, title, config); + tmp.Save(); + return tmp; + } + public static Folder MakeFolder(int parentID, int dbid, string name, string title, string config, DateTime dts, string usrID) + { + Folder tmp = Folder.New(parentID, dbid, name, title, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Folder Get(int folderID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Folder"); + return DataPortal.Fetch(new PKCriteria(folderID)); + } + public static Folder Get(SafeDataReader dr) + { + if (dr.Read()) return new Folder(dr); + return null; + } + private Folder(SafeDataReader dr) + { + _FolderID = dr.GetInt32("FolderID"); + _ParentID = dr.GetInt32("ParentID"); + _DBID = dr.GetInt32("DBID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int folderID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Folder"); + DataPortal.Delete(new PKCriteria(folderID)); + } + public override Folder Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Folder"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Folder"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Folder"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _FolderID; + public int FolderID + { get { return _FolderID; } } + public PKCriteria(int folderID) + { + _FolderID = folderID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _FolderID = NextFolderID; + // Database Defaults + _ParentID = ext.DefaultParentID; + _DBID = ext.DefaultDBID; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getFolder"; + cm.Parameters.AddWithValue("@FolderID", criteria.FolderID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _FolderID = dr.GetInt32("FolderID"); + _ParentID = dr.GetInt32("ParentID"); + _DBID = dr.GetInt32("DBID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _FolderAssignments = FolderAssignments.Get(dr); + // load child objects + dr.NextResult(); + _FolderDocVersions = FolderDocVersions.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Folder.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Folder.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addFolder"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@ParentID", _ParentID); + cm.Parameters.AddWithValue("@DBID", _DBID); + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int); + param_FolderID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_FolderID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _FolderID = (int)cm.Parameters["@newFolderID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _FolderAssignments.Update(this, cn); + _FolderDocVersions.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Folder.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Folder.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int folderID, int parentID, int dbid, string name, string title, string config, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addFolder"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@ParentID", parentID); + cm.Parameters.AddWithValue("@DBID", dbid); + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_FolderID = new SqlParameter("@newFolderID", SqlDbType.Int); + param_FolderID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_FolderID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + folderID = (int)cm.Parameters["@newFolderID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Folder.Add", ex); + throw new DbCslaException("Folder.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateFolder"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@FolderID", _FolderID); + cm.Parameters.AddWithValue("@ParentID", _ParentID); + cm.Parameters.AddWithValue("@DBID", _DBID); + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _FolderAssignments.Update(this, cn); + _FolderDocVersions.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Folder.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int folderID, int parentID, int dbid, string name, string title, string config, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateFolder"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FolderID", folderID); + cm.Parameters.AddWithValue("@ParentID", parentID); + cm.Parameters.AddWithValue("@DBID", dbid); + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Folder.Update", ex); + throw new DbCslaException("Folder.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_FolderID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteFolder"; + cm.Parameters.AddWithValue("@FolderID", criteria.FolderID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Folder.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Folder.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int folderID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteFolder"; + // Input PK Fields + cm.Parameters.AddWithValue("@FolderID", folderID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Folder.Remove", ex); + throw new DbCslaException("Folder.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int folderID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(folderID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _FolderID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int folderID) + { + _FolderID = folderID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsFolder"; + cm.Parameters.AddWithValue("@FolderID", _FolderID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Folder.DataPortal_Execute", ex); + throw new DbCslaException("Folder.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultParentID + { + get { return 0; } + } + public virtual int DefaultDBID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create FolderExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Folder +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultParentID +// { +// get { return 0; } +// } +// public virtual int DefaultDBID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignment.cs b/PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignment.cs new file mode 100644 index 00000000..519bb551 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignment.cs @@ -0,0 +1,566 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// FolderAssignment Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class FolderAssignment : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _AID; + [System.ComponentModel.DataObjectField(true, true)] + public int AID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _AID; + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_GID != value) + { + _GID = value; + PropertyHasChanged(); + } + } + } + private int _RID; + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_RID != value) + { + _RID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private string _Group_GroupName = string.Empty; + public string Group_GroupName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_GroupName; + } + } + private int _Group_GroupType; + public int Group_GroupType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_GroupType; + } + } + private string _Group_Config = string.Empty; + public string Group_Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_Config; + } + } + private DateTime _Group_DTS = new DateTime(); + public DateTime Group_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_DTS; + } + } + private string _Group_UsrID = string.Empty; + public string Group_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_UsrID; + } + } + private string _Role_Name = string.Empty; + public string Role_Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_Name; + } + } + private string _Role_Title = string.Empty; + public string Role_Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_Title; + } + } + private DateTime _Role_DTS = new DateTime(); + public DateTime Role_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_DTS; + } + } + private string _Role_UsrID = string.Empty; + public string Role_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_UsrID; + } + } + // TODO: Check FolderAssignment.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current FolderAssignment + protected override object GetIdValue() + { + return _AID; + } + // TODO: Replace base FolderAssignment.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current FolderAssignment + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(AID, ""); + //AuthorizationRules.AllowRead(GID, ""); + //AuthorizationRules.AllowWrite(GID, ""); + //AuthorizationRules.AllowRead(RID, ""); + //AuthorizationRules.AllowWrite(RID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static FolderAssignment New(int gid, int rid) + { + return new FolderAssignment(Volian.CSLA.Library.Group.Get(gid), Volian.CSLA.Library.Role.Get(rid)); + } + internal static FolderAssignment Get(SafeDataReader dr) + { + return new FolderAssignment(dr); + } + public FolderAssignment() + { + MarkAsChild(); + _AID = Assignment.NextAID; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private FolderAssignment(Group group, Role role) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _GID = group.GID; + _Group_GroupName = group.GroupName; + _Group_GroupType = group.GroupType; + _Group_Config = group.Config; + _Group_DTS = group.DTS; + _Group_UsrID = group.UsrID; + _RID = role.RID; + _Role_Name = role.Name; + _Role_Title = role.Title; + _Role_DTS = role.DTS; + _Role_UsrID = role.UsrID; + } + private FolderAssignment(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _AID = dr.GetInt32("AID"); + _GID = dr.GetInt32("GID"); + _RID = dr.GetInt32("RID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + _Group_GroupName = dr.GetString("Group_GroupName"); + _Group_GroupType = dr.GetInt32("Group_GroupType"); + _Group_Config = dr.GetString("Group_Config"); + _Group_DTS = dr.GetDateTime("Group_DTS"); + _Group_UsrID = dr.GetString("Group_UsrID"); + _Role_Name = dr.GetString("Role_Name"); + _Role_Title = dr.GetString("Role_Title"); + _Role_DTS = dr.GetDateTime("Role_DTS"); + _Role_UsrID = dr.GetString("Role_UsrID"); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("FolderAssignment.Fetch", ex); + throw new DbCslaException("FolderAssignment.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Folder folder, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Assignment.Add(cn, ref _AID, _GID, _RID, folder.FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID); + MarkOld(); + } + internal void Update(Folder folder, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Assignment.Update(cn, ref _AID, _GID, _RID, folder.FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Folder folder, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Assignment.Remove(cn, _AID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create FolderAssignmentExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class FolderAssignment +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignments.cs b/PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignments.cs new file mode 100644 index 00000000..ae0fa473 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignments.cs @@ -0,0 +1,142 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// FolderAssignments Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class FolderAssignments : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // Many To Many + public FolderAssignment this[int gid, int rid] + { + get + { + foreach (FolderAssignment assignment in this) + if (assignment.GID == gid && assignment.RID == rid) + return assignment; + return null; + } + } + public FolderAssignment GetItem(int gid, int rid) + { + foreach (FolderAssignment assignment in this) + if (assignment.GID == gid && assignment.RID == rid) + return assignment; + return null; + } + public FolderAssignment Add(int gid, int rid) + { + if (!Contains(gid, rid)) + { + FolderAssignment assignment = FolderAssignment.New(gid, rid); + this.Add(assignment); + return assignment; + } + else + throw new InvalidOperationException("assignment already exists"); + } + public void Remove(int gid, int rid) + { + foreach (FolderAssignment assignment in this) + { + if (assignment.GID == gid && assignment.RID == rid) + { + Remove(assignment); + break; + } + } + } + public bool Contains(int gid, int rid) + { + foreach (FolderAssignment assignment in this) + if (assignment.GID == gid && assignment.RID == rid) + return true; + return false; + } + public bool ContainsDeleted(int gid, int rid) + { + foreach (FolderAssignment assignment in DeletedList) + if (assignment.GID == gid && assignment.RID == rid) + return true; + return false; + } + #endregion + #region Factory Methods + internal static FolderAssignments New() + { + return new FolderAssignments(); + } + internal static FolderAssignments Get(SafeDataReader dr) + { + return new FolderAssignments(dr); + } + private FolderAssignments() + { + MarkAsChild(); + } + private FolderAssignments(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(FolderAssignment.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Folder folder, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (FolderAssignment obj in DeletedList) + obj.DeleteSelf(folder, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (FolderAssignment obj in this) + { + if (obj.IsNew) + obj.Insert(folder, cn); + else + obj.Update(folder, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersion.cs b/PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersion.cs new file mode 100644 index 00000000..4c99af9a --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersion.cs @@ -0,0 +1,447 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// FolderDocVersion Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class FolderDocVersion : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _VersionID; + [System.ComponentModel.DataObjectField(true, true)] + public int VersionID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionID; + } + } + private int _VersionType; + /// + /// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable) + /// + public int VersionType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_VersionType != value) + { + _VersionType = value; + PropertyHasChanged(); + } + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Name != value) + { + _Name = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_StructureID != value) + { + _StructureID = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check FolderDocVersion.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current FolderDocVersion + protected override object GetIdValue() + { + return _VersionID; + } + // TODO: Replace base FolderDocVersion.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current FolderDocVersion + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Name"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + // TODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(VersionID, ""); + //AuthorizationRules.AllowRead(VersionType, ""); + //AuthorizationRules.AllowWrite(VersionType, ""); + //AuthorizationRules.AllowRead(Name, ""); + //AuthorizationRules.AllowWrite(Name, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowRead(StructureID, ""); + //AuthorizationRules.AllowWrite(StructureID, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static FolderDocVersion New(string name) + { + return new FolderDocVersion(name); + } + internal static FolderDocVersion Get(SafeDataReader dr) + { + return new FolderDocVersion(dr); + } + public FolderDocVersion() + { + MarkAsChild(); + _VersionID = DocVersion.NextVersionID; + _VersionType = ext.DefaultVersionType; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + } + private FolderDocVersion(string name) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _VersionType = ext.DefaultVersionType; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + _Name = name; + } + private FolderDocVersion(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _VersionID = dr.GetInt32("VersionID"); + _VersionType = dr.GetInt32("VersionType"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _StructureID = dr.GetInt32("StructureID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("FolderDocVersion.Fetch", ex); + throw new DbCslaException("FolderDocVersion.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Folder folder, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = DocVersion.Add(cn, ref _VersionID, folder.FolderID, _VersionType, _Name, _Title, _StructureID, _Config, _DTS, _UserID); + MarkOld(); + } + internal void Update(Folder folder, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = DocVersion.Update(cn, ref _VersionID, folder.FolderID, _VersionType, _Name, _Title, _StructureID, _Config, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Folder folder, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + DocVersion.Remove(cn, _VersionID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultVersionType + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create FolderDocVersionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class FolderDocVersion +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultVersionType +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersions.cs b/PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersions.cs new file mode 100644 index 00000000..c70a6ef3 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersions.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// FolderDocVersions Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class FolderDocVersions : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new FolderDocVersion this[int versionID] + { + get + { + foreach (FolderDocVersion docVersion in this) + if (docVersion.VersionID == versionID) + return docVersion; + return null; + } + } + public FolderDocVersion GetItem(int versionID) + { + foreach (FolderDocVersion docVersion in this) + if (docVersion.VersionID == versionID) + return docVersion; + return null; + } + public FolderDocVersion Add(string name) + { + FolderDocVersion docVersion = FolderDocVersion.New(name); + this.Add(docVersion); + return docVersion; + } + public void Remove(int versionID) + { + foreach (FolderDocVersion docVersion in this) + { + if (docVersion.VersionID == versionID) + { + Remove(docVersion); + break; + } + } + } + public bool Contains(int versionID) + { + foreach (FolderDocVersion docVersion in this) + if (docVersion.VersionID == versionID) + return true; + return false; + } + public bool ContainsDeleted(int versionID) + { + foreach (FolderDocVersion docVersion in DeletedList) + if (docVersion.VersionID == versionID) + return true; + return false; + } + #endregion + #region Factory Methods + internal static FolderDocVersions New() + { + return new FolderDocVersions(); + } + internal static FolderDocVersions Get(SafeDataReader dr) + { + return new FolderDocVersions(dr); + } + private FolderDocVersions() + { + MarkAsChild(); + } + private FolderDocVersions(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(FolderDocVersion.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Folder folder, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (FolderDocVersion obj in DeletedList) + obj.DeleteSelf(folder, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (FolderDocVersion obj in this) + { + if (obj.IsNew) + obj.Insert(folder, cn); + else + obj.Update(folder, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/FolderInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/FolderInfo.cs new file mode 100644 index 00000000..d3b82a63 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/FolderInfo.cs @@ -0,0 +1,213 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// FolderInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class FolderInfo : ReadOnlyBase + { + #region Business Methods + private int _FolderID; + [System.ComponentModel.DataObjectField(true, true)] + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + } + private int _ParentID; + /// + /// {child Folders.FolderID} + /// + public int ParentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ParentID; + } + } + private int _DBID; + public int DBID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DBID; + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + private int _Assignmentcount = 0; + /// + /// Count of Assignment for this Folder + /// + public int AssignmentCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Assignmentcount; + } + } + private AssignmentInfoList _Assignments = null; + public AssignmentInfoList Assignments + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Assignments == null) + _Assignments = AssignmentInfoList.GetByFolder(_FolderID); + return _Assignments; + } + } + private int _DocVersioncount = 0; + /// + /// Count of DocVersion for this Folder + /// + public int DocVersionCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DocVersioncount; + } + } + private DocVersionInfoList _DocVersions = null; + public DocVersionInfoList DocVersions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_DocVersions == null) + _DocVersions = DocVersionInfoList.GetByFolder(_FolderID); + return _DocVersions; + } + } + // TODO: Replace base FolderInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current FolderInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check FolderInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current FolderInfo + protected override object GetIdValue() + { + return _FolderID; + } + #endregion + #region Factory Methods + private FolderInfo() + { /* require use of factory methods */ } + public Folder Get() + { + return Folder.Get(_FolderID); + } + #endregion + #region Data Access Portal + internal FolderInfo(SafeDataReader dr) + { + try + { + _FolderID = dr.GetInt32("FolderID"); + _ParentID = dr.GetInt32("ParentID"); + _DBID = dr.GetInt32("DBID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + _Assignmentcount = dr.GetInt32("AssignmentCount"); + _DocVersioncount = dr.GetInt32("DocVersionCount"); + } + catch (Exception ex) + { + Database.LogException("FolderInfo.Constructor", ex); + throw new DbCslaException("FolderInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/FolderInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/FolderInfoList.cs new file mode 100644 index 00000000..89b56e8d --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/FolderInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// FolderInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class FolderInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static FolderInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static FolderInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static FolderInfoList GetByConnection(int dbid) + { + return DataPortal.Fetch(new ConnectionCriteria(dbid)); + } + private FolderInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getFolders"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new FolderInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("FolderInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class ConnectionCriteria + { + public ConnectionCriteria(int dbid) + { + _DBID = dbid; + } + private int _DBID; + public int DBID + { + get { return _DBID; } + set { _DBID = value; } + } + } + private void DataPortal_Fetch(ConnectionCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getFoldersByConnection"; + cm.Parameters.AddWithValue("@DBID", criteria.DBID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new FolderInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("FolderInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("FolderInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Group.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Group.cs new file mode 100644 index 00000000..4cb65ed2 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Group.cs @@ -0,0 +1,734 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Group Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Group : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextGID = -1; + public static int NextGID + { + get { return _nextGID--; } + } + private int _GID; + [System.ComponentModel.DataObjectField(true, true)] + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + } + private string _GroupName = string.Empty; + public string GroupName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GroupName; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_GroupName != value) + { + _GroupName = value; + PropertyHasChanged(); + } + } + } + private int _GroupType; + public int GroupType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GroupType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_GroupType != value) + { + _GroupType = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private GroupAssignments _GroupAssignments = GroupAssignments.New(); + /// + /// Related Field + /// + public GroupAssignments GroupAssignments + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GroupAssignments; + } + } + private GroupMemberships _GroupMemberships = GroupMemberships.New(); + /// + /// Related Field + /// + public GroupMemberships GroupMemberships + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GroupMemberships; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _GroupAssignments.IsDirty || _GroupMemberships.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _GroupAssignments.IsValid && _GroupMemberships.IsValid; } + } + // TODO: Replace base Group.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Group + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Group.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Group + protected override object GetIdValue() + { + return _GID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "GroupName"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("GroupName", 50)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(GID, ""); + //AuthorizationRules.AllowRead(GroupName, ""); + //AuthorizationRules.AllowRead(GroupType, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(GroupName, ""); + //AuthorizationRules.AllowWrite(GroupType, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Group() + {/* require use of factory methods */} + public static Group New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Group"); + return DataPortal.Create(); + } + public static Group New(string groupName, int groupType, string config) + { + Group tmp = Group.New(); + tmp.GroupName = groupName; + tmp.GroupType = groupType; + tmp.Config = config; + return tmp; + } + public static Group MakeGroup(string groupName, int groupType, string config) + { + Group tmp = Group.New(groupName, groupType, config); + tmp.Save(); + return tmp; + } + public static Group MakeGroup(string groupName, int groupType, string config, DateTime dts, string usrID) + { + Group tmp = Group.New(groupName, groupType, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Group Get(int gid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Group"); + return DataPortal.Fetch(new PKCriteria(gid)); + } + public static Group Get(SafeDataReader dr) + { + if (dr.Read()) return new Group(dr); + return null; + } + private Group(SafeDataReader dr) + { + _GID = dr.GetInt32("GID"); + _GroupName = dr.GetString("GroupName"); + _GroupType = dr.GetInt32("GroupType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int gid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Group"); + DataPortal.Delete(new PKCriteria(gid)); + } + public override Group Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Group"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Group"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Group"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _GID; + public int GID + { get { return _GID; } } + public PKCriteria(int gid) + { + _GID = gid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _GID = NextGID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getGroup"; + cm.Parameters.AddWithValue("@GID", criteria.GID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _GID = dr.GetInt32("GID"); + _GroupName = dr.GetString("GroupName"); + _GroupType = dr.GetInt32("GroupType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _GroupAssignments = GroupAssignments.Get(dr); + // load child objects + dr.NextResult(); + _GroupMemberships = GroupMemberships.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Group.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Group.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addGroup"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@GroupName", _GroupName); + cm.Parameters.AddWithValue("@GroupType", _GroupType); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_GID = new SqlParameter("@newGID", SqlDbType.Int); + param_GID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_GID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _GID = (int)cm.Parameters["@newGID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _GroupAssignments.Update(this, cn); + _GroupMemberships.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Group.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Group.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int gid, string groupName, int groupType, string config, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addGroup"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@GroupName", groupName); + cm.Parameters.AddWithValue("@GroupType", groupType); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_GID = new SqlParameter("@newGID", SqlDbType.Int); + param_GID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_GID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + gid = (int)cm.Parameters["@newGID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Group.Add", ex); + throw new DbCslaException("Group.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateGroup"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@GID", _GID); + cm.Parameters.AddWithValue("@GroupName", _GroupName); + cm.Parameters.AddWithValue("@GroupType", _GroupType); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _GroupAssignments.Update(this, cn); + _GroupMemberships.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Group.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int gid, string groupName, int groupType, string config, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateGroup"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@GID", gid); + cm.Parameters.AddWithValue("@GroupName", groupName); + cm.Parameters.AddWithValue("@GroupType", groupType); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Group.Update", ex); + throw new DbCslaException("Group.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_GID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteGroup"; + cm.Parameters.AddWithValue("@GID", criteria.GID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Group.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Group.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int gid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteGroup"; + // Input PK Fields + cm.Parameters.AddWithValue("@GID", gid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Group.Remove", ex); + throw new DbCslaException("Group.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int gid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(gid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _GID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int gid) + { + _GID = gid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsGroup"; + cm.Parameters.AddWithValue("@GID", _GID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Group.DataPortal_Execute", ex); + throw new DbCslaException("Group.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create GroupExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Group +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignment.cs b/PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignment.cs new file mode 100644 index 00000000..84aee05a --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignment.cs @@ -0,0 +1,593 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// GroupAssignment Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class GroupAssignment : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _AID; + [System.ComponentModel.DataObjectField(true, true)] + public int AID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _AID; + } + } + private int _RID; + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_RID != value) + { + _RID = value; + PropertyHasChanged(); + } + } + } + private int _FolderID; + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FolderID != value) + { + _FolderID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private int _Folder_ParentID; + /// + /// {child Folders.FolderID} + /// + public int Folder_ParentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_ParentID; + } + } + private int _Folder_DBID; + public int Folder_DBID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_DBID; + } + } + private string _Folder_Name = string.Empty; + public string Folder_Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_Name; + } + } + private string _Folder_Title = string.Empty; + public string Folder_Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_Title; + } + } + private string _Folder_Config = string.Empty; + public string Folder_Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_Config; + } + } + private DateTime _Folder_DTS = new DateTime(); + public DateTime Folder_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_DTS; + } + } + private string _Folder_UsrID = string.Empty; + public string Folder_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_UsrID; + } + } + private string _Role_Name = string.Empty; + public string Role_Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_Name; + } + } + private string _Role_Title = string.Empty; + public string Role_Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_Title; + } + } + private DateTime _Role_DTS = new DateTime(); + public DateTime Role_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_DTS; + } + } + private string _Role_UsrID = string.Empty; + public string Role_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Role_UsrID; + } + } + // TODO: Check GroupAssignment.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current GroupAssignment + protected override object GetIdValue() + { + return _AID; + } + // TODO: Replace base GroupAssignment.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current GroupAssignment + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(AID, ""); + //AuthorizationRules.AllowRead(RID, ""); + //AuthorizationRules.AllowWrite(RID, ""); + //AuthorizationRules.AllowRead(FolderID, ""); + //AuthorizationRules.AllowWrite(FolderID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static GroupAssignment New(int rid, int folderID) + { + return new GroupAssignment(Volian.CSLA.Library.Role.Get(rid), Volian.CSLA.Library.Folder.Get(folderID)); + } + internal static GroupAssignment Get(SafeDataReader dr) + { + return new GroupAssignment(dr); + } + public GroupAssignment() + { + MarkAsChild(); + _AID = Assignment.NextAID; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private GroupAssignment(Role role, Folder folder) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _FolderID = folder.FolderID; + _Folder_ParentID = folder.ParentID; + _Folder_DBID = folder.DBID; + _Folder_Name = folder.Name; + _Folder_Title = folder.Title; + _Folder_Config = folder.Config; + _Folder_DTS = folder.DTS; + _Folder_UsrID = folder.UsrID; + _RID = role.RID; + _Role_Name = role.Name; + _Role_Title = role.Title; + _Role_DTS = role.DTS; + _Role_UsrID = role.UsrID; + } + private GroupAssignment(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _AID = dr.GetInt32("AID"); + _RID = dr.GetInt32("RID"); + _FolderID = dr.GetInt32("FolderID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + _Folder_ParentID = dr.GetInt32("Folder_ParentID"); + _Folder_DBID = dr.GetInt32("Folder_DBID"); + _Folder_Name = dr.GetString("Folder_Name"); + _Folder_Title = dr.GetString("Folder_Title"); + _Folder_Config = dr.GetString("Folder_Config"); + _Folder_DTS = dr.GetDateTime("Folder_DTS"); + _Folder_UsrID = dr.GetString("Folder_UsrID"); + _Role_Name = dr.GetString("Role_Name"); + _Role_Title = dr.GetString("Role_Title"); + _Role_DTS = dr.GetDateTime("Role_DTS"); + _Role_UsrID = dr.GetString("Role_UsrID"); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("GroupAssignment.Fetch", ex); + throw new DbCslaException("GroupAssignment.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Group group, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Assignment.Add(cn, ref _AID, group.GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID); + MarkOld(); + } + internal void Update(Group group, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Assignment.Update(cn, ref _AID, group.GID, _RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Group group, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Assignment.Remove(cn, _AID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create GroupAssignmentExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class GroupAssignment +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignments.cs b/PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignments.cs new file mode 100644 index 00000000..36b2d2ce --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignments.cs @@ -0,0 +1,142 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// GroupAssignments Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class GroupAssignments : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // Many To Many + public GroupAssignment this[int folderID, int rid] + { + get + { + foreach (GroupAssignment assignment in this) + if (assignment.FolderID == folderID && assignment.RID == rid) + return assignment; + return null; + } + } + public GroupAssignment GetItem(int folderID, int rid) + { + foreach (GroupAssignment assignment in this) + if (assignment.FolderID == folderID && assignment.RID == rid) + return assignment; + return null; + } + public GroupAssignment Add(int rid, int folderID) + { + if (!Contains(rid, folderID)) + { + GroupAssignment assignment = GroupAssignment.New(rid, folderID); + this.Add(assignment); + return assignment; + } + else + throw new InvalidOperationException("assignment already exists"); + } + public void Remove(int folderID, int rid) + { + foreach (GroupAssignment assignment in this) + { + if (assignment.FolderID == folderID && assignment.RID == rid) + { + Remove(assignment); + break; + } + } + } + public bool Contains(int folderID, int rid) + { + foreach (GroupAssignment assignment in this) + if (assignment.FolderID == folderID && assignment.RID == rid) + return true; + return false; + } + public bool ContainsDeleted(int folderID, int rid) + { + foreach (GroupAssignment assignment in DeletedList) + if (assignment.FolderID == folderID && assignment.RID == rid) + return true; + return false; + } + #endregion + #region Factory Methods + internal static GroupAssignments New() + { + return new GroupAssignments(); + } + internal static GroupAssignments Get(SafeDataReader dr) + { + return new GroupAssignments(dr); + } + private GroupAssignments() + { + MarkAsChild(); + } + private GroupAssignments(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(GroupAssignment.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Group group, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (GroupAssignment obj in DeletedList) + obj.DeleteSelf(group, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (GroupAssignment obj in this) + { + if (obj.IsNew) + obj.Insert(group, cn); + else + obj.Update(group, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/GroupInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/GroupInfo.cs new file mode 100644 index 00000000..d33e8c94 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/GroupInfo.cs @@ -0,0 +1,188 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class GroupInfo : ReadOnlyBase + { + #region Business Methods + private int _GID; + [System.ComponentModel.DataObjectField(true, true)] + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + } + private string _GroupName = string.Empty; + public string GroupName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GroupName; + } + } + private int _GroupType; + public int GroupType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GroupType; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + private int _Assignmentcount = 0; + /// + /// Count of Assignment for this Group + /// + public int AssignmentCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Assignmentcount; + } + } + private AssignmentInfoList _Assignments = null; + public AssignmentInfoList Assignments + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Assignments == null) + _Assignments = AssignmentInfoList.GetByGroup(_GID); + return _Assignments; + } + } + private int _Membershipcount = 0; + /// + /// Count of Membership for this Group + /// + public int MembershipCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Membershipcount; + } + } + private MembershipInfoList _Memberships = null; + public MembershipInfoList Memberships + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Memberships == null) + _Memberships = MembershipInfoList.GetByGroup(_GID); + return _Memberships; + } + } + // TODO: Replace base GroupInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current GroupInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current GroupInfo + protected override object GetIdValue() + { + return _GID; + } + #endregion + #region Factory Methods + private GroupInfo() + { /* require use of factory methods */ } + public Group Get() + { + return Group.Get(_GID); + } + #endregion + #region Data Access Portal + internal GroupInfo(SafeDataReader dr) + { + try + { + _GID = dr.GetInt32("GID"); + _GroupName = dr.GetString("GroupName"); + _GroupType = dr.GetInt32("GroupType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + _Assignmentcount = dr.GetInt32("AssignmentCount"); + _Membershipcount = dr.GetInt32("MembershipCount"); + } + catch (Exception ex) + { + Database.LogException("GroupInfo.Constructor", ex); + throw new DbCslaException("GroupInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/GroupInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/GroupInfoList.cs new file mode 100644 index 00000000..17190e90 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/GroupInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// GroupInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class GroupInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static GroupInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static GroupInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private GroupInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getGroups"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new GroupInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("GroupInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("GroupInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/GroupMembership.cs b/PROMS/proms/Volian.CSLA.Library/Generated/GroupMembership.cs new file mode 100644 index 00000000..8fd2868b --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/GroupMembership.cs @@ -0,0 +1,590 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// GroupMembership Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class GroupMembership : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _UGID; + [System.ComponentModel.DataObjectField(true, true)] + public int UGID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UGID; + } + } + private int _UID; + public int UID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_UID != value) + { + _UID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private string _User_UserID = string.Empty; + public string User_UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_UserID; + } + } + private string _User_FirstName = string.Empty; + public string User_FirstName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_FirstName; + } + } + private string _User_MiddleName = string.Empty; + public string User_MiddleName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_MiddleName; + } + } + private string _User_LastName = string.Empty; + public string User_LastName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_LastName; + } + } + private string _User_Suffix = string.Empty; + public string User_Suffix + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_Suffix; + } + } + private string _User_CourtesyTitle = string.Empty; + public string User_CourtesyTitle + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_CourtesyTitle; + } + } + private string _User_PhoneNumber = string.Empty; + public string User_PhoneNumber + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_PhoneNumber; + } + } + private string _User_CFGName = string.Empty; + public string User_CFGName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_CFGName; + } + } + private string _User_UserLogin = string.Empty; + public string User_UserLogin + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_UserLogin; + } + } + private string _User_UserName = string.Empty; + public string User_UserName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_UserName; + } + } + private string _User_Config = string.Empty; + public string User_Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_Config; + } + } + private DateTime _User_DTS = new DateTime(); + public DateTime User_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_DTS; + } + } + private string _User_UsrID = string.Empty; + public string User_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _User_UsrID; + } + } + // TODO: Check GroupMembership.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current GroupMembership + protected override object GetIdValue() + { + return _UGID; + } + // TODO: Replace base GroupMembership.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current GroupMembership + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(UGID, ""); + //AuthorizationRules.AllowRead(UID, ""); + //AuthorizationRules.AllowWrite(UID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static GroupMembership New(int uid) + { + return new GroupMembership(Volian.CSLA.Library.User.Get(uid)); + } + internal static GroupMembership Get(SafeDataReader dr) + { + return new GroupMembership(dr); + } + public GroupMembership() + { + MarkAsChild(); + _UGID = Membership.NextUGID; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private GroupMembership(User user) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _UID = user.UID; + _User_UserID = user.UserID; + _User_FirstName = user.FirstName; + _User_MiddleName = user.MiddleName; + _User_LastName = user.LastName; + _User_Suffix = user.Suffix; + _User_CourtesyTitle = user.CourtesyTitle; + _User_PhoneNumber = user.PhoneNumber; + _User_CFGName = user.CFGName; + _User_UserLogin = user.UserLogin; + _User_UserName = user.UserName; + _User_Config = user.Config; + _User_DTS = user.DTS; + _User_UsrID = user.UsrID; + } + private GroupMembership(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _UGID = dr.GetInt32("UGID"); + _UID = dr.GetInt32("UID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + _User_UserID = dr.GetString("User_UserID"); + _User_FirstName = dr.GetString("User_FirstName"); + _User_MiddleName = dr.GetString("User_MiddleName"); + _User_LastName = dr.GetString("User_LastName"); + _User_Suffix = dr.GetString("User_Suffix"); + _User_CourtesyTitle = dr.GetString("User_CourtesyTitle"); + _User_PhoneNumber = dr.GetString("User_PhoneNumber"); + _User_CFGName = dr.GetString("User_CFGName"); + _User_UserLogin = dr.GetString("User_UserLogin"); + _User_UserName = dr.GetString("User_UserName"); + _User_Config = dr.GetString("User_Config"); + _User_DTS = dr.GetDateTime("User_DTS"); + _User_UsrID = dr.GetString("User_UsrID"); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("GroupMembership.Fetch", ex); + throw new DbCslaException("GroupMembership.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Group group, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Membership.Add(cn, ref _UGID, _UID, group.GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID); + MarkOld(); + } + internal void Update(Group group, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Membership.Update(cn, ref _UGID, _UID, group.GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Group group, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Membership.Remove(cn, _UGID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create GroupMembershipExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class GroupMembership +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/GroupMemberships.cs b/PROMS/proms/Volian.CSLA.Library/Generated/GroupMemberships.cs new file mode 100644 index 00000000..2c1dd062 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/GroupMemberships.cs @@ -0,0 +1,142 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// GroupMemberships Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class GroupMemberships : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // Many To Many + public new GroupMembership this[int uid] + { + get + { + foreach (GroupMembership membership in this) + if (membership.UID == uid) + return membership; + return null; + } + } + public GroupMembership GetItem(int uid) + { + foreach (GroupMembership membership in this) + if (membership.UID == uid) + return membership; + return null; + } + public GroupMembership Add(int uid) + { + if (!Contains(uid)) + { + GroupMembership membership = GroupMembership.New(uid); + this.Add(membership); + return membership; + } + else + throw new InvalidOperationException("membership already exists"); + } + public void Remove(int uid) + { + foreach (GroupMembership membership in this) + { + if (membership.UID == uid) + { + Remove(membership); + break; + } + } + } + public bool Contains(int uid) + { + foreach (GroupMembership membership in this) + if (membership.UID == uid) + return true; + return false; + } + public bool ContainsDeleted(int uid) + { + foreach (GroupMembership membership in DeletedList) + if (membership.UID == uid) + return true; + return false; + } + #endregion + #region Factory Methods + internal static GroupMemberships New() + { + return new GroupMemberships(); + } + internal static GroupMemberships Get(SafeDataReader dr) + { + return new GroupMemberships(dr); + } + private GroupMemberships() + { + MarkAsChild(); + } + private GroupMemberships(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(GroupMembership.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Group group, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (GroupMembership obj in DeletedList) + obj.DeleteSelf(group, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (GroupMembership obj in this) + { + if (obj.IsNew) + obj.Insert(group, cn); + else + obj.Update(group, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Membership.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Membership.cs new file mode 100644 index 00000000..6bd00b21 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Membership.cs @@ -0,0 +1,768 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Membership Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Membership : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextUGID = -1; + public static int NextUGID + { + get { return _nextUGID--; } + } + private int _UGID; + [System.ComponentModel.DataObjectField(true, true)] + public int UGID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UGID; + } + } + private int _UID; + public int UID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_UID != value) + { + _UID = value; + PropertyHasChanged(); + } + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_GID != value) + { + _GID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Membership.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Membership + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Membership.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Membership + protected override object GetIdValue() + { + return _UGID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(UGID, ""); + //AuthorizationRules.AllowRead(UID, ""); + //AuthorizationRules.AllowRead(GID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UID, ""); + //AuthorizationRules.AllowWrite(GID, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Membership() + {/* require use of factory methods */} + public static Membership New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Membership"); + return DataPortal.Create(); + } + public static Membership New(int uid, int gid, string startDate, string endDate) + { + Membership tmp = Membership.New(); + tmp.UID = uid; + tmp.GID = gid; + tmp.StartDate = startDate; + tmp.EndDate = endDate; + return tmp; + } + public static Membership MakeMembership(int uid, int gid, string startDate, string endDate) + { + Membership tmp = Membership.New(uid, gid, startDate, endDate); + tmp.Save(); + return tmp; + } + public static Membership MakeMembership(int uid, int gid, string startDate, string endDate, DateTime dts, string usrID) + { + Membership tmp = Membership.New(uid, gid, startDate, endDate); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Membership Get(int ugid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Membership"); + return DataPortal.Fetch(new PKCriteria(ugid)); + } + public static Membership Get(SafeDataReader dr) + { + if (dr.Read()) return new Membership(dr); + return null; + } + private Membership(SafeDataReader dr) + { + _UGID = dr.GetInt32("UGID"); + _UID = dr.GetInt32("UID"); + _GID = dr.GetInt32("GID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int ugid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Membership"); + DataPortal.Delete(new PKCriteria(ugid)); + } + public override Membership Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Membership"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Membership"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Membership"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _UGID; + public int UGID + { get { return _UGID; } } + public PKCriteria(int ugid) + { + _UGID = ugid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _UGID = NextUGID; + // Database Defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getMembership"; + cm.Parameters.AddWithValue("@UGID", criteria.UGID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _UGID = dr.GetInt32("UGID"); + _UID = dr.GetInt32("UID"); + _GID = dr.GetInt32("GID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Membership.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Membership.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addMembership"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@UID", _UID); + cm.Parameters.AddWithValue("@GID", _GID); + cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue); + cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_UGID = new SqlParameter("@newUGID", SqlDbType.Int); + param_UGID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_UGID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _UGID = (int)cm.Parameters["@newUGID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Membership.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Membership.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int ugid, int uid, int gid, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addMembership"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@UID", uid); + cm.Parameters.AddWithValue("@GID", gid); + cm.Parameters.AddWithValue("@StartDate", startDate.DBValue); + cm.Parameters.AddWithValue("@EndDate", endDate.DBValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_UGID = new SqlParameter("@newUGID", SqlDbType.Int); + param_UGID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_UGID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + ugid = (int)cm.Parameters["@newUGID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Membership.Add", ex); + throw new DbCslaException("Membership.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateMembership"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@UGID", _UGID); + cm.Parameters.AddWithValue("@UID", _UID); + cm.Parameters.AddWithValue("@GID", _GID); + cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue); + cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Membership.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int ugid, int uid, int gid, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateMembership"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@UGID", ugid); + cm.Parameters.AddWithValue("@UID", uid); + cm.Parameters.AddWithValue("@GID", gid); + cm.Parameters.AddWithValue("@StartDate", startDate.DBValue); + cm.Parameters.AddWithValue("@EndDate", endDate.DBValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Membership.Update", ex); + throw new DbCslaException("Membership.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_UGID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteMembership"; + cm.Parameters.AddWithValue("@UGID", criteria.UGID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Membership.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Membership.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int ugid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteMembership"; + // Input PK Fields + cm.Parameters.AddWithValue("@UGID", ugid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Membership.Remove", ex); + throw new DbCslaException("Membership.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int ugid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(ugid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _UGID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int ugid) + { + _UGID = ugid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsMembership"; + cm.Parameters.AddWithValue("@UGID", _UGID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Membership.DataPortal_Execute", ex); + throw new DbCslaException("Membership.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create MembershipExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Membership +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfo.cs new file mode 100644 index 00000000..1eb2d676 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfo.cs @@ -0,0 +1,147 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class MembershipInfo : ReadOnlyBase + { + #region Business Methods + private int _UGID; + [System.ComponentModel.DataObjectField(true, true)] + public int UGID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UGID; + } + } + private int _UID; + public int UID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UID; + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + // TODO: Replace base MembershipInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current MembershipInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check MembershipInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current MembershipInfo + protected override object GetIdValue() + { + return _UGID; + } + #endregion + #region Factory Methods + private MembershipInfo() + { /* require use of factory methods */ } + public Membership Get() + { + return Membership.Get(_UGID); + } + #endregion + #region Data Access Portal + internal MembershipInfo(SafeDataReader dr) + { + try + { + _UGID = dr.GetInt32("UGID"); + _UID = dr.GetInt32("UID"); + _GID = dr.GetInt32("GID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + } + catch (Exception ex) + { + Database.LogException("MembershipInfo.Constructor", ex); + throw new DbCslaException("MembershipInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfoList.cs new file mode 100644 index 00000000..d5a4b5b7 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfoList.cs @@ -0,0 +1,168 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// MembershipInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class MembershipInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static MembershipInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static MembershipInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static MembershipInfoList GetByGroup(int gid) + { + return DataPortal.Fetch(new GroupCriteria(gid)); + } + public static MembershipInfoList GetByUser(int uid) + { + return DataPortal.Fetch(new UserCriteria(uid)); + } + private MembershipInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getMemberships"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new MembershipInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("MembershipInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class GroupCriteria + { + public GroupCriteria(int gid) + { + _GID = gid; + } + private int _GID; + public int GID + { + get { return _GID; } + set { _GID = value; } + } + } + private void DataPortal_Fetch(GroupCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getMembershipsByGroup"; + cm.Parameters.AddWithValue("@GID", criteria.GID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new MembershipInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("MembershipInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class UserCriteria + { + public UserCriteria(int uid) + { + _UID = uid; + } + private int _UID; + public int UID + { + get { return _UID; } + set { _UID = value; } + } + } + private void DataPortal_Fetch(UserCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getMembershipsByUser"; + cm.Parameters.AddWithValue("@UID", criteria.UID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new MembershipInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("MembershipInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("MembershipInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Permission.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Permission.cs new file mode 100644 index 00000000..894e6832 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Permission.cs @@ -0,0 +1,876 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Permission Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Permission : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextPID = -1; + public static int NextPID + { + get { return _nextPID--; } + } + private int _PID; + [System.ComponentModel.DataObjectField(true, true)] + public int PID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PID; + } + } + private int _RID; + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_RID != value) + { + _RID = value; + PropertyHasChanged(); + } + } + } + private int _PermLevel; + /// + /// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments + /// + public int PermLevel + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermLevel; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PermLevel != value) + { + _PermLevel = value; + PropertyHasChanged(); + } + } + } + private int _VersionType; + /// + /// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All) + /// + public int VersionType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_VersionType != value) + { + _VersionType = value; + PropertyHasChanged(); + } + } + } + private int _PermValue; + /// + /// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All) + /// + public int PermValue + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermValue; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PermValue != value) + { + _PermValue = value; + PropertyHasChanged(); + } + } + } + private int _PermAD; + /// + /// 0 - Allow, 1 - Deny + /// + public int PermAD + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermAD; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PermAD != value) + { + _PermAD = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Permission.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Permission + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Permission.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Permission + protected override object GetIdValue() + { + return _PID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(PID, ""); + //AuthorizationRules.AllowRead(RID, ""); + //AuthorizationRules.AllowRead(PermLevel, ""); + //AuthorizationRules.AllowRead(VersionType, ""); + //AuthorizationRules.AllowRead(PermValue, ""); + //AuthorizationRules.AllowRead(PermAD, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(RID, ""); + //AuthorizationRules.AllowWrite(PermLevel, ""); + //AuthorizationRules.AllowWrite(VersionType, ""); + //AuthorizationRules.AllowWrite(PermValue, ""); + //AuthorizationRules.AllowWrite(PermAD, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Permission() + {/* require use of factory methods */} + public static Permission New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Permission"); + return DataPortal.Create(); + } + public static Permission New(int rid, int permLevel, int versionType, int permValue, int permAD, string startDate, string endDate) + { + Permission tmp = Permission.New(); + tmp.RID = rid; + tmp.PermLevel = permLevel; + tmp.VersionType = versionType; + tmp.PermValue = permValue; + tmp.PermAD = permAD; + tmp.StartDate = startDate; + tmp.EndDate = endDate; + return tmp; + } + public static Permission MakePermission(int rid, int permLevel, int versionType, int permValue, int permAD, string startDate, string endDate) + { + Permission tmp = Permission.New(rid, permLevel, versionType, permValue, permAD, startDate, endDate); + tmp.Save(); + return tmp; + } + public static Permission MakePermission(int rid, int permLevel, int versionType, int permValue, int permAD, string startDate, string endDate, DateTime dts, string usrID) + { + Permission tmp = Permission.New(rid, permLevel, versionType, permValue, permAD, startDate, endDate); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Permission Get(int pid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Permission"); + return DataPortal.Fetch(new PKCriteria(pid)); + } + public static Permission Get(SafeDataReader dr) + { + if (dr.Read()) return new Permission(dr); + return null; + } + private Permission(SafeDataReader dr) + { + _PID = dr.GetInt32("PID"); + _RID = dr.GetInt32("RID"); + _PermLevel = dr.GetInt32("PermLevel"); + _VersionType = dr.GetInt32("VersionType"); + _PermValue = dr.GetInt32("PermValue"); + _PermAD = dr.GetInt32("PermAD"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int pid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Permission"); + DataPortal.Delete(new PKCriteria(pid)); + } + public override Permission Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Permission"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Permission"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Permission"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _PID; + public int PID + { get { return _PID; } } + public PKCriteria(int pid) + { + _PID = pid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _PID = NextPID; + // Database Defaults + _PermAD = ext.DefaultPermAD; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPermission"; + cm.Parameters.AddWithValue("@PID", criteria.PID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _PID = dr.GetInt32("PID"); + _RID = dr.GetInt32("RID"); + _PermLevel = dr.GetInt32("PermLevel"); + _VersionType = dr.GetInt32("VersionType"); + _PermValue = dr.GetInt32("PermValue"); + _PermAD = dr.GetInt32("PermAD"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Permission.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Permission.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addPermission"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@RID", _RID); + cm.Parameters.AddWithValue("@PermLevel", _PermLevel); + cm.Parameters.AddWithValue("@VersionType", _VersionType); + cm.Parameters.AddWithValue("@PermValue", _PermValue); + cm.Parameters.AddWithValue("@PermAD", _PermAD); + cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue); + cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_PID = new SqlParameter("@newPID", SqlDbType.Int); + param_PID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_PID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _PID = (int)cm.Parameters["@newPID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Permission.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Permission.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int pid, int rid, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addPermission"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@RID", rid); + cm.Parameters.AddWithValue("@PermLevel", permLevel); + cm.Parameters.AddWithValue("@VersionType", versionType); + cm.Parameters.AddWithValue("@PermValue", permValue); + cm.Parameters.AddWithValue("@PermAD", permAD); + cm.Parameters.AddWithValue("@StartDate", startDate.DBValue); + cm.Parameters.AddWithValue("@EndDate", endDate.DBValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_PID = new SqlParameter("@newPID", SqlDbType.Int); + param_PID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_PID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + pid = (int)cm.Parameters["@newPID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Permission.Add", ex); + throw new DbCslaException("Permission.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updatePermission"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@PID", _PID); + cm.Parameters.AddWithValue("@RID", _RID); + cm.Parameters.AddWithValue("@PermLevel", _PermLevel); + cm.Parameters.AddWithValue("@VersionType", _VersionType); + cm.Parameters.AddWithValue("@PermValue", _PermValue); + cm.Parameters.AddWithValue("@PermAD", _PermAD); + cm.Parameters.AddWithValue("@StartDate", new SmartDate(_StartDate).DBValue); + cm.Parameters.AddWithValue("@EndDate", new SmartDate(_EndDate).DBValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Permission.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int pid, int rid, int permLevel, int versionType, int permValue, int permAD, SmartDate startDate, SmartDate endDate, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updatePermission"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@PID", pid); + cm.Parameters.AddWithValue("@RID", rid); + cm.Parameters.AddWithValue("@PermLevel", permLevel); + cm.Parameters.AddWithValue("@VersionType", versionType); + cm.Parameters.AddWithValue("@PermValue", permValue); + cm.Parameters.AddWithValue("@PermAD", permAD); + cm.Parameters.AddWithValue("@StartDate", startDate.DBValue); + cm.Parameters.AddWithValue("@EndDate", endDate.DBValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Permission.Update", ex); + throw new DbCslaException("Permission.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_PID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deletePermission"; + cm.Parameters.AddWithValue("@PID", criteria.PID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Permission.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Permission.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int pid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deletePermission"; + // Input PK Fields + cm.Parameters.AddWithValue("@PID", pid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Permission.Remove", ex); + throw new DbCslaException("Permission.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int pid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(pid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _PID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int pid) + { + _PID = pid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsPermission"; + cm.Parameters.AddWithValue("@PID", _PID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Permission.DataPortal_Execute", ex); + throw new DbCslaException("Permission.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultPermAD + { + get { return 0; } + } + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create PermissionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Permission +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultPermAD +// { +// get { return 0; } +// } +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfo.cs new file mode 100644 index 00000000..0d52f843 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfo.cs @@ -0,0 +1,192 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// PermissionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class PermissionInfo : ReadOnlyBase + { + #region Business Methods + private int _PID; + [System.ComponentModel.DataObjectField(true, true)] + public int PID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PID; + } + } + private int _RID; + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + } + private int _PermLevel; + /// + /// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments + /// + public int PermLevel + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermLevel; + } + } + private int _VersionType; + /// + /// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All) + /// + public int VersionType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionType; + } + } + private int _PermValue; + /// + /// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All) + /// + public int PermValue + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermValue; + } + } + private int _PermAD; + /// + /// 0 - Allow, 1 - Deny + /// + public int PermAD + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermAD; + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + // TODO: Replace base PermissionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current PermissionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check PermissionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current PermissionInfo + protected override object GetIdValue() + { + return _PID; + } + #endregion + #region Factory Methods + private PermissionInfo() + { /* require use of factory methods */ } + public Permission Get() + { + return Permission.Get(_PID); + } + #endregion + #region Data Access Portal + internal PermissionInfo(SafeDataReader dr) + { + try + { + _PID = dr.GetInt32("PID"); + _RID = dr.GetInt32("RID"); + _PermLevel = dr.GetInt32("PermLevel"); + _VersionType = dr.GetInt32("VersionType"); + _PermValue = dr.GetInt32("PermValue"); + _PermAD = dr.GetInt32("PermAD"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + } + catch (Exception ex) + { + Database.LogException("PermissionInfo.Constructor", ex); + throw new DbCslaException("PermissionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfoList.cs new file mode 100644 index 00000000..1d484ce1 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// PermissionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class PermissionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static PermissionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static PermissionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static PermissionInfoList GetByRole(int rid) + { + return DataPortal.Fetch(new RoleCriteria(rid)); + } + private PermissionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPermissions"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new PermissionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("PermissionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class RoleCriteria + { + public RoleCriteria(int rid) + { + _RID = rid; + } + private int _RID; + public int RID + { + get { return _RID; } + set { _RID = value; } + } + } + private void DataPortal_Fetch(RoleCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPermissionsByRole"; + cm.Parameters.AddWithValue("@RID", criteria.RID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new PermissionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("PermissionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("PermissionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Procedure.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Procedure.cs new file mode 100644 index 00000000..67388053 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Procedure.cs @@ -0,0 +1,805 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Procedure Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Procedure : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextProcID = -1; + public static int NextProcID + { + get { return _nextProcID--; } + } + private int _ProcID; + [System.ComponentModel.DataObjectField(true, true)] + public int ProcID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ProcID; + } + } + private string _Number = string.Empty; + public string Number + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Number; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Number != value) + { + _Number = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private string _Format = string.Empty; + public string Format + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Format; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Format != value) + { + _Format = value; + PropertyHasChanged(); + } + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_StructureID != value) + { + _StructureID = value; + PropertyHasChanged(); + } + } + } + private int _StructureStart; + public int StructureStart + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureStart; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_StructureStart != value) + { + _StructureStart = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Procedure.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Procedure + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Procedure.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Procedure + protected override object GetIdValue() + { + return _ProcID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Number"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Title"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Format", 2048)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(ProcID, ""); + //AuthorizationRules.AllowRead(Number, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(Format, ""); + //AuthorizationRules.AllowRead(StructureID, ""); + //AuthorizationRules.AllowRead(StructureStart, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(Number, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(Format, ""); + //AuthorizationRules.AllowWrite(StructureID, ""); + //AuthorizationRules.AllowWrite(StructureStart, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Procedure() + {/* require use of factory methods */} + public static Procedure New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Procedure"); + return DataPortal.Create(); + } + public static Procedure New(string number, string title, string config, string format, int structureID, int structureStart) + { + Procedure tmp = Procedure.New(); + tmp.Number = number; + tmp.Title = title; + tmp.Config = config; + tmp.Format = format; + tmp.StructureID = structureID; + tmp.StructureStart = structureStart; + return tmp; + } + public static Procedure MakeProcedure(string number, string title, string config, string format, int structureID, int structureStart) + { + Procedure tmp = Procedure.New(number, title, config, format, structureID, structureStart); + tmp.Save(); + return tmp; + } + public static Procedure MakeProcedure(string number, string title, string config, string format, int structureID, int structureStart, DateTime dts, string userID) + { + Procedure tmp = Procedure.New(number, title, config, format, structureID, structureStart); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static Procedure Get(int procID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Procedure"); + return DataPortal.Fetch(new PKCriteria(procID)); + } + public static Procedure Get(SafeDataReader dr) + { + if (dr.Read()) return new Procedure(dr); + return null; + } + private Procedure(SafeDataReader dr) + { + _ProcID = dr.GetInt32("ProcID"); + _Number = dr.GetString("Number"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _Format = dr.GetString("Format"); + _StructureID = dr.GetInt32("StructureID"); + _StructureStart = dr.GetInt32("StructureStart"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int procID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Procedure"); + DataPortal.Delete(new PKCriteria(procID)); + } + public override Procedure Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Procedure"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Procedure"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Procedure"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _ProcID; + public int ProcID + { get { return _ProcID; } } + public PKCriteria(int procID) + { + _ProcID = procID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _ProcID = NextProcID; + // Database Defaults + _StructureID = ext.DefaultStructureID; + _StructureStart = ext.DefaultStructureStart; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getProcedure"; + cm.Parameters.AddWithValue("@ProcID", criteria.ProcID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _ProcID = dr.GetInt32("ProcID"); + _Number = dr.GetString("Number"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _Format = dr.GetString("Format"); + _StructureID = dr.GetInt32("StructureID"); + _StructureStart = dr.GetInt32("StructureStart"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Procedure.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Procedure.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addProcedure"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Number", _Number); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@Format", _Format); + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@StructureStart", _StructureStart); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_ProcID = new SqlParameter("@newProcID", SqlDbType.Int); + param_ProcID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_ProcID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _ProcID = (int)cm.Parameters["@newProcID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Procedure.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Procedure.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int procID, string number, string title, string config, string format, int structureID, int structureStart, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addProcedure"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Number", number); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@Format", format); + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@StructureStart", structureStart); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_ProcID = new SqlParameter("@newProcID", SqlDbType.Int); + param_ProcID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_ProcID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + procID = (int)cm.Parameters["@newProcID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Procedure.Add", ex); + throw new DbCslaException("Procedure.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateProcedure"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@ProcID", _ProcID); + cm.Parameters.AddWithValue("@Number", _Number); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@Format", _Format); + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@StructureStart", _StructureStart); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Procedure.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int procID, string number, string title, string config, string format, int structureID, int structureStart, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateProcedure"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@ProcID", procID); + cm.Parameters.AddWithValue("@Number", number); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@Format", format); + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@StructureStart", structureStart); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Procedure.Update", ex); + throw new DbCslaException("Procedure.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_ProcID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteProcedure"; + cm.Parameters.AddWithValue("@ProcID", criteria.ProcID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Procedure.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Procedure.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int procID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteProcedure"; + // Input PK Fields + cm.Parameters.AddWithValue("@ProcID", procID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Procedure.Remove", ex); + throw new DbCslaException("Procedure.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int procID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(procID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _ProcID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int procID) + { + _ProcID = procID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsProcedure"; + cm.Parameters.AddWithValue("@ProcID", _ProcID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Procedure.DataPortal_Execute", ex); + throw new DbCslaException("Procedure.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultStructureID + { + get { return 0; } + } + public virtual int DefaultStructureStart + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ProcedureExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Procedure +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultStructureID +// { +// get { return 0; } +// } +// public virtual int DefaultStructureStart +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfo.cs new file mode 100644 index 00000000..1885b521 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfo.cs @@ -0,0 +1,169 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ProcedureInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ProcedureInfo : ReadOnlyBase + { + #region Business Methods + private int _ProcID; + [System.ComponentModel.DataObjectField(true, true)] + public int ProcID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ProcID; + } + } + private string _Number = string.Empty; + public string Number + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Number; + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private string _Format = string.Empty; + public string Format + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Format; + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private int _StructureStart; + public int StructureStart + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureStart; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + // TODO: Replace base ProcedureInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ProcedureInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ProcedureInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ProcedureInfo + protected override object GetIdValue() + { + return _ProcID; + } + #endregion + #region Factory Methods + private ProcedureInfo() + { /* require use of factory methods */ } + public Procedure Get() + { + return Procedure.Get(_ProcID); + } + #endregion + #region Data Access Portal + internal ProcedureInfo(SafeDataReader dr) + { + try + { + _ProcID = dr.GetInt32("ProcID"); + _Number = dr.GetString("Number"); + _Title = dr.GetString("Title"); + _Config = dr.GetString("Config"); + _Format = dr.GetString("Format"); + _StructureID = dr.GetInt32("StructureID"); + _StructureStart = dr.GetInt32("StructureStart"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + } + catch (Exception ex) + { + Database.LogException("ProcedureInfo.Constructor", ex); + throw new DbCslaException("ProcedureInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfoList.cs new file mode 100644 index 00000000..1207bb83 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ProcedureInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ProcedureInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static ProcedureInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static ProcedureInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private ProcedureInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getProcedures"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ProcedureInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ProcedureInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ProcedureInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoUsage.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoUsage.cs new file mode 100644 index 00000000..f6e17975 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoUsage.cs @@ -0,0 +1,666 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoUsage Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoUsage : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextROUsageId = -1; + public static int NextROUsageId + { + get { return _nextROUsageId--; } + } + private int _ROUsageId; + [System.ComponentModel.DataObjectField(true, true)] + public int ROUsageId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ROUsageId; + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_StructureID != value) + { + _StructureID = value; + PropertyHasChanged(); + } + } + } + private string _ROID = string.Empty; + public string ROID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ROID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_ROID != value) + { + _ROID = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base RoUsage.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current RoUsage + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check RoUsage.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current RoUsage + protected override object GetIdValue() + { + return _ROUsageId; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "ROID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROID", 16)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(ROUsageId, ""); + //AuthorizationRules.AllowRead(StructureID, ""); + //AuthorizationRules.AllowRead(ROID, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(StructureID, ""); + //AuthorizationRules.AllowWrite(ROID, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private RoUsage() + {/* require use of factory methods */} + public static RoUsage New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a RoUsage"); + return DataPortal.Create(); + } + public static RoUsage New(int structureID, string roid) + { + RoUsage tmp = RoUsage.New(); + tmp.StructureID = structureID; + tmp.ROID = roid; + return tmp; + } + public static RoUsage MakeRoUsage(int structureID, string roid) + { + RoUsage tmp = RoUsage.New(structureID, roid); + tmp.Save(); + return tmp; + } + public static RoUsage MakeRoUsage(int structureID, string roid, DateTime dts, string userID) + { + RoUsage tmp = RoUsage.New(structureID, roid); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static RoUsage Get(int rOUsageId) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a RoUsage"); + return DataPortal.Fetch(new PKCriteria(rOUsageId)); + } + public static RoUsage Get(SafeDataReader dr) + { + if (dr.Read()) return new RoUsage(dr); + return null; + } + private RoUsage(SafeDataReader dr) + { + _ROUsageId = dr.GetInt32("ROUsageId"); + _StructureID = dr.GetInt32("StructureID"); + _ROID = dr.GetString("ROID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int rOUsageId) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a RoUsage"); + DataPortal.Delete(new PKCriteria(rOUsageId)); + } + public override RoUsage Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a RoUsage"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a RoUsage"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a RoUsage"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _ROUsageId; + public int ROUsageId + { get { return _ROUsageId; } } + public PKCriteria(int rOUsageId) + { + _ROUsageId = rOUsageId; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _ROUsageId = NextROUsageId; + // Database Defaults + _StructureID = ext.DefaultStructureID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getRoUsage"; + cm.Parameters.AddWithValue("@ROUsageId", criteria.ROUsageId); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _ROUsageId = dr.GetInt32("ROUsageId"); + _StructureID = dr.GetInt32("StructureID"); + _ROID = dr.GetString("ROID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("RoUsage.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addRoUsage"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@ROID", _ROID); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_ROUsageId = new SqlParameter("@newROUsageId", SqlDbType.Int); + param_ROUsageId.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_ROUsageId); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _ROUsageId = (int)cm.Parameters["@newROUsageId"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("RoUsage.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int rOUsageId, int structureID, string roid, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addRoUsage"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@ROID", roid); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_ROUsageId = new SqlParameter("@newROUsageId", SqlDbType.Int); + param_ROUsageId.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_ROUsageId); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + rOUsageId = (int)cm.Parameters["@newROUsageId"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.Add", ex); + throw new DbCslaException("RoUsage.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateRoUsage"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@ROUsageId", _ROUsageId); + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@ROID", _ROID); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int rOUsageId, int structureID, string roid, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateRoUsage"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@ROUsageId", rOUsageId); + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@ROID", roid); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.Update", ex); + throw new DbCslaException("RoUsage.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_ROUsageId)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteRoUsage"; + cm.Parameters.AddWithValue("@ROUsageId", criteria.ROUsageId); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("RoUsage.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int rOUsageId) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteRoUsage"; + // Input PK Fields + cm.Parameters.AddWithValue("@ROUsageId", rOUsageId); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.Remove", ex); + throw new DbCslaException("RoUsage.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int rOUsageId) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(rOUsageId)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _ROUsageId; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int rOUsageId) + { + _ROUsageId = rOUsageId; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsRoUsage"; + cm.Parameters.AddWithValue("@ROUsageId", _ROUsageId); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("RoUsage.DataPortal_Execute", ex); + throw new DbCslaException("RoUsage.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultStructureID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create RoUsageExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class RoUsage +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultStructureID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfo.cs new file mode 100644 index 00000000..5d786f0e --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfo.cs @@ -0,0 +1,125 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoUsageInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoUsageInfo : ReadOnlyBase + { + #region Business Methods + private int _ROUsageId; + [System.ComponentModel.DataObjectField(true, true)] + public int ROUsageId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ROUsageId; + } + } + private int _StructureID; + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private string _ROID = string.Empty; + public string ROID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ROID; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + // TODO: Replace base RoUsageInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current RoUsageInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check RoUsageInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current RoUsageInfo + protected override object GetIdValue() + { + return _ROUsageId; + } + #endregion + #region Factory Methods + private RoUsageInfo() + { /* require use of factory methods */ } + public RoUsage Get() + { + return RoUsage.Get(_ROUsageId); + } + #endregion + #region Data Access Portal + internal RoUsageInfo(SafeDataReader dr) + { + try + { + _ROUsageId = dr.GetInt32("ROUsageId"); + _StructureID = dr.GetInt32("StructureID"); + _ROID = dr.GetString("ROID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + } + catch (Exception ex) + { + Database.LogException("RoUsageInfo.Constructor", ex); + throw new DbCslaException("RoUsageInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfoList.cs new file mode 100644 index 00000000..70b10674 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoUsageInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoUsageInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static RoUsageInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static RoUsageInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static RoUsageInfoList GetByStructure(int structureID) + { + return DataPortal.Fetch(new StructureCriteria(structureID)); + } + private RoUsageInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getRoUsages"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new RoUsageInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("RoUsageInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class StructureCriteria + { + public StructureCriteria(int structureID) + { + _StructureID = structureID; + } + private int _StructureID; + public int StructureID + { + get { return _StructureID; } + set { _StructureID = value; } + } + } + private void DataPortal_Fetch(StructureCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getRoUsagesByStructure"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new RoUsageInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("RoUsageInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("RoUsageInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Role.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Role.cs new file mode 100644 index 00000000..ef2fe679 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Role.cs @@ -0,0 +1,707 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Role Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Role : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextRID = -1; + public static int NextRID + { + get { return _nextRID--; } + } + private int _RID; + [System.ComponentModel.DataObjectField(true, true)] + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Name != value) + { + _Name = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private RoleAssignments _RoleAssignments = RoleAssignments.New(); + /// + /// Related Field + /// + public RoleAssignments RoleAssignments + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RoleAssignments; + } + } + private RolePermissions _RolePermissions = RolePermissions.New(); + /// + /// Related Field + /// + public RolePermissions RolePermissions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RolePermissions; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _RoleAssignments.IsDirty || _RolePermissions.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _RoleAssignments.IsValid && _RolePermissions.IsValid; } + } + // TODO: Replace base Role.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Role + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Role.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Role + protected override object GetIdValue() + { + return _RID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Name"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 50)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Title"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 250)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(RID, ""); + //AuthorizationRules.AllowRead(Name, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(Name, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Role() + {/* require use of factory methods */} + public static Role New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Role"); + return DataPortal.Create(); + } + public static Role New(string name, string title) + { + Role tmp = Role.New(); + tmp.Name = name; + tmp.Title = title; + return tmp; + } + public static Role MakeRole(string name, string title) + { + Role tmp = Role.New(name, title); + tmp.Save(); + return tmp; + } + public static Role MakeRole(string name, string title, DateTime dts, string usrID) + { + Role tmp = Role.New(name, title); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static Role Get(int rid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Role"); + return DataPortal.Fetch(new PKCriteria(rid)); + } + public static Role Get(SafeDataReader dr) + { + if (dr.Read()) return new Role(dr); + return null; + } + private Role(SafeDataReader dr) + { + _RID = dr.GetInt32("RID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int rid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Role"); + DataPortal.Delete(new PKCriteria(rid)); + } + public override Role Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Role"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Role"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Role"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _RID; + public int RID + { get { return _RID; } } + public PKCriteria(int rid) + { + _RID = rid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _RID = NextRID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getRole"; + cm.Parameters.AddWithValue("@RID", criteria.RID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _RID = dr.GetInt32("RID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _RoleAssignments = RoleAssignments.Get(dr); + // load child objects + dr.NextResult(); + _RolePermissions = RolePermissions.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Role.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Role.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addRole"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_RID = new SqlParameter("@newRID", SqlDbType.Int); + param_RID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_RID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _RID = (int)cm.Parameters["@newRID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _RoleAssignments.Update(this, cn); + _RolePermissions.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Role.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Role.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addRole"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_RID = new SqlParameter("@newRID", SqlDbType.Int); + param_RID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_RID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + rid = (int)cm.Parameters["@newRID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Role.Add", ex); + throw new DbCslaException("Role.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateRole"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@RID", _RID); + cm.Parameters.AddWithValue("@Name", _Name); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _RoleAssignments.Update(this, cn); + _RolePermissions.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Role.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int rid, string name, string title, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateRole"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@RID", rid); + cm.Parameters.AddWithValue("@Name", name); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Role.Update", ex); + throw new DbCslaException("Role.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_RID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteRole"; + cm.Parameters.AddWithValue("@RID", criteria.RID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Role.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Role.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int rid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteRole"; + // Input PK Fields + cm.Parameters.AddWithValue("@RID", rid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Role.Remove", ex); + throw new DbCslaException("Role.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int rid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(rid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _RID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int rid) + { + _RID = rid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsRole"; + cm.Parameters.AddWithValue("@RID", _RID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Role.DataPortal_Execute", ex); + throw new DbCslaException("Role.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create RoleExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Role +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignment.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignment.cs new file mode 100644 index 00000000..0796eea2 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignment.cs @@ -0,0 +1,605 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoleAssignment Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoleAssignment : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _AID; + [System.ComponentModel.DataObjectField(true, true)] + public int AID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _AID; + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_GID != value) + { + _GID = value; + PropertyHasChanged(); + } + } + } + private int _FolderID; + public int FolderID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FolderID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FolderID != value) + { + _FolderID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private int _Folder_ParentID; + /// + /// {child Folders.FolderID} + /// + public int Folder_ParentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_ParentID; + } + } + private int _Folder_DBID; + public int Folder_DBID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_DBID; + } + } + private string _Folder_Name = string.Empty; + public string Folder_Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_Name; + } + } + private string _Folder_Title = string.Empty; + public string Folder_Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_Title; + } + } + private string _Folder_Config = string.Empty; + public string Folder_Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_Config; + } + } + private DateTime _Folder_DTS = new DateTime(); + public DateTime Folder_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_DTS; + } + } + private string _Folder_UsrID = string.Empty; + public string Folder_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Folder_UsrID; + } + } + private string _Group_GroupName = string.Empty; + public string Group_GroupName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_GroupName; + } + } + private int _Group_GroupType; + public int Group_GroupType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_GroupType; + } + } + private string _Group_Config = string.Empty; + public string Group_Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_Config; + } + } + private DateTime _Group_DTS = new DateTime(); + public DateTime Group_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_DTS; + } + } + private string _Group_UsrID = string.Empty; + public string Group_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_UsrID; + } + } + // TODO: Check RoleAssignment.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current RoleAssignment + protected override object GetIdValue() + { + return _AID; + } + // TODO: Replace base RoleAssignment.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current RoleAssignment + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(AID, ""); + //AuthorizationRules.AllowRead(GID, ""); + //AuthorizationRules.AllowWrite(GID, ""); + //AuthorizationRules.AllowRead(FolderID, ""); + //AuthorizationRules.AllowWrite(FolderID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static RoleAssignment New(int gid, int folderID) + { + return new RoleAssignment(Volian.CSLA.Library.Group.Get(gid), Volian.CSLA.Library.Folder.Get(folderID)); + } + internal static RoleAssignment Get(SafeDataReader dr) + { + return new RoleAssignment(dr); + } + public RoleAssignment() + { + MarkAsChild(); + _AID = Assignment.NextAID; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private RoleAssignment(Group group, Folder folder) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _FolderID = folder.FolderID; + _Folder_ParentID = folder.ParentID; + _Folder_DBID = folder.DBID; + _Folder_Name = folder.Name; + _Folder_Title = folder.Title; + _Folder_Config = folder.Config; + _Folder_DTS = folder.DTS; + _Folder_UsrID = folder.UsrID; + _GID = group.GID; + _Group_GroupName = group.GroupName; + _Group_GroupType = group.GroupType; + _Group_Config = group.Config; + _Group_DTS = group.DTS; + _Group_UsrID = group.UsrID; + } + private RoleAssignment(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _AID = dr.GetInt32("AID"); + _GID = dr.GetInt32("GID"); + _FolderID = dr.GetInt32("FolderID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + _Folder_ParentID = dr.GetInt32("Folder_ParentID"); + _Folder_DBID = dr.GetInt32("Folder_DBID"); + _Folder_Name = dr.GetString("Folder_Name"); + _Folder_Title = dr.GetString("Folder_Title"); + _Folder_Config = dr.GetString("Folder_Config"); + _Folder_DTS = dr.GetDateTime("Folder_DTS"); + _Folder_UsrID = dr.GetString("Folder_UsrID"); + _Group_GroupName = dr.GetString("Group_GroupName"); + _Group_GroupType = dr.GetInt32("Group_GroupType"); + _Group_Config = dr.GetString("Group_Config"); + _Group_DTS = dr.GetDateTime("Group_DTS"); + _Group_UsrID = dr.GetString("Group_UsrID"); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("RoleAssignment.Fetch", ex); + throw new DbCslaException("RoleAssignment.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Role role, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Assignment.Add(cn, ref _AID, _GID, role.RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID); + MarkOld(); + } + internal void Update(Role role, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Assignment.Update(cn, ref _AID, _GID, role.RID, _FolderID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Role role, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Assignment.Remove(cn, _AID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create RoleAssignmentExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class RoleAssignment +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignments.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignments.cs new file mode 100644 index 00000000..edcaf13c --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignments.cs @@ -0,0 +1,142 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoleAssignments Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoleAssignments : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // Many To Many + public RoleAssignment this[int folderID, int gid] + { + get + { + foreach (RoleAssignment assignment in this) + if (assignment.FolderID == folderID && assignment.GID == gid) + return assignment; + return null; + } + } + public RoleAssignment GetItem(int folderID, int gid) + { + foreach (RoleAssignment assignment in this) + if (assignment.FolderID == folderID && assignment.GID == gid) + return assignment; + return null; + } + public RoleAssignment Add(int gid, int folderID) + { + if (!Contains(gid, folderID)) + { + RoleAssignment assignment = RoleAssignment.New(gid, folderID); + this.Add(assignment); + return assignment; + } + else + throw new InvalidOperationException("assignment already exists"); + } + public void Remove(int folderID, int gid) + { + foreach (RoleAssignment assignment in this) + { + if (assignment.FolderID == folderID && assignment.GID == gid) + { + Remove(assignment); + break; + } + } + } + public bool Contains(int folderID, int gid) + { + foreach (RoleAssignment assignment in this) + if (assignment.FolderID == folderID && assignment.GID == gid) + return true; + return false; + } + public bool ContainsDeleted(int folderID, int gid) + { + foreach (RoleAssignment assignment in DeletedList) + if (assignment.FolderID == folderID && assignment.GID == gid) + return true; + return false; + } + #endregion + #region Factory Methods + internal static RoleAssignments New() + { + return new RoleAssignments(); + } + internal static RoleAssignments Get(SafeDataReader dr) + { + return new RoleAssignments(dr); + } + private RoleAssignments() + { + MarkAsChild(); + } + private RoleAssignments(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(RoleAssignment.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Role role, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (RoleAssignment obj in DeletedList) + obj.DeleteSelf(role, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (RoleAssignment obj in this) + { + if (obj.IsNew) + obj.Insert(role, cn); + else + obj.Update(role, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoleInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoleInfo.cs new file mode 100644 index 00000000..5bcab49c --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoleInfo.cs @@ -0,0 +1,177 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoleInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoleInfo : ReadOnlyBase + { + #region Business Methods + private int _RID; + [System.ComponentModel.DataObjectField(true, true)] + public int RID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RID; + } + } + private string _Name = string.Empty; + public string Name + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Name; + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + private int _Assignmentcount = 0; + /// + /// Count of Assignment for this Role + /// + public int AssignmentCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Assignmentcount; + } + } + private AssignmentInfoList _Assignments = null; + public AssignmentInfoList Assignments + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Assignments == null) + _Assignments = AssignmentInfoList.GetByRole(_RID); + return _Assignments; + } + } + private int _Permissioncount = 0; + /// + /// Count of Permission for this Role + /// + public int PermissionCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Permissioncount; + } + } + private PermissionInfoList _Permissions = null; + public PermissionInfoList Permissions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Permissions == null) + _Permissions = PermissionInfoList.GetByRole(_RID); + return _Permissions; + } + } + // TODO: Replace base RoleInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current RoleInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check RoleInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current RoleInfo + protected override object GetIdValue() + { + return _RID; + } + #endregion + #region Factory Methods + private RoleInfo() + { /* require use of factory methods */ } + public Role Get() + { + return Role.Get(_RID); + } + #endregion + #region Data Access Portal + internal RoleInfo(SafeDataReader dr) + { + try + { + _RID = dr.GetInt32("RID"); + _Name = dr.GetString("Name"); + _Title = dr.GetString("Title"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + _Assignmentcount = dr.GetInt32("AssignmentCount"); + _Permissioncount = dr.GetInt32("PermissionCount"); + } + catch (Exception ex) + { + Database.LogException("RoleInfo.Constructor", ex); + throw new DbCslaException("RoleInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RoleInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RoleInfoList.cs new file mode 100644 index 00000000..5f9c7d3f --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RoleInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RoleInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RoleInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static RoleInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static RoleInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private RoleInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getRoles"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new RoleInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("RoleInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("RoleInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RolePermission.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RolePermission.cs new file mode 100644 index 00000000..96232e18 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RolePermission.cs @@ -0,0 +1,527 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RolePermission Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RolePermission : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _PID; + [System.ComponentModel.DataObjectField(true, true)] + public int PID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PID; + } + } + private int _PermLevel; + /// + /// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments + /// + public int PermLevel + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermLevel; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PermLevel != value) + { + _PermLevel = value; + PropertyHasChanged(); + } + } + } + private int _VersionType; + /// + /// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All) + /// + public int VersionType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _VersionType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_VersionType != value) + { + _VersionType = value; + PropertyHasChanged(); + } + } + } + private int _PermValue; + /// + /// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All) + /// + public int PermValue + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermValue; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PermValue != value) + { + _PermValue = value; + PropertyHasChanged(); + } + } + } + private int _PermAD; + /// + /// 0 - Allow, 1 - Deny + /// + public int PermAD + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PermAD; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PermAD != value) + { + _PermAD = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check RolePermission.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current RolePermission + protected override object GetIdValue() + { + return _PID; + } + // TODO: Replace base RolePermission.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current RolePermission + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(PID, ""); + //AuthorizationRules.AllowRead(PermLevel, ""); + //AuthorizationRules.AllowWrite(PermLevel, ""); + //AuthorizationRules.AllowRead(VersionType, ""); + //AuthorizationRules.AllowWrite(VersionType, ""); + //AuthorizationRules.AllowRead(PermValue, ""); + //AuthorizationRules.AllowWrite(PermValue, ""); + //AuthorizationRules.AllowRead(PermAD, ""); + //AuthorizationRules.AllowWrite(PermAD, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static RolePermission New(int permLevel, int versionType, int permValue) + { + return new RolePermission(permLevel, versionType, permValue); + } + internal static RolePermission Get(SafeDataReader dr) + { + return new RolePermission(dr); + } + public RolePermission() + { + MarkAsChild(); + _PID = Permission.NextPID; + _PermAD = ext.DefaultPermAD; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private RolePermission(int permLevel, int versionType, int permValue) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _PermAD = ext.DefaultPermAD; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _PermLevel = permLevel; + _VersionType = versionType; + _PermValue = permValue; + } + private RolePermission(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _PID = dr.GetInt32("PID"); + _PermLevel = dr.GetInt32("PermLevel"); + _VersionType = dr.GetInt32("VersionType"); + _PermValue = dr.GetInt32("PermValue"); + _PermAD = dr.GetInt32("PermAD"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("RolePermission.Fetch", ex); + throw new DbCslaException("RolePermission.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Role role, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Permission.Add(cn, ref _PID, role.RID, _PermLevel, _VersionType, _PermValue, _PermAD, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID); + MarkOld(); + } + internal void Update(Role role, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Permission.Update(cn, ref _PID, role.RID, _PermLevel, _VersionType, _PermValue, _PermAD, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Role role, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Permission.Remove(cn, _PID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultPermAD + { + get { return 0; } + } + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create RolePermissionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class RolePermission +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultPermAD +// { +// get { return 0; } +// } +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/RolePermissions.cs b/PROMS/proms/Volian.CSLA.Library/Generated/RolePermissions.cs new file mode 100644 index 00000000..d4eb64f8 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/RolePermissions.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// RolePermissions Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class RolePermissions : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new RolePermission this[int pid] + { + get + { + foreach (RolePermission permission in this) + if (permission.PID == pid) + return permission; + return null; + } + } + public RolePermission GetItem(int pid) + { + foreach (RolePermission permission in this) + if (permission.PID == pid) + return permission; + return null; + } + public RolePermission Add(int permLevel, int versionType, int permValue) + { + RolePermission permission = RolePermission.New(permLevel, versionType, permValue); + this.Add(permission); + return permission; + } + public void Remove(int pid) + { + foreach (RolePermission permission in this) + { + if (permission.PID == pid) + { + Remove(permission); + break; + } + } + } + public bool Contains(int pid) + { + foreach (RolePermission permission in this) + if (permission.PID == pid) + return true; + return false; + } + public bool ContainsDeleted(int pid) + { + foreach (RolePermission permission in DeletedList) + if (permission.PID == pid) + return true; + return false; + } + #endregion + #region Factory Methods + internal static RolePermissions New() + { + return new RolePermissions(); + } + internal static RolePermissions Get(SafeDataReader dr) + { + return new RolePermissions(dr); + } + private RolePermissions() + { + MarkAsChild(); + } + private RolePermissions(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(RolePermission.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Role role, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (RolePermission obj in DeletedList) + obj.DeleteSelf(role, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (RolePermission obj in this) + { + if (obj.IsNew) + obj.Insert(role, cn); + else + obj.Update(role, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Section.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Section.cs new file mode 100644 index 00000000..e3299a22 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Section.cs @@ -0,0 +1,804 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Section Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Section : BusinessBase
+ { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextSectID = -1; + public static int NextSectID + { + get { return _nextSectID--; } + } + private int _SectID; + [System.ComponentModel.DataObjectField(true, true)] + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + } + private string _Number = string.Empty; + public string Number + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Number; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Number != value) + { + _Number = value; + PropertyHasChanged(); + } + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Title != value) + { + _Title = value; + PropertyHasChanged(); + } + } + } + private byte _ContentType; + /// + /// 0 Nothing, 1 Structure, 2 Document + /// + public byte ContentType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ContentType != value) + { + _ContentType = value; + PropertyHasChanged(); + } + } + } + private int _ContentID; + public int ContentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ContentID != value) + { + _ContentID = value; + PropertyHasChanged(); + } + } + } + private string _Format = string.Empty; + public string Format + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Format; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Format != value) + { + _Format = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Section.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Section + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Section.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Section + protected override object GetIdValue() + { + return _SectID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Number", 30)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Title", 510)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Format", 2048)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(SectID, ""); + //AuthorizationRules.AllowRead(Number, ""); + //AuthorizationRules.AllowRead(Title, ""); + //AuthorizationRules.AllowRead(ContentType, ""); + //AuthorizationRules.AllowRead(ContentID, ""); + //AuthorizationRules.AllowRead(Format, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(Number, ""); + //AuthorizationRules.AllowWrite(Title, ""); + //AuthorizationRules.AllowWrite(ContentType, ""); + //AuthorizationRules.AllowWrite(ContentID, ""); + //AuthorizationRules.AllowWrite(Format, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Section() + {/* require use of factory methods */} + public static Section New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Section"); + return DataPortal.Create
(); + } + public static Section New(string number, string title, byte contentType, int contentID, string format, string config) + { + Section tmp = Section.New(); + tmp.Number = number; + tmp.Title = title; + tmp.ContentType = contentType; + tmp.ContentID = contentID; + tmp.Format = format; + tmp.Config = config; + return tmp; + } + public static Section MakeSection(string number, string title, byte contentType, int contentID, string format, string config) + { + Section tmp = Section.New(number, title, contentType, contentID, format, config); + tmp.Save(); + return tmp; + } + public static Section MakeSection(string number, string title, byte contentType, int contentID, string format, string config, DateTime dts, string userID) + { + Section tmp = Section.New(number, title, contentType, contentID, format, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static Section Get(int sectID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Section"); + return DataPortal.Fetch
(new PKCriteria(sectID)); + } + public static Section Get(SafeDataReader dr) + { + if (dr.Read()) return new Section(dr); + return null; + } + private Section(SafeDataReader dr) + { + _SectID = dr.GetInt32("SectID"); + _Number = dr.GetString("Number"); + _Title = dr.GetString("Title"); + _ContentType = dr.GetByte("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _Format = dr.GetString("Format"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int sectID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Section"); + DataPortal.Delete(new PKCriteria(sectID)); + } + public override Section Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Section"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Section"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Section"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _SectID; + public int SectID + { get { return _SectID; } } + public PKCriteria(int sectID) + { + _SectID = sectID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _SectID = NextSectID; + // Database Defaults + _ContentType = ext.DefaultContentType; + _ContentID = ext.DefaultContentID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getSection"; + cm.Parameters.AddWithValue("@SectID", criteria.SectID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _SectID = dr.GetInt32("SectID"); + _Number = dr.GetString("Number"); + _Title = dr.GetString("Title"); + _ContentType = dr.GetByte("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _Format = dr.GetString("Format"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Section.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Section.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addSection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Number", _Number); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@ContentType", _ContentType); + cm.Parameters.AddWithValue("@ContentID", _ContentID); + cm.Parameters.AddWithValue("@Format", _Format); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_SectID = new SqlParameter("@newSectID", SqlDbType.Int); + param_SectID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_SectID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _SectID = (int)cm.Parameters["@newSectID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Section.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Section.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int sectID, string number, string title, byte contentType, int contentID, string format, string config, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addSection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@Number", number); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@ContentType", contentType); + cm.Parameters.AddWithValue("@ContentID", contentID); + cm.Parameters.AddWithValue("@Format", format); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_SectID = new SqlParameter("@newSectID", SqlDbType.Int); + param_SectID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_SectID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + sectID = (int)cm.Parameters["@newSectID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Section.Add", ex); + throw new DbCslaException("Section.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateSection"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@SectID", _SectID); + cm.Parameters.AddWithValue("@Number", _Number); + cm.Parameters.AddWithValue("@Title", _Title); + cm.Parameters.AddWithValue("@ContentType", _ContentType); + cm.Parameters.AddWithValue("@ContentID", _ContentID); + cm.Parameters.AddWithValue("@Format", _Format); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Section.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int sectID, string number, string title, byte contentType, int contentID, string format, string config, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateSection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@SectID", sectID); + cm.Parameters.AddWithValue("@Number", number); + cm.Parameters.AddWithValue("@Title", title); + cm.Parameters.AddWithValue("@ContentType", contentType); + cm.Parameters.AddWithValue("@ContentID", contentID); + cm.Parameters.AddWithValue("@Format", format); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Section.Update", ex); + throw new DbCslaException("Section.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_SectID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteSection"; + cm.Parameters.AddWithValue("@SectID", criteria.SectID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Section.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Section.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int sectID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteSection"; + // Input PK Fields + cm.Parameters.AddWithValue("@SectID", sectID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Section.Remove", ex); + throw new DbCslaException("Section.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int sectID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(sectID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _SectID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int sectID) + { + _SectID = sectID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsSection"; + cm.Parameters.AddWithValue("@SectID", _SectID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Section.DataPortal_Execute", ex); + throw new DbCslaException("Section.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual byte DefaultContentType + { + get { return 0; } + } + public virtual int DefaultContentID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create SectionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Section +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual byte DefaultContentType +// { +// get { return 0; } +// } +// public virtual int DefaultContentID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/SectionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/SectionInfo.cs new file mode 100644 index 00000000..57ab0505 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/SectionInfo.cs @@ -0,0 +1,198 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// SectionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class SectionInfo : ReadOnlyBase + { + #region Business Methods + private int _SectID; + [System.ComponentModel.DataObjectField(true, true)] + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + } + private string _Number = string.Empty; + public string Number + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Number; + } + } + private string _Title = string.Empty; + public string Title + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Title; + } + } + private byte _ContentType; + /// + /// 0 Nothing, 1 Structure, 2 Document + /// + public byte ContentType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentType; + } + } + private int _ContentID; + public int ContentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentID; + } + } + private string _Format = string.Empty; + public string Format + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Format; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + private int _ZSectioncount = 0; + /// + /// Count of ZSection for this Section + /// + public int ZSectionCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ZSectioncount; + } + } + private ZSectionInfoList _ZSections = null; + public ZSectionInfoList ZSections + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_ZSections == null) + _ZSections = ZSectionInfoList.GetBySection(_SectID); + return _ZSections; + } + } + // TODO: Replace base SectionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current SectionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check SectionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current SectionInfo + protected override object GetIdValue() + { + return _SectID; + } + #endregion + #region Factory Methods + private SectionInfo() + { /* require use of factory methods */ } + public Section Get() + { + return Section.Get(_SectID); + } + #endregion + #region Data Access Portal + internal SectionInfo(SafeDataReader dr) + { + try + { + _SectID = dr.GetInt32("SectID"); + _Number = dr.GetString("Number"); + _Title = dr.GetString("Title"); + _ContentType = dr.GetByte("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _Format = dr.GetString("Format"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + _ZSectioncount = dr.GetInt32("ZSectionCount"); + } + catch (Exception ex) + { + Database.LogException("SectionInfo.Constructor", ex); + throw new DbCslaException("SectionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/SectionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/SectionInfoList.cs new file mode 100644 index 00000000..63013190 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/SectionInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// SectionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class SectionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static SectionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static SectionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private SectionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getSections"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new SectionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("SectionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("SectionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Step.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Step.cs new file mode 100644 index 00000000..4592ed3b --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Step.cs @@ -0,0 +1,714 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Step Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Step : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextStepID = -1; + public static int NextStepID + { + get { return _nextStepID--; } + } + private int _StepID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + } + private string _StepType = string.Empty; + public string StepType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_StepType != value) + { + _StepType = value; + PropertyHasChanged(); + } + } + } + private int _TextMID; + public int TextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_TextMID != value) + { + _TextMID = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private StepStepTexts _StepStepTexts = StepStepTexts.New(); + /// + /// Related Field + /// + public StepStepTexts StepStepTexts + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepStepTexts; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _StepStepTexts.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _StepStepTexts.IsValid; } + } + // TODO: Replace base Step.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Step + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Step.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Step + protected override object GetIdValue() + { + return _StepID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("StepType", 2)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StepID, ""); + //AuthorizationRules.AllowRead(StepType, ""); + //AuthorizationRules.AllowRead(TextMID, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(StepType, ""); + //AuthorizationRules.AllowWrite(TextMID, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Step() + {/* require use of factory methods */} + public static Step New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Step"); + return DataPortal.Create(); + } + public static Step New(string stepType, int textMID, string config) + { + Step tmp = Step.New(); + tmp.StepType = stepType; + tmp.TextMID = textMID; + tmp.Config = config; + return tmp; + } + public static Step MakeStep(string stepType, int textMID, string config) + { + Step tmp = Step.New(stepType, textMID, config); + tmp.Save(); + return tmp; + } + public static Step MakeStep(string stepType, int textMID, string config, DateTime dts, string userID) + { + Step tmp = Step.New(stepType, textMID, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static Step Get(int stepID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Step"); + return DataPortal.Fetch(new PKCriteria(stepID)); + } + public static Step Get(SafeDataReader dr) + { + if (dr.Read()) return new Step(dr); + return null; + } + private Step(SafeDataReader dr) + { + _StepID = dr.GetInt32("StepID"); + _StepType = dr.GetString("StepType"); + _TextMID = dr.GetInt32("TextMID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int stepID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Step"); + DataPortal.Delete(new PKCriteria(stepID)); + } + public override Step Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Step"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Step"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Step"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _StepID; + public int StepID + { get { return _StepID; } } + public PKCriteria(int stepID) + { + _StepID = stepID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _StepID = NextStepID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStep"; + cm.Parameters.AddWithValue("@StepID", criteria.StepID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _StepID = dr.GetInt32("StepID"); + _StepType = dr.GetString("StepType"); + _TextMID = dr.GetInt32("TextMID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _StepStepTexts = StepStepTexts.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Step.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Step.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addStep"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepType", _StepType); + cm.Parameters.AddWithValue("@TextMID", _TextMID); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_StepID = new SqlParameter("@newStepID", SqlDbType.Int); + param_StepID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StepID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _StepID = (int)cm.Parameters["@newStepID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _StepStepTexts.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Step.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Step.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int stepID, string stepType, int textMID, string config, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addStep"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepType", stepType); + cm.Parameters.AddWithValue("@TextMID", textMID); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_StepID = new SqlParameter("@newStepID", SqlDbType.Int); + param_StepID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StepID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + stepID = (int)cm.Parameters["@newStepID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Step.Add", ex); + throw new DbCslaException("Step.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateStep"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@StepID", _StepID); + cm.Parameters.AddWithValue("@StepType", _StepType); + cm.Parameters.AddWithValue("@TextMID", _TextMID); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _StepStepTexts.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Step.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int stepID, string stepType, int textMID, string config, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateStep"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepID", stepID); + cm.Parameters.AddWithValue("@StepType", stepType); + cm.Parameters.AddWithValue("@TextMID", textMID); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Step.Update", ex); + throw new DbCslaException("Step.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_StepID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteStep"; + cm.Parameters.AddWithValue("@StepID", criteria.StepID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Step.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Step.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int stepID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteStep"; + // Input PK Fields + cm.Parameters.AddWithValue("@StepID", stepID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Step.Remove", ex); + throw new DbCslaException("Step.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int stepID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(stepID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _StepID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int stepID) + { + _StepID = stepID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsStep"; + cm.Parameters.AddWithValue("@StepID", _StepID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Step.DataPortal_Execute", ex); + throw new DbCslaException("Step.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create StepExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Step +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepInfo.cs new file mode 100644 index 00000000..3e7c9c00 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepInfo.cs @@ -0,0 +1,188 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepInfo : ReadOnlyBase + { + #region Business Methods + private int _StepID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + } + private string _StepType = string.Empty; + public string StepType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepType; + } + } + private int _TextMID; + public int TextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMID; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + private int _StepTextcount = 0; + /// + /// Count of StepText for this Step + /// + public int StepTextCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepTextcount; + } + } + private StepTextInfoList _StepTexts = null; + public StepTextInfoList StepTexts + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_StepTexts == null) + _StepTexts = StepTextInfoList.GetByStep(_StepID); + return _StepTexts; + } + } + private int _ZStepcount = 0; + /// + /// Count of ZStep for this Step + /// + public int ZStepCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ZStepcount; + } + } + private ZStepInfoList _ZSteps = null; + public ZStepInfoList ZSteps + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_ZSteps == null) + _ZSteps = ZStepInfoList.GetByStep(_StepID); + return _ZSteps; + } + } + // TODO: Replace base StepInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StepInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check StepInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StepInfo + protected override object GetIdValue() + { + return _StepID; + } + #endregion + #region Factory Methods + private StepInfo() + { /* require use of factory methods */ } + public Step Get() + { + return Step.Get(_StepID); + } + #endregion + #region Data Access Portal + internal StepInfo(SafeDataReader dr) + { + try + { + _StepID = dr.GetInt32("StepID"); + _StepType = dr.GetString("StepType"); + _TextMID = dr.GetInt32("TextMID"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + _StepTextcount = dr.GetInt32("StepTextCount"); + _ZStepcount = dr.GetInt32("ZStepCount"); + } + catch (Exception ex) + { + Database.LogException("StepInfo.Constructor", ex); + throw new DbCslaException("StepInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepInfoList.cs new file mode 100644 index 00000000..58638d22 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static StepInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static StepInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static StepInfoList GetByTextM(int textMID) + { + return DataPortal.Fetch(new TextMCriteria(textMID)); + } + private StepInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getSteps"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new StepInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("StepInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("StepInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class TextMCriteria + { + public TextMCriteria(int textMID) + { + _TextMID = textMID; + } + private int _TextMID; + public int TextMID + { + get { return _TextMID; } + set { _TextMID = value; } + } + } + private void DataPortal_Fetch(TextMCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStepsByTextM"; + cm.Parameters.AddWithValue("@TextMID", criteria.TextMID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new StepInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("StepInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("StepInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepStepText.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepStepText.cs new file mode 100644 index 00000000..1b43e43a --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepStepText.cs @@ -0,0 +1,358 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepStepText Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepStepText : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _StepTextMID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepTextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepTextMID; + } + } + private int _ItemType; + public int ItemType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ItemType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ItemType != value) + { + _ItemType = value; + PropertyHasChanged(); + } + } + } + private string _TextM = string.Empty; + public string TextM + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextM; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_TextM != value) + { + _TextM = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check StepStepText.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StepStepText + protected override object GetIdValue() + { + return _StepTextMID; + } + // TODO: Replace base StepStepText.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StepStepText + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "TextM"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("TextM", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + // TODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StepTextMID, ""); + //AuthorizationRules.AllowRead(ItemType, ""); + //AuthorizationRules.AllowWrite(ItemType, ""); + //AuthorizationRules.AllowRead(TextM, ""); + //AuthorizationRules.AllowWrite(TextM, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static StepStepText New(int itemType, string textM) + { + return new StepStepText(itemType, textM); + } + internal static StepStepText Get(SafeDataReader dr) + { + return new StepStepText(dr); + } + public StepStepText() + { + MarkAsChild(); + _StepTextMID = StepText.NextStepTextMID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + } + private StepStepText(int itemType, string textM) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + _ItemType = itemType; + _TextM = textM; + } + private StepStepText(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _StepTextMID = dr.GetInt32("StepTextMID"); + _ItemType = dr.GetInt32("ItemType"); + _TextM = dr.GetString("TextM"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("StepStepText.Fetch", ex); + throw new DbCslaException("StepStepText.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Step step, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = StepText.Add(cn, ref _StepTextMID, step.StepID, _ItemType, _TextM, _DTS, _UserID); + MarkOld(); + } + internal void Update(Step step, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = StepText.Update(cn, ref _StepTextMID, step.StepID, _ItemType, _TextM, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Step step, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + StepText.Remove(cn, _StepTextMID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create StepStepTextExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class StepStepText +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepStepTexts.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepStepTexts.cs new file mode 100644 index 00000000..a7ac6a6a --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepStepTexts.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepStepTexts Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepStepTexts : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new StepStepText this[int stepTextMID] + { + get + { + foreach (StepStepText stepText in this) + if (stepText.StepTextMID == stepTextMID) + return stepText; + return null; + } + } + public StepStepText GetItem(int stepTextMID) + { + foreach (StepStepText stepText in this) + if (stepText.StepTextMID == stepTextMID) + return stepText; + return null; + } + public StepStepText Add(int itemType, string textM) + { + StepStepText stepText = StepStepText.New(itemType, textM); + this.Add(stepText); + return stepText; + } + public void Remove(int stepTextMID) + { + foreach (StepStepText stepText in this) + { + if (stepText.StepTextMID == stepTextMID) + { + Remove(stepText); + break; + } + } + } + public bool Contains(int stepTextMID) + { + foreach (StepStepText stepText in this) + if (stepText.StepTextMID == stepTextMID) + return true; + return false; + } + public bool ContainsDeleted(int stepTextMID) + { + foreach (StepStepText stepText in DeletedList) + if (stepText.StepTextMID == stepTextMID) + return true; + return false; + } + #endregion + #region Factory Methods + internal static StepStepTexts New() + { + return new StepStepTexts(); + } + internal static StepStepTexts Get(SafeDataReader dr) + { + return new StepStepTexts(dr); + } + private StepStepTexts() + { + MarkAsChild(); + } + private StepStepTexts(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(StepStepText.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Step step, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (StepStepText obj in DeletedList) + obj.DeleteSelf(step, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (StepStepText obj in this) + { + if (obj.IsNew) + obj.Insert(step, cn); + else + obj.Update(step, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepText.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepText.cs new file mode 100644 index 00000000..7d6a8d74 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepText.cs @@ -0,0 +1,686 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepText Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepText : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextStepTextMID = -1; + public static int NextStepTextMID + { + get { return _nextStepTextMID--; } + } + private int _StepTextMID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepTextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepTextMID; + } + } + private int _StepID; + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_StepID != value) + { + _StepID = value; + PropertyHasChanged(); + } + } + } + private int _ItemType; + public int ItemType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ItemType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ItemType != value) + { + _ItemType = value; + PropertyHasChanged(); + } + } + } + private string _TextM = string.Empty; + public string TextM + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextM; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_TextM != value) + { + _TextM = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base StepText.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StepText + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check StepText.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StepText + protected override object GetIdValue() + { + return _StepTextMID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "TextM"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("TextM", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StepTextMID, ""); + //AuthorizationRules.AllowRead(StepID, ""); + //AuthorizationRules.AllowRead(ItemType, ""); + //AuthorizationRules.AllowRead(TextM, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(StepID, ""); + //AuthorizationRules.AllowWrite(ItemType, ""); + //AuthorizationRules.AllowWrite(TextM, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private StepText() + {/* require use of factory methods */} + public static StepText New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a StepText"); + return DataPortal.Create(); + } + public static StepText New(int stepID, int itemType, string textM) + { + StepText tmp = StepText.New(); + tmp.StepID = stepID; + tmp.ItemType = itemType; + tmp.TextM = textM; + return tmp; + } + public static StepText MakeStepText(int stepID, int itemType, string textM) + { + StepText tmp = StepText.New(stepID, itemType, textM); + tmp.Save(); + return tmp; + } + public static StepText MakeStepText(int stepID, int itemType, string textM, DateTime dts, string userID) + { + StepText tmp = StepText.New(stepID, itemType, textM); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static StepText Get(int stepTextMID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a StepText"); + return DataPortal.Fetch(new PKCriteria(stepTextMID)); + } + public static StepText Get(SafeDataReader dr) + { + if (dr.Read()) return new StepText(dr); + return null; + } + private StepText(SafeDataReader dr) + { + _StepTextMID = dr.GetInt32("StepTextMID"); + _StepID = dr.GetInt32("StepID"); + _ItemType = dr.GetInt32("ItemType"); + _TextM = dr.GetString("TextM"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int stepTextMID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a StepText"); + DataPortal.Delete(new PKCriteria(stepTextMID)); + } + public override StepText Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a StepText"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a StepText"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a StepText"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _StepTextMID; + public int StepTextMID + { get { return _StepTextMID; } } + public PKCriteria(int stepTextMID) + { + _StepTextMID = stepTextMID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _StepTextMID = NextStepTextMID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStepText"; + cm.Parameters.AddWithValue("@StepTextMID", criteria.StepTextMID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _StepTextMID = dr.GetInt32("StepTextMID"); + _StepID = dr.GetInt32("StepID"); + _ItemType = dr.GetInt32("ItemType"); + _TextM = dr.GetString("TextM"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("StepText.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("StepText.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addStepText"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepID", _StepID); + cm.Parameters.AddWithValue("@ItemType", _ItemType); + cm.Parameters.AddWithValue("@TextM", _TextM); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_StepTextMID = new SqlParameter("@newStepTextMID", SqlDbType.Int); + param_StepTextMID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StepTextMID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _StepTextMID = (int)cm.Parameters["@newStepTextMID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("StepText.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("StepText.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int stepTextMID, int stepID, int itemType, string textM, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addStepText"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepID", stepID); + cm.Parameters.AddWithValue("@ItemType", itemType); + cm.Parameters.AddWithValue("@TextM", textM); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_StepTextMID = new SqlParameter("@newStepTextMID", SqlDbType.Int); + param_StepTextMID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StepTextMID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + stepTextMID = (int)cm.Parameters["@newStepTextMID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("StepText.Add", ex); + throw new DbCslaException("StepText.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateStepText"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@StepTextMID", _StepTextMID); + cm.Parameters.AddWithValue("@StepID", _StepID); + cm.Parameters.AddWithValue("@ItemType", _ItemType); + cm.Parameters.AddWithValue("@TextM", _TextM); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("StepText.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int stepTextMID, int stepID, int itemType, string textM, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateStepText"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepTextMID", stepTextMID); + cm.Parameters.AddWithValue("@StepID", stepID); + cm.Parameters.AddWithValue("@ItemType", itemType); + cm.Parameters.AddWithValue("@TextM", textM); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("StepText.Update", ex); + throw new DbCslaException("StepText.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_StepTextMID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteStepText"; + cm.Parameters.AddWithValue("@StepTextMID", criteria.StepTextMID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("StepText.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("StepText.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int stepTextMID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteStepText"; + // Input PK Fields + cm.Parameters.AddWithValue("@StepTextMID", stepTextMID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("StepText.Remove", ex); + throw new DbCslaException("StepText.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int stepTextMID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(stepTextMID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _StepTextMID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int stepTextMID) + { + _StepTextMID = stepTextMID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsStepText"; + cm.Parameters.AddWithValue("@StepTextMID", _StepTextMID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("StepText.DataPortal_Execute", ex); + throw new DbCslaException("StepText.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create StepTextExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class StepText +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepTextInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepTextInfo.cs new file mode 100644 index 00000000..c0b61d4e --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepTextInfo.cs @@ -0,0 +1,136 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepTextInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepTextInfo : ReadOnlyBase + { + #region Business Methods + private int _StepTextMID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepTextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepTextMID; + } + } + private int _StepID; + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + } + private int _ItemType; + public int ItemType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ItemType; + } + } + private string _TextM = string.Empty; + public string TextM + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextM; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + // TODO: Replace base StepTextInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StepTextInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check StepTextInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StepTextInfo + protected override object GetIdValue() + { + return _StepTextMID; + } + #endregion + #region Factory Methods + private StepTextInfo() + { /* require use of factory methods */ } + public StepText Get() + { + return StepText.Get(_StepTextMID); + } + #endregion + #region Data Access Portal + internal StepTextInfo(SafeDataReader dr) + { + try + { + _StepTextMID = dr.GetInt32("StepTextMID"); + _StepID = dr.GetInt32("StepID"); + _ItemType = dr.GetInt32("ItemType"); + _TextM = dr.GetString("TextM"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + } + catch (Exception ex) + { + Database.LogException("StepTextInfo.Constructor", ex); + throw new DbCslaException("StepTextInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StepTextInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StepTextInfoList.cs new file mode 100644 index 00000000..1f6c4e41 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StepTextInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StepTextInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StepTextInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static StepTextInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static StepTextInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static StepTextInfoList GetByStep(int stepID) + { + return DataPortal.Fetch(new StepCriteria(stepID)); + } + private StepTextInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStepTexts"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new StepTextInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("StepTextInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("StepTextInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class StepCriteria + { + public StepCriteria(int stepID) + { + _StepID = stepID; + } + private int _StepID; + public int StepID + { + get { return _StepID; } + set { _StepID = value; } + } + } + private void DataPortal_Fetch(StepCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStepTextsByStep"; + cm.Parameters.AddWithValue("@StepID", criteria.StepID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new StepTextInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("StepTextInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("StepTextInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Structure.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Structure.cs new file mode 100644 index 00000000..7307b716 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Structure.cs @@ -0,0 +1,759 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Structure Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Structure : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextStructureID = -1; + public static int NextStructureID + { + get { return _nextStructureID--; } + } + private int _StructureID; + [System.ComponentModel.DataObjectField(true, true)] + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private int _FromType; + /// + /// 0 - Parent, 1 - Previous + /// + public int FromType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FromType != value) + { + _FromType = value; + PropertyHasChanged(); + } + } + } + private int _FromID; + public int FromID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FromID != value) + { + _FromID = value; + PropertyHasChanged(); + } + } + } + private int _ContentType; + /// + /// 0 - Structure, 1 - Procedure, 2 - Section, 3 - Step, 4 - Branch + /// + public int ContentType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ContentType != value) + { + _ContentType = value; + PropertyHasChanged(); + } + } + } + private int _ContentID; + public int ContentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ContentID != value) + { + _ContentID = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private StructureRoUsages _StructureRoUsages = StructureRoUsages.New(); + /// + /// Related Field + /// + public StructureRoUsages StructureRoUsages + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureRoUsages; + } + } + private StructureTransitions _StructureTransitions = StructureTransitions.New(); + /// + /// Related Field + /// + public StructureTransitions StructureTransitions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureTransitions; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _StructureRoUsages.IsDirty || _StructureTransitions.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _StructureRoUsages.IsValid && _StructureTransitions.IsValid; } + } + // TODO: Replace base Structure.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Structure + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Structure.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Structure + protected override object GetIdValue() + { + return _StructureID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StructureID, ""); + //AuthorizationRules.AllowRead(FromType, ""); + //AuthorizationRules.AllowRead(FromID, ""); + //AuthorizationRules.AllowRead(ContentType, ""); + //AuthorizationRules.AllowRead(ContentID, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(FromType, ""); + //AuthorizationRules.AllowWrite(FromID, ""); + //AuthorizationRules.AllowWrite(ContentType, ""); + //AuthorizationRules.AllowWrite(ContentID, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Structure() + {/* require use of factory methods */} + public static Structure New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Structure"); + return DataPortal.Create(); + } + public static Structure New(int fromType, int fromID, int contentType, int contentID) + { + Structure tmp = Structure.New(); + tmp.FromType = fromType; + tmp.FromID = fromID; + tmp.ContentType = contentType; + tmp.ContentID = contentID; + return tmp; + } + public static Structure MakeStructure(int fromType, int fromID, int contentType, int contentID) + { + Structure tmp = Structure.New(fromType, fromID, contentType, contentID); + tmp.Save(); + return tmp; + } + public static Structure MakeStructure(int fromType, int fromID, int contentType, int contentID, DateTime dts, string userID) + { + Structure tmp = Structure.New(fromType, fromID, contentType, contentID); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static Structure Get(int structureID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Structure"); + return DataPortal.Fetch(new PKCriteria(structureID)); + } + public static Structure Get(SafeDataReader dr) + { + if (dr.Read()) return new Structure(dr); + return null; + } + private Structure(SafeDataReader dr) + { + _StructureID = dr.GetInt32("StructureID"); + _FromType = dr.GetInt32("FromType"); + _FromID = dr.GetInt32("FromID"); + _ContentType = dr.GetInt32("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int structureID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Structure"); + DataPortal.Delete(new PKCriteria(structureID)); + } + public override Structure Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Structure"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Structure"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Structure"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _StructureID; + public int StructureID + { get { return _StructureID; } } + public PKCriteria(int structureID) + { + _StructureID = structureID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _StructureID = NextStructureID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStructure"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _StructureID = dr.GetInt32("StructureID"); + _FromType = dr.GetInt32("FromType"); + _FromID = dr.GetInt32("FromID"); + _ContentType = dr.GetInt32("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _StructureRoUsages = StructureRoUsages.Get(dr); + // load child objects + dr.NextResult(); + _StructureTransitions = StructureTransitions.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Structure.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Structure.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addStructure"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FromType", _FromType); + cm.Parameters.AddWithValue("@FromID", _FromID); + cm.Parameters.AddWithValue("@ContentType", _ContentType); + cm.Parameters.AddWithValue("@ContentID", _ContentID); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int); + param_StructureID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StructureID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _StructureID = (int)cm.Parameters["@newStructureID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _StructureRoUsages.Update(this, cn); + _StructureTransitions.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Structure.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Structure.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addStructure"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FromType", fromType); + cm.Parameters.AddWithValue("@FromID", fromID); + cm.Parameters.AddWithValue("@ContentType", contentType); + cm.Parameters.AddWithValue("@ContentID", contentID); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int); + param_StructureID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StructureID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + structureID = (int)cm.Parameters["@newStructureID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Structure.Add", ex); + throw new DbCslaException("Structure.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateStructure"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@FromType", _FromType); + cm.Parameters.AddWithValue("@FromID", _FromID); + cm.Parameters.AddWithValue("@ContentType", _ContentType); + cm.Parameters.AddWithValue("@ContentID", _ContentID); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _StructureRoUsages.Update(this, cn); + _StructureTransitions.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("Structure.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateStructure"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@FromType", fromType); + cm.Parameters.AddWithValue("@FromID", fromID); + cm.Parameters.AddWithValue("@ContentType", contentType); + cm.Parameters.AddWithValue("@ContentID", contentID); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Structure.Update", ex); + throw new DbCslaException("Structure.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_StructureID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteStructure"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Structure.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Structure.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int structureID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteStructure"; + // Input PK Fields + cm.Parameters.AddWithValue("@StructureID", structureID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Structure.Remove", ex); + throw new DbCslaException("Structure.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int structureID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(structureID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _StructureID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int structureID) + { + _StructureID = structureID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsStructure"; + cm.Parameters.AddWithValue("@StructureID", _StructureID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Structure.DataPortal_Execute", ex); + throw new DbCslaException("Structure.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create StructureExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Structure +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StructureInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StructureInfo.cs new file mode 100644 index 00000000..9ecf1b6e --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StructureInfo.cs @@ -0,0 +1,231 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StructureInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StructureInfo : ReadOnlyBase + { + #region Business Methods + private int _StructureID; + [System.ComponentModel.DataObjectField(true, true)] + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private int _FromType; + /// + /// 0 - Parent, 1 - Previous + /// + public int FromType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromType; + } + } + private int _FromID; + public int FromID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromID; + } + } + private int _ContentType; + /// + /// 0 - Structure, 1 - Procedure, 2 - Section, 3 - Step, 4 - Branch + /// + public int ContentType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentType; + } + } + private int _ContentID; + public int ContentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentID; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + private int _RoUsagecount = 0; + /// + /// Count of RoUsage for this Structure + /// + public int RoUsageCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _RoUsagecount; + } + } + private RoUsageInfoList _RoUsages = null; + public RoUsageInfoList RoUsages + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_RoUsages == null) + _RoUsages = RoUsageInfoList.GetByStructure(_StructureID); + return _RoUsages; + } + } + private int _Transitioncount = 0; + /// + /// Count of Transition for this Structure + /// + public int TransitionCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Transitioncount; + } + } + private TransitionInfoList _Transitions = null; + public TransitionInfoList Transitions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Transitions == null) + _Transitions = TransitionInfoList.GetByStructure(_StructureID); + return _Transitions; + } + } + private int _ZStructcount = 0; + /// + /// Count of ZStruct for this Structure + /// + public int ZStructCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ZStructcount; + } + } + private ZStructInfoList _ZStructs = null; + public ZStructInfoList ZStructs + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_ZStructs == null) + _ZStructs = ZStructInfoList.GetByStructure(_StructureID); + return _ZStructs; + } + } + // TODO: Replace base StructureInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StructureInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check StructureInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StructureInfo + protected override object GetIdValue() + { + return _StructureID; + } + #endregion + #region Factory Methods + private StructureInfo() + { /* require use of factory methods */ } + public Structure Get() + { + return Structure.Get(_StructureID); + } + #endregion + #region Data Access Portal + internal StructureInfo(SafeDataReader dr) + { + try + { + _StructureID = dr.GetInt32("StructureID"); + _FromType = dr.GetInt32("FromType"); + _FromID = dr.GetInt32("FromID"); + _ContentType = dr.GetInt32("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + _RoUsagecount = dr.GetInt32("RoUsageCount"); + _Transitioncount = dr.GetInt32("TransitionCount"); + _ZStructcount = dr.GetInt32("ZStructCount"); + } + catch (Exception ex) + { + Database.LogException("StructureInfo.Constructor", ex); + throw new DbCslaException("StructureInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StructureInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StructureInfoList.cs new file mode 100644 index 00000000..134ab376 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StructureInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StructureInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StructureInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static StructureInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static StructureInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private StructureInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getStructures"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new StructureInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("StructureInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("StructureInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StructureRoUsage.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StructureRoUsage.cs new file mode 100644 index 00000000..e830016f --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StructureRoUsage.cs @@ -0,0 +1,342 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StructureRoUsage Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StructureRoUsage : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _ROUsageId; + [System.ComponentModel.DataObjectField(true, true)] + public int ROUsageId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ROUsageId; + } + } + private string _ROID = string.Empty; + public string ROID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ROID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_ROID != value) + { + _ROID = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check StructureRoUsage.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StructureRoUsage + protected override object GetIdValue() + { + return _ROUsageId; + } + // TODO: Replace base StructureRoUsage.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StructureRoUsage + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "ROID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("ROID", 16)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + // TODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(ROUsageId, ""); + //AuthorizationRules.AllowRead(ROID, ""); + //AuthorizationRules.AllowWrite(ROID, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static StructureRoUsage New(string roid) + { + return new StructureRoUsage(roid); + } + internal static StructureRoUsage Get(SafeDataReader dr) + { + return new StructureRoUsage(dr); + } + public StructureRoUsage() + { + MarkAsChild(); + _ROUsageId = RoUsage.NextROUsageId; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + } + private StructureRoUsage(string roid) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + _ROID = roid; + } + private StructureRoUsage(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _ROUsageId = dr.GetInt32("ROUsageId"); + _ROID = dr.GetString("ROID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("StructureRoUsage.Fetch", ex); + throw new DbCslaException("StructureRoUsage.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Structure structure, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = RoUsage.Add(cn, ref _ROUsageId, structure.StructureID, _ROID, _DTS, _UserID); + MarkOld(); + } + internal void Update(Structure structure, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = RoUsage.Update(cn, ref _ROUsageId, structure.StructureID, _ROID, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Structure structure, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + RoUsage.Remove(cn, _ROUsageId); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultStructureID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create StructureRoUsageExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class StructureRoUsage +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultStructureID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StructureRoUsages.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StructureRoUsages.cs new file mode 100644 index 00000000..72a46939 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StructureRoUsages.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StructureRoUsages Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StructureRoUsages : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new StructureRoUsage this[int rOUsageId] + { + get + { + foreach (StructureRoUsage roUsage in this) + if (roUsage.ROUsageId == rOUsageId) + return roUsage; + return null; + } + } + public StructureRoUsage GetItem(int rOUsageId) + { + foreach (StructureRoUsage roUsage in this) + if (roUsage.ROUsageId == rOUsageId) + return roUsage; + return null; + } + public StructureRoUsage Add(string roid) + { + StructureRoUsage roUsage = StructureRoUsage.New(roid); + this.Add(roUsage); + return roUsage; + } + public void Remove(int rOUsageId) + { + foreach (StructureRoUsage roUsage in this) + { + if (roUsage.ROUsageId == rOUsageId) + { + Remove(roUsage); + break; + } + } + } + public bool Contains(int rOUsageId) + { + foreach (StructureRoUsage roUsage in this) + if (roUsage.ROUsageId == rOUsageId) + return true; + return false; + } + public bool ContainsDeleted(int rOUsageId) + { + foreach (StructureRoUsage roUsage in DeletedList) + if (roUsage.ROUsageId == rOUsageId) + return true; + return false; + } + #endregion + #region Factory Methods + internal static StructureRoUsages New() + { + return new StructureRoUsages(); + } + internal static StructureRoUsages Get(SafeDataReader dr) + { + return new StructureRoUsages(dr); + } + private StructureRoUsages() + { + MarkAsChild(); + } + private StructureRoUsages(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(StructureRoUsage.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Structure structure, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (StructureRoUsage obj in DeletedList) + obj.DeleteSelf(structure, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (StructureRoUsage obj in this) + { + if (obj.IsNew) + obj.Insert(structure, cn); + else + obj.Update(structure, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StructureTransition.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StructureTransition.cs new file mode 100644 index 00000000..4f02a6b8 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StructureTransition.cs @@ -0,0 +1,496 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StructureTransition Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StructureTransition : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _TransitionId; + [System.ComponentModel.DataObjectField(true, true)] + public int TransitionId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TransitionId; + } + } + private int _ToId; + /// + /// StructureID + /// + public int ToId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ToId; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ToId != value) + { + _ToId = value; + PropertyHasChanged(); + } + } + } + private int _TranType; + public int TranType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TranType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_TranType != value) + { + _TranType = value; + PropertyHasChanged(); + } + } + } + private int _SectID; + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_SectID != value) + { + _SectID = value; + PropertyHasChanged(); + } + } + } + private int _ProcID; + public int ProcID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ProcID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ProcID != value) + { + _ProcID = value; + PropertyHasChanged(); + } + } + } + private int _SetID; + public int SetID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SetID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_SetID != value) + { + _SetID = value; + PropertyHasChanged(); + } + } + } + private int _PlantID; + public int PlantID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PlantID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PlantID != value) + { + _PlantID = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check StructureTransition.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current StructureTransition + protected override object GetIdValue() + { + return _TransitionId; + } + // TODO: Replace base StructureTransition.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current StructureTransition + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + // TODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(TransitionId, ""); + //AuthorizationRules.AllowRead(ToId, ""); + //AuthorizationRules.AllowWrite(ToId, ""); + //AuthorizationRules.AllowRead(TranType, ""); + //AuthorizationRules.AllowWrite(TranType, ""); + //AuthorizationRules.AllowRead(SectID, ""); + //AuthorizationRules.AllowWrite(SectID, ""); + //AuthorizationRules.AllowRead(ProcID, ""); + //AuthorizationRules.AllowWrite(ProcID, ""); + //AuthorizationRules.AllowRead(SetID, ""); + //AuthorizationRules.AllowWrite(SetID, ""); + //AuthorizationRules.AllowRead(PlantID, ""); + //AuthorizationRules.AllowWrite(PlantID, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static StructureTransition New(int toId) + { + return new StructureTransition(toId); + } + internal static StructureTransition Get(SafeDataReader dr) + { + return new StructureTransition(dr); + } + public StructureTransition() + { + MarkAsChild(); + _TransitionId = Transition.NextTransitionId; + _TranType = ext.DefaultTranType; + _SectID = ext.DefaultSectID; + _ProcID = ext.DefaultProcID; + _SetID = ext.DefaultSetID; + _PlantID = ext.DefaultPlantID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + } + private StructureTransition(int toId) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _TranType = ext.DefaultTranType; + _SectID = ext.DefaultSectID; + _ProcID = ext.DefaultProcID; + _SetID = ext.DefaultSetID; + _PlantID = ext.DefaultPlantID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + _ToId = toId; + } + private StructureTransition(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _TransitionId = dr.GetInt32("TransitionId"); + _ToId = dr.GetInt32("ToId"); + _TranType = dr.GetInt32("TranType"); + _SectID = dr.GetInt32("SectID"); + _ProcID = dr.GetInt32("ProcID"); + _SetID = dr.GetInt32("SetID"); + _PlantID = dr.GetInt32("PlantID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("StructureTransition.Fetch", ex); + throw new DbCslaException("StructureTransition.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Structure structure, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Transition.Add(cn, ref _TransitionId, structure.StructureID, _ToId, _TranType, _SectID, _ProcID, _SetID, _PlantID, _DTS, _UserID); + MarkOld(); + } + internal void Update(Structure structure, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Transition.Update(cn, ref _TransitionId, structure.StructureID, _ToId, _TranType, _SectID, _ProcID, _SetID, _PlantID, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Structure structure, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Transition.Remove(cn, _TransitionId); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultTranType + { + get { return 0; } + } + public virtual int DefaultSectID + { + get { return 0; } + } + public virtual int DefaultProcID + { + get { return 0; } + } + public virtual int DefaultSetID + { + get { return 0; } + } + public virtual int DefaultPlantID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create StructureTransitionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class StructureTransition +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultTranType +// { +// get { return 0; } +// } +// public virtual int DefaultSectID +// { +// get { return 0; } +// } +// public virtual int DefaultProcID +// { +// get { return 0; } +// } +// public virtual int DefaultSetID +// { +// get { return 0; } +// } +// public virtual int DefaultPlantID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/StructureTransitions.cs b/PROMS/proms/Volian.CSLA.Library/Generated/StructureTransitions.cs new file mode 100644 index 00000000..da625fd0 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/StructureTransitions.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// StructureTransitions Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class StructureTransitions : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new StructureTransition this[int transitionId] + { + get + { + foreach (StructureTransition transition in this) + if (transition.TransitionId == transitionId) + return transition; + return null; + } + } + public StructureTransition GetItem(int transitionId) + { + foreach (StructureTransition transition in this) + if (transition.TransitionId == transitionId) + return transition; + return null; + } + public StructureTransition Add(int toId) + { + StructureTransition transition = StructureTransition.New(toId); + this.Add(transition); + return transition; + } + public void Remove(int transitionId) + { + foreach (StructureTransition transition in this) + { + if (transition.TransitionId == transitionId) + { + Remove(transition); + break; + } + } + } + public bool Contains(int transitionId) + { + foreach (StructureTransition transition in this) + if (transition.TransitionId == transitionId) + return true; + return false; + } + public bool ContainsDeleted(int transitionId) + { + foreach (StructureTransition transition in DeletedList) + if (transition.TransitionId == transitionId) + return true; + return false; + } + #endregion + #region Factory Methods + internal static StructureTransitions New() + { + return new StructureTransitions(); + } + internal static StructureTransitions Get(SafeDataReader dr) + { + return new StructureTransitions(dr); + } + private StructureTransitions() + { + MarkAsChild(); + } + private StructureTransitions(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(StructureTransition.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(Structure structure, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (StructureTransition obj in DeletedList) + obj.DeleteSelf(structure, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (StructureTransition obj in this) + { + if (obj.IsNew) + obj.Insert(structure, cn); + else + obj.Update(structure, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TextM.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TextM.cs new file mode 100644 index 00000000..951daee4 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TextM.cs @@ -0,0 +1,654 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TextM Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TextM : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextTextMID = -1; + public static int NextTextMID + { + get { return _nextTextMID--; } + } + private int _TextMID; + [System.ComponentModel.DataObjectField(true, true)] + public int TextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMID; + } + } + private string _TextMValue = string.Empty; + public string TextMValue + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMValue; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_TextMValue != value) + { + _TextMValue = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private TextMSteps _TextMSteps = TextMSteps.New(); + /// + /// Related Field + /// + public TextMSteps TextMSteps + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMSteps; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _TextMSteps.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _TextMSteps.IsValid; } + } + // TODO: Replace base TextM.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current TextM + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check TextM.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current TextM + protected override object GetIdValue() + { + return _TextMID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "TextMValue"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("TextMValue", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(TextMID, ""); + //AuthorizationRules.AllowRead(TextMValue, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(TextMValue, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private TextM() + {/* require use of factory methods */} + public static TextM New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a TextM"); + return DataPortal.Create(); + } + public static TextM New(string textMValue) + { + TextM tmp = TextM.New(); + tmp.TextMValue = textMValue; + return tmp; + } + public static TextM MakeTextM(string textMValue) + { + TextM tmp = TextM.New(textMValue); + tmp.Save(); + return tmp; + } + public static TextM MakeTextM(string textMValue, DateTime dts, string userID) + { + TextM tmp = TextM.New(textMValue); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static TextM Get(int textMID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a TextM"); + return DataPortal.Fetch(new PKCriteria(textMID)); + } + public static TextM Get(SafeDataReader dr) + { + if (dr.Read()) return new TextM(dr); + return null; + } + private TextM(SafeDataReader dr) + { + _TextMID = dr.GetInt32("TextMID"); + _TextMValue = dr.GetString("TextMValue"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int textMID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a TextM"); + DataPortal.Delete(new PKCriteria(textMID)); + } + public override TextM Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a TextM"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a TextM"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a TextM"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _TextMID; + public int TextMID + { get { return _TextMID; } } + public PKCriteria(int textMID) + { + _TextMID = textMID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _TextMID = NextTextMID; + // Database Defaults + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getTextM"; + cm.Parameters.AddWithValue("@TextMID", criteria.TextMID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _TextMID = dr.GetInt32("TextMID"); + _TextMValue = dr.GetString("TextMValue"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _TextMSteps = TextMSteps.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("TextM.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("TextM.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addTextM"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TextMValue", _TextMValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_TextMID = new SqlParameter("@newTextMID", SqlDbType.Int); + param_TextMID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_TextMID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _TextMID = (int)cm.Parameters["@newTextMID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _TextMSteps.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("TextM.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("TextM.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int textMID, string textMValue, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addTextM"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TextMValue", textMValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_TextMID = new SqlParameter("@newTextMID", SqlDbType.Int); + param_TextMID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_TextMID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + textMID = (int)cm.Parameters["@newTextMID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("TextM.Add", ex); + throw new DbCslaException("TextM.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateTextM"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@TextMID", _TextMID); + cm.Parameters.AddWithValue("@TextMValue", _TextMValue); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _TextMSteps.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("TextM.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int textMID, string textMValue, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateTextM"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TextMID", textMID); + cm.Parameters.AddWithValue("@TextMValue", textMValue); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("TextM.Update", ex); + throw new DbCslaException("TextM.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_TextMID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteTextM"; + cm.Parameters.AddWithValue("@TextMID", criteria.TextMID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("TextM.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("TextM.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int textMID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteTextM"; + // Input PK Fields + cm.Parameters.AddWithValue("@TextMID", textMID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("TextM.Remove", ex); + throw new DbCslaException("TextM.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int textMID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(textMID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _TextMID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int textMID) + { + _TextMID = textMID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsTextM"; + cm.Parameters.AddWithValue("@TextMID", _TextMID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("TextM.DataPortal_Execute", ex); + throw new DbCslaException("TextM.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create TextMExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class TextM +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TextMInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TextMInfo.cs new file mode 100644 index 00000000..8cc78134 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TextMInfo.cs @@ -0,0 +1,140 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TextMInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TextMInfo : ReadOnlyBase + { + #region Business Methods + private int _TextMID; + [System.ComponentModel.DataObjectField(true, true)] + public int TextMID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMID; + } + } + private string _TextMValue = string.Empty; + public string TextMValue + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TextMValue; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + private int _Stepcount = 0; + /// + /// Count of Step for this TextM + /// + public int StepCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Stepcount; + } + } + private StepInfoList _Steps = null; + public StepInfoList Steps + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Steps == null) + _Steps = StepInfoList.GetByTextM(_TextMID); + return _Steps; + } + } + // TODO: Replace base TextMInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current TextMInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check TextMInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current TextMInfo + protected override object GetIdValue() + { + return _TextMID; + } + #endregion + #region Factory Methods + private TextMInfo() + { /* require use of factory methods */ } + public TextM Get() + { + return TextM.Get(_TextMID); + } + #endregion + #region Data Access Portal + internal TextMInfo(SafeDataReader dr) + { + try + { + _TextMID = dr.GetInt32("TextMID"); + _TextMValue = dr.GetString("TextMValue"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + _Stepcount = dr.GetInt32("StepCount"); + } + catch (Exception ex) + { + Database.LogException("TextMInfo.Constructor", ex); + throw new DbCslaException("TextMInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TextMInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TextMInfoList.cs new file mode 100644 index 00000000..df8e67c5 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TextMInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TextMInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TextMInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static TextMInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static TextMInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private TextMInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getTextMs"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new TextMInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("TextMInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("TextMInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TextMStep.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TextMStep.cs new file mode 100644 index 00000000..e0b0d5d5 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TextMStep.cs @@ -0,0 +1,351 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TextMStep Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TextMStep : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _StepID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + } + private string _StepType = string.Empty; + public string StepType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_StepType != value) + { + _StepType = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Check TextMStep.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current TextMStep + protected override object GetIdValue() + { + return _StepID; + } + // TODO: Replace base TextMStep.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current TextMStep + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("StepType", 2)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + // TODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StepID, ""); + //AuthorizationRules.AllowRead(StepType, ""); + //AuthorizationRules.AllowWrite(StepType, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static TextMStep New() + { + return new TextMStep(); + } + internal static TextMStep Get(SafeDataReader dr) + { + return new TextMStep(dr); + } + public TextMStep() + { + MarkAsChild(); + _StepID = Step.NextStepID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + } + private TextMStep(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _StepID = dr.GetInt32("StepID"); + _StepType = dr.GetString("StepType"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("TextMStep.Fetch", ex); + throw new DbCslaException("TextMStep.Fetch", ex); + } + MarkOld(); + } + internal void Insert(TextM textM, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Step.Add(cn, ref _StepID, _StepType, textM.TextMID, _Config, _DTS, _UserID); + MarkOld(); + } + internal void Update(TextM textM, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Step.Update(cn, ref _StepID, _StepType, textM.TextMID, _Config, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(TextM textM, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Step.Remove(cn, _StepID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create TextMStepExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class TextMStep +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TextMSteps.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TextMSteps.cs new file mode 100644 index 00000000..7c993647 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TextMSteps.cs @@ -0,0 +1,137 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TextMSteps Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TextMSteps : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // One To Many + public new TextMStep this[int stepID] + { + get + { + foreach (TextMStep step in this) + if (step.StepID == stepID) + return step; + return null; + } + } + public TextMStep GetItem(int stepID) + { + foreach (TextMStep step in this) + if (step.StepID == stepID) + return step; + return null; + } + public TextMStep Add() + { + TextMStep step = TextMStep.New(); + this.Add(step); + return step; + } + public void Remove(int stepID) + { + foreach (TextMStep step in this) + { + if (step.StepID == stepID) + { + Remove(step); + break; + } + } + } + public bool Contains(int stepID) + { + foreach (TextMStep step in this) + if (step.StepID == stepID) + return true; + return false; + } + public bool ContainsDeleted(int stepID) + { + foreach (TextMStep step in DeletedList) + if (step.StepID == stepID) + return true; + return false; + } + #endregion + #region Factory Methods + internal static TextMSteps New() + { + return new TextMSteps(); + } + internal static TextMSteps Get(SafeDataReader dr) + { + return new TextMSteps(dr); + } + private TextMSteps() + { + MarkAsChild(); + } + private TextMSteps(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(TextMStep.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(TextM textM, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (TextMStep obj in DeletedList) + obj.DeleteSelf(textM, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (TextMStep obj in this) + { + if (obj.IsNew) + obj.Insert(textM, cn); + else + obj.Update(textM, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/Transition.cs b/PROMS/proms/Volian.CSLA.Library/Generated/Transition.cs new file mode 100644 index 00000000..80aed45f --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/Transition.cs @@ -0,0 +1,844 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// Transition Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class Transition : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextTransitionId = -1; + public static int NextTransitionId + { + get { return _nextTransitionId--; } + } + private int _TransitionId; + [System.ComponentModel.DataObjectField(true, true)] + public int TransitionId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TransitionId; + } + } + private int _FromId; + public int FromId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromId; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FromId != value) + { + _FromId = value; + PropertyHasChanged(); + } + } + } + private int _ToId; + /// + /// StructureID + /// + public int ToId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ToId; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ToId != value) + { + _ToId = value; + PropertyHasChanged(); + } + } + } + private int _TranType; + public int TranType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TranType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_TranType != value) + { + _TranType = value; + PropertyHasChanged(); + } + } + } + private int _SectID; + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_SectID != value) + { + _SectID = value; + PropertyHasChanged(); + } + } + } + private int _ProcID; + public int ProcID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ProcID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ProcID != value) + { + _ProcID = value; + PropertyHasChanged(); + } + } + } + private int _SetID; + public int SetID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SetID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_SetID != value) + { + _SetID = value; + PropertyHasChanged(); + } + } + } + private int _PlantID; + public int PlantID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PlantID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_PlantID != value) + { + _PlantID = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base Transition.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Transition + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check Transition.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Transition + protected override object GetIdValue() + { + return _TransitionId; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(TransitionId, ""); + //AuthorizationRules.AllowRead(FromId, ""); + //AuthorizationRules.AllowRead(ToId, ""); + //AuthorizationRules.AllowRead(TranType, ""); + //AuthorizationRules.AllowRead(SectID, ""); + //AuthorizationRules.AllowRead(ProcID, ""); + //AuthorizationRules.AllowRead(SetID, ""); + //AuthorizationRules.AllowRead(PlantID, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(FromId, ""); + //AuthorizationRules.AllowWrite(ToId, ""); + //AuthorizationRules.AllowWrite(TranType, ""); + //AuthorizationRules.AllowWrite(SectID, ""); + //AuthorizationRules.AllowWrite(ProcID, ""); + //AuthorizationRules.AllowWrite(SetID, ""); + //AuthorizationRules.AllowWrite(PlantID, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private Transition() + {/* require use of factory methods */} + public static Transition New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Transition"); + return DataPortal.Create(); + } + public static Transition New(int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID) + { + Transition tmp = Transition.New(); + tmp.FromId = fromId; + tmp.ToId = toId; + tmp.TranType = tranType; + tmp.SectID = sectID; + tmp.ProcID = procID; + tmp.SetID = setID; + tmp.PlantID = plantID; + return tmp; + } + public static Transition MakeTransition(int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID) + { + Transition tmp = Transition.New(fromId, toId, tranType, sectID, procID, setID, plantID); + tmp.Save(); + return tmp; + } + public static Transition MakeTransition(int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID, DateTime dts, string userID) + { + Transition tmp = Transition.New(fromId, toId, tranType, sectID, procID, setID, plantID); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (userID != null && userID != string.Empty) tmp.UserID = userID; + tmp.Save(); + return tmp; + } + public static Transition Get(int transitionId) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Transition"); + return DataPortal.Fetch(new PKCriteria(transitionId)); + } + public static Transition Get(SafeDataReader dr) + { + if (dr.Read()) return new Transition(dr); + return null; + } + private Transition(SafeDataReader dr) + { + _TransitionId = dr.GetInt32("TransitionId"); + _FromId = dr.GetInt32("FromId"); + _ToId = dr.GetInt32("ToId"); + _TranType = dr.GetInt32("TranType"); + _SectID = dr.GetInt32("SectID"); + _ProcID = dr.GetInt32("ProcID"); + _SetID = dr.GetInt32("SetID"); + _PlantID = dr.GetInt32("PlantID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int transitionId) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Transition"); + DataPortal.Delete(new PKCriteria(transitionId)); + } + public override Transition Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Transition"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Transition"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Transition"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _TransitionId; + public int TransitionId + { get { return _TransitionId; } } + public PKCriteria(int transitionId) + { + _TransitionId = transitionId; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _TransitionId = NextTransitionId; + // Database Defaults + _TranType = ext.DefaultTranType; + _SectID = ext.DefaultSectID; + _ProcID = ext.DefaultProcID; + _SetID = ext.DefaultSetID; + _PlantID = ext.DefaultPlantID; + _DTS = ext.DefaultDTS; + _UserID = ext.DefaultUserID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getTransition"; + cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _TransitionId = dr.GetInt32("TransitionId"); + _FromId = dr.GetInt32("FromId"); + _ToId = dr.GetInt32("ToId"); + _TranType = dr.GetInt32("TranType"); + _SectID = dr.GetInt32("SectID"); + _ProcID = dr.GetInt32("ProcID"); + _SetID = dr.GetInt32("SetID"); + _PlantID = dr.GetInt32("PlantID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("Transition.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Transition.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addTransition"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FromId", _FromId); + cm.Parameters.AddWithValue("@ToId", _ToId); + cm.Parameters.AddWithValue("@TranType", _TranType); + cm.Parameters.AddWithValue("@SectID", _SectID); + cm.Parameters.AddWithValue("@ProcID", _ProcID); + cm.Parameters.AddWithValue("@SetID", _SetID); + cm.Parameters.AddWithValue("@PlantID", _PlantID); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_TransitionId = new SqlParameter("@newTransitionId", SqlDbType.Int); + param_TransitionId.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_TransitionId); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _TransitionId = (int)cm.Parameters["@newTransitionId"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("Transition.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Transition.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int transitionId, int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID, DateTime dts, string userID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addTransition"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FromId", fromId); + cm.Parameters.AddWithValue("@ToId", toId); + cm.Parameters.AddWithValue("@TranType", tranType); + cm.Parameters.AddWithValue("@SectID", sectID); + cm.Parameters.AddWithValue("@ProcID", procID); + cm.Parameters.AddWithValue("@SetID", setID); + cm.Parameters.AddWithValue("@PlantID", plantID); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_TransitionId = new SqlParameter("@newTransitionId", SqlDbType.Int); + param_TransitionId.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_TransitionId); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + transitionId = (int)cm.Parameters["@newTransitionId"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Transition.Add", ex); + throw new DbCslaException("Transition.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateTransition"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@TransitionId", _TransitionId); + cm.Parameters.AddWithValue("@FromId", _FromId); + cm.Parameters.AddWithValue("@ToId", _ToId); + cm.Parameters.AddWithValue("@TranType", _TranType); + cm.Parameters.AddWithValue("@SectID", _SectID); + cm.Parameters.AddWithValue("@ProcID", _ProcID); + cm.Parameters.AddWithValue("@SetID", _SetID); + cm.Parameters.AddWithValue("@PlantID", _PlantID); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("Transition.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int transitionId, int fromId, int toId, int tranType, int sectID, int procID, int setID, int plantID, DateTime dts, string userID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateTransition"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TransitionId", transitionId); + cm.Parameters.AddWithValue("@FromId", fromId); + cm.Parameters.AddWithValue("@ToId", toId); + cm.Parameters.AddWithValue("@TranType", tranType); + cm.Parameters.AddWithValue("@SectID", sectID); + cm.Parameters.AddWithValue("@ProcID", procID); + cm.Parameters.AddWithValue("@SetID", setID); + cm.Parameters.AddWithValue("@PlantID", plantID); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("Transition.Update", ex); + throw new DbCslaException("Transition.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_TransitionId)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteTransition"; + cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("Transition.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("Transition.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int transitionId) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteTransition"; + // Input PK Fields + cm.Parameters.AddWithValue("@TransitionId", transitionId); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("Transition.Remove", ex); + throw new DbCslaException("Transition.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int transitionId) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(transitionId)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _TransitionId; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int transitionId) + { + _TransitionId = transitionId; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsTransition"; + cm.Parameters.AddWithValue("@TransitionId", _TransitionId); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("Transition.DataPortal_Execute", ex); + throw new DbCslaException("Transition.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual int DefaultTranType + { + get { return 0; } + } + public virtual int DefaultSectID + { + get { return 0; } + } + public virtual int DefaultProcID + { + get { return 0; } + } + public virtual int DefaultSetID + { + get { return 0; } + } + public virtual int DefaultPlantID + { + get { return 0; } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create TransitionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class Transition +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual int DefaultTranType +// { +// get { return 0; } +// } +// public virtual int DefaultSectID +// { +// get { return 0; } +// } +// public virtual int DefaultProcID +// { +// get { return 0; } +// } +// public virtual int DefaultSetID +// { +// get { return 0; } +// } +// public virtual int DefaultPlantID +// { +// get { return 0; } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TransitionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TransitionInfo.cs new file mode 100644 index 00000000..227ceb46 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TransitionInfo.cs @@ -0,0 +1,209 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TransitionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TransitionInfo : ReadOnlyBase + { + #region Business Methods + private int _TransitionId; + [System.ComponentModel.DataObjectField(true, true)] + public int TransitionId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TransitionId; + } + } + private int _FromId; + public int FromId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromId; + } + } + private int _ToId; + /// + /// StructureID + /// + public int ToId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ToId; + } + } + private int _TranType; + public int TranType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TranType; + } + } + private int _SectID; + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + } + private int _ProcID; + public int ProcID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ProcID; + } + } + private int _SetID; + public int SetID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SetID; + } + } + private int _PlantID; + public int PlantID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PlantID; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + private int _ZTransitioncount = 0; + /// + /// Count of ZTransition for this Transition + /// + public int ZTransitionCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ZTransitioncount; + } + } + private ZTransitionInfoList _ZTransitions = null; + public ZTransitionInfoList ZTransitions + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_ZTransitions == null) + _ZTransitions = ZTransitionInfoList.GetByTransition(_TransitionId); + return _ZTransitions; + } + } + // TODO: Replace base TransitionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current TransitionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check TransitionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current TransitionInfo + protected override object GetIdValue() + { + return _TransitionId; + } + #endregion + #region Factory Methods + private TransitionInfo() + { /* require use of factory methods */ } + public Transition Get() + { + return Transition.Get(_TransitionId); + } + #endregion + #region Data Access Portal + internal TransitionInfo(SafeDataReader dr) + { + try + { + _TransitionId = dr.GetInt32("TransitionId"); + _FromId = dr.GetInt32("FromId"); + _ToId = dr.GetInt32("ToId"); + _TranType = dr.GetInt32("TranType"); + _SectID = dr.GetInt32("SectID"); + _ProcID = dr.GetInt32("ProcID"); + _SetID = dr.GetInt32("SetID"); + _PlantID = dr.GetInt32("PlantID"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + _ZTransitioncount = dr.GetInt32("ZTransitionCount"); + } + catch (Exception ex) + { + Database.LogException("TransitionInfo.Constructor", ex); + throw new DbCslaException("TransitionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/TransitionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/TransitionInfoList.cs new file mode 100644 index 00000000..19033e59 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/TransitionInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// TransitionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class TransitionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static TransitionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static TransitionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static TransitionInfoList GetByStructure(int structureID) + { + return DataPortal.Fetch(new StructureCriteria(structureID)); + } + private TransitionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getTransitions"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new TransitionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("TransitionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class StructureCriteria + { + public StructureCriteria(int structureID) + { + _StructureID = structureID; + } + private int _StructureID; + public int StructureID + { + get { return _StructureID; } + set { _StructureID = value; } + } + } + private void DataPortal_Fetch(StructureCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getTransitionsByStructure"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new TransitionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("TransitionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("TransitionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/User.cs b/PROMS/proms/Volian.CSLA.Library/Generated/User.cs new file mode 100644 index 00000000..8200d62f --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/User.cs @@ -0,0 +1,993 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// User Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class User : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextUID = -1; + public static int NextUID + { + get { return _nextUID--; } + } + private int _UID; + [System.ComponentModel.DataObjectField(true, true)] + public int UID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UID; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private string _FirstName = string.Empty; + public string FirstName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FirstName; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_FirstName != value) + { + _FirstName = value; + PropertyHasChanged(); + } + } + } + private string _MiddleName = string.Empty; + public string MiddleName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _MiddleName; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_MiddleName != value) + { + _MiddleName = value; + PropertyHasChanged(); + } + } + } + private string _LastName = string.Empty; + public string LastName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _LastName; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_LastName != value) + { + _LastName = value; + PropertyHasChanged(); + } + } + } + private string _Suffix = string.Empty; + public string Suffix + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Suffix; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Suffix != value) + { + _Suffix = value; + PropertyHasChanged(); + } + } + } + private string _CourtesyTitle = string.Empty; + public string CourtesyTitle + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _CourtesyTitle; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_CourtesyTitle != value) + { + _CourtesyTitle = value; + PropertyHasChanged(); + } + } + } + private string _PhoneNumber = string.Empty; + public string PhoneNumber + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PhoneNumber; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_PhoneNumber != value) + { + _PhoneNumber = value; + PropertyHasChanged(); + } + } + } + private string _CFGName = string.Empty; + public string CFGName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _CFGName; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_CFGName != value) + { + _CFGName = value; + PropertyHasChanged(); + } + } + } + private string _UserLogin = string.Empty; + public string UserLogin + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserLogin; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserLogin != value) + { + _UserLogin = value; + PropertyHasChanged(); + } + } + } + private string _UserName = string.Empty; + public string UserName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserName; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UserName != value) + { + _UserName = value; + PropertyHasChanged(); + } + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Config != value) + { + _Config = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private UserMemberships _UserMemberships = UserMemberships.New(); + /// + /// Related Field + /// + public UserMemberships UserMemberships + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserMemberships; + } + } + public override bool IsDirty + { + get { return base.IsDirty || _UserMemberships.IsDirty; } + } + public override bool IsValid + { + get { return base.IsValid && _UserMemberships.IsValid; } + } + // TODO: Replace base User.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current User + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check User.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current User + protected override object GetIdValue() + { + return _UID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("FirstName", 50)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("MiddleName", 50)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("LastName", 50)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Suffix", 10)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("CourtesyTitle", 10)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("PhoneNumber", 30)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("CFGName", 8)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserLogin", 10)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserName", 32)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823)); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(UID, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowRead(FirstName, ""); + //AuthorizationRules.AllowRead(MiddleName, ""); + //AuthorizationRules.AllowRead(LastName, ""); + //AuthorizationRules.AllowRead(Suffix, ""); + //AuthorizationRules.AllowRead(CourtesyTitle, ""); + //AuthorizationRules.AllowRead(PhoneNumber, ""); + //AuthorizationRules.AllowRead(CFGName, ""); + //AuthorizationRules.AllowRead(UserLogin, ""); + //AuthorizationRules.AllowRead(UserName, ""); + //AuthorizationRules.AllowRead(Config, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + //AuthorizationRules.AllowWrite(FirstName, ""); + //AuthorizationRules.AllowWrite(MiddleName, ""); + //AuthorizationRules.AllowWrite(LastName, ""); + //AuthorizationRules.AllowWrite(Suffix, ""); + //AuthorizationRules.AllowWrite(CourtesyTitle, ""); + //AuthorizationRules.AllowWrite(PhoneNumber, ""); + //AuthorizationRules.AllowWrite(CFGName, ""); + //AuthorizationRules.AllowWrite(UserLogin, ""); + //AuthorizationRules.AllowWrite(UserName, ""); + //AuthorizationRules.AllowWrite(Config, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private User() + {/* require use of factory methods */} + public static User New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a User"); + return DataPortal.Create(); + } + public static User New(string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config) + { + User tmp = User.New(); + tmp.UserID = userID; + tmp.FirstName = firstName; + tmp.MiddleName = middleName; + tmp.LastName = lastName; + tmp.Suffix = suffix; + tmp.CourtesyTitle = courtesyTitle; + tmp.PhoneNumber = phoneNumber; + tmp.CFGName = cFGName; + tmp.UserLogin = userLogin; + tmp.UserName = userName; + tmp.Config = config; + return tmp; + } + public static User MakeUser(string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config) + { + User tmp = User.New(userID, firstName, middleName, lastName, suffix, courtesyTitle, phoneNumber, cFGName, userLogin, userName, config); + tmp.Save(); + return tmp; + } + public static User MakeUser(string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID) + { + User tmp = User.New(userID, firstName, middleName, lastName, suffix, courtesyTitle, phoneNumber, cFGName, userLogin, userName, config); + if (dts >= new DateTime(1753, 1, 1) && dts <= new DateTime(9999, 12, 31)) tmp.DTS = dts; + if (usrID != null && usrID != string.Empty) tmp.UsrID = usrID; + tmp.Save(); + return tmp; + } + public static User Get(int uid) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a User"); + return DataPortal.Fetch(new PKCriteria(uid)); + } + public static User Get(SafeDataReader dr) + { + if (dr.Read()) return new User(dr); + return null; + } + private User(SafeDataReader dr) + { + _UID = dr.GetInt32("UID"); + _UserID = dr.GetString("UserID"); + _FirstName = dr.GetString("FirstName"); + _MiddleName = dr.GetString("MiddleName"); + _LastName = dr.GetString("LastName"); + _Suffix = dr.GetString("Suffix"); + _CourtesyTitle = dr.GetString("CourtesyTitle"); + _PhoneNumber = dr.GetString("PhoneNumber"); + _CFGName = dr.GetString("CFGName"); + _UserLogin = dr.GetString("UserLogin"); + _UserName = dr.GetString("UserName"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int uid) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a User"); + DataPortal.Delete(new PKCriteria(uid)); + } + public override User Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a User"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a User"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a User"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _UID; + public int UID + { get { return _UID; } } + public PKCriteria(int uid) + { + _UID = uid; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _UID = NextUID; + // Database Defaults + _UserID = ext.DefaultUserID; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getUser"; + cm.Parameters.AddWithValue("@UID", criteria.UID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _UID = dr.GetInt32("UID"); + _UserID = dr.GetString("UserID"); + _FirstName = dr.GetString("FirstName"); + _MiddleName = dr.GetString("MiddleName"); + _LastName = dr.GetString("LastName"); + _Suffix = dr.GetString("Suffix"); + _CourtesyTitle = dr.GetString("CourtesyTitle"); + _PhoneNumber = dr.GetString("PhoneNumber"); + _CFGName = dr.GetString("CFGName"); + _UserLogin = dr.GetString("UserLogin"); + _UserName = dr.GetString("UserName"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + // load child objects + dr.NextResult(); + _UserMemberships = UserMemberships.Get(dr); + } + } + } + } + catch (Exception ex) + { + Database.LogException("User.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("User.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addUser"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@FirstName", _FirstName); + cm.Parameters.AddWithValue("@MiddleName", _MiddleName); + cm.Parameters.AddWithValue("@LastName", _LastName); + cm.Parameters.AddWithValue("@Suffix", _Suffix); + cm.Parameters.AddWithValue("@CourtesyTitle", _CourtesyTitle); + cm.Parameters.AddWithValue("@PhoneNumber", _PhoneNumber); + cm.Parameters.AddWithValue("@CFGName", _CFGName); + cm.Parameters.AddWithValue("@UserLogin", _UserLogin); + cm.Parameters.AddWithValue("@UserName", _UserName); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + // Output Calculated Columns + SqlParameter param_UID = new SqlParameter("@newUID", SqlDbType.Int); + param_UID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_UID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _UID = (int)cm.Parameters["@newUID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + _UserMemberships.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("User.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("User.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int uid, string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addUser"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@FirstName", firstName); + cm.Parameters.AddWithValue("@MiddleName", middleName); + cm.Parameters.AddWithValue("@LastName", lastName); + cm.Parameters.AddWithValue("@Suffix", suffix); + cm.Parameters.AddWithValue("@CourtesyTitle", courtesyTitle); + cm.Parameters.AddWithValue("@PhoneNumber", phoneNumber); + cm.Parameters.AddWithValue("@CFGName", cFGName); + cm.Parameters.AddWithValue("@UserLogin", userLogin); + cm.Parameters.AddWithValue("@UserName", userName); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + // Output Calculated Columns + SqlParameter param_UID = new SqlParameter("@newUID", SqlDbType.Int); + param_UID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_UID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + uid = (int)cm.Parameters["@newUID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("User.Add", ex); + throw new DbCslaException("User.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateUser"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@UID", _UID); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@FirstName", _FirstName); + cm.Parameters.AddWithValue("@MiddleName", _MiddleName); + cm.Parameters.AddWithValue("@LastName", _LastName); + cm.Parameters.AddWithValue("@Suffix", _Suffix); + cm.Parameters.AddWithValue("@CourtesyTitle", _CourtesyTitle); + cm.Parameters.AddWithValue("@PhoneNumber", _PhoneNumber); + cm.Parameters.AddWithValue("@CFGName", _CFGName); + cm.Parameters.AddWithValue("@UserLogin", _UserLogin); + cm.Parameters.AddWithValue("@UserName", _UserName); + cm.Parameters.AddWithValue("@Config", _Config); + cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UsrID", _UsrID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + _UserMemberships.Update(this, cn); + } + } + catch (Exception ex) + { + Database.LogException("User.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int uid, string userID, string firstName, string middleName, string lastName, string suffix, string courtesyTitle, string phoneNumber, string cFGName, string userLogin, string userName, string config, DateTime dts, string usrID, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateUser"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@UID", uid); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@FirstName", firstName); + cm.Parameters.AddWithValue("@MiddleName", middleName); + cm.Parameters.AddWithValue("@LastName", lastName); + cm.Parameters.AddWithValue("@Suffix", suffix); + cm.Parameters.AddWithValue("@CourtesyTitle", courtesyTitle); + cm.Parameters.AddWithValue("@PhoneNumber", phoneNumber); + cm.Parameters.AddWithValue("@CFGName", cFGName); + cm.Parameters.AddWithValue("@UserLogin", userLogin); + cm.Parameters.AddWithValue("@UserName", userName); + cm.Parameters.AddWithValue("@Config", config); + cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UsrID", usrID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("User.Update", ex); + throw new DbCslaException("User.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_UID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteUser"; + cm.Parameters.AddWithValue("@UID", criteria.UID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("User.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("User.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int uid) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteUser"; + // Input PK Fields + cm.Parameters.AddWithValue("@UID", uid); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("User.Remove", ex); + throw new DbCslaException("User.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int uid) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(uid)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _UID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int uid) + { + _UID = uid; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsUser"; + cm.Parameters.AddWithValue("@UID", _UID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("User.DataPortal_Execute", ex); + throw new DbCslaException("User.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create UserExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class User +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/UserInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/UserInfo.cs new file mode 100644 index 00000000..5c6ccc63 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/UserInfo.cs @@ -0,0 +1,250 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// UserInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class UserInfo : ReadOnlyBase + { + #region Business Methods + private int _UID; + [System.ComponentModel.DataObjectField(true, true)] + public int UID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UID; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserID; + } + } + private string _FirstName = string.Empty; + public string FirstName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FirstName; + } + } + private string _MiddleName = string.Empty; + public string MiddleName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _MiddleName; + } + } + private string _LastName = string.Empty; + public string LastName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _LastName; + } + } + private string _Suffix = string.Empty; + public string Suffix + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Suffix; + } + } + private string _CourtesyTitle = string.Empty; + public string CourtesyTitle + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _CourtesyTitle; + } + } + private string _PhoneNumber = string.Empty; + public string PhoneNumber + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PhoneNumber; + } + } + private string _CFGName = string.Empty; + public string CFGName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _CFGName; + } + } + private string _UserLogin = string.Empty; + public string UserLogin + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserLogin; + } + } + private string _UserName = string.Empty; + public string UserName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UserName; + } + } + private string _Config = string.Empty; + public string Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Config; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + } + private int _Membershipcount = 0; + /// + /// Count of Membership for this User + /// + public int MembershipCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Membershipcount; + } + } + private MembershipInfoList _Memberships = null; + public MembershipInfoList Memberships + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + if (_Memberships == null) + _Memberships = MembershipInfoList.GetByUser(_UID); + return _Memberships; + } + } + // TODO: Replace base UserInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current UserInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check UserInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current UserInfo + protected override object GetIdValue() + { + return _UID; + } + #endregion + #region Factory Methods + private UserInfo() + { /* require use of factory methods */ } + public User Get() + { + return User.Get(_UID); + } + #endregion + #region Data Access Portal + internal UserInfo(SafeDataReader dr) + { + try + { + _UID = dr.GetInt32("UID"); + _UserID = dr.GetString("UserID"); + _FirstName = dr.GetString("FirstName"); + _MiddleName = dr.GetString("MiddleName"); + _LastName = dr.GetString("LastName"); + _Suffix = dr.GetString("Suffix"); + _CourtesyTitle = dr.GetString("CourtesyTitle"); + _PhoneNumber = dr.GetString("PhoneNumber"); + _CFGName = dr.GetString("CFGName"); + _UserLogin = dr.GetString("UserLogin"); + _UserName = dr.GetString("UserName"); + _Config = dr.GetString("Config"); + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + _Membershipcount = dr.GetInt32("MembershipCount"); + } + catch (Exception ex) + { + Database.LogException("UserInfo.Constructor", ex); + throw new DbCslaException("UserInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/UserInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/UserInfoList.cs new file mode 100644 index 00000000..ee8845f3 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/UserInfoList.cs @@ -0,0 +1,76 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// UserInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class UserInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static UserInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static UserInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + private UserInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getUsers"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new UserInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("UserInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("UserInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/UserMembership.cs b/PROMS/proms/Volian.CSLA.Library/Generated/UserMembership.cs new file mode 100644 index 00000000..e3b85b4d --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/UserMembership.cs @@ -0,0 +1,494 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// UserMembership Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class UserMembership : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _UGID; + [System.ComponentModel.DataObjectField(true, true)] + public int UGID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UGID; + } + } + private int _GID; + public int GID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _GID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_GID != value) + { + _GID = value; + PropertyHasChanged(); + } + } + } + private string _StartDate = string.Empty; + public string StartDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StartDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _StartDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_StartDate != tmp.ToString()) + { + _StartDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private string _EndDate = string.Empty; + public string EndDate + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _EndDate; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + _EndDate = value; + try + { + SmartDate tmp = new SmartDate(value); + if (_EndDate != tmp.ToString()) + { + _EndDate = tmp.ToString(); + // TODO: Any Cross Property Validation + } + } + catch + { + } + PropertyHasChanged(); + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UsrID = string.Empty; + public string UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _UsrID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_UsrID != value) + { + _UsrID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + private string _Group_GroupName = string.Empty; + public string Group_GroupName + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_GroupName; + } + } + private int _Group_GroupType; + public int Group_GroupType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_GroupType; + } + } + private string _Group_Config = string.Empty; + public string Group_Config + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_Config; + } + } + private DateTime _Group_DTS = new DateTime(); + public DateTime Group_DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_DTS; + } + } + private string _Group_UsrID = string.Empty; + public string Group_UsrID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Group_UsrID; + } + } + // TODO: Check UserMembership.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current UserMembership + protected override object GetIdValue() + { + return _UGID; + } + // TODO: Replace base UserMembership.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current UserMembership + //public override string ToString() + //{ + // return base.ToString(); + //} + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "StartDate"); + ValidationRules.AddRule(StartDateValid, "StartDate"); + ValidationRules.AddRule(EndDateValid, "EndDate"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UsrID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UsrID", 100)); + // TODO: Add other validation rules + } + private bool StartDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_StartDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + private bool EndDateValid(object target, Csla.Validation.RuleArgs e) + { + try + { + DateTime tmp = SmartDate.StringToDate(_EndDate); + } + catch + { + e.Description = "Invalid Date"; + return false; + } + return true; + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(UGID, ""); + //AuthorizationRules.AllowRead(GID, ""); + //AuthorizationRules.AllowWrite(GID, ""); + //AuthorizationRules.AllowRead(StartDate, ""); + //AuthorizationRules.AllowWrite(StartDate, ""); + //AuthorizationRules.AllowRead(EndDate, ""); + //AuthorizationRules.AllowWrite(EndDate, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UsrID, ""); + //AuthorizationRules.AllowWrite(UsrID, ""); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + internal static UserMembership New(int gid) + { + return new UserMembership(Volian.CSLA.Library.Group.Get(gid)); + } + internal static UserMembership Get(SafeDataReader dr) + { + return new UserMembership(dr); + } + public UserMembership() + { + MarkAsChild(); + _UGID = Membership.NextUGID; + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + } + private UserMembership(Group group) + { + MarkAsChild(); + // TODO: Add any initialization & defaults + _StartDate = ext.DefaultStartDate; + _DTS = ext.DefaultDTS; + _UsrID = ext.DefaultUsrID; + _GID = group.GID; + _Group_GroupName = group.GroupName; + _Group_GroupType = group.GroupType; + _Group_Config = group.Config; + _Group_DTS = group.DTS; + _Group_UsrID = group.UsrID; + } + private UserMembership(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + try + { + _UGID = dr.GetInt32("UGID"); + _GID = dr.GetInt32("GID"); + _StartDate = dr.GetSmartDate("StartDate").Text; + _EndDate = dr.GetSmartDate("EndDate").Text; + _DTS = dr.GetDateTime("DTS"); + _UsrID = dr.GetString("UsrID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + _Group_GroupName = dr.GetString("Group_GroupName"); + _Group_GroupType = dr.GetInt32("Group_GroupType"); + _Group_Config = dr.GetString("Group_Config"); + _Group_DTS = dr.GetDateTime("Group_DTS"); + _Group_UsrID = dr.GetString("Group_UsrID"); + } + catch (Exception ex) // FKItem Fetch + { + Database.LogException("UserMembership.Fetch", ex); + throw new DbCslaException("UserMembership.Fetch", ex); + } + MarkOld(); + } + internal void Insert(User user, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Membership.Add(cn, ref _UGID, user.UID, _GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID); + MarkOld(); + } + internal void Update(User user, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + _LastChanged = Membership.Update(cn, ref _UGID, user.UID, _GID, new SmartDate(_StartDate), new SmartDate(_EndDate), _DTS, _UsrID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(User user, SqlConnection cn) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + Membership.Remove(cn, _UGID); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual string DefaultStartDate + { + get { return DateTime.Now.ToShortDateString(); } + } + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUsrID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create UserMembershipExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class UserMembership +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public virtual SmartDate DefaultStartDate +// { +// get { return DateTime.Now.ToShortDateString(); } +// } +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUsrID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/UserMemberships.cs b/PROMS/proms/Volian.CSLA.Library/Generated/UserMemberships.cs new file mode 100644 index 00000000..8d383343 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/UserMemberships.cs @@ -0,0 +1,142 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// UserMemberships Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class UserMemberships : BusinessListBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + // Many To Many + public new UserMembership this[int gid] + { + get + { + foreach (UserMembership membership in this) + if (membership.GID == gid) + return membership; + return null; + } + } + public UserMembership GetItem(int gid) + { + foreach (UserMembership membership in this) + if (membership.GID == gid) + return membership; + return null; + } + public UserMembership Add(int gid) + { + if (!Contains(gid)) + { + UserMembership membership = UserMembership.New(gid); + this.Add(membership); + return membership; + } + else + throw new InvalidOperationException("membership already exists"); + } + public void Remove(int gid) + { + foreach (UserMembership membership in this) + { + if (membership.GID == gid) + { + Remove(membership); + break; + } + } + } + public bool Contains(int gid) + { + foreach (UserMembership membership in this) + if (membership.GID == gid) + return true; + return false; + } + public bool ContainsDeleted(int gid) + { + foreach (UserMembership membership in DeletedList) + if (membership.GID == gid) + return true; + return false; + } + #endregion + #region Factory Methods + internal static UserMemberships New() + { + return new UserMemberships(); + } + internal static UserMemberships Get(SafeDataReader dr) + { + return new UserMemberships(dr); + } + private UserMemberships() + { + MarkAsChild(); + } + private UserMemberships(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(UserMembership.Get(dr)); + this.RaiseListChangedEvents = true; + } + internal void Update(User user, SqlConnection cn) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (UserMembership obj in DeletedList) + obj.DeleteSelf(user, cn); + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (UserMembership obj in this) + { + if (obj.IsNew) + obj.Insert(user, cn); + else + obj.Update(user, cn); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZSection.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZSection.cs new file mode 100644 index 00000000..01aa8c0c --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZSection.cs @@ -0,0 +1,531 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZSection Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZSection : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _SectID; + [System.ComponentModel.DataObjectField(true, true)] + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + } + private string _OldStepSequence = string.Empty; + public string OldStepSequence + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _OldStepSequence; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_OldStepSequence != value) + { + _OldStepSequence = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base ZSection.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZSection + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZSection.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZSection + protected override object GetIdValue() + { + return _SectID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "OldStepSequence"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("OldStepSequence", 14)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(SectID, ""); + //AuthorizationRules.AllowRead(OldStepSequence, ""); + //AuthorizationRules.AllowWrite(OldStepSequence, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private ZSection() + {/* require use of factory methods */} + public static ZSection New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZSection"); + return DataPortal.Create(); + } + public static ZSection New(int sectID, string oldStepSequence) + { + ZSection tmp = ZSection.New(); + tmp._SectID = sectID; + tmp.OldStepSequence = oldStepSequence; + return tmp; + } + public static ZSection MakeZSection(int sectID, string oldStepSequence) + { + ZSection tmp = ZSection.New(sectID, oldStepSequence); + tmp.Save(); + return tmp; + } + public static ZSection Get(int sectID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a ZSection"); + return DataPortal.Fetch(new PKCriteria(sectID)); + } + public static ZSection Get(SafeDataReader dr) + { + if (dr.Read()) return new ZSection(dr); + return null; + } + private ZSection(SafeDataReader dr) + { + _SectID = dr.GetInt32("SectID"); + _OldStepSequence = dr.GetString("OldStepSequence"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int sectID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZSection"); + DataPortal.Delete(new PKCriteria(sectID)); + } + public override ZSection Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZSection"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZSection"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a ZSection"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _SectID; + public int SectID + { get { return _SectID; } } + public PKCriteria(int sectID) + { + _SectID = sectID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + + // Database Defaults + + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZSection"; + cm.Parameters.AddWithValue("@SectID", criteria.SectID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _SectID = dr.GetInt32("SectID"); + _OldStepSequence = dr.GetString("OldStepSequence"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZSection.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZSection.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZSection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@SectID", _SectID); + cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZSection.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZSection.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, int sectID, string oldStepSequence) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZSection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@SectID", sectID); + cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZSection.Add", ex); + throw new DbCslaException("ZSection.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZSection"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@SectID", _SectID); + cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZSection.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, int sectID, string oldStepSequence, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZSection"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@SectID", sectID); + cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZSection.Update", ex); + throw new DbCslaException("ZSection.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_SectID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZSection"; + cm.Parameters.AddWithValue("@SectID", criteria.SectID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("ZSection.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZSection.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int sectID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZSection"; + // Input PK Fields + cm.Parameters.AddWithValue("@SectID", sectID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("ZSection.Remove", ex); + throw new DbCslaException("ZSection.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int sectID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(sectID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _SectID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int sectID) + { + _SectID = sectID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsZSection"; + cm.Parameters.AddWithValue("@SectID", _SectID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("ZSection.DataPortal_Execute", ex); + throw new DbCslaException("ZSection.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ZSectionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class ZSection +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZSectionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZSectionInfo.cs new file mode 100644 index 00000000..41f12f4b --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZSectionInfo.cs @@ -0,0 +1,92 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZSectionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZSectionInfo : ReadOnlyBase + { + #region Business Methods + private int _SectID; + [System.ComponentModel.DataObjectField(true, true)] + public int SectID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _SectID; + } + } + private string _OldStepSequence = string.Empty; + public string OldStepSequence + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _OldStepSequence; + } + } + // TODO: Replace base ZSectionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZSectionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZSectionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZSectionInfo + protected override object GetIdValue() + { + return _SectID; + } + #endregion + #region Factory Methods + private ZSectionInfo() + { /* require use of factory methods */ } + public ZSection Get() + { + return ZSection.Get(_SectID); + } + #endregion + #region Data Access Portal + internal ZSectionInfo(SafeDataReader dr) + { + try + { + _SectID = dr.GetInt32("SectID"); + _OldStepSequence = dr.GetString("OldStepSequence"); + } + catch (Exception ex) + { + Database.LogException("ZSectionInfo.Constructor", ex); + throw new DbCslaException("ZSectionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZSectionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZSectionInfoList.cs new file mode 100644 index 00000000..34bf7dfa --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZSectionInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZSectionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZSectionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static ZSectionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static ZSectionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static ZSectionInfoList GetBySection(int sectID) + { + return DataPortal.Fetch(new SectionCriteria(sectID)); + } + private ZSectionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZSections"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZSectionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZSectionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZSectionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class SectionCriteria + { + public SectionCriteria(int sectID) + { + _SectID = sectID; + } + private int _SectID; + public int SectID + { + get { return _SectID; } + set { _SectID = value; } + } + } + private void DataPortal_Fetch(SectionCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZSectionsBySection"; + cm.Parameters.AddWithValue("@SectID", criteria.SectID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZSectionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZSectionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZSectionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZStep.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZStep.cs new file mode 100644 index 00000000..5ef8ccb2 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZStep.cs @@ -0,0 +1,531 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZStep Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZStep : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _StepID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + } + private string _OldStepSequence = string.Empty; + public string OldStepSequence + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _OldStepSequence; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_OldStepSequence != value) + { + _OldStepSequence = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base ZStep.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZStep + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZStep.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZStep + protected override object GetIdValue() + { + return _StepID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "OldStepSequence"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("OldStepSequence", 12)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StepID, ""); + //AuthorizationRules.AllowRead(OldStepSequence, ""); + //AuthorizationRules.AllowWrite(OldStepSequence, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private ZStep() + {/* require use of factory methods */} + public static ZStep New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZStep"); + return DataPortal.Create(); + } + public static ZStep New(int stepID, string oldStepSequence) + { + ZStep tmp = ZStep.New(); + tmp._StepID = stepID; + tmp.OldStepSequence = oldStepSequence; + return tmp; + } + public static ZStep MakeZStep(int stepID, string oldStepSequence) + { + ZStep tmp = ZStep.New(stepID, oldStepSequence); + tmp.Save(); + return tmp; + } + public static ZStep Get(int stepID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a ZStep"); + return DataPortal.Fetch(new PKCriteria(stepID)); + } + public static ZStep Get(SafeDataReader dr) + { + if (dr.Read()) return new ZStep(dr); + return null; + } + private ZStep(SafeDataReader dr) + { + _StepID = dr.GetInt32("StepID"); + _OldStepSequence = dr.GetString("OldStepSequence"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int stepID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZStep"); + DataPortal.Delete(new PKCriteria(stepID)); + } + public override ZStep Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZStep"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZStep"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a ZStep"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _StepID; + public int StepID + { get { return _StepID; } } + public PKCriteria(int stepID) + { + _StepID = stepID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + + // Database Defaults + + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZStep"; + cm.Parameters.AddWithValue("@StepID", criteria.StepID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _StepID = dr.GetInt32("StepID"); + _OldStepSequence = dr.GetString("OldStepSequence"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZStep.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZStep.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZStep"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepID", _StepID); + cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZStep.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZStep.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, int stepID, string oldStepSequence) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZStep"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepID", stepID); + cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZStep.Add", ex); + throw new DbCslaException("ZStep.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZStep"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@StepID", _StepID); + cm.Parameters.AddWithValue("@OldStepSequence", _OldStepSequence); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZStep.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, int stepID, string oldStepSequence, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZStep"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StepID", stepID); + cm.Parameters.AddWithValue("@OldStepSequence", oldStepSequence); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZStep.Update", ex); + throw new DbCslaException("ZStep.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_StepID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZStep"; + cm.Parameters.AddWithValue("@StepID", criteria.StepID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("ZStep.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZStep.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int stepID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZStep"; + // Input PK Fields + cm.Parameters.AddWithValue("@StepID", stepID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("ZStep.Remove", ex); + throw new DbCslaException("ZStep.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int stepID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(stepID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _StepID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int stepID) + { + _StepID = stepID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsZStep"; + cm.Parameters.AddWithValue("@StepID", _StepID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("ZStep.DataPortal_Execute", ex); + throw new DbCslaException("ZStep.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ZStepExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class ZStep +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZStepInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZStepInfo.cs new file mode 100644 index 00000000..9a7d837b --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZStepInfo.cs @@ -0,0 +1,92 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZStepInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZStepInfo : ReadOnlyBase + { + #region Business Methods + private int _StepID; + [System.ComponentModel.DataObjectField(true, true)] + public int StepID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StepID; + } + } + private string _OldStepSequence = string.Empty; + public string OldStepSequence + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _OldStepSequence; + } + } + // TODO: Replace base ZStepInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZStepInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZStepInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZStepInfo + protected override object GetIdValue() + { + return _StepID; + } + #endregion + #region Factory Methods + private ZStepInfo() + { /* require use of factory methods */ } + public ZStep Get() + { + return ZStep.Get(_StepID); + } + #endregion + #region Data Access Portal + internal ZStepInfo(SafeDataReader dr) + { + try + { + _StepID = dr.GetInt32("StepID"); + _OldStepSequence = dr.GetString("OldStepSequence"); + } + catch (Exception ex) + { + Database.LogException("ZStepInfo.Constructor", ex); + throw new DbCslaException("ZStepInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZStepInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZStepInfoList.cs new file mode 100644 index 00000000..ff4fe337 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZStepInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZStepInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZStepInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static ZStepInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static ZStepInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static ZStepInfoList GetByStep(int stepID) + { + return DataPortal.Fetch(new StepCriteria(stepID)); + } + private ZStepInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZSteps"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZStepInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZStepInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZStepInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class StepCriteria + { + public StepCriteria(int stepID) + { + _StepID = stepID; + } + private int _StepID; + public int StepID + { + get { return _StepID; } + set { _StepID = value; } + } + } + private void DataPortal_Fetch(StepCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZStepsByStep"; + cm.Parameters.AddWithValue("@StepID", criteria.StepID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZStepInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZStepInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZStepInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZStruct.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZStruct.cs new file mode 100644 index 00000000..81ebfcd3 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZStruct.cs @@ -0,0 +1,740 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZStruct Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZStruct : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private static int _nextStructureID = -1; + public static int NextStructureID + { + get { return _nextStructureID--; } + } + private int _StructureID; + [System.ComponentModel.DataObjectField(true, true)] + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private int _FromType; + public int FromType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FromType != value) + { + _FromType = value; + PropertyHasChanged(); + } + } + } + private int _FromID; + public int FromID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_FromID != value) + { + _FromID = value; + PropertyHasChanged(); + } + } + } + private int _ContentType; + public int ContentType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentType; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ContentType != value) + { + _ContentType = value; + PropertyHasChanged(); + } + } + } + private int _ContentID; + public int ContentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_ContentID != value) + { + _ContentID = value; + PropertyHasChanged(); + } + } + } + private int _Level; + public int Level + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Level; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_Level != value) + { + _Level = value; + PropertyHasChanged(); + } + } + } + private int _Item; + public int Item + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Item; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (_Item != value) + { + _Item = value; + PropertyHasChanged(); + } + } + } + private string _PPath = string.Empty; + public string PPath + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PPath; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_PPath != value) + { + _PPath = value; + PropertyHasChanged(); + } + } + } + private string _Path = string.Empty; + public string Path + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Path; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Path != value) + { + _Path = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base ZStruct.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZStruct + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZStruct.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZStruct + protected override object GetIdValue() + { + return _StructureID; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(StructureID, ""); + //AuthorizationRules.AllowRead(FromType, ""); + //AuthorizationRules.AllowRead(FromID, ""); + //AuthorizationRules.AllowRead(ContentType, ""); + //AuthorizationRules.AllowRead(ContentID, ""); + //AuthorizationRules.AllowRead(Level, ""); + //AuthorizationRules.AllowRead(Item, ""); + //AuthorizationRules.AllowRead(PPath, ""); + //AuthorizationRules.AllowRead(Path, ""); + //AuthorizationRules.AllowWrite(FromType, ""); + //AuthorizationRules.AllowWrite(FromID, ""); + //AuthorizationRules.AllowWrite(ContentType, ""); + //AuthorizationRules.AllowWrite(ContentID, ""); + //AuthorizationRules.AllowWrite(Level, ""); + //AuthorizationRules.AllowWrite(Item, ""); + //AuthorizationRules.AllowWrite(PPath, ""); + //AuthorizationRules.AllowWrite(Path, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private ZStruct() + {/* require use of factory methods */} + public static ZStruct New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZStruct"); + return DataPortal.Create(); + } + public static ZStruct New(int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path) + { + ZStruct tmp = ZStruct.New(); + tmp.FromType = fromType; + tmp.FromID = fromID; + tmp.ContentType = contentType; + tmp.ContentID = contentID; + tmp.Level = level; + tmp.Item = item; + tmp.PPath = pPath; + tmp.Path = path; + return tmp; + } + public static ZStruct MakeZStruct(int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path) + { + ZStruct tmp = ZStruct.New(fromType, fromID, contentType, contentID, level, item, pPath, path); + tmp.Save(); + return tmp; + } + public static ZStruct Get(int structureID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a ZStruct"); + return DataPortal.Fetch(new PKCriteria(structureID)); + } + public static ZStruct Get(SafeDataReader dr) + { + if (dr.Read()) return new ZStruct(dr); + return null; + } + private ZStruct(SafeDataReader dr) + { + _StructureID = dr.GetInt32("StructureID"); + _FromType = dr.GetInt32("FromType"); + _FromID = dr.GetInt32("FromID"); + _ContentType = dr.GetInt32("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _Level = dr.GetInt32("Level"); + _Item = dr.GetInt32("Item"); + _PPath = dr.GetString("PPath"); + _Path = dr.GetString("Path"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int structureID) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZStruct"); + DataPortal.Delete(new PKCriteria(structureID)); + } + public override ZStruct Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZStruct"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZStruct"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a ZStruct"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _StructureID; + public int StructureID + { get { return _StructureID; } } + public PKCriteria(int structureID) + { + _StructureID = structureID; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + _StructureID = NextStructureID; + // Database Defaults + + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZStruct"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _StructureID = dr.GetInt32("StructureID"); + _FromType = dr.GetInt32("FromType"); + _FromID = dr.GetInt32("FromID"); + _ContentType = dr.GetInt32("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _Level = dr.GetInt32("Level"); + _Item = dr.GetInt32("Item"); + _PPath = dr.GetString("PPath"); + _Path = dr.GetString("Path"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZStruct.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZStruct"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FromType", _FromType); + cm.Parameters.AddWithValue("@FromID", _FromID); + cm.Parameters.AddWithValue("@ContentType", _ContentType); + cm.Parameters.AddWithValue("@ContentID", _ContentID); + cm.Parameters.AddWithValue("@Level", _Level); + cm.Parameters.AddWithValue("@Item", _Item); + cm.Parameters.AddWithValue("@PPath", _PPath); + cm.Parameters.AddWithValue("@Path", _Path); + // Output Calculated Columns + SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int); + param_StructureID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StructureID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _StructureID = (int)cm.Parameters["@newStructureID"].Value; + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZStruct.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZStruct"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@FromType", fromType); + cm.Parameters.AddWithValue("@FromID", fromID); + cm.Parameters.AddWithValue("@ContentType", contentType); + cm.Parameters.AddWithValue("@ContentID", contentID); + cm.Parameters.AddWithValue("@Level", level); + cm.Parameters.AddWithValue("@Item", item); + cm.Parameters.AddWithValue("@PPath", pPath); + cm.Parameters.AddWithValue("@Path", path); + // Output Calculated Columns + SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int); + param_StructureID.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_StructureID); + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + structureID = (int)cm.Parameters["@newStructureID"].Value; + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.Add", ex); + throw new DbCslaException("ZStruct.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZStruct"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@StructureID", _StructureID); + cm.Parameters.AddWithValue("@FromType", _FromType); + cm.Parameters.AddWithValue("@FromID", _FromID); + cm.Parameters.AddWithValue("@ContentType", _ContentType); + cm.Parameters.AddWithValue("@ContentID", _ContentID); + cm.Parameters.AddWithValue("@Level", _Level); + cm.Parameters.AddWithValue("@Item", _Item); + cm.Parameters.AddWithValue("@PPath", _PPath); + cm.Parameters.AddWithValue("@Path", _Path); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZStruct"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@StructureID", structureID); + cm.Parameters.AddWithValue("@FromType", fromType); + cm.Parameters.AddWithValue("@FromID", fromID); + cm.Parameters.AddWithValue("@ContentType", contentType); + cm.Parameters.AddWithValue("@ContentID", contentID); + cm.Parameters.AddWithValue("@Level", level); + cm.Parameters.AddWithValue("@Item", item); + cm.Parameters.AddWithValue("@PPath", pPath); + cm.Parameters.AddWithValue("@Path", path); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.Update", ex); + throw new DbCslaException("ZStruct.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_StructureID)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZStruct"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZStruct.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int structureID) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZStruct"; + // Input PK Fields + cm.Parameters.AddWithValue("@StructureID", structureID); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.Remove", ex); + throw new DbCslaException("ZStruct.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int structureID) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(structureID)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _StructureID; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int structureID) + { + _StructureID = structureID; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsZStruct"; + cm.Parameters.AddWithValue("@StructureID", _StructureID); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("ZStruct.DataPortal_Execute", ex); + throw new DbCslaException("ZStruct.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ZStructExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class ZStruct +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZStructInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZStructInfo.cs new file mode 100644 index 00000000..7b3532ab --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZStructInfo.cs @@ -0,0 +1,169 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZStructInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZStructInfo : ReadOnlyBase + { + #region Business Methods + private int _StructureID; + [System.ComponentModel.DataObjectField(true, true)] + public int StructureID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _StructureID; + } + } + private int _FromType; + public int FromType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromType; + } + } + private int _FromID; + public int FromID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _FromID; + } + } + private int _ContentType; + public int ContentType + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentType; + } + } + private int _ContentID; + public int ContentID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _ContentID; + } + } + private int _Level; + public int Level + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Level; + } + } + private int _Item; + public int Item + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Item; + } + } + private string _PPath = string.Empty; + public string PPath + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _PPath; + } + } + private string _Path = string.Empty; + public string Path + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Path; + } + } + // TODO: Replace base ZStructInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZStructInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZStructInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZStructInfo + protected override object GetIdValue() + { + return _StructureID; + } + #endregion + #region Factory Methods + private ZStructInfo() + { /* require use of factory methods */ } + public ZStruct Get() + { + return ZStruct.Get(_StructureID); + } + #endregion + #region Data Access Portal + internal ZStructInfo(SafeDataReader dr) + { + try + { + _StructureID = dr.GetInt32("StructureID"); + _FromType = dr.GetInt32("FromType"); + _FromID = dr.GetInt32("FromID"); + _ContentType = dr.GetInt32("ContentType"); + _ContentID = dr.GetInt32("ContentID"); + _Level = dr.GetInt32("Level"); + _Item = dr.GetInt32("Item"); + _PPath = dr.GetString("PPath"); + _Path = dr.GetString("Path"); + } + catch (Exception ex) + { + Database.LogException("ZStructInfo.Constructor", ex); + throw new DbCslaException("ZStructInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZStructInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZStructInfoList.cs new file mode 100644 index 00000000..231d897e --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZStructInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZStructInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZStructInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static ZStructInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static ZStructInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static ZStructInfoList GetByStructure(int structureID) + { + return DataPortal.Fetch(new StructureCriteria(structureID)); + } + private ZStructInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZStructs"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZStructInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZStructInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZStructInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class StructureCriteria + { + public StructureCriteria(int structureID) + { + _StructureID = structureID; + } + private int _StructureID; + public int StructureID + { + get { return _StructureID; } + set { _StructureID = value; } + } + } + private void DataPortal_Fetch(StructureCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZStructsByStructure"; + cm.Parameters.AddWithValue("@StructureID", criteria.StructureID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZStructInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZStructInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZStructInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZTransition.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZTransition.cs new file mode 100644 index 00000000..bcac6102 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZTransition.cs @@ -0,0 +1,531 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZTransition Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZTransition : BusinessBase + { + #region Business Methods + private string _errorMessage = string.Empty; + public string ErrorMessage + { + get { return _errorMessage; } + } + private int _TransitionId; + [System.ComponentModel.DataObjectField(true, true)] + public int TransitionId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TransitionId; + } + } + private string _Oldto = string.Empty; + public string Oldto + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Oldto; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty(true); + if (value == null) value = string.Empty; + if (_Oldto != value) + { + _Oldto = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // TODO: Replace base ZTransition.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZTransition + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZTransition.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZTransition + protected override object GetIdValue() + { + return _TransitionId; + } + #endregion + #region ValidationRules + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "Oldto"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("Oldto", 32)); + ext.AddValidationRules(ValidationRules); + // TODO: Add other validation rules + // ValidationRules.AddRule(StartDateGTEndDate, "Started"); + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //TODO: Who can read/write which fields + //AuthorizationRules.AllowRead(TransitionId, ""); + //AuthorizationRules.AllowRead(Oldto, ""); + //AuthorizationRules.AllowWrite(Oldto, ""); + ext.AddAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // TODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // TODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // TODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // TODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private ZTransition() + {/* require use of factory methods */} + public static ZTransition New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZTransition"); + return DataPortal.Create(); + } + public static ZTransition New(int transitionId, string oldto) + { + ZTransition tmp = ZTransition.New(); + tmp._TransitionId = transitionId; + tmp.Oldto = oldto; + return tmp; + } + public static ZTransition MakeZTransition(int transitionId, string oldto) + { + ZTransition tmp = ZTransition.New(transitionId, oldto); + tmp.Save(); + return tmp; + } + public static ZTransition Get(int transitionId) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a ZTransition"); + return DataPortal.Fetch(new PKCriteria(transitionId)); + } + public static ZTransition Get(SafeDataReader dr) + { + if (dr.Read()) return new ZTransition(dr); + return null; + } + private ZTransition(SafeDataReader dr) + { + _TransitionId = dr.GetInt32("TransitionId"); + _Oldto = dr.GetString("oldto"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + public static void Delete(int transitionId) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZTransition"); + DataPortal.Delete(new PKCriteria(transitionId)); + } + public override ZTransition Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a ZTransition"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a ZTransition"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a ZTransition"); + return base.Save(); + } + #endregion + #region Data Access Portal + [Serializable()] + private class PKCriteria + { + private int _TransitionId; + public int TransitionId + { get { return _TransitionId; } } + public PKCriteria(int transitionId) + { + _TransitionId = transitionId; + } + } + // TODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create(object criteria) + { + + // Database Defaults + + // TODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void DataPortal_Fetch(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZTransition"; + cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + dr.Read(); + _TransitionId = dr.GetInt32("TransitionId"); + _Oldto = dr.GetString("oldto"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.DataPortal_Fetch", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZTransition.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZTransition"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TransitionId", _TransitionId); + cm.Parameters.AddWithValue("@Oldto", _Oldto); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + // update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.DataPortal_Insert", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZTransition.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, int transitionId, string oldto) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addZTransition"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TransitionId", transitionId); + cm.Parameters.AddWithValue("@Oldto", oldto); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.Add", ex); + throw new DbCslaException("ZTransition.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (IsDirty)// If this is dirty - open the connection + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZTransition"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@TransitionId", _TransitionId); + cm.Parameters.AddWithValue("@Oldto", _Oldto); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + // use the open connection to update child objects + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.DataPortal_Update", ex); + _errorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user."))throw ex; + } + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, int transitionId, string oldto, ref byte[] lastChanged) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updateZTransition"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@TransitionId", transitionId); + cm.Parameters.AddWithValue("@Oldto", oldto); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.Update", ex); + throw new DbCslaException("ZTransition.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_TransitionId)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZTransition"; + cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.DataPortal_Delete", ex); + _errorMessage = ex.Message; + throw new DbCslaException("ZTransition.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int transitionId) + { + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deleteZTransition"; + // Input PK Fields + cm.Parameters.AddWithValue("@TransitionId", transitionId); + // TODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.Remove", ex); + throw new DbCslaException("ZTransition.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int transitionId) + { + ExistsCommand result; + result = DataPortal.Execute + (new ExistsCommand(transitionId)); + return result.Exists; + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _TransitionId; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int transitionId) + { + _TransitionId = transitionId; + } + protected override void DataPortal_Execute() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsZTransition"; + cm.Parameters.AddWithValue("@TransitionId", _TransitionId); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + Database.LogException("ZTransition.DataPortal_Execute", ex); + throw new DbCslaException("ZTransition.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + Extension ext = new Extension(); + [Serializable()] + partial class Extension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class +} // Namespace + + +//// The following is a sample Extension File. You can use it to create ZTransitionExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace Volian.CSLA.Library +//{ +// public partial class ZTransition +// { +// partial class Extension : extensionBase +// { +// // TODO: Override automatic defaults +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// } +// } +//} diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZTransitionInfo.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZTransitionInfo.cs new file mode 100644 index 00000000..fbde1698 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZTransitionInfo.cs @@ -0,0 +1,92 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZTransitionInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZTransitionInfo : ReadOnlyBase + { + #region Business Methods + private int _TransitionId; + [System.ComponentModel.DataObjectField(true, true)] + public int TransitionId + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _TransitionId; + } + } + private string _Oldto = string.Empty; + public string Oldto + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty(true); + return _Oldto; + } + } + // TODO: Replace base ZTransitionInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current ZTransitionInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // TODO: Check ZTransitionInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current ZTransitionInfo + protected override object GetIdValue() + { + return _TransitionId; + } + #endregion + #region Factory Methods + private ZTransitionInfo() + { /* require use of factory methods */ } + public ZTransition Get() + { + return ZTransition.Get(_TransitionId); + } + #endregion + #region Data Access Portal + internal ZTransitionInfo(SafeDataReader dr) + { + try + { + _TransitionId = dr.GetInt32("TransitionId"); + _Oldto = dr.GetString("oldto"); + } + catch (Exception ex) + { + Database.LogException("ZTransitionInfo.Constructor", ex); + throw new DbCslaException("ZTransitionInfo.Constructor", ex); + } + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Generated/ZTransitionInfoList.cs b/PROMS/proms/Volian.CSLA.Library/Generated/ZTransitionInfoList.cs new file mode 100644 index 00000000..ff517df0 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Generated/ZTransitionInfoList.cs @@ -0,0 +1,122 @@ +// ======================================================================== +// Copyright 2006 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; + +namespace Volian.CSLA.Library +{ + /// + /// ZTransitionInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + public partial class ZTransitionInfoList : ReadOnlyListBase + { + #region Factory Methods + /// + /// Return a list of all projects. + /// + public static ZTransitionInfoList Get() + { + return DataPortal.Fetch(new Criteria()); + } + // TODO: Add alternative gets - + //public static ZTransitionInfoList Get() + //{ + // return DataPortal.Fetch(new FilteredCriteria()); + //} + public static ZTransitionInfoList GetByTransition(int transitionId) + { + return DataPortal.Fetch(new TransitionCriteria(transitionId)); + } + private ZTransitionInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + [Serializable()] + private class Criteria + { /* no criteria - retrieve all rows */ } + private void DataPortal_Fetch(Criteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZTransitions"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZTransitionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZTransitionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZTransitionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class TransitionCriteria + { + public TransitionCriteria(int transitionId) + { + _TransitionId = transitionId; + } + private int _TransitionId; + public int TransitionId + { + get { return _TransitionId; } + set { _TransitionId = value; } + } + } + private void DataPortal_Fetch(TransitionCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getZTransitionsByTransition"; + cm.Parameters.AddWithValue("@TransitionId", criteria.TransitionId); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new ZTransitionInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + Database.LogException("ZTransitionInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ZTransitionInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + } // Class +} // Namespace diff --git a/PROMS/proms/Volian.CSLA.Library/Properties/AssemblyInfo.cs b/PROMS/proms/Volian.CSLA.Library/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..5ef8e239 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Volian.CSLA.Library")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("Volian.CSLA.Library")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f1b42bfb-1550-446a-8ae3-7fa0e11daebb")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/Volian.CSLA.Library/VEObjects/HLStepInfo.cs b/PROMS/proms/Volian.CSLA.Library/VEObjects/HLStepInfo.cs new file mode 100644 index 00000000..a0b90ed3 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/VEObjects/HLStepInfo.cs @@ -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 + { + #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 + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/VEObjects/HLStepInfoList.cs b/PROMS/proms/Volian.CSLA.Library/VEObjects/HLStepInfoList.cs new file mode 100644 index 00000000..7c83d533 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/VEObjects/HLStepInfoList.cs @@ -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 + { + #region Factory Methods + + protected HLStepInfoList() + { /* require use of factory methods */ } + + #endregion + + #region Item Specific Data Access + /// + /// This is the SQL Command Definition + /// + /// SQL Command + /// Criteria for this object + protected override void SetupSelect(SqlCommand cm, Criteria criteria) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "vesp_ListHLSteps"; + cm.Parameters.AddWithValue("@StructID", criteria.Id); + } + /// + /// This saves each item to the list from the Database + /// + /// SafeDataReader used to load items + 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 + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyBase.cs b/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyBase.cs new file mode 100644 index 00000000..f01c7931 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyBase.cs @@ -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 : ReadOnlyBase, IVEReadOnlyItem + where T : ReadOnlyBase + { + #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 + //{ + // private VERODataPath() : base() { ;} + // public VERODataPath(int id, string name) : base(id, name) { ;} + //} + //public class VEROPlant : VEReadOnlyBase + //{ + // private VEROPlant() : base() { ;} + // public VEROPlant(int id, string name) : base(id, name) { ;} + //} +} diff --git a/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyItem.cs b/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyItem.cs new file mode 100644 index 00000000..36df7cb0 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyItem.cs @@ -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(); + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyListBase.cs b/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyListBase.cs new file mode 100644 index 00000000..77a848c8 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/VEObjects/VEReadOnlyListBase.cs @@ -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 : ReadOnlyListBase + where T : VEReadOnlyListBase + where C : VEReadOnlyBase, 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(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 + } +} diff --git a/PROMS/proms/Volian.CSLA.Library/VEObjects/VETreeNode.cs b/PROMS/proms/Volian.CSLA.Library/VEObjects/VETreeNode.cs new file mode 100644 index 00000000..592826a2 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/VEObjects/VETreeNode.cs @@ -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 : 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 + { + public static VEFolder LoadTree() + { + VEFolder root = null; + FolderInfoList fil = FolderInfoList.Get(); + Dictionary dicMissing = new Dictionary(); + Dictionary dicExists = new Dictionary(); + 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 { } + public class VEProcedure : VETreeNodeBase + { + public override void LoadChildren() + { + if (!_ChildrenLoaded) + { + this.Nodes.Clear(); + Dictionary dicSect = new Dictionary(); + 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 { } + public class VEStep : VETreeNodeBase { } +} diff --git a/PROMS/proms/Volian.CSLA.Library/Volian.CSLA.Library.csproj b/PROMS/proms/Volian.CSLA.Library/Volian.CSLA.Library.csproj new file mode 100644 index 00000000..0aeb23cf --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Volian.CSLA.Library.csproj @@ -0,0 +1,164 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {3C162BD7-5DBC-45A6-90D8-9391AC8CD0FD} + Library + Properties + Volian.CSLA.Library + Volian.CSLA.Library + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + False + ..\..\..\..\veproms\bin\log4net.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.CSLA.Library/Volian.CSLA.Library.csproj.vspscc b/PROMS/proms/Volian.CSLA.Library/Volian.CSLA.Library.csproj.vspscc new file mode 100644 index 00000000..05a3bdb5 --- /dev/null +++ b/PROMS/proms/Volian.CSLA.Library/Volian.CSLA.Library.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:Volian.CSLA.Library" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/Volian.Controls.Library/Properties/AssemblyInfo.cs b/PROMS/proms/Volian.Controls.Library/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..f58a767d --- /dev/null +++ b/PROMS/proms/Volian.Controls.Library/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Volian.Controls.Library")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("Volian.Controls.Library")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("75dc3e0c-064d-4160-9053-1dd5b536a0c3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/Volian.Controls.Library/Volian.Controls.Library.csproj b/PROMS/proms/Volian.Controls.Library/Volian.Controls.Library.csproj new file mode 100644 index 00000000..4d3e0da6 --- /dev/null +++ b/PROMS/proms/Volian.Controls.Library/Volian.Controls.Library.csproj @@ -0,0 +1,59 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8556527C-6615-487F-8AF7-22EBC3EF0268} + Library + Properties + Volian.Controls.Library + Volian.Controls.Library + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Component + + + vlnTreeView.cs + + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Controls.Library/Volian.Controls.Library.csproj.vspscc b/PROMS/proms/Volian.Controls.Library/Volian.Controls.Library.csproj.vspscc new file mode 100644 index 00000000..3c21c81f --- /dev/null +++ b/PROMS/proms/Volian.Controls.Library/Volian.Controls.Library.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:Volian.Controls.Library" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/Volian.Controls.Library/vlnTreeView.cs b/PROMS/proms/Volian.Controls.Library/vlnTreeView.cs new file mode 100644 index 00000000..91a1e398 --- /dev/null +++ b/PROMS/proms/Volian.Controls.Library/vlnTreeView.cs @@ -0,0 +1,635 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Runtime.InteropServices; // For DragHelper +using System.Reflection; + +namespace Volian.Controls.Library +{ + public delegate void vlnTreeViewEvent(object sender, vlnTreeEventArgs args); + public delegate bool vlnTreeViewBoolEvent(object sender, vlnTreeEventArgs args); + public delegate TreeNode vlnTreeViewTreeNodeEvent(object sender, vlnTreeEventArgs args); + //public delegate void vlnTreeViewDDEvent(object sender, System.Windows.Forms.DragEventArgs args); + public partial class vlnTreeEventArgs + { + #region Business Methods + private TreeNode _Node; + public TreeNode Node + { + get { return _Node; } + set { _Node = value; } + } + private TreeNode _Destination=null; + public TreeNode Destination + { + get { return _Destination; } + set { _Destination = value; } + } + private int _Index; + public int Index + { + get { return _Index; } + set { _Index = value; } + } + #endregion + #region Factory Methods + private vlnTreeEventArgs() { ;} + public vlnTreeEventArgs(TreeNode node) + { + _Node = node; + } + public vlnTreeEventArgs(TreeNode node, TreeNode destination, int index) + { + _Node = node; + _Destination = destination; + _Index = index; + } + #endregion + } + public partial class vlnTreeView : TreeView + { + #region Events + public event vlnTreeViewEvent NodeDragDrop; + private void OnNodeDragDrop(object sender, vlnTreeEventArgs args) + { + if (NodeDragDrop != null) NodeDragDrop(sender, args); + } + public event vlnTreeViewEvent NodeMove; + private void OnNodeMove(object sender, vlnTreeEventArgs args) + { + if (NodeMove != null) NodeMove(sender, args); + } + public event vlnTreeViewEvent NodeCopy; + private void OnNodeCopy(object sender, vlnTreeEventArgs args) + { + if (NodeCopy != null) NodeCopy(sender, args); + } + public event vlnTreeViewBoolEvent NodeDelete; + private bool OnNodeDelete(object sender, vlnTreeEventArgs args) + { + bool result = true; + if (NodeDelete != null) result = NodeDelete(sender, args); + return result; + } + public event vlnTreeViewTreeNodeEvent NodeNew; + private TreeNode OnNodeNew(object sender, vlnTreeEventArgs args) + { + if (NodeNew != null) return NodeNew(sender, args); + else return new TreeNode("New Item"); + } + public event vlnTreeViewEvent NodeProperties; + private void OnNodeProperties(object sender, vlnTreeEventArgs args) + { + if (NodeProperties != null) NodeProperties(sender, args); + } + public event vlnTreeViewEvent NodeSelectionChange; + private void OnNodeSelectionChange(object sender, vlnTreeEventArgs args) + { + if (NodeSelectionChange != null) NodeSelectionChange(sender, args); + } + #endregion + #region Business Methods + ImageList _dragImageList = new ImageList(); + #endregion + #region Constructors + public vlnTreeView() + { + InitializeComponent(); + this.AllowDrop = true; + DragHelper.InitCommonControls(); + this.ItemDrag += new ItemDragEventHandler(tv_ItemDrag); + this.DragDrop += new DragEventHandler(tv_DragDrop); + this.DragEnter += new DragEventHandler(tv_DragEnter); + this.DragLeave += new EventHandler(tv_DragLeave); + this.DragOver += new DragEventHandler(tv_DragOver); + this.MouseDown += new MouseEventHandler(tv_MouseDown); + base.AfterSelect += new TreeViewEventHandler(tv_AfterSelect); + } + private void tv_AfterSelect(object sender, TreeViewEventArgs e) + { + OnNodeSelectionChange(sender, new vlnTreeEventArgs(e.Node)); + } + void tv_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + TreeNode tn = this.GetNodeAt(new Point(e.X, e.Y)); + if (tn != null) + { + this.SelectedNode = tn; + Application.DoEvents(); + // Display Menu + ToolStripMenuItem mi = new ToolStripMenuItem(); + ContextMenu cm = new ContextMenu(); + cm.MenuItems.Add("New...",new EventHandler(mi_Click)); + cm.MenuItems.Add("Cut", new EventHandler(mi_Click)); + cm.MenuItems.Add("Copy", new EventHandler(mi_Click)); + cm.MenuItems.Add("Paste", new EventHandler(mi_Click)); + cm.MenuItems.Add("Delete", new EventHandler(mi_Click)); + cm.MenuItems.Add("Properties...", new EventHandler(mi_Click)); + cm.Show(this, new Point(e.X, e.Y)); + } + } + } + + void mi_Click(object sender, EventArgs e) + { + MenuItem mi = (MenuItem)sender; + switch (mi.Text) + { + case "New..."://Add a new child node at the current location + // Should Give the option to the controling code to Add a New Node + SelectedNode.Expand(); + TreeNode tn = OnNodeNew(this, new vlnTreeEventArgs(SelectedNode)); + if (tn != null) + { + SelectedNode.Nodes.Add(tn); + if (LabelEdit) + tn.BeginEdit(); + else + SelectedNode = tn; + } + break; + case "Cut"://Cut the selected node + // Cut to Clipboard + break; + case "Copy"://Copy the selected node + // Add to Clipboard + break; + case "Paste"://Paste the clipboard node + // this is either a copy or a move depending upon where it came from + // if it is from a cut then when the paste is done it should be set to a copy + break; + case "Delete"://Delete the selected node + if(OnNodeDelete(this, new vlnTreeEventArgs(SelectedNode))) + SelectedNode.Remove(); + break; + case "Properties..."://Show the properties for the selected node + OnNodeProperties(this,new vlnTreeEventArgs(SelectedNode)); + break; + default: + MessageBox.Show(string.Format("Unrecognized Menu Item '{0}'", mi.Text)); + break; + } + } + #endregion + #region Cursor + private bool SetupDragCursor(ImageList il, TreeNode tn) + { + // Reset image list used for drag image + il.Images.Clear(); + int howBig = tn.Bounds.Size.Width + this.Indent; + if (howBig > 256) howBig = 256; + il.ImageSize = new Size(howBig, tn.Bounds.Height); + + // Create new bitmap + // This bitmap will contain the tree node image to be dragged + Bitmap bmp = new Bitmap(tn.Bounds.Width + this.Indent, tn.Bounds.Height); + + // Get graphics from bitmap + Graphics gfx = Graphics.FromImage(bmp); + + // Draw node icon into the bitmap + if (this.ImageList != null) gfx.DrawImage(this.ImageList.Images[0], 0, 0); + + // Draw node label into bitmap + gfx.DrawString(tn.Text, this.Font, new SolidBrush(this.ForeColor), + // new SolidBrush(Color.Blue), + (float)this.Indent, 1.0f); + + // Add bitmap to imagelist + _dragImageList.Images.Add(bmp); + + // Get mouse position in client coordinates + Point p = this.PointToClient(Control.MousePosition); + + // Compute delta between mouse position and node bounds + int dx = p.X + this.Indent - tn.Bounds.Left; + int dy = p.Y - tn.Bounds.Top; + + // Begin dragging image + return DragHelper.ImageList_BeginDrag(_dragImageList.Handle, 0, dx, dy); + } + private void tv_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) + { + // Get drag node and select it + try + { + TreeNode dragNode = (TreeNode)e.Item; + Type t = dragNode.GetType(); + Console.WriteLine("Item Drag {0} - {1}", t.FullName, t.BaseType.FullName); + Type t2 = Type.GetType(t.FullName); + if(t2 != null) + Console.WriteLine("Item Drag {0} - {1}", t2.FullName, t2.BaseType.FullName); + this.SelectedNode = dragNode; + if (SetupDragCursor(_dragImageList, dragNode)) + { + this.DoDragDrop(dragNode, DragDropEffects.Move | DragDropEffects.Copy);// Begin dragging + DragHelper.ImageList_EndDrag();// End dragging image + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + #endregion + public enum DropPosition : int + { + Child = 0, Before = 1, After = 2 + } + private class DropLocation + { + #region Business Methods + private TreeNode _dropNode; + public TreeNode DropNode + { + get { return _dropNode; } + set { _dropNode = value; } + } + private int _index; + public int Index + { + get { return _index; } + set { _index = value; } + } + private DropPosition _position; + public DropPosition Position + { + get { return _position; } + set { _position = value; } + } + DateTime _lastScroll; + public DateTime LastScroll + { + get { return _lastScroll; } + } + private string _location = string.Empty; + #endregion + #region Constructors + public DropLocation(TreeView tv, System.Windows.Forms.DragEventArgs e, DateTime lastScroll) + { + _lastScroll = lastScroll; + _dropNode = tv.GetNodeAt(tv.PointToClient(new Point(e.X, e.Y))); + if (_dropNode == null) return; + int OffsetY = tv.PointToClient(Cursor.Position).Y - _dropNode.Bounds.Top; + if (OffsetY < _dropNode.Bounds.Height / 3) // First Third - Before + { + _index = _dropNode.Index; + _dropNode = _dropNode.Parent; + _position = DropPosition.Before; + _location = string.Format("Before1 {0}[{1}] y={2}", _dropNode.Text, _index, OffsetY); + } + else if ((OffsetY / 2) < _dropNode.Bounds.Height / 3) // Second Third - Child + { + _location = string.Format("Child {0} y={1}", _dropNode.Text, OffsetY); + _position = DropPosition.Child; + _index = 0; + if (_dropNode.Parent == null) + { + Console.WriteLine("Root Node"); + } + } + else // Last Third - After Now I need to check the X value + { + if (_dropNode.NextVisibleNode !=null && _dropNode.Nodes.Count > 0)// Has Children - Insert first child + { + // _dropNode = _dropNode.Nodes[0]; + _index = 0; + _position = DropPosition.Before; + _location = string.Format("Before2 {0}[{1}] y={2}", _dropNode.Text, _index, OffsetY); + } + else // No Children - Insert Next at various levels + { + Point pt = tv.PointToClient(new Point(e.X, e.Y)); + TreeNode nextParent = _dropNode.NextNode; + if (nextParent != null) nextParent = nextParent.Parent; + do + { + _index = _dropNode.Index; + _dropNode = _dropNode.Parent; + } while (pt.X < _dropNode.Bounds.X && _dropNode != nextParent); + _location = string.Format("After {0}[{1}] y={2}", _dropNode.Text, _index, OffsetY); + _position = DropPosition.After; + } + } + LimitMoves(e); + } + public void LimitMoves(DragEventArgs e) + { + if ((e.KeyState & 8) == 0) + { + //TreeNode dragNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); + //TreeNode dragNode = (TreeNode)e.Data.GetData("TreeTest.FolderTreeNode"); + TreeNode dragNode = vlnTreeView.GetTreeNodeFromData(e.Data); + switch (_position) + { + case DropPosition.Before: + if (dragNode == _dropNode.Nodes[_index] || dragNode == _dropNode.Nodes[_index].PrevNode) + { + // Console.WriteLine("Before {0} {1} {2} {3} {4}", dragNode.Text ,_position.ToString() , _dropNode.Nodes[_index].Text + // ,_dropNode.Nodes[_index].PrevNode,_dropNode.Nodes[_index].NextNode); + _dropNode = null; + } + break; + case DropPosition.Child: + if (dragNode.Parent == _dropNode) + { + // Console.WriteLine("Child {0} {1} {2} {3} {4} {5}", dragNode.Text ,_position.ToString() , _dropNode.Nodes[_index].Text + // ,_dropNode.Nodes[_index].PrevNode,_dropNode.Nodes[_index].NextNode,DateTime.Now); + _dropNode = null; + } + break; + case DropPosition.After: + if (dragNode == _dropNode.Nodes[_index] || dragNode == _dropNode.Nodes[_index].NextNode) + { + // Console.WriteLine("After {0} {1} {2} {3} {4}", dragNode.Text ,_position.ToString() , _dropNode.Nodes[_index].Text + // ,_dropNode.Nodes[_index].PrevNode,_dropNode.Nodes[_index].NextNode); + _dropNode = null; + } + break; + } + } + } + #endregion + public override string ToString() + { + return string.Format("{0}[{1}].{2}", _dropNode.Text, _index, _position.ToString()); + } + #region Drawing + private void TreeNodeTriangle(Graphics g) + { + Rectangle r = _dropNode.Bounds; + int RightPos = r.Right + 6; + Point[] RightTriangle = new Point[]{ + new Point(RightPos, r.Y ), + new Point(RightPos - (r.Height / 2), r.Y + (r.Height / 2)), + new Point(RightPos, r.Y + r.Height), + new Point(RightPos - (r.Height / 3), r.Y + (r.Height / 2)) + }; + g.FillPolygon(System.Drawing.Brushes.Black, RightTriangle); + } + private void InsertPointer(TreeNode tn, Graphics g) + { + TreeView tv = _dropNode.TreeView; + Rectangle r2 = _dropNode.Nodes[_index].Bounds; + Rectangle r3 = tn.Bounds; + int y = (_position == DropPosition.Before ? r2.Y : r3.Bottom); + int x = r2.Left; + + if (y == 0) + { + return; + } +// Console.WriteLine("Line at {0} Node {1}[{2}] {3}", _location, _dropNode.Text, _index, _position.ToString()); + Color lc = (_position == DropPosition.After ? Color.Red : Color.Blue); + Brush lb = (_position == DropPosition.After ? Brushes.Red : Brushes.Blue); + Point[] RightTriangle; + if (_position == DropPosition.After) + { + RightTriangle = new Point[]{ + new Point(x, y ), + new Point(x+4, y+4), + new Point(x+8, y)}; + } + else + { + RightTriangle = new Point[]{ + new Point(x, y), + new Point(x+4, y-4), + new Point(x+8, y)}; + } + g.DrawLine(new System.Drawing.Pen(lc, 2), new Point(r2.Left, y), new Point(tv.Width - 8, y)); + g.FillPolygon(lb, RightTriangle); + } + public void ShowLocation(System.Windows.Forms.DragEventArgs e, bool ScrollOnly) + { + //if (e.Effect == DragDropEffects.None) return; + if (_dropNode != null) + { +// Console.WriteLine("ShowLocation1 {0} {1}", e.Effect.ToString(), DateTime.Now.Millisecond); + DragHelper.ImageList_DragShowNolock(false); + TreeView tv = _dropNode.TreeView; + TreeNode tmp = tv.GetNodeAt(tv.PointToClient(new Point(e.X, e.Y))); +// if (!ScrollOnly) +// { + if (ScrollTreeView(tmp) || !ScrollOnly) + { + Console.WriteLine("ShowLocation2 {0} {1}",e.Effect.ToString(),DateTime.Now.Millisecond); + tv.Refresh(); + if (e.Effect != DragDropEffects.None) + { + //tv.SelectedNode = dropNode; + Graphics g = tv.CreateGraphics(); + TreeNodeTriangle(g); + if (_position != DropPosition.Child)InsertPointer(tmp, g); + } + } +// } +// else ScrollTreeView(tmp); + DragHelper.ImageList_DragShowNolock(true); + } + } + #endregion + public void ShowLocation() + { + Console.WriteLine("{0}[{1}] {2}", _dropNode.Text, _index, _position.ToString()); + } + #region AutoScroll + private bool ScrollTreeView(TreeNode tn) + { + bool retval = false; + TimeSpan ts = new TimeSpan(DateTime.Now.Ticks - _lastScroll.Ticks); + if (ts.Milliseconds > 100)// This controls the scroll speed + { + int top = tn.Bounds.Top; + _lastScroll = DateTime.Now; + if (tn.TreeView.ClientSize.Height < tn.Bounds.Bottom) tn.EnsureVisible();// Make sure that the current node is visible + if (tn.NextVisibleNode != null && tn.TreeView.ClientSize.Height < tn.NextVisibleNode.Bounds.Bottom) + tn.NextVisibleNode.EnsureVisible();// Make sure that the next node is visible + else + if (tn.PrevVisibleNode != null && tn.PrevVisibleNode.PrevVisibleNode != null && tn.PrevVisibleNode.PrevVisibleNode.IsVisible == false) + tn.PrevVisibleNode.PrevVisibleNode.EnsureVisible();// Make sure that the previous node is visible } + else + if (tn.PrevVisibleNode != null && tn.PrevVisibleNode.IsVisible == false) + tn.PrevVisibleNode.EnsureVisible();// Make sure that the previous node is visible + retval = (top != tn.Bounds.Top); +// if (retval) Console.WriteLine("Scroll"); + } + return retval; + } + #endregion + public bool Equals(DropLocation dl) + { + return (dl != null && _lastScroll.Equals(dl.LastScroll) && _dropNode.Equals(dl.DropNode) && + _position.Equals(dl.Position)); + } + } + private DropLocation _LastDropLocation = null; + private void tv_DragOver(object sender, System.Windows.Forms.DragEventArgs e) + { + try + { + TreeNode dragNode = GetTreeNodeFromData(e.Data); + // Compute drag position and move image + Point formP = this.FindForm().PointToClient(new Point(e.X, e.Y)); + DragHelper.ImageList_DragMove(formP.X - this.Left, formP.Y - this.Top); + DropLocation dl = new DropLocation(this, e, _LastDropLocation == null ? DateTime.Now : _LastDropLocation.LastScroll); + string s = string.Empty; + if (dl.DropNode == null) + { + e.Effect = DragDropEffects.None; + } + else + { + DragDropEffects ee = e.Effect; + if ((e.KeyState & 8) == 8) + ee = DragDropEffects.Copy; // Copy it + else + ee = DragDropEffects.Move; // Move it + if (IsChild(dragNode, dl.DropNode)) + ee = DragDropEffects.None; // Don't copy or move to a child node + if (e.Effect != ee) e.Effect = ee; + dl.ShowLocation(e, dl.Equals(_LastDropLocation)); + _LastDropLocation = dl; + } + } + catch (Exception ex) + { + for(;ex!=null;ex=ex.InnerException) + Console.WriteLine(ex.Message); + } + } + private static TreeNode GetTreeNodeFromData(IDataObject datobj) + { + foreach (string s in datobj.GetFormats()) + { + try + { + return (TreeNode)datobj.GetData(s); + } + catch (Exception ex2) + { + for (; ex2 != null; ex2 = ex2.InnerException) + Console.WriteLine("Error: {0}", ex2.Message); + } + } + return null; + } + private void tv_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) + { + try + { + TreeNode dragNode = GetTreeNodeFromData(e.Data); + DragHelper.ImageList_DragLeave(this.Handle); + int index = _LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0); + if (dragNode.Parent == _LastDropLocation.DropNode && dragNode.Index <= _LastDropLocation.Index) index--; + if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent + dragNode.Remove(); + else + dragNode = Clone(dragNode); + _LastDropLocation.DropNode.Nodes.Insert(index, dragNode); + this.SelectedNode = dragNode; + OnNodeDragDrop(sender, new vlnTreeEventArgs(dragNode, _LastDropLocation.DropNode,index)); + } + catch (Exception ex) + { + for (; ex != null; ex = ex.InnerException) + Console.WriteLine(ex.Message); + } + } + private void DumpMembers(object o) + { + Type t = o.GetType(); + Console.WriteLine("\r\n\r\nMembers for type {0}", t.ToString()); + MemberInfo[] mis = t.GetMembers(); + int i = 0; + foreach (MemberInfo mi in mis) + { + i++; + try + { + if(mi.MemberType != MemberTypes.Method) + Console.WriteLine("{0} {1} {2}", i, mi.Name,mi.MemberType); +// if (fi.Name == "TreeView") +// fi.SetValue(o, null); + } + catch (Exception ex) + { + for (; ex != null; ex = ex.InnerException) + Console.WriteLine("\r\n{0} {1}", ex.GetType().ToString(), ex.Message); + } + } + } + private TreeNode Clone(TreeNode tn) + { + + TreeNode tmp = (TreeNode)tn.Clone(); + ExpandMatch(tmp,tn); + return tmp; + } + private void tv_DragDropOld(object sender, System.Windows.Forms.DragEventArgs e) + { + TreeNode dragNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");// Get the drag node + DragHelper.ImageList_DragLeave(this.Handle); + TreeNode cloneNode = (TreeNode)dragNode.Clone();// copy the source node + ExpandMatch(cloneNode, dragNode); + _LastDropLocation.DropNode.Nodes.Insert(_LastDropLocation.Index + (_LastDropLocation.Position == DropPosition.After ? 1 : 0), cloneNode); + if (e.Effect == DragDropEffects.Move)// If Move Remove drag node from parent + dragNode.Remove(); + this.SelectedNode = cloneNode; + } + private void tv_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) + { + DragHelper.ImageList_DragEnter(this.Handle, e.X - this.Left, e.Y - this.Top); + } + private void tv_DragLeave(object sender, System.EventArgs e) + { + DragHelper.ImageList_DragLeave(this.Handle); + this.Refresh(); + } + private void ExpandMatch(TreeNode tn1, TreeNode tn2) + { + if (tn2.IsExpanded) tn1.Expand(); + foreach (TreeNode tc in tn2.Nodes) ExpandMatch(tn1.Nodes[tc.Index], tc); + } + private bool IsChild(TreeNode parent, TreeNode child) + { + if (parent.Equals(child)) return true;// Check against self + foreach (TreeNode tc in parent.Nodes) if (IsChild(tc, child)) return true;//Check all children + return false;// Must not be a child at this level + } + } + public class DragHelper + { + [DllImport("comctl32.dll")] + public static extern bool InitCommonControls(); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_BeginDrag(IntPtr himlTrack, int + iTrack, int dxHotspot, int dyHotspot); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragMove(int x, int y); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern void ImageList_EndDrag(); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragEnter(IntPtr hwndLock, int x, int y); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragLeave(IntPtr hwndLock); + + [DllImport("comctl32.dll", CharSet = CharSet.Auto)] + public static extern bool ImageList_DragShowNolock(bool fShow); + static DragHelper() + { + InitCommonControls(); + } + } +} diff --git a/PROMS/proms/Volian.Controls.Library/vlnTreeView.designer.cs b/PROMS/proms/Volian.Controls.Library/vlnTreeView.designer.cs new file mode 100644 index 00000000..1428834d --- /dev/null +++ b/PROMS/proms/Volian.Controls.Library/vlnTreeView.designer.cs @@ -0,0 +1,36 @@ +namespace Volian.Controls.Library +{ + partial class vlnTreeView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + } + + #endregion + } +} diff --git a/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.cs b/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.cs new file mode 100644 index 00000000..19a88f3f --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.cs @@ -0,0 +1,383 @@ +/* + IniReader class for C# + Version: 1.0 Date: 2002/04/24 +*/ +/* + Copyright © 2002, The KPD-Team + All rights reserved. + http://www.mentalis.org/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Neither the name of the KPD-Team, nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using System.Collections; +using System.Runtime.InteropServices; + +// The Org.Mentalis.Files contains a number of classes that read from or write to special files. +namespace Org.Mentalis.Files { + /// + /// The INIReader class can read keys from and write keys to an INI file. + /// + /// + /// This class uses several Win32 API functions to read from and write to INI files. It will not work on Linux or FreeBSD. + /// + public class IniReader { + // API declarations + /// + /// The GetPrivateProfileInt function retrieves an integer associated with a key in the specified section of an initialization file. + /// + /// Pointer to a null-terminated string specifying the name of the section in the initialization file. + /// Pointer to the null-terminated string specifying the name of the key whose value is to be retrieved. This value is in the form of a string; the GetPrivateProfileInt function converts the string into an integer and returns the integer. + /// Specifies the default value to return if the key name cannot be found in the initialization file. + /// Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory. + /// The return value is the integer equivalent of the string following the specified key name in the specified initialization file. If the key is not found, the return value is the specified default value. If the value of the key is less than zero, the return value is zero. + [DllImport("KERNEL32.DLL", EntryPoint="GetPrivateProfileIntA", CharSet=CharSet.Ansi)] + private static extern int GetPrivateProfileInt(string lpApplicationName, string lpKeyName, int nDefault, string lpFileName); + /// + /// The WritePrivateProfileString function copies a string into the specified section of an initialization file. + /// + /// Pointer to a null-terminated string containing the name of the section to which the string will be copied. If the section does not exist, it is created. The name of the section is case-independent; the string can be any combination of uppercase and lowercase letters. + /// Pointer to the null-terminated string containing the name of the key to be associated with a string. If the key does not exist in the specified section, it is created. If this parameter is NULL, the entire section, including all entries within the section, is deleted. + /// Pointer to a null-terminated string to be written to the file. If this parameter is NULL, the key pointed to by the lpKeyName parameter is deleted. + /// Pointer to a null-terminated string that specifies the name of the initialization file. + /// If the function successfully copies the string to the initialization file, the return value is nonzero; if the function fails, or if it flushes the cached version of the most recently accessed initialization file, the return value is zero. + [DllImport("KERNEL32.DLL", EntryPoint="WritePrivateProfileStringA", CharSet=CharSet.Ansi)] + private static extern int WritePrivateProfileString (string lpApplicationName, string lpKeyName, string lpString, string lpFileName); + /// + /// The GetPrivateProfileString function retrieves a string from the specified section in an initialization file. + /// + /// Pointer to a null-terminated string that specifies the name of the section containing the key name. If this parameter is NULL, the GetPrivateProfileString function copies all section names in the file to the supplied buffer. + /// Pointer to the null-terminated string specifying the name of the key whose associated string is to be retrieved. If this parameter is NULL, all key names in the section specified by the lpAppName parameter are copied to the buffer specified by the lpReturnedString parameter. + /// Pointer to a null-terminated default string. If the lpKeyName key cannot be found in the initialization file, GetPrivateProfileString copies the default string to the lpReturnedString buffer. This parameter cannot be NULL.
Avoid specifying a default string with trailing blank characters. The function inserts a null character in the lpReturnedString buffer to strip any trailing blanks.
+ /// Pointer to the buffer that receives the retrieved string. + /// Specifies the size, in TCHARs, of the buffer pointed to by the lpReturnedString parameter. + /// Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory. + /// The return value is the number of characters copied to the buffer, not including the terminating null character. + [DllImport("KERNEL32.DLL", EntryPoint="GetPrivateProfileStringA", CharSet=CharSet.Ansi)] + private static extern int GetPrivateProfileString (string lpApplicationName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName); + /// + /// The GetPrivateProfileSectionNames function retrieves the names of all sections in an initialization file. + /// + /// Pointer to a buffer that receives the section names associated with the named file. The buffer is filled with one or more null-terminated strings; the last string is followed by a second null character. + /// Specifies the size, in TCHARs, of the buffer pointed to by the lpszReturnBuffer parameter. + /// Pointer to a null-terminated string that specifies the name of the initialization file. If this parameter is NULL, the function searches the Win.ini file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory. + /// The return value specifies the number of characters copied to the specified buffer, not including the terminating null character. If the buffer is not large enough to contain all the section names associated with the specified initialization file, the return value is equal to the length specified by nSize minus two. + [DllImport("KERNEL32.DLL", EntryPoint="GetPrivateProfileSectionNamesA", CharSet=CharSet.Ansi)] + private static extern int GetPrivateProfileSectionNames (byte[] lpszReturnBuffer, int nSize, string lpFileName); + /// + /// The WritePrivateProfileSection function replaces the keys and values for the specified section in an initialization file. + /// + /// Pointer to a null-terminated string specifying the name of the section in which data is written. This section name is typically the name of the calling application. + /// Pointer to a buffer containing the new key names and associated values that are to be written to the named section. + /// Pointer to a null-terminated string containing the name of the initialization file. If this parameter does not contain a full path for the file, the function searches the Windows directory for the file. If the file does not exist and lpFileName does not contain a full path, the function creates the file in the Windows directory. The function does not create a file if lpFileName contains the full path and file name of a file that does not exist. + /// If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
+ [DllImport("KERNEL32.DLL", EntryPoint="WritePrivateProfileSectionA", CharSet=CharSet.Ansi)] + private static extern int WritePrivateProfileSection (string lpAppName, string lpString, string lpFileName); + /// Constructs a new IniReader instance. + /// Specifies the full path to the INI file (the file doesn't have to exist). + public IniReader(string file) { + Filename = file; + } + /// Gets or sets the full path to the INI file. + /// A String representing the full path to the INI file. + public string Filename { + get { + return m_Filename; + } + set { + m_Filename = value; + } + } + /// Gets or sets the section you're working in. (aka 'the active section') + /// A String representing the section you're working in. + public string Section { + get { + return m_Section; + } + set { + m_Section = value; + } + } + /// Reads an Integer from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// The value to return if the specified key isn't found. + /// Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file. + public int ReadInteger(string section, string key, int defVal) { + return GetPrivateProfileInt(section, key, defVal, Filename); + } + /// Reads an Integer from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// Returns the value of the specified section/key pair, or returns 0 if the specified section/key pair isn't found in the INI file. + public int ReadInteger(string section, string key) { + return ReadInteger(section, key, 0); + } + /// Reads an Integer from the specified key of the active section. + /// The key from which to return the value. + /// The section to search in. + /// Returns the value of the specified Key, or returns the default value if the specified Key isn't found in the active section of the INI file. + public int ReadInteger(string key, int defVal) { + return ReadInteger(Section, key, defVal); + } + /// Reads an Integer from the specified key of the active section. + /// The key from which to return the value. + /// Returns the value of the specified key, or returns 0 if the specified key isn't found in the active section of the INI file. + public int ReadInteger(string key) { + return ReadInteger(key, 0); + } + /// Reads a String from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// The value to return if the specified key isn't found. + /// Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file. + public string ReadString(string section, string key, string defVal) { + StringBuilder sb = new StringBuilder(MAX_ENTRY); + int Ret = GetPrivateProfileString(section, key, defVal, sb, MAX_ENTRY, Filename); + return sb.ToString(); + } + /// Reads a String from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// Returns the value of the specified section/key pair, or returns an empty String if the specified section/key pair isn't found in the INI file. + public string ReadString(string section, string key) { + return ReadString(section, key, ""); + } + /// Reads a String from the specified key of the active section. + /// The key from which to return the value. + /// Returns the value of the specified key, or returns an empty String if the specified key isn't found in the active section of the INI file. + public string ReadString(string key) { + return ReadString(Section, key); + } + /// Reads a Long from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// The value to return if the specified key isn't found. + /// Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file. + public long ReadLong(string section, string key, long defVal) { + return long.Parse(ReadString(section, key, defVal.ToString())); + } + /// Reads a Long from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// Returns the value of the specified section/key pair, or returns 0 if the specified section/key pair isn't found in the INI file. + public long ReadLong(string section, string key) { + return ReadLong(section, key, 0); + } + /// Reads a Long from the specified key of the active section. + /// The key from which to return the value. + /// The section to search in. + /// Returns the value of the specified key, or returns the default value if the specified key isn't found in the active section of the INI file. + public long ReadLong(string key, long defVal) { + return ReadLong(Section, key, defVal); + } + /// Reads a Long from the specified key of the active section. + /// The key from which to return the value. + /// Returns the value of the specified Key, or returns 0 if the specified Key isn't found in the active section of the INI file. + public long ReadLong(string key) { + return ReadLong(key, 0); + } + /// Reads a Byte array from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// Returns the value of the specified section/key pair, or returns null (Nothing in VB.NET) if the specified section/key pair isn't found in the INI file. + public byte[] ReadByteArray(string section, string key) { + try { + return Convert.FromBase64String(ReadString(section, key)); + } catch {} + return null; + } + /// Reads a Byte array from the specified key of the active section. + /// The key from which to return the value. + /// Returns the value of the specified key, or returns null (Nothing in VB.NET) if the specified key pair isn't found in the active section of the INI file. + public byte[] ReadByteArray(string key) { + return ReadByteArray(Section, key); + } + /// Reads a Boolean from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// The value to return if the specified key isn't found. + /// Returns the value of the specified section/key pair, or returns the default value if the specified section/key pair isn't found in the INI file. + public bool ReadBoolean(string section, string key, bool defVal) { + return Boolean.Parse(ReadString(section, key, defVal.ToString())); + } + /// Reads a Boolean from the specified key of the specified section. + /// The section to search in. + /// The key from which to return the value. + /// Returns the value of the specified section/key pair, or returns false if the specified section/key pair isn't found in the INI file. + public bool ReadBoolean(string section, string key) { + return ReadBoolean(section, key, false); + } + /// Reads a Boolean from the specified key of the specified section. + /// The key from which to return the value. + /// The value to return if the specified key isn't found. + /// Returns the value of the specified key pair, or returns the default value if the specified key isn't found in the active section of the INI file. + public bool ReadBoolean(string key, bool defVal) { + return ReadBoolean(Section, key, defVal); + } + /// Reads a Boolean from the specified key of the specified section. + /// The key from which to return the value. + /// Returns the value of the specified key, or returns false if the specified key isn't found in the active section of the INI file. + public bool ReadBoolean(string key) { + return ReadBoolean(Section, key); + } + /// Writes an Integer to the specified key in the specified section. + /// The section to write in. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string section, string key, int value) { + return Write(section, key, value.ToString()); + } + /// Writes an Integer to the specified key in the active section. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string key, int value) { + return Write(Section, key, value); + } + /// Writes a String to the specified key in the specified section. + /// Specifies the section to write in. + /// Specifies the key to write to. + /// Specifies the value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string section, string key, string value) { + return (WritePrivateProfileString(section, key, value, Filename) != 0); + } + /// Writes a String to the specified key in the active section. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string key, string value) { + return Write(Section, key, value); + } + /// Writes a Long to the specified key in the specified section. + /// The section to write in. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string section, string key, long value) { + return Write(section, key, value.ToString()); + } + /// Writes a Long to the specified key in the active section. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string key, long value) { + return Write(Section, key, value); + } + /// Writes a Byte array to the specified key in the specified section. + /// The section to write in. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string section, string key, byte [] value) { + if (value == null) + return Write(section, key, (string)null); + else + return Write(section, key, value, 0, value.Length); + } + /// Writes a Byte array to the specified key in the active section. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string key, byte [] value) { + return Write(Section, key, value); + } + /// Writes a Byte array to the specified key in the specified section. + /// The section to write in. + /// The key to write to. + /// The value to write. + /// An offset in value. + /// The number of elements of value to convert. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string section, string key, byte [] value, int offset, int length) { + if (value == null) + return Write(section, key, (string)null); + else + return Write(section, key, Convert.ToBase64String(value, offset, length)); + } + /// Writes a Boolean to the specified key in the specified section. + /// The section to write in. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string section, string key, bool value) { + return Write(section, key, value.ToString()); + } + /// Writes a Boolean to the specified key in the active section. + /// The key to write to. + /// The value to write. + /// Returns true if the function succeeds, false otherwise. + public bool Write(string key, bool value) { + return Write(Section, key, value); + } + /// Deletes a key from the specified section. + /// The section to delete from. + /// The key to delete. + /// Returns true if the function succeeds, false otherwise. + public bool DeleteKey(string section, string key) { + return (WritePrivateProfileString(section, key, null, Filename) != 0); + } + /// Deletes a key from the active section. + /// The key to delete. + /// Returns true if the function succeeds, false otherwise. + public bool DeleteKey(string key) { + return (WritePrivateProfileString(Section, key, null, Filename) != 0); + } + /// Deletes a section from an INI file. + /// The section to delete. + /// Returns true if the function succeeds, false otherwise. + public bool DeleteSection(string section) { + return WritePrivateProfileSection(section, null, Filename) != 0; + } + /// Retrieves a list of all available sections in the INI file. + /// Returns an ArrayList with all available sections. + public ArrayList GetSectionNames() { + try { + byte[] buffer = new byte[MAX_ENTRY]; + GetPrivateProfileSectionNames(buffer, MAX_ENTRY, Filename); + string [] parts = Encoding.ASCII.GetString(buffer).Trim('\0').Split('\0'); + return new ArrayList(parts); + } catch {} + return null; + } + //Private variables and constants + /// + /// Holds the full path to the INI file. + /// + private string m_Filename; + /// + /// Holds the active section name + /// + private string m_Section; + /// + /// The maximum number of bytes in a section buffer. + /// + private const int MAX_ENTRY = 32768; + } +} \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.csproj b/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.csproj new file mode 100644 index 00000000..23c8e55f --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.csproj @@ -0,0 +1,51 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {889E30F7-CFBC-470D-9488-7009C354F9C9} + Library + Properties + IniReader + IniReader + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.csproj.vspscc b/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.csproj.vspscc new file mode 100644 index 00000000..ced93a04 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/IniReader/IniReader.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:Volian.Utils.Library\\IniReader" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/Volian.Utils.Library/IniReader/Properties/AssemblyInfo.cs b/PROMS/proms/Volian.Utils.Library/IniReader/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a5d08ab8 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/IniReader/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IniReader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("IniReader")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0defcd71-3fa3-4b0c-8df0-64ca71984473")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/Volian.Utils.Library/MSWord/MSWord.csproj b/PROMS/proms/Volian.Utils.Library/MSWord/MSWord.csproj new file mode 100644 index 00000000..500de57e --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/MSWord/MSWord.csproj @@ -0,0 +1,77 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {2F79D7F9-885E-4441-99F3-045D7612B2E5} + Library + Properties + MSWord + MSWord + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52} + 2 + 3 + 0 + primary + False + + + {0002E157-0000-0000-C000-000000000046} + 5 + 3 + 0 + primary + False + + + {00020905-0000-0000-C000-000000000046} + 8 + 3 + 0 + primary + False + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/MSWord/MSWord.csproj.vspscc b/PROMS/proms/Volian.Utils.Library/MSWord/MSWord.csproj.vspscc new file mode 100644 index 00000000..a5479473 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/MSWord/MSWord.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:Volian.Utils.Library\\MSWord" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/Volian.Utils.Library/MSWord/Properties/AssemblyInfo.cs b/PROMS/proms/Volian.Utils.Library/MSWord/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..b59c322b --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/MSWord/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MSWord")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("MSWord")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d96766ab-573a-470e-8104-d862880d1cd7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/Volian.Utils.Library/MSWord/WordDoc.cs b/PROMS/proms/Volian.Utils.Library/MSWord/WordDoc.cs new file mode 100644 index 00000000..f2133808 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/MSWord/WordDoc.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Reflection; +using Microsoft.Office.Interop; +using Microsoft.Office.Interop.Word; + +namespace Volian.MSWord +{ + public class WordDoc + { + private object optional = Missing.Value; + private object oFalse = false; + private object oTrue = true; + private object oBlank = ""; + private object oWdStory = WdUnits.wdStory; + private object oWdWord = WdUnits.wdWord; + private object oWdChar = WdUnits.wdCharacter; + private object oWdLine = WdUnits.wdLine; + private object oWdPara = WdUnits.wdParagraph; + private object oWdExtend = WdMovementType.wdExtend; + private object oWdMove = WdMovementType.wdMove; + private object o1 = 1; + private Application m_App; + // Microsoft.Office.Interop.Word.Application App + // { + // get{return m_App;} + // } + private Document m_Doc; + // Microsoft.Office.Interop.Word.Document Doc + // { + // get{return m_Doc;} + // } + private string mDocName; + + public string DocName + { + get { return mDocName; } + set { mDocName = value; } + } + public WordDoc(string sPath) + { + m_App = new ApplicationClass(); + //m_App.Visible = true; + mDocName = sPath; + object oFile = sPath; + m_Doc = m_App.Documents.Open( + ref oFile // FileName + ,ref optional // ConfirmConversions + ,ref optional // ReadOnly + ,ref optional // AddToRecentFiles + ,ref optional // PasswordDocument + ,ref optional // PasswordTemplate + ,ref optional // Revert + ,ref optional // WritePasswordDocument + ,ref optional // WritePasswordTemplate + ,ref optional // Format + ,ref optional // Encoding + ,ref optional // Visible + ,ref optional // OpenAndRepair + ,ref optional // DocumentDirection + ,ref optional // NoEncodingDialog + ,ref optional // XMLTransform + ); + } + //~WordDoc() + //{ + // m_App.Quit(ref oFalse, ref optional, ref optional); + //} + private string SaveDoc() + { + object oFileName = mDocName; + object oFileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocument; + //object oFileFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatFilteredHTML; + object oPassWord = ""; + try + { + m_Doc.SaveAs2000( + ref oFileName // FileName + ,ref oFileFormat // FileFormat + ,ref oFalse // LockComments + ,ref oPassWord // Password + ,ref oFalse // AddToRecentFiles + ,ref oPassWord // WritePassword + ,ref oFalse // ReadOnlyRecommended + ,ref oFalse // EmbedTrueTypeFonts + ,ref oFalse // SaveNativePictureFormat + ,ref oFalse // SaveFormsData + ,ref oFalse // SaveAsAOCELetter + ); + return "Successful Save"; + } + catch (Exception ex) + { + return string.Format("Error during Doc save - {0}", ex.Message); + } + } + public string Save() + { + return SaveDoc(); + } + public string Save(string sPath) + { + mDocName = sPath; + return SaveDoc(); + } + public void Close() + { + m_App.Quit(ref oFalse, ref optional, ref optional); + } + } +} diff --git a/PROMS/proms/Volian.Utils.Library/vlnObject/Properties/AssemblyInfo.cs b/PROMS/proms/Volian.Utils.Library/vlnObject/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7e8b607c --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnObject/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("vlnObject")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("vlnObject")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("456c5324-6f56-478e-8069-b8e8957f5749")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/Volian.Utils.Library/vlnObject/vlnControl.xml b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnControl.xml new file mode 100644 index 00000000..595b0d13 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnControl.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObject.cs b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObject.cs new file mode 100644 index 00000000..3de17358 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObject.cs @@ -0,0 +1,282 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml.Serialization; +using System.Xml; +using System.Xml.Schema; +using System.Collections; +using System.IO; +using System.Text.RegularExpressions; + +namespace vlnObjectLibrary +{ + [Serializable()] + public class vlnObject : IXmlSerializable , IDisposable + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + public void Dispose() + { + /* See if I need to do anything */ + } + #region XML Serialization + public void WriteXml(XmlWriter w) + { + WriteXml(w, true); + } + public void WriteXml(XmlWriter w,bool bSaveParent) + { + w.WriteAttributeString("title", Title); + w.WriteAttributeString("path", Path); + w.WriteAttributeString("type", Type); + if (m_PropArray.Count > 0) + { + w.WriteStartElement("properties"); + foreach (string sKey in m_PropArray.Keys) + { + w.WriteStartElement("property"); + w.WriteAttributeString("name", sKey); + w.WriteAttributeString("value", PropArray[sKey]); + w.WriteEndElement(); + } + w.WriteEndElement(); + } + if (bSaveParent && Parent != null) + { + w.WriteStartElement("parent"); + Parent.WriteXml(w); + w.WriteEndElement(); + } + } + private bool SkipToElement(XmlReader xr) + { + while (xr.Read()) + if (xr.NodeType == XmlNodeType.Element || xr.NodeType == XmlNodeType.EndElement) + return xr.NodeType == XmlNodeType.Element; + return false; + } + public void ReadXml(XmlReader xr) + { + SkipToElement(xr); + if (xr.MoveToAttribute("title")) m_Title = xr.Value; + if (xr.MoveToAttribute("type")) m_Type = xr.Value; + if (xr.MoveToAttribute("path")) m_Path = xr.Value; + while (SkipToElement(xr)) + { + if (xr.NodeType == XmlNodeType.Element && xr.Name == "properties") + while (SkipToElement(xr)) + if (xr.NodeType == XmlNodeType.Element && xr.Name == "property") + AddProp(xr.ReadSubtree()); + if (xr.NodeType == XmlNodeType.Element && xr.Name == "parent") + m_Parent = new vlnObject(xr.ReadSubtree()); + } + xr.Close(); + } + + public XmlSchema GetSchema() + { + return (null); + } + #endregion + #region Constructors + public vlnObject(vlnObject parent, string type, string title, string path) + { + m_Parent = parent; + m_Type = type; + m_Title = title; + m_Path = path; + m_PropArray = new Dictionary(); + } + public vlnObject() + { + m_Parent = null; + m_Title = null; + m_Path = null; + m_Type = null; + m_PropArray = new Dictionary(); + } + public vlnObject(XmlReader xr) + { + m_Parent = null; + m_PropArray = new Dictionary(); + this.ReadXml(xr); + } + public vlnObject(string sXML) + { + m_Parent = null; + m_PropArray = new Dictionary(); + this.ReadXml(new XmlTextReader(new StringReader(sXML))); + } + #endregion + #region Public Properties + private vlnObject m_Parent; + public vlnObject Parent + { + get { return m_Parent; } + set { m_Parent = value; } + } + private string m_Title; + public string Title + { + get { return m_Title; } + set { m_Title = value; } + } + private string m_Path; + public string Path + { + get { return m_Path; } + set { m_Path = value; } + } + private string m_Type; + + public string Type + { + get { return m_Type; } + set { m_Type = value; } + } + private Dictionary m_PropArray; + public Dictionary PropArray + { + get { return m_PropArray; } + set { m_PropArray = value; } + } + #endregion + #region Public Methods + public vlnObject Add(string type, string title, string path) + { + vlnObject b = new vlnObject(this, type, title, path); + return b; + } + public void AddProp(string name, string value) + { + PropArray[name.ToUpper()] = value; + } + public void AddProp(XmlReader xr) + { + SkipToElement(xr); + string sName = null; + string sValue = null; + if (xr.MoveToAttribute("name")) sName = xr.Value; + if (xr.MoveToAttribute("value")) sValue = xr.Value; + if (sName != null && sValue != null) AddProp(sName, sValue); + xr.Close(); + } + public override string ToString() + { + StringWriter swxml = new StringWriter(); + XmlSerializer mySer = new XmlSerializer(this.GetType()); + mySer.Serialize(swxml, this); + return swxml.ToString(); + } + #endregion + private List m_Children; + public List Children + { + get + { + return m_Children; + } + set + { + m_Children = value; + } + } + public void LoadChildren(string sXml) + { + LoadChildren(new XmlTextReader(new StringReader(sXml))); + } + public void LoadChildren(XmlReader xr) + { + m_Children = new List(); + SkipToElement(xr); + while(SkipToElement(xr)){ + vlnObject o = new vlnObject(xr.ReadSubtree()); + o.Parent = this; + m_Children.Add(o); + } + } + public string AllChildren() + { + StringWriter sw = new StringWriter(); + XmlTextWriter xw = new XmlTextWriter(sw); + xw.WriteStartElement("children"); + foreach (vlnObject vb in Children) + { + xw.WriteStartElement("vlnObject"); + vb.WriteXml(xw,false); + xw.WriteEndElement(); + } + xw.WriteEndElement(); + return sw.ToString(); + } + public string ProcessString(string s) + { + //string retval=s; + //string retval = Regex.Replace(s, "{[.]*}", new MatchEvaluator(ReplaceKey)); + string retval = Regex.Replace(s, "{{.*?}}", new MatchEvaluator(ReplaceRow)); + retval = Regex.Replace(retval, "{.*?}", new MatchEvaluator(ReplaceDrv)); + return retval; + } + private string ReplaceRow(Match m) + { + string sResult = FindField(m.Value.Substring(2, m.Value.Length - 4)); + if (sResult == null && Parent != null) + { + sResult = Parent.ReplaceRow(m); + } + if (sResult == null) + { + log.ErrorFormat("vlnObject - Couldn't find {0}", m.Value); + } + return sResult; + } + private string ReplaceDrv(Match m) + { + string sRetVal = FindField(m.Value.Substring(1, m.Value.Length - 2)); + if (sRetVal == null) sRetVal = ""; + return sRetVal; + } + private string FindField(string s) + { + string retval = ""; + string[] parts = s.ToUpper().Split(":".ToCharArray()); + switch (s.ToUpper()) + { + case "PATH": + retval = m_Path; + break; + //case "TITLE": + //retval = m_Title; + //break; + case "TYPE": + retval = m_Type; + break; + default: + if (PropArray.ContainsKey(parts[0])) + { + retval = PropArray[parts[0]].ToString(); + } + else + { + return null; + } + break; + } + if (parts.Length > 1) + { + int width = Convert.ToInt32(parts[1]); + if (parts[1][0] == ' ' || parts[1][0] == '0') + { + retval = retval.PadLeft(width, parts[1][0]); + } + else + { + retval = retval.PadRight(width).Substring(0, width).Trim(); + } + } + return retval; + } + } + +} diff --git a/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObjectLibrary.csproj b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObjectLibrary.csproj new file mode 100644 index 00000000..2e3b9cde --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObjectLibrary.csproj @@ -0,0 +1,60 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {933269F5-C3AD-423E-88EB-133A7333FD6B} + Library + Properties + vlnObject + vlnObject + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\veproms\bin\log4net.dll + + + + + + + + + + + + Always + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObjectLibrary.csproj.vspscc b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObjectLibrary.csproj.vspscc new file mode 100644 index 00000000..0fe73fb0 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnObject/vlnObjectLibrary.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:Volian.Utils.Library\\vlnObject" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/Properties/AssemblyInfo.cs b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..e8848a04 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("vlnServerLibrary")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("vlnServerLibrary")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ca6a9567-282a-427f-9a41-2c205650f3d1")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnControl.xml b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnControl.xml new file mode 100644 index 00000000..595b0d13 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnControl.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs new file mode 100644 index 00000000..12a542c4 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServer.cs @@ -0,0 +1,249 @@ +using System; +using System.Collections.Generic; +using System.Text; +using vlnObjectLibrary; +using System.Xml; +using System.IO; +using System.Data; +using System.Data.OleDb; +using System.Reflection; + +namespace vlnServerLibrary +{ + public class vlnServer // This class loads children for a vlnObject + { + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region Static Properties + private static string m_XmlControlPath; + private static XmlDocument m_XmlControl; + public static string XMLControlPath + { + get { return m_XmlControlPath; } + set + { + m_XmlControlPath = value; + } + } + public static XmlDocument XMLControl + { + get + { + if (m_XmlControl == null) + { + m_XmlControl = new XmlDocument(); + lock (m_XmlControl) + { + XMLControlPath = "vlnControl.xml"; + m_XmlControl.Load(m_XmlControlPath); + } + } + return m_XmlControl; + } + } + #endregion + private List LoadChildren(vlnObject o) + { + o.Children = new List(); + LoadChildrenFromFolders(o);// TODO: Load children based upon directory lookup + LoadChildrenFromDB(o,LookUp(o,"select"));// TODO: Load children based upon select statement + return o.Children; + } + public string GetChildren(string sVlnObject) + { + using (vlnObject o = new vlnObject(sVlnObject)) + { + LoadChildren(o); + return o.AllChildren(); + } + } + public string GetDataPath() + { + vlnObject o = new vlnObject(); + o.Type="datapath"; + o.Title="Data Path"; + o.Path=LookUpX(o,".//default/@datapath"); + return o.ToString(); + } + protected string LookUp(vlnObject o,string s) + { + string xPath = string.Format(".//dbObject[@type='{0}']/@{1}", o.Type, s); + return LookUpX(o,xPath); + } + protected string LookUpP(vlnObject o,string s) + { + string xPath = string.Format(".//dbObject[@type='{0}']/@{1}", o.Parent.Type, s); + return LookUpX(o,xPath); + } + protected string LookUpX(vlnObject o,string xPath) + { + return LookUpX(o,xPath, XMLControl); + } + private void LoadChildrenFromDB(vlnObject o,string sSelect) + { + if (sSelect != "") + { + try + { + string s = LookUpX(o,".//connection/@string"); + OleDbConnectionStringBuilder csb = new OleDbConnectionStringBuilder(s); + OleDbConnection dbConn = new OleDbConnection(csb.ConnectionString); + string sTable = LookUp(o,"table"); + //if (dbConn.State != ConnectionState.Open) dbConn.Open(); + OleDbDataAdapter da = new OleDbDataAdapter(sSelect, dbConn); + DataSet ds = new DataSet(); + da.Fill(ds, sTable); + string srt = LookUp(o,"sort"); + DataView dv = new DataView(ds.Tables[sTable], LookUp(o,"criteria"), LookUp(o,"sort"), DataViewRowState.CurrentRows); + foreach (DataRowView mydrv in dv) + { + vlnObject vb = o.Add(LookUp(o,"child"), "", o.Path); + foreach (DataColumn dc in dv.Table.Columns) + { + vb.AddProp(dc.ColumnName, mydrv[dc.ColumnName].ToString()); + } + vb.Title = LookUpP(vb,"title"); + o.Children.Add(vb); + } + } + catch (Exception ex) + { + log.ErrorFormat("{0}\r\n{1}", ex.Message, ex.InnerException); + } + } + } + public DataSet GetDataSet(vlnObject o, string sSelect) + { + if (sSelect != "") + { + try + { + OleDbConnection dbConn = new OleDbConnection(LookUpX(o, ".//connection/@string")); + OleDbDataAdapter da = new OleDbDataAdapter(sSelect, dbConn); + DataSet ds = new DataSet(); + da.Fill(ds, LookUp(o, "table")); + return ds; + } + catch (Exception ex) + { + log.ErrorFormat("{0}\r\n{1}", ex.Message, ex.InnerException); + } + } + return null; + } + public OleDbDataReader GetDataReader(vlnObject o, string sSelect) + { + if (sSelect != "") + { + OleDbConnection dbConn = new OleDbConnection(LookUpX(o, ".//connection/@string")); + OleDbCommand cmd = new OleDbCommand(sSelect, dbConn); + cmd.CommandType = CommandType.Text; + dbConn.Open(); + OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); + return dr; + } + return null; + } + private void LoadChildrenFromFolders(vlnObject o) + { + // First look in the XML to see if there are any folders for the specified item + XmlNodeList nl = XMLControl.SelectNodes(string.Format(".//dbObject[@type='{0}']/folders/folder", o.Type)); + if (nl.Count != 0) + { + foreach (XmlNode xn in nl) + { + LoadChildrenFromFolder(o,xn); + } + } + } + private void LoadChildrenFromFolder(vlnObject o, XmlNode xn) + { + // First look in the XML to see if there are any folders for the specified item + string sTmp = LookUpX(o,"@template", xn); + if (sTmp != "") + { + string sException = LookUpX(o,"@exception", xn); + string sRequired = LookUpX(o,"@requires", xn); + DirectoryInfo di = new DirectoryInfo(o.Path); + if (sRequired == "" || di.GetFileSystemInfos(sRequired).Length > 0) + { + if (sException == "" || di.GetFileSystemInfos(sException).Length == 0) + { + try + { + if (sTmp == ".") + { + LoadChildrenFromFolder(o, xn, di); + } + else + { + if(sTmp.Contains("\\")){ + string[] sTmps = sTmp.Split('\\'); + DirectoryInfo [] dis = di.GetDirectories(sTmps[0]); + foreach (DirectoryInfo di2 in dis) + { + foreach (FileSystemInfo di3 in di2.GetFileSystemInfos(sTmps[1])) + { + LoadChildrenFromFolder(o, xn, di3); + } + } + } + else + { + foreach (FileSystemInfo di1 in di.GetFileSystemInfos(sTmp)) + { + LoadChildrenFromFolder(o, xn, di1); + } + } + } + } + catch (DirectoryNotFoundException ex) + { + // Ignore this exception + log.InfoFormat("Directory {0} Template {1} Error {2}",di, sTmp,ex.Message); + } + catch (Exception ex) + { + log.ErrorFormat("Error: {0}\r\n{1}", ex.Message, ex.InnerException); + } + } + } + } + } + private void LoadChildrenFromFolder(vlnObject o,XmlNode xn, FileSystemInfo fi) + { + vlnObject vb = o.Add(LookUpX(o,"@child", xn), "", fi.FullName); + vb.AddProp("filename", fi.Name); + vb.Title = GetTitle(fi.FullName, LookUpX(vb,"@title", xn)); + o.Children.Add(vb); + } + protected string GetTitle(string sPath, string sDefault) + { + string sRetval = sDefault; + if (sRetval[0] == '~') + { + string sTitlePath = sPath + "\\title"; + if (File.Exists(sTitlePath)) + { + StreamReader sr = File.OpenText(sTitlePath); + return sr.ReadToEnd(); + } + sRetval = sRetval.Substring(1); + } + return sRetval; + } + protected string LookUpX(vlnObject o, string xPath, XmlNode xn) + { + XmlNode nd = xn; + XmlNode ndf = nd.SelectSingleNode(xPath); + while (ndf == null && nd.ParentNode != null) + { + nd = nd.ParentNode; + ndf = nd.SelectSingleNode(xPath); + } + if (ndf == null) return ""; + return o.ProcessString(ndf.InnerText); + } + } +} diff --git a/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServerLibrary.csproj b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServerLibrary.csproj new file mode 100644 index 00000000..fd7bbd54 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServerLibrary.csproj @@ -0,0 +1,64 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2} + Library + Properties + vlnServerLibrary + vlnServerLibrary + SAK + SAK + SAK + SAK + + + true + full + false + ..\..\..\..\..\veproms\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\..\..\veproms\bin\log4net.dll + + + + + + False + ..\..\..\..\..\veproms\bin\vlnObject.dll + + + + + + + + + PreserveNewest + + + + + \ No newline at end of file diff --git a/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServerLibrary.csproj.vspscc b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServerLibrary.csproj.vspscc new file mode 100644 index 00000000..fa5e8e94 --- /dev/null +++ b/PROMS/proms/Volian.Utils.Library/vlnServerLibrary/vlnServerLibrary.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:Volian.Utils.Library\\vlnServerLibrary" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/proms/proms.sln b/PROMS/proms/proms.sln new file mode 100644 index 00000000..2c2f0d5b --- /dev/null +++ b/PROMS/proms/proms.sln @@ -0,0 +1,102 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLoader", "DataLoader\DataLoader.csproj", "{8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volian.Controls.Library", "Volian.Controls.Library\Volian.Controls.Library.csproj", "{8556527C-6615-487F-8AF7-22EBC3EF0268}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Volian.Utils.Library", "Volian.Utils.Library", "{5A0EDD18-70A4-4D5E-93CC-39F4D246352A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IniReader", "Volian.Utils.Library\IniReader\IniReader.csproj", "{889E30F7-CFBC-470D-9488-7009C354F9C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSWord", "Volian.Utils.Library\MSWord\MSWord.csproj", "{2F79D7F9-885E-4441-99F3-045D7612B2E5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vlnObjectLibrary", "Volian.Utils.Library\vlnObject\vlnObjectLibrary.csproj", "{933269F5-C3AD-423E-88EB-133A7333FD6B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vlnServerLibrary", "Volian.Utils.Library\vlnServerLibrary\vlnServerLibrary.csproj", "{F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "veproms", "veproms\veproms.csproj", "{0D8723B4-51DD-486A-A5E1-8D55BB526690}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volian.CSLA.Library", "Volian.CSLA.Library\Volian.CSLA.Library.csproj", "{3C162BD7-5DBC-45A6-90D8-9391AC8CD0FD}" +EndProject +Global + GlobalSection(SourceCodeControl) = preSolution + SccNumberOfProjects = 9 + SccLocalPath0 = . + SccProjectUniqueName1 = DataLoader\\DataLoader.csproj + SccLocalPath1 = . + SccProjectFilePathRelativizedFromConnection1 = DataLoader\\ + SccProjectUniqueName2 = veproms\\veproms.csproj + SccLocalPath2 = . + SccProjectFilePathRelativizedFromConnection2 = veproms\\ + SccProjectUniqueName3 = Volian.Controls.Library\\Volian.Controls.Library.csproj + SccLocalPath3 = . + SccProjectFilePathRelativizedFromConnection3 = Volian.Controls.Library\\ + SccProjectUniqueName4 = Volian.CSLA.Library\\Volian.CSLA.Library.csproj + SccLocalPath4 = . + SccProjectFilePathRelativizedFromConnection4 = Volian.CSLA.Library\\ + SccProjectUniqueName5 = Volian.Utils.Library\\IniReader\\IniReader.csproj + SccProjectTopLevelParentUniqueName5 = proms.sln + SccLocalPath5 = . + SccProjectFilePathRelativizedFromConnection5 = Volian.Utils.Library\\IniReader\\ + SccProjectUniqueName6 = Volian.Utils.Library\\MSWord\\MSWord.csproj + SccProjectTopLevelParentUniqueName6 = proms.sln + SccLocalPath6 = . + SccProjectFilePathRelativizedFromConnection6 = Volian.Utils.Library\\MSWord\\ + SccProjectUniqueName7 = Volian.Utils.Library\\vlnObject\\vlnObjectLibrary.csproj + SccProjectTopLevelParentUniqueName7 = proms.sln + SccLocalPath7 = . + SccProjectFilePathRelativizedFromConnection7 = Volian.Utils.Library\\vlnObject\\ + SccProjectUniqueName8 = Volian.Utils.Library\\vlnServerLibrary\\vlnServerLibrary.csproj + SccProjectTopLevelParentUniqueName8 = proms.sln + SccLocalPath8 = . + SccProjectFilePathRelativizedFromConnection8 = Volian.Utils.Library\\vlnServerLibrary\\ + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}.Release|Any CPU.Build.0 = Release|Any CPU + {8556527C-6615-487F-8AF7-22EBC3EF0268}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8556527C-6615-487F-8AF7-22EBC3EF0268}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8556527C-6615-487F-8AF7-22EBC3EF0268}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8556527C-6615-487F-8AF7-22EBC3EF0268}.Release|Any CPU.Build.0 = Release|Any CPU + {889E30F7-CFBC-470D-9488-7009C354F9C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {889E30F7-CFBC-470D-9488-7009C354F9C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {889E30F7-CFBC-470D-9488-7009C354F9C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {889E30F7-CFBC-470D-9488-7009C354F9C9}.Release|Any CPU.Build.0 = Release|Any CPU + {2F79D7F9-885E-4441-99F3-045D7612B2E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F79D7F9-885E-4441-99F3-045D7612B2E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F79D7F9-885E-4441-99F3-045D7612B2E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F79D7F9-885E-4441-99F3-045D7612B2E5}.Release|Any CPU.Build.0 = Release|Any CPU + {933269F5-C3AD-423E-88EB-133A7333FD6B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {933269F5-C3AD-423E-88EB-133A7333FD6B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {933269F5-C3AD-423E-88EB-133A7333FD6B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {933269F5-C3AD-423E-88EB-133A7333FD6B}.Release|Any CPU.Build.0 = Release|Any CPU + {F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2}.Release|Any CPU.Build.0 = Release|Any CPU + {0D8723B4-51DD-486A-A5E1-8D55BB526690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D8723B4-51DD-486A-A5E1-8D55BB526690}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D8723B4-51DD-486A-A5E1-8D55BB526690}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D8723B4-51DD-486A-A5E1-8D55BB526690}.Release|Any CPU.Build.0 = Release|Any CPU + {3C162BD7-5DBC-45A6-90D8-9391AC8CD0FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C162BD7-5DBC-45A6-90D8-9391AC8CD0FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C162BD7-5DBC-45A6-90D8-9391AC8CD0FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C162BD7-5DBC-45A6-90D8-9391AC8CD0FD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {889E30F7-CFBC-470D-9488-7009C354F9C9} = {5A0EDD18-70A4-4D5E-93CC-39F4D246352A} + {2F79D7F9-885E-4441-99F3-045D7612B2E5} = {5A0EDD18-70A4-4D5E-93CC-39F4D246352A} + {933269F5-C3AD-423E-88EB-133A7333FD6B} = {5A0EDD18-70A4-4D5E-93CC-39F4D246352A} + {F9B53DDC-2A2E-4A17-B777-4EC0EE585DE2} = {5A0EDD18-70A4-4D5E-93CC-39F4D246352A} + EndGlobalSection +EndGlobal diff --git a/PROMS/proms/proms.vssscc b/PROMS/proms/proms.vssscc new file mode 100644 index 00000000..6cb031bc --- /dev/null +++ b/PROMS/proms/proms.vssscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/PROMS/proms/veproms/Form1.Designer.cs b/PROMS/proms/veproms/Form1.Designer.cs new file mode 100644 index 00000000..b0168d90 --- /dev/null +++ b/PROMS/proms/veproms/Form1.Designer.cs @@ -0,0 +1,39 @@ +namespace veproms +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/PROMS/proms/veproms/Form1.cs b/PROMS/proms/veproms/Form1.cs new file mode 100644 index 00000000..dba16694 --- /dev/null +++ b/PROMS/proms/veproms/Form1.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace veproms +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/PROMS/proms/veproms/Program.cs b/PROMS/proms/veproms/Program.cs new file mode 100644 index 00000000..1cbda2fc --- /dev/null +++ b/PROMS/proms/veproms/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace veproms +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} \ No newline at end of file diff --git a/PROMS/proms/veproms/Properties/AssemblyInfo.cs b/PROMS/proms/veproms/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..82236733 --- /dev/null +++ b/PROMS/proms/veproms/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("veproms")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Volian Enterprises, Inc.")] +[assembly: AssemblyProduct("veproms")] +[assembly: AssemblyCopyright("Copyright © Volian Enterprises, Inc. 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("da84d5e7-846b-48e7-b952-6aeb39abf576")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/proms/veproms/Properties/Resources.Designer.cs b/PROMS/proms/veproms/Properties/Resources.Designer.cs new file mode 100644 index 00000000..a796edad --- /dev/null +++ b/PROMS/proms/veproms/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace veproms.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("veproms.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/PROMS/proms/veproms/Properties/Resources.resx b/PROMS/proms/veproms/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/PROMS/proms/veproms/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/proms/veproms/Properties/Settings.Designer.cs b/PROMS/proms/veproms/Properties/Settings.Designer.cs new file mode 100644 index 00000000..6de23628 --- /dev/null +++ b/PROMS/proms/veproms/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace veproms.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/PROMS/proms/veproms/Properties/Settings.settings b/PROMS/proms/veproms/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/PROMS/proms/veproms/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/PROMS/proms/veproms/veproms.csproj b/PROMS/proms/veproms/veproms.csproj new file mode 100644 index 00000000..9f26217a --- /dev/null +++ b/PROMS/proms/veproms/veproms.csproj @@ -0,0 +1,78 @@ + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {0D8723B4-51DD-486A-A5E1-8D55BB526690} + WinExe + Properties + veproms + veproms + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + \ No newline at end of file diff --git a/PROMS/proms/veproms/veproms.csproj.vspscc b/PROMS/proms/veproms/veproms.csproj.vspscc new file mode 100644 index 00000000..2fecc8d8 --- /dev/null +++ b/PROMS/proms/veproms/veproms.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:veproms" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +}