This commit is contained in:
71
PROMS/proms/DataLoader/App.config
Normal file
71
PROMS/proms/DataLoader/App.config
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
</configSections>
|
||||
<log4net>
|
||||
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
|
||||
<param name="File" value="Log4Net.txt" />
|
||||
<param name="AppendToFile" value="false" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="Header" value="[Header]\r\n" />
|
||||
<param name="Footer" value="[Footer]\r\n" />
|
||||
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="--> %date [%thread] %-5level %logger (%property{log4net:HostName}) [%ndc] - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
|
||||
<threshold value="WARN" />
|
||||
<mapping>
|
||||
<level value="DEBUG" />
|
||||
<eventLogEntryType value="Information" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="INFO" />
|
||||
<eventLogEntryType value="Information" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="WARN" />
|
||||
<eventLogEntryType value="Warning" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="ERROR" />
|
||||
<eventLogEntryType value="Error" />
|
||||
</mapping>
|
||||
<mapping>
|
||||
<level value="FATAL" />
|
||||
<eventLogEntryType value="Error" />
|
||||
</mapping>
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<param name="ConversionPattern" value="---> %d [%t] %-5p %c - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="ALL" />
|
||||
<appender-ref ref="ConsoleAppender" />
|
||||
<appender-ref ref="LogFileAppender" />
|
||||
<appender-ref ref="EventLogAppender" />
|
||||
</root>
|
||||
<logger name="Volian.CSLA.Library">
|
||||
<level value="WARN" />
|
||||
</logger>
|
||||
</log4net>
|
||||
<appSettings>
|
||||
<add key="CslaAuthentication" value="Windows" />
|
||||
<!-- Active Connection -->
|
||||
<!-- Inactive Connections
|
||||
-->
|
||||
</appSettings>
|
||||
<connectionStrings>
|
||||
<!--<add name="VEPROMS"
|
||||
connectionString="Data Source=rhmdesktop\SQLEXPRESS;AttachDbFilename="C:\VS2005Projects\VEPROMS_USERS\VEPROMS_Users.mdf";Integrated Security=True;User Instance=True"
|
||||
providerName="System.Data.SqlClient" />-->
|
||||
<add name="VEPROMS"
|
||||
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=VEPROMS;Integrated Security=True"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
</configuration>
|
||||
1
PROMS/proms/DataLoader/ClassDiagram1.cd
Normal file
1
PROMS/proms/DataLoader/ClassDiagram1.cd
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
79
PROMS/proms/DataLoader/ConfigInfo.cs
Normal file
79
PROMS/proms/DataLoader/ConfigInfo.cs
Normal file
@@ -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("<config/>");
|
||||
else
|
||||
xmldoc.LoadXml(xml);
|
||||
}
|
||||
|
||||
public ConfigInfo(string xml, string ename, string aname, string avalue)
|
||||
{
|
||||
xmldoc = new XmlDocument();
|
||||
if (xml == null)
|
||||
xmldoc.LoadXml("<config/>");
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
110
PROMS/proms/DataLoader/CurSet.cs
Normal file
110
PROMS/proms/DataLoader/CurSet.cs
Normal file
@@ -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>
|
||||
/// Summary description for CurSet.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
166
PROMS/proms/DataLoader/DataLoader.csproj
Normal file
166
PROMS/proms/DataLoader/DataLoader.csproj
Normal file
@@ -0,0 +1,166 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{8E239A2B-B38C-4CD5-BA0D-A41A88BD2AEE}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>DataLoader</RootNamespace>
|
||||
<AssemblyName>DataLoader</AssemblyName>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\veproms\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Csla, Version=2.0.3.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\Csla.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IniReader, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\IniReader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MSWord, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\MSWord.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="vlnObject, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\vlnObject.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="vlnServerLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\vlnServerLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Volian.CSLA.Library, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\veproms\bin\Volian.CSLA.Library.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigInfo.cs" />
|
||||
<Compile Include="CurSet.cs" />
|
||||
<Compile Include="FolderTreeNode.cs" />
|
||||
<Compile Include="Documents.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmLoader.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="frmLoader.Designer.cs">
|
||||
<DependentUpon>frmLoader.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GroupProp.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="GroupProp.Designer.cs">
|
||||
<DependentUpon>GroupProp.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LibDoc.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LoadConfig.cs">
|
||||
</Compile>
|
||||
<Compile Include="LoadTreeNh.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PrivateProfile.cs" />
|
||||
<Compile Include="Procedures.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="frmLoader.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>frmLoader.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="GroupProp.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>GroupProp.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="App.config" />
|
||||
<None Include="ClassDiagram1.cd" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="RefObjs.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ROFST.cs" />
|
||||
<Compile Include="SecObj.cs">
|
||||
</Compile>
|
||||
<Compile Include="Sections.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Steps.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Structures.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TextConvert.cs" />
|
||||
<Compile Include="Transitions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="LoadTreeDB.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DocVersions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
10
PROMS/proms/DataLoader/DataLoader.csproj.vspscc
Normal file
10
PROMS/proms/DataLoader/DataLoader.csproj.vspscc
Normal file
@@ -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"
|
||||
}
|
||||
61
PROMS/proms/DataLoader/DocVersions.cs
Normal file
61
PROMS/proms/DataLoader/DocVersions.cs
Normal file
@@ -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<string, int>();
|
||||
dicTrans_StrIds = new Dictionary<string, int>();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
114
PROMS/proms/DataLoader/Documents.cs
Normal file
114
PROMS/proms/DataLoader/Documents.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
110
PROMS/proms/DataLoader/FolderTreeNode.cs
Normal file
110
PROMS/proms/DataLoader/FolderTreeNode.cs
Normal file
@@ -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<int, FolderTreeNode> _findTree = null;
|
||||
private Dictionary<int, FolderTreeNode> 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<int, FolderTreeNode> dicMissing = new Dictionary<int, FolderTreeNode>();
|
||||
Dictionary<int, FolderTreeNode> dicExists = new Dictionary<int, FolderTreeNode>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
110
PROMS/proms/DataLoader/GroupProp.Designer.cs
generated
Normal file
110
PROMS/proms/DataLoader/GroupProp.Designer.cs
generated
Normal file
@@ -0,0 +1,110 @@
|
||||
namespace DataLoader
|
||||
{
|
||||
partial class GroupProp
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
45
PROMS/proms/DataLoader/GroupProp.cs
Normal file
45
PROMS/proms/DataLoader/GroupProp.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
PROMS/proms/DataLoader/GroupProp.resx
Normal file
120
PROMS/proms/DataLoader/GroupProp.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
153
PROMS/proms/DataLoader/LibDoc.cs
Normal file
153
PROMS/proms/DataLoader/LibDoc.cs
Normal file
@@ -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<string, int> dicLibDocSect = new Dictionary<string, int>();
|
||||
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<string, int>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
198
PROMS/proms/DataLoader/LoadConfig.cs
Normal file
198
PROMS/proms/DataLoader/LoadConfig.cs
Normal file
@@ -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<string> listIni_EleName = new List<string>();
|
||||
public List<string> listIni_AttrName = new List<string>();
|
||||
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");
|
||||
|
||||
// <user>.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");
|
||||
|
||||
// <user>.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
|
||||
}
|
||||
}
|
||||
111
PROMS/proms/DataLoader/LoadTreeDB.cs
Normal file
111
PROMS/proms/DataLoader/LoadTreeDB.cs
Normal file
@@ -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<Folder> vlnDataPathFolders() // was vlnDataPath
|
||||
{
|
||||
List<Folder> dpf = new List<Folder>();
|
||||
// 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<vlnObject> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
PROMS/proms/DataLoader/LoadTreeNh.cs
Normal file
43
PROMS/proms/DataLoader/LoadTreeNh.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
274
PROMS/proms/DataLoader/PrivateProfile.cs
Normal file
274
PROMS/proms/DataLoader/PrivateProfile.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// PrivateProfile opens a private profile string and stores it's contents in an xml document.
|
||||
/// </summary>
|
||||
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<string> attr;
|
||||
private List<string> 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("<ConfigInfo/>");// 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<string> listIni_EleName, List<string> 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<nd.Attributes.Count;i++)
|
||||
{
|
||||
retval=retval + " " + nd.Attributes.Item(i).Name + "='" + nd.Attributes.Item(i).Value + "'";
|
||||
}
|
||||
retval=retval+">";
|
||||
for(int i=0;i<nd.ChildNodes.Count;i++)
|
||||
{
|
||||
retval=retval+"\r\n"+PrettyNode(nd.ChildNodes.Item(i),level+1);
|
||||
}
|
||||
retval=retval+"\r\n" + prefix + "</" + nd.Name + ">";
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = prefix + "<" + nd.Name;
|
||||
for(int i=0;i<nd.Attributes.Count;i++)
|
||||
{
|
||||
retval=retval + " " + nd.Attributes.Item(i).Name + "='" + nd.Attributes.Item(i).Value + "'";
|
||||
}
|
||||
retval=retval+"/>";
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
189
PROMS/proms/DataLoader/Procedures.cs
Normal file
189
PROMS/proms/DataLoader/Procedures.cs
Normal file
@@ -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<object, string>();
|
||||
Stack<int> SubSectLevels = new Stack<int>(); // 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<int, int> dicSecCount = new Dictionary<int, int>();
|
||||
Dictionary<int, int> dicSecID = new Dictionary<int, int>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
PROMS/proms/DataLoader/Program.cs
Normal file
21
PROMS/proms/DataLoader/Program.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
//<summary>
|
||||
//The main entry point for the application.
|
||||
//</summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new frmLoader());
|
||||
}
|
||||
}
|
||||
}
|
||||
33
PROMS/proms/DataLoader/Properties/AssemblyInfo.cs
Normal file
33
PROMS/proms/DataLoader/Properties/AssemblyInfo.cs
Normal file
@@ -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")]
|
||||
63
PROMS/proms/DataLoader/Properties/Resources.Designer.cs
generated
Normal file
63
PROMS/proms/DataLoader/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DataLoader.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
PROMS/proms/DataLoader/Properties/Resources.resx
Normal file
117
PROMS/proms/DataLoader/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
PROMS/proms/DataLoader/Properties/Settings.Designer.cs
generated
Normal file
26
PROMS/proms/DataLoader/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
PROMS/proms/DataLoader/Properties/Settings.settings
Normal file
7
PROMS/proms/DataLoader/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
251
PROMS/proms/DataLoader/ROFST.cs
Normal file
251
PROMS/proms/DataLoader/ROFST.cs
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
92
PROMS/proms/DataLoader/RefObjs.cs
Normal file
92
PROMS/proms/DataLoader/RefObjs.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
913
PROMS/proms/DataLoader/SecObj.cs
Normal file
913
PROMS/proms/DataLoader/SecObj.cs
Normal file
@@ -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>
|
||||
/// Summary description for Security.
|
||||
/// </summary>
|
||||
///
|
||||
#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<ProcOptions> poList = new List<ProcOptions>();
|
||||
|
||||
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<ushort, ProcSet> psDic = new Dictionary<ushort,ProcSet>();
|
||||
|
||||
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<PlantOptions> PlantOpts = new List<PlantOptions>();
|
||||
|
||||
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<Plant> plntList = new List<Plant>();
|
||||
List<OldUser> userList = new List<OldUser>();
|
||||
Dictionary<ushort, Plant> plntDic = new Dictionary<ushort, Plant>();
|
||||
|
||||
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<ushort, Plant> 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<OldUser> 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<ushort, Plant> plntDic = new Dictionary<ushort, Plant>();
|
||||
List<OldUser> userList = new List<OldUser>();
|
||||
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<ushort, Plant> plntDic, List<OldUser> 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<int, Role> AddDefaultRoles()
|
||||
{
|
||||
Dictionary<int, Role> rdic = new Dictionary<int, Role>();
|
||||
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<ushort, Plant> 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<string> folderlist = new List<string>();
|
||||
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<string, int> LoadFolders()
|
||||
{
|
||||
FolderInfoList fldlist = FolderInfoList.Get();
|
||||
Dictionary<string, int> fdic = new Dictionary<string, int>();
|
||||
foreach (FolderInfo fi in fldlist)
|
||||
{
|
||||
fdic.Add(fi.Title.ToUpper(), fi.FolderID);
|
||||
}
|
||||
return fdic;
|
||||
}
|
||||
|
||||
private bool TranslateToNew(VESamOpt vso, Dictionary<ushort, Plant> plntDic, List<OldUser> userList)
|
||||
{
|
||||
Dictionary<int, Role> 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<int, List<int>> dic, int folderId, int roleId)
|
||||
{
|
||||
if (!dic.ContainsKey(folderId)) dic[folderId] = new List<int>();
|
||||
dic[folderId].Add(roleId);
|
||||
}
|
||||
private void AddUsrGrpAsgnRecs(Dictionary<ushort, Plant> plntDic, List<OldUser> userList)
|
||||
{
|
||||
Dictionary<string, List<string>> dicGroups = new Dictionary<string, List<string>>();
|
||||
Dictionary<string, int> dicGroupIds = new Dictionary<string, int>();
|
||||
Dictionary<string, int> dicOldFolders = new Dictionary<string, int>();
|
||||
int oldFolderCount = 1;
|
||||
dicOldFolders.Add("system", oldFolderCount++);
|
||||
Dictionary<string, int> dicNewFolders = LoadFolders();
|
||||
List<string> lstVersions = new List<string>();
|
||||
StringBuilder sb;
|
||||
OldUser frst = userList[0];
|
||||
|
||||
string[] accessLevel = { "", "\"Guest\"", "\"Reviewer\"", "\"Writer\"", "\"Admin\"", "\"Admin\"" };
|
||||
foreach (OldUser usr in userList)
|
||||
{
|
||||
int sysAccess = 5;
|
||||
Dictionary<PlantOptions, int> plantAccess = new Dictionary<PlantOptions, int>();
|
||||
|
||||
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<int, List<int>> accessRights = new Dictionary<int, List<int>>();
|
||||
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<string>();
|
||||
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<string, int> 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
|
||||
}
|
||||
383
PROMS/proms/DataLoader/Sections.cs
Normal file
383
PROMS/proms/DataLoader/Sections.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
307
PROMS/proms/DataLoader/Steps.cs
Normal file
307
PROMS/proms/DataLoader/Steps.cs
Normal file
@@ -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<string, Step> dicStep = new Dictionary<string, Step>();
|
||||
dicStep[drv["CSequence"].ToString()] = stp;
|
||||
Dictionary<string, Dictionary<string, int>> dicStruct = new Dictionary<string, Dictionary<string, int>>();
|
||||
Dictionary<string, int> dicBase = new Dictionary<string, int>();
|
||||
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<string,int> 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<string, int>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
PROMS/proms/DataLoader/Structures.cs
Normal file
70
PROMS/proms/DataLoader/Structures.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
PROMS/proms/DataLoader/TextConvert.cs
Normal file
120
PROMS/proms/DataLoader/TextConvert.cs
Normal file
@@ -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<int, int> dicChar;
|
||||
public static void BuildDictionarySeq()
|
||||
{
|
||||
dicChar = new Dictionary<int, int>();
|
||||
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<int, int>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
139
PROMS/proms/DataLoader/Transitions.cs
Normal file
139
PROMS/proms/DataLoader/Transitions.cs
Normal file
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
382
PROMS/proms/DataLoader/frmLoader.Designer.cs
generated
Normal file
382
PROMS/proms/DataLoader/frmLoader.Designer.cs
generated
Normal file
@@ -0,0 +1,382 @@
|
||||
namespace DataLoader
|
||||
{
|
||||
partial class frmLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
416
PROMS/proms/DataLoader/frmLoader.cs
Normal file
416
PROMS/proms/DataLoader/frmLoader.cs
Normal file
@@ -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<string, int> 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<string, int> dicTrans_StrDone;
|
||||
private Dictionary<string, int> dicTrans_StrIds;
|
||||
private Dictionary<object, string> dicOldStepSequence;
|
||||
private Dictionary<TreeNode, TreeNode> 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<TreeNode, TreeNode>();
|
||||
}
|
||||
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<Folder> lfldr = vlnDataPathFolders();
|
||||
|
||||
List<vlnObject> dp2 = new List<vlnObject>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
123
PROMS/proms/DataLoader/frmLoader.resx
Normal file
123
PROMS/proms/DataLoader/frmLoader.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="fbd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
329
PROMS/proms/Volian.CSLA.Library/Config/FolderConfig.cs
Normal file
329
PROMS/proms/Volian.CSLA.Library/Config/FolderConfig.cs
Normal file
@@ -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 = "<config/>";
|
||||
_Xp = new XMLProperties(xml);
|
||||
}
|
||||
public FolderConfig()
|
||||
{
|
||||
_Xp = new XMLProperties();
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
string s = _Xp.ToString();
|
||||
if (s == "<config/>" || s == "<config></config>") 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
|
||||
}
|
||||
}
|
||||
127
PROMS/proms/Volian.CSLA.Library/Config/XMLProperties.cs
Normal file
127
PROMS/proms/Volian.CSLA.Library/Config/XMLProperties.cs
Normal file
@@ -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("<config/>");
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
31
PROMS/proms/Volian.CSLA.Library/Extension/DocVersionExt.cs
Normal file
31
PROMS/proms/Volian.CSLA.Library/Extension/DocVersionExt.cs
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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<DocVersionInfo>, 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
|
||||
}
|
||||
}
|
||||
44
PROMS/proms/Volian.CSLA.Library/Extension/FolderExt.cs
Normal file
44
PROMS/proms/Volian.CSLA.Library/Extension/FolderExt.cs
Normal file
@@ -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<Folder>
|
||||
{
|
||||
#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
|
||||
}
|
||||
}
|
||||
30
PROMS/proms/Volian.CSLA.Library/Extension/FolderInfoExt.cs
Normal file
30
PROMS/proms/Volian.CSLA.Library/Extension/FolderInfoExt.cs
Normal file
@@ -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<FolderInfo>, 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
|
||||
}
|
||||
}
|
||||
@@ -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<ProcedureInfo>, 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
|
||||
}
|
||||
}
|
||||
@@ -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<ProcedureInfoList, ProcedureInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
public static ProcedureInfoList Get(int StructureID)
|
||||
{
|
||||
return DataPortal.Fetch<ProcedureInfoList>(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
|
||||
}
|
||||
}
|
||||
86
PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoExt.cs
Normal file
86
PROMS/proms/Volian.CSLA.Library/Extension/SectionInfoExt.cs
Normal file
@@ -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<SectionInfo>, IVEReadOnlyItem
|
||||
{
|
||||
#region Business Methods
|
||||
private string _PPath = string.Empty;
|
||||
/// <summary>
|
||||
/// Required to build tree PPath is the Parent Path calculated with a recursive query
|
||||
/// </summary>
|
||||
public string PPath
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _PPath;
|
||||
}
|
||||
}
|
||||
private string _Path = string.Empty;
|
||||
/// <summary>
|
||||
/// Required to build tree Path is the Current Path calculated with a recursive query
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// This loads the SectionInfo Record and adds the Path and PPath fields
|
||||
/// </summary>
|
||||
/// <param name="dr"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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<SectionInfoList, SectionInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Get SectionInfoList based upon starting Structure ID
|
||||
/// </summary>
|
||||
/// <param name="StructureID">Starting structureID</param>
|
||||
/// <returns></returns>
|
||||
public static SectionInfoList Get(int StructureID)
|
||||
{
|
||||
return DataPortal.Fetch<SectionInfoList>(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
|
||||
}
|
||||
}
|
||||
797
PROMS/proms/Volian.CSLA.Library/Generated/Assignment.cs
Normal file
797
PROMS/proms/Volian.CSLA.Library/Generated/Assignment.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Assignment Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Assignment : BusinessBase<Assignment>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Assignment</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Assignment.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Assignment</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Assignment>();
|
||||
}
|
||||
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<Assignment>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
158
PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfo.cs
Normal file
158
PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// AssignmentInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class AssignmentInfo : ReadOnlyBase<AssignmentInfo>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current AssignmentInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check AssignmentInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current AssignmentInfo</returns>
|
||||
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
|
||||
214
PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfoList.cs
Normal file
214
PROMS/proms/Volian.CSLA.Library/Generated/AssignmentInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// AssignmentInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class AssignmentInfoList : ReadOnlyListBase<AssignmentInfoList, AssignmentInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static AssignmentInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<AssignmentInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static AssignmentInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<AssignmentInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static AssignmentInfoList GetByFolder(int folderID)
|
||||
{
|
||||
return DataPortal.Fetch<AssignmentInfoList>(new FolderCriteria(folderID));
|
||||
}
|
||||
public static AssignmentInfoList GetByGroup(int gid)
|
||||
{
|
||||
return DataPortal.Fetch<AssignmentInfoList>(new GroupCriteria(gid));
|
||||
}
|
||||
public static AssignmentInfoList GetByRole(int rid)
|
||||
{
|
||||
return DataPortal.Fetch<AssignmentInfoList>(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
|
||||
792
PROMS/proms/Volian.CSLA.Library/Generated/Connection.cs
Normal file
792
PROMS/proms/Volian.CSLA.Library/Generated/Connection.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Connection Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Connection : BusinessBase<Connection>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 SQL Server
|
||||
/// </summary>
|
||||
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();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Connection</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Connection.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Connection</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ConnectionString, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ServerType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ConnectionString, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ServerType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Connection>();
|
||||
}
|
||||
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<Connection>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
432
PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolder.cs
Normal file
432
PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolder.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ConnectionFolder Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ConnectionFolder : BusinessBase<ConnectionFolder>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// {child Folders.FolderID}
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current ConnectionFolder</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _FolderID;
|
||||
}
|
||||
// TODO: Replace base ConnectionFolder.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ConnectionFolder</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
137
PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolders.cs
Normal file
137
PROMS/proms/Volian.CSLA.Library/Generated/ConnectionFolders.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ConnectionFolders Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ConnectionFolders : BusinessListBase<ConnectionFolders, ConnectionFolder>
|
||||
{
|
||||
#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
|
||||
187
PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfo.cs
Normal file
187
PROMS/proms/Volian.CSLA.Library/Generated/ConnectionInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ConnectionInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ConnectionInfo : ReadOnlyBase<ConnectionInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 SQL Server
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of Folder for this Connection
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ConnectionInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check ConnectionInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current ConnectionInfo</returns>
|
||||
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
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ConnectionInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ConnectionInfoList : ReadOnlyListBase<ConnectionInfoList, ConnectionInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static ConnectionInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<ConnectionInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static ConnectionInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<ConnectionInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
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
|
||||
124
PROMS/proms/Volian.CSLA.Library/Generated/Database.cs
Normal file
124
PROMS/proms/Volian.CSLA.Library/Generated/Database.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Database Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[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 <mdf 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
|
||||
793
PROMS/proms/Volian.CSLA.Library/Generated/DocVersion.cs
Normal file
793
PROMS/proms/Volian.CSLA.Library/Generated/DocVersion.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// DocVersion Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class DocVersion : BusinessBase<DocVersion>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current DocVersion</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check DocVersion.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current DocVersion</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
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<DocVersion>();
|
||||
}
|
||||
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<DocVersion>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
172
PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfo.cs
Normal file
172
PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// DocVersionInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class DocVersionInfo : ReadOnlyBase<DocVersionInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current DocVersionInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check DocVersionInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current DocVersionInfo</returns>
|
||||
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
|
||||
122
PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfoList.cs
Normal file
122
PROMS/proms/Volian.CSLA.Library/Generated/DocVersionInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// DocVersionInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class DocVersionInfoList : ReadOnlyListBase<DocVersionInfoList, DocVersionInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static DocVersionInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<DocVersionInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static DocVersionInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<DocVersionInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static DocVersionInfoList GetByFolder(int folderID)
|
||||
{
|
||||
return DataPortal.Fetch<DocVersionInfoList>(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
|
||||
729
PROMS/proms/Volian.CSLA.Library/Generated/Document.cs
Normal file
729
PROMS/proms/Volian.CSLA.Library/Generated/Document.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Document Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Document : BusinessBase<Document>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// Actual content of a Word Document (RTF, DOC or XML Format)
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Used for searching
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Document</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Document.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Document</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(LibTitle, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DocContent, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DocAscii, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(LibTitle, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DocContent, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DocAscii, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
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<Document>();
|
||||
}
|
||||
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<Document>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
153
PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfo.cs
Normal file
153
PROMS/proms/Volian.CSLA.Library/Generated/DocumentInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// DocumentInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class DocumentInfo : ReadOnlyBase<DocumentInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// Actual content of a Word Document (RTF, DOC or XML Format)
|
||||
/// </summary>
|
||||
public byte[] DocContent
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _DocContent;
|
||||
}
|
||||
}
|
||||
private string _DocAscii = string.Empty;
|
||||
/// <summary>
|
||||
/// Used for searching
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current DocumentInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check DocumentInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current DocumentInfo</returns>
|
||||
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
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// DocumentInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class DocumentInfoList : ReadOnlyListBase<DocumentInfoList, DocumentInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static DocumentInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<DocumentInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static DocumentInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<DocumentInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
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
|
||||
817
PROMS/proms/Volian.CSLA.Library/Generated/Folder.cs
Normal file
817
PROMS/proms/Volian.CSLA.Library/Generated/Folder.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Folder Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Folder : BusinessBase<Folder>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// {child Folders.FolderID}
|
||||
/// </summary>
|
||||
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();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
public FolderAssignments FolderAssignments
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _FolderAssignments;
|
||||
}
|
||||
}
|
||||
private FolderDocVersions _FolderDocVersions = FolderDocVersions.New();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Folder</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Folder.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Folder</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ParentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DBID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ParentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DBID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Folder>();
|
||||
}
|
||||
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<Folder>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
566
PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignment.cs
Normal file
566
PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignment.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderAssignment Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class FolderAssignment : BusinessBase<FolderAssignment>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current FolderAssignment</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _AID;
|
||||
}
|
||||
// TODO: Replace base FolderAssignment.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current FolderAssignment</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
142
PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignments.cs
Normal file
142
PROMS/proms/Volian.CSLA.Library/Generated/FolderAssignments.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderAssignments Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class FolderAssignments : BusinessListBase<FolderAssignments, FolderAssignment>
|
||||
{
|
||||
#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
|
||||
447
PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersion.cs
Normal file
447
PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersion.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderDocVersion Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class FolderDocVersion : BusinessBase<FolderDocVersion>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 Working Draft, 1 Temporary, 128 Revision, 129 Approved (Greater than 127 - non editable)
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current FolderDocVersion</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _VersionID;
|
||||
}
|
||||
// TODO: Replace base FolderDocVersion.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current FolderDocVersion</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
137
PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersions.cs
Normal file
137
PROMS/proms/Volian.CSLA.Library/Generated/FolderDocVersions.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderDocVersions Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class FolderDocVersions : BusinessListBase<FolderDocVersions, FolderDocVersion>
|
||||
{
|
||||
#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
|
||||
213
PROMS/proms/Volian.CSLA.Library/Generated/FolderInfo.cs
Normal file
213
PROMS/proms/Volian.CSLA.Library/Generated/FolderInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class FolderInfo : ReadOnlyBase<FolderInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// {child Folders.FolderID}
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of Assignment for this Folder
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of DocVersion for this Folder
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current FolderInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check FolderInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current FolderInfo</returns>
|
||||
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
|
||||
122
PROMS/proms/Volian.CSLA.Library/Generated/FolderInfoList.cs
Normal file
122
PROMS/proms/Volian.CSLA.Library/Generated/FolderInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class FolderInfoList : ReadOnlyListBase<FolderInfoList, FolderInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static FolderInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<FolderInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static FolderInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<FolderInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static FolderInfoList GetByConnection(int dbid)
|
||||
{
|
||||
return DataPortal.Fetch<FolderInfoList>(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
|
||||
734
PROMS/proms/Volian.CSLA.Library/Generated/Group.cs
Normal file
734
PROMS/proms/Volian.CSLA.Library/Generated/Group.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Group Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Group : BusinessBase<Group>
|
||||
{
|
||||
#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();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
public GroupAssignments GroupAssignments
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _GroupAssignments;
|
||||
}
|
||||
}
|
||||
private GroupMemberships _GroupMemberships = GroupMemberships.New();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Group</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Group.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Group</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(GroupName, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(GroupType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(GroupName, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(GroupType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Group>();
|
||||
}
|
||||
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<Group>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
593
PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignment.cs
Normal file
593
PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignment.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupAssignment Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class GroupAssignment : BusinessBase<GroupAssignment>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// {child Folders.FolderID}
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current GroupAssignment</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _AID;
|
||||
}
|
||||
// TODO: Replace base GroupAssignment.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current GroupAssignment</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
142
PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignments.cs
Normal file
142
PROMS/proms/Volian.CSLA.Library/Generated/GroupAssignments.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupAssignments Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class GroupAssignments : BusinessListBase<GroupAssignments, GroupAssignment>
|
||||
{
|
||||
#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
|
||||
188
PROMS/proms/Volian.CSLA.Library/Generated/GroupInfo.cs
Normal file
188
PROMS/proms/Volian.CSLA.Library/Generated/GroupInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class GroupInfo : ReadOnlyBase<GroupInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// Count of Assignment for this Group
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of Membership for this Group
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current GroupInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check GroupInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current GroupInfo</returns>
|
||||
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
|
||||
76
PROMS/proms/Volian.CSLA.Library/Generated/GroupInfoList.cs
Normal file
76
PROMS/proms/Volian.CSLA.Library/Generated/GroupInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class GroupInfoList : ReadOnlyListBase<GroupInfoList, GroupInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static GroupInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<GroupInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static GroupInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<GroupInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
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
|
||||
590
PROMS/proms/Volian.CSLA.Library/Generated/GroupMembership.cs
Normal file
590
PROMS/proms/Volian.CSLA.Library/Generated/GroupMembership.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupMembership Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class GroupMembership : BusinessBase<GroupMembership>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current GroupMembership</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _UGID;
|
||||
}
|
||||
// TODO: Replace base GroupMembership.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current GroupMembership</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
142
PROMS/proms/Volian.CSLA.Library/Generated/GroupMemberships.cs
Normal file
142
PROMS/proms/Volian.CSLA.Library/Generated/GroupMemberships.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupMemberships Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class GroupMemberships : BusinessListBase<GroupMemberships, GroupMembership>
|
||||
{
|
||||
#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
|
||||
768
PROMS/proms/Volian.CSLA.Library/Generated/Membership.cs
Normal file
768
PROMS/proms/Volian.CSLA.Library/Generated/Membership.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Membership Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Membership : BusinessBase<Membership>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Membership</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Membership.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Membership</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Membership>();
|
||||
}
|
||||
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<Membership>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
147
PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfo.cs
Normal file
147
PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// MembershipInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class MembershipInfo : ReadOnlyBase<MembershipInfo>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current MembershipInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check MembershipInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current MembershipInfo</returns>
|
||||
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
|
||||
168
PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfoList.cs
Normal file
168
PROMS/proms/Volian.CSLA.Library/Generated/MembershipInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// MembershipInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class MembershipInfoList : ReadOnlyListBase<MembershipInfoList, MembershipInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static MembershipInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<MembershipInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static MembershipInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<MembershipInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static MembershipInfoList GetByGroup(int gid)
|
||||
{
|
||||
return DataPortal.Fetch<MembershipInfoList>(new GroupCriteria(gid));
|
||||
}
|
||||
public static MembershipInfoList GetByUser(int uid)
|
||||
{
|
||||
return DataPortal.Fetch<MembershipInfoList>(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
|
||||
876
PROMS/proms/Volian.CSLA.Library/Generated/Permission.cs
Normal file
876
PROMS/proms/Volian.CSLA.Library/Generated/Permission.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Permission Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Permission : BusinessBase<Permission>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 0 - Allow, 1 - Deny
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Permission</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Permission.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Permission</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PermLevel, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PermValue, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PermAD, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(RID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PermLevel, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PermValue, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PermAD, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Permission>();
|
||||
}
|
||||
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<Permission>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
192
PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfo.cs
Normal file
192
PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// PermissionInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class PermissionInfo : ReadOnlyBase<PermissionInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
|
||||
/// </summary>
|
||||
public int PermLevel
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _PermLevel;
|
||||
}
|
||||
}
|
||||
private int _VersionType;
|
||||
/// <summary>
|
||||
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
|
||||
/// </summary>
|
||||
public int VersionType
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _VersionType;
|
||||
}
|
||||
}
|
||||
private int _PermValue;
|
||||
/// <summary>
|
||||
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
|
||||
/// </summary>
|
||||
public int PermValue
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _PermValue;
|
||||
}
|
||||
}
|
||||
private int _PermAD;
|
||||
/// <summary>
|
||||
/// 0 - Allow, 1 - Deny
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current PermissionInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check PermissionInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current PermissionInfo</returns>
|
||||
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
|
||||
122
PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfoList.cs
Normal file
122
PROMS/proms/Volian.CSLA.Library/Generated/PermissionInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// PermissionInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class PermissionInfoList : ReadOnlyListBase<PermissionInfoList, PermissionInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static PermissionInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<PermissionInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static PermissionInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<PermissionInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static PermissionInfoList GetByRole(int rid)
|
||||
{
|
||||
return DataPortal.Fetch<PermissionInfoList>(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
|
||||
805
PROMS/proms/Volian.CSLA.Library/Generated/Procedure.cs
Normal file
805
PROMS/proms/Volian.CSLA.Library/Generated/Procedure.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Procedure Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Procedure : BusinessBase<Procedure>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Procedure</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Procedure.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Procedure</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Format, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StructureStart, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Format, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StructureStart, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
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<Procedure>();
|
||||
}
|
||||
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<Procedure>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
169
PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfo.cs
Normal file
169
PROMS/proms/Volian.CSLA.Library/Generated/ProcedureInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ProcedureInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ProcedureInfo : ReadOnlyBase<ProcedureInfo>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ProcedureInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check ProcedureInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current ProcedureInfo</returns>
|
||||
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
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// ProcedureInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ProcedureInfoList : ReadOnlyListBase<ProcedureInfoList, ProcedureInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static ProcedureInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<ProcedureInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static ProcedureInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<ProcedureInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
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
|
||||
666
PROMS/proms/Volian.CSLA.Library/Generated/RoUsage.cs
Normal file
666
PROMS/proms/Volian.CSLA.Library/Generated/RoUsage.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoUsage Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoUsage : BusinessBase<RoUsage>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RoUsage</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check RoUsage.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current RoUsage</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ROID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ROID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
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<RoUsage>();
|
||||
}
|
||||
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<RoUsage>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
125
PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfo.cs
Normal file
125
PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoUsageInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoUsageInfo : ReadOnlyBase<RoUsageInfo>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RoUsageInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check RoUsageInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current RoUsageInfo</returns>
|
||||
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
|
||||
122
PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfoList.cs
Normal file
122
PROMS/proms/Volian.CSLA.Library/Generated/RoUsageInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoUsageInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoUsageInfoList : ReadOnlyListBase<RoUsageInfoList, RoUsageInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static RoUsageInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<RoUsageInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static RoUsageInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<RoUsageInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static RoUsageInfoList GetByStructure(int structureID)
|
||||
{
|
||||
return DataPortal.Fetch<RoUsageInfoList>(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
|
||||
707
PROMS/proms/Volian.CSLA.Library/Generated/Role.cs
Normal file
707
PROMS/proms/Volian.CSLA.Library/Generated/Role.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Role Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Role : BusinessBase<Role>
|
||||
{
|
||||
#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();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
public RoleAssignments RoleAssignments
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _RoleAssignments;
|
||||
}
|
||||
}
|
||||
private RolePermissions _RolePermissions = RolePermissions.New();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Role</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Role.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Role</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Name, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
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<Role>();
|
||||
}
|
||||
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<Role>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
605
PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignment.cs
Normal file
605
PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignment.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoleAssignment Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoleAssignment : BusinessBase<RoleAssignment>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// {child Folders.FolderID}
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current RoleAssignment</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _AID;
|
||||
}
|
||||
// TODO: Replace base RoleAssignment.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RoleAssignment</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(GID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(FolderID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
142
PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignments.cs
Normal file
142
PROMS/proms/Volian.CSLA.Library/Generated/RoleAssignments.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoleAssignments Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoleAssignments : BusinessListBase<RoleAssignments, RoleAssignment>
|
||||
{
|
||||
#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
|
||||
177
PROMS/proms/Volian.CSLA.Library/Generated/RoleInfo.cs
Normal file
177
PROMS/proms/Volian.CSLA.Library/Generated/RoleInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoleInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoleInfo : ReadOnlyBase<RoleInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// Count of Assignment for this Role
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of Permission for this Role
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RoleInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check RoleInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current RoleInfo</returns>
|
||||
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
|
||||
76
PROMS/proms/Volian.CSLA.Library/Generated/RoleInfoList.cs
Normal file
76
PROMS/proms/Volian.CSLA.Library/Generated/RoleInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RoleInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RoleInfoList : ReadOnlyListBase<RoleInfoList, RoleInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static RoleInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<RoleInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static RoleInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<RoleInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
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
|
||||
527
PROMS/proms/Volian.CSLA.Library/Generated/RolePermission.cs
Normal file
527
PROMS/proms/Volian.CSLA.Library/Generated/RolePermission.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RolePermission Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RolePermission : BusinessBase<RolePermission>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 - None, 1 - Security, 2 - System, 3 - RO, 4 - Procdures, 5 - Sections, 6 - Steps, 7 - Comments
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 0 - None, 1 - Working Draft, 2 - Approved, (3 - All)
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 1 - Read, 2 - Write, 4 - Create, 8 - Delete (15 - All)
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 0 - Allow, 1 - Deny
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current RolePermission</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _PID;
|
||||
}
|
||||
// TODO: Replace base RolePermission.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current RolePermission</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PermLevel, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PermLevel, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(VersionType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PermValue, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PermValue, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PermAD, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PermAD, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StartDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(EndDate, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UsrID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UsrID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
137
PROMS/proms/Volian.CSLA.Library/Generated/RolePermissions.cs
Normal file
137
PROMS/proms/Volian.CSLA.Library/Generated/RolePermissions.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// RolePermissions Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class RolePermissions : BusinessListBase<RolePermissions, RolePermission>
|
||||
{
|
||||
#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
|
||||
804
PROMS/proms/Volian.CSLA.Library/Generated/Section.cs
Normal file
804
PROMS/proms/Volian.CSLA.Library/Generated/Section.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Section Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Section : BusinessBase<Section>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 Nothing, 1 Structure, 2 Document
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Section</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Section.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Section</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Number, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ContentType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Format, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Number, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Title, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ContentType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Format, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
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<Section>();
|
||||
}
|
||||
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<Section>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
198
PROMS/proms/Volian.CSLA.Library/Generated/SectionInfo.cs
Normal file
198
PROMS/proms/Volian.CSLA.Library/Generated/SectionInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// SectionInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class SectionInfo : ReadOnlyBase<SectionInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// 0 Nothing, 1 Structure, 2 Document
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of ZSection for this Section
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current SectionInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check SectionInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current SectionInfo</returns>
|
||||
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
|
||||
76
PROMS/proms/Volian.CSLA.Library/Generated/SectionInfoList.cs
Normal file
76
PROMS/proms/Volian.CSLA.Library/Generated/SectionInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// SectionInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class SectionInfoList : ReadOnlyListBase<SectionInfoList, SectionInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static SectionInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<SectionInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static SectionInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<SectionInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
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
|
||||
714
PROMS/proms/Volian.CSLA.Library/Generated/Step.cs
Normal file
714
PROMS/proms/Volian.CSLA.Library/Generated/Step.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Step Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class Step : BusinessBase<Step>
|
||||
{
|
||||
#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();
|
||||
/// <summary>
|
||||
/// Related Field
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current Step</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check Step.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current Step</returns>
|
||||
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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(StepType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(TextMID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(StepType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(TextMID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Config, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
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<Step>();
|
||||
}
|
||||
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<Step>(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<ExistsCommand>
|
||||
(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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
188
PROMS/proms/Volian.CSLA.Library/Generated/StepInfo.cs
Normal file
188
PROMS/proms/Volian.CSLA.Library/Generated/StepInfo.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// StepInfo Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class StepInfo : ReadOnlyBase<StepInfo>
|
||||
{
|
||||
#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;
|
||||
/// <summary>
|
||||
/// Count of StepText for this Step
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// Count of ZStep for this Step
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current StepInfo</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check StepInfo.GetIdValue to assure that the ID returned is unique
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current StepInfo</returns>
|
||||
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
|
||||
122
PROMS/proms/Volian.CSLA.Library/Generated/StepInfoList.cs
Normal file
122
PROMS/proms/Volian.CSLA.Library/Generated/StepInfoList.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// StepInfoList Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class StepInfoList : ReadOnlyListBase<StepInfoList, StepInfo>
|
||||
{
|
||||
#region Factory Methods
|
||||
/// <summary>
|
||||
/// Return a list of all projects.
|
||||
/// </summary>
|
||||
public static StepInfoList Get()
|
||||
{
|
||||
return DataPortal.Fetch<StepInfoList>(new Criteria());
|
||||
}
|
||||
// TODO: Add alternative gets -
|
||||
//public static StepInfoList Get(<criteria>)
|
||||
//{
|
||||
// return DataPortal.Fetch<StepInfoList>(new FilteredCriteria(<criteria>));
|
||||
//}
|
||||
public static StepInfoList GetByTextM(int textMID)
|
||||
{
|
||||
return DataPortal.Fetch<StepInfoList>(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
|
||||
358
PROMS/proms/Volian.CSLA.Library/Generated/StepStepText.cs
Normal file
358
PROMS/proms/Volian.CSLA.Library/Generated/StepStepText.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// StepStepText Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class StepStepText : BusinessBase<StepStepText>
|
||||
{
|
||||
#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
|
||||
/// <summary>
|
||||
/// Overrides Base GetIdValue - Used internally by CSLA to determine equality
|
||||
/// </summary>
|
||||
/// <returns>A Unique ID for the current StepStepText</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _StepTextMID;
|
||||
}
|
||||
// TODO: Replace base StepStepText.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current StepStepText</returns>
|
||||
//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, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ItemType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ItemType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(TextM, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(TextM, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(DTS, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(UserID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(UserID, "<Role(s)>");
|
||||
}
|
||||
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, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user