C2025-022-Remove-UCF-2

This commit is contained in:
2025-08-27 12:59:53 -04:00
parent 47a4c62e92
commit 525173bc9f
30 changed files with 1159 additions and 1603 deletions

View File

@@ -1755,165 +1755,88 @@ namespace VEPROMS.CSLA.Library
#endregion
#region UCF Fix FormatId After Import
private class FixFormatIDAfterImportCriteria
{
private string _DocVersionList;
public string DocVersionList
{
get { return _DocVersionList; }
set { _DocVersionList = value; }
}
private int _OldFormatID;
public int OldFormatID
{
get { return _OldFormatID; }
set { _OldFormatID = value; }
}
private int _NewFormatID;
public int NewFormatID
{
get { return _NewFormatID; }
set { _NewFormatID = value; }
}
public FixFormatIDAfterImportCriteria(string dvlst, int oldfid, int newfid)
{
_DocVersionList = dvlst;
_OldFormatID = oldfid;
_NewFormatID = newfid;
}
}
private void DataPortal_Fetch(FixFormatIDAfterImportCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_UpdateVersionFormatForUCF";
cm.Parameters.AddWithValue("@VersionList", criteria.DocVersionList);
cm.Parameters.AddWithValue("@OldFormatID", criteria.OldFormatID);
cm.Parameters.AddWithValue("@NewFormatID", criteria.NewFormatID);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("FixFormatIDAfterImport.DataPortal_Fetch", ex);
throw new DbCslaException("FixFormatIDAfterImport.DataPortal_Fetch", ex);
}
}
//#region UCF Clear Overwridden Formats
//private class ClearOverrideFormatsByFolderCriteria
//{
// public ClearOverrideFormatsByFolderCriteria(int folderID, int? formatID, int? newformatID)
// {
// _FormatID = formatID;
// _FolderID = folderID;
// _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 int _FolderID;
// public int FolderID
// {
// get { return _FolderID; }
// set { _FolderID = value; }
// }
//}
public static ContentInfoList FixFormatIDAfterImport(string dvlst, int oldfid, int newfid)
{
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new FixFormatIDAfterImportCriteria(dvlst, oldfid, newfid));
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentInfoList.FixFormatIDAfterImport", ex);
}
}
//private void DataPortal_Fetch(ClearOverrideFormatsByFolderCriteria criteria)
//{
// try
// {
// using (SqlConnection cn = Database.VEPROMS_SqlConnection)
// {
// using (SqlCommand cm = cn.CreateCommand())
// {
// cm.CommandType = CommandType.StoredProcedure;
// cm.CommandText = "vesp_ClearOverrideFormatsByFolder";
// cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
// if (criteria.FormatID == null)
// cm.Parameters.AddWithValue("@FormatID", DBNull.Value);
// else
// cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
// if (criteria.NewFormatID == null)
// cm.Parameters.AddWithValue("@NewFormatID", DBNull.Value);
// else
// cm.Parameters.AddWithValue("@NewFormatID", criteria.NewFormatID);
// cm.CommandTimeout = Database.DefaultTimeout;
// using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
// {
// IsReadOnly = false;
// while (dr.Read())
// {
// ContentInfo contentInfo = new ContentInfo(dr);
// this.Add(contentInfo);
// }
// IsReadOnly = true;
// }
// }
// }
// }
// catch (Exception ex)
// {
// Database.LogException("ClearOverrideFormatsByFolderCriteria.DataPortal_Fetch", ex);
// throw new DbCslaException("ClearOverrideFormatsByFolderCriteria.DataPortal_Fetch", ex);
// }
//}
#endregion
#region UCF Clear Overwridden Formats
private class ClearOverrideFormatsByFolderCriteria
{
public ClearOverrideFormatsByFolderCriteria(int folderID, int? formatID, int? newformatID)
{
_FormatID = formatID;
_FolderID = folderID;
_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 int _FolderID;
public int FolderID
{
get { return _FolderID; }
set { _FolderID = value; }
}
}
private void DataPortal_Fetch(ClearOverrideFormatsByFolderCriteria criteria)
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "vesp_ClearOverrideFormatsByFolder";
cm.Parameters.AddWithValue("@FolderID", criteria.FolderID);
if (criteria.FormatID == null)
cm.Parameters.AddWithValue("@FormatID", DBNull.Value);
else
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
if (criteria.NewFormatID == null)
cm.Parameters.AddWithValue("@NewFormatID", DBNull.Value);
else
cm.Parameters.AddWithValue("@NewFormatID", criteria.NewFormatID);
cm.CommandTimeout = Database.DefaultTimeout;
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ContentInfo contentInfo = new ContentInfo(dr);
this.Add(contentInfo);
}
IsReadOnly = true;
}
}
}
}
catch (Exception ex)
{
Database.LogException("ClearOverrideFormatsByFolderCriteria.DataPortal_Fetch", ex);
throw new DbCslaException("ClearOverrideFormatsByFolderCriteria.DataPortal_Fetch", ex);
}
}
public static ContentInfoList ClearOverrideFormatsByFolder(int folderID, int? formatID, int? newformatID)
{
try
{
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ClearOverrideFormatsByFolderCriteria(folderID, formatID, newformatID));
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on ContentInfoList.ClearOverrideFormatsByFolder", ex);
}
}
//public static ContentInfoList ClearOverrideFormatsByFolder(int folderID, int? formatID, int? newformatID)
//{
// try
// {
// ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ClearOverrideFormatsByFolderCriteria(folderID, formatID, newformatID));
// return tmp;
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on ContentInfoList.ClearOverrideFormatsByFolder", ex);
// }
//}
private class ClearOverrideFormatsByDocVersionCriteria
{
@@ -2077,7 +2000,6 @@ namespace VEPROMS.CSLA.Library
}
}
#endregion
#region Enhanced

View File

@@ -2195,12 +2195,12 @@ namespace VEPROMS.CSLA.Library
//int profileDepth = ProfileTimer.Push(">>>> DoReplaceWords2.ForLoop");
foreach (FormatConfig.ReplaceStr rs in rsl)
{
bool dopartial = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.Partials) == E_ReplaceFlags.Partials;
bool dopartial = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.Partials;
if (!dopartial) // F2021-093: Partials moved into their own method and done first
{
bool onlyDoList = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.FirstWord) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.PageList) == E_ReplaceFlags.PageList; // B2021-132
bool onlyDoList = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.PageList; // B2021-132
//B2021-132 only do replacewords in paglist if the replaceword pagelist flag is set
if (_DoReplWordInPageList && !doInPagelist) continue;
@@ -2228,7 +2228,7 @@ namespace VEPROMS.CSLA.Library
{
if (!dicReplaceRegex.ContainsKey(rs))
{
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
//int profileDepth3 = ProfileTimer.Push(">>>> DoReplaceWords2.BuildMatch");
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace with the ReplaceWith string as is
//RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase & RegexOptions.Singleline : RegexOptions.None & RegexOptions.Singleline;
@@ -2274,12 +2274,12 @@ namespace VEPROMS.CSLA.Library
Dictionary<E_ReplaceFlags?, bool> shouldReplace = new Dictionary<E_ReplaceFlags?, bool>();
foreach (FormatConfig.ReplaceStr rs in rsl)
{
bool dopartial = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.Partials) == E_ReplaceFlags.Partials;
bool dopartial = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.Partials;
if (dopartial)
{
bool onlyDoList = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.FirstWord) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.PageList) == E_ReplaceFlags.PageList; // B2021-132
bool onlyDoList = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.BeforeList; // C2021-045
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.FirstWord; // C2021-056
bool doInPagelist = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.PageList; // B2021-132
//B2021-132 only do replacewords in paglist if the replaceword pagelist flag is set
if (_DoReplWordInPageList && !doInPagelist) continue;
@@ -2304,7 +2304,7 @@ namespace VEPROMS.CSLA.Library
{
if (!dicReplaceRegex.ContainsKey(rs))
{
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
dicReplaceRegex.Add(rs, new Regex(rs.ReplaceWord, myOptions));
}
try
@@ -2563,12 +2563,12 @@ namespace VEPROMS.CSLA.Library
{
// B2022-015 BNPPalr: Determine whether RO text should have Replace Words applied. InLinkAndNotInRoFlag checks
// for flag on replace word item & checks that it is within and RO link
bool InLinkAndNotInRoFlag = ((foundMatch.MyWord.Flag & FormatConfig.E_ReplaceFlagsUCF.NotInRO) != 0) ? VerifyWithinLink(text, foundMatch, offset) : false;
bool InLinkAndNotInRoFlag = ((foundMatch.MyWord.Flag) != 0) ? VerifyWithinLink(text, foundMatch, offset) : false;
if (!InLinkAndNotInRoFlag && VerifyNoHardSpace(text, foundMatch, offset) && VerifyNoLink(text, foundMatch, offset))
{
//if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
//{
if (((foundMatch.MyWord.Flag & FormatConfig.E_ReplaceFlagsUCF.DiffUnit) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord, _MyItemInfo, "UNIT "))
if (((foundMatch.MyWord.Flag) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord, _MyItemInfo, "UNIT "))
{
string with = foundMatch.MyWord.ReplaceWith;
if (offset == 0 && with.StartsWith(@"{\par}"))

View File

@@ -596,68 +596,68 @@ public partial class FormatInfo : IFormatOrFormatInfo
}
// Get format data, but do not resolve the 'Data' and 'Genmac' fields, i.e. keep empty if they are
// empty.
public static FormatInfo GetFormatNoUCFByFormatID(int formatID)
{
try
{
FormatInfo tmp = DataPortal.Fetch<FormatInfo>(new FormatIDNoUCFCriteria(formatID));
if (tmp.ErrorMessage == "No Record Found")
{
tmp.Dispose(); // Clean-up FormatInfo
tmp = null;
}
return tmp;
}
catch (Exception ex)
{
throw new DbCslaException("Error on FormatInfo.GetFormatNoUCFByFormatID", ex);
}
}
protected class FormatIDNoUCFCriteria
{
private int _FormatID;
public int FormatID { get { return _FormatID; } }
public FormatIDNoUCFCriteria(int formatID)
{
_FormatID = formatID;
}
}
private void DataPortal_Fetch(FormatIDNoUCFCriteria criteria)
{
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.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 = "getFormatNoUCF";
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
cm.CommandTimeout = Database.DefaultTimeout;
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("FormatInfo.DataPortal_Fetch", ex);
_ErrorMessage = ex.Message;
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
}
}
//public static FormatInfo GetFormatNoUCFByFormatID(int formatID)
//{
// try
// {
// FormatInfo tmp = DataPortal.Fetch<FormatInfo>(new FormatIDNoUCFCriteria(formatID));
// if (tmp.ErrorMessage == "No Record Found")
// {
// tmp.Dispose(); // Clean-up FormatInfo
// tmp = null;
// }
// return tmp;
// }
// catch (Exception ex)
// {
// throw new DbCslaException("Error on FormatInfo.GetFormatNoUCFByFormatID", ex);
// }
//}
//protected class FormatIDNoUCFCriteria
//{
// private int _FormatID;
// public int FormatID { get { return _FormatID; } }
// public FormatIDNoUCFCriteria(int formatID)
// {
// _FormatID = formatID;
// }
//}
//private void DataPortal_Fetch(FormatIDNoUCFCriteria criteria)
//{
// if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] FormatInfo.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 = "getFormatNoUCF";
// cm.Parameters.AddWithValue("@FormatID", criteria.FormatID);
// cm.CommandTimeout = Database.DefaultTimeout;
// 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("FormatInfo.DataPortal_Fetch", ex);
// _ErrorMessage = ex.Message;
// throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
// }
//}
#region PlantFormat
[NonSerialized]
private PlantFormat _PlantFormat;

View File

@@ -6067,7 +6067,7 @@ namespace VEPROMS.CSLA.Library
// To determine if the section has a checkoff...
// Section won't have checkoffs if there is no checkofflist, or
ProcData pd = ActiveFormat.PlantFormat.FormatData.ProcData;
int maxindx = pd.CheckOffUCF ? pd.CheckOffData.CheckOffList.MaxIndex : pd.CheckOffData.CheckOffList.MaxIndexNoInherit;
int maxindx = pd.CheckOffData.CheckOffList.MaxIndexNoInherit;
if (pd.CheckOffData == null || pd.CheckOffData.CheckOffList == null || maxindx <= 0) return false;
if (pd.CheckOffData.CheckOffHeaderList == null || pd.CheckOffData.CheckOffHeaderList.MaxIndex <= 1) return true;
//if (pd.CheckOffData == null || pd.CheckOffData.CheckOffHeaderList == null || pd.CheckOffData.CheckOffHeaderList.Count <= 1) return false;
@@ -6099,7 +6099,7 @@ namespace VEPROMS.CSLA.Library
private int SectionDefaultCheckOffIndex()
{
ProcData pd = ActiveFormat.PlantFormat.FormatData.ProcData;
int maxindx = pd.CheckOffUCF ? pd.CheckOffData.CheckOffList.MaxIndex : pd.CheckOffData.CheckOffList.MaxIndexNoInherit;
int maxindx = pd.CheckOffData.CheckOffList.MaxIndexNoInherit;
if (pd.CheckOffData != null && pd.CheckOffData.CheckOffList != null && maxindx == 2) return 0; // if only two items, first is macro - use it.
SectionConfig sc = ActiveSection.MyConfig as SectionConfig;
return sc.Section_CheckoffListSelection;
@@ -6111,23 +6111,23 @@ namespace VEPROMS.CSLA.Library
if (!SectionHasCheckOffs()) return null;
int stpCoIndx = CheckOffIndex(); // this step has a checkoff defined
if (stpCoIndx == -1) return null;
if (stpCoIndx > 1)
{
if (ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffUCF && stpCoIndx >= 100)
{
// get index, if greater than 100, store that - otherwise store index down list.
// if this format does not have ucf signoffs, indx is just the selected index from the combo box.
foreach (CheckOff co in ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList)
{
if (stpCoIndx == co.Index)
{
stpCoIndx = (int)co.Index;
break;
}
}
}
return ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList[stpCoIndx]; // DO override of CheckOffList[] to get ucf
}
//if (stpCoIndx > 1)
//{
// if (ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffUCF && stpCoIndx >= 100)
// {
// // get index, if greater than 100, store that - otherwise store index down list.
// // if this format does not have ucf signoffs, indx is just the selected index from the combo box.
// foreach (CheckOff co in ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList)
// {
// if (stpCoIndx == co.Index)
// {
// stpCoIndx = (int)co.Index;
// break;
// }
// }
// }
// return ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList[stpCoIndx]; // DO override of CheckOffList[] to get ucf
//}
int sectCoIndx = SectionDefaultCheckOffIndex(); // no checkoff on step, see if there is a section default.
if (sectCoIndx == -1) return null;
if ((ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffOnHLSOnly && IsHigh)
@@ -6161,7 +6161,7 @@ namespace VEPROMS.CSLA.Library
get
{
ProcData pd = ActiveFormat.PlantFormat.FormatData.ProcData;
int maxindx = pd.CheckOffUCF ? pd.CheckOffData.CheckOffList.MaxIndex : pd.CheckOffData.CheckOffList.MaxIndexNoInherit;
int maxindx = pd.CheckOffData.CheckOffList.MaxIndexNoInherit;
if (pd.CheckOffData != null && pd.CheckOffData.CheckOffList != null && maxindx == 2 && pd.CheckOffData.CheckOffList[0].MenuItem == "Enabled")
return true; // if only two items, first is macro - use it.
return false;