C2018-039: Upgrade – User Control of Format
This commit is contained in:
@@ -1357,9 +1357,322 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Enhanced
|
||||
#region Enhanced_UnlinkItems
|
||||
[Serializable()]
|
||||
#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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
#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);
|
||||
}
|
||||
}
|
||||
private class ClearOverrideFormatsByDocVersionCriteria
|
||||
{
|
||||
public ClearOverrideFormatsByDocVersionCriteria(string dvlist, int? formatID, int?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; }
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(ClearOverrideFormatsByDocVersionCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "vesp_ClearOverrideFormatsByDocVersion";
|
||||
cm.Parameters.AddWithValue("@DocVersionList", criteria.DVList);
|
||||
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("ClearOverrideFormatsByDocVersion.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("ClearOverrideFormatsByDocVersion.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
public static ContentInfoList ClearOverrideFormatsByDocVersion(string dvlist, int? formatID, int? newformatID)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ClearOverrideFormatsByDocVersionCriteria(dvlist, formatID, newformatID));
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ContentInfoList.ClearOverrideFormatsByDocVersion", ex);
|
||||
}
|
||||
}
|
||||
private class ClearOverrideFormatsByItemCriteria
|
||||
{
|
||||
public ClearOverrideFormatsByItemCriteria(int itemID, int? formatID, int? newformatID)
|
||||
{
|
||||
_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; }
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(ClearOverrideFormatsByItemCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "vesp_ClearOverrideFormatsByItem";
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
|
||||
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("ClearOverrideFormatsByItem.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("ClearOverrideFormatsByItem.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
public static ContentInfoList ClearOverrideFormatsByItem(int itemID, int? formatID, int? newformatID)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ClearOverrideFormatsByItemCriteria(itemID, formatID, newformatID));
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ContentInfoList.ClearOverrideFormatsByItem", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#region Enhanced
|
||||
#region Enhanced_UnlinkItems
|
||||
[Serializable()]
|
||||
private class EnhancedUnlinkCriteria
|
||||
{
|
||||
public EnhancedUnlinkCriteria(int? enhancedID)
|
||||
|
@@ -1936,7 +1936,7 @@ namespace VEPROMS.CSLA.Library
|
||||
// return Text;
|
||||
//}
|
||||
#endregion
|
||||
private static Dictionary<ReplaceStr, Regex> dicReplaceRegex = new Dictionary<ReplaceStr, Regex>();
|
||||
private static Dictionary<FormatConfig.ReplaceStr, Regex> dicReplaceRegex = new Dictionary<FormatConfig.ReplaceStr, Regex>();
|
||||
private static bool? _ProcessReplaceWords;
|
||||
public static bool ProcessReplaceWords
|
||||
{
|
||||
@@ -1961,33 +1961,33 @@ namespace VEPROMS.CSLA.Library
|
||||
if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
|
||||
FoundMatches myMatches = new FoundMatches(Text,_MyItemInfo.FormatStepData.Font,_MyItemInfo);
|
||||
// Exclude Link Text from Replace Word process
|
||||
myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion);
|
||||
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
|
||||
|
||||
myMatches.AddLink(regFindLink, _MyFormat.PlantFormat.FormatData.SectData.ReplaceWordsInROs, _MyItemInfo.MyProcedure.MyDocVersion);
|
||||
FormatConfig.ReplaceStrData rsl = _MyFormat.PlantFormat.UCFandOrigReplaceStrData;
|
||||
|
||||
// ReplaceStrData xml node is empty, it does the inheritance and gets the 'base' format's list.
|
||||
if (rsl.Count==1 && (rsl[0].ReplaceWord == null || rsl[0].ReplaceWord == "")) return Text;
|
||||
// Loop through text looking for words to be replaced
|
||||
Dictionary<ReplaceStr, Regex> partialReplaceList = new Dictionary<ReplaceStr, Regex>();
|
||||
Dictionary<FormatConfig.ReplaceStr, Regex> partialReplaceList = new Dictionary<FormatConfig.ReplaceStr, Regex>();
|
||||
Dictionary<E_ReplaceFlags?, bool> shouldReplace = new Dictionary<E_ReplaceFlags?, bool>();
|
||||
//int profileDepth = ProfileTimer.Push(">>>> DoReplaceWords2.ForLoop");
|
||||
foreach (ReplaceStr rs in rsl)
|
||||
foreach (FormatConfig.ReplaceStr rs in rsl)
|
||||
{
|
||||
bool dopartial = (rs.Flag & E_ReplaceFlags.Partials) == E_ReplaceFlags.Partials;
|
||||
bool dopartial = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.Partials) == E_ReplaceFlags.Partials;
|
||||
// note that the order of this check is important. Check in this order...
|
||||
// background here
|
||||
if (!shouldReplace.ContainsKey(rs.Flag))
|
||||
if (!shouldReplace.ContainsKey((E_ReplaceFlags)rs.Flag))
|
||||
{
|
||||
//int profileDepth2 = ProfileTimer.Push(">>>> Before ShouldReplaceIt");
|
||||
shouldReplace.Add(rs.Flag, ShouldReplaceIt(rs.Flag));
|
||||
shouldReplace.Add((E_ReplaceFlags)rs.Flag, ShouldReplaceIt((E_ReplaceFlags)rs.Flag));
|
||||
//ProfileTimer.Pop(profileDepth2);
|
||||
}
|
||||
bool replaceit = shouldReplace[rs.Flag];
|
||||
bool replaceit = shouldReplace[(E_ReplaceFlags)rs.Flag];
|
||||
|
||||
if (replaceit)
|
||||
{
|
||||
if (!dicReplaceRegex.ContainsKey(rs))
|
||||
{
|
||||
RegexOptions myOptions = (rs.Flag & E_ReplaceFlags.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
|
||||
RegexOptions myOptions = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.CaseInsens) == E_ReplaceFlags.CaseInsens ? RegexOptions.IgnoreCase : RegexOptions.None;
|
||||
if (dopartial)
|
||||
{
|
||||
dicReplaceRegex.Add(rs, new Regex(rs.ReplaceWord, myOptions));
|
||||
@@ -2028,8 +2028,8 @@ namespace VEPROMS.CSLA.Library
|
||||
Text = Text.Replace(@"\xA0", @"\u160?"); //replace hard space
|
||||
try
|
||||
{
|
||||
foreach (ReplaceStr prs in partialReplaceList.Keys)
|
||||
Text = partialReplaceList[prs].Replace(Text, prs.ReplaceWith);
|
||||
foreach (FormatConfig.ReplaceStr prs in partialReplaceList.Keys)
|
||||
Text = partialReplaceList[prs].Replace(Text, prs.ReplaceWith);
|
||||
}
|
||||
catch (Exception ex) // Don't crash on a format issue.
|
||||
{
|
||||
@@ -2184,7 +2184,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_Font = font;
|
||||
_MyItemInfo = myItemInfo;
|
||||
}
|
||||
public void Add(Regex myRegEx, ReplaceStr myWord)
|
||||
public void Add(Regex myRegEx, FormatConfig.ReplaceStr myWord)
|
||||
{
|
||||
MatchCollection myMatches = myRegEx.Matches(_Text);
|
||||
foreach (Match myMatch in myMatches)
|
||||
@@ -2227,7 +2227,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void Add(Match myMatch, ReplaceStr myWord)
|
||||
public void Add(Match myMatch, FormatConfig.ReplaceStr myWord)
|
||||
{
|
||||
// If one already exists for this location, then don't add another.
|
||||
if (ContainsKey(myMatch.Index)) return;
|
||||
@@ -2262,9 +2262,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
//if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}"))
|
||||
//{
|
||||
if (((foundMatch.MyWord.Flag & E_ReplaceFlags.DiffUnit) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord,_MyItemInfo,"UNIT "))
|
||||
if (((foundMatch.MyWord.Flag & FormatConfig.E_ReplaceFlagsUCF.DiffUnit) == 0) || DiffUnit(foundMatch.MyWord.ReplaceWord,_MyItemInfo,"UNIT "))
|
||||
{
|
||||
string with = foundMatch.MyWord.ReplaceWith;
|
||||
string with = foundMatch.MyWord.ReplaceWith;
|
||||
if (offset == 0 && with.StartsWith(@"{\par}"))
|
||||
if(StartsWith(text,foundMatch.MyMatch.Index,"",@"\ul ",@"\b ",@"* ",@"* \ul ",@"* \b ",@"*",@"*\ul ",@"*\b "))
|
||||
with = with.Replace(@"{\par}", "");
|
||||
@@ -2365,13 +2365,13 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return _MyMatch; }
|
||||
set { _MyMatch = value; }
|
||||
}
|
||||
private ReplaceStr _MyWord;
|
||||
public ReplaceStr MyWord
|
||||
private FormatConfig.ReplaceStr _MyWord;
|
||||
public FormatConfig.ReplaceStr MyWord
|
||||
{
|
||||
get { return _MyWord; }
|
||||
set { _MyWord = value; }
|
||||
}
|
||||
public FoundMatch(Match myMatch, ReplaceStr myWord)
|
||||
public FoundMatch(Match myMatch, FormatConfig.ReplaceStr myWord)
|
||||
{
|
||||
_MyMatch = myMatch;
|
||||
_MyWord = myWord;
|
||||
|
@@ -140,7 +140,7 @@ namespace VEPROMS.CSLA.Library
|
||||
[NonSerialized]
|
||||
private PlantFormat _PlantFormat;
|
||||
public PlantFormat PlantFormat
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this)); } }
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this, Config)); } }
|
||||
#endregion
|
||||
public static event FormatEvent FormatLoaded;
|
||||
private static void OnFormatLoaded(object sender, FormatEventArgs args)
|
||||
@@ -517,11 +517,75 @@ namespace VEPROMS.CSLA.Library
|
||||
throw new DbCslaException("FormatInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
#region PlantFormat
|
||||
[NonSerialized]
|
||||
private PlantFormat _PlantFormat;
|
||||
public PlantFormat PlantFormat
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this)); } }
|
||||
{ get { return (_PlantFormat != null ? _PlantFormat : _PlantFormat = new PlantFormat(this, Config)); } }
|
||||
#endregion
|
||||
public IFormatOrFormatInfo MyIParent { get { return MyParent; } }
|
||||
public override string ToString()
|
||||
@@ -608,6 +672,51 @@ namespace VEPROMS.CSLA.Library
|
||||
return _SortedFormatInfoList;
|
||||
}
|
||||
}
|
||||
public static FormatInfoList GetFormatInfoListUsed()
|
||||
{
|
||||
try
|
||||
{
|
||||
FormatInfoList fvl = (FormatInfoList)DataPortal.Fetch(new FormatInfoListUsedCriteria());
|
||||
return fvl;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("FormatVersionList.DataPortal_Fetch GetFormatVersions", ex);
|
||||
}
|
||||
}
|
||||
protected class FormatInfoListUsedCriteria
|
||||
{
|
||||
}
|
||||
private void DataPortal_Fetch(FormatInfoListUsedCriteria criteria)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getFormatListUsed";
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
FormatInfo formatInfo = new FormatInfo(dr);
|
||||
IsReadOnly = false;
|
||||
this.Add(formatInfo);
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("FormatInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("FormatInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class FormatVersion
|
||||
{
|
||||
|
@@ -5185,7 +5185,8 @@ 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;
|
||||
if (pd.CheckOffData == null || pd.CheckOffData.CheckOffList == null || pd.CheckOffData.CheckOffList.MaxIndex <= 0) return false;
|
||||
int maxindx = pd.CheckOffUCF ? pd.CheckOffData.CheckOffList.MaxIndex : 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;
|
||||
|
||||
@@ -5216,7 +5217,8 @@ namespace VEPROMS.CSLA.Library
|
||||
private int SectionDefaultCheckOffIndex()
|
||||
{
|
||||
ProcData pd = ActiveFormat.PlantFormat.FormatData.ProcData;
|
||||
if (pd.CheckOffData != null && pd.CheckOffData.CheckOffList != null && pd.CheckOffData.CheckOffList.MaxIndex == 2) return 0; // if only two items, first is macro - use it.
|
||||
int maxindx = pd.CheckOffUCF ? pd.CheckOffData.CheckOffList.MaxIndex : 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;
|
||||
}
|
||||
@@ -5227,7 +5229,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) return ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffList[stpCoIndx];
|
||||
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)
|
||||
@@ -5261,7 +5279,8 @@ namespace VEPROMS.CSLA.Library
|
||||
get
|
||||
{
|
||||
ProcData pd = ActiveFormat.PlantFormat.FormatData.ProcData;
|
||||
if (pd.CheckOffData != null && pd.CheckOffData.CheckOffList != null && pd.CheckOffData.CheckOffList.MaxIndex == 2 && pd.CheckOffData.CheckOffList[0].MenuItem == "Enabled")
|
||||
int maxindx = pd.CheckOffUCF ? pd.CheckOffData.CheckOffList.MaxIndex : 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user