The purpose of this upgrade is to improve the user experience when using the Admin tool to Update ROs. Currently for larger RO dbs (like Barakah) we can run up against memory constraints that do not allow all the ROs to be updated at one time. This is based upon some initial resource where some places were identified where we could improve memory usage. Some of these should benefit PROMS as a whole while others will be specific to the RO Update option in Admin Tools.
568 lines
20 KiB
C#
568 lines
20 KiB
C#
|
|
// ========================================================================
|
|
// 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.Object.Library
|
|
{
|
|
/// <summary>
|
|
/// FolderAssignment Generated by MyGeneration using the CSLA Object Mapping template
|
|
/// </summary>
|
|
[Serializable()]
|
|
public partial class FolderAssignment : BusinessBase<FolderAssignment>
|
|
{
|
|
#region Business Methods
|
|
|
|
|
|
private int _aid;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public int Aid
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _aid;
|
|
}
|
|
}
|
|
private int _gid;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public int Gid
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _gid;
|
|
}
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
set
|
|
{
|
|
if (_gid != value)
|
|
{
|
|
_gid = value;
|
|
PropertyHasChanged();
|
|
}
|
|
}
|
|
}
|
|
private int _rid;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public int Rid
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _rid;
|
|
}
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
set
|
|
{
|
|
if (_rid != value)
|
|
{
|
|
_rid = value;
|
|
PropertyHasChanged();
|
|
}
|
|
}
|
|
}
|
|
private string _startdate = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string StartDate
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _startdate;
|
|
}
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
set
|
|
{
|
|
if (value == null) value = string.Empty;
|
|
_startdate = value;
|
|
try
|
|
{
|
|
DateTime tmp = SmartDate.StringToDate(value);
|
|
if (_startdate != tmp.ToShortDateString())
|
|
{
|
|
_startdate = tmp.ToShortDateString();
|
|
// TODO: Any Cross Property Validation
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
PropertyHasChanged();
|
|
}
|
|
}
|
|
private string _enddate = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string EndDate
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _enddate;
|
|
}
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
set
|
|
{
|
|
if (value == null) value = string.Empty;
|
|
_enddate = value;
|
|
try
|
|
{
|
|
DateTime tmp = SmartDate.StringToDate(value);
|
|
if (_enddate != tmp.ToShortDateString())
|
|
{
|
|
_enddate = tmp.ToShortDateString();
|
|
// TODO: Any Cross Property Validation
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
PropertyHasChanged();
|
|
}
|
|
}
|
|
private DateTime _dts = new DateTime();
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public DateTime Dts
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _dts;
|
|
}
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
set
|
|
{
|
|
if (_dts != value)
|
|
{
|
|
_dts = value;
|
|
PropertyHasChanged();
|
|
}
|
|
}
|
|
}
|
|
private string _usrid = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Usrid
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _usrid;
|
|
}
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
set
|
|
{
|
|
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;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Group_GroupName
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _group_groupname;
|
|
}
|
|
}
|
|
private int _group_grouptype;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public int Group_GroupType
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _group_grouptype;
|
|
}
|
|
}
|
|
private string _group_config = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Group_Config
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _group_config;
|
|
}
|
|
}
|
|
private DateTime _group_dts = new DateTime();
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public DateTime Group_Dts
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _group_dts;
|
|
}
|
|
}
|
|
private string _group_usrid = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Group_Usrid
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _group_usrid;
|
|
}
|
|
}
|
|
private string _role_name = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Role_Name
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _role_name;
|
|
}
|
|
}
|
|
private string _role_title = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Role_Title
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _role_title;
|
|
}
|
|
}
|
|
private DateTime _role_dts = new DateTime();
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public DateTime Role_Dts
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
return _role_dts;
|
|
}
|
|
}
|
|
private string _role_usrid = string.Empty;
|
|
[System.ComponentModel.DataObjectField(true, true)]
|
|
public string Role_Usrid
|
|
{
|
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
|
get
|
|
{
|
|
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(StartDateValid, "StartDate");
|
|
ValidationRules.AddRule(EndDateValid, "EndDate");
|
|
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
|
|
|
|
internal static FolderAssignment New(int gid, int rid)
|
|
{
|
|
return new FolderAssignment(Volian.Object.Library.Group.Get(gid), Volian.Object.Library.Role.Get(rid));
|
|
}
|
|
|
|
internal static FolderAssignment Get(SafeDataReader dr)
|
|
{
|
|
return new FolderAssignment(dr);
|
|
}
|
|
|
|
private FolderAssignment()
|
|
{
|
|
MarkAsChild();
|
|
_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("Groups_GroupName");
|
|
_group_grouptype = dr.GetInt32("Groups_GroupType");
|
|
_group_config = dr.GetString("Groups_Config");
|
|
_group_dts = dr.GetDateTime("Groups_DTS");
|
|
_group_usrid = dr.GetString("Groups_UsrID");
|
|
_role_name = dr.GetString("Roles_Name");
|
|
_role_title = dr.GetString("Roles_Title");
|
|
_role_dts = dr.GetDateTime("Roles_DTS");
|
|
_role_usrid = dr.GetString("Roles_UsrID");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Database.LogException("FolderAssignment", 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);
|
|
}
|
|
|
|
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
|
|
|
|
// The follwing 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 PatrialClass
|
|
//{
|
|
// 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));
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
} // Class
|
|
} // Namespace
|