CSLA - Extension

This commit is contained in:
2026-09-01 08:21:41 -04:00
parent dcd2fbc294
commit dab65dbfb6
30 changed files with 2703 additions and 5680 deletions
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Csla;
using Csla.Data;
using JR.Utils.GUI.Forms;
@@ -23,13 +21,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
public class CanCheckOutItemCriteria
{
private int _ObjectID;
public int ObjectID
{ get { return _ObjectID; } }
private CheckOutType _ObjectType;
public CheckOutType ObjectType
{ get { return _ObjectType; } }
public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
private readonly int _ObjectID;
public int ObjectID => _ObjectID;
private readonly CheckOutType _ObjectType;
public CheckOutType ObjectType => _ObjectType;
public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
{
_ObjectID = objectID;
_ObjectType = objectType;
@@ -37,7 +33,7 @@ namespace VEPROMS.CSLA.Library
}
private void DataPortal_Fetch(CanCheckOutItemCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfoList.DataPortal_Fetch", GetHashCode());
try
{
@@ -53,7 +49,7 @@ namespace VEPROMS.CSLA.Library
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new SessionInfo(dr));
while (dr.Read()) Add(new SessionInfo(dr));
IsReadOnly = true;
}
}
@@ -64,7 +60,7 @@ namespace VEPROMS.CSLA.Library
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("SessionInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
}
#endregion
@@ -72,8 +68,8 @@ namespace VEPROMS.CSLA.Library
#region SessionInfo stuff
public partial class SessionInfo
{
private Int64 _LastContentChange;
public Int64 LastContentChange
private long _LastContentChange;
public long LastContentChange
{
get { return _LastContentChange; }
set { _LastContentChange = value; }
@@ -88,15 +84,9 @@ namespace VEPROMS.CSLA.Library
}
set { _LastChanged = value; }
}
public string LastChangedString
{
get { return ContentInfo.FormatByteArray(_LastChanged); }
}
public Int64 LastChangedInt64
{
get { return Convert.ToInt64(LastChangedString, 16); }
}
public static SessionInfo BeginSession(string machineName, int processID)
public string LastChangedString => ContentInfo.FormatByteArray(_LastChanged);
public long LastChangedInt64 => Convert.ToInt64(LastChangedString, 16);
public static SessionInfo BeginSession(string machineName, int processID)
{
try
{
@@ -113,14 +103,14 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on SessionInfo.BeginSession", ex);
}
}
private Dictionary<int, Int64> _ChangedContents;
public Dictionary<int, Int64> ChangedContents
private Dictionary<int, long> _ChangedContents;
public Dictionary<int, long> ChangedContents
{
get { return _ChangedContents; }
set { _ChangedContents = value; }
}
private Dictionary<int, Int64> _ChangedItems;
public Dictionary<int, Int64> ChangedItems
private Dictionary<int, long> _ChangedItems;
public Dictionary<int, long> ChangedItems
{
get { return _ChangedItems; }
set { _ChangedItems = value; }
@@ -131,10 +121,10 @@ namespace VEPROMS.CSLA.Library
try
{
List<int> myList = new List<int>();
SessionPing.Execute(this.SessionID);
ChangedContents = SessionChangedContents.Execute(this.LastContentChange);
ChangedItems = SessionChangedItems.Execute(this.LastContentChange);
OwnerInfoList oil = OwnerInfoList.GetBySessionID(this.SessionID);
SessionPing.Execute(SessionID);
ChangedContents = SessionChangedContents.Execute(LastContentChange);
ChangedItems = SessionChangedItems.Execute(LastContentChange);
OwnerInfoList oil = OwnerInfoList.GetBySessionID(SessionID);
foreach (OwnerInfo oi in oil)
myList.Add(oi.OwnerID);
return myList;
@@ -144,11 +134,8 @@ namespace VEPROMS.CSLA.Library
return null;
}
}
public void EndSession()
{
SessionEnd.Execute(this.SessionID);
}
public bool CanCheckOutItem(int objectID, CheckOutType objectType, ref string message)
public void EndSession() => SessionEnd.Execute(SessionID);
public bool CanCheckOutItem(int objectID, CheckOutType objectType, ref string message)
{
try
{
@@ -178,7 +165,7 @@ namespace VEPROMS.CSLA.Library
// C2015-022 part of separate windows logic, check the processID instead of the sessionID
foreach (SessionInfo si in sil)
{
if (si.ProcessID != this.ProcessID && objectType == CheckOutType.Procedure)
if (si.ProcessID != ProcessID && objectType == CheckOutType.Procedure)
{
//B2024-074 If no Number for Procedure, Display Title
ProcedureInfo tmpproc = ItemInfo.Get(objectID).MyProcedure;
@@ -189,12 +176,12 @@ namespace VEPROMS.CSLA.Library
message = string.Format("The procedure {0} is already checked out to {1}.\r\nWould You like to open the procedure in View Only Mode?", name, si.UserID);
rv = rv && false;
}
else if (si.ProcessID != this.ProcessID && objectType == CheckOutType.Document)
else if (si.ProcessID != ProcessID && objectType == CheckOutType.Document)
{
message = string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(objectID).DocumentEntries[0].MyContent.Text, si.UserID);
rv = rv && false;
}
else if (si.ProcessID != this.ProcessID && objectType == CheckOutType.DocVersion)
else if (si.ProcessID != ProcessID && objectType == CheckOutType.DocVersion)
{
// gets here if other session has working draft open & click on sam working draft.
OwnerInfo oi = OwnerInfo.GetBySessionIDandVersionID(si.SessionID, objectID);
@@ -213,10 +200,10 @@ namespace VEPROMS.CSLA.Library
else if (oi.OwnerType == 1)
message = message + string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(oi.OwnerItemID).DocumentEntries[0].MyContent.Text, si.UserID) + Environment.NewLine;
else if (oi.OwnerType == 2)
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
message += string.Format("The working draft is already checked out to {0}", si.UserID);
rv = rv && false;
}
else if (si.ProcessID != this.ProcessID && objectType == CheckOutType.Folder)
else if (si.ProcessID != ProcessID && objectType == CheckOutType.Folder)
{
// gets here if other session has working draft open & click on folder above. Gets here
// if other session has wd open and click on top folder - query returns empty.
@@ -236,9 +223,9 @@ namespace VEPROMS.CSLA.Library
else if (oi.OwnerType == 1)
message = message + string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(oi.OwnerItemID).DocumentEntries[0].MyContent.Text, si.UserID) + Environment.NewLine;
else if (oi.OwnerType == 2)
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
message += string.Format("The working draft is already checked out to {0}", si.UserID);
else if (oi.OwnerType == 3)
message = message + string.Format("The folder is already checked out to {0}", si.UserID);
message += string.Format("The folder is already checked out to {0}", si.UserID);
rv = rv && false;
}
}
@@ -251,16 +238,9 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on SessionInfo.Get", ex);
}
}
public int CheckOutItem(int itemID, CheckOutType itemType)
{
int ownerID = SessionCheckOutItem.Execute(this.SessionID, itemID, itemType);
return ownerID;
}
public void CheckInItem(int ownerID)
{
SessionCheckInItem.Execute(ownerID);
}
private void DataPortal_Fetch(BeginSessionCriteria criteria)
public int CheckOutItem(int itemID, CheckOutType itemType) => SessionCheckOutItem.Execute(SessionID, itemID, itemType);
public void CheckInItem(int ownerID) => SessionCheckInItem.Execute(ownerID);
private void DataPortal_Fetch(BeginSessionCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.DataPortal_Fetch", GetHashCode());
try
@@ -298,78 +278,22 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
}
}
//private void DataPortal_Fetch(CanCheckOutItemCriteria criteria)
//{
// if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.DataPortal_Fetch", GetHashCode());
// try
// {
// using (SqlConnection cn = Database.VEPROMS_SqlConnection)
// {
// ApplicationContext.LocalContext["cn"] = cn;
// using (SqlCommand cm = cn.CreateCommand())
// {
// cm.CommandType = CommandType.StoredProcedure;
// cm.CommandText = "vesp_SessionCanCheckOutItem";
// cm.Parameters.AddWithValue("@ObjectID", criteria.ObjectID);
// cm.Parameters.AddWithValue("@ObjectType", criteria.ObjectType);
// using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// {
// while(dr.Read())
// if (!dr.Read())
// {
// _ErrorMessage = "No Record Found";
// return;
// }
// ReadData(dr);
// }
// }
// // removing of item only needed for local data portal
// if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client)
// ApplicationContext.LocalContext.Remove("cn");
// }
// }
// catch (Exception ex)
// {
// if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfo.DataPortal_Fetch", ex);
// _ErrorMessage = ex.Message;
// throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
// }
//}
[Serializable()]
protected class BeginSessionCriteria
{
private string _UserID;
public string UserID
{ get { return _UserID; } }
private string _MachineName;
public string MachineName
{ get { return _MachineName; } }
private int _ProcessID;
public int ProcessID
{ get { return _ProcessID; } }
public BeginSessionCriteria(string userID, string machineName, int processID)
private readonly string _UserID;
public string UserID => _UserID;
private readonly string _MachineName;
public string MachineName => _MachineName;
private readonly int _ProcessID;
public int ProcessID => _ProcessID;
public BeginSessionCriteria(string userID, string machineName, int processID)
{
_UserID = userID;
_MachineName = machineName;
_ProcessID = processID;
}
}
//[Serializable()]
//protected class CanCheckOutItemCriteria
//{
// private int _ObjectID;
// public int ObjectID
// { get { return _ObjectID; } }
// private CheckOutType _ObjectType;
// public CheckOutType ObjectType
// { get { return _ObjectType; } }
// public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
// {
// _ObjectID = objectID;
// _ObjectType = objectType;
// }
//}
}
public class TurnChangeManagerOff : CommandBase
{
@@ -473,20 +397,18 @@ namespace VEPROMS.CSLA.Library
public class SessionPing : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _SessionID;
public int SessionID
{
get { return _SessionID; }
set { _SessionID = value; }
}
#region Factory Methods
public static void Execute(int sessionID)
public int SessionID { get; set; }
#region Factory Methods
public static void Execute(int sessionID)
{
try
{
SessionPing cmd = new SessionPing();
cmd.SessionID = sessionID;
DataPortal.Execute<SessionPing>(cmd);
SessionPing cmd = new SessionPing
{
SessionID = sessionID
};
DataPortal.Execute<SessionPing>(cmd);
}
catch (Exception ex)
{
@@ -521,18 +443,16 @@ namespace VEPROMS.CSLA.Library
public class SessionEnd : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _SessionID;
public int SessionID
public int SessionID { get; set; }
#region Factory Methods
public static void Execute(int sessionID)
{
get { return _SessionID; }
set { _SessionID = value; }
}
#region Factory Methods
public static void Execute(int sessionID)
{
SessionEnd cmd = new SessionEnd();
cmd.SessionID = sessionID;
DataPortal.Execute<SessionEnd>(cmd);
SessionEnd cmd = new SessionEnd
{
SessionID = sessionID
};
DataPortal.Execute<SessionEnd>(cmd);
}
#endregion
#region Server-Side code
@@ -562,38 +482,21 @@ namespace VEPROMS.CSLA.Library
public class SessionCheckOutItem : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _SessionID;
public int SessionID
public int SessionID { get; set; }
public int ItemID { get; set; }
public int ItemType { get; set; }
public int OwnerID { get; set; }
#region Factory Methods
public static int Execute(int sessionID, int itemID, CheckOutType itemType)
{
get { return _SessionID; }
set { _SessionID = value; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
private int _ItemType;
public int ItemType
{
get { return _ItemType; }
set { _ItemType = value; }
}
private int _OwnerID;
public int OwnerID
{
get { return _OwnerID; }
set { _OwnerID = value; }
}
#region Factory Methods
public static int Execute(int sessionID, int itemID, CheckOutType itemType)
{
SessionCheckOutItem cmd = new SessionCheckOutItem();
cmd.SessionID = sessionID;
cmd.ItemID = itemID;
cmd.ItemType = (int)itemType;
cmd = DataPortal.Execute<SessionCheckOutItem>(cmd);
SessionCheckOutItem cmd = new SessionCheckOutItem
{
SessionID = sessionID,
ItemID = itemID,
ItemType = (int)itemType
};
cmd = DataPortal.Execute<SessionCheckOutItem>(cmd);
return cmd.OwnerID;
}
#endregion
@@ -629,19 +532,16 @@ namespace VEPROMS.CSLA.Library
public class SessionCheckInItem : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _OwnerID;
public int OwnerID
public int OwnerID { get; set; }
#region Factory Methods
public static void Execute(int ownerID)
{
get { return _OwnerID; }
set { _OwnerID = value; }
}
private int _ItemID;
#region Factory Methods
public static void Execute(int ownerID)
{
SessionCheckInItem cmd = new SessionCheckInItem();
cmd.OwnerID = ownerID;
DataPortal.Execute<SessionCheckInItem>(cmd);
SessionCheckInItem cmd = new SessionCheckInItem
{
OwnerID = ownerID
};
DataPortal.Execute<SessionCheckInItem>(cmd);
}
#endregion
#region Server-Side code
@@ -671,24 +571,17 @@ namespace VEPROMS.CSLA.Library
public class SessionChangedContents : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Int64 _LastContentChange;
public Int64 LastContentChange
public long LastContentChange { get; set; }
public Dictionary<int, long> ChangedContents { get; set; }
#region Factory Methods
public static Dictionary<int, long> Execute(long lastContentChanged)
{
get { return _LastContentChange; }
set { _LastContentChange = value; }
}
private Dictionary<int,Int64> _ChangedContents;
public Dictionary<int, Int64> ChangedContents
{
get { return _ChangedContents; }
set { _ChangedContents = value; }
}
#region Factory Methods
public static Dictionary<int, Int64> Execute(Int64 lastContentChanged)
{
SessionChangedContents cmd = new SessionChangedContents();
cmd.LastContentChange = lastContentChanged;
cmd = DataPortal.Execute<SessionChangedContents>(cmd);
SessionChangedContents cmd = new SessionChangedContents
{
LastContentChange = lastContentChanged
};
cmd = DataPortal.Execute<SessionChangedContents>(cmd);
return cmd.ChangedContents;
}
#endregion
@@ -706,9 +599,9 @@ namespace VEPROMS.CSLA.Library
cmd.Parameters.AddWithValue("@LastChanged", LastContentChange);
cmd.Parameters.AddWithValue("@UserID", Volian.Base.Library.VlnSettings.UserID);
SqlDataReader dr = cmd.ExecuteReader();
ChangedContents = new Dictionary<int, Int64>();
ChangedContents = new Dictionary<int, long>();
while (dr.Read())
ChangedContents.Add(dr.GetInt32(0), (Int64)dr.GetSqlInt64(1));
ChangedContents.Add(dr.GetInt32(0), (long)dr.GetSqlInt64(1));
}
}
}
@@ -723,24 +616,17 @@ namespace VEPROMS.CSLA.Library
public class SessionChangedItems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private Int64 _LastContentChange;
public Int64 LastContentChange
public long LastContentChange { get; set; }
public Dictionary<int, long> ChangedItems { get; set; }
#region Factory Methods
public static Dictionary<int, long> Execute(long lastContentChanged)
{
get { return _LastContentChange; }
set { _LastContentChange = value; }
}
private Dictionary<int, Int64> _ChangedItems;
public Dictionary<int, Int64> ChangedItems
{
get { return _ChangedItems; }
set { _ChangedItems = value; }
}
#region Factory Methods
public static Dictionary<int, Int64> Execute(Int64 lastContentChanged)
{
SessionChangedItems cmd = new SessionChangedItems();
cmd.LastContentChange = lastContentChanged;
cmd = DataPortal.Execute<SessionChangedItems>(cmd);
SessionChangedItems cmd = new SessionChangedItems
{
LastContentChange = lastContentChanged
};
cmd = DataPortal.Execute<SessionChangedItems>(cmd);
return cmd.ChangedItems;
}
#endregion
@@ -758,9 +644,9 @@ namespace VEPROMS.CSLA.Library
cmd.Parameters.AddWithValue("@LastChanged", LastContentChange);
cmd.Parameters.AddWithValue("@UserID", Volian.Base.Library.VlnSettings.UserID);
SqlDataReader dr = cmd.ExecuteReader();
ChangedItems = new Dictionary<int, Int64>();
ChangedItems = new Dictionary<int, long>();
while (dr.Read())
ChangedItems.Add(dr.GetInt32(0), (Int64)dr.GetSqlInt64(1));
ChangedItems.Add(dr.GetInt32(0), (long)dr.GetSqlInt64(1));
}
}
}
@@ -777,24 +663,17 @@ namespace VEPROMS.CSLA.Library
#region OwnerInfo stuff
public partial class OwnerInfoList
{
public static OwnerInfoList GetBySessionID(int sessionID)
{
OwnerInfoList tmp = DataPortal.Fetch<OwnerInfoList>(new GetBySessionIDCriteria(sessionID));
return tmp;
}
[Serializable()]
public static OwnerInfoList GetBySessionID(int sessionID) => DataPortal.Fetch<OwnerInfoList>(new GetBySessionIDCriteria(sessionID));
[Serializable()]
protected class GetBySessionIDCriteria
{
private int _SessionID;
public int SessionID { get { return _SessionID; } }
public GetBySessionIDCriteria(int sessionID)
{
_SessionID = sessionID;
}
}
private readonly int _SessionID;
public int SessionID => _SessionID;
public GetBySessionIDCriteria(int sessionID) => _SessionID = sessionID;
}
private void DataPortal_Fetch(GetBySessionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfoList.DataPortal_Fetch", GetHashCode());
try
{
@@ -809,7 +688,7 @@ namespace VEPROMS.CSLA.Library
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new OwnerInfo(dr));
while (dr.Read()) Add(new OwnerInfo(dr));
IsReadOnly = true;
}
}
@@ -820,7 +699,7 @@ namespace VEPROMS.CSLA.Library
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("OwnerInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
public static OwnerInfoList GetByVersionID(int versionID)
{
@@ -839,16 +718,13 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class GetByVersionIDCriteria
{
private int _VersionID;
public int VersionID { get { return _VersionID; } }
public GetByVersionIDCriteria(int versionID)
{
_VersionID = versionID;
}
private readonly int _VersionID;
public int VersionID => _VersionID;
public GetByVersionIDCriteria(int versionID) => _VersionID = versionID;
}
private void DataPortal_Fetch(GetByVersionIDCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfoList.DataPortal_Fetch", GetHashCode());
try
{
@@ -863,7 +739,7 @@ namespace VEPROMS.CSLA.Library
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read()) this.Add(new OwnerInfo(dr));
while (dr.Read()) Add(new OwnerInfo(dr));
IsReadOnly = true;
}
}
@@ -874,7 +750,7 @@ namespace VEPROMS.CSLA.Library
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("OwnerInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
}
public partial class OwnerInfo
@@ -899,13 +775,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class GetBySessionIDandFolderIDCriteria
{
private int _SessionID;
public int SessionID
{ get { return _SessionID; } }
private int _FolderID;
public int FolderID
{ get { return _FolderID; } }
public GetBySessionIDandFolderIDCriteria(int sessionID, int folderID)
private readonly int _SessionID;
public int SessionID => _SessionID;
private readonly int _FolderID;
public int FolderID => _FolderID;
public GetBySessionIDandFolderIDCriteria(int sessionID, int folderID)
{
_SessionID = sessionID;
_FolderID = folderID;
@@ -968,13 +842,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class GetBySessionIDandVersionIDCriteria
{
private int _SessionID;
public int SessionID
{ get { return _SessionID; } }
private int _VersionID;
public int VersionID
{ get { return _VersionID; } }
public GetBySessionIDandVersionIDCriteria(int sessionID, int versionID)
private readonly int _SessionID;
public int SessionID => _SessionID;
private readonly int _VersionID;
public int VersionID => _VersionID;
public GetBySessionIDandVersionIDCriteria(int sessionID, int versionID)
{
_SessionID = sessionID;
_VersionID = versionID;
@@ -1037,13 +909,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class GetByItemIDCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
private CheckOutType _ItemType;
public CheckOutType ItemType
{ get { return _ItemType; } }
public GetByItemIDCriteria(int itemID, CheckOutType itemType)
private readonly int _ItemID;
public int ItemID => _ItemID;
private readonly CheckOutType _ItemType;
public CheckOutType ItemType => _ItemType;
public GetByItemIDCriteria(int itemID, CheckOutType itemType)
{
_ItemID = itemID;
_ItemType = itemType;
@@ -1090,7 +960,7 @@ namespace VEPROMS.CSLA.Library
{
get
{
SessionInfo si = SessionInfo.Get(this.SessionID);
SessionInfo si = SessionInfo.Get(SessionID);
return si.UserID;
}
}
@@ -1101,32 +971,20 @@ namespace VEPROMS.CSLA.Library
public partial class UserInfo
{
public static bool CanEdit(UserInfo myUserInfo, DocVersionInfo myDVI)
{
return myUserInfo!=null && myDVI!=null && (myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI) || myUserInfo.IsWriter(myDVI));
}
public static bool CanEdit(UserInfo myUserInfo, DocVersionInfo myDVI) => myUserInfo != null && myDVI != null && (myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI) || myUserInfo.IsWriter(myDVI));
public static bool CanEditROs(UserInfo myUserInfo, DocVersionInfo myDVI)
{
return myUserInfo != null && myDVI != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI) || myUserInfo.IsROEditor(myDVI);
}
public static bool CanEditROs(UserInfo myUserInfo, DocVersionInfo myDVI) => myUserInfo != null && myDVI != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI) || myUserInfo.IsROEditor(myDVI);
public static bool CanCreateFolders(UserInfo myUserInfo, DocVersionInfo myDVI)
{
return myUserInfo != null && myDVI != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI);
}
public static bool CanCreateFolders(UserInfo myUserInfo, DocVersionInfo myDVI) => myUserInfo != null && myDVI != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(myDVI);
public static bool CanCreateFolders(UserInfo myUserInfo, FolderInfo fi)
{
return myUserInfo != null && fi != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(fi.MyParent); //B2020-111 allow if set amin controls parent
}
public static bool CanCreateFolders(UserInfo myUserInfo, FolderInfo fi) => myUserInfo != null && fi != null && myUserInfo.IsAdministrator() || myUserInfo.IsSetAdministrator(fi.MyParent); //B2020-111 allow if set amin controls parent
public bool IsAdministrator()
public bool IsAdministrator()
{
if (this.UserMembershipCount == 0)
if (UserMembershipCount == 0)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
foreach (MembershipInfo mi in UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
{
@@ -1145,10 +1003,10 @@ namespace VEPROMS.CSLA.Library
// would then be skipped (from where is called)
public bool IsSetAdministrator(FolderInfo fldinf)
{
if (this.UserMembershipCount == 0 || fldinf == null)
if (UserMembershipCount == 0 || fldinf == null)
return false;
foreach (MembershipInfo mi in this.UserMemberships)
foreach (MembershipInfo mi in UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
{
@@ -1173,10 +1031,10 @@ namespace VEPROMS.CSLA.Library
public bool IsSetAdministrator(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
if (UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
foreach (MembershipInfo mi in UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
{
@@ -1200,10 +1058,10 @@ namespace VEPROMS.CSLA.Library
public bool IsWriter(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
if (UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
foreach (MembershipInfo mi in UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
{
@@ -1227,10 +1085,10 @@ namespace VEPROMS.CSLA.Library
public bool IsReviewer(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
if (UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
foreach (MembershipInfo mi in UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
{
@@ -1254,10 +1112,10 @@ namespace VEPROMS.CSLA.Library
public bool IsROEditor(DocVersionInfo dv)
{
if (this.UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
if (UserMembershipCount == 0 || dv == null) // B2022-026 RO Memory reduction - check for null DocVersionInfo
return false;
foreach (MembershipInfo mi in this.UserMemberships)
foreach (MembershipInfo mi in UserMemberships)
{
if (mi.EndDate == string.Empty && mi.MyGroup.GroupAssignments != null) //B2024-051 added null check - user assigned to non-existing procedure set
{
@@ -1279,12 +1137,9 @@ namespace VEPROMS.CSLA.Library
return false;
}
// B2018-112 added for easy check if user's PROMS Security allows making edits - used in StepTabRibbon - SetButtonAndMenuEnabling()
public bool IsAllowedToEdit(DocVersionInfo dvi)
{
return IsAdministrator() || IsSetAdministrator(dvi) || IsWriter(dvi);
}
public static UserInfo GetByUserID(string userID)
// B2018-112 added for easy check if user's PROMS Security allows making edits - used in StepTabRibbon - SetButtonAndMenuEnabling()
public bool IsAllowedToEdit(DocVersionInfo dvi) => IsAdministrator() || IsSetAdministrator(dvi) || IsWriter(dvi);
public static UserInfo GetByUserID(string userID)
{
try
{
@@ -1305,14 +1160,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class GetByUserIDCriteria
{
private string _UserID;
public string UserID
{ get { return _UserID; } }
public GetByUserIDCriteria(string userID)
{
_UserID = userID;
}
}
private readonly string _UserID;
public string UserID => _UserID;
public GetByUserIDCriteria(string userID) => _UserID = userID;
}
private void DataPortal_Fetch(GetByUserIDCriteria criteria)
{