This commit is contained in:
740
PROMS/proms/Volian.CSLA.Library/Generated/ZStruct.cs
Normal file
740
PROMS/proms/Volian.CSLA.Library/Generated/ZStruct.cs
Normal file
@@ -0,0 +1,740 @@
|
||||
// ========================================================================
|
||||
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
|
||||
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
// ------------------------------------------------------------------------
|
||||
// $Workfile: $ $Revision: $
|
||||
// $Author: $ $Date: $
|
||||
//
|
||||
// $History: $
|
||||
// ========================================================================
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
|
||||
namespace Volian.CSLA.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// ZStruct Generated by MyGeneration using the CSLA Object Mapping template
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public partial class ZStruct : BusinessBase<ZStruct>
|
||||
{
|
||||
#region Business Methods
|
||||
private string _errorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _errorMessage; }
|
||||
}
|
||||
private static int _nextStructureID = -1;
|
||||
public static int NextStructureID
|
||||
{
|
||||
get { return _nextStructureID--; }
|
||||
}
|
||||
private int _StructureID;
|
||||
[System.ComponentModel.DataObjectField(true, true)]
|
||||
public int StructureID
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _StructureID;
|
||||
}
|
||||
}
|
||||
private int _FromType;
|
||||
public int FromType
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _FromType;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_FromType != value)
|
||||
{
|
||||
_FromType = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _FromID;
|
||||
public int FromID
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _FromID;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_FromID != value)
|
||||
{
|
||||
_FromID = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _ContentType;
|
||||
public int ContentType
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _ContentType;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_ContentType != value)
|
||||
{
|
||||
_ContentType = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _ContentID;
|
||||
public int ContentID
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _ContentID;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_ContentID != value)
|
||||
{
|
||||
_ContentID = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Level;
|
||||
public int Level
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _Level;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_Level != value)
|
||||
{
|
||||
_Level = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Item;
|
||||
public int Item
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _Item;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (_Item != value)
|
||||
{
|
||||
_Item = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _PPath = string.Empty;
|
||||
public string PPath
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _PPath;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (value == null) value = string.Empty;
|
||||
if (_PPath != value)
|
||||
{
|
||||
_PPath = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _Path = string.Empty;
|
||||
public string Path
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty(true);
|
||||
return _Path;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty(true);
|
||||
if (value == null) value = string.Empty;
|
||||
if (_Path != value)
|
||||
{
|
||||
_Path = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private byte[] _LastChanged = new byte[8];//timestamp
|
||||
// TODO: Replace base ZStruct.ToString function as necessary
|
||||
/// <summary>
|
||||
/// Overrides Base ToString
|
||||
/// </summary>
|
||||
/// <returns>A string representation of current ZStruct</returns>
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return base.ToString();
|
||||
//}
|
||||
// TODO: Check ZStruct.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 ZStruct</returns>
|
||||
protected override object GetIdValue()
|
||||
{
|
||||
return _StructureID;
|
||||
}
|
||||
#endregion
|
||||
#region ValidationRules
|
||||
protected override void AddBusinessRules()
|
||||
{
|
||||
ext.AddValidationRules(ValidationRules);
|
||||
// TODO: Add other validation rules
|
||||
// ValidationRules.AddRule(StartDateGTEndDate, "Started");
|
||||
}
|
||||
// Sample data comparison validation rule
|
||||
//private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e)
|
||||
//{
|
||||
// if (_started > _ended)
|
||||
// {
|
||||
// e.Description = "Start date can't be after end date";
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// return true;
|
||||
//}
|
||||
#endregion
|
||||
#region Authorization Rules
|
||||
protected override void AddAuthorizationRules()
|
||||
{
|
||||
//TODO: Who can read/write which fields
|
||||
//AuthorizationRules.AllowRead(StructureID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(FromType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(FromID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ContentType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(ContentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Level, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Item, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(PPath, "<Role(s)>");
|
||||
//AuthorizationRules.AllowRead(Path, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(FromType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(FromID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ContentType, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(ContentID, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Level, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Item, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(PPath, "<Role(s)>");
|
||||
//AuthorizationRules.AllowWrite(Path, "<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 ZStruct()
|
||||
{/* require use of factory methods */}
|
||||
public static ZStruct New()
|
||||
{
|
||||
if (!CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a ZStruct");
|
||||
return DataPortal.Create<ZStruct>();
|
||||
}
|
||||
public static ZStruct New(int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path)
|
||||
{
|
||||
ZStruct tmp = ZStruct.New();
|
||||
tmp.FromType = fromType;
|
||||
tmp.FromID = fromID;
|
||||
tmp.ContentType = contentType;
|
||||
tmp.ContentID = contentID;
|
||||
tmp.Level = level;
|
||||
tmp.Item = item;
|
||||
tmp.PPath = pPath;
|
||||
tmp.Path = path;
|
||||
return tmp;
|
||||
}
|
||||
public static ZStruct MakeZStruct(int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path)
|
||||
{
|
||||
ZStruct tmp = ZStruct.New(fromType, fromID, contentType, contentID, level, item, pPath, path);
|
||||
tmp.Save();
|
||||
return tmp;
|
||||
}
|
||||
public static ZStruct Get(int structureID)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a ZStruct");
|
||||
return DataPortal.Fetch<ZStruct>(new PKCriteria(structureID));
|
||||
}
|
||||
public static ZStruct Get(SafeDataReader dr)
|
||||
{
|
||||
if (dr.Read()) return new ZStruct(dr);
|
||||
return null;
|
||||
}
|
||||
private ZStruct(SafeDataReader dr)
|
||||
{
|
||||
_StructureID = dr.GetInt32("StructureID");
|
||||
_FromType = dr.GetInt32("FromType");
|
||||
_FromID = dr.GetInt32("FromID");
|
||||
_ContentType = dr.GetInt32("ContentType");
|
||||
_ContentID = dr.GetInt32("ContentID");
|
||||
_Level = dr.GetInt32("Level");
|
||||
_Item = dr.GetInt32("Item");
|
||||
_PPath = dr.GetString("PPath");
|
||||
_Path = dr.GetString("Path");
|
||||
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
||||
}
|
||||
public static void Delete(int structureID)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a ZStruct");
|
||||
DataPortal.Delete(new PKCriteria(structureID));
|
||||
}
|
||||
public override ZStruct Save()
|
||||
{
|
||||
if (IsDeleted && !CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a ZStruct");
|
||||
else if (IsNew && !CanAddObject())
|
||||
throw new System.Security.SecurityException("User not authorized to add a ZStruct");
|
||||
else if (!CanEditObject())
|
||||
throw new System.Security.SecurityException("User not authorized to update a ZStruct");
|
||||
return base.Save();
|
||||
}
|
||||
#endregion
|
||||
#region Data Access Portal
|
||||
[Serializable()]
|
||||
private class PKCriteria
|
||||
{
|
||||
private int _StructureID;
|
||||
public int StructureID
|
||||
{ get { return _StructureID; } }
|
||||
public PKCriteria(int structureID)
|
||||
{
|
||||
_StructureID = structureID;
|
||||
}
|
||||
}
|
||||
// TODO: If Create needs to access DB - It should not be marked RunLocal
|
||||
[RunLocal()]
|
||||
private new void DataPortal_Create(object criteria)
|
||||
{
|
||||
_StructureID = NextStructureID;
|
||||
// Database Defaults
|
||||
|
||||
// TODO: Add any defaults that are necessary
|
||||
ValidationRules.CheckRules();
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getZStruct";
|
||||
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
dr.Read();
|
||||
_StructureID = dr.GetInt32("StructureID");
|
||||
_FromType = dr.GetInt32("FromType");
|
||||
_FromID = dr.GetInt32("FromID");
|
||||
_ContentType = dr.GetInt32("ContentType");
|
||||
_ContentID = dr.GetInt32("ContentID");
|
||||
_Level = dr.GetInt32("Level");
|
||||
_Item = dr.GetInt32("Item");
|
||||
_PPath = dr.GetString("PPath");
|
||||
_Path = dr.GetString("Path");
|
||||
dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.DataPortal_Fetch", ex);
|
||||
_errorMessage = ex.Message;
|
||||
throw new DbCslaException("ZStruct.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
protected override void DataPortal_Insert()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "addZStruct";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@FromType", _FromType);
|
||||
cm.Parameters.AddWithValue("@FromID", _FromID);
|
||||
cm.Parameters.AddWithValue("@ContentType", _ContentType);
|
||||
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
||||
cm.Parameters.AddWithValue("@Level", _Level);
|
||||
cm.Parameters.AddWithValue("@Item", _Item);
|
||||
cm.Parameters.AddWithValue("@PPath", _PPath);
|
||||
cm.Parameters.AddWithValue("@Path", _Path);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int);
|
||||
param_StructureID.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_StructureID);
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||
param_LastChanged.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// TODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
// Save all values being returned from the Procedure
|
||||
_StructureID = (int)cm.Parameters["@newStructureID"].Value;
|
||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
}
|
||||
// update child objects
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.DataPortal_Insert", ex);
|
||||
_errorMessage = ex.Message;
|
||||
throw new DbCslaException("ZStruct.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Add(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "addZStruct";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@FromType", fromType);
|
||||
cm.Parameters.AddWithValue("@FromID", fromID);
|
||||
cm.Parameters.AddWithValue("@ContentType", contentType);
|
||||
cm.Parameters.AddWithValue("@ContentID", contentID);
|
||||
cm.Parameters.AddWithValue("@Level", level);
|
||||
cm.Parameters.AddWithValue("@Item", item);
|
||||
cm.Parameters.AddWithValue("@PPath", pPath);
|
||||
cm.Parameters.AddWithValue("@Path", path);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_StructureID = new SqlParameter("@newStructureID", SqlDbType.Int);
|
||||
param_StructureID.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_StructureID);
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||
param_LastChanged.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// TODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
// Save all values being returned from the Procedure
|
||||
structureID = (int)cm.Parameters["@newStructureID"].Value;
|
||||
return (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.Add", ex);
|
||||
throw new DbCslaException("ZStruct.Add", ex);
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
protected override void DataPortal_Update()
|
||||
{
|
||||
if (IsDirty)// If this is dirty - open the connection
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
if (base.IsDirty)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "updateZStruct";
|
||||
// All Fields including Calculated Fields
|
||||
cm.Parameters.AddWithValue("@StructureID", _StructureID);
|
||||
cm.Parameters.AddWithValue("@FromType", _FromType);
|
||||
cm.Parameters.AddWithValue("@FromID", _FromID);
|
||||
cm.Parameters.AddWithValue("@ContentType", _ContentType);
|
||||
cm.Parameters.AddWithValue("@ContentID", _ContentID);
|
||||
cm.Parameters.AddWithValue("@Level", _Level);
|
||||
cm.Parameters.AddWithValue("@Item", _Item);
|
||||
cm.Parameters.AddWithValue("@PPath", _PPath);
|
||||
cm.Parameters.AddWithValue("@Path", _Path);
|
||||
cm.Parameters.AddWithValue("@LastChanged", _LastChanged);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||
param_LastChanged.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// TODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
// Save all values being returned from the Procedure
|
||||
_LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
}
|
||||
}
|
||||
// use the open connection to update child objects
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.DataPortal_Update", ex);
|
||||
_errorMessage = ex.Message;
|
||||
if (!ex.Message.EndsWith("has been edited by another user."))throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Update(SqlConnection cn, ref int structureID, int fromType, int fromID, int contentType, int contentID, int level, int item, string pPath, string path, ref byte[] lastChanged)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "updateZStruct";
|
||||
// Input All Fields - Except Calculated Columns
|
||||
cm.Parameters.AddWithValue("@StructureID", structureID);
|
||||
cm.Parameters.AddWithValue("@FromType", fromType);
|
||||
cm.Parameters.AddWithValue("@FromID", fromID);
|
||||
cm.Parameters.AddWithValue("@ContentType", contentType);
|
||||
cm.Parameters.AddWithValue("@ContentID", contentID);
|
||||
cm.Parameters.AddWithValue("@Level", level);
|
||||
cm.Parameters.AddWithValue("@Item", item);
|
||||
cm.Parameters.AddWithValue("@PPath", pPath);
|
||||
cm.Parameters.AddWithValue("@Path", path);
|
||||
cm.Parameters.AddWithValue("@LastChanged", lastChanged);
|
||||
// Output Calculated Columns
|
||||
SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp);
|
||||
param_LastChanged.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_LastChanged);
|
||||
// TODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
// Save all values being returned from the Procedure
|
||||
return (byte[])cm.Parameters["@newLastChanged"].Value;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.Update", ex);
|
||||
throw new DbCslaException("ZStruct.Update", ex);
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
protected override void DataPortal_DeleteSelf()
|
||||
{
|
||||
DataPortal_Delete(new PKCriteria(_StructureID));
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
private void DataPortal_Delete(PKCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "deleteZStruct";
|
||||
cm.Parameters.AddWithValue("@StructureID", criteria.StructureID);
|
||||
cm.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.DataPortal_Delete", ex);
|
||||
_errorMessage = ex.Message;
|
||||
throw new DbCslaException("ZStruct.DataPortal_Delete", ex);
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static void Remove(SqlConnection cn, int structureID)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "deleteZStruct";
|
||||
// Input PK Fields
|
||||
cm.Parameters.AddWithValue("@StructureID", structureID);
|
||||
// TODO: Define any additional output parameters
|
||||
cm.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.Remove", ex);
|
||||
throw new DbCslaException("ZStruct.Remove", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Exists
|
||||
public static bool Exists(int structureID)
|
||||
{
|
||||
ExistsCommand result;
|
||||
result = DataPortal.Execute<ExistsCommand>
|
||||
(new ExistsCommand(structureID));
|
||||
return result.Exists;
|
||||
}
|
||||
[Serializable()]
|
||||
private class ExistsCommand : CommandBase
|
||||
{
|
||||
private int _StructureID;
|
||||
private bool _exists;
|
||||
public bool Exists
|
||||
{
|
||||
get { return _exists; }
|
||||
}
|
||||
public ExistsCommand(int structureID)
|
||||
{
|
||||
_StructureID = structureID;
|
||||
}
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
cn.Open();
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "existsZStruct";
|
||||
cm.Parameters.AddWithValue("@StructureID", _StructureID);
|
||||
int count = (int)cm.ExecuteScalar();
|
||||
_exists = (count > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ZStruct.DataPortal_Execute", ex);
|
||||
throw new DbCslaException("ZStruct.DataPortal_Execute", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
// Standard Default Code
|
||||
#region extension
|
||||
Extension ext = new Extension();
|
||||
[Serializable()]
|
||||
partial class Extension : extensionBase
|
||||
{
|
||||
}
|
||||
[Serializable()]
|
||||
class extensionBase
|
||||
{
|
||||
// Default Values
|
||||
// Authorization Rules
|
||||
public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||
{
|
||||
// Needs to be overriden to add new authorization rules
|
||||
}
|
||||
// Validation Rules
|
||||
public virtual void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
{
|
||||
// Needs to be overriden to add new validation rules
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
} // Class
|
||||
} // Namespace
|
||||
|
||||
|
||||
//// The following is a sample Extension File. You can use it to create ZStructExt.cs
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Text;
|
||||
//using Csla;
|
||||
|
||||
//namespace Volian.CSLA.Library
|
||||
//{
|
||||
// public partial class ZStruct
|
||||
// {
|
||||
// partial class Extension : extensionBase
|
||||
// {
|
||||
// // TODO: Override automatic defaults
|
||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||
// {
|
||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
Reference in New Issue
Block a user