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
@@ -5,31 +5,22 @@ using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using Csla.Validation;
namespace VEPROMS.CSLA.Library
{
public class ESP_FixHyphens : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int AffectedRows { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _AffectedRows;
public int AffectedRows
{
get { return _AffectedRows; }
set { _AffectedRows = value; }
}
public static int Execute(string storedProcedure)
{
ESP_DeletePDFs cmd = new ESP_DeletePDFs();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_DeletePDFs>(cmd);
ESP_DeletePDFs cmd = new ESP_DeletePDFs
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_DeletePDFs>(cmd);
return cmd.AffectedRows;
}
#endregion
@@ -59,24 +50,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_DeletePDFs : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int AffectedRows { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _AffectedRows;
public int AffectedRows
{
get { return _AffectedRows; }
set { _AffectedRows = value; }
}
public static int Execute(string storedProcedure)
{
ESP_DeletePDFs cmd = new ESP_DeletePDFs();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_DeletePDFs>(cmd);
ESP_DeletePDFs cmd = new ESP_DeletePDFs
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_DeletePDFs>(cmd);
return cmd.AffectedRows;
}
#endregion
@@ -106,24 +89,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_IdentifyDisconnectedItems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_IdentifyDisconnectedItems cmd = new ESP_IdentifyDisconnectedItems();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_IdentifyDisconnectedItems>(cmd);
ESP_IdentifyDisconnectedItems cmd = new ESP_IdentifyDisconnectedItems
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_IdentifyDisconnectedItems>(cmd);
return cmd.RowCount;
}
#endregion
@@ -157,24 +132,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_PurgeDisconnectedItems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_PurgeDisconnectedItems cmd = new ESP_PurgeDisconnectedItems();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_PurgeDisconnectedItems>(cmd);
ESP_PurgeDisconnectedItems cmd = new ESP_PurgeDisconnectedItems
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_PurgeDisconnectedItems>(cmd);
return cmd.RowCount;
}
#endregion
@@ -206,24 +173,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_GetROAssoc : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_GetROAssoc cmd = new ESP_GetROAssoc();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_GetROAssoc>(cmd);
ESP_GetROAssoc cmd = new ESP_GetROAssoc
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_GetROAssoc>(cmd);
return cmd.RowCount;
}
#endregion
@@ -257,24 +216,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_CleanupROAssoc : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_CleanupROAssoc cmd = new ESP_CleanupROAssoc();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_CleanupROAssoc>(cmd);
ESP_CleanupROAssoc cmd = new ESP_CleanupROAssoc
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_CleanupROAssoc>(cmd);
return cmd.RowCount;
}
#endregion
@@ -307,24 +258,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_GetUnusedRoFsts : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_GetUnusedRoFsts cmd = new ESP_GetUnusedRoFsts();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_GetUnusedRoFsts>(cmd);
ESP_GetUnusedRoFsts cmd = new ESP_GetUnusedRoFsts
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_GetUnusedRoFsts>(cmd);
return cmd.RowCount;
}
#endregion
@@ -358,24 +301,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_GetUnusedFigures : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_GetUnusedFigures cmd = new ESP_GetUnusedFigures();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_GetUnusedFigures>(cmd);
ESP_GetUnusedFigures cmd = new ESP_GetUnusedFigures
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_GetUnusedFigures>(cmd);
return cmd.RowCount;
}
#endregion
@@ -409,24 +344,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_PurgeUnusedRoFstsAndFigures : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public int RowCount { get; set; }
public static int Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _RowCount;
public int RowCount
{
get { return _RowCount; }
set { _RowCount = value; }
}
public static int Execute(string storedProcedure)
{
ESP_PurgeUnusedRoFstsAndFigures cmd = new ESP_PurgeUnusedRoFstsAndFigures();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_PurgeUnusedRoFstsAndFigures>(cmd);
ESP_PurgeUnusedRoFstsAndFigures cmd = new ESP_PurgeUnusedRoFstsAndFigures
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_PurgeUnusedRoFstsAndFigures>(cmd);
return cmd.RowCount;
}
#endregion
@@ -458,24 +385,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_IdentifyNonEditableItems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public List<ItemInfo> ItemInfoList { get; set; } = new List<ItemInfo>();
public static List<ItemInfo> Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private List<ItemInfo> _ItemInfoList = new List<ItemInfo>();
public List<ItemInfo> ItemInfoList
{
get { return _ItemInfoList; }
set { _ItemInfoList = value; }
}
public static List<ItemInfo> Execute(string storedProcedure)
{
ESP_IdentifyNonEditableItems cmd = new ESP_IdentifyNonEditableItems();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_IdentifyNonEditableItems>(cmd);
ESP_IdentifyNonEditableItems cmd = new ESP_IdentifyNonEditableItems
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_IdentifyNonEditableItems>(cmd);
return cmd.ItemInfoList;
}
#endregion
@@ -508,24 +427,16 @@ namespace VEPROMS.CSLA.Library
public class ESP_GetDatabaseSessions : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
#region Factory Methods
public string StoredProcedure { get; set; }
public string ResultsString { get; set; }
public static string Execute(string storedProcedure)
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private string _ResultsString;
public string ResultsString
{
get { return _ResultsString; }
set { _ResultsString = value; }
}
public static string Execute(string storedProcedure)
{
ESP_GetDatabaseSessions cmd = new ESP_GetDatabaseSessions();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ESP_GetDatabaseSessions>(cmd);
ESP_GetDatabaseSessions cmd = new ESP_GetDatabaseSessions
{
StoredProcedure = storedProcedure
};
DataPortal.Execute<ESP_GetDatabaseSessions>(cmd);
return cmd.ResultsString;
}
#endregion
@@ -579,7 +490,7 @@ namespace VEPROMS.CSLA.Library
}
}
}
_ResultsString = sbs.ToString();
ResultsString = sbs.ToString();
}
}
}
@@ -591,12 +502,4 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
public class ESP_FindROProblems : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
#endregion
#region Server-Side Code
#endregion
}
}
@@ -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;
@@ -11,12 +9,9 @@ namespace VEPROMS.CSLA.Library
{
public partial class AnnotationInfo
{
public override string ToString()
{
return _SearchText;
}
#region JCB Annotation Status
private bool _IsAnnotationNew = false;
public override string ToString() => _SearchText;
#region JCB Annotation Status
private bool _IsAnnotationNew = false;
public bool IsAnnotationNew
{
@@ -49,11 +44,8 @@ namespace VEPROMS.CSLA.Library
}
public partial class AnnotationType
{
public override string ToString()
{
return _Name;
}
[NonSerialized]
public override string ToString() => _Name;
[NonSerialized]
private AnnotationTypeConfig _AnnotationTypeConfig;
public AnnotationTypeConfig AnnotationTypeConfig
{
@@ -83,79 +75,69 @@ namespace VEPROMS.CSLA.Library
return _AnnotationTypeConfig;
}
}
public static List<AnnotationTypeInfo> AllList()
public static List<AnnotationTypeInfo> AllList() => AnnotationTypeInfo._CacheList;
public override string ToString() => _Name;
public static AnnotationTypeInfo GetByName(string name)
{
//return _AllList;
return AnnotationTypeInfo._CacheList;
try
{
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationTypeInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
}
}
public override string ToString()
[Serializable()]
protected class GetByNameCriteria
{
return _Name;
private readonly string _Name;
public string Name => _Name;
public GetByNameCriteria(string name) => _Name = name;
}
public static AnnotationTypeInfo GetByName(string name)
{
try
{
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up AnnotationTypeInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
}
}
[Serializable()]
protected class GetByNameCriteria
{
private string _Name;
public string Name { get { return _Name; } }
public GetByNameCriteria(string name)
{
_Name = name;
}
}
private void DataPortal_Fetch(GetByNameCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.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 = "getAnnotationTypeByName";
cm.CommandTimeout = Database.SQLTimeout;
cm.Parameters.AddWithValue("@Name", criteria.Name);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
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("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
}
}
}
private void DataPortal_Fetch(GetByNameCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.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 = "getAnnotationTypeByName";
cm.CommandTimeout = Database.SQLTimeout;
cm.Parameters.AddWithValue("@Name", criteria.Name);
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
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("AnnotationTypeInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
}
}
}
public partial class AnnotationTypeInfoList
{
public static void Refresh()
@@ -177,44 +159,20 @@ namespace VEPROMS.CSLA.Library
_TypeID = anotypeid;
MarkDirty(); // force the record update
Save();
//Update(); // commit record to database
}
}
public void CommitChanges()
{
MarkDirty(); // force the record update
Save(true);
//Update();
}
public static void DeleteAnnotation(AnnotationInfo obj)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
// ItemInfo nextItem = item.NextItem;
// ItemInfo prevItem = item.MyPrevious;
// item.OnBeforeDelete();
DataPortal.Delete(new DeleteCriteria(obj.AnnotationID, Volian.Base.Library.VlnSettings.UserID));
AnnotationInfo.StaticOnInfoChanged();
// if (nextItem != null) // Adjust PreviousID for NextItem
// {
// ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID);
// // The order of the next two methods was required to fix a null reference
// // when getting myparent. This bug was found when deleting a node from the
// // tree when the RTBItem was not open (i.e. in the step editor window).
// nextItem.RefreshItemParts();
// //nextItem.ResetOrdinal(); - UpdateTransitionText calls ResetOrdinal
// nextItem.UpdateTransitionText();
// }
// else if (prevItem != null)
// {
// prevItem.RefreshNextItems();
// if (prevItem.IsCaution || prevItem.IsNote) prevItem.ResetOrdinal();
// prevItem.UpdateTransitionText();
// }
// ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
}
catch (Exception ex)
{
@@ -228,8 +186,6 @@ namespace VEPROMS.CSLA.Library
public static void DeleteAnnotationProcByType(int typID, string procList)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
DataPortal.Delete(new DeleteAnnotationProcByTypeCriteria(typID, procList));
@@ -247,8 +203,6 @@ namespace VEPROMS.CSLA.Library
public static void DeleteAnnotationDocvByType(int typID, string versionID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
DataPortal.Delete(new DeleteAnnotationDocvByTypeCriteria(typID, versionID));
@@ -266,8 +220,6 @@ namespace VEPROMS.CSLA.Library
public static int getAnnotationProcCnt(int typID, string procList)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
Annotation ProcCnt = DataPortal.Fetch<Annotation>(new getAnnotationCountProcCriteria(typID, procList));
@@ -287,8 +239,6 @@ namespace VEPROMS.CSLA.Library
public static int getAnnotationCountDocv(int typID, string procList)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
try
{
Annotation DocvCnt = DataPortal.Fetch<Annotation>(new getAnnotationCountDocvCriteria(typID, procList));
@@ -319,10 +269,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class DeleteCriteria
{
private int _AnnotationID;
public int AnnotationID
{ get { return _AnnotationID; } }
private string _UserID;
private readonly int _AnnotationID;
public int AnnotationID => _AnnotationID;
private string _UserID;
public string UserID
{
get { return _UserID; }
@@ -364,14 +313,12 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class DeleteAnnotationProcByTypeCriteria
{
private int _typeID;
public int TypeID
{ get { return _typeID; } }
private readonly int _typeID;
public int TypeID => _typeID;
private string _procList;
public string ProcList
{ get { return _procList; } }
public DeleteAnnotationProcByTypeCriteria(int typeID, string procList)
private readonly string _procList;
public string ProcList => _procList;
public DeleteAnnotationProcByTypeCriteria(int typeID, string procList)
{
_typeID = typeID;
_procList = procList;
@@ -407,14 +354,12 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class DeleteAnnotationDocvByTypeCriteria
{
private int _typeID;
public int TypeID
{ get { return _typeID; } }
private readonly int _typeID;
public int TypeID => _typeID;
private string _versionID;
public string VersionID
{ get { return _versionID; } }
public DeleteAnnotationDocvByTypeCriteria(int typeID, string versionID)
private readonly string _versionID;
public string VersionID => _versionID;
public DeleteAnnotationDocvByTypeCriteria(int typeID, string versionID)
{
_typeID = typeID;
_versionID = versionID;
@@ -459,16 +404,15 @@ namespace VEPROMS.CSLA.Library
{
private int _procCnt;
public int ProcCnt
{ get { return _procCnt; }
set { _procCnt = value; }
{
get { return _procCnt; }
set { _procCnt = value; }
}
private int _typeID;
public int TypeID
{ get { return _typeID; } }
private string _procList;
public string ProcList
{ get { return _procList; } }
public getAnnotationCountProcCriteria(int typeID, string procList, int procCnt = 0)
private readonly int _typeID;
public int TypeID => _typeID;
private readonly string _procList;
public string ProcList => _procList;
public getAnnotationCountProcCriteria(int typeID, string procList, int procCnt = 0)
{
_typeID = typeID;
_procList = procList;
@@ -517,16 +461,15 @@ namespace VEPROMS.CSLA.Library
{
private int _docvCnt;
public int DocvCnt
{ get { return _docvCnt; }
set { _docvCnt = value; }
{
get { return _docvCnt; }
set { _docvCnt = value; }
}
private int _TypeID;
public int TypeID
{ get { return _TypeID; } }
private string _docvList;
public string DocvList
{ get { return _docvList; } }
public getAnnotationCountDocvCriteria(int typeID, string docvList, int docvCnt = 0)
private readonly int _TypeID;
public int TypeID => _TypeID;
private readonly string _docvList;
public string DocvList => _docvList;
public getAnnotationCountDocvCriteria(int typeID, string docvList, int docvCnt = 0)
{
_TypeID = typeID;
_docvList = docvList;
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;
using Volian.Base.Library;
@@ -438,29 +437,29 @@ namespace VEPROMS.CSLA.Library
count += lst.Count;
if (count == 0) return "";
string output = typeof(T).Name;
output += "\t" + cache.Count;
output += "\t" + count + "\r\n";
output += $"\t{cache.Count}";
output += $"\t{count}\r\n";
return output;
}
private static string Counts<T>(int count)
{
if (count == 0) return "";
string output = typeof(T).Name;
output += "\t" + count + "\r\n";
output += $"\t{count}\r\n";
return output;
}
private static string Counts<T>(int countNotDisposed, int countNotFinalized)
{
if (countNotDisposed == 0 && countNotFinalized == 0) return "";
string output = typeof(T).Name;
output += "\t" + countNotDisposed + "\t" + countNotFinalized + "\r\n";
output += $"\t{countNotDisposed}\t{countNotFinalized}\r\n";
return output;
}
private static string Counts<T>(int countCreated, int countNotDisposed, int countNotFinalized)
{
if (countCreated == 0) return "";
string output = typeof(T).Name;
output += "\t" + countCreated + "\t" + countNotDisposed + "\t" + countNotFinalized + "\r\n";
output += $"\t{countCreated}\t{countNotDisposed}\t{countNotFinalized}\r\n";
return output;
}
}
@@ -475,7 +474,8 @@ namespace VEPROMS.CSLA.Library
#region Stack
public partial class Content
{
private static List<string> _MyStack = new List<string>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<string> _MyStack = new List<string>();
public static string MyStack
{
get
@@ -519,15 +519,13 @@ namespace VEPROMS.CSLA.Library
return _MyStack.IndexOf(stk);
}
}
private int _StackIndex = StaticStackIndex;
public int StackIndex
{
get { return _StackIndex; }
}
}
private readonly int _StackIndex = StaticStackIndex;
public int StackIndex => _StackIndex;
}
public partial class ContentInfo
{
private static List<string> _MyStack = new List<string>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<string> _MyStack = new List<string>();
public static string MyStack
{
get
@@ -571,15 +569,13 @@ namespace VEPROMS.CSLA.Library
return _MyStack.IndexOf(stk);
}
}
private int _StackIndex = StaticStackIndex;
public int StackIndex
{
get { return _StackIndex; }
}
}
private readonly int _StackIndex = StaticStackIndex;
public int StackIndex => _StackIndex;
}
public partial class DocVersionInfo
{
private static List<string> _MyStack = new List<string>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<string> _MyStack = new List<string>();
public static string MyStack
{
get
@@ -623,12 +619,9 @@ namespace VEPROMS.CSLA.Library
return _MyStack.IndexOf(stk);
}
}
private int _StackIndex = StaticStackIndex;
public int StackIndex
{
get { return _StackIndex; }
}
}
private readonly int _StackIndex = StaticStackIndex;
public int StackIndex => _StackIndex;
}
public partial class PartInfo
{
public static HashSet<int> CacheList
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
@@ -21,26 +19,28 @@ namespace VEPROMS.CSLA.Library
// if the dictionary hasn't been set yet,
if (ColorIndx==null)
{
ColorIndx = new Dictionary<string, int>();
ColorIndx["black"] = 1;
ColorIndx["blue"] = 2;
ColorIndx["green"] = 3;
ColorIndx["cyan"] = 4;
ColorIndx["red"] = 5;
ColorIndx["magenta"] = 6;
ColorIndx["brown"] = 7;
ColorIndx["lightgray"] = 8;
ColorIndx["darkgray"] = 9;
ColorIndx["lightblue"] = 10;
ColorIndx["lightgreen"] = 11;
ColorIndx["lightcyan"] = 12;
ColorIndx["lightred"] = 13;
ColorIndx["lightmagenta"] = 14;
ColorIndx["yellow"] = 15;
ColorIndx["white"] = 16;
ColorIndx["ro"] = 17;
ColorIndx["trans"] = 18;
ColorIndx["editbackground"] = 19;
ColorIndx = new Dictionary<string, int>
{
["black"] = 1,
["blue"] = 2,
["green"] = 3,
["cyan"] = 4,
["red"] = 5,
["magenta"] = 6,
["brown"] = 7,
["lightgray"] = 8,
["darkgray"] = 9,
["lightblue"] = 10,
["lightgreen"] = 11,
["lightcyan"] = 12,
["lightred"] = 13,
["lightmagenta"] = 14,
["yellow"] = 15,
["white"] = 16,
["ro"] = 17,
["trans"] = 18,
["editbackground"] = 19
};
}
return ColorIndx[color];
}
@@ -49,49 +49,49 @@ namespace VEPROMS.CSLA.Library
// This gets the rtf color table string for the input color.
public static string GetTableString(string color)
{
Dictionary<string, int> ColorIndx = new Dictionary<string, int>();
if (ColorRtf == null)
{
ColorRtf = new Dictionary<string, string>();
// color table, from 16-bit code, is defined as (in order):
// black=0,0,0
// blue=0,0,255
// green=0,155,12
// cyan=0,136,159
// red=255,0,0
// magenta=202,28,175
// brown=128,64,0
// lightgray=0,0,0
// darkgray=0,0,0
// lightblue=0,0,255
// lightgreen=0,255,0
// lightcyan=0,0,255
// lightred=209,29,183
// lightmagenta=255,0,255
// yellow=255,0,0
// white=128,128,128
// ro=255,128,0
// editbackground=192,192,192
ColorRtf["black"] = "\\red0\\green0\\blue0;";
ColorRtf["blue"] = "\\red0\\green0\\blue255;";
ColorRtf["green"] = "\\red0\\green155\\blue12;";
ColorRtf["cyan"] = "\\red0\\green136\\blue159;";
ColorRtf["red"] = "\\red255\\green0\\blue0;";
ColorRtf["magenta"] = "\\red202\\green28\\blue175;";
ColorRtf["brown"] = "\\red128\\green64\\blue0;";
ColorRtf["lightgray"] = "\\red100\\green100\\blue100;";
ColorRtf["darkgray"] = "\\red10\\green10\\blue10;";
ColorRtf["lightblue"] = "\\red0\\green0\\blue255;";
ColorRtf["lightgreen"] = "\\red0\\green255\\blue0;";
ColorRtf["lightcyan"] = "\\red0\\green0\\blue255;";
ColorRtf["lightred"] = "\\red209\\green29\\blue183;";
ColorRtf["lightmagenta"] = "\\red255\\green0\\blue255;";
ColorRtf["yellow"] = "\\red255\\green0\\blue0;";
ColorRtf["white"] = "\\red128\\green128\\blue128;";
ColorRtf["ro"] = "\\red255\\green128\\blue0;";
ColorRtf["trans"] = "\\red255\\green128\\blue0;";
ColorRtf["editbackground"] = "\\red192\\green192\\blue192;";
ColorRtf = new Dictionary<string, string>
{
// color table, from 16-bit code, is defined as (in order):
// black=0,0,0
// blue=0,0,255
// green=0,155,12
// cyan=0,136,159
// red=255,0,0
// magenta=202,28,175
// brown=128,64,0
// lightgray=0,0,0
// darkgray=0,0,0
// lightblue=0,0,255
// lightgreen=0,255,0
// lightcyan=0,0,255
// lightred=209,29,183
// lightmagenta=255,0,255
// yellow=255,0,0
// white=128,128,128
// ro=255,128,0
// editbackground=192,192,192
["black"] = "\\red0\\green0\\blue0;",
["blue"] = "\\red0\\green0\\blue255;",
["green"] = "\\red0\\green155\\blue12;",
["cyan"] = "\\red0\\green136\\blue159;",
["red"] = "\\red255\\green0\\blue0;",
["magenta"] = "\\red202\\green28\\blue175;",
["brown"] = "\\red128\\green64\\blue0;",
["lightgray"] = "\\red100\\green100\\blue100;",
["darkgray"] = "\\red10\\green10\\blue10;",
["lightblue"] = "\\red0\\green0\\blue255;",
["lightgreen"] = "\\red0\\green255\\blue0;",
["lightcyan"] = "\\red0\\green0\\blue255;",
["lightred"] = "\\red209\\green29\\blue183;",
["lightmagenta"] = "\\red255\\green0\\blue255;",
["yellow"] = "\\red255\\green0\\blue0;",
["white"] = "\\red128\\green128\\blue128;",
["ro"] = "\\red255\\green128\\blue0;",
["trans"] = "\\red255\\green128\\blue0;",
["editbackground"] = "\\red192\\green192\\blue192;"
};
}
return ColorRtf[color];
}
+140 -364
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;
@@ -80,7 +79,7 @@ namespace VEPROMS.CSLA.Library
{
string rv = ConvertTransitionToText(tran, newvalue);
//Text = Text.Substring(0, myIndex - 14) + gg + Text.Substring(myIndex + myLength);
using (Item myitem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
using (Item myitem = ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// B2016-225 (follow through) added more descriptive Annotation Type when transition is converted to text]
@@ -161,13 +160,11 @@ namespace VEPROMS.CSLA.Library
else
{ // look for rtf font command and insert it around the special char (i.e. symbol char)
int ii = orgText.IndexOf(specChar);
int fnt1 = -1;
int fnt2 = -1;
if (ii > -1)
if (ii > -1)
{
fnt1 = orgText.LastIndexOf(@"\f", ii);
fnt2 = orgText.IndexOf(@"\f", ii);
if (fnt1 != -1 && fnt2 != -1)
int fnt1 = orgText.LastIndexOf(@"\f", ii);
int fnt2 = orgText.IndexOf(@"\f", ii);
if (fnt1 != -1 && fnt2 != -1)
newValue = newValue.Replace(specChar, orgText.Substring(fnt1, 3) + specChar + orgText.Substring(fnt2, 3) + " ");
}
}
@@ -199,11 +196,8 @@ namespace VEPROMS.CSLA.Library
}
else
lookFor = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
int lastIndex = 0;
string newText = MyGrid.Data;
foreach (Match mm in ms)
{
int offset = mm.Index;
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
if (m != null && m.Groups.Count > 1)
{
@@ -228,8 +222,7 @@ namespace VEPROMS.CSLA.Library
}
break; // Text has been processed
}
lastIndex = mm.Index + mm.Length;
}
}
return;
}
public string ConvertTransitionToText(TransitionInfo tran, string value)
@@ -554,13 +547,13 @@ namespace VEPROMS.CSLA.Library
}
if (value == "?" || gg != newvalue)
{
MyGrid.Data = Content.ConvertGridROsToText(MyGrid.Data, mmg, mg, newvalue); // B2017-060 convert the RO in the grid (table) to text
MyGrid.Data = ConvertGridROsToText(MyGrid.Data, mmg, mg, newvalue); // B2017-060 convert the RO in the grid (table) to text
}
}
}
}
}
return retval == null ? "" : retval;
return retval ?? "";
}
// B2017-060 logic pulled from dlgExportImport to covert a RO in a table (grid) to text
public static string ConvertGridROsToText(string data, Match mmg, Match mg, string ss)
@@ -601,8 +594,8 @@ namespace VEPROMS.CSLA.Library
string retval = null;
if (value == "?")
{
retval = this.ConvertROToText(rousg, value, rotype, origROFstInfo, roidFrmImportStep);
using (Item myitem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
retval = ConvertROToText(rousg, value, rotype, origROFstInfo, roidFrmImportStep);
using (Item myitem = ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// B2016-225 (follow through) added more descriptive Annotation Type when RO is converted to text
@@ -638,7 +631,7 @@ namespace VEPROMS.CSLA.Library
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
if (!saveAnnotation)
{
using (Item myitem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
using (Item myitem = ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myitem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// B2016-225 (follow through) added more descriptive Annotation Type when RO is converted to text
@@ -836,21 +829,17 @@ namespace VEPROMS.CSLA.Library
{
return str.Replace(@"\u8209?", "-").Replace(@"\u160?", " "); //dash and hard space
}
//C2022-028 (only used from Amin Tools) check the RO link text - compare with RO Usage information, annotate RO links that are bad
public bool CheckROLinkTextandUsage(ref int BadROLinksCount, ref int CheckROLinksCount, ref int FixedROLinksCount)
//C2022-028 (only used from Admin Tools) check the RO link text - compare with RO Usage information, annotate RO links that are bad
public bool CheckROLinkTextandUsage(ref int BadROLinksCount, ref int CheckROLinksCount)
{
/*** needed if we fix RO link text
bool bFixedROLinks = false;
bool bFixedTableDataText = false;
***/
if (this.Text.Contains("#Link:ReferencedObject:"))
if (Text.Contains("#Link:ReferencedObject:"))
{
if (this.ContentRoUsageCount == 0) // Procedure text has one or more links but no RO Usage records
if (ContentRoUsageCount == 0) // Procedure text has one or more links but no RO Usage records
{
CheckROLinksCount++;
_MyLog.ErrorFormat(string.Format("No RO usage records for RO link(s) - ContentID = {0}", this.ContentID));
using (Item myItem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache
_MyLog.ErrorFormat(string.Format("No RO usage records for RO link(s) - ContentID = {0}", ContentID));
using (Item myItem = ContentItems[0].MyItem) // so that myitem does not stay in cache
{
myItem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed
Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", "Incomplete RO Link Information for all RO References in this text - Relink RO References", null);
@@ -862,7 +851,6 @@ namespace VEPROMS.CSLA.Library
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink); // finds all the links (both RO and Transitions)
string lookFor = "#Link:ReferencedObject:";
string fixedContentText = Text;
if (ms.Count > 0)
{
int roCnt = 0;
@@ -892,18 +880,17 @@ namespace VEPROMS.CSLA.Library
bool GoodROUsageID = false;
bool GoodROID = false;
// Check each ContentRoUsages and look for a matching ROUsageID and ROID
if (iRousage > 0 && this.ContentRoUsageCount > 0)
if (iRousage > 0 && ContentRoUsageCount > 0)
{
int lastROUsageID = -1;
string lastROID = "";
RoUsageInfo badRoUsageInfo = null;
foreach (RoUsageInfo rui in this.ContentItems[0].MyItem.MyItemInfo.MyContent.ContentRoUsages)
foreach (RoUsageInfo rui in ContentItems[0].MyItem.MyItemInfo.MyContent.ContentRoUsages)
{
GoodROID = rui.ROID.Equals(sROid); //does this usage record have a matching ROID with the link text?
GoodROUsageID = rui.ROUsageID.Equals(iRousage); //does the usage record have a matching ROUsageID with the link text?
if (GoodROID && GoodROUsageID)
{
//myROUsages.RemoveAt(myROUsageCnt - 1);
break; // jump out loop - valid RO Usage record found
}
if (GoodROID && !GoodROUsageID)
@@ -918,46 +905,24 @@ namespace VEPROMS.CSLA.Library
{
BadROLinksCount++;
// Add detail information to the error log
_MyLog.ErrorFormat(string.Format("Invalid ROID - ContentID = {0} Link - {1}", this.ContentID, mm.Value));
_MyLog.ErrorFormat(string.Format("Invalid ROID - ContentID = {0} Link - {1}", ContentID, mm.Value));
sAnnotationText += string.Format("Bad RO Instance {0} - RO Needs Relinked - RO Text different than RO Data\n", roCnt);
}
else if (!GoodROUsageID) // Link does not have a valid ROUsage record for that RO link - add annotation
{
BadROLinksCount++;
/*********
//** below is logic to replace the ROUsageID in the linked text with one (for this contentID) that has the same ROID
//** Commented out for now as this was test code for now - don't want to give to customers until we are comfortable
//if (lastROUsageID != -1)
//{
// // set the ROUsageID in the link text to last good ROUsageID found in ROUsage table
// linkText = linkText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
// fixedContentText = fixedContentText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
// bFixedROLinks = true; // set to true so we know to update content text
// _MyLog.InfoFormat(string.Format("Fixed Invalid RO Link - ContentID = {0} badLink - {1} goodLink - {2}",this.ContentID, mm.Value, linkText));
// FixedROLinksCount++;
// using (Item myItem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
// {
// myItem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
// //Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", string.Format("Invalid RO Usage ID for RO Instance {0}",roCnt), null);
// Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Fixed Bad RO link"), "", string.Format("Fixed RO Instance {0} - Verify RO Value", roCnt), null);
// }
//}
*********/
//else
//{
// Add detail information to the error log
_MyLog.ErrorFormat(string.Format("Invalid ROUsageID - ContentID = {0} Link - {1}", this.ContentID, mm.Value));
sAnnotationText += string.Format("RO Instance {0} Needs Relinked - Value Not Able To Update\n", roCnt);
//}
// Add detail information to the error log
_MyLog.ErrorFormat(string.Format("Invalid ROUsageID - ContentID = {0} Link - {1}", ContentID, mm.Value));
sAnnotationText += string.Format("RO Instance {0} Needs Relinked - Value Not Able To Update\n", roCnt);
}
}
}
}
if (roCnt < this.ContentRoUsageCount)
if (roCnt < ContentRoUsageCount)
{
BadROLinksCount++;
// there are more RO Usage records then there links in the step
_MyLog.WarnFormat(string.Format("Possible missing RO links, more RO Usage records than Links - ContentID = {0}", this.ContentID));
_MyLog.WarnFormat(string.Format("Possible missing RO links, more RO Usage records than Links - ContentID = {0}", ContentID));
sAnnotationText += "Possible missing RO links.\n";
}
// if any bad RO links were found, put the information in an Annotation
@@ -965,113 +930,15 @@ namespace VEPROMS.CSLA.Library
{
char[] newLine = { '\n' };
sAnnotationText = sAnnotationText.TrimEnd(newLine);
using (Item myItem = this.ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
using (Item myItem = ContentItems[0].MyItem) // so that myitem does not stay in cache B2016-153
{
myItem.DisposeOfContent = false; // don't dispose of the contents may be needed if more than one RO needs processed - part of B2017-060
//Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", string.Format("Invalid RO Usage ID for RO Instance {0}",roCnt), null);
Annotation.MakeAnnotation(myItem, AnnotationType.GetByNameOrCreate("Bad RO link"), "", sAnnotationText, null);
}
}
/*** COMMENTED OUT BECAUSE WE NOT MAKING CHANGES TO THE DATA - FOR NOW
//if (bFixedROLinks)
//{
// // save content text
// Text = fixedContentText;
//}
*****/
/*******
// if we fix RO links in the RTF then see if there is a grid to update too.
// WE DON'T NEED TO ADD ANNOTATIONS AS THAT IS DONE ABOVE (FOR THE RTF OF THE TABLE - BELOW IS THE XML OF THE TABLE
// *** bFixedROLinks WILL REMAIN FALSE FOR NOW AS WE ARE NOT CHANGING LINK TEXT - THIS WILL PREVENT THE CHECKING OF THE XML TABLE
if (bFixedROLinks && MyGrid != null && MyGrid.Data.Length > 0)
{
string fixedTableDataText = MyGrid.Data;
// **** NEED LOGIC TO CHECK RO TABLES ****
//if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
//{
// if (origROFstInfo != null)
// {
// List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
// if (MyGrid.Data != retlist[1])
// {
// MyGrid.Data = retlist[1];
// retval = Text;
// if (Text != retlist[0])
// Text = retlist[0];
// }
// }
//}
//else
{
// if it's an ro within a table, need to process into an flex grid to save the grid data:
string findLinkXml = @"&lt;START\].*?\[END&gt;";
//string lookForXml = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;$", rousg.ROUsageID);
string lookForXml = "#Link:ReferencedObject:";
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
Match mg = Regex.Match(mmg.Value, lookForXml);// look for Referenced Object link in linked text
if (mg != null && mg.Groups.Count > 1)
{
string tblLinkText = mmg.Value; // the link text in the table XML
int rousgidx = mg.Index + mg.Length;
int rousagid_len = mmg.Value.IndexOf(" ", rousgidx) - rousgidx;
string sROusageID = mmg.Value.Substring(rousgidx, rousagid_len); // ROUsageID from link text
int roidIdx = rousgidx + rousagid_len + 1;
int roid_Len = mmg.Value.IndexOf(" ", roidIdx) - roidIdx;
string sROid = mmg.Value.Substring(roidIdx, roid_Len);
// initialize to zero for cases where the ROUsage is <CROUSGID or <NEWID> to force a no match below
// -when a link has either of these, then the process of inserting that RO link did not complete for some reason
int iRousage = 0;
if (!sROusageID.StartsWith("<")) // don't try to convert if link has <CROUSGID or <NEWID> for the ROUsageID value
iRousage = Convert.ToInt32(sROusageID); //ROUsageID as interger
// see if there is a ContentID and ROUsage record match
// Both GoodROUsageID and GoodROUID must match in ROUsage record for link to be good
bool GoodROUsageID = false;
bool GoodROID = false;
// Check each ContentRoUsages and look for a matching ROUsageID and ROID
if (iRousage > 0 && this.ContentRoUsageCount > 0)
{
int lastROUsageID = -1;
string lastROID = "";
RoUsageInfo badRoUsageInfo = null;
foreach (RoUsageInfo rui in this.ContentItems[0].MyItem.MyItemInfo.MyContent.ContentRoUsages)
{
GoodROID = rui.ROID.Equals(sROid); //does this usage record have a matching ROID with the link text?
GoodROUsageID = rui.ROUsageID.Equals(iRousage); //does the usage record have a matching ROUsageID with the link text?
if (GoodROID && GoodROUsageID) break; // jump out loop - valid RO Usage record found
if (GoodROID && !GoodROUsageID)
{
lastROUsageID = rui.ROUsageID;
lastROID = rui.ROID;
}
else if (!GoodROID && GoodROUsageID)
badRoUsageInfo = rui;
}
if (!GoodROUsageID && GoodROID && lastROUsageID != -1) // Link does not have a valid ROUsage record for that RO link - add annotation
{
// set the ROUsageID in the link text to last good ROUsageID found in ROUsage table
tblLinkText = tblLinkText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
fixedTableDataText = fixedTableDataText.Replace(string.Format("#Link:ReferencedObject:{0} ", sROusageID), string.Format("#Link:ReferencedObject:{0} ", lastROUsageID));
bFixedTableDataText = true; // set to true so we know to update content text
}
if (bFixedTableDataText) // if we changed the table XML, then save it
{
this.MyGrid.Data = fixedTableDataText;
}
}
}
}
}
******* End modify table ****/
}
}
}
/*** needed if we fix RO links
return (bFixedROLinks || bFixedTableDataText);
***/
return false;
}
}
@@ -1079,29 +946,14 @@ namespace VEPROMS.CSLA.Library
public delegate void StaticContentInfoEvent(object sender, StaticContentInfoEventArgs args);
public class StaticContentInfoEventArgs
{
string _OldValue;
public string OldValue
public string OldValue { get; set; }
public string NewValue { get; set; }
public string Type { get; set; }
public StaticContentInfoEventArgs(string oldValue, string newValue, string type)
{
get { return _OldValue; }
set { _OldValue = value; }
}
string _NewValue;
public string NewValue
{
get { return _NewValue; }
set { _NewValue = value; }
}
string _Type;
public string Type
{
get { return _Type; }
set { _Type = value; }
}
public StaticContentInfoEventArgs(string oldValue, string newValue, string type)
{
_OldValue = oldValue;
_NewValue = newValue;
_Type = type;
OldValue = oldValue;
NewValue = newValue;
Type = type;
}
}
@@ -1119,27 +971,14 @@ namespace VEPROMS.CSLA.Library
return sb.ToString();
}
public string LastChangedString
{
get { return ContentInfo.FormatByteArray(_LastChanged); }
}
public string LastChangedString => FormatByteArray(_LastChanged);
public Int64 LastChangedInt64
{
get { return Convert.ToInt64(LastChangedString, 16); }
}
public static bool IsInCache(int contentID)
{
return _CacheByPrimaryKey.ContainsKey(contentID.ToString());
}
public static event StaticContentInfoEvent StaticContentInfoChange;
// B2018-002 - Invalid Transitions - Changed to Public
public static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args)
{
if (StaticContentInfoChange != null)
StaticContentInfoChange(sender, args);
}
public string MyContentMessage = string.Empty;
public long LastChangedInt64 => Convert.ToInt64(LastChangedString, 16);
public static bool IsInCache(int contentID) => _CacheByPrimaryKey.ContainsKey(contentID.ToString());
public static event StaticContentInfoEvent StaticContentInfoChange;
// B2018-002 - Invalid Transitions - Changed to Public
public static void OnStaticContentInfoChange(object sender, StaticContentInfoEventArgs args) => StaticContentInfoChange?.Invoke(sender, args);
public string MyContentMessage = string.Empty;
public string MyGridMessage = string.Empty;
public bool InList(params int[] IDs)
{
@@ -1150,22 +989,13 @@ namespace VEPROMS.CSLA.Library
return false;
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii)
{
FixTransitionText(tran, tranLookup, ii, "");
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii) => FixTransitionText(tran, tranLookup, ii, "");
public void FixTransitionText(TransitionInfo tran, ItemInfo ii)
{
FixTransitionText(tran, ii, "");
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii) => FixTransitionText(tran, ii, "");
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, string forceConvertToText)
{
FixTransitionText(tran, null, ii, forceConvertToText);
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, string forceConvertToText) => FixTransitionText(tran, null, ii, forceConvertToText);
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, string forceConvertToText)
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, string forceConvertToText)
{
string newvalue;
MyContentMessage = string.Empty;
@@ -1199,7 +1029,7 @@ namespace VEPROMS.CSLA.Library
myLength += m.Groups[3].Length;
}
string gg = Text.Substring(myIndex, myLength);
MyContentMessage = string.Format("ContentExt.ContentInfo:Content:{0}, {1}, {2}", this.ContentID, tran.TransitionID, gg);
MyContentMessage = string.Format("ContentExt.ContentInfo:Content:{0}, {1}, {2}", ContentID, tran.TransitionID, gg);
newvalue = newvalue.Replace("{", @"\{").Replace("}", @"\}");
if ((gg.Replace(@"\u8209?", "-").Replace(@"\u9586?", @"\\")) != (newvalue.Replace("\\u8209?", "-").Replace(@"\u9586?", @"\\")) || newvalue == "?") // B2017-165 added check of newvalue
{
@@ -1230,66 +1060,57 @@ namespace VEPROMS.CSLA.Library
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
{
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
//Match mg = Regex.Match(MyGrid.Data, lookForXml);
//if (mg != null && mg.Groups.Count > 1)
//{
// System.Text.RegularExpressions.Group g = mg.Groups[3];
// //if (g.ToString() != transText)
// // MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
//}
MyGridMessage = string.Empty;
string findLinkXml = @"&lt;START\].*?\[END&gt;";
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END&gt;", rousg.ROUsageID);
string lookForXml = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
int myIndex = mg.Groups[4].Index + mmg.Index;
int myLength = mg.Groups[4].Length;
if (mg.Groups[3].Value != " ")
{
myIndex = mg.Groups[3].Index + mmg.Index;
myLength += mg.Groups[3].Length;
}
string gg = MyGrid.Data.Substring(myIndex, myLength);
if (newvalue.Contains(@"\u8209?"))
{
// B2022-058: Printing of '-' in transition in table prints as '?' instead of '-'. Wasn't using correct string to
// look for font character (was using newvalue, not gg)
Match m = Regex.Match(gg, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u8209?", "-");
else
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
}
if (newvalue.Contains(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + m.Groups[3].Value);
}
if (newvalue.Contains(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + m.Groups[3].Value);
}
MyGridMessage = string.Format("ContentExt.ContentInfo:Grid:{0}, {1}, {2}", this.ContentID, tran.TransitionID, gg);
if (gg != newvalue)
{
MyGrid.SetData(MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength));
}
}
}
}
MyGridMessage = string.Empty;
string findLinkXml = @"&lt;START\].*?\[END&gt;";
string lookForXml = string.Format(@"^&lt;START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}} \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
foreach (Match mmg in msg)
{
Match mg = Regex.Match(mmg.Value, lookForXml);
if (mg != null && mg.Groups.Count > 1)
{
int myIndex = mg.Groups[4].Index + mmg.Index;
int myLength = mg.Groups[4].Length;
if (mg.Groups[3].Value != " ")
{
myIndex = mg.Groups[3].Index + mmg.Index;
myLength += mg.Groups[3].Length;
}
string gg = MyGrid.Data.Substring(myIndex, myLength);
if (newvalue.Contains(@"\u8209?"))
{
// B2022-058: Printing of '-' in transition in table prints as '?' instead of '-'. Wasn't using correct string to
// look for font character (was using newvalue, not gg)
Match m = Regex.Match(gg, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u8209?", "-");
else
newvalue = newvalue.Replace(@"\u8209?", $@"{m.Groups[1].Value}\u8209?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", $@"{m.Groups[1].Value}\u9586?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u9586?"))
{
Match m = Regex.Match(newvalue, @"(\\f[0-9]+)(\\u[0-9]{1,4}\?)(\\f[0-9]+ ?)");
if (m == null)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", $@"{m.Groups[1].Value}\u9586?{m.Groups[3].Value}");
}
MyGridMessage = string.Format("ContentExt.ContentInfo:Grid:{0}, {1}, {2}", ContentID, tran.TransitionID, gg);
if (gg != newvalue)
{
MyGrid.SetData(MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength));
}
}
}
}
}
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo, ItemInfo ii)
@@ -1362,10 +1183,6 @@ namespace VEPROMS.CSLA.Library
newvalue = newvalue.Replace($"{(char)916}", @"\u916?");
}
// Debug - jsj 5-19-2017 - left in for initial check-in
//string xx_gg = gg_org.Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
//string xx_nv = newval_org.Replace(@"\'b0", @"\'B0").Replace(@"\u8209?", "-").Replace(@"\u160?", " ").Replace("\xA0", " ");
//Console.WriteLine(xx_gg.CompareTo(xx_nv));
OnStaticContentInfoChange(ii, new StaticContentInfoEventArgs(gg, newvalue, "RO"));
break; // Text has been processed
}
@@ -1378,7 +1195,7 @@ namespace VEPROMS.CSLA.Library
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this.Get(), new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
List<string> retlist = origROFstInfo.OnROTableUpdate(Get(), new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (retlist != null && Text != retlist[0]) _Text = retlist[0]; //B2022-075 added null reference check
}
else
@@ -1412,7 +1229,7 @@ namespace VEPROMS.CSLA.Library
if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u8209?", "-");
else
newvalue = newvalue.Replace(@"\u8209?", m.Groups[1].Value + @"\u8209?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u8209?", $@"{m.Groups[1].Value}\u8209?{m.Groups[3].Value}");
}
//B2024-003, B2023-113, B2024-093 - Updating RO Values inside a text Grid,
// This will handle if there is a delta and the column/row of the grid is removed
@@ -1425,7 +1242,7 @@ namespace VEPROMS.CSLA.Library
else if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u916?", $"{(char)916}");
else
newvalue = newvalue.Replace(@"\u916?", m.Groups[1].Value + @"\u916?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u916?", $@"{m.Groups[1].Value}\u916?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u8593?"))
{
@@ -1433,7 +1250,7 @@ namespace VEPROMS.CSLA.Library
if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u8593?", "^");
else
newvalue = newvalue.Replace(@"\u8593?", m.Groups[1].Value + @"\u8593?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u8593?", $@"{m.Groups[1].Value}\u8593?{m.Groups[3].Value}");
}
if (newvalue.Contains(@"\u9586?"))
@@ -1442,7 +1259,7 @@ namespace VEPROMS.CSLA.Library
if (m.Groups.Count < 3)
newvalue = newvalue.Replace(@"\u9586?", @"\\");
else
newvalue = newvalue.Replace(@"\u9586?", m.Groups[1].Value + @"\u9586?" + m.Groups[3].Value);
newvalue = newvalue.Replace(@"\u9586?", $@"{m.Groups[1].Value}\u9586?{m.Groups[3].Value}");
}
// B2022-064: Translate '<' to '&lt;', '<' is xml token, so xml grid string was incorrect for print.
// Note that the '>' symbol was also translated. This method does NOT save the string to database,
@@ -1469,24 +1286,18 @@ namespace VEPROMS.CSLA.Library
_Text = "?";
}
// C2021-018 used to update the content record when displaying Alarm Pont Table information in the step Editor (BNPP alarms)
public void UpdateAlarmTableInfoView(string updateText)
{
_Text = updateText;
}
// C2021-018 used to update the content record when displaying Alarm Pont Table information in the step Editor (BNPP alarms)
public void UpdateAlarmTableInfoView(string updateText) => _Text = updateText;
public void LoadNonCachedGrid()
public void LoadNonCachedGrid()
{
_MyGrid = GridInfo.GetNonCached(ContentID);
//Console.WriteLine("LoadNonCachedGrid {0},{1},{2}",ContentID,_MyGrid==null,_MyContentInfoUnique);
}
public PartInfoList LocalContentParts
{
get { return _ContentParts; }
}
public PartInfoList LocalContentParts => _ContentParts;
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
{
if (_ContentParts == null)
_ContentParts = new PartInfoList(dr, itemInfo);
@@ -1494,17 +1305,11 @@ namespace VEPROMS.CSLA.Library
_ContentParts.AddPartInfo(dr, itemInfo);
}
public override string ToString()
{
return string.Format("{0} {1}", Number, Text);
}
public override string ToString() => $"{Number} {Text}";
public void ShowChange()
{
OnChange();
}
public void ShowChange() => OnChange();
internal ContentInfo(SafeDataReader dr, bool ForItem)
internal ContentInfo(SafeDataReader dr, bool ForItem)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
@@ -1587,7 +1392,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ContentListCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1604,7 +1409,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1616,7 +1421,7 @@ namespace VEPROMS.CSLA.Library
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
public static ContentInfoList GetChangedList(byte[] lastChanged)
@@ -1624,7 +1429,6 @@ namespace VEPROMS.CSLA.Library
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ChangeListCriteria(lastChanged));
// ContentInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
@@ -1651,7 +1455,7 @@ namespace VEPROMS.CSLA.Library
private void DataPortal_Fetch(ChangeListCriteria criteria)
{
this.RaiseListChangedEvents = false;
RaiseListChangedEvents = false;
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
@@ -1668,7 +1472,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1680,7 +1484,7 @@ namespace VEPROMS.CSLA.Library
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
}
this.RaiseListChangedEvents = true;
RaiseListChangedEvents = true;
}
#region ClearCBOverride
@@ -1725,7 +1529,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1760,29 +1564,15 @@ namespace VEPROMS.CSLA.Library
{
public ClearOverrideFormatsByDocVersionCriteria(string dvlist, int? formatID, int? newformatID)
{
_FormatID = formatID;
_DVList = dvlist;
_NewFormatID = newformatID;
FormatID = formatID;
DVList = dvlist;
NewFormatID = newformatID;
}
private int? _FormatID;
public int? FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
private int? _NewFormatID;
public int? NewFormatID
{
get { return _NewFormatID; }
set { _NewFormatID = value; }
}
private string _DVList;
public string DVList
{
get { return _DVList; }
set { _DVList = value; }
}
}
public int? FormatID { get; set; }
public int? NewFormatID { get; set; }
public string DVList { get; set; }
}
private void DataPortal_Fetch(ClearOverrideFormatsByDocVersionCriteria criteria)
{
@@ -1810,7 +1600,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1841,29 +1631,15 @@ namespace VEPROMS.CSLA.Library
{
public ClearOverrideFormatsByItemCriteria(int itemID, int? formatID, int? newformatID)
{
_FormatID = formatID;
_NewFormatID = newformatID;
_ItemID = itemID;
FormatID = formatID;
NewFormatID = newformatID;
ItemID = itemID;
}
private int? _FormatID;
public int? FormatID
{
get { return _FormatID; }
set { _FormatID = value; }
}
private int? _NewFormatID;
public int? NewFormatID
{
get { return _NewFormatID; }
set { _NewFormatID = value; }
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
public int? FormatID { get; set; }
public int? NewFormatID { get; set; }
public int ItemID { get; set; }
}
private void DataPortal_Fetch(ClearOverrideFormatsByItemCriteria criteria)
{
@@ -1891,7 +1667,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1975,7 +1751,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2005,7 +1781,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2069,7 +1845,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2146,7 +1922,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -2222,7 +1998,7 @@ namespace VEPROMS.CSLA.Library
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
Add(contentInfo);
}
IsReadOnly = true;
}
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
File diff suppressed because it is too large Load Diff
@@ -18,7 +18,6 @@ using System.IO;
using System.Threading;
using System.Xml;
using System.Text.RegularExpressions;
//using VEPROMS.Properties;
namespace VEPROMS.CSLA.Library
{
@@ -26,8 +25,6 @@ namespace VEPROMS.CSLA.Library
{
public static DocVersion GetFromDB(int versionID) // get data from database (don't look in cache first)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a DocVersion");
try
{
DocVersion tmp = DataPortal.Fetch<DocVersion>(new PKCriteria(versionID));
@@ -146,18 +143,15 @@ namespace VEPROMS.CSLA.Library
return _DocVersionConfig;
}
}
private void _DocVersionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _DocVersionConfig.ToString();
}
#endregion
#region UserSettings
/// <summary>
/// These settings are set on the user interface side.
/// This is used to control whether the Name and/or Title is displayed
/// next to the tree nodes in the user interface
/// </summary>
private bool _DisplayTreeNodeNames = true;
private void _DocVersionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) => Config = _DocVersionConfig.ToString();
#endregion
#region UserSettings
/// <summary>
/// These settings are set on the user interface side.
/// This is used to control whether the Name and/or Title is displayed
/// next to the tree nodes in the user interface
/// </summary>
private bool _DisplayTreeNodeNames = true;
public bool DisplayTreeNodeNames
{
get { return _DisplayTreeNodeNames; }
@@ -182,50 +176,12 @@ namespace VEPROMS.CSLA.Library
rtnstr += Title;
}
return rtnstr;
//return string.Format("{0} - {1}", Name, Title);
}
#region IVEDrillDown
//public System.Collections.IList GetChildren()
//{
// return null;
//}
//public bool HasChildren
//{
// get { return _ItemID > 0; }
//}
//public IVEDrillDown ActiveParent
//{
// get
// {
// return MyFolder;
// }
//}
//private Format _ActiveFormat = null;
//public Format ActiveFormat
//{
// get
// {
// if (_ActiveFormat == null)
// _ActiveFormat = LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat;
// return _ActiveFormat;
// }
// set
// {
// _ActiveFormat = null;
// }
//}
//public Format LocalFormat
//{
// get { return MyFormat; }
//}
public ConfigDynamicTypeDescriptor MyConfig
{
get { return DocVersionConfig; }
}
#endregion
public DocVersionInfo MyDocVersionInfo
{ get { return DocVersionInfo.Get(VersionID); } }
}
#region IVEDrillDown
public ConfigDynamicTypeDescriptor MyConfig => DocVersionConfig;
#endregion
public DocVersionInfo MyDocVersionInfo => DocVersionInfo.Get(VersionID);
}
public partial class DocVersionInfo : IVEDrillDownReadOnly
{
public TimeSpan tsTimeOut = TimeSpan.FromSeconds(6);
@@ -249,9 +205,10 @@ namespace VEPROMS.CSLA.Library
}
return exists;
}
// The following dictionary is used to store the state of the ro.fst check so that it is
// not made repeatedly in NewerRoFst. (B2017-050)
private static Dictionary<string, bool> NewerRoFstLookup = new Dictionary<string, bool>();
// The following dictionary is used to store the state of the ro.fst check so that it is
// not made repeatedly in NewerRoFst. (B2017-050)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static Dictionary<string, bool> NewerRoFstLookup = new Dictionary<string, bool>();
private static bool AddToRoFstLookup(string key, bool result)
{
if (!NewerRoFstLookup.ContainsKey(key)) NewerRoFstLookup.Add(key, result);
@@ -267,7 +224,6 @@ namespace VEPROMS.CSLA.Library
RODbInfo rdi = RODbInfo.GetJustRODB(roFstInfo.RODbID);
string rofstPath = rdi.FolderPath + @"\ro.fst";
//if (!File.Exists(rofstPath)) return false;
if (!pathExists(rofstPath))
{
_MyLog.WarnFormat("RO Path '{0}' could not be found", rofstPath);
@@ -369,10 +325,10 @@ namespace VEPROMS.CSLA.Library
return _SearchDVPath;
}
}
public string SearchPath { get { return ""; } }
public string SearchPath => "";
// B2021-076: Proms search results are not presented in order when printed to PDF
public string SearchDefaultSort { get { return string.Empty; } }
// B2021-076: Proms search results are not presented in order when printed to PDF
public string SearchDefaultSort => string.Empty;
#endregion
#region UnlinkEnhancedDocVersion
@@ -420,22 +376,15 @@ namespace VEPROMS.CSLA.Library
#region DocVersion Config
[NonSerialized]
private DocVersionConfig _DocVersionConfig;
public DocVersionConfig DocVersionConfig
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this)); } }
private void DocVersionConfigRefresh()
{
_DocVersionConfig = null;
}
#endregion
public DocVersionConfig DocVersionConfig => _DocVersionConfig ?? (_DocVersionConfig = new DocVersionConfig(this));
private void DocVersionConfigRefresh() => _DocVersionConfig = null;
#endregion
#region MOVE TO DOCVERSION CONFIG
#region MOVE TO DOCVERSION CONFIG
private string GetProfile(string grp, string nam)
{
return GetProfile(grp, nam, false);
}
private string GetProfile(string grp, string nam) => GetProfile(grp, nam, false);
private string GetProfile(string grp, string nam, bool flag)
private string GetProfile(string grp, string nam, bool flag)
{
DocVersionConfig dvcfg = DocVersionConfig;
string buff = null;
@@ -454,16 +403,14 @@ namespace VEPROMS.CSLA.Library
}
// B2021-066: Procedure PC/PC resolve procedure number with Unit Specific info
public string UnitSpecific(string str, int len, ItemInfo ii)
public string UnitSpecific(ItemInfo ii)
{
ProcedureInfo pi = ii as ProcedureInfo;
if (!(ii is ProcedureInfo pi)) // B2022-004: Don't crash if Proc PC/PC (ii is from a list, so wasn't an ItemInfo)
{
pi = ProcedureInfo.Get(ii.ItemID);
}
if (pi == null) // B2022-004: Don't crash if Proc PC/PC (ii is from a list, so wasn't an ItemInfo)
{
pi = ProcedureInfo.Get(ii.ItemID);
}
if (pi == null) return "";
if (pi == null) return "";
// B2023-035 for save the current select child (selectedSlave) and use the child number
// that was selected when printed. This is needed for when "Other" applicability
@@ -478,9 +425,8 @@ namespace VEPROMS.CSLA.Library
}
string unitdes = "ID";
string prefix = null;
string fromunitdes = null;
str = ItemInfo.ConvertToDisplayText(pi.MyContent.Number);
bool hastoken = false;
string str = ItemInfo.ConvertToDisplayText(pi.MyContent.Number);
bool hastoken = false;
// Determine if there is a token in the procedure number data, default is ID
if (str.ToUpper().Contains(@"<U"))
@@ -503,28 +449,29 @@ namespace VEPROMS.CSLA.Library
}
}
if (unitdes == "NUMBER")
fromunitdes = DocVersionConfig.Unit_Number;
else if (unitdes == "ID")
fromunitdes = DocVersionConfig.Unit_ID;
else if (unitdes == "NAME")
fromunitdes = DocVersionConfig.Unit_Name;
else if (unitdes == "TEXT")
fromunitdes = DocVersionConfig.Unit_Text;
// B2021-145: For applicability, the tree view & pdf file name are not getting resolved when using any of the OTHER tokens
// B2022-023 also check for other followed by a space
else if (unitdes == "OTHERTEXT" || unitdes == "OTHER TEXT")
fromunitdes = DocVersionConfig.Other_Unit_Text;
else if (unitdes == "OTHERNUMBER" || unitdes == "OTHER NUMBER")
fromunitdes = DocVersionConfig.Other_Unit_Number;
else if (unitdes == "OTHERNAME" || unitdes == "OTHER NAME")
fromunitdes = DocVersionConfig.Other_Unit_Name;
else if (unitdes == "OTHERID" || unitdes == "OTHER ID")
fromunitdes = DocVersionConfig.Other_Unit_ID;
else
fromunitdes = DocVersionConfig.Unit_ID;
string fromunitdes;
if (unitdes == "NUMBER")
fromunitdes = DocVersionConfig.Unit_Number;
else if (unitdes == "ID")
fromunitdes = DocVersionConfig.Unit_ID;
else if (unitdes == "NAME")
fromunitdes = DocVersionConfig.Unit_Name;
else if (unitdes == "TEXT")
fromunitdes = DocVersionConfig.Unit_Text;
// B2021-145: For applicability, the tree view & pdf file name are not getting resolved when using any of the OTHER tokens
// B2022-023 also check for other followed by a space
else if (unitdes == "OTHERTEXT" || unitdes == "OTHER TEXT")
fromunitdes = DocVersionConfig.Other_Unit_Text;
else if (unitdes == "OTHERNUMBER" || unitdes == "OTHER NUMBER")
fromunitdes = DocVersionConfig.Other_Unit_Number;
else if (unitdes == "OTHERNAME" || unitdes == "OTHER NAME")
fromunitdes = DocVersionConfig.Other_Unit_Name;
else if (unitdes == "OTHERID" || unitdes == "OTHER ID")
fromunitdes = DocVersionConfig.Other_Unit_ID;
else
fromunitdes = DocVersionConfig.Unit_ID;
DocVersionConfig.SelectedSlave = docVerSelectedSlave; //B2023-035 reset the selected Slave
DocVersionConfig.SelectedSlave = docVerSelectedSlave; //B2023-035 reset the selected Slave
// adjustments to the procedure number for applicability can be defined in 2 places:
// 1) mstr below: working draft properties/Applicability/Procedure number field for each unit can have text. The '#' in this
@@ -569,16 +516,16 @@ namespace VEPROMS.CSLA.Library
else
if (procAppl) prefs.Add(tokRepAndPrefix);
}
if (procAppl && tokRepAndPrefix != "") prefix = prefix + (prefix == null ? tokRepAndPrefix : (prefix != null && prefix.Length > 0 && prefix[prefix.Length - 1] != ',' ? "," : "") + tokRepAndPrefix);
if (procAppl && tokRepAndPrefix != "") prefix += (prefix == null ? tokRepAndPrefix : (prefix != null && prefix.Length > 0 && prefix[prefix.Length - 1] != ',' ? "," : "") + tokRepAndPrefix);
}
str = Regex.Replace(str, @"\<[uU]-[a-zA-Z]+\>", "");
str = Regex.Replace(str, @"\<[uU]\>", "");
return (!sometext) ? str: "[" + prefix + "]" + str;
return (!sometext) ? str: $"[{prefix}]{str}";
}
public string UnitSpecific(string str, int len)
public string UnitSpecific(string str)
{
// This routine retrieves the procedure number format from the
@@ -587,20 +534,8 @@ namespace VEPROMS.CSLA.Library
string retvalu = "";
string asis = "#";
if (str == null || str.Equals(string.Empty)) return retvalu; // return a null (empty) string
/*
* Bug fix: B2005-017 3/2/2005
* Need to use the largest procedure number length that's in the
* SET.DFF file. "LargestNumber" is the largest length after the
* procedure number is replaced via the SET.INI file "replace" list.
*
if(len==0)len=LargestNumber;
*/
// TODO: Do we need this line?-->>> if(len==0)len=LargestRawSetNumber;
//GetPrivateProfileString("unit", "procedure number", asis, mstr, MAXPATH, "proc.ini");
string pnum = asis;
//rhm/jcb stuff 20120511
//string mstr = GetProfile("Unit", "ProcedureNumber", true);
string mstr = DocVersionConfig.Unit_ProcedureNumber;
if (mstr != null && !mstr.Equals(string.Empty))
pnum = mstr;
@@ -684,11 +619,11 @@ namespace VEPROMS.CSLA.Library
case 'P':
//TODO: THIS IS A GLOBAL IN THE 16 BIT CODE!!!!
string procnumber = "";
pn = UnitSpecific(procnumber, 0);
pn = UnitSpecific(procnumber);
retval = GetProfile(pn, substr, true);
break;
}
if (retval == null) // .Equals(string.Empty))
if (retval == null)
swptr++;
}
str += sav;
@@ -752,13 +687,9 @@ namespace VEPROMS.CSLA.Library
#endregion
ItemInfoList _Procedures = null;
public ItemInfoList Procedures
{ get { return (_Procedures != null ? _Procedures : _Procedures = ItemInfoList.GetList(_ItemID, (int)E_FromType.Procedure)); } }
public void ResetProcedures()
{
_Procedures = null;
}
public static void ResetProcedures(int versionID)
public ItemInfoList Procedures => _Procedures ?? (_Procedures = ItemInfoList.GetList(_ItemID, (int)E_FromType.Procedure));
public void ResetProcedures() => _Procedures = null;
public static void ResetProcedures(int versionID)
{
string key = versionID.ToString();
if (_CacheByPrimaryKey.ContainsKey(key))
@@ -778,31 +709,12 @@ namespace VEPROMS.CSLA.Library
foreach (DocVersionInfo dvi in _CacheList)
dvi.ResetProcedures();
}
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
return Procedures;
}
//public bool ChildrenAreLoaded
//{
// get { return _iil == null; }
//}
public bool HasChildren
{
get { return _ItemID > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
return MyFolder;
}
}
public FormatInfo ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
#region IVEReadOnlyItem
public System.Collections.IList GetChildren() => Procedures;
public bool HasChildren => _ItemID > 0;
public IVEDrillDownReadOnly ActiveParent => MyFolder;
public FormatInfo ActiveFormat => LocalFormat ?? ActiveParent.ActiveFormat;
public FormatInfo LocalFormat
{
get
{
@@ -810,17 +722,14 @@ namespace VEPROMS.CSLA.Library
return MyFormat;
}
}
public ConfigDynamicTypeDescriptor MyConfig
public ConfigDynamicTypeDescriptor MyConfig => DocVersionConfig;
#region PasteChild
public ItemInfo PasteChild(int copyStartID) // pastes into an 'empty' docversion
{
get { return DocVersionConfig; }
}
//public bool HasStandardSteps()
//{ return false; }
#region PasteChild
public ItemInfo PasteChild(int copyStartID) // pastes into an 'empty' docversion
{
ItemInfo cpItem = ItemInfo.Get(copyStartID);
try
#pragma warning disable IDE0059 // Unnecessary assignment of a value - Kept for Side Effect and Debugging
ItemInfo cpItem = ItemInfo.Get(copyStartID);
#pragma warning restore IDE0059 // Unnecessary assignment of a value
try
{
DocVersionInfo dvi = DataPortal.Fetch<DocVersionInfo>(new VersionPastingPartCriteria(VersionID, copyStartID, DateTime.Now, Volian.Base.Library.VlnSettings.UserID));
ItemInfo tmp = dvi.Procedures[0] as ItemInfo;
@@ -831,8 +740,8 @@ namespace VEPROMS.CSLA.Library
}
return tmp;
}
catch (Exception ex)
{
catch (Exception)
{
System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return null;
}
@@ -869,23 +778,12 @@ namespace VEPROMS.CSLA.Library
rtnstr += Title;
}
return rtnstr;
//return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str,System.IFormatProvider ifp)
//{
// return ToString();
//}
public ItemInfo LastChild()
{
return MyItem.LastSibling;
}
public ItemInfo FirstChild()
{
return MyItem;
}
#endregion
#region DataPortal
private void DataPortal_Fetch(VersionPastingPartCriteria criteria)
public ItemInfo LastChild() => MyItem.LastSibling;
public ItemInfo FirstChild() => MyItem;
#endregion
#region DataPortal
private void DataPortal_Fetch(VersionPastingPartCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocVersionInfo.DataPortal_Fetch", GetHashCode());
try
@@ -899,10 +797,12 @@ namespace VEPROMS.CSLA.Library
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
cm.Parameters.AddWithValue("@StartItemID", criteria.StartItemID);
cm.Parameters.AddWithValue("@DTS", criteria.DTS); //ABC
cm.Parameters.AddWithValue("@UserID", criteria.UserID); //ABC
SqlParameter param_ContentID = new SqlParameter("@ThisVersionID", SqlDbType.Int);
param_ContentID.Direction = ParameterDirection.Output;
cm.Parameters.Add(param_ContentID);
cm.Parameters.AddWithValue("@UserID", criteria.UserID); //ABC
SqlParameter param_ContentID = new SqlParameter("@ThisVersionID", SqlDbType.Int)
{
Direction = ParameterDirection.Output
};
cm.Parameters.Add(param_ContentID);
cm.CommandText = "PasteDocVersionChild";
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
@@ -934,12 +834,9 @@ namespace VEPROMS.CSLA.Library
#region Extension
partial class DocVersionInfoExtension : extensionBase
{
public override void Refresh(DocVersionInfo tmp)
{
tmp.DocVersionConfigRefresh();
}
public override void Refresh(DocVersionInfo tmp) => tmp.DocVersionConfigRefresh();
}
}
#endregion
public ROFstInfo GetROFst(int rodbid)
{
@@ -967,7 +864,8 @@ namespace VEPROMS.CSLA.Library
rodbid, DocVersionAssociations.Count, VersionID, MyFolder.Name);
return null;
}
private static List<int> _HasBadRODBIDProblem = new List<int>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<int> _HasBadRODBIDProblem = new List<int>();
private bool FirstBadRODBIDProblemDetected
{
get
@@ -977,49 +875,13 @@ namespace VEPROMS.CSLA.Library
return true;
}
}
public bool IsFolder
{
get
{
return false;
}
}
public bool IsDocVersion
{
get
{
return true;
}
}
public bool IsProcedure
{
get
{
return false;
}
}
public bool IsSection
{
get
{
return false;
}
}
public bool IsStep
{
get
{
return false;
}
}
public int MultiUnitCount
{
get
{
return DocVersionConfig.Unit_Count;
}
}
private string[] _UnitNames;
public bool IsFolder => false;
public bool IsDocVersion => true;
public bool IsProcedure => false;
public bool IsSection => false;
public bool IsStep => false;
public int MultiUnitCount => DocVersionConfig.Unit_Count;
private string[] _UnitNames;
public string[] UnitNames
{
get
@@ -1138,7 +1000,8 @@ namespace VEPROMS.CSLA.Library
{
public DocVersionNonEnhancedListCriteria() { ;}
}
private void DataPortal_Fetch(DocVersionNonEnhancedListCriteria criteria)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
private void DataPortal_Fetch(DocVersionNonEnhancedListCriteria criteria)
{
this.RaiseListChangedEvents = false;
try
File diff suppressed because it is too large Load Diff
@@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.IO;
using Volian.Base.Library;
namespace VEPROMS.CSLA.Library
{
@@ -16,13 +12,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class AddByROFstIDImageIDCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
private string _ImagedIDs;
public string ImagedIDs
{ get { return _ImagedIDs; } }
public AddByROFstIDImageIDCriteria(int rOFstID, string imagedIDs)
private readonly int _ROFstID;
public int ROFstID => _ROFstID;
private readonly string _ImagedIDs;
public string ImagedIDs => _ImagedIDs;
public AddByROFstIDImageIDCriteria(int rOFstID, string imagedIDs)
{
_ROFstID = rOFstID;
_ImagedIDs = imagedIDs;
+46 -173
View File
@@ -13,10 +13,7 @@ using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.Linq;
@@ -40,73 +37,19 @@ namespace VEPROMS.CSLA.Library
return _FolderConfig;
}
}
public void FolderConfigRefresh()
{
_FolderConfig = null;
}
private void _FolderConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _FolderConfig.ToString();
}
#endregion
public override string ToString()
{
return _Title;
}
#region IVEReadOnlyItem
//public System.Collections.IList GetChildren()
//{
// if (FolderDocVersionCount != 0) return FolderDocVersions;
// if (ChildFolderCount != 0) return ChildFolders;
// return null;
//}
//public bool HasChildren
//{
// get { return _FolderDocVersionCount > 0 || _ChildFolderCount > 0; }
//}
//public IVEDrillDown ActiveParent
//{
// get
// {
// return MyParent;
// }
//}
//private Format _ActiveFormat = null;
//public Format ActiveFormat
//{
// get
// {
// if (_ActiveFormat == null)
// _ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent != null ? ActiveParent.ActiveFormat : null);
// return _ActiveFormat;
// }
// set
// {
// _ActiveFormat = null; // Reset
// }
//}
//public Format LocalFormat
//{
// get { return MyFormat; }
//}
public ConfigDynamicTypeDescriptor MyConfig
{
get { return FolderConfig; }
}
#endregion
#region MakeFolders for ManualOrder
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID)
{
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config, dts, usrID);
}
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config)
{
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config);
}
#endregion
public FolderInfo MyFolderInfo
{ get { return FolderInfo.Get(FolderID); } }
}
public void FolderConfigRefresh() => _FolderConfig = null;
private void _FolderConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) => Config = _FolderConfig.ToString();
#endregion
public override string ToString() => _Title;
#region IVEReadOnlyItem
public ConfigDynamicTypeDescriptor MyConfig => FolderConfig;
#endregion
#region MakeFolders for ManualOrder
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID) => MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config, dts, usrID);
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config) => MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config);
#endregion
public FolderInfo MyFolderInfo => FolderInfo.Get(FolderID);
}
public partial class FolderInfo:IVEDrillDownReadOnly
{
#region Search Paths
@@ -125,26 +68,20 @@ namespace VEPROMS.CSLA.Library
return _SearchDVPath;
}
}
public string SearchPath { get { return ""; } }
public string SearchPath => "";
// B2021-076: Proms search results are not presented in order when printed to PDF
public string SearchDefaultSort { get { return string.Empty; } }
#endregion
#region Folder Config (Read-Only)
[NonSerialized]
// B2021-076: Proms search results are not presented in order when printed to PDF
public string SearchDefaultSort => string.Empty;
#endregion
#region Folder Config (Read-Only)
[NonSerialized]
private FolderConfig _FolderConfig;
public FolderConfig FolderConfig
{ get {
return (_FolderConfig != null ? _FolderConfig : _FolderConfig = new FolderConfig(this));
} }
private void FolderConfigRefresh()
{
_FolderConfig = null;
}
#endregion
#region SortingChildren
private static bool IsInManualOrderNullFix = false;
public FolderConfig FolderConfig => _FolderConfig ?? (_FolderConfig = new FolderConfig(this));
private void FolderConfigRefresh() => _FolderConfig = null;
#endregion
#region SortingChildren
private static bool IsInManualOrderNullFix = false;
[NonSerialized]
public Csla.SortedBindingList<FolderInfo> _SortedChildFolders;
@@ -180,8 +117,6 @@ namespace VEPROMS.CSLA.Library
if (_SortedChildFolders == null)
{
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
//_SortedChildFolders.ApplySort("FolderID", ListSortDirection.Ascending);
//_SortedChildFolders.ApplySort("Name", ListSortDirection.Ascending);
}
else if (_SortedChildFolders.Count != ChildFolders.Count)
{
@@ -266,43 +201,20 @@ namespace VEPROMS.CSLA.Library
public System.Collections.IList GetChildren()
{
if(FolderDocVersionCount != 0)return FolderDocVersions;
//if (ChildFolderCount != 0) return ChildFolders;
if (ChildFolderCount != 0) return SortedChildFolders;
return null;
}
//public bool ChildrenAreLoaded
//{
// get { return _FolderDocVersions != null || _ChildFolders != null; }
//}
public bool HasChildren
{
get { return FolderDocVersionCount > 0 || ChildFolderCount > 0; }
}
public IVEDrillDownReadOnly ActiveParent
{
get
{
return MyParent;
}
}
public FormatInfo ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : ( ActiveParent != null ? ActiveParent.ActiveFormat : null); }
}
public FormatInfo LocalFormat
{
get { return MyFormat; }
}
public ConfigDynamicTypeDescriptor MyConfig
{
get { return FolderConfig; }
}
/// <summary>
/// These settings are set on the user interface side.
/// This is used to control whether the Name and/or Title is displayed
/// next to the tree nodes in the user interface
/// </summary>
private bool _DisplayTreeNodeNames = true;
public bool HasChildren => FolderDocVersionCount > 0 || ChildFolderCount > 0;
public IVEDrillDownReadOnly ActiveParent => MyParent;
public FormatInfo ActiveFormat => LocalFormat ?? (ActiveParent?.ActiveFormat);
public FormatInfo LocalFormat => MyFormat;
public ConfigDynamicTypeDescriptor MyConfig => FolderConfig;
/// <summary>
/// These settings are set on the user interface side.
/// This is used to control whether the Name and/or Title is displayed
/// next to the tree nodes in the user interface
/// </summary>
private bool _DisplayTreeNodeNames = true;
public bool DisplayTreeNodeNames
{
get { return _DisplayTreeNodeNames; }
@@ -326,12 +238,7 @@ namespace VEPROMS.CSLA.Library
rtnstr += Title;
}
return rtnstr;
//return string.Format("{0} - {1}", Name, Title);
}
//public string ToString(string str, System.IFormatProvider ifp)
//{
// return ToString();
//}
#endregion
public Color BackColor
{ get { return FolderConfig.Default_BkColor; } }
@@ -351,15 +258,10 @@ namespace VEPROMS.CSLA.Library
#region Extension
partial class FolderInfoExtension : extensionBase
{
public override void Refresh(FolderInfo tmp)
{
tmp.FolderConfigRefresh();
}
}
public override void Refresh(FolderInfo tmp) => tmp.FolderConfigRefresh();
}
public static FolderInfo GetTop()
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Folder");
try
{
FolderInfo tmp = DataPortal.Fetch<FolderInfo>(new TopCriteria());
@@ -375,7 +277,8 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on FolderInfo.GetTop", ex);
}
}
private void DataPortal_Fetch(TopCriteria criteria)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
private void DataPortal_Fetch(TopCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FolderInfo.DataPortal_Fetch", GetHashCode());
try
@@ -416,41 +319,11 @@ namespace VEPROMS.CSLA.Library
{
public TopCriteria() { ;}
}
public bool IsFolder
{
get
{
return true;
}
}
public bool IsDocVersion
{
get
{
return false;
}
}
public bool IsProcedure
{
get
{
return false;
}
}
public bool IsSection
{
get
{
return false;
}
}
public bool IsStep
{
get
{
return false;
}
}
}
public bool IsFolder => true;
public bool IsDocVersion => false;
public bool IsProcedure => false;
public bool IsSection => false;
public bool IsStep => false;
}
}
@@ -1,69 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
//public static class FontTab
//{
// private static Dictionary<string, int> FontIndx = null;
// // This dictionary takes a color name and converts it to the rtf string:
// private static Dictionary<string, string> FontRtf = null;
// public enum E_Fonts : int
// {
// None = 0, PrestigeEliteTall = 64, CourierNew = 2, TimesNewRoman = 0, LetterGothic = 66, Arial = 202, VolianDraw = 70, GothicUltra = 63, LetterGothicTall = 67, VolianScript = 71, ArialUnicode = 35
// }
// #region FontIndex
// /// <summary>
// /// GetIndex - Use this to get the number of the font in the font table based on the input
// /// string.
// /// </summary>
// /// <param name="font"></param>
// /// <returns></returns>
// public static int GetIndex(string font)
// {
// // if the dictionary hasn't been set yet,
// if (FontIndx==null)
// {
// FontIndx = new Dictionary<string, int>();
// FontIndx["Prestige Elite Tall"] = 64;
// FontIndx["Courier New"] = 2;
// FontIndx["Times New Roman"] = 0;
// FontIndx["Letter Gothic"] = 66;
// FontIndx["Arial"] = 202;
// FontIndx["Volian Draw"] = 70;
// FontIndx["Gothic Ultra"] = 63;
// FontIndx["Letter Gothic Tall"] = 67;
// FontIndx["VolianScript"] = 71;
// FontIndx["Arial Unicode"] = 35;
// }
// return FontIndx[font];
// }
// #endregion
// #region ColorRtf
// /// <summary>
// /// GetTableString - Use this to get the string to add to font table based on the input
// /// string.
// /// </summary>
// public static string GetTableString(string font)
// {
// if (FontRtf == null)
// {
// FontRtf = new Dictionary<string, string>();
// FontRtf["Prestige Elite Tall"] = "{\\f64\\fmodern\\fcharset2\\fprq1 Prestige Elite Tall;}";
// FontRtf["Courier New"] = "{\\f2\\fmodern\\fcharset0\\fprq1 Courier New;}";
// FontRtf["Times New Roman"] = "{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}";
// FontRtf["Letter Gothic"] = "{\\f66\\fmodern\\fcharset2\\fprq1 Letter Gothic;}";
// FontRtf["Arial"] = "{\\f1\\fswiss\\fcharset0\\fprq2 Arial;}";
// FontRtf["Volian Draw"] = "{\\f70\\fmodern\\fcharset2\\fprq1 VolianDraw;}";
// FontRtf["Gothic Ultra"] = "{\\f63\\fmodern\\fcharset2\\fprq1 Gothic Ultra;}";
// FontRtf["Letter Gothic Tall"] = "{\\f67\\fmodern\\fcharset2\\fprq1 Letter Gothic Tall;}";
// FontRtf["VolianScript"] = "{\\f71\\fswiss\\fcharset2\\fprq2 VolianScript;}";
// FontRtf["Arial Unicode"] = "{\\f35\\fswiss\\fcharset128\\fprq2 Arial Unicode MS;}";
// }
// return FontRtf[font];
// }
// #endregion
//}
}
+91 -162
View File
@@ -13,10 +13,8 @@ using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.Xml;
using System.Drawing;
using System.ComponentModel;
using System.Collections.Generic;
using Volian.Base.Library;
@@ -33,17 +31,12 @@ namespace VEPROMS.CSLA.Library
get { return _AllFormats; }
set { _AllFormats = value; }
}
public CriteriaAllFormats(bool allFormats)
{
_AllFormats = allFormats;
}
}
public CriteriaAllFormats(bool allFormats) => _AllFormats = allFormats;
}
public partial class Format
{
public static Format GetJustFormat(int formatID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Format");
try
{
Format tmp = GetCachedByPrimaryKey(formatID);
@@ -67,14 +60,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteriaJustFormat
{
private int _FormatID;
public int FormatID
{ get { return _FormatID; } }
public PKCriteriaJustFormat(int formatID)
{
_FormatID = formatID;
}
}
private readonly int _FormatID;
public int FormatID => _FormatID;
public PKCriteriaJustFormat(int formatID) => _FormatID = formatID;
}
private void DataPortal_Fetch(PKCriteriaJustFormat criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.DataPortal_Fetch JustFormat", GetHashCode());
@@ -123,92 +112,66 @@ namespace VEPROMS.CSLA.Library
}
public class FormatEventArgs
{
private string _Status;
public string Status
{
get { return _Status; }
set { _Status = value; }
}
public FormatEventArgs(string status)
{
_Status = status;
}
}
public string Status { get; set; }
public FormatEventArgs(string status) => Status = status;
}
public delegate void FormatEvent(object sender,FormatEventArgs args);
public partial class Format:IFormatOrFormatInfo
{
#region PlantFormat
[NonSerialized]
private PlantFormat _PlantFormat;
public PlantFormat PlantFormat
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this, Config)); } }
#endregion
public static event FormatEvent FormatLoaded;
private static void OnFormatLoaded(object sender, FormatEventArgs args)
{
if (FormatLoaded != null)
FormatLoaded(sender, args);
}
public IFormatOrFormatInfo MyIParent { get { return MyParent; } }
public override string ToString()
{
//return Name;
//return PlantFormat.FormatData.Name;
return FullName;
}
public string FullName
public PlantFormat PlantFormat => _PlantFormat ?? (_PlantFormat = new PlantFormat(this, Config));
#endregion
public static event FormatEvent FormatLoaded;
private static void OnFormatLoaded(object sender, FormatEventArgs args) => FormatLoaded?.Invoke(sender, args);
public IFormatOrFormatInfo MyIParent => MyParent;
public override string ToString() => FullName;
public string FullName
{
get
{
if (ParentID == 1) return Description + " (" + Name + ")";
if (Description.StartsWith("*")) return Description.Substring(1) + " (" + Name + ")";
if (ParentID == 1) return $"{Description} ({Name})";
if (Description.StartsWith("*")) return $"{Description.Substring(1)} ({Name})";
// C2019-029: if UCF, just use description & name, using parent is confusing
if (Config != null && Config != "") return Description + " (" + Name + ")";
return MyParent.Description + " - " + Description + " (" + Name + ")";
if (Config != null && Config != "") return $"{Description} ({Name})";
return $"{MyParent.Description} - {Description} ({Name})";
}
}
public static void UpdateFormats(string fmtPath, string genmacPath)
{
Format basefmt = null;
Format parent = null;
// Load base format.
basefmt = AddFormatToDB(null, "base", false, DateTime.Now, "Migration", fmtPath, genmacPath);
if (basefmt == null) return;
// Load base format.
Format basefmt = AddFormatToDB(null, "base", false, "Migration", fmtPath, genmacPath);
if (basefmt == null) return;
// now loop through all files... If there is an _ in the name, it's a subformat
// (for example, AEP_00.xml) skip it in main loop, it's handled for each format.
DirectoryInfo di = new DirectoryInfo(fmtPath); //(@"c:\development\fmtall");
FileInfo[] fis = di.GetFiles("*.xml");
OnFormatLoaded(null, new FormatEventArgs(fis.Length.ToString() + " Formats to Load"));
OnFormatLoaded(null, new FormatEventArgs($"{fis.Length} Formats to Load"));
foreach (FileInfo fi in fis)
{
//if (fi.Name.ToUpper() == "WCN2ALL.XML"|| fi.Name.ToUpper() == "OHLPALL.XML")
//{
bool issub = (fi.Name.IndexOf("_") > 0) ? true : false;
bool issub = (fi.Name.IndexOf("_") > 0);
if (!issub && fi.Name.ToLower() != "baseall.xml")
{
string fmtname = fi.Name.Substring(0, fi.Name.Length - 7);
// remove the all.xml part of the filename.
try
{
parent = AddFormatToDB(basefmt, fmtname, issub, DateTime.Now, "Migration", fmtPath, genmacPath);
if (parent != null)
Format parent = AddFormatToDB(basefmt, fmtname, issub, "Migration", fmtPath, genmacPath);
if (parent != null)
{
// now see if there are any subformats associated with this, if so
// add them here...
DirectoryInfo sdi = new DirectoryInfo(fmtPath); //("c:\\development\\fmtall");
FileInfo[] sfis = di.GetFiles(fmtname + "_*.xml");
FileInfo[] sfis = di.GetFiles($"{fmtname}_*.xml");
foreach (FileInfo sfi in sfis)
{
string nm = sfi.Name.Substring(0, sfi.Name.Length - 7);
OnFormatLoaded(null, new FormatEventArgs("Loading SubFormat " + sfi.Name));
//Console.WriteLine("Processing {0}", sfi.Name);
//frmMain.Status = string.Format("Processing Format {0}", sfi.Name);
OnFormatLoaded(null, new FormatEventArgs($"Loading SubFormat {sfi.Name}"));
try
{
AddFormatToDB(parent, nm, true, DateTime.Now, "Migration",fmtPath,genmacPath);
AddFormatToDB(parent, nm, true, "Migration",fmtPath,genmacPath);
}
catch (Exception ex)
{
@@ -242,7 +205,7 @@ namespace VEPROMS.CSLA.Library
string fmtname = Path.GetFileNameWithoutExtension(fi.Name);
try
{
AddEPFormatToDB(fmtname, DateTime.Now, VlnSettings.UserID, epPath);
AddEPFormatToDB(fmtname, VlnSettings.UserID, epPath);
}
catch (Exception ex)
{
@@ -283,16 +246,15 @@ namespace VEPROMS.CSLA.Library
_ = LookupFormats;
}
private static Format AddFormatToDB(Format parent, string format, bool issub, DateTime Dts, string Userid, string fmtPath, string genmacPath)
private static Format AddFormatToDB(Format parent, string format, bool issub, string Userid, string fmtPath, string genmacPath)
{
string fmtdata = null;
FileInfo fmtfi = null;
string genmacdata = null;
XmlDocument xd = null;
OnFormatLoaded(null, new FormatEventArgs("Loading Format "+format));
//string path = "c:\\development\\fmtall\\" + format + "all.xml";
string path = fmtPath + "\\" + format + "all.xml";
OnFormatLoaded(null, new FormatEventArgs($"Loading Format {format}"));
string path = $"{fmtPath}\\{format}all.xml";
if (File.Exists(path))
{
try
@@ -301,12 +263,11 @@ namespace VEPROMS.CSLA.Library
fmtfi = new FileInfo(path);
xd = new XmlDocument();
xd.Load(srf);
//xd.Load(path);
fmtdata = xd.OuterXml;
}
catch (Exception ex)
{
OnFormatLoaded(null, new FormatEventArgs("Error Loading Format " + format));
catch (Exception)
{
OnFormatLoaded(null, new FormatEventArgs($"Error Loading Format {format}"));
_MyLog.ErrorFormat("AddFormatToDB('{0}','{1}')", (parent == null)?"Base": parent.Name, path);
return null;
}
@@ -315,8 +276,7 @@ namespace VEPROMS.CSLA.Library
// Do we need genmac - only if non-subformat
if (!issub)
{
//path = "c:\\development\\genmacall\\" + format + ".svg";
path = genmacPath + "\\" + format + ".svg";
path = $"{genmacPath}\\{format}.svg";
if (File.Exists(path))
{
try
@@ -327,9 +287,8 @@ namespace VEPROMS.CSLA.Library
//xdg.Load(path);
genmacdata = xdg.OuterXml;
}
catch (Exception ex)
{
//frmMain.AddError(ex, "AddFormatToDB('{0}','{1}')", parent.Name, path);
catch (Exception)
{
_MyLog.ErrorFormat("AddFormatToDB('{0}','{1}')", parent.Name, path);
return null;
}
@@ -344,12 +303,11 @@ namespace VEPROMS.CSLA.Library
if (parent != null)
{
XmlNode nmnode = xd.SelectSingleNode("//FormatData");
if (nmnode is XmlElement)
{
XmlElement xm = (XmlElement)nmnode;
nmattr = xm.GetAttribute("Name");
}
}
if (nmnode is XmlElement xm)
{
nmattr = xm.GetAttribute("Name");
}
}
// use the format name if base or non sub. If it's a sub, remove the "_".
string fname = issub ? format.Replace("_", "") : format;
Format rec = null;
@@ -369,40 +327,39 @@ namespace VEPROMS.CSLA.Library
rec = rec.Save();
}
}
catch (Exception ex)
catch (Exception)
{
//frmMain.AddError(ex, "AddFormatToDB-make format('{0}','{1}')", parent.Name, path);
//Do Nothing --- if Debugging: frmMain.AddError(ex, "AddFormatToDB-make format('{0}','{1}')", parent.Name, path);
}
return rec;
}
//C2025-023 - Electronic Procedures - Modifications to PROMS
//Procedure to load the EP format fiels into the DB
private static void AddEPFormatToDB(string formatname, DateTime Dts, string Userid, string epPath)
private static void AddEPFormatToDB(string formatname, string Userid, string epPath)
{
string fmtdata = null;
FileInfo fmtfi = null;
XmlDocument xd = null;
OnFormatLoaded(null, new FormatEventArgs($"Loading Format {formatname}"));
OnFormatLoaded(null, new FormatEventArgs("Loading Format " + formatname));
string path = Path.Combine(epPath, formatname + ".xml");
string path = Path.Combine(epPath, $"{formatname}.xml");
if (File.Exists(path))
{
try
{
using (StreamReader srf = new StreamReader(path))
{
fmtfi = new FileInfo(path);
xd = new XmlDocument();
xd.XmlResolver = null;
xd.Load(srf);
FileInfo fmtfi = new FileInfo(path);
XmlDocument xd = new XmlDocument
{
XmlResolver = null
};
xd.Load(srf);
fmtdata = xd.OuterXml;
}
}
catch (Exception ex)
catch (Exception)
{
OnFormatLoaded(null, new FormatEventArgs("Error Loading Format " + formatname));
OnFormatLoaded(null, new FormatEventArgs($"Error Loading Format {formatname}"));
_MyLog.ErrorFormat($"AddEPFormatToDB('{path}')");
return;
}
@@ -414,7 +371,7 @@ namespace VEPROMS.CSLA.Library
{
EPFormatFile.UpdateEPFormat(formatname, fmtdata, Userid);
}
catch (Exception ex)
catch (Exception)
{
_MyLog.ErrorFormat($"AddFormatToDB-make format('{path}')");
}
@@ -441,13 +398,10 @@ public partial class FormatInfo : IFormatOrFormatInfo
[Serializable()]
private class FormatIDCriteria
{
private int _FormatID;
public int FormatID { get { return _FormatID; } }
public FormatIDCriteria(int formatID)
{
_FormatID = formatID;
}
}
private readonly int _FormatID;
public int FormatID => _FormatID;
public FormatIDCriteria(int formatID) => _FormatID = formatID;
}
private void DataPortal_Fetch(FormatIDCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] TransitionInfoList.DataPortal_Fetch", GetHashCode());
@@ -478,17 +432,10 @@ public partial class FormatInfo : IFormatOrFormatInfo
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
}
}
//end transition report stuff
public virtual Format GetJustFormat()
{
return _Editable = Format.GetJustFormat(_FormatID);
}
public static bool HasLatestChanges()
{
if (!HasSeqTabFmtTabToken()) return false;
return true;
}
private static bool HasSeqTabFmtTabToken()
//end transition report stuff
public virtual Format GetJustFormat() => _Editable = Format.GetJustFormat(_FormatID);
public static bool HasLatestChanges() => HasSeqTabFmtTabToken();
private static bool HasSeqTabFmtTabToken()
{
using (FormatInfo fi = FormatInfo.Get("WCN2"))
{
@@ -517,17 +464,13 @@ public partial class FormatInfo : IFormatOrFormatInfo
return _PROMSBaseFormat;
}
}
public static void Reset()
{
_PROMSBaseFormat = null;
}
public static void Reset() => _PROMSBaseFormat = null;
public static FormatInfo Get(string name)
{
try
{
FormatInfo tmp = DataPortal.Fetch<FormatInfo>(new NameCriteria(name));
//AddToCache(tmp);
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up FormatInfo
@@ -563,14 +506,10 @@ public partial class FormatInfo : IFormatOrFormatInfo
}
protected class NameCriteria
{
private string _Name;
public string Name
{ get { return _Name; } }
public NameCriteria(string name)
{
_Name = name;
}
}
private readonly string _Name;
public string Name => _Name;
public NameCriteria(string name) => _Name = name;
}
private void DataPortal_Fetch(NameCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.DataPortal_Fetch", GetHashCode());
@@ -611,17 +550,11 @@ public partial class FormatInfo : IFormatOrFormatInfo
#region PlantFormat
[NonSerialized]
private PlantFormat _PlantFormat;
public PlantFormat PlantFormat
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this, Config)); } }
#endregion
public IFormatOrFormatInfo MyIParent { get { return MyParent; } }
public override string ToString()
{
//return Name;
//return PlantFormat.FormatData.Name;
return FullName;
}
public string FullName
public PlantFormat PlantFormat => _PlantFormat ?? (_PlantFormat = new PlantFormat(this, Config));
#endregion
public IFormatOrFormatInfo MyIParent => MyParent;
public override string ToString() => FullName;
public string FullName
{
get
{
@@ -632,15 +565,9 @@ public partial class FormatInfo : IFormatOrFormatInfo
return MyParent.Description + " - " + Description + " (" + Name + ")";
}
}
public StepSectionLayoutData MyStepSectionLayoutData
{
get { return PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData; }
}
public StepSectionPrintData MyStepSectionPrintData
{
get { return PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData; }
}
}
public StepSectionLayoutData MyStepSectionLayoutData => PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData;
public StepSectionPrintData MyStepSectionPrintData => PlantFormat.FormatData.SectData.StepSectionData.StepSectionPrintData;
}
public partial class FormatInfoList
{
/// <summary>
@@ -658,7 +585,8 @@ public partial class FormatInfo : IFormatOrFormatInfo
throw new DbCslaException("Error on FormatInfoList.GetAll", ex);
}
}
private void DataPortal_Fetch(CriteriaAllFormats myCrit)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
private void DataPortal_Fetch(CriteriaAllFormats myCrit)
{
this.RaiseListChangedEvents = false;
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfoList.DataPortal_Fetch", GetHashCode());
@@ -716,7 +644,8 @@ public partial class FormatInfo : IFormatOrFormatInfo
protected class FormatInfoListUsedCriteria
{
}
private void DataPortal_Fetch(FormatInfoListUsedCriteria criteria)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping until replace CSLA")]
private void DataPortal_Fetch(FormatInfoListUsedCriteria criteria)
{
try
{
@@ -749,13 +678,13 @@ public partial class FormatInfo : IFormatOrFormatInfo
}
public class FormatVersion
{
private string _Title;
public string Title { get { return _Title; } }
private int _FormatID;
public int FormatID { get { return _FormatID; } }
private int _VersionID;
public int VersionID { get { return _VersionID; } }
public FormatVersion(string title, int formatID, int versionID)
private readonly string _Title;
public string Title => _Title;
private readonly int _FormatID;
public int FormatID => _FormatID;
private readonly int _VersionID;
public int VersionID => _VersionID;
public FormatVersion(string title, int formatID, int versionID)
{
_Title = title;
_FormatID = formatID;
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
@@ -12,69 +11,23 @@ namespace VEPROMS.CSLA.Library
// B2022-047 - refresh the Content/Text field for table. Get all grids in database.
public class CriteriaAllGridIds
{
bool _AllGridIds;
public bool AllGridIds
{
get { return _AllGridIds; }
set { _AllGridIds = value; }
}
public CriteriaAllGridIds(bool allGridIds)
{
_AllGridIds = allGridIds;
}
}
public bool AllGridIds { get; set; }
public CriteriaAllGridIds(bool allGridIds) => AllGridIds = allGridIds;
}
[Serializable()]
[TypeConverter(typeof(FormatInfoListConverter))]
public partial class GridInfoList : ReadOnlyListBase<GridInfoList, GridInfo>
{
#region Log4Net
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
internal new IList<GridInfo> Items
{ get { return base.Items; } }
private bool _Disposed = false;
private static int _CountCreated = 0;
private static int _CountDisposed = 0;
private static int _CountFinalized = 0;
private static int IncrementCountCreated
{ get { return ++_CountCreated; } }
private int _CountWhenCreated = IncrementCountCreated;
public static int CountCreated
{ get { return _CountCreated; } }
public static int CountNotDisposed
{ get { return _CountCreated - _CountDisposed; } }
public static int CountNotFinalized
{ get { return _CountCreated - _CountFinalized; } }
~GridInfoList()
{
_CountFinalized++;
}
#endregion
private bool _Disposed = false;
public void Dispose()
{
if (_Disposed) return;
_CountDisposed++;
_Disposed = true;
}
public static GridInfoList _GridInfoList = null;
/// <summary>
/// Return a list of all GridInfo. Commented out - GridInfoList was added to fix B2022-047. Have this code here in
/// case it is needed in the future.
/// </summary>
//public static GridInfoList Get()
//{
// try
// {
// if (_GridInfoList != null)
// return _GridInfoList;
// GridInfoList tmp = DataPortal.Fetch<GridInfoList>();
// _GridInfoList = tmp;
// return tmp;
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on FormatInfoList.Get", ex);
// }
//}
public static List<int> GetIds()
{
try
@@ -108,53 +61,17 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("Error on GridInfoList.Get", ex);
}
}
// Commented out - GridInfoList was added to fix B2022-047. Have this code here in
// case it is needed in the future. The associated query 'getGrids' does not exist.
//private void DataPortal_Fetch()
//{
// this.RaiseListChangedEvents = false;
// if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] GridInfoList.DataPortal_Fetch", GetHashCode());
// try
// {
// using (SqlConnection cn = Database.VEPROMS_SqlConnection)
// {
// using (SqlCommand cm = cn.CreateCommand())
// {
// cm.CommandType = CommandType.StoredProcedure;
// cm.CommandText = "getGrids";
// cm.CommandTimeout = Database.DefaultTimeout;
// using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// {
// IsReadOnly = false;
// while (dr.Read()) this.Add(new GridInfo(dr));
// IsReadOnly = true;
// }
// }
// }
// }
// catch (Exception ex)
// {
// if (_MyLog.IsErrorEnabled) _MyLog.Error("GridInfoList.DataPortal_Fetch", ex);
// throw new DbCslaException("GridInfoList.DataPortal_Fetch", ex);
// }
// this.RaiseListChangedEvents = true;
//}
}
public partial class GridInfo
{
public void ResetContent(Grid myGrid)
{
RefreshFields(myGrid);
}
public void SetData(string myData)
public void ResetContent(Grid myGrid) => RefreshFields(myGrid);
public void SetData(string myData)
{
_Data = myData;
RemoveFromCache(this);
}
public static GridInfo GetNonCached(int contentID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a Grid");
try
{
GridInfo tmp = DataPortal.Fetch<GridInfo>(new PKCriteria(contentID));
File diff suppressed because it is too large Load Diff
@@ -1,19 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace VEPROMS.CSLA.Library
{
public partial class ItemInfo
{
public ItemInfo SearchNext
{
get
{
return SearchNextSkip(SkipPartType.This);
}
}
private ItemInfo SearchNextSkip(SkipPartType skip)
public ItemInfo SearchNext => SearchNextSkip(SkipPartType.This);
private ItemInfo SearchNextSkip(SkipPartType skip)
{
if (skip < SkipPartType.Caution && Cautions != null && Cautions.Count > 0) return Cautions[0].SearchTop;
if (skip < SkipPartType.Note && Notes != null && Notes.Count > 0) return Notes[0].SearchTop;
@@ -28,9 +18,8 @@ namespace VEPROMS.CSLA.Library
bool iseditable = true;
if (IsSection)
{
SectionConfig sc = MyConfig as SectionConfig;
if (sc != null && sc.SubSection_Edit != "Y") iseditable = false;
}
if (MyConfig is SectionConfig sc && sc.SubSection_Edit != "Y") iseditable = false;
}
if (iseditable && skip < SkipPartType.Steps && Steps != null && Steps.Count > 0) return Steps[0].SearchTop;
if (NextItem != null) return NextItem.SearchTop;
@@ -49,9 +38,8 @@ namespace VEPROMS.CSLA.Library
{
get
{
ItemInfo parentItem = ActiveParent as ItemInfo;
if (parentItem == null) return null;
if (IsCautionPart) return parentItem.SearchNextSkip(SkipPartType.Caution);
if (!(ActiveParent is ItemInfo parentItem)) return null;
if (IsCautionPart) return parentItem.SearchNextSkip(SkipPartType.Caution);
if (IsNotePart) return parentItem.SearchNextSkip(SkipPartType.Note);
if (IsRNOPart) return parentItem.SearchNextSkip(SkipPartType.RNO);
if (IsSupInfoPart) return parentItem.SearchNextSkip(SkipPartType.SupInfo);
@@ -63,14 +51,8 @@ namespace VEPROMS.CSLA.Library
return parentItem.UpOneNext;
}
}
public ItemInfo SearchPrev
{
get
{
return SearchPrevSkip(SkipPartType.This);
}
}
private ItemInfo SearchPrevSkip(SkipPartType skip)
public ItemInfo SearchPrev => SearchPrevSkip(SkipPartType.This);
private ItemInfo SearchPrevSkip(SkipPartType skip)
{
if (skip > SkipPartType.Steps && Steps != null) return Steps[0].LastSibling.SearchBottom;
if (skip > SkipPartType.Sections && Sections != null) return Sections[0].LastSibling.SearchBottom;
@@ -101,9 +83,8 @@ namespace VEPROMS.CSLA.Library
{
get
{
ItemInfo parentItem = ActiveParent as ItemInfo;
if (parentItem == null) return null;
if (IsCautionPart) return parentItem.SearchPrevSkip(SkipPartType.Caution);
if (!(ActiveParent is ItemInfo parentItem)) return null;
if (IsCautionPart) return parentItem.SearchPrevSkip(SkipPartType.Caution);
if (IsNotePart) return parentItem.SearchPrevSkip(SkipPartType.Note);
if (IsRNOPart) return parentItem.SearchPrevSkip(SkipPartType.RNO);
if (IsSupInfoPart) return parentItem.SearchPrevSkip(SkipPartType.SupInfo);
File diff suppressed because it is too large Load Diff
@@ -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)
{
@@ -12,19 +12,10 @@ namespace VEPROMS.CSLA.Library
Rtf = rtf;
WithBorder = withBorder;
}
private string _Rtf;
public string Rtf
{
get { return _Rtf; }
set { _Rtf = value; }
}
private bool _WithBorder;
public bool WithBorder
{
get { return _WithBorder; }
set { _WithBorder = value; }
}
private RtfLines _Lines;
public string Rtf { get; set; }
public bool WithBorder { get; set; }
private RtfLines _Lines;
public RtfLines Lines
{
get
@@ -43,11 +34,8 @@ namespace VEPROMS.CSLA.Library
Lines.Add(new RtfLine(maxWidth, WithBorder ? @"\u9492?" : " ", WithBorder ? @"\u9472?" : " ", WithBorder ? @"\u9496?" : " ")); // Insert bottom line
Lines.ReplaceLines(WithBorder);
}
public override string ToString()
{
return Lines.ToString();
}
}
public override string ToString() => Lines.ToString();
}
public class RtfLines : List<RtfLine>
{
public static Regex _RegReplaceLine = new Regex(@"\\line((\\[^ \[\]\\\(\)]*) )");
@@ -58,7 +46,6 @@ namespace VEPROMS.CSLA.Library
// split text into lines
string[] breaks = { "\r\n" };
string[] lines = txt.Split(breaks, StringSplitOptions.None);
//string lastLine = lines[lines.Length - 1];
foreach (string line in lines)
Add(new RtfLine(line.Replace("\\bullet","*")));
}
@@ -89,19 +76,19 @@ namespace VEPROMS.CSLA.Library
}
return sb.ToString();
}
private static Regex _RegRightCheck = new Regex(@"-|\\u9472?|\\u8209\?");
private static Regex _RegAboveCheck = new Regex(@"\||\\u9474\?|\\u9492\?|\\u9516\?|\\u9532\?|\\u9500\?|\\u9484\?|\\u9524\?|\\u9488\?|\\u9508\?");
private static Regex _RegLeftCheck = new Regex(@"-|\\u9472\?|\\u9508\?|\\u9516\?|\\u9500\?|\\u9532\?|\\u9484\?|\\u9488\?|\\u9492\?|\\u8209\?");
private static Regex _RegBelowCheck = new Regex(@"\||\\u9474\?");
private static readonly Regex _RegRightCheck = new Regex(@"-|\\u9472?|\\u8209\?");
private static readonly Regex _RegAboveCheck = new Regex(@"\||\\u9474\?|\\u9492\?|\\u9516\?|\\u9532\?|\\u9500\?|\\u9484\?|\\u9524\?|\\u9488\?|\\u9508\?");
private static readonly Regex _RegLeftCheck = new Regex(@"-|\\u9472\?|\\u9508\?|\\u9516\?|\\u9500\?|\\u9532\?|\\u9484\?|\\u9488\?|\\u9492\?|\\u8209\?");
private static readonly Regex _RegBelowCheck = new Regex(@"\||\\u9474\?");
private static Regex _RegRightCheck1 = new Regex(@"\\u9474\?");
private static Regex _RegAboveCheck1 = new Regex(@"\\u9472\?|\\u8209\?");
private static Regex _RegLeftCheck1 = new Regex(@"\\u9474\?");
private static Regex _RegBelowCheck1 = new Regex(@"\\u9472\?|\\u8209\?");
private static readonly Regex _RegRightCheck1 = new Regex(@"\\u9474\?");
private static readonly Regex _RegAboveCheck1 = new Regex(@"\\u9472\?|\\u8209\?");
private static readonly Regex _RegLeftCheck1 = new Regex(@"\\u9474\?");
private static readonly Regex _RegBelowCheck1 = new Regex(@"\\u9472\?|\\u8209\?");
private static Regex _RegHorizontalCheck = new Regex(@"-|\\u9472\?|\\u8209\?");
private static Regex _RegVerticalCheck = new Regex(@"\||\\u9474\?");
static private string[] TableCharsU = {
private static readonly Regex _RegHorizontalCheck = new Regex(@"-|\\u9472\?|\\u8209\?");
private static readonly Regex _RegVerticalCheck = new Regex(@"\||\\u9474\?");
private static readonly string[] TableCharsU = {
"\x0", // HEX"\x0", // No character
@"\u9472?", // HEX@"\u2500",// - Horizontal line - 16-bit char: '\xC4'
@"\u9474?", // HEX@"\u2502",// | Vertical line - 16-bit char: '\xB3'
@@ -159,24 +146,10 @@ namespace VEPROMS.CSLA.Library
}
}
}
private void ListItems(string loc, string str)
{
StringBuilder sb = new StringBuilder(string.Format("{0} = @\"", loc));
string sep = "";
foreach (char c in str)
{
if (c < 127)
sb.Append(sep + c.ToString());
else
sb.Append(sep + string.Format("\\u{0}?", (int)c));
sep = "|";
}
Console.WriteLine(sb.ToString());
}
}
public class RtfLine : List<RtfPiece>
{
private static Regex _RegRtfText = new Regex(@"((\\[^'u ]*|\\up[0-9]|\\ul|\\ulnone)+( |$|(?=\\['u])))?(<START\]|#Link.*?\[END>|\\'[0-9a-fA-F]{2}|\\u[0-9]*\?|[^\\]{1}|$|)");
private static readonly Regex _RegRtfText = new Regex(@"((\\[^'u ]*|\\up[0-9]|\\ul|\\ulnone)+( |$|(?=\\['u])))?(<START\]|#Link.*?\[END>|\\'[0-9a-fA-F]{2}|\\u[0-9]*\?|[^\\]{1}|$|)");
public RtfLine(string text)
{
MatchCollection matches = _RegRtfText.Matches(text);
@@ -192,15 +165,13 @@ namespace VEPROMS.CSLA.Library
nextIndex = match.Index + match.Length;
string rtfPart = match.Groups[1].ToString();
if (match.Groups[1].ToString().TrimEnd(" ".ToCharArray()).Length + match.Groups[4].ToString().Length > 0)
this.Add(new RtfPiece(match.Groups[1].ToString().TrimEnd(" ".ToCharArray()), match.Groups[4].ToString()));
//if (match.Groups[1].ToString().Length + match.Groups[4].ToString().Length > 0)
// this.Add(new RtfPiece(match.Groups[1].ToString(), match.Groups[4].ToString()));
Add(new RtfPiece(match.Groups[1].ToString().TrimEnd(" ".ToCharArray()), match.Groups[4].ToString()));
}
}
public RtfLine(int width, string left, string fill, string right)
{
Add(new RtfPiece("", left));
for (int i = 0; i < width; i++) this.Add(new RtfPiece("", fill)); // Pad
for (int i = 0; i < width; i++) Add(new RtfPiece("", fill)); // Pad
Add(new RtfPiece("", right));
}
public int MaximumWidth
@@ -223,9 +194,9 @@ namespace VEPROMS.CSLA.Library
internal void Pad(int maxWidth, string edge)
{
int pad = maxWidth - MaximumWidth;
this.Insert(0, new RtfPiece("", edge)); // Left Edge
for (int i = 0; i < pad; i++) this.Add(new RtfPiece("", " ")); // Pad
this.Add(new RtfPiece("", edge)); // Right Edge
Insert(0, new RtfPiece("", edge)); // Left Edge
for (int i = 0; i < pad; i++) Add(new RtfPiece("", " ")); // Pad
Add(new RtfPiece("", edge)); // Right Edge
}
public new RtfPiece this[int index]
{
@@ -246,61 +217,23 @@ namespace VEPROMS.CSLA.Library
}
public class RtfPiece
{
private string _Rtf;
public string Rtf
{
get { return _Rtf; }
set { _Rtf = value; }
}
private string _Text = "";
public string Text
{
get { return _Text; }
set { _Text = value; }
}
public int TextLength
{
get { return Text.Length; }
}
public int MaximumWidth
{
get { return Text == "" ? 0 : 1; }
}
private static Regex _RegStartLink = new Regex(@"<START\]");
private static Regex _RegEndLink = new Regex(@"#Link.*?\[END>");
public string Rtf { get; set; }
public string Text { get; set; } = "";
public int TextLength => Text.Length;
public int MaximumWidth => Text == "" ? 0 : 1;
private static readonly Regex _RegStartLink = new Regex(@"<START\]");
private static readonly Regex _RegEndLink = new Regex(@"#Link.*?\[END>");
public RtfPiece(string rtf, string text)
{
_Rtf = rtf;
Rtf = rtf;
if (_RegStartLink.IsMatch(text) || _RegEndLink.IsMatch(text))
_Rtf += (rtf == "" ? "" : " ") + text;
Rtf += (rtf == "" ? "" : " ") + text;
else
{
_Rtf += rtf == "" ? "" : " ";
_Text = text;
Rtf += rtf == "" ? "" : " ";
Text = text;
}
}
public override string ToString()
{
return _Rtf + _Text;
//string retval = _RegUnicode.Replace(_Text, new MatchEvaluator(RtfUnicodeCharacter));
//retval = _RegHex.Replace(retval, new MatchEvaluator(RtfHexCharacter));
//return retval;
}
//private static Regex _RegUnicode = new Regex(@"\\u([0-9ABCDEF]*)\?");
//internal static string RtfUnicodeCharacter(Match myMatch)
//{
// string hexStr = myMatch.Groups[1].ToString();
// int i = int.Parse(hexStr);
// Char schar = Convert.ToChar(i);
// return schar.ToString();
//}
//private static Regex _RegHex = new Regex(@"\\'([0-9A-Fa-f]{2})");
//internal static string RtfHexCharacter(Match myMatch)
//{
// string hexStr = myMatch.Groups[1].ToString();
// int i = int.Parse(hexStr, System.Globalization.NumberStyles.HexNumber);
// Char schar = Convert.ToChar(i);
// return schar.ToString();
//}
}
public override string ToString() => Rtf + Text;
}
}
+28 -103
View File
@@ -1,42 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
namespace VEPROMS.CSLA.Library
{
public partial class ContentPart
{
public override string ToString()
{
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
}
public override string ToString() => string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
public partial class ItemPart
{
public override string ToString()
{
return string.Format("{0} {1}", _MyContent.Number, MyContent.Text);
}
}
public override string ToString() => string.Format("{0} {1}", _MyContent.Number, MyContent.Text);
}
public partial class Part
{
public override string ToString()
{
return string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
}
public override string ToString() => string.Format("{0} {1}", MyItem.MyContent.Number, MyItem.MyContent.Text);
}
public partial class PartInfoList
{
internal PartInfoList(SafeDataReader dr, ItemInfo itemInfo)
{
AddPartInfo(dr,itemInfo);
}
internal void AddPartInfo(SafeDataReader dr, ItemInfo itemInfo)
internal PartInfoList(SafeDataReader dr, ItemInfo itemInfo) => AddPartInfo(dr, itemInfo);
internal void AddPartInfo(SafeDataReader dr, ItemInfo itemInfo)
{
IsReadOnly = false;
this.Add(new PartInfo(dr, itemInfo));
Add(new PartInfo(dr, itemInfo));
IsReadOnly = true;
}
public PartInfo Find(E_FromType fromType)
@@ -124,9 +109,8 @@ namespace VEPROMS.CSLA.Library
{
if (_SearchDefaultSort == null)
{
string partText = String.Empty;
switch ((E_FromType)FromType)
string partText;
switch ((E_FromType)FromType)
{
case E_FromType.Caution:
partText = ".Caution";
@@ -189,11 +173,9 @@ namespace VEPROMS.CSLA.Library
throw new DbCslaException("PartInfo.ReadData", ex);
}
}
public E_FromType PartType
{ get { return (E_FromType)_FromType; } }
public E_FromTypes PartTypes
{ get { return (E_FromTypes)_FromType; } }
public override string ToString()
public E_FromType PartType => (E_FromType)_FromType;
public E_FromTypes PartTypes => (E_FromTypes)_FromType;
public override string ToString()
{
// if the parttype is table or figure, add the correct label:
if (PartTypes == E_FromTypes.Tables)
@@ -204,28 +186,12 @@ namespace VEPROMS.CSLA.Library
}
return string.Format("{0}", PartTypes);
}
//public string ToString(string str, System.IFormatProvider ifp)
//{
// return ToString();
//}
#region IVEDrillDownReadOnly
public ItemInfoList _MyItems;
public ItemInfoList MyItems
{ get { return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType)); } }
public System.Collections.IList GetChildren()
{
//return (_MyItems != null ? _MyItems : _MyItems = ItemInfoList.GetList(_ItemID, _FromType));
return MyItems;
}
//public bool ChildrenAreLoaded
//{
// get { return _MyItems == null; }
//}
public bool HasChildren
{
get { return this.MyContent.ContentPartCount > 0; }
}
public IVEDrillDownReadOnly ActiveParent
public ItemInfoList MyItems => _MyItems ?? (_MyItems = ItemInfoList.GetList(_ItemID, _FromType));
public System.Collections.IList GetChildren() => MyItems;
public bool HasChildren => MyContent.ContentPartCount > 0;
public IVEDrillDownReadOnly ActiveParent
{
get
{
@@ -234,57 +200,16 @@ namespace VEPROMS.CSLA.Library
return parentContent.ContentItems[0];
}
}
public FormatInfo ActiveFormat
{
get { return ActiveParent.ActiveFormat; }
}
public FormatInfo LocalFormat
{
get { return null; }
}
public ConfigDynamicTypeDescriptor MyConfig
{
get { return null; }
}
public bool IsFolder
{
get
{
return false;
}
}
public bool IsDocVersion
{
get
{
return false;
}
}
public bool IsProcedure
{
get
{
return false;
}
}
public bool IsSection
{
get
{
return false;
}
}
public bool IsStep
{
get
{
return false;
}
}
//public bool HasStandardSteps()
//{ return false; }
#endregion
}
public FormatInfo ActiveFormat => ActiveParent.ActiveFormat;
public FormatInfo LocalFormat => null;
public ConfigDynamicTypeDescriptor MyConfig => null;
public bool IsFolder => false;
public bool IsDocVersion => false;
public bool IsProcedure => false;
public bool IsSection => false;
public bool IsStep => false;
#endregion
}
// B2017-146 added the "Part" and "Parts" types of zero so that we have a valid node name when creating an export of a procedure with this FromType value
public enum E_FromType : int
+19 -35
View File
@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using Csla.Validation;
using System.Diagnostics;
namespace VEPROMS.CSLA.Library
{
@@ -14,8 +9,6 @@ namespace VEPROMS.CSLA.Library
{
public static void DeleteAll(int docID)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Pdf");
try
{
DataPortal.Delete(new DocIDCriteria(docID));
@@ -28,14 +21,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class DocIDCriteria
{
private int _DocID;
public int DocID
{ get { return _DocID; } }
public DocIDCriteria(int docID)
{
_DocID = docID;
}
}
private readonly int _DocID;
public int DocID => _DocID;
public DocIDCriteria(int docID) => _DocID = docID;
}
[Transactional(TransactionalTypes.TransactionScope)]
private void DataPortal_Delete(DocIDCriteria criteria)
{
@@ -66,8 +55,6 @@ namespace VEPROMS.CSLA.Library
// used to remove word section PDFs to force ROs to be updated when printed or saved
public static void DeleteDocVersionPDFsWithNewROs(int versionID, int origfstid, int newfstid)
{
if (!CanDeleteObject())
throw new System.Security.SecurityException("User not authorized to remove a Pdf");
try
{
DeleteWithNewROs(versionID, origfstid, newfstid);
@@ -111,11 +98,10 @@ namespace VEPROMS.CSLA.Library
{
if (sect.MyContent.MyEntry == null) return; // B2023-030 not a word section so just jump out
DocStyle myDocStyle = sect.ActiveSection.MyDocStyle;
SectionConfig sc = sect.ActiveSection.MyConfig as SectionConfig;
int ss = sect.MyDocVersion.DocVersionConfig.SelectedSlave;
int ss = sect.MyDocVersion.DocVersionConfig.SelectedSlave;
if (sc != null && sc.Section_WordMargin == "Y")
if (sect.ActiveSection.MyConfig is SectionConfig sc && sc.Section_WordMargin == "Y")
{
RemoveFromCachedByPrimaryKey(sect.MyContent.MyEntry.DocID, ss * 10 + MSWordToPDF.DebugStatus, 0, 0, 0, 0);
}
@@ -132,23 +118,21 @@ namespace VEPROMS.CSLA.Library
while (count < 2)
{
DocStyle myDocStyle = sect.ActiveSection.MyDocStyle;
SectionConfig sc = sect.ActiveSection.MyConfig as SectionConfig;
PdfInfo myPdf = null;
int ss = sect.MyDocVersion.DocVersionConfig.SelectedSlave;
int ss = sect.MyDocVersion.DocVersionConfig.SelectedSlave;
PdfInfo myPdf;
if (sect.ActiveSection.MyConfig is SectionConfig sc && sc.Section_WordMargin == "Y")
{
myPdf = Get(sect.MyContent.MyEntry.DocID, ss * 10 + MSWordToPDF.DebugStatus, 0, 0, 0, 0);
}
else
{
myPdf = Get(sect.MyContent.MyEntry.DocID, ss * 10 + MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopMargin, (int)myDocStyle.Layout.PageLength,
(int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth);
}
if (sc != null && sc.Section_WordMargin == "Y")
{
myPdf = Get(sect.MyContent.MyEntry.DocID, ss*10 + MSWordToPDF.DebugStatus, 0, 0, 0, 0);
}
else
{
myPdf = Get(sect.MyContent.MyEntry.DocID, ss*10 + MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopMargin, (int)myDocStyle.Layout.PageLength,
(int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth);
}
// override forces the printing of the word section, which creates a word file with resolved ROs, which is saved for an approved export
if (!ovrride || (ovrride && count == 1))
// override forces the printing of the word section, which creates a word file with resolved ROs, which is saved for an approved export
if (!ovrride || (ovrride && count == 1))
{
if (myPdf != null) return myPdf;
if (count > 0) return null; // Could not find or create a pdf
@@ -8,13 +8,6 @@
// $History: $
// ========================================================================
using System;
using System.Data;
using System.Data.SqlClient;
using Csla;
using Csla.Data;
using System.Configuration;
using System.IO;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
@@ -23,22 +16,16 @@ namespace VEPROMS.CSLA.Library
{
public partial class ChildFoldersPropertyDescriptor
{
public override string DisplayName
{ get { return Item.Name; } }
public override string Description
{ get { return Item.Title; } }
public override string Name
{ get { return Item.Name; } }
}
public override string DisplayName => Item.Name;
public override string Description => Item.Title;
public override string Name => Item.Name;
}
public partial class FolderDocVersionsPropertyDescriptor
{
public override string DisplayName
{ get { return Item.Name; } }
public override string Description
{ get { return Item.Name; } }
public override string Name
{ get { return Item.Name; } }
}
public override string DisplayName => Item.Name;
public override string Description => Item.Name;
public override string Name => Item.Name;
}
public class FormatList : System.ComponentModel.StringConverter
{
private static SortedList<string, FormatInfo> _MyFormatInfoList;
@@ -64,19 +51,10 @@ namespace VEPROMS.CSLA.Library
_MyFormatInfoList.Add("", null);
}
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection((ICollection)MyFormatInfoList.Values);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
public static int? ToInt(string formatName)
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) => new StandardValuesCollection((ICollection)MyFormatInfoList.Values);
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => true;
public static int? ToInt(string formatName)
{
if (formatName == null || formatName == string.Empty) return null;
foreach (FormatInfo formatInfo in MyFormatInfoList.Values)
@@ -136,31 +114,12 @@ namespace VEPROMS.CSLA.Library
if (!ds.Inactive)_MyDocStyleList.Add(ds.Name,10000 + (int) ds.Index);
}
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection((ICollection)MyDocStyleList.Keys);
}
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
{
return true;
}
public static int? ToInt(string docStyleName)
{
return MyDocStyleList[docStyleName];
}
public static string ToString(int? sectionType)
{
if (sectionType == null) return null;
return MyDocStyleList.Keys[MyDocStyleList.IndexOfValue((int)sectionType)];
}
public static int ToSectionType(string docStyleName)
{
return MyDocStyleList[docStyleName];
}
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) => new StandardValuesCollection((ICollection)MyDocStyleList.Keys);
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) => true;
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) => true;
public static int? ToInt(string docStyleName) => MyDocStyleList[docStyleName];
public static string ToString(int? sectionType) => sectionType == null ? null : MyDocStyleList.Keys[MyDocStyleList.IndexOfValue((int)sectionType)];
public static int ToSectionType(string docStyleName) => MyDocStyleList[docStyleName];
}
}
+12 -52
View File
@@ -9,13 +9,6 @@
// ========================================================================
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;
using Csla;
using Csla.Data;
using System.Data.SqlClient;
@@ -28,17 +21,10 @@ namespace VEPROMS.CSLA.Library
#region RODb Config
[NonSerialized]
private RODbConfig _RODbConfig;
public RODbConfig RODbConfig
{ get { return (_RODbConfig != null ? _RODbConfig : _RODbConfig = new RODbConfig(this)); } }
private void RODbConfigRefresh()
{
_RODbConfig = null;
}
public RODbConfig RODbConfig => _RODbConfig ?? (_RODbConfig = new RODbConfig(this));
#endregion
public static RODbInfo GetJustRODB(int rODbID)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODbInfo tmp = GetCachedByPrimaryKey(rODbID);
@@ -62,14 +48,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteriaJustRODB
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
public PKCriteriaJustRODB(int rODbID)
{
_RODbID = rODbID;
}
}
private readonly int _RODbID;
public int RODbID => _RODbID;
public PKCriteriaJustRODB(int rODbID) => _RODbID = rODbID;
}
private void DataPortal_Fetch(PKCriteriaJustRODB criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODbInfo.DataPortal_Fetch", GetHashCode());
@@ -112,8 +94,6 @@ namespace VEPROMS.CSLA.Library
{
public static RODb GetJustRoDb(int rODbID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a RODb");
try
{
RODb tmp = DataPortal.Fetch<RODb>(new PKCriteriaJustRoDb(rODbID));
@@ -151,15 +131,6 @@ namespace VEPROMS.CSLA.Library
return;
}
ReadData(dr);
// Don't load child objects
//dr.NextResult();
//_RODbROFsts = RODbROFsts.Get(dr);
// load child objects
//dr.NextResult();
//_RODbROImages = RODbROImages.Get(dr);
// load child objects
//dr.NextResult();
//_RODbRoUsages = RODbRoUsages.Get(dr);
}
}
// removing of item only needed for local data portal
@@ -177,18 +148,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteriaJustRoDb
{
private int _RODbID;
public int RODbID
{ get { return _RODbID; } }
public PKCriteriaJustRoDb(int rODbID)
{
_RODbID = rODbID;
}
}
#region Log4Net
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
private readonly int _RODbID;
public int RODbID => _RODbID;
public PKCriteriaJustRoDb(int rODbID) => _RODbID = rODbID;
}
#region RODb Config
[NonSerialized]
@@ -205,10 +168,7 @@ namespace VEPROMS.CSLA.Library
return _RODbConfig;
}
}
private void _RODbConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Config = _RODbConfig.ToString();
}
#endregion
}
private void _RODbConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) => Config = _RODbConfig.ToString();
#endregion
}
}
+111 -208
View File
@@ -10,12 +10,8 @@
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;
using System.Text.RegularExpressions;
using System.Data;
using System.Data.SqlClient;
@@ -30,9 +26,6 @@ namespace VEPROMS.CSLA.Library
{
public static ROFst GetJustROFst(int rOFstID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a ROFst");
try
{
ROFst tmp = GetCachedByPrimaryKey(rOFstID);
@@ -59,14 +52,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteriaJustROFst
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteriaJustROFst(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private readonly int _ROFstID;
public int ROFstID => _ROFstID;
public PKCriteriaJustROFst(int rOFstID) => _ROFstID = rOFstID;
}
private void DataPortal_Fetch(PKCriteriaJustROFst criteria)
{
@@ -111,30 +100,22 @@ namespace VEPROMS.CSLA.Library
public partial class ROFstInfo
{
#region Log4Net
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
[Serializable()]
protected class PKCriteriaJustROFst
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
public PKCriteriaJustROFst(int rOFstID)
{
_ROFstID = rOFstID;
}
}
private readonly int _ROFstID;
public int ROFstID => _ROFstID;
public PKCriteriaJustROFst(int rOFstID) => _ROFstID = rOFstID;
}
#region Fields
// this is used by the frmBatchRefresh which is the Adim Tools so that one message is display for a group of procedure sets processed
public static StringBuilder MessageList = null;
private static List<int> DocVersionsNeedingROUpdate = new List<int>();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private static List<int> DocVersionsNeedingROUpdate = new List<int>();
#endregion
@@ -142,23 +123,19 @@ namespace VEPROMS.CSLA.Library
public event ROFstInfoROTableUpdateEvent ROTableUpdate;
#endregion
#endregion
#region Public Methods
#region Public Methods
// B2022-107: Display Progress Bar Messages/Statuses when a new ROFST binary file is loaded into the database
public ROFSTLookup GetROFSTLookup(DocVersionInfo dvi, string ovrrideChild = null, bool showLoadingStatus = true) => new ROFSTLookup(this.ROFstID, dvi, ovrrideChild, showLoadingStatus);
public ROFSTLookup GetROFSTLookup(DocVersionInfo dvi, string ovrrideChild = null, bool showLoadingStatus = true)
{
// B2022-107: Display Progress Bar Messages/Statuses when a new ROFST binary file is loaded into the database
return new ROFSTLookup(this.ROFstID, dvi, ovrrideChild, showLoadingStatus);
}
/// <summary>
/// Adds an ro.fst into a sql database.
/// </summary>
/// <param name="rdi" - the Rodb to use as the path for updating the ro.fst, i.e. import from there.
/// <param name="docver" - hook into this doc version></param>
/// <returns>ROFst: Returns the created rofst object</returns>
public static ROFst AddRoFst(RODbInfo rdi, DocVersion docver, ROFstInfoProgressBarRefresh myProgressBarRefresh)
/// <summary>
/// Adds an ro.fst into a sql database.
/// </summary>
/// <param name="rdi" - the Rodb to use as the path for updating the ro.fst, i.e. import from there.
/// <param name="docver" - hook into this doc version></param>
/// <returns>ROFst: Returns the created rofst object</returns>
public static ROFst AddRoFst(RODbInfo rdi, DocVersion docver, ROFstInfoProgressBarRefresh myProgressBarRefresh)
{
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
@@ -218,9 +195,11 @@ namespace VEPROMS.CSLA.Library
}
if (myUnChangedROImages.Count > 0)
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
#pragma warning disable CS0642 // Possible mistaken empty statement - valid - keeps scope of add
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
#pragma warning restore CS0642 // Possible mistaken empty statement
return rofst;
return rofst;
}
}
}
@@ -252,8 +231,7 @@ namespace VEPROMS.CSLA.Library
TimeSpan ts = DateTime.Now - start;
if (tbStatus != null)
tbStatus.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects{0}, Fixed {3} Referenced Objects{0}, Elapsed Seconds:{4}{0}{0}", Environment.NewLine, itm.MyProcedure.DisplayNumber, ItemInfo.ROCheckCount, ItemInfo.ROFixCount, ts.TotalSeconds));
tbStatus?.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects{0}, Fixed {3} Referenced Objects{0}, Elapsed Seconds:{4}{0}{0}", Environment.NewLine, itm.MyProcedure.DisplayNumber, ItemInfo.ROCheckCount, ItemInfo.ROFixCount, ts.TotalSeconds));
}
//Update the DocVersion Associations to link to the new RO FST id and current date/time
@@ -288,8 +266,7 @@ namespace VEPROMS.CSLA.Library
DocVersionInfo dvi = DocVersionInfo.Get(proc.MyDocVersion.VersionID);
if (dvi.DocVersionConfig.SelectedSlave <= 0)
{
int i = 0;
DateTime start = DateTime.Now;
DateTime start = DateTime.Now;
ProcedureInfo.ResetCheckROLinkCounters();
ProcedureInfo.CheckReferenceObjectsLinks(proc);
@@ -297,8 +274,7 @@ namespace VEPROMS.CSLA.Library
TimeSpan ts = DateTime.Now - start;
if (tbStatus != null)
tbStatus.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects Links{0}, Found {3} Bad RO Links{0} Elapsed Seconds:{5}{0}{0}", Environment.NewLine, proc.DisplayNumber, ProcedureInfo.CheckROLinksCount, ProcedureInfo.BadROLinksCount, ProcedureInfo.FixedROLinksCount, ts.TotalSeconds));
tbStatus?.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects Links{0}, Found {3} Bad RO Links{0} Elapsed Seconds:{5}{0}{0}", Environment.NewLine, proc.DisplayNumber, ProcedureInfo.CheckROLinksCount, ProcedureInfo.BadROLinksCount, ProcedureInfo.FixedROLinksCount, ts.TotalSeconds));
/*** keep for now - incase we decide to fix RO links later on, this will show the number of RO Links that we fixed
//tbStatus.AppendText(string.Format("Procedure: {1}{0}, Checked {2} Referenced Objects Links{0}, Found {3} Bad RO Links{0}, Fixed {4} Bad RO Links{0} Elapsed Seconds:{5}{0}{0}", Environment.NewLine, proc.DisplayNumber, ProcedureInfo.CheckROLinksCount, ProcedureInfo.BadROLinksCount, ProcedureInfo.FixedROLinksCount, ts.TotalSeconds));
***/
@@ -330,9 +306,9 @@ namespace VEPROMS.CSLA.Library
{
ROWorkingDraftAsk.ClearWorkingDrafts();
if (myProgressBarRefresh != null) myProgressBarRefresh(0, 100, "Starting Update");
myProgressBarRefresh?.Invoke(0, 100, "Starting Update");
int origFSTid = origROFst.ROFstID;
int origFSTid = origROFst.ROFstID;
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
@@ -346,16 +322,15 @@ namespace VEPROMS.CSLA.Library
if (rofst != null)
{
// Get a list of figures which have changed content (DTS)
List<string> MyChangedFigureROIDs = null;
if (docver.ROfstLoadingFigures) // B2017-125 see if loading figures was completed
{
ROFSTLookup myLookup = new ROFSTLookup(rofst.ROFstID, DocVersionInfo.Get(docver.VersionID));
MyChangedFigureROIDs = UpdateROFigures(rdi, myProgressBarRefresh, rofst, RODb.GetJustRoDb(rdi.RODbID), myLookup, docver);
_ = UpdateROFigures(rdi, myProgressBarRefresh, rofst, RODb.GetJustRoDb(rdi.RODbID), myLookup, docver);
}
else
{
MyChangedFigureROIDs = GetChangedFigureROIDs(origROFst, ROFstInfo.GetJustROFst(rofst.ROFstID), DocVersionInfo.Get(docver.VersionID), myProgressBarRefresh);
_ = GetChangedFigureROIDs(origROFst, ROFstInfo.GetJustROFst(rofst.ROFstID), DocVersionInfo.Get(docver.VersionID), myProgressBarRefresh);
}
docver.DocVersionAssociations[0].MyROFst = rofst;
@@ -404,18 +379,11 @@ namespace VEPROMS.CSLA.Library
return false;
}
public ROFst GetJustROFst()
{
return ROFst.GetJustROFst(ROFstID);
}
public ROFst GetJustROFst() => ROFst.GetJustROFst(ROFstID);
public List<string> OnROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
if (ROTableUpdate != null) return ROTableUpdate(sender, args);
return null;
}
public List<string> OnROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args) => ROTableUpdate != null ? ROTableUpdate(sender, args) : null;
public static ROFstInfo GetJustROFst(int rOFstID)
public static ROFstInfo GetJustROFst(int rOFstID)
{
try
{
@@ -433,11 +401,6 @@ namespace VEPROMS.CSLA.Library
tmp = null;
}
if (tmp != null)
{
tmp.ClearROLookupBytes();
}
return tmp;
}
catch (Exception ex)
@@ -481,9 +444,11 @@ namespace VEPROMS.CSLA.Library
{
string cfg = docver.DocVersionAssociations[0].Config;
AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "<Config />" : cfg);
ac.ROUpdate_LastCompleted = value;
docver.DocVersionAssociations[0].Config = ac.ToString();
AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "<Config />" : cfg)
{
ROUpdate_LastCompleted = value
};
docver.DocVersionAssociations[0].Config = ac.ToString();
docver.Save();
}
@@ -494,9 +459,11 @@ namespace VEPROMS.CSLA.Library
if (docver.DocVersionAssociations[0]?.MyROFst != null && value != -1)
{
string cfg = docver.DocVersionAssociations[0].Config;
AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "<Config />" : cfg);
ac.ROUpdate_PrevROFSTID = value.ToString();
docver.DocVersionAssociations[0].Config = ac.ToString();
AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "<Config />" : cfg)
{
ROUpdate_PrevROFSTID = value.ToString()
};
docver.DocVersionAssociations[0].Config = ac.ToString();
docver.Save();
}
}
@@ -506,9 +473,11 @@ namespace VEPROMS.CSLA.Library
{
string cfg = docver.DocVersionAssociations[0].Config;
AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "<Config />" : cfg);
ac.ROUpdate_LoadingFigures = value;
docver.DocVersionAssociations[0].Config = ac.ToString();
AssociationConfig ac = new AssociationConfig((cfg == null || cfg.Length == 0) ? "<Config />" : cfg)
{
ROUpdate_LoadingFigures = value
};
docver.DocVersionAssociations[0].Config = ac.ToString();
docver.Save();
}
@@ -539,8 +508,10 @@ namespace VEPROMS.CSLA.Library
// Add references for existing RO Images to the Figure table (Figure table relates ro.fst with its images)
if (myUnChangedROImages.Count > 0)
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
}
#pragma warning disable CS0642 // Possible mistaken empty statement - valid keeps scope of add
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
#pragma warning restore CS0642 // Possible mistaken empty statement
}
SetAssociationROFiguresLoading(docVer, string.Empty); // B2017-125 loading RO Figures is completed
@@ -662,12 +633,9 @@ namespace VEPROMS.CSLA.Library
return myRoImagesList;
}
private static string ROImageKey(string fileName, DateTime dts)
{
return string.Format("{0}:{1}", fileName, dts);
}
private static string ROImageKey(string fileName, DateTime dts) => string.Format("{0}:{1}", fileName, dts);
private static string buildImageIDString(List<int> myROImageIDs)
private static string buildImageIDString(List<int> myROImageIDs)
{
StringBuilder sb = new StringBuilder();
@@ -687,61 +655,6 @@ namespace VEPROMS.CSLA.Library
return sb.ToString();
}
private static DateTime ShowDuration(DateTime dtLast, string message)
{
DateTime dtNext = DateTime.Now;
Console.WriteLine("{0,10:#####0.00},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - dtLast.Ticks).TotalSeconds, message);
return dtNext;
}
private static List<string> BuildActiveROIDsForRoUsages12(string RoidList, string versions)
{
List<string> activeRoids = new List<string>();
using (RoUsageInfoList activeList = RoUsageInfoList.GetROUSagesByROIDsAndVersions(RoidList, versions))
{
foreach (RoUsageInfo roui in activeList)
{
string roid = roui.ROID.ToUpper().Substring(0, 12);
if (!activeRoids.Contains(roid))
activeRoids.Add(roid);
}
}
return activeRoids;
}
private static List<string> BuildActiveROIDsForDRoUsages12(string RoidList, string versions)
{
List<string> activeRoids = new List<string>();
using (DROUsageInfoList activeList = DROUsageInfoList.GetDROUsagesByROIDsAndVersions(RoidList, versions))
{
foreach (DROUsageInfo roui in activeList)
{
string roid = roui.ROID.Substring(0, 12);
if (!activeRoids.Contains(roid))
activeRoids.Add(roid);
}
}
return activeRoids;
}
private static string GetRoidList(int dbid, List<string> chgList)
{
StringBuilder sb = new StringBuilder(string.Format("{0}", dbid));
string sep = ":";
foreach (string roid in chgList)
{
sb.Append(sep + roid);
sep = ",";
}
return sb.ToString();
}
// B2022-026 RO Memory Reduction code - all rochild types passed in are of type image (graphics)
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages, List<string> MyChangedFigureROIDs, ROFstInfoProgressBarRefresh myProgressBarRefresh, int cnt, ref int curCnt)
{
@@ -771,64 +684,65 @@ namespace VEPROMS.CSLA.Library
}
string imgfile = rdi.FolderPath + @"\" + fname;
if (File.Exists(imgfile))
{
FileInfo fi = new FileInfo(imgfile);
ROImage roImg = null;
// if the roimage record exists, don't create a new one...
string key = ROImageKey(imgname, fi.LastWriteTimeUtc);
if (File.Exists(imgfile))
{
FileInfo fi = new FileInfo(imgfile);
if (myExistingROImages.ContainsKey(key))
{
int imageID = myExistingROImages[key];
if (!myUnChangedROImages.Contains(imageID))
myUnChangedROImages.Add(imageID);
}
else
{
if (!myAddedROImages.Contains(key))
{
myProgressBarRefresh(curCnt, cnt, "Loading " + imgname); // show progress of loading images
// if the roimage record exists, don't create a new one...
string key = ROImageKey(imgname, fi.LastWriteTimeUtc);
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader r = new BinaryReader(fsIn);
byte[] ab = r.ReadBytes((int)fsIn.Length);
r.Close();
fsIn.Close();
if (myExistingROImages.ContainsKey(key))
{
int imageID = myExistingROImages[key];
if (!myUnChangedROImages.Contains(imageID))
myUnChangedROImages.Add(imageID);
}
else
{
if (!myAddedROImages.Contains(key))
{
myProgressBarRefresh(curCnt, cnt, "Loading " + imgname); // show progress of loading images
byte[] cmp = ROImageInfo.Compress(ab);
int existingImageID = FindExisting(myExistingROImages, imgname, imgfile, cmp, ab);
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
BinaryReader r = new BinaryReader(fsIn);
byte[] ab = r.ReadBytes((int)fsIn.Length);
r.Close();
fsIn.Close();
if (existingImageID != 0)
{
if (!myUnChangedROImages.Contains(existingImageID))
{
myUnChangedROImages.Add(existingImageID);
}
byte[] cmp = ROImageInfo.Compress(ab);
int existingImageID = FindExisting(myExistingROImages, imgname, imgfile, cmp, ab);
return;
}
if (existingImageID != 0)
{
if (!myUnChangedROImages.Contains(existingImageID))
{
myUnChangedROImages.Add(existingImageID);
}
ROImageConfig rc = new ROImageConfig
{
Image_Size = ab.Length.ToString()
};
return;
}
ROImageConfig rc = new ROImageConfig();
rc.Image_Size = ab.Length.ToString();
using (roImg = ROImage.MakeROImage(rodb, imgname, ROImageInfo.Compress(ab), rc.ToString(), fi.LastWriteTimeUtc, "Migration"))
{
using (Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID))
{
if (figure != null) return;
Figure.MakeFigure(rofst, roImg, null).Dispose();
myAddedROImages.Add(key);
MyChangedFigureROIDs.Add(myRO.roid); // Save the roid so that the related documents will be refeshed. (PDF will be deleted)
}
}
}
}
}
}
ROImage roImg;
using (roImg = ROImage.MakeROImage(rodb, imgname, ROImageInfo.Compress(ab), rc.ToString(), fi.LastWriteTimeUtc, "Migration"))
{
using (Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID))
{
if (figure != null) return;
Figure.MakeFigure(rofst, roImg, null).Dispose();
myAddedROImages.Add(key);
MyChangedFigureROIDs.Add(myRO.roid); // Save the roid so that the related documents will be refeshed. (PDF will be deleted)
}
}
}
}
}
}
private int FindExisting(Dictionary<string, int> myExistingROImages, string imgname, string imgfile, byte[] cmpFileContents, byte[] fileContents)
{
@@ -940,22 +854,12 @@ namespace VEPROMS.CSLA.Library
public class ROFstInfoROTableUpdateEventArgs
{
private string _ROText;
public string ROText
public string ROText { get; set; }
public string OldGridXml { get; set; }
public ROFstInfoROTableUpdateEventArgs(string rotext, string oldgridxml)
{
get { return _ROText; }
set { _ROText = value; }
}
private string _OldGridXml;
public string OldGridXml
{
get { return _OldGridXml; }
set { _OldGridXml = value; }
}
public ROFstInfoROTableUpdateEventArgs(string rotext, string oldgridxml)
{
_ROText = rotext;
_OldGridXml = oldgridxml;
ROText = rotext;
OldGridXml = oldgridxml;
}
}
@@ -1045,7 +949,6 @@ namespace VEPROMS.CSLA.Library
}
}
//GC.Collect();
return isDifferent;
}
catch (Exception ex)
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
@@ -14,63 +13,30 @@ namespace VEPROMS.CSLA.Library
public delegate void ROImageInfoCompressionEvent(object sender, ROImageInfoCompressionEventArgs args);
public class ROImageInfoCompressionEventArgs
{
private int _Total;
public int Total
public int Total { get; set; }
public int Current { get; set; }
public string FileName { get; set; }
public ROImageCompressionEventType Type { get; set; }
public ROImageInfoCompressionEventArgs(ROImageCompressionEventType type) => Type = type;
public ROImageInfoCompressionEventArgs(int current, string fileName)
{
get { return _Total; }
set { _Total = value; }
}
private int _Current;
public int Current
{
get { return _Current; }
set { _Current = value; }
}
private string _FileName;
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
private ROImageCompressionEventType _Type;
public ROImageCompressionEventType Type
{
get { return _Type; }
set { _Type = value; }
}
public ROImageInfoCompressionEventArgs(ROImageCompressionEventType type)
{
_Type = type;
}
public ROImageInfoCompressionEventArgs(int current, string fileName)
{
_Current = current;
_FileName = fileName;
_Type = ROImageCompressionEventType.Update;
Current = current;
FileName = fileName;
Type = ROImageCompressionEventType.Update;
}
public ROImageInfoCompressionEventArgs(int total)
{
_Type = ROImageCompressionEventType.Initialize;
_Total = total;
Type = ROImageCompressionEventType.Initialize;
Total = total;
}
}
public enum ROImageCompressionEventType:int {Initialize, Update, Complete};
public partial class ROImageInfo
{
public static event ROImageInfoCompressionEvent CompressAllExistingImages;
public static void OnCompressAllExistingImages(object sender, ROImageInfoCompressionEventArgs args)
public static void OnCompressAllExistingImages(object sender, ROImageInfoCompressionEventArgs args) => CompressAllExistingImages?.Invoke(sender, args);
public static ROImageInfo GetByROFstID_FileName(int rOFstID, string fileName)
{
if (CompressAllExistingImages != null) CompressAllExistingImages(sender, args);
}
// put in for debug
//public static int CacheCountPrimaryKey
//{ get { return _CacheByPrimaryKey.Count; } }
//public static int CacheCountList
//{ get { return _CacheList.Count; } }
public static ROImageInfo GetByROFstID_FileName(int rOFstID, string fileName)
{
//if (!CanGetObject())
// throw new System.Security.SecurityException("User not authorized to view a ROImage");
try
{
if (fileName.EndsWith("PCX")) fileName = fileName.Replace(".PCX", ".TIF");
@@ -95,7 +61,6 @@ namespace VEPROMS.CSLA.Library
}
public static byte[] Compress(byte[] blob)
{
int size = blob.Length;
using (MemoryStream Source = new MemoryStream(blob))
{
using (MemoryStream Destination = new MemoryStream())
@@ -171,9 +136,11 @@ namespace VEPROMS.CSLA.Library
{
string nm = ro.FileName;
OnCompressAllExistingImages(null, new ROImageInfoCompressionEventArgs(pcount++, nm));
ROImageConfig rc = new ROImageConfig();
rc.Image_Size = ro.Content.Length.ToString();
ro.Content = ROImageInfo.Compress(ro.Content);
ROImageConfig rc = new ROImageConfig
{
Image_Size = ro.Content.Length.ToString()
};
ro.Content = ROImageInfo.Compress(ro.Content);
ro.Config = rc.ToString();
ro.Save();
}
@@ -226,14 +193,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class ROFstID_FileNameCriteria
{
private int _ROFstID;
public int ROFstID
{ get { return _ROFstID; } }
private string _FileName;
public string FileName
{ get { return _FileName; } }
public ROFstID_FileNameCriteria(int rOFstID, string fileName)
private readonly int _ROFstID;
public int ROFstID => _ROFstID;
private readonly string _FileName;
public string FileName => _FileName;
public ROFstID_FileNameCriteria(int rOFstID, string fileName)
{
_ROFstID = rOFstID;
_FileName = fileName;
@@ -245,7 +209,6 @@ namespace VEPROMS.CSLA.Library
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Fields
private bool _IsDisposed;
//private static string _TemporaryFolder = null;
#endregion
#region Properties
private ROImageInfo _MyROImage = null;
@@ -260,19 +223,12 @@ namespace VEPROMS.CSLA.Library
}
}
private FileInfo _MyFile = null;
public FileInfo MyFile
{
get { return _MyFile; }
}
private string _Extension = "TIF";
public string Extension
{
get { return _Extension; }
set { _Extension = value; }
}
#endregion
#region Private Methods
private void TryDelete()
public FileInfo MyFile => _MyFile;
public string Extension { get; set; } = "TIF";
#endregion
#region Private Methods
private void TryDelete()
{
if (_MyROImage == null) return;
if (_MyFile == null) return;
@@ -356,15 +312,12 @@ namespace VEPROMS.CSLA.Library
roImage.DTS = _MyFile.LastWriteTimeUtc;
roImage.Save();
}
#endregion
#region Constructors
public ROImageFile(ROImageInfo myROImage)
{
MyROImage = myROImage;
}
#endregion
#region Destructor
~ROImageFile()
#endregion
#region Constructors
public ROImageFile(ROImageInfo myROImage) => MyROImage = myROImage;
#endregion
#region Destructor
~ROImageFile()
{
Dispose(false);
}
@@ -374,7 +327,8 @@ namespace VEPROMS.CSLA.Library
GC.SuppressFinalize(this);
}
protected void Dispose(bool disposing)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Keeping disposing to match different signature")]
protected void Dispose(bool disposing)
{
if (!_IsDisposed)
{
@@ -402,17 +356,10 @@ namespace VEPROMS.CSLA.Library
}
private class RODbIDNoDataCriteria
{
public RODbIDNoDataCriteria(int rODbID)
{
_RODbID = rODbID;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
}
public RODbIDNoDataCriteria(int rODbID) => RODbID = rODbID;
public int RODbID { get; set; }
}
private void DataPortal_Fetch(RODbIDNoDataCriteria criteria)
{
this.RaiseListChangedEvents = false;
@@ -448,7 +395,6 @@ namespace VEPROMS.CSLA.Library
try
{
ROImageInfoList tmp = DataPortal.Fetch<ROImageInfoList>(new RODbIDFilenameCriteria(rODbID,filename));
//ROImageInfo.AddList(tmp);
tmp.AddEvents();
return tmp;
}
@@ -461,22 +407,13 @@ namespace VEPROMS.CSLA.Library
{
public RODbIDFilenameCriteria(int rODbID,string filename)
{
_RODbID = rODbID;
_Filename = filename;
RODbID = rODbID;
Filename = filename;
}
private int _RODbID;
public int RODbID
{
get { return _RODbID; }
set { _RODbID = value; }
}
private string _Filename;
public string Filename
{
get { return _Filename; }
set { _Filename = value; }
}
}
public int RODbID { get; set; }
public string Filename { get; set; }
}
private void DataPortal_Fetch(RODbIDFilenameCriteria criteria)
{
this.RaiseListChangedEvents = false;
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Csla;
@@ -118,11 +116,8 @@ namespace VEPROMS.CSLA.Library
[Serializable]
private class GetROUsagesByROIDsCriteria
{
public GetROUsagesByROIDsCriteria(string roids)
{
_ROIDS = roids;
}
private string _ROIDS;
public GetROUsagesByROIDsCriteria(string roids) => _ROIDS = roids;
private string _ROIDS;
public string ROIDS
{
get { return _ROIDS; }
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Text;
using Csla;
using Csla.Data;
using Csla.Validation;
using System.Data.SqlClient;
using System.Data;
using Volian.Base.Library;
@@ -143,35 +142,20 @@ namespace VEPROMS.CSLA.Library
public delegate void ItemInfoListCCEvent(object sender, ItemInfoListCCEventArgs args);
public class ItemInfoListCCEventArgs : EventArgs
{
private ProcedureInfo _MyProcedure;
public ProcedureInfo MyProcedure { get; set; }
public ProcedureInfo MyProcedure
public int MyCount { get; set; }
public ItemInfoListCCEventArgs(ProcedureInfo myProcedure, int myCount)
{
get { return _MyProcedure; }
set { _MyProcedure = value; }
}
private int _MyCount;
public int MyCount
{
get { return _MyCount; }
set { _MyCount = value; }
}
public ItemInfoListCCEventArgs(ProcedureInfo myProcedure, int myCount)
{
_MyProcedure = myProcedure;
_MyCount = myCount;
MyProcedure = myProcedure;
MyCount = myCount;
}
}
public partial class ItemInfoList
{
public static event ItemInfoListCCEvent ConsistencyCheckUpdated;
private static void OnConsistencyCheckUpdated(object sender, ItemInfoListCCEventArgs args)
{
if (ConsistencyCheckUpdated != null)
ConsistencyCheckUpdated(sender, args);
}
public static ItemInfoList GetMoreProcedures(List<ProcedureInfo> procs)
private static void OnConsistencyCheckUpdated(object sender, ItemInfoListCCEventArgs args) => ConsistencyCheckUpdated?.Invoke(sender, args);
public static ItemInfoList GetMoreProcedures(List<ProcedureInfo> procs)
{
StringBuilder sb = new StringBuilder("<Items>");
int count = 1;
@@ -290,11 +274,8 @@ namespace VEPROMS.CSLA.Library
get { return _DocVersionID; }
set { _DocVersionID = value; }
}
public ItemListAllInConsistenciesCriteria(int docVersionID)
{
_DocVersionID = docVersionID;
}
}
public ItemListAllInConsistenciesCriteria(int docVersionID) => _DocVersionID = docVersionID;
}
private void DataPortal_Fetch(ItemListAllInConsistenciesCriteria criteria)
{
this.RaiseListChangedEvents = false;
@@ -359,16 +340,9 @@ namespace VEPROMS.CSLA.Library
}
public static Revision GetByItemIDAndRevisionNumber(int itemID, string revisionNumber)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Revision");
try
{
//Revision tmp = GetCachedByPrimaryKey(revisionID);
//if (tmp == null)
//{
Revision tmp = DataPortal.Fetch<Revision>(new ItemRevisionNumberCriteria(itemID, revisionNumber));
// AddToCache(tmp);
//}
Revision tmp = DataPortal.Fetch<Revision>(new ItemRevisionNumberCriteria(itemID, revisionNumber));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Revision
@@ -384,13 +358,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class ItemRevisionNumberCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
private string _RevisionNumber;
public string RevisionNumber
{ get { return _RevisionNumber; } }
public ItemRevisionNumberCriteria(int itemID, string revisionNumber)
private readonly int _ItemID;
public int ItemID => _ItemID;
private readonly string _RevisionNumber;
public string RevisionNumber => _RevisionNumber;
public ItemRevisionNumberCriteria(int itemID, string revisionNumber)
{
_ItemID = itemID;
_RevisionNumber = revisionNumber;
@@ -442,16 +414,9 @@ namespace VEPROMS.CSLA.Library
//jcb 20120625
public static Revision GetByItemIDAndRevisionNumberAndUnitID(int itemID, string revisionNumber, int unitID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Revision");
try
{
//Revision tmp = GetCachedByPrimaryKey(revisionID);
//if (tmp == null)
//{
Revision tmp = DataPortal.Fetch<Revision>(new UnitItemRevisionNumberCriteria(itemID, revisionNumber, unitID));
// AddToCache(tmp);
//}
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up Revision
@@ -467,16 +432,13 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class UnitItemRevisionNumberCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
private string _RevisionNumber;
public string RevisionNumber
{ get { return _RevisionNumber; } }
private int _UnitID;
public int UnitID
{ get { return _UnitID; } }
public UnitItemRevisionNumberCriteria(int itemID, string revisionNumber, int unitID)
private readonly int _ItemID;
public int ItemID => _ItemID;
private readonly string _RevisionNumber;
public string RevisionNumber => _RevisionNumber;
private readonly int _UnitID;
public int UnitID => _UnitID;
public UnitItemRevisionNumberCriteria(int itemID, string revisionNumber, int unitID)
{
_ItemID = itemID;
_RevisionNumber = revisionNumber;
@@ -535,12 +497,9 @@ namespace VEPROMS.CSLA.Library
{
try
{
//if (_RevisionInfoList != null)
// return _RevisionInfoList;
RevisionInfoList tmp = DataPortal.Fetch<RevisionInfoList>(new ItemCriteria(itemID));
RevisionInfo.AddList(tmp);
tmp.AddEvents();
//_RevisionInfoList = tmp;
return tmp;
}
catch (Exception ex)
@@ -551,14 +510,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class ItemCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
public ItemCriteria(int itemID)
{
_ItemID = itemID;
}
}
private readonly int _ItemID;
public int ItemID => _ItemID;
public ItemCriteria(int itemID) => _ItemID = itemID;
}
private void DataPortal_Fetch(ItemCriteria criteria)
{
this.RaiseListChangedEvents = false;
@@ -594,12 +549,9 @@ namespace VEPROMS.CSLA.Library
{
try
{
//if (_RevisionInfoList != null)
// return _RevisionInfoList;
RevisionInfoList tmp = DataPortal.Fetch<RevisionInfoList>(new ItemUnitCriteria(itemID, unitID));
RevisionInfo.AddList(tmp);
tmp.AddEvents();
//_RevisionInfoList = tmp;
return tmp;
}
catch (Exception ex)
@@ -610,13 +562,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class ItemUnitCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
private int _UnitID;
public int UnitID
{ get { return _UnitID; } }
public ItemUnitCriteria(int itemID, int unitID)
private readonly int _ItemID;
public int ItemID => _ItemID;
private readonly int _UnitID;
public int UnitID => _UnitID;
public ItemUnitCriteria(int itemID, int unitID)
{
_ItemID = itemID;
_UnitID = unitID;
@@ -671,14 +621,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class ItemCriteria
{
private int _ItemID;
public int ItemID
{ get { return _ItemID; } }
public ItemCriteria(int itemID)
{
_ItemID = itemID;
}
private int _UnitID = 0;
private readonly int _ItemID;
public int ItemID => _ItemID;
public ItemCriteria(int itemID) => _ItemID = itemID;
private int _UnitID = 0;
public int UnitID
{
get{return _UnitID;}
@@ -696,12 +642,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class CurrentItemUnitCriteria : ItemCriteria
{
public CurrentItemUnitCriteria(int itemID, int unitID)
: base(itemID)
{
UnitID = unitID;
}
}
public CurrentItemUnitCriteria(int itemID, int unitID)
: base(itemID) => UnitID = unitID;
}
[Serializable()]
protected class PreviousItemCriteria : ItemCriteria
{
@@ -714,12 +657,6 @@ namespace VEPROMS.CSLA.Library
{
try
{
//RevisionInfo tmp = GetCachedByPrimaryKey(revisionID);
//if (tmp == null)
//{
// tmp = DataPortal.Fetch<RevisionInfo>(new PKCriteria(revisionID));
// AddToCache(tmp);
//}
RevisionInfo tmp = DataPortal.Fetch<RevisionInfo>(new CurrentItemCriteria(itemID));
if (tmp.ErrorMessage == "No Record Found")
{
@@ -754,12 +691,6 @@ namespace VEPROMS.CSLA.Library
{
try
{
//RevisionInfo tmp = GetCachedByPrimaryKey(revisionID);
//if (tmp == null)
//{
// tmp = DataPortal.Fetch<RevisionInfo>(new PKCriteria(revisionID));
// AddToCache(tmp);
//}
RevisionInfo tmp = DataPortal.Fetch<RevisionInfo>(new PreviousItemCriteria(itemID));
if (tmp.ErrorMessage == "No Record Found")
{
@@ -906,9 +837,11 @@ namespace VEPROMS.CSLA.Library
}
public static string BuildRevisionChecks(ProcedureInfo proc)
{
ConsistencyChecks cc = new ConsistencyChecks();
cc.ItemID = proc.ItemID;
BuildROChecks(cc, proc);
ConsistencyChecks cc = new ConsistencyChecks
{
ItemID = proc.ItemID
};
BuildROChecks(cc, proc);
BuildTransitionFromChecks(cc, proc);
BuildTransitionToChecks(cc, proc);
BuildLibDocChecks(cc, proc);
@@ -933,13 +866,11 @@ namespace VEPROMS.CSLA.Library
//create checkro record for each roid
//_MyTimer.ActiveProcess = "Get DocVersionInfo";
// DocVersionInfo dbi = proc.ActiveParent as DocVersionInfo;
DocVersionInfo dvi = proc.MyDocVersion;
//_MyTimer.ActiveProcess = "Get MyROFst";
if (dvi.DocVersionAssociations == null || dvi.DocVersionAssociations.Count == 0) return; // B2020-124: don't crash if docversion doesn't have rofst
ROFstInfo rofst = ROFstInfo.GetJustROFst(dvi.DocVersionAssociations[0].ROFstID);
//_MyTimer.ActiveProcess = "Get ROFst Lookup";
//rofst.docVer = dvi;
ROFSTLookup lookup = rofst.GetROFSTLookup(dvi);
//_MyTimer.ActiveProcess = "Populating RevisionChecksXML table";
cc.ROConsistency.ROFstDate = rofst.DTS;
@@ -957,27 +888,21 @@ namespace VEPROMS.CSLA.Library
using (TransitionInfoList myList = TransitionInfoList.GetAllForProcedure(proc, true))
foreach (TransitionInfo myTI in myList)
{
//\v <START]\v0 EMG\u160?ES\u8209?02, REACTOR TRIP RESPONSE, Step 14\v #Link:Transition:0 1 102[END>\v0
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", myTI.TranType, myTI.TransitionID);
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", myTI.TranType, myTI.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", myTI.TranType, myTI.TransitionID);
Match m = Regex.Match(myTI.ContentText, lookFor);
if (m != null && m.Groups.Count > 1)
{
int myIndex = m.Groups[4].Index;
int myLength = m.Groups[4].Length;
if (m.Groups[3].Value != " ")
{
myIndex = m.Groups[3].Index;
myLength += m.Groups[3].Length;
}
string gg = myTI.ContentText.Substring(myIndex, myLength);
cc.AddTransitionFromCheck(myTI.TransitionID, gg);
// System.Text.RegularExpressions.Group g = m.Groups[3];
// cc.AddTransitionFromCheck(myTI.TransitionID, g.ToString());
int myIndex = m.Groups[4].Index;
int myLength = m.Groups[4].Length;
if (m.Groups[3].Value != " ")
{
myIndex = m.Groups[3].Index;
myLength += m.Groups[3].Length;
}
string gg = myTI.ContentText.Substring(myIndex, myLength);
cc.AddTransitionFromCheck(myTI.TransitionID, gg);
}
//_MyTimer.ActiveProcess = "get from path";
//string myPath = myTI.MyItemToID.ShortPath;
}
}
private static void BuildTransitionToChecks(ConsistencyChecks cc, ProcedureInfo proc)
@@ -985,24 +910,20 @@ namespace VEPROMS.CSLA.Library
using (TransitionInfoList myList = TransitionInfoList.GetAllForProcedure(proc, false))
foreach (TransitionInfo myTI in myList)
{
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", myTI.TranType, myTI.TransitionID);
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", myTI.TranType, myTI.TransitionID);
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", myTI.TranType, myTI.TransitionID);
Match m = Regex.Match(myTI.ContentText, lookFor);
if (m != null && m.Groups.Count > 1)
{
int myIndex = m.Groups[4].Index;
int myLength = m.Groups[4].Length;
if (m.Groups[3].Value != " ")
{
myIndex = m.Groups[3].Index;
myLength += m.Groups[3].Length;
}
string gg = myTI.ContentText.Substring(myIndex, myLength);
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
cc.AddTransitionToCheck(myTI.TransitionID, gg);
// System.Text.RegularExpressions.Group g = m.Groups[3];
// cc.AddTransitionToCheck(myTI.TransitionID, g.ToString());
int myIndex = m.Groups[4].Index;
int myLength = m.Groups[4].Length;
if (m.Groups[3].Value != " ")
{
myIndex = m.Groups[3].Index;
myLength += m.Groups[3].Length;
}
string gg = myTI.ContentText.Substring(myIndex, myLength);
gg = gg.Replace("{", @"\{").Replace("}", @"\}");
cc.AddTransitionToCheck(myTI.TransitionID, gg);
}
}
}
@@ -1013,25 +934,16 @@ namespace VEPROMS.CSLA.Library
cc.AddLibDocCheck(myDI.DocID, myDI.DTS);
}
private static Volian.Base.Library.VlnTimer _MyTimer;
public static void SetupTimer()
{
_MyTimer = new Volian.Base.Library.VlnTimer();
}
public static void ShowTimer()
{
_MyTimer.ShowElapsedTimes("BuildROChecks");
}
}
public static void SetupTimer() => _MyTimer = new Volian.Base.Library.VlnTimer();
public static void ShowTimer() => _MyTimer.ShowElapsedTimes("BuildROChecks");
}
public partial class RoUsageInfoList
{
[Serializable()]
private class AllForProcedureCriteria
{
public AllForProcedureCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public AllForProcedureCriteria(int itemID) => _ItemID = itemID;
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
@@ -1090,11 +1002,8 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class AllForProcedureCriteria
{
public AllForProcedureCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public AllForProcedureCriteria(int itemID) => _ItemID = itemID;
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
@@ -1217,9 +1126,11 @@ namespace VEPROMS.CSLA.Library
IsReadOnly = false;
while (dr.Read())
{
TransitionInfo ti = new TransitionInfo(dr);
ti.ContentText = dr.GetString("ContentText");
this.Add(ti);
TransitionInfo ti = new TransitionInfo(dr)
{
ContentText = dr.GetString("ContentText")
};
this.Add(ti);
}
IsReadOnly = true;
}
@@ -1239,11 +1150,8 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class AllForProcedureCriteria
{
public AllForProcedureCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public AllForProcedureCriteria(int itemID) => _ItemID = itemID;
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
@@ -1301,15 +1209,9 @@ namespace VEPROMS.CSLA.Library
[XmlRoot("ConsistencyChecks")]
public class ConsistencyChecks
{
public static ConsistencyChecks Get(string xml)
{
return GenericSerializer<ConsistencyChecks>.StringDeserialize(xml);
}
public override string ToString()
{
return GenericSerializer<ConsistencyChecks>.StringSerialize(this);
}
private int _ItemID;
public static ConsistencyChecks Get(string xml) => GenericSerializer<ConsistencyChecks>.StringDeserialize(xml);
public override string ToString() => GenericSerializer<ConsistencyChecks>.StringSerialize(this);
private int _ItemID;
[XmlAttribute("ItemID")]
public int ItemID
{
@@ -1326,12 +1228,9 @@ namespace VEPROMS.CSLA.Library
get { return _ROConsistency; }
set { _ROConsistency = value; }
}
public void AddROCheck(string roid, string roValue)
{
ROConsistency.AddROCheck(roid, roValue);
}
public void AddROCheck(string roid, string roValue) => ROConsistency.AddROCheck(roid, roValue);
private TransitionConsistency _TransitionFromConsistency = new TransitionConsistency();
private TransitionConsistency _TransitionFromConsistency = new TransitionConsistency();
[XmlElement("TransitionFromChecks")]
[Category("Transitions")]
[Description("Transition From Consistency Data")]
@@ -1341,11 +1240,8 @@ namespace VEPROMS.CSLA.Library
get { return _TransitionFromConsistency; }
set { _TransitionFromConsistency = value; }
}
public void AddTransitionFromCheck(int transitionid, string transitionValue)
{
TransitionFromConsistency.AddTransitionCheck(transitionid, transitionValue);
}
private TransitionConsistency _TransitionToConsistency = new TransitionConsistency();
public void AddTransitionFromCheck(int transitionid, string transitionValue) => TransitionFromConsistency.AddTransitionCheck(transitionid, transitionValue);
private TransitionConsistency _TransitionToConsistency = new TransitionConsistency();
[XmlElement("TransitionToChecks")]
[Category("Transitions")]
[Description("Transition To Consistency Data")]
@@ -1355,11 +1251,8 @@ namespace VEPROMS.CSLA.Library
get { return _TransitionToConsistency; }
set { _TransitionToConsistency = value; }
}
public void AddTransitionToCheck(int transitionid, string transitionValue)
{
TransitionToConsistency.AddTransitionCheck(transitionid, transitionValue);
}
private TransitionConsistency _TransitionConsistency = new TransitionConsistency();
public void AddTransitionToCheck(int transitionid, string transitionValue) => TransitionToConsistency.AddTransitionCheck(transitionid, transitionValue);
private TransitionConsistency _TransitionConsistency = new TransitionConsistency();
[XmlElement("TransitionChecks")]
[Category("Transitions")]
[Description("Transition Consistency Data")]
@@ -1380,11 +1273,8 @@ namespace VEPROMS.CSLA.Library
get { return _LibDocConsistency; }
set { _LibDocConsistency = value; }
}
public void AddLibDocCheck(int docid, DateTime docdate)
{
LibDocConsistency.AddLibDocCheck(docid, docdate);
}
}
public void AddLibDocCheck(int docid, DateTime docdate) => LibDocConsistency.AddLibDocCheck(docid, docdate);
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class ROConsistency
@@ -1422,11 +1312,8 @@ namespace VEPROMS.CSLA.Library
if (!_ROCheckList.ContainsKey(roid))
_ROCheckList.Add(roid, new ROCheck(roid, roValue));
}
public override string ToString()
{
return string.Format("{0} ROs", _ROCheckList.Count);
}
}
public override string ToString() => string.Format("{0} ROs", _ROCheckList.Count);
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class ROCheck
@@ -1463,11 +1350,8 @@ namespace VEPROMS.CSLA.Library
public ROCheck()
{
}
public override string ToString()
{
return string.Format("{0} - '{1}'", ROID, ROValue);
}
}
public override string ToString() => string.Format("{0} - '{1}'", ROID, ROValue);
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
@@ -1497,11 +1381,8 @@ namespace VEPROMS.CSLA.Library
if (!_TransitionCheckList.ContainsKey(transitionid))
_TransitionCheckList.Add(transitionid, new TransitionCheck(transitionid, transitionValue));
}
public override string ToString()
{
return string.Format("{0} Transitions", _TransitionCheckList.Count);
}
}
public override string ToString() => string.Format("{0} Transitions", _TransitionCheckList.Count);
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class TransitionCheck
@@ -1538,11 +1419,8 @@ namespace VEPROMS.CSLA.Library
public TransitionCheck()
{
}
public override string ToString()
{
return string.Format("{0} - '{1}'", TransitionID, TransitionValue);
}
}
public override string ToString() => string.Format("{0} - '{1}'", TransitionID, TransitionValue);
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
@@ -1572,11 +1450,8 @@ namespace VEPROMS.CSLA.Library
if (!_LibDocCheckList.ContainsKey(docid))
_LibDocCheckList.Add(docid, new LibDocCheck(docid, docDate));
}
public override string ToString()
{
return string.Format("{0} LibDocs", _LibDocCheckList.Count);
}
}
public override string ToString() => string.Format("{0} LibDocs", _LibDocCheckList.Count);
}
[Serializable]
[TypeConverter(typeof(ExpandableObjectConverter))]
public class LibDocCheck
@@ -1604,16 +1479,10 @@ namespace VEPROMS.CSLA.Library
{
get
{
//if (_OldDocDate == DateTime.MinValue)
// return null;
return _OldDocDate;
}
set
{
//if (value == null)
// _OldDocDate = DateTime.MinValue;
//else
// _OldDocDate = value.Value;
_OldDocDate = value;
}
}
@@ -1625,11 +1494,8 @@ namespace VEPROMS.CSLA.Library
public LibDocCheck()
{
}
public override string ToString()
{
return string.Format("{0} - '{1}'", DocID, DocDate);
}
}
public override string ToString() => string.Format("{0} - '{1}'", DocID, DocDate);
}
public enum Rev_Types : int
{
Revision = 1, TempMod = 2
@@ -9,13 +9,6 @@
// ========================================================================
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;
using Csla;
using Csla.Data;
using System.Data.SqlClient;
@@ -50,14 +43,10 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteriaJustStage
{
private int _StageID;
public int StageID
{ get { return _StageID; } }
public PKCriteriaJustStage(int stageID)
{
_StageID = stageID;
}
}
private readonly int _StageID;
public int StageID => _StageID;
public PKCriteriaJustStage(int stageID) => _StageID = stageID;
}
private void DataPortal_Fetch(PKCriteriaJustStage criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageInfo.DataPortal_Fetch", GetHashCode());
@@ -99,8 +88,6 @@ namespace VEPROMS.CSLA.Library
{
public static Stage GetJustStage(int stageID)
{
if (!CanGetObject())
throw new System.Security.SecurityException("User not authorized to view a Stage");
try
{
Stage tmp = DataPortal.Fetch<Stage>(new PKCriteriaJustStage(stageID));
@@ -138,12 +125,6 @@ namespace VEPROMS.CSLA.Library
return;
}
ReadData(dr);
// Don't load child objects
//dr.NextResult();
//_StageChecks = StageChecks.Get(dr);
// load child objects
//dr.NextResult();
//_StageVersions = StageVersions.Get(dr);
}
}
// removing of item only needed for local data portal
@@ -161,17 +142,9 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class PKCriteriaJustStage
{
private int _StageID;
public int StageID
{ get { return _StageID; } }
public PKCriteriaJustStage(int stageID)
{
_StageID = stageID;
}
}
#region Log4Net
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#endregion
private readonly int _StageID;
public int StageID => _StageID;
public PKCriteriaJustStage(int stageID) => _StageID = stageID;
}
}
}
@@ -25,25 +25,10 @@ namespace VEPROMS.CSLA.Library
get { return _NewTransToUnNumberedItem; }
set { _NewTransToUnNumberedItem = value; }
}
public string PathTo
{
get
{
return MyItemToID.Path;
}
}
public string PathFrom
{
get
{
return MyContent.ContentItems[0].Path;
}
}
public override string ToString()
{
return string.Format("ID: {0} From: {1} To: {2}", TransitionID, FromID, ToID);
}
[NonSerialized]
public string PathTo => MyItemToID.Path;
public string PathFrom => MyContent.ContentItems[0].Path;
public override string ToString() => $"ID: {TransitionID} From: {FromID} To: {ToID}";
[NonSerialized]
private TransitionConfig _TransitionConfig;
public TransitionConfig TransitionConfig
{
@@ -56,27 +41,7 @@ namespace VEPROMS.CSLA.Library
return _TransitionConfig;
}
}
public bool HasPageNum
{
get
{
return TransitionConfig.Transition_Formatted.ToUpper() == "TRUE";
}
}
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, int tranType, ItemInfo toitem, ItemInfo rangeitem, bool hasPageNum)
{
try
{
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, rangeitem, HasPageNum);
}
catch (Exception ex)
{
if (tranType == 2 && ex.Message == "Cannot find Next Item")
return TransitionText.GetResolvedText(fi, itminfo, tranType, toitem, toitem, HasPageNum);
_MyLog.Error("Error Processing Transition Text", ex);
return "(Resolved Transition Text)";
}
}
public bool HasPageNum => TransitionConfig.Transition_Formatted.ToUpper() == "TRUE";
public string ResolvePathTo(FormatInfo fi, ItemInfo itminfo, int tranType, ItemInfo toitem, ItemInfo rangeitem)
{
try
@@ -108,13 +73,6 @@ namespace VEPROMS.CSLA.Library
ItemInfo item = MyContent.ContentItems[0];
ItemInfo myItemToID = MyItemToID;
if (tranLookup.ContainsKey(item.ItemID)) item = tranLookup[item.ItemID];
bool hasPageNum = false;
if (item.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier ||
item.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier)
{
TransitionConfig tc = new TransitionConfig(Config);
if (tc != null && tc.Transition_Formatted.ToUpper() == "TRUE") hasPageNum = true;
}
if (tranLookup.ContainsKey(ToID))
{
myItemToID = tranLookup[ToID];
@@ -150,7 +108,7 @@ namespace VEPROMS.CSLA.Library
//Console.WriteLine("MyItemToID = {0}", MyItemToID);
//Console.WriteLine("MyItemRangeID = {0}", MyItemRangeID);
}
return ResolvePathTo(item.ActiveFormat, item, TranType, myItemToID, myItemRangeID, hasPageNum);
return ResolvePathTo(item.ActiveFormat, item, TranType, myItemToID, myItemRangeID);
}
}
#region AffectedTransitons
@@ -172,17 +130,11 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
protected class TransitionReportDataCriteria
{
private int _VersionID;
public int VersionID
{
get { return _VersionID; }
}
private int _ProcedureID;
public int ProcedureID
{
get { return _ProcedureID; }
}
public TransitionReportDataCriteria(int versionID, int procedureID)
private readonly int _VersionID;
public int VersionID => _VersionID;
private readonly int _ProcedureID;
public int ProcedureID => _ProcedureID;
public TransitionReportDataCriteria(int versionID, int procedureID)
{
_VersionID = versionID;
_ProcedureID = procedureID;
@@ -208,9 +160,11 @@ namespace VEPROMS.CSLA.Library
IsReadOnly = false;
while (dr.Read())
{
TransitionInfo ti = new TransitionInfo(dr);
ti.Level = dr.GetInt32("level");
this.Add(ti);
TransitionInfo ti = new TransitionInfo(dr)
{
Level = dr.GetInt32("level")
};
this.Add(ti);
}
IsReadOnly = true;
}
@@ -228,11 +182,8 @@ namespace VEPROMS.CSLA.Library
[Serializable()]
private class AffectedTransitonsCriteria
{
public AffectedTransitonsCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public AffectedTransitonsCriteria(int itemID) => _ItemID = itemID;
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
@@ -287,24 +238,17 @@ namespace VEPROMS.CSLA.Library
{
StringBuilder sb = new StringBuilder("");
foreach (TransitionInfo trans in this)
sb.Append("\r\n" + trans.PathFrom);
sb.Append($"\r\n{trans.PathFrom}");
return sb.ToString();
}
#endregion
#region ExternalTransitionsToChildren
private class ExternalTransitionsToChildrenCriteria
{
public ExternalTransitionsToChildrenCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
public ExternalTransitionsToChildrenCriteria(int itemID) => ItemID = itemID;
public int ItemID { get; set; }
}
public static TransitionInfoList GetExternalTransitionsToChildren(int itemID)
{
try
@@ -354,17 +298,10 @@ namespace VEPROMS.CSLA.Library
#region ExternalTransitions
private class ExternalTransitionsCriteria
{
public ExternalTransitionsCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
public ExternalTransitionsCriteria(int itemID) => ItemID = itemID;
public int ItemID { get; set; }
}
public static TransitionInfoList GetExternalTransitions(int itemID)
{
try
@@ -413,17 +350,10 @@ namespace VEPROMS.CSLA.Library
#region PastedAffectedTransitions
private class PastedAffectedTransitonsCriteria
{
public PastedAffectedTransitonsCriteria(int itemID)
{
_ItemID = itemID;
}
private int _ItemID;
public int ItemID
{
get { return _ItemID; }
set { _ItemID = value; }
}
}
public PastedAffectedTransitonsCriteria(int itemID) => ItemID = itemID;
public int ItemID { get; set; }
}
internal static TransitionInfoList GetPastedAffected(int itemID)
{
try
@@ -472,17 +402,10 @@ namespace VEPROMS.CSLA.Library
#region TransitionsToDisconnected
private class TransitionsToDisconnectedCriteria
{
public TransitionsToDisconnectedCriteria(string docVersionList)
{
_DocVersionList = docVersionList;
}
private string _DocVersionList;
public string DocVersionList
{
get { return _DocVersionList; }
set { _DocVersionList = value; }
}
}
public TransitionsToDisconnectedCriteria(string docVersionList) => DocVersionList = docVersionList;
public string DocVersionList { get; set; }
}
public static TransitionInfoList GetTransitionsToDisconnected(string docVersionList)
{
try
@@ -531,17 +454,10 @@ namespace VEPROMS.CSLA.Library
#region TransitionsToNonEditable
private class TransitionsToNonEditableCriteria
{
public TransitionsToNonEditableCriteria(string docVersionList)
{
_DocVersionList = docVersionList;
}
private string _DocVersionList;
public string DocVersionList
{
get { return _DocVersionList; }
set { _DocVersionList = value; }
}
}
public TransitionsToNonEditableCriteria(string docVersionList) => DocVersionList = docVersionList;
public string DocVersionList { get; set; }
}
public static TransitionInfoList GetTransitionsToNonEditable(string docVersionList)
{
try
@@ -590,7 +506,7 @@ namespace VEPROMS.CSLA.Library
}
public class TransitionBuilder
{
private StringBuilder _Results = new StringBuilder();
private readonly StringBuilder _Results = new StringBuilder();
public FormatData _FormatData;
public string _TransFormat;
public E_TransUI _TransUI;
@@ -599,53 +515,25 @@ namespace VEPROMS.CSLA.Library
public ItemInfo _ToItem;
public ItemInfo _RangeItem;
public bool _UsedRangeAncestor;
private string _Token;
public string _UnitProcSetString;
public string _UnitProcSetString;
public bool SectNumWithStepNum;
private int _SectionNumberLength = 0;
public int SectionNumberLength
{
get { return _SectionNumberLength; }
set { _SectionNumberLength = value; }
}
private string _StepPrefix = "";
public string StepPrefix
{
get { return _StepPrefix; }
set { _StepPrefix = value; }
}
private List<int> _SectionsUsed = new List<int>();
public List<int> SectionsUsed
{
get { return _SectionsUsed; }
}
public string Token
{
get { return _Token; }
set { _Token = value; }
}
private string _Prefix;
public int SectionNumberLength { get; set; } = 0;
public string StepPrefix { get; set; } = "";
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "Keeping Collections Not ReadOnly")]
private List<int> _SectionsUsed = new List<int>();
public List<int> SectionsUsed => _SectionsUsed;
public string Token { get; set; }
private string _Prefix;
public string Prefix
{
get { return _Prefix; }
set { if(_Prefix==null)_Prefix = value; }
}
public void ResetPrefix(string str)
{
_Prefix = str;
}
public bool HasText
{
get
{
return _Results.Length > 0;
}
}
public StringBuilder Append(string str)
{
return _Results.Append(str);
}
public StringBuilder ReplaceToken(string str)
public void ResetPrefix(string str) => _Prefix = str;
public bool HasText => _Results.Length > 0;
public StringBuilder Append(string str) => _Results.Append(str);
public StringBuilder ReplaceToken(string str)
{
if (str == null || str == "") return _Results;
if (_FormatData.TransData.XchngTranSpForHard && str[0]!=',' && str[0] != ' ')
@@ -662,19 +550,10 @@ namespace VEPROMS.CSLA.Library
else
return _Results.Append(str.TrimEnd(" :".ToCharArray()));
}
public override string ToString()
{
return _Results.ToString();
}
public StringBuilder Remove(int startIndex, int length)
{
return _Results.Remove(startIndex, length);
}
public int Length
{
get { return _Results.Length; }
}
public void AppendPrefix()
public override string ToString() => _Results.ToString();
public StringBuilder Remove(int startIndex, int length) => _Results.Remove(startIndex, length);
public int Length => _Results.Length;
public void AppendPrefix()
{
if (Prefix == null) return; // no Prefix text to add
if (HasText)
@@ -741,47 +620,43 @@ namespace VEPROMS.CSLA.Library
private static Dictionary<string, TransitionAppendFunction> _AppendMethods;
private static void SetupMethods()
{
_AppendMethods = new Dictionary<string, TransitionAppendFunction>();
_AppendMethods.Add("{Proc Num}", AddTransitionProcNum);
_AppendMethods.Add("{?.Proc Num}", AddOptionalTransitionProcNum);
_AppendMethods.Add("{Proc Title}", AddTransitionProcTitle);
_AppendMethods.Add("{?.Proc Title}", AddOptionalTransitionProcTitle);
_AppendMethods.Add("{First Step}", AddStepNumber);
_AppendMethods.Add("{Step Number}", AddStepNumber); // WCN2, tran type 6
_AppendMethods.Add("{Last Step}", AddRangeStepNumber);
_AppendMethods.Add("{.}", AddIncludedStepNumber);
_AppendMethods.Add("{Sect Hdr}", AddTranGetSectionHdr);
_AppendMethods.Add("{?.Sect Hdr}", AddOptionalTranGetSectionHdr);
_AppendMethods.Add("{Sect Title}", AddTranGetSectionTitle);
_AppendMethods.Add("{?.Sect Title}", AddOptionalTranGetSectionTitle);
_AppendMethods.Add("{?.Sect Num}", AddOptionalTranGetSectionNum);
_AppendMethods.Add("{Sect Num}", AddTranGetSectionNumber);
_AppendMethods.Add("{Sect Num All}", AddTranGetAllSectionNumber);
_AppendMethods.Add("{Sect Number}", AddTranGetSectionNumber); // WCN2, tran type 6
_AppendMethods.Add("{Page Num}", AddPageNumber);
_AppendMethods.Add("{Step Text}", AddStepText);
_AppendMethods = new Dictionary<string, TransitionAppendFunction>
{
{ "{Proc Num}", AddTransitionProcNum },
{ "{?.Proc Num}", AddOptionalTransitionProcNum },
{ "{Proc Title}", AddTransitionProcTitle },
{ "{?.Proc Title}", AddOptionalTransitionProcTitle },
{ "{First Step}", AddStepNumber },
{ "{Step Number}", AddStepNumber }, // WCN2, tran type 6
{ "{Last Step}", AddRangeStepNumber },
{ "{.}", AddIncludedStepNumber },
{ "{Sect Hdr}", AddTranGetSectionHdr },
{ "{?.Sect Hdr}", AddOptionalTranGetSectionHdr },
{ "{Sect Title}", AddTranGetSectionTitle },
{ "{?.Sect Title}", AddOptionalTranGetSectionTitle },
{ "{?.Sect Num}", AddOptionalTranGetSectionNum },
{ "{Sect Num}", AddTranGetSectionNumber },
{ "{Sect Num All}", AddTranGetAllSectionNumber },
{ "{Sect Number}", AddTranGetSectionNumber }, // WCN2, tran type 6
{ "{Page Num}", AddPageNumber },
{ "{Step Text}", AddStepText }
};
}
public static string GetResolvedText(ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem, bool hasPageNum)
{
return GetResolvedText(fromInfo.ActiveFormat, fromInfo, tranType, toItem, rangeItem, hasPageNum);
}
private static Regex RegFixVCS = new Regex(@"Section ([0-9.]+)(.0)? Step \1"); // Find Section xxx followed by Step xxx
public static string GetResolvedText(ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem, bool hasPageNum) => GetResolvedText(fromInfo.ActiveFormat, fromInfo, tranType, toItem, rangeItem, hasPageNum);
private static readonly Regex RegFixVCS = new Regex(@"Section ([0-9.]+)(.0)? Step \1"); // Find Section xxx followed by Step xxx
public static string GetResolvedText(FormatInfo formatInfo, ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem, bool pagenum)
{
if (!pagenum)
{
TransitionInfo ct = fromInfo.MyContent.ContentTransitionCount > 0 ? fromInfo.MyContent.ContentTransitions[0] : null;
int trIU = -1;
string cfg = string.Empty;
if (ct != null)
if (ct != null)
{
trIU = fromInfo.MyContent.ContentTransitions[0].MyTransitionInfoUnique;
cfg = fromInfo.MyContent.ContentTransitions[0].Config;
}
_ = fromInfo.MyContent.ContentTransitions[0].MyTransitionInfoUnique;
_ = fromInfo.MyContent.ContentTransitions[0].Config;
}
else
{
string pattern = string.Format(@"<START\]\\v0([^#]*)\\v #Link:Transition(|Range):[0-9]* <CTID=-[0-9]+>( [0-9]*){{1,2}}\[END>");
//string pattern = string.Format(@".*\\v <START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:[0-9]+ <CTID=-[0-9]+>( [0-9]*){{1,2}}\[END>");
string pattern = string.Format(@"<START\]\\v0([^#]*)\\v #Link:Transition(|Range):[0-9]* <CTID=-[0-9]+>( [0-9]*){{1,2}}\[END>");
Match m = Regex.Match(fromInfo.MyContent.Text, pattern);
if (m.Groups.Count > 1 && m.Groups[1].Value.ToUpper().Contains("(PAGE ~)")) // B2020-089, check for upper case Page ~ in case step was upper cased
pagenum = true;
@@ -805,7 +680,7 @@ namespace VEPROMS.CSLA.Library
tb._TransFormat = tb._TransFormat.Insert(tb._TransFormat.IndexOf("{First Step}")+12, " {Page Num}");
}
else
tb._TransFormat = tb._TransFormat + " {Page Num}";
tb._TransFormat += " {Page Num}";
}
}
if(_AppendMethods==null)
@@ -820,18 +695,7 @@ namespace VEPROMS.CSLA.Library
retval = toItem.Ordinal.ToString();
fromInfo.NewTransToUnNumberedItem = true;
//Volian.Base.Library.vlnStackTrace.ShowStackLocal("Setting Flag", 3, 10);
//using (Item itm = fromInfo.Get())
//{
// ItemAnnotation ia = itm.ItemAnnotations.Add(AnnotationType.GetByName("Verifcation Required"));
// ia.SearchText = "Transition to Un-Numbered Step";
//itm.Save();
//}
}
//if (Regex.IsMatch(retval, @".*\[[BP][0-9]{4,4}\].*")
// && tb._ToItem.ActiveFormat != null
// && tb._ToItem.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert )
// retval = Regex.Replace(retval, @" *(\[[BP][0-9]{4,4}\])+","");
//return retval;
if (Regex.IsMatch(retval, @".* *\[([A-Z0-9 ]|\\u160\?)+\] *.*")
&& tb._ToItem.ActiveFormat != null
&& tb._ToItem.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert)
@@ -844,11 +708,13 @@ namespace VEPROMS.CSLA.Library
}
private static TransitionBuilder SetupTransitionBuilder(FormatInfo formatInfo, ItemInfo fromInfo, int tranType, ItemInfo toItem, ItemInfo rangeItem)
{
TransitionBuilder tb = new TransitionBuilder();
tb._FormatData = formatInfo.PlantFormat.FormatData;
// get the format of the transition string based on this transition's index into the TransData part of
// format....
if (tranType >= tb._FormatData.TransData.TransTypeList.MaxIndex) // found during fixing of B2016-176 B2016-197 fixes invalid index error during import of procedure
TransitionBuilder tb = new TransitionBuilder
{
_FormatData = formatInfo.PlantFormat.FormatData
};
// get the format of the transition string based on this transition's index into the TransData part of
// format....
if (tranType >= tb._FormatData.TransData.TransTypeList.MaxIndex) // found during fixing of B2016-176 B2016-197 fixes invalid index error during import of procedure
tranType = 0;
// Replace 3 tokens ", {.}, {.}, {.}" with a single token "{.}"
tb._TransFormat = tb._FormatData.TransData.TransTypeList[tranType].TransFormat.Replace(", {.}, {.}, {.}", "{.}");
@@ -873,9 +739,7 @@ namespace VEPROMS.CSLA.Library
tb._TranType = 4;
}
int startIndex = 0;
int index = -1;
int rexIndex = -1;
string prefix = null;
string prefix = null;
string prevToken = null;
bool lastAdded = false;
MatchCollection mc = Regex.Matches(tb._TransFormat, @"{(Proc Num|\?\.Proc Num|Proc Title|\?\.Proc Title|" +
@@ -885,8 +749,8 @@ namespace VEPROMS.CSLA.Library
{
string tmppref = prefix;
prefix = null;
rexIndex = m.Index;
int rexEndToken = m.Index + m.Length - 1;
int rexIndex = m.Index;
int rexEndToken = m.Index + m.Length - 1;
if (rexIndex > startIndex) prefix = tb._TransFormat.Substring(startIndex, rexIndex - startIndex);
if (prefix == null) prevToken = null;
// if the last token did not add anything to the buffer, still want to put the text prefix in:
@@ -1007,9 +871,8 @@ namespace VEPROMS.CSLA.Library
// as used by AEP is: UnitProcSetString ="{PSI:UNITCOM}-{SI:SETNAME}-{PSI:SETID}-"
string findMatch = "{.*?}";
MatchCollection ms = Regex.Matches(tb._UnitProcSetString,findMatch);
string txt = tb._UnitProcSetString;
FolderConfig fc = tb._ToItem.MyDocVersion.MyFolder.FolderConfig as FolderConfig;
ProcedureConfig pc = new ProcedureConfig(tb._ToItem.MyProcedure.MyContent.Config);
_ = tb._ToItem.MyDocVersion.MyFolder.FolderConfig as FolderConfig;
ProcedureConfig pc = new ProcedureConfig(tb._ToItem.MyProcedure.MyContent.Config);
// Use a dictionary to get all of the tokens from the format string, then
// go through all dictionary entries to make the replacements.
Dictionary<string, string> repStr = new Dictionary<string, string>();
@@ -1094,7 +957,7 @@ namespace VEPROMS.CSLA.Library
{
lretstr.Append(tb._FormatData.TransData.DelimiterForTransitionTitle);
lretstr.Append(tb._FormatData.TransData.CapsTransitions ? parenstr.ToUpper().Replace(@"\U", @"\u") :
tb._FormatData.TransData.Cap1stCharTrans ? CapFirstLetterOnly(parenstr, 0) :
tb._FormatData.TransData.Cap1stCharTrans ? CapFirstLetterOnly(parenstr) :
parenstr);
lretstr.Append(tb._FormatData.TransData.DelimiterForTransitionTitle);
}
@@ -1170,7 +1033,7 @@ namespace VEPROMS.CSLA.Library
if (thisTab != null && thisTab != "")
{
thisTab = thisTab.Trim(" ".ToCharArray());
if (hasDelim && !thisTab.EndsWith(".") && !thisTab.EndsWith(")")) thisTab = thisTab + ".";
if (hasDelim && !thisTab.EndsWith(".") && !thisTab.EndsWith(")")) thisTab += ".";
if (hasDotZero && thisTab.EndsWith(".0.")) thisTab = thisTab.Substring(0, thisTab.Length - 2);
}
// RHM 20130326 2039 - I added the logic to limit the addition of the section tab to
@@ -1197,7 +1060,7 @@ namespace VEPROMS.CSLA.Library
if (!hasDelim)
foreach (string rmvDelim in DelimList) hlsTab = hlsTab.Replace(rmvDelim, "");
hlsTab = hlsTab.Trim(" ".ToCharArray());
if (hasDelim && !hlsTab.EndsWith(".") && !hlsTab.EndsWith(")")) hlsTab = hlsTab + ".";
if (hasDelim && !hlsTab.EndsWith(".") && !hlsTab.EndsWith(")")) hlsTab += ".";
if (hasDotZero)
{
if (item.IsHigh)
@@ -1218,9 +1081,6 @@ namespace VEPROMS.CSLA.Library
}
private static bool AddPageNumber(TransitionBuilder tb)
{
//At some point, add a property off a section 'IsFoldout' and use the next two lines:
//if ((myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts && mySection.MyContent.Number.ToUpper() == "FOLDOUT")
//|| (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && mySection.MyContent.Text.ToUpper().Contains("FOLDOUT")))
if (tb._ToItem.PageNumber != -1 && (tb._FromItem.PageNumber != -1 || (tb._FromItem.ActiveSection.MyConfig as SectionConfig).Section_IsFoldout == "Y")) //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box
{
int pgoffset = tb._ToItem.PageNumber - tb._FromItem.PageNumber;
@@ -1255,9 +1115,11 @@ namespace VEPROMS.CSLA.Library
}
private static bool AddStepNumber(TransitionBuilder tb)
{
// If we're on a step put out the step number.
ItemInfo secitm = TranGetSectionItem(tb._ToItem);
if ((!((tb._TransUI & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone)) || tb._ToItem.MyContent.Type > 20000)
// If we're on a step put out the step number.
#pragma warning disable IDE0059 // Unnecessary assignment of a value - Kept for Debugging
ItemInfo secitm = TranGetSectionItem(tb._ToItem);
#pragma warning restore IDE0059 // Unnecessary assignment of a value
if ((!((tb._TransUI & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone)) || tb._ToItem.MyContent.Type > 20000)
{
if (tb._FormatData.PrintData.SpecialCaseCalvertAlarm && tb._ToItem.IsHigh && tb._ToItem.FormatStepData.StepEditData.TypeMenu.MenuItem.ToUpper().Contains("WINDOW"))
{
@@ -1281,7 +1143,6 @@ namespace VEPROMS.CSLA.Library
tb.Remove(tb.Length - 7, 7); // 7 is length of ", Step "
tb.AppendPrefix();
}
//else if (tb._TranType == 4 && tb._ToItem.MoreThanOneStepSection())
else if (tb._TranType == 4 && tb._ToItem.MoreThanOneStepSection() || tb._TranType == 5)
{
tb.AppendPrefix();
@@ -1333,14 +1194,14 @@ namespace VEPROMS.CSLA.Library
bool usedRangeAncestor = false;
// Refresh Next Items
tb._ToItem.RefreshNextItems();
ItemInfo next = GetNextItem(tb._ToItem, rangeAncestors, ref usedRangeAncestor);
ItemInfo next = GetNextItem(tb._ToItem, rangeAncestors);
string lastTab = Tab(tb._RangeItem, tb._RangeItem.ActiveFormat.PlantFormat.FormatData.TransData.TStepNoFlag);
while (next.ItemID != tb._RangeItem.ItemID)
{
string thisTab = Tab(next, tb._RangeItem.ActiveFormat.PlantFormat.FormatData.TransData.TStepNoFlag);
if (lastTab == thisTab) break;
tb.ReplaceToken(", " + thisTab);
next = GetNextItem(next, rangeAncestors, ref usedRangeAncestor);
next = GetNextItem(next, rangeAncestors);
}
tb._UsedRangeAncestor = usedRangeAncestor;
return true;
@@ -1363,7 +1224,7 @@ namespace VEPROMS.CSLA.Library
}
return retval;
}
private static ItemInfo GetNextItem(ItemInfo next, Dictionary<int, ItemInfo> rangeAncestors, ref bool usedRangeAncestor)
private static ItemInfo GetNextItem(ItemInfo next, Dictionary<int, ItemInfo> rangeAncestors)
{
if (rangeAncestors.ContainsKey(next.ItemID))
return rangeAncestors[next.ItemID];
@@ -1473,15 +1334,9 @@ namespace VEPROMS.CSLA.Library
}
return false;
}
private static bool AddTranGetSectionNumber(TransitionBuilder tb)
{
return AddTranGetSectionNumber(tb, false);
}
private static bool AddTranGetAllSectionNumber(TransitionBuilder tb)
{
return AddTranGetSectionNumber(tb, true);
}
private static bool AddTranGetSectionNumber(TransitionBuilder tb, bool allLevels)
private static bool AddTranGetSectionNumber(TransitionBuilder tb) => AddTranGetSectionNumber(tb, false);
private static bool AddTranGetAllSectionNumber(TransitionBuilder tb) => AddTranGetSectionNumber(tb, true);
private static bool AddTranGetSectionNumber(TransitionBuilder tb, bool allLevels)
{
if (tb._TranType == 1 && tb._ToItem.ActiveSection.ItemID == tb._FromItem.ActiveSection.ItemID) return false;
if (tb.SectNumWithStepNum) return false;
@@ -1514,13 +1369,9 @@ namespace VEPROMS.CSLA.Library
tb.ReplaceToken(retstr);
return (retstr != null && retstr != "");
}
//B2016-003 Transitions to sections whose number has a leading space was causing errors in transition text
private static string TrimSectNumber(string str)
{
if (str == null) return str;
return str.TrimStart();
}
private static string FixTitleCase(Match m)
//B2016-003 Transitions to sections whose number has a leading space was causing errors in transition text
private static string TrimSectNumber(string str) => str == null ? str : str.TrimStart();
private static string FixTitleCase(Match m)
{
if (Regex.IsMatch(m.Value, @"^[A-Za-z]+\.?$"))
{
@@ -1533,12 +1384,11 @@ namespace VEPROMS.CSLA.Library
}
return m.Value;
}
private static string CapFirstLetterOnly(string retstr, int p)
private static string CapFirstLetterOnly(string retstr)
{
// LATER: write code to capitalize first letter (active plants)
// F2021-037: Support title case include '/' as separator (added '/' to regex replace)
string lretstr = Regex.Replace(retstr, @"([^ ,/]+)", new MatchEvaluator(FixTitleCase));
return lretstr;
// LATER: write code to capitalize first letter (active plants)
// F2021-037: Support title case include '/' as separator (added '/' to regex replace)
return Regex.Replace(retstr, @"([^ ,/]+)", new MatchEvaluator(FixTitleCase));
}
// TODO: Section methods are not complete....
private static ItemInfo TranGetSectionItem(ItemInfo itminfo)
@@ -1564,7 +1414,7 @@ namespace VEPROMS.CSLA.Library
string str1 = TranGetSectionNumber(tb._ToItem);
// F2024-008 added flag to title case the section number in transitions
if (tb._FormatData.TransData.Cap1stCharTransSectionNumber)
str1 = CapFirstLetterOnly(str1, 0);
str1 = CapFirstLetterOnly(str1);
if(!tb._ToItem.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert) return str1;
List<ItemInfo> FromSections = GetSections(tb._FromItem.ActiveSection);
List<ItemInfo> ToSections = GetSections(tb._ToItem.ActiveSection);
@@ -1578,11 +1428,9 @@ namespace VEPROMS.CSLA.Library
break;
}
}
//string str = tmpitm.MyContent.Number;
string str = BuildSectionPath(ToSections);
// B2024-025 - process all of the applicability token (<U-xxx>, <U>, <ID>)
str = VEPROMS.CSLA.Library.DisplayText.ResolveUnitSpecific(tb._ToItem.MyDocVersion, str);
//if (!str.EndsWith(".") && tb._ToItem.ItemID != tb._ToItem.ActiveSection.ItemID)
tb.StepPrefix = ".";
tb.SectionNumberLength = str.Length;
return (str);
@@ -1611,11 +1459,8 @@ namespace VEPROMS.CSLA.Library
sb.Append(sep + lastPart.TrimEnd(" ".ToCharArray()));
return sb.ToString();
}
private static bool IsRoman(string number)
{
return Regex.IsMatch(number,@"[IVXLCDM]+\.?");
}
private static List<ItemInfo> GetSections(ItemInfo myItemInfo)
private static bool IsRoman(string number) => Regex.IsMatch(number, @"[IVXLCDM]+\.?");
private static List<ItemInfo> GetSections(ItemInfo myItemInfo)
{
List<ItemInfo> retval = new List<ItemInfo>();
while (myItemInfo != null && myItemInfo.IsSection)
@@ -1633,7 +1478,7 @@ namespace VEPROMS.CSLA.Library
ItemInfo tmpitm = TranGetSectionItem(itminfo);
string sectionTitle = tmpitm.MyContent.Text;
sectionTitle = (tb._FormatData.TransData.CapsTransitionsSection ? sectionTitle.ToUpper().Replace(@"\U", @"\u") :
tb._FormatData.TransData.Cap1stCharTransSection ? CapFirstLetterOnly(sectionTitle, 0) :
tb._FormatData.TransData.Cap1stCharTransSection ? CapFirstLetterOnly(sectionTitle) :
sectionTitle);
// F2024-008 Added flag to surround the section title with parenthesis in transitions
if (tb._FormatData.TransData.ParensAroundSectionTitle)
@@ -1658,7 +1503,7 @@ namespace VEPROMS.CSLA.Library
ItemInfo tmpitm = TranGetSectionItem(itminfo);
string sectionTitle = tmpitm.MyContent.Text;
sectionTitle = (tb._FormatData.TransData.CapsTransitionsSection ? sectionTitle.ToUpper().Replace(@"\U", @"\u") :
tb._FormatData.TransData.Cap1stCharTransSection ? CapFirstLetterOnly(sectionTitle, 0) :
tb._FormatData.TransData.Cap1stCharTransSection ? CapFirstLetterOnly(sectionTitle) :
sectionTitle);
// B2017-236 Replace embedded returns with spaces and trim the spaces from the end of the section title.
return TrimSectionTitle(sectionTitle);