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;
|
||||
}
|
||||
|
335
PROMS/VEPROMS.CSLA.Library/Format/Comparator.cs
Normal file
335
PROMS/VEPROMS.CSLA.Library/Format/Comparator.cs
Normal file
@@ -0,0 +1,335 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public class Comparator
|
||||
{
|
||||
private XmlDocument _ResultsDoc;
|
||||
public XmlDocument ResultsDoc
|
||||
{
|
||||
get { return _ResultsDoc; }
|
||||
set { _ResultsDoc = value; }
|
||||
}
|
||||
private XmlDocument _XDoc1;
|
||||
public XmlDocument XDoc1
|
||||
{
|
||||
get { return _XDoc1; }
|
||||
set { _XDoc1 = value; }
|
||||
}
|
||||
private XmlDocument _XDoc2;
|
||||
public XmlDocument XDoc2
|
||||
{
|
||||
get { return _XDoc2; }
|
||||
set { _XDoc2 = value; }
|
||||
}
|
||||
public Comparator(XmlDocument xdoc1, XmlDocument xdoc2)
|
||||
{
|
||||
XDoc1 = xdoc1;
|
||||
XDoc2 = xdoc2;
|
||||
ResultsDoc = new XmlDocument();
|
||||
ResultsDoc.LoadXml(@"<PlantFormat></PlantFormat>");
|
||||
}
|
||||
public Comparator(string existingFC, string importedFC) //string fName1, string fName2)
|
||||
{
|
||||
XDoc1 = new XmlDocument();
|
||||
XDoc1.LoadXml(existingFC);
|
||||
XDoc2 = new XmlDocument();
|
||||
XDoc2.LoadXml(importedFC);
|
||||
ResultsDoc = new XmlDocument();
|
||||
ResultsDoc.LoadXml(@"<PlantFormat></PlantFormat>");
|
||||
}
|
||||
public XmlDocument Compare()
|
||||
{
|
||||
AllKeys = null;
|
||||
Compare(XDoc1.DocumentElement, XDoc2.DocumentElement, "");
|
||||
Console.WriteLine("results xml = \r\n{0}", ResultsDoc.InnerXml);
|
||||
return ResultsDoc;
|
||||
}
|
||||
public void Compare(XmlNode xn1, XmlNode xn2, string path)
|
||||
{
|
||||
if (xn1.OuterXml == xn2.OuterXml) return;
|
||||
Compare(xn1.Attributes, xn2.Attributes , path, xn1, xn2);
|
||||
xn1.Attributes.RemoveAll();
|
||||
xn2.Attributes.RemoveAll();
|
||||
|
||||
Dictionary<string, XmlNode> xns1 = new Dictionary<string, XmlNode>(); // child nodes, key = 'OuterXml', value = node itself
|
||||
Dictionary<string, XmlNode> xns2 = new Dictionary<string, XmlNode>();
|
||||
// xns1 starts out with all child nodes of xn1
|
||||
foreach (XmlNode xc1 in xn1.ChildNodes)
|
||||
xns1.Add(xc1.OuterXml + GetKey(xc1), xc1);
|
||||
// xns1 - remove any matching child nodes from xns2
|
||||
// xns2 - has nodes that are not in xns1
|
||||
foreach (XmlNode xc2 in xn2.ChildNodes)
|
||||
if (xns1.ContainsKey(xc2.OuterXml + GetKey(xc2)))
|
||||
xns1.Remove(xc2.OuterXml + GetKey(xc2));
|
||||
else
|
||||
xns2.Add(xc2.OuterXml+GetKey(xc2), xc2);
|
||||
|
||||
// xnss1 & xnss2 are dictionaries based on a unique key
|
||||
Dictionary<string, XmlNode> xnss1 = new Dictionary<string, XmlNode>();
|
||||
Dictionary<string, XmlNode> xnss2 = new Dictionary<string, XmlNode>();
|
||||
foreach (XmlNode xc1 in xns1.Values)
|
||||
xnss1.Add(GetKey(xc1), xc1);
|
||||
foreach (XmlNode xc2 in xns2.Values)
|
||||
if (xnss1.ContainsKey(GetKey(xc2)))
|
||||
Compare(xnss1[GetKey(xc2)], xc2, path + "/" + GetKey(xc2));
|
||||
else
|
||||
xnss2.Add(GetKey(xc2), xc2);
|
||||
// element differences, if counts are different. xns1 elements are not found in xns2 and xns2 elements are not found in xns1
|
||||
if (xns1.Count == 0 && xns2.Count == 0) return;
|
||||
xns1 = new Dictionary<string, XmlNode>(); // child nodes, key = 'OuterXml', value = node itself
|
||||
xns2 = new Dictionary<string, XmlNode>();
|
||||
// xns1 starts out with all child nodes of xn1
|
||||
foreach (XmlNode xc1 in xn1.ChildNodes)
|
||||
{
|
||||
xns1.Add(xc1.OuterXml+GetKey(xc1), xc1);
|
||||
}
|
||||
// xns1 - remove any matching child nodes from xns2
|
||||
// xns2 - has nodes that are not in xns1
|
||||
foreach (XmlNode xc2 in xn2.ChildNodes)
|
||||
if (xns1.ContainsKey(xc2.OuterXml + GetKey(xc2)))
|
||||
xns1.Remove(xc2.OuterXml + GetKey(xc2));
|
||||
else
|
||||
xns2.Add(xc2.OuterXml + GetKey(xc2), xc2);
|
||||
|
||||
// xnss1 & xnss2 are dictionaries based on a unique key
|
||||
xnss1 = new Dictionary<string, XmlNode>();
|
||||
xnss2 = new Dictionary<string, XmlNode>();
|
||||
foreach (XmlNode xc1 in xns1.Values)
|
||||
xnss1.Add(GetKey(xc1), xc1);
|
||||
foreach (XmlNode xc2 in xns2.Values)
|
||||
if (xnss1.ContainsKey(GetKey(xc2)))
|
||||
Compare(xnss1[GetKey(xc2)], xc2, path + "/" + GetKey(xc2));
|
||||
else
|
||||
xnss2.Add(GetKey(xc2), xc2);
|
||||
// element differences, if counts are different. xns1 elements are not found in xns2 and xns2 elements are not found in xns1
|
||||
if (xns1.Count == 0 && xns2.Count == 0) return;
|
||||
Console.WriteLine(" {0} {1} {2}", path + "/" + xn1.Name, xns1.Count, xns2.Count);
|
||||
foreach (string key in xnss1.Keys)
|
||||
{
|
||||
if (xnss1[key].Attributes.Count > 0 || xnss1[key].ChildNodes.Count > 0)
|
||||
{
|
||||
XmlNode xnr = MakeXPathFormat(path);
|
||||
if (xnr != null)
|
||||
{
|
||||
XmlNode cloned = xnss1[key].CloneNode(true);
|
||||
XmlNode importNode = ResultsDoc.ImportNode(cloned, true);
|
||||
XmlNode resnd = xnr.AppendChild(importNode);
|
||||
XmlAttribute xKey = ResultsDoc.CreateAttribute("Mode");
|
||||
xKey.Value = "Deleted";
|
||||
resnd.Attributes.Append(xKey);
|
||||
xKey = ResultsDoc.CreateAttribute("OldKey");
|
||||
xKey.Value = GetKey(xnss1[key]);
|
||||
resnd.Attributes.Append(xKey);
|
||||
xnr.AppendChild(resnd);
|
||||
if (resnd.ChildNodes.Count > 0)
|
||||
{
|
||||
foreach (XmlNode cxn in resnd.ChildNodes) if (cxn.Name == "Layout") SuffixAttributes("Old", cxn);
|
||||
}
|
||||
}
|
||||
}
|
||||
xnss1[key].ParentNode.RemoveChild(xnss1[key]);
|
||||
}
|
||||
|
||||
foreach (string key in xnss2.Keys)
|
||||
{
|
||||
if (xnss2[key].Attributes.Count > 0 || xnss2[key].ChildNodes.Count > 0)
|
||||
{
|
||||
XmlNode xnr = MakeXPathFormat(path);
|
||||
if (xnr != null)
|
||||
{
|
||||
XmlNode cloned = xnss2[key].CloneNode(true);
|
||||
XmlNode importNode = ResultsDoc.ImportNode(cloned, true);
|
||||
XmlNode resnd = xnr.AppendChild(importNode);
|
||||
|
||||
// if this has subnodes, add the 'Inserted' mode on them, otherwise, out it on this level
|
||||
if (resnd.ChildNodes.Count > 0)
|
||||
{
|
||||
foreach (XmlNode cxn in resnd.ChildNodes)
|
||||
{
|
||||
if (cxn.Name=="Layout") SuffixAttributes("New", cxn);
|
||||
XmlAttribute xKey = ResultsDoc.CreateAttribute("Mode");
|
||||
xKey.Value = "Inserted";
|
||||
if (cxn is XmlText)
|
||||
resnd.Attributes.Append(xKey);
|
||||
else
|
||||
cxn.Attributes.Append(xKey); // crashing here on a flag difference - trying to append this attribute to 'false'.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlAttribute xKey = ResultsDoc.CreateAttribute("Mode");
|
||||
xKey.Value = "Inserted";
|
||||
resnd.Attributes.Append(xKey);
|
||||
}
|
||||
XmlAttribute xKey1 = ResultsDoc.CreateAttribute("NewKey");
|
||||
xKey1.Value = GetKey(xnss2[key]);
|
||||
resnd.Attributes.Append(xKey1);
|
||||
xnr.AppendChild(resnd);
|
||||
}
|
||||
}
|
||||
xnss2[key].ParentNode.RemoveChild(xnss2[key]);
|
||||
}
|
||||
}
|
||||
|
||||
private void SuffixAttributes(string suffix, XmlNode resnd)
|
||||
{
|
||||
Dictionary<string, string> renameList = new Dictionary<string, string>();
|
||||
foreach (XmlAttribute xa in resnd.Attributes) renameList.Add(xa.Name, xa.Value);
|
||||
foreach (string key in renameList.Keys)
|
||||
{
|
||||
resnd.Attributes.RemoveNamedItem(key);
|
||||
XmlAttribute xKey1 = ResultsDoc.CreateAttribute(key+suffix);
|
||||
xKey1.Value = renameList[key];
|
||||
resnd.Attributes.Append(xKey1);
|
||||
}
|
||||
}
|
||||
private Dictionary<XmlNode, string> _AllKeys;
|
||||
public Dictionary<XmlNode, string> AllKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_AllKeys == null) _AllKeys = new Dictionary<XmlNode, string>();
|
||||
return _AllKeys;
|
||||
}
|
||||
set { _AllKeys = value; }
|
||||
}
|
||||
public string GetKey(XmlNode xn)
|
||||
{
|
||||
string key = GetKey1(xn);
|
||||
if (AllKeys.ContainsKey(xn)) return AllKeys[xn];
|
||||
AllKeys.Add(xn, key);
|
||||
return key;
|
||||
}
|
||||
// Get unique key, key is a string representing either the name itself or a combination of element name/attribute to make it unique
|
||||
public string GetKey1(XmlNode xn)
|
||||
{
|
||||
if (xn.Attributes == null) return xn.Name;
|
||||
XmlAttribute xi = xn.Attributes.GetNamedItem("Index") as XmlAttribute;
|
||||
if (xi != null)
|
||||
{
|
||||
XmlAttribute xa = xn.Attributes.GetNamedItem("Name") as XmlAttribute;
|
||||
if (xa != null) return string.Format("{0}[{1}]", xn.Name, xa.Value);
|
||||
return string.Format("{0}[{1}]", xn.Name, xi.Value);
|
||||
}
|
||||
XmlAttribute xt = xn.Attributes.GetNamedItem("Token") as XmlAttribute;
|
||||
if(xt != null) return string.Format("{0}[{1}]", xn.Name, xt.Value);
|
||||
XmlAttribute xw = xn.Attributes.GetNamedItem("ReplaceWord") as XmlAttribute;
|
||||
if(xw != null) return string.Format("{0}[{1}]", xn.Name, xw.Value);
|
||||
return xn.Name;
|
||||
}
|
||||
static private XmlNode makeXPath(XmlDocument doc, string xpath)
|
||||
{
|
||||
xpath = xpath.Replace(@"DocStyle[", @"DocStyle[@Name='");
|
||||
xpath = xpath.Replace(@"]", "']");
|
||||
return makeXPath(doc, doc as XmlNode, xpath);
|
||||
}
|
||||
|
||||
static private XmlNode makeXPath(XmlDocument doc, XmlNode parent, string xpath)
|
||||
{
|
||||
if (xpath.Contains("DocStyle")) Console.WriteLine("here");
|
||||
// grab the next node name in the xpath; or return parent if empty
|
||||
string[] partsOfXPath = xpath.Trim('/').Split('/');
|
||||
string nextNodeInXPath = partsOfXPath.First();
|
||||
if (string.IsNullOrEmpty(nextNodeInXPath))
|
||||
return parent;
|
||||
|
||||
XmlNode node = parent.SelectSingleNode(nextNodeInXPath);
|
||||
if (node == null)
|
||||
{
|
||||
if (nextNodeInXPath.Contains("@")) // element with an attribute, create both
|
||||
{
|
||||
// make element
|
||||
string elename = nextNodeInXPath.Substring(0, nextNodeInXPath.IndexOf("@") - 1);
|
||||
node = parent.AppendChild(doc.CreateElement(elename));
|
||||
// make attribute
|
||||
int indx = nextNodeInXPath.IndexOf("@")+1;
|
||||
string name = nextNodeInXPath.Substring(indx, nextNodeInXPath.IndexOf("=",indx)-indx);
|
||||
XmlAttribute xKeyd = doc.CreateAttribute(name);
|
||||
indx = nextNodeInXPath.IndexOf("='",indx)+2;
|
||||
string value = nextNodeInXPath.Substring(indx,nextNodeInXPath.IndexOf("'", indx) - indx);
|
||||
xKeyd.Value = nextNodeInXPath.Substring(indx,nextNodeInXPath.IndexOf("'",indx)-indx);
|
||||
node.Attributes.Append(xKeyd);
|
||||
}
|
||||
else
|
||||
node = parent.AppendChild(doc.CreateElement(nextNodeInXPath));
|
||||
}
|
||||
|
||||
// rejoin the remainder of the array as an xpath expression and recurse
|
||||
string rest = String.Join("/", partsOfXPath.Skip(1).ToArray());
|
||||
return makeXPath(doc, node, rest);
|
||||
}
|
||||
|
||||
private XmlNode MakeXPathFormat(string xpath)
|
||||
{
|
||||
// first find or make, if not found, the XmlElement within FormatData or DocStyles
|
||||
Console.WriteLine("path = {0}", xpath);
|
||||
return makeXPath(ResultsDoc, xpath);
|
||||
}
|
||||
#region Attributes
|
||||
private void Compare(XmlAttributeCollection atts1, XmlAttributeCollection atts2, string path, XmlNode atts1Par, XmlNode atts2Par)
|
||||
{
|
||||
// go through attributes in first xml document, see if they exist in the 2nd xml document & are identical attribute
|
||||
foreach (XmlAttribute xa1 in atts1)
|
||||
{
|
||||
XmlAttribute xa2 = atts2.GetNamedItem(xa1.Name) as XmlAttribute;
|
||||
if (xa2 == null)
|
||||
{
|
||||
XmlNode xnr = MakeXPathFormat(path);
|
||||
if (xnr != null)
|
||||
{
|
||||
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa1.Name+"Old");
|
||||
xKey.Value = xa1.Value;
|
||||
xnr.Attributes.Append(xKey);
|
||||
xKey = ResultsDoc.CreateAttribute("OldKey");
|
||||
xKey.Value = GetKey(atts1Par);
|
||||
if (xKey.Value != null) xnr.Attributes.Append(xKey);
|
||||
}
|
||||
}
|
||||
else if (xa2.Value != xa1.Value)
|
||||
{
|
||||
XmlNode xnr = MakeXPathFormat(path);
|
||||
if (xnr != null)
|
||||
{
|
||||
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa1.Name + "Old");
|
||||
xKey.Value = xa1.Value;
|
||||
xnr.Attributes.Append(xKey);
|
||||
XmlAttribute xKey2 = ResultsDoc.CreateAttribute(xa2.Name + "New");
|
||||
xKey2.Value = xa2.Value;
|
||||
xnr.Attributes.Append(xKey2);
|
||||
xKey = ResultsDoc.CreateAttribute("OldKey");
|
||||
xKey.Value = GetKey(atts1Par);
|
||||
if (xKey.Value != null) xnr.Attributes.Append(xKey);
|
||||
xKey = ResultsDoc.CreateAttribute("NewKey");
|
||||
xKey.Value = GetKey(atts2Par);
|
||||
if (xKey.Value != null) xnr.Attributes.Append(xKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
// go through attributes in 2nd xml document to see if they exist in the first xml document & are identical
|
||||
foreach (XmlAttribute xa2 in atts2)
|
||||
{
|
||||
XmlAttribute xa1 = atts1.GetNamedItem(xa2.Name) as XmlAttribute;
|
||||
if (xa1 == null)
|
||||
{
|
||||
XmlNode xnr = MakeXPathFormat(path);
|
||||
if (xnr != null)
|
||||
{
|
||||
XmlAttribute xKey = ResultsDoc.CreateAttribute(xa2.Name+"New");
|
||||
xKey.Value = xa2.Value;
|
||||
xnr.Attributes.Append(xKey);
|
||||
xKey = ResultsDoc.CreateAttribute("NewKey");
|
||||
xKey.Value = GetKey(atts2Par);
|
||||
if (xKey.Value != null) xnr.Attributes.Append(xKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -515,7 +515,29 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _LeftMargin, "@LeftMargin");
|
||||
if (PlantFormat.IgnoreUCF) return LazyLoad(ref _LeftMargin, "@LeftMargin");
|
||||
if (MyFormat.PlantFormat.FormatConfig == null) return LazyLoad(ref _LeftMargin, "@LeftMargin");
|
||||
|
||||
// see if there is UCF data, need to match the index of the ucf data to that in the original format, and
|
||||
// also need to check that LeftMargin is not null, since other docstyle data may exist in UCF but not PageLength:
|
||||
XmlNode par = this.XmlNode.ParentNode;
|
||||
string indx = null;
|
||||
XmlElement ele = par as XmlElement;
|
||||
if (ele.HasAttribute("Index")) indx = ele.GetAttribute("Index");
|
||||
if (indx == null) return LazyLoad(ref _PageLength, "@LeftMargin");
|
||||
if (MyFormat.PlantFormat.FormatConfig != null && this.MyFormat.PlantFormat.FormatConfig.PlantFormat.DocStyles != null && MyFormat.PlantFormat.FormatConfig.PlantFormat.DocStyles.Count > 0)
|
||||
{
|
||||
foreach (FormatConfig.DocStyle ds in MyFormat.PlantFormat.FormatConfig.PlantFormat.DocStyles)
|
||||
{
|
||||
if (indx == ds.Index)
|
||||
{
|
||||
float? test = ds.Layout.LeftMargin;
|
||||
if (test != null) _LeftMargin = new LazyLoad<float?>(ds.Layout.LeftMargin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return LazyLoad(ref _LeftMargin, "@LeftMargin");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -526,10 +548,33 @@ namespace VEPROMS.CSLA.Library
|
||||
[Description("Length of Page")]
|
||||
public float? PageLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _PageLength, "@PageLength");
|
||||
}
|
||||
get
|
||||
{
|
||||
if (PlantFormat.IgnoreUCF) return LazyLoad(ref _PageLength, "@PageLength");
|
||||
if (MyFormat.PlantFormat.FormatConfig == null) return LazyLoad(ref _PageLength, "@PageLength");
|
||||
|
||||
// see if there is UCF data, need to match the index of the ucf data to that in the original format, and
|
||||
// also need to check that PageLength is not null, since other docstyle data may exist in UCF but not PageLength:
|
||||
XmlNode par = this.XmlNode.ParentNode;
|
||||
string indx = null;
|
||||
XmlElement ele = par as XmlElement;
|
||||
if (ele.HasAttribute("Index")) indx = ele.GetAttribute("Index");
|
||||
if (indx == null) return LazyLoad(ref _PageLength, "@PageLength");
|
||||
if (MyFormat.PlantFormat.FormatConfig != null && this.MyFormat.PlantFormat.FormatConfig.PlantFormat.DocStyles != null && MyFormat.PlantFormat.FormatConfig.PlantFormat.DocStyles.Count > 0)
|
||||
{
|
||||
foreach (FormatConfig.DocStyle ds in MyFormat.PlantFormat.FormatConfig.PlantFormat.DocStyles)
|
||||
{
|
||||
if (indx == ds.Index)
|
||||
{
|
||||
float? test = ds.Layout.PageLength;
|
||||
if (test != null) _PageLength = new LazyLoad<float?>(ds.Layout.PageLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return LazyLoad(ref _PageLength, "@PageLength");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region PageWidth
|
||||
|
@@ -247,5 +247,13 @@ namespace VEPROMS.CSLA.Library
|
||||
SupInfoPdfPrint = 2,
|
||||
Merge = 3
|
||||
}
|
||||
public enum E_UCFImportOptions : uint
|
||||
{
|
||||
Ignore = 0,
|
||||
LoadNotUsed = 1,
|
||||
LoadOnlyImported = 2,
|
||||
LoadUseAll = 3,
|
||||
LoadForSetOnly = 4
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@@ -11,9 +11,56 @@ namespace VEPROMS.CSLA.Library
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class PlantFormat
|
||||
{
|
||||
public PlantFormat(IFormatOrFormatInfo format)
|
||||
public PlantFormat(IFormatOrFormatInfo format, string config)
|
||||
{
|
||||
_MyFormat = format;
|
||||
string str = null;
|
||||
if (format is Format) str = (format as Format).Config;
|
||||
else if (format is FormatInfo) str = (format as FormatInfo).Config;
|
||||
if (str != null && str != "") _FormatConfig = FormatConfig.Get(str);
|
||||
}
|
||||
private FormatConfig _FormatConfig;
|
||||
public FormatConfig FormatConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_FormatConfig == null)
|
||||
{
|
||||
_FormatConfig = GetFormatConfig(_MyFormat);
|
||||
}
|
||||
return _FormatConfig;
|
||||
}
|
||||
set { _FormatConfig = value; }
|
||||
}
|
||||
// when IgnoreUCF is true, get the original data, i.e. don't apply any UCF changes to it
|
||||
private static bool _IgnoreUCF = false;
|
||||
public static bool IgnoreUCF
|
||||
{
|
||||
get { return PlantFormat._IgnoreUCF; }
|
||||
set { PlantFormat._IgnoreUCF = value; }
|
||||
}
|
||||
// flags that the User Control of Format setting for using additional UCF checkoffs is active
|
||||
private static bool _DoingUCFCheckOffs = false;
|
||||
public static bool DoingUCFCheckOffs
|
||||
{
|
||||
get { return PlantFormat._DoingUCFCheckOffs; }
|
||||
set { PlantFormat._DoingUCFCheckOffs = value; }
|
||||
}
|
||||
// flags the value that should be used (true/false) for using additional UCF checkoffs (used with DoingUCFCheckOffs)
|
||||
private static bool _DoingUCFCheckOffsUse = false;
|
||||
public static bool DoingUCFCheckOffsUse
|
||||
{
|
||||
get { return PlantFormat._DoingUCFCheckOffsUse; }
|
||||
set { PlantFormat._DoingUCFCheckOffsUse = value; }
|
||||
}
|
||||
public static FormatConfig GetFormatConfig(IFormatOrFormatInfo format)
|
||||
{
|
||||
FormatConfig fc = null;
|
||||
string str = null;
|
||||
if (format is Format) str = (format as Format).Config;
|
||||
else if (format is FormatInfo) str = (format as FormatInfo).Config;
|
||||
if (str != null && str != "") fc = FormatConfig.Get(str);
|
||||
return fc;
|
||||
}
|
||||
private IFormatOrFormatInfo _MyFormat;
|
||||
public IFormatOrFormatInfo MyFormat
|
||||
@@ -58,12 +105,76 @@ namespace VEPROMS.CSLA.Library
|
||||
return _DocStyles;
|
||||
}
|
||||
}
|
||||
public bool HasPageListToken(string token)
|
||||
{;
|
||||
string xpath = string.Format("/PlantFormat/PageStyles/PageStyle/Item[@Token = '{0}']", token);
|
||||
XmlNodeList nl = XmlDoc.SelectNodes(xpath);
|
||||
return nl.Count > 0;
|
||||
}
|
||||
public bool HasPageListToken(string token)
|
||||
{
|
||||
string xpath = string.Format("/PlantFormat/PageStyles/PageStyle/Item[@Token = '{0}']", token);
|
||||
XmlNodeList nl = XmlDoc.SelectNodes(xpath);
|
||||
return nl.Count > 0;
|
||||
}
|
||||
private FormatConfig.ReplaceStrData _UCFandOrigReplaceStrData = null;
|
||||
public FormatConfig.ReplaceStrData UCFandOrigReplaceStrData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UCFandOrigReplaceStrData != null) return _UCFandOrigReplaceStrData;
|
||||
_UCFandOrigReplaceStrData = GetMergedReplaceList(this);
|
||||
return _UCFandOrigReplaceStrData;
|
||||
}
|
||||
}
|
||||
private FormatConfig.ReplaceStrData GetMergedReplaceList(PlantFormat OriginalPlantFormat)
|
||||
{
|
||||
// need to compare the original format list with the list as it is stored for working with property grid.
|
||||
FormatConfig.ReplaceStrData retlist = new FormatConfig.ReplaceStrData(); // merged list
|
||||
List<string> inoriglist = new List<string>(); // use this list to find new items in formatconfig (see below)
|
||||
foreach (ReplaceStr origrepstr in OriginalPlantFormat.FormatData.SectData.ReplaceStrList)
|
||||
{
|
||||
// In the format config list (UCF), find the 'ReplaceWord'. This is the 'key' for defining whether the
|
||||
// replace word has been overwridden by UCF data. If it exists, use it:
|
||||
FormatConfig.ReplaceStr usethisone = null;
|
||||
bool deleted = false;
|
||||
// States for replacewords: 0 = no change, -1 deleted, 1 added, 2 modified
|
||||
if (FormatConfig != null)
|
||||
{
|
||||
foreach (FormatConfig.ReplaceStr ucfrepstr in FormatConfig.PlantFormat.FormatData.ReplaceStrData)
|
||||
{
|
||||
if (ucfrepstr.ReplaceWord == origrepstr.ReplaceWord)
|
||||
{
|
||||
if (ucfrepstr.State == -1) deleted = true;
|
||||
else usethisone = ucfrepstr;
|
||||
ucfrepstr.State = 2;
|
||||
inoriglist.Add(origrepstr.ReplaceWord);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!deleted && usethisone == null)
|
||||
{
|
||||
usethisone = new FormatConfig.ReplaceStr();
|
||||
usethisone.Flag = (FormatConfig.E_ReplaceFlagsUCF)origrepstr.Flag;
|
||||
usethisone.State = 0; // no change
|
||||
usethisone.ReplaceWith = origrepstr.ReplaceWith;
|
||||
usethisone.ReplaceWord = origrepstr.ReplaceWord;
|
||||
}
|
||||
if (!deleted) retlist.Add(usethisone);
|
||||
}
|
||||
// now add in any ucf only replacements, any that are not in the inoriglist
|
||||
if (FormatConfig != null)
|
||||
{
|
||||
foreach (FormatConfig.ReplaceStr ucfrepstr in FormatConfig.PlantFormat.FormatData.ReplaceStrData)
|
||||
{
|
||||
if (!inoriglist.Contains(ucfrepstr.ReplaceWord))
|
||||
{
|
||||
FormatConfig.ReplaceStr newone = new FormatConfig.ReplaceStr();
|
||||
newone.Flag = (FormatConfig.E_ReplaceFlagsUCF)ucfrepstr.Flag;
|
||||
newone.State = 1;
|
||||
newone.ReplaceWith = ucfrepstr.ReplaceWith;
|
||||
newone.ReplaceWord = ucfrepstr.ReplaceWord;
|
||||
retlist.Add(newone);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (retlist);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region VE_Font
|
||||
@@ -71,12 +182,20 @@ namespace VEPROMS.CSLA.Library
|
||||
public class VE_Font : vlnFormatItem
|
||||
{
|
||||
public VE_Font(XmlNode xmlNode) : base(xmlNode) { }
|
||||
private string _ffam = null;
|
||||
private int _fsize = 0;
|
||||
private E_Style _fstyle = E_Style.None;
|
||||
private float _fcpi = 0;
|
||||
public VE_Font(string family, int size, E_Style style, float CPI)
|
||||
{
|
||||
_Family = new LazyLoad<string>(family);
|
||||
_Size = new LazyLoad<int?>(size);
|
||||
_Style = new LazyLoad<E_Style?>(style);
|
||||
_CPI = new LazyLoad<float?>(CPI);
|
||||
_ffam = family;
|
||||
_fsize = size;
|
||||
_fstyle = style;
|
||||
_fcpi = CPI;
|
||||
}
|
||||
private LazyLoad<string> _Family;
|
||||
private static Dictionary<string, Font> _WinFontLookup = new Dictionary<string, Font>();
|
||||
@@ -127,10 +246,15 @@ namespace VEPROMS.CSLA.Library
|
||||
style |= FontStyle.Underline;
|
||||
}
|
||||
// for now - check size to be 0 and set to 10 if so, error in fmtxml?
|
||||
if (Family == null) // Need to get inherited font
|
||||
_WindowsFont = GetFont("Arial", 10, FontStyle.Regular);
|
||||
else
|
||||
_WindowsFont = GetFont(Family, Size == 0 ? 10 : (float)Size, style);
|
||||
if (Family == null) // Need to get inherited font
|
||||
_WindowsFont = GetFont("Arial", 10, FontStyle.Regular);
|
||||
else
|
||||
{
|
||||
//if (_ffam != null)
|
||||
// _WindowsFont = GetFont(_ffam, (float)_fsize, style); // this needs work.
|
||||
//else
|
||||
_WindowsFont = GetFont(Family, Size == 0 ? 10 : (float)Size, style);
|
||||
}
|
||||
}
|
||||
return _WindowsFont;
|
||||
}
|
||||
@@ -1107,13 +1231,13 @@ namespace VEPROMS.CSLA.Library
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class ProcData : vlnFormatItem
|
||||
{
|
||||
public ProcData(XmlNode xmlNode): base(xmlNode) {}
|
||||
public ProcData(XmlNode xmlNode) : base(xmlNode) { }
|
||||
private ProcedureSuffixList _ProcedureSuffixList;
|
||||
public ProcedureSuffixList ProcedureSuffixList
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ProcedureSuffixList == null? _ProcedureSuffixList = new ProcedureSuffixList(SelectNodes("ProcedureSuffix/string")): _ProcedureSuffixList;
|
||||
return _ProcedureSuffixList == null ? _ProcedureSuffixList = new ProcedureSuffixList(SelectNodes("ProcedureSuffix/string")) : _ProcedureSuffixList;
|
||||
}
|
||||
set { _ProcedureSuffixList = value; }
|
||||
}
|
||||
@@ -1122,7 +1246,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ChangeBarData == null? _ChangeBarData = new ChangeBarData(SelectSingleNode("ChangeBarData")):_ChangeBarData;
|
||||
return _ChangeBarData == null ? _ChangeBarData = new ChangeBarData(SelectSingleNode("ChangeBarData")) : _ChangeBarData;
|
||||
}
|
||||
}
|
||||
private CheckOffData _CheckOffData;
|
||||
@@ -1130,7 +1254,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CheckOffData == null? _CheckOffData = new CheckOffData(SelectSingleNode("CheckOffData")):_CheckOffData;
|
||||
return _CheckOffData == null ? _CheckOffData = new CheckOffData(SelectSingleNode("CheckOffData")) : _CheckOffData;
|
||||
}
|
||||
}
|
||||
private PSI _PSI;
|
||||
@@ -1141,29 +1265,47 @@ namespace VEPROMS.CSLA.Library
|
||||
return _PSI == null ? _PSI = new PSI(SelectSingleNode("PSI")) : _PSI;
|
||||
}
|
||||
}
|
||||
private LazyLoad<bool> _CheckOffUCF;
|
||||
public bool CheckOffUCF
|
||||
{
|
||||
get
|
||||
{
|
||||
// The following line is used in UCF: this needs to be able to control a change in setting in UCF versus its use:
|
||||
// This is a special case since the original format, using the value in BaseAll, is always 'false'. And the value
|
||||
// should never be set in original volian plant format files, if the additional UCF checkoffs are to be used, this must
|
||||
// be set in the UCF user interface.
|
||||
if (PlantFormat.DoingUCFCheckOffs) return PlantFormat.DoingUCFCheckOffsUse;
|
||||
|
||||
if (PlantFormat.IgnoreUCF) return LazyLoad(ref _CheckOffUCF, "@CheckOffUCF");
|
||||
bool? localvalue = null; // comes to here if in edit or print - use any UCF data before going to original format.
|
||||
FormatConfig fc = PlantFormat.GetFormatConfig(MyFormat);
|
||||
if (fc != null) localvalue = fc.PlantFormat.FormatData.Flags.CheckOffUCF;
|
||||
return localvalue ?? LazyLoad(ref _CheckOffUCF, "@CheckOffUCF");
|
||||
}
|
||||
}
|
||||
private LazyLoad<int?> _TitleLength;
|
||||
public int? TitleLength
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _TitleLength, "@TitleLength");
|
||||
}
|
||||
}
|
||||
}
|
||||
private LazyLoad<int?> _CoverTitleLength;
|
||||
public int? CoverTitleLength
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _CoverTitleLength, "@CoverTitleLength");
|
||||
}
|
||||
}
|
||||
}
|
||||
private LazyLoad<string> _ProcedureSuffixFlags;
|
||||
public string ProcedureSuffixFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _ProcedureSuffixFlags, "@ProcedureSuffixFlags");
|
||||
}
|
||||
return LazyLoad(ref _ProcedureSuffixFlags, "@ProcedureSuffixFlags");
|
||||
}
|
||||
}
|
||||
private LazyLoad<bool> _CapitalizeTitle;
|
||||
public bool CapitalizeTitle
|
||||
@@ -1503,22 +1645,146 @@ namespace VEPROMS.CSLA.Library
|
||||
public class CheckOffData : vlnFormatItem
|
||||
{
|
||||
public CheckOffData(XmlNode xmlNode) : base(xmlNode) { }
|
||||
private CheckOffList _CheckOffList;
|
||||
private CheckOffList _CheckOffList = null;
|
||||
public CheckOffList CheckOffList
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CheckOffList == null? _CheckOffList = new CheckOffList(SelectNodes("CheckOffList/CheckOff"),MyFormat):_CheckOffList;
|
||||
if (_CheckOffList != null) return _CheckOffList;
|
||||
|
||||
// Get a list of checkoffs that should be included:
|
||||
// if !UseCheckOffUCF (Baseall has it as false. User can change setting in UCF to true)
|
||||
// if !IgnoreUCF, i.e. use UCF changes, return original lists with only active items (Inactive = false)
|
||||
// if IgnoreUCF, return original lists with all items
|
||||
// if UseCheckOffUCF is true use the merged lists from current format and baseall.xml and
|
||||
// do the same processing for IgnoreUCF described above.
|
||||
|
||||
// UseCheckOffUCF is false or there is no FormatConfig (UCF) data:
|
||||
FormatConfig fc = PlantFormat.GetFormatConfig(MyFormat);
|
||||
if (!MyFormat.PlantFormat.FormatData.ProcData.CheckOffUCF || fc==null)
|
||||
{
|
||||
_CheckOffList = new CheckOffList(SelectNodes("CheckOffList/CheckOff"), MyFormat);
|
||||
// If Ignoring the UCF data, just return the entire list. Also, return entire list if there is no UCF data (fc == null)
|
||||
if (!PlantFormat.IgnoreUCF || fc == null) return _CheckOffList;
|
||||
// If not ignoring UCF settings, only return those that are active
|
||||
foreach (FormatConfig.CheckOff co in fc.PlantFormat.FormatData.CheckOffList)
|
||||
{
|
||||
foreach (CheckOff coo in _CheckOffList)
|
||||
{
|
||||
if ((int)coo.Index == Convert.ToInt32(co.Index) && !(bool)co.Active)
|
||||
{
|
||||
_CheckOffList.Remove(coo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _CheckOffList;
|
||||
}
|
||||
// UseCheckOfffUCF is true:
|
||||
// merge the checkoff list from the current format and the checkoff list from the base format
|
||||
_CheckOffList = new CheckOffList(SelectNodes("CheckOffList/CheckOff"), MyFormat);
|
||||
CheckOffList retlist2 = new CheckOffList(SelectNodes("../CheckOffDataUCF/CheckOffList/CheckOff"), MyFormat);
|
||||
if (retlist2 != null && retlist2.Count > 0) foreach (CheckOff co in retlist2) _CheckOffList.Add(co);
|
||||
if (PlantFormat.IgnoreUCF) return _CheckOffList;
|
||||
|
||||
// if applying UCF, then remove those that are inactive:
|
||||
foreach (FormatConfig.CheckOff co in fc.PlantFormat.FormatData.CheckOffList)
|
||||
{
|
||||
foreach (CheckOff coo in _CheckOffList)
|
||||
{
|
||||
if ((int)coo.Index == Convert.ToInt32(co.Index) && !(bool)co.Active)
|
||||
{
|
||||
_CheckOffList.Remove(coo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _CheckOffList;
|
||||
}
|
||||
}
|
||||
public void ClearCheckOffAndHeaderLists()
|
||||
{
|
||||
_CheckOffList = null;
|
||||
_CheckOffHeaderList = null;
|
||||
}
|
||||
private CheckOffHeaderList _CheckOffHeaderList;
|
||||
public CheckOffHeaderList CheckOffHeaderList
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CheckOffHeaderList == null? _CheckOffHeaderList = new CheckOffHeaderList(SelectNodes("CheckOffHeaderList/CheckOffHeader"),MyFormat): _CheckOffHeaderList;
|
||||
if (_CheckOffHeaderList != null) return _CheckOffHeaderList;
|
||||
FormatConfig fc = PlantFormat.GetFormatConfig(MyFormat);
|
||||
if (!MyFormat.PlantFormat.FormatData.ProcData.CheckOffUCF || fc == null)
|
||||
{
|
||||
_CheckOffHeaderList = new CheckOffHeaderList(SelectNodes("CheckOffHeaderList/CheckOffHeader"), MyFormat);
|
||||
// Depending on the IgnoreUCF flag, either return this list with UCF Inactive flags set or return the
|
||||
// list as is.
|
||||
if (PlantFormat.IgnoreUCF || fc == null) return _CheckOffHeaderList;
|
||||
// If not ignoring UCF settings, only return those that are active
|
||||
foreach (FormatConfig.CheckOffHeader coh in fc.PlantFormat.FormatData.CheckOffHeaderList)
|
||||
{
|
||||
foreach (CheckOffHeader coo in _CheckOffHeaderList)
|
||||
{
|
||||
if ((int)coo.Index == Convert.ToInt32(coh.Index) && !(bool)coh.Active)
|
||||
{
|
||||
_CheckOffHeaderList.Remove(coo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _CheckOffHeaderList;
|
||||
}
|
||||
// merge the checkoff header lists from the current format and the list from the base
|
||||
_CheckOffHeaderList = new CheckOffHeaderList(SelectNodes("CheckOffHeaderList/CheckOffHeader"), MyFormat);
|
||||
CheckOffHeaderList retlist2 = new CheckOffHeaderList(SelectNodes("../CheckOffDataUCF/CheckOffHeaderList/CheckOffHeader"), MyFormat);
|
||||
if (retlist2 != null && retlist2.Count > 0) foreach (CheckOffHeader co in retlist2) _CheckOffHeaderList.Add(co);
|
||||
if (PlantFormat.IgnoreUCF) return _CheckOffHeaderList;
|
||||
|
||||
// if applying UCF, then remove those that are inactive.
|
||||
foreach (FormatConfig.CheckOffHeader coh in fc.PlantFormat.FormatData.CheckOffHeaderList)
|
||||
{
|
||||
foreach (CheckOffHeader cooh in _CheckOffHeaderList)
|
||||
{
|
||||
if ((int)cooh.Index == Convert.ToInt32(coh.Index) && !(bool)coh.Active)
|
||||
{
|
||||
_CheckOffHeaderList.Remove(cooh);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _CheckOffHeaderList;
|
||||
}
|
||||
}
|
||||
public void CheckOffHeaderListRefresh(bool CheckOffUCF)
|
||||
{
|
||||
if (!CheckOffUCF)
|
||||
{
|
||||
_CheckOffHeaderList = new CheckOffHeaderList(SelectNodes("CheckOffHeaderList/CheckOffHeader"), MyFormat);
|
||||
// Depending on the IgnoreUCF flag, either return this list with UCF Inactive flags set or return the
|
||||
// list as is.
|
||||
FormatConfig fc = PlantFormat.GetFormatConfig(MyFormat);
|
||||
if (PlantFormat.IgnoreUCF || fc == null) return;
|
||||
// If not ignoring UCF settings, only return those that are active
|
||||
foreach (FormatConfig.CheckOffHeader coh in fc.PlantFormat.FormatData.CheckOffHeaderList)
|
||||
{
|
||||
foreach (CheckOffHeader coo in _CheckOffHeaderList)
|
||||
{
|
||||
if ((int)coo.Index == Convert.ToInt32(coh.Index) && !(bool)coh.Active)
|
||||
{
|
||||
_CheckOffHeaderList.Remove(coo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// if coming from the UCF dialog, then check for the 'ignoreUCF' this will flag whether to only
|
||||
// merge the checkoff header lists from the current format and the list from the base
|
||||
CheckOffHeaderList retlist = new CheckOffHeaderList(SelectNodes("CheckOffHeaderList/CheckOffHeader"), MyFormat);
|
||||
CheckOffHeaderList retlist2 = new CheckOffHeaderList(SelectNodes("../CheckOffDataUCF/CheckOffHeaderList/CheckOffHeader"), MyFormat);
|
||||
if (retlist2 != null && retlist2.Count > 0) foreach (CheckOffHeader co in retlist2) retlist.Add(co);
|
||||
_CheckOffHeaderList = retlist;
|
||||
}
|
||||
private LazyLoad<bool> _CheckOffHeaderInPagelist;
|
||||
public bool CheckOffHeaderInPagelist
|
||||
{
|
||||
@@ -1619,57 +1885,6 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
//#region RightCheckOffBox
|
||||
//[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
//public class RightCheckOffBox : vlnFormatItem, IVlnIndexedFormatItem
|
||||
//{
|
||||
// public RightCheckOffBox(XmlNode xmlNode) : base(xmlNode) { }
|
||||
// public RightCheckOffBox() : base() { }
|
||||
// private LazyLoad<int?> _Index;
|
||||
// public int? Index
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return LazyLoad(ref _Index, "@Index");
|
||||
// }
|
||||
// }
|
||||
// private LazyLoad<int?> _RightCheckOffBoxChar;
|
||||
// public int? RightCheckOffBoxChar
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return LazyLoad(ref _RightCheckOffBoxChar, "@RightCheckOffBoxChar");
|
||||
// }
|
||||
// }
|
||||
// public override string GetPDDisplayName()
|
||||
// { return string.Format("[{0}]", Index); }
|
||||
// public override string GetPDDescription()
|
||||
// { return string.Format("[{0}] - {1}", Index, RightCheckOffBoxChar); }
|
||||
// public override string GetPDCategory()
|
||||
// { return "RightCheckOffBox Data"; }
|
||||
// public override string ToString()
|
||||
// {
|
||||
// return RightCheckOffBoxChar.ToString();
|
||||
// }
|
||||
//}
|
||||
//#endregion
|
||||
//#region RightCheckOffBoxList
|
||||
//[TypeConverter(typeof(vlnIndexedListConverter<RightCheckOffBoxList, RightCheckOffBox>))]
|
||||
//public class RightCheckOffBoxList : vlnIndexedFormatList<RightCheckOffBox>
|
||||
//{
|
||||
// public RightCheckOffBoxList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList,myFormat) { }
|
||||
// public override vlnIndexedFormatList<RightCheckOffBox> InheritedList
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// IFormatOrFormatInfo parentFormat = MyFormat.MyIParent;
|
||||
// if (parentFormat != null)
|
||||
// return parentFormat.PlantFormat.FormatData.ProcData.CheckOffData.RightCheckOffBoxList;
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//#endregion
|
||||
#region CheckOff
|
||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||
public class CheckOff : vlnFormatItem,IVlnIndexedFormatItem
|
||||
@@ -3531,7 +3746,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _CompressSteps, "@CompressSteps");
|
||||
if (PlantFormat.IgnoreUCF) return LazyLoad(ref _CompressSteps, "@CompressSteps");
|
||||
bool? localvalue = null;
|
||||
FormatConfig fc = PlantFormat.GetFormatConfig(MyFormat);
|
||||
if (fc != null) localvalue = fc.PlantFormat.FormatData.Flags.CompressSteps;
|
||||
return localvalue ?? LazyLoad(ref _CompressSteps, "@CompressSteps");
|
||||
}
|
||||
}
|
||||
private LazyLoad<bool> _DoSTExtraAtTop;
|
||||
@@ -3718,7 +3937,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _PartialStepCompression, "@PartialStepCompression");
|
||||
if (PlantFormat.IgnoreUCF) return LazyLoad(ref _PartialStepCompression, "@PartialStepCompression");
|
||||
bool? localvalue = null;
|
||||
FormatConfig fc = PlantFormat.GetFormatConfig(MyFormat);
|
||||
if (fc != null) localvalue = fc.PlantFormat.FormatData.Flags.PartialStepCompression;
|
||||
return localvalue ?? LazyLoad(ref _PartialStepCompression, "@PartialStepCompression");
|
||||
}
|
||||
}
|
||||
private LazyLoad<bool> _VirtualDotInHLSTab;
|
||||
@@ -5072,11 +5295,41 @@ namespace VEPROMS.CSLA.Library
|
||||
return LazyLoad(ref _Quoted, "@Quoted");
|
||||
}
|
||||
}
|
||||
private VE_Font GetUCFFontAsVE_Font()
|
||||
{
|
||||
// if formatconfig & step list, then go through to see if index exists, if so and if there is a font, use it:
|
||||
if (MyFormat.PlantFormat.FormatConfig != null && MyFormat.PlantFormat.FormatConfig.PlantFormat != null && MyFormat.PlantFormat.FormatConfig.PlantFormat.FormatData != null && MyFormat.PlantFormat.FormatConfig.PlantFormat.FormatData.StepData != null)
|
||||
{
|
||||
foreach (FormatConfig.Step stp in MyFormat.PlantFormat.FormatConfig.PlantFormat.FormatData.StepData)
|
||||
{
|
||||
if (Convert.ToInt32(stp.Index) == (int)Index && stp.FontDesc != null && stp.FontDesc.Font != null && stp.FontDesc.Font != "")
|
||||
{
|
||||
System.Drawing.FontConverter cvt = new System.Drawing.FontConverter();
|
||||
System.Drawing.Font windowsFont = cvt.ConvertFromString(stp.FontDesc.Font) as System.Drawing.Font;
|
||||
|
||||
E_Style myStyle = E_Style.None;
|
||||
if (windowsFont.Bold) myStyle |= E_Style.Bold;
|
||||
if (windowsFont.Underline) myStyle |= E_Style.Underline;
|
||||
if (windowsFont.Italic) myStyle |= E_Style.Italics;
|
||||
return (new VE_Font(windowsFont.Name, (int)windowsFont.Size, myStyle, windowsFont.SizeInPoints));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private VE_Font _Font;
|
||||
public VE_Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
if (PlantFormat.IgnoreUCF) return (_Font == null) ?_Font = new VE_Font(base.XmlNode): _Font;
|
||||
if (_Font != null) return (_Font);
|
||||
VE_Font vef = GetUCFFontAsVE_Font();
|
||||
if (vef != null)
|
||||
{
|
||||
_Font = vef;
|
||||
return vef;
|
||||
}
|
||||
return (_Font == null) ?_Font = new VE_Font(base.XmlNode): _Font;
|
||||
}
|
||||
}
|
||||
|
@@ -642,6 +642,19 @@ namespace VEPROMS.CSLA.Library
|
||||
return max;
|
||||
}
|
||||
}
|
||||
public int MaxIndexNoInherit
|
||||
{
|
||||
get
|
||||
{
|
||||
int max = base.Count;
|
||||
foreach (T tmp in this)
|
||||
{
|
||||
if (tmp.Index >= max)
|
||||
max = ((int)tmp.Index) + 1;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
}
|
||||
#region ICustomTypeDescriptor
|
||||
public String GetClassName()
|
||||
{ return TypeDescriptor.GetClassName(this, true); }
|
||||
|
@@ -262,6 +262,27 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _Config = string.Empty;
|
||||
public string Config
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Config", true);
|
||||
return _Config;
|
||||
}
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
set
|
||||
{
|
||||
CanWriteProperty("Config", true);
|
||||
if (value == null) value = string.Empty;
|
||||
if (_Config != value)
|
||||
{
|
||||
_Config = value;
|
||||
PropertyHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _GenMac = string.Empty;
|
||||
public string GenMac
|
||||
{
|
||||
@@ -559,15 +580,18 @@ namespace VEPROMS.CSLA.Library
|
||||
Csla.Validation.CommonRules.StringRequired, "Name");
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringMaxLength,
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 20));
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringMaxLength,
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Description", 250));
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringRequired, "Data");
|
||||
//ValidationRules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringRequired, "Data");
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringMaxLength,
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Data", 1073741823));
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringMaxLength,
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("Config", 1073741823));
|
||||
ValidationRules.AddRule(
|
||||
Csla.Validation.CommonRules.StringMaxLength,
|
||||
new Csla.Validation.CommonRules.MaxLengthRuleArgs("GenMac", 1073741823));
|
||||
@@ -747,13 +771,14 @@ namespace VEPROMS.CSLA.Library
|
||||
tmp.Data = data;
|
||||
return tmp;
|
||||
}
|
||||
public static Format New(Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID)
|
||||
public static Format New(Format myParent, string name, string description, string data, string config, string genMac, DateTime dts, string userID)
|
||||
{
|
||||
Format tmp = Format.New();
|
||||
tmp.MyParent = myParent;
|
||||
tmp.Name = name;
|
||||
tmp.Description = description;
|
||||
tmp.Data = data;
|
||||
tmp.Config = config;
|
||||
tmp.GenMac = genMac;
|
||||
tmp.DTS = dts;
|
||||
tmp.UserID = userID;
|
||||
@@ -761,7 +786,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
public static Format MakeFormat(Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID)
|
||||
{
|
||||
Format tmp = Format.New(myParent, name, description, data, genMac, dts, userID);
|
||||
Format tmp = Format.New(myParent, name, description, data, null, genMac, dts, userID);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
else
|
||||
@@ -775,19 +800,20 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
public static Format New(Format myParent, string name, string description, string data, string genMac)
|
||||
public static Format New(Format myParent, string name, string description, string data, string config, string genMac)
|
||||
{
|
||||
Format tmp = Format.New();
|
||||
tmp.MyParent = myParent;
|
||||
tmp.Name = name;
|
||||
tmp.Description = description;
|
||||
tmp.Data = data;
|
||||
tmp.Config = config;
|
||||
tmp.GenMac = genMac;
|
||||
return tmp;
|
||||
}
|
||||
public static Format MakeFormat(Format myParent, string name, string description, string data, string genMac)
|
||||
{
|
||||
Format tmp = Format.New(myParent, name, description, data, genMac);
|
||||
Format tmp = Format.New(myParent, name, description, data, null, genMac);
|
||||
if (tmp.IsSavable)
|
||||
tmp = tmp.Save();
|
||||
else
|
||||
@@ -953,6 +979,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_Name = dr.GetString("Name");
|
||||
_Description = dr.GetString("Description");
|
||||
_Data = dr.GetString("Data");
|
||||
_Config = dr.GetString("Config");
|
||||
_GenMac = dr.GetString("GenMac");
|
||||
_DTS = dr.GetDateTime("DTS");
|
||||
_UserID = dr.GetString("UserID");
|
||||
@@ -1094,6 +1121,7 @@ namespace VEPROMS.CSLA.Library
|
||||
cm.Parameters.AddWithValue("@Name", _Name);
|
||||
cm.Parameters.AddWithValue("@Description", _Description);
|
||||
cm.Parameters.AddWithValue("@Data", _Data);
|
||||
cm.Parameters.AddWithValue("@Config", _Config);
|
||||
cm.Parameters.AddWithValue("@GenMac", _GenMac);
|
||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||
@@ -1126,7 +1154,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Add(SqlConnection cn, ref int formatID, Format myParent, string name, string description, string data, string genMac, DateTime dts, string userID)
|
||||
public static byte[] Add(SqlConnection cn, ref int formatID, Format myParent, string name, string description, string data, string config, string genMac, DateTime dts, string userID)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Add", 0);
|
||||
try
|
||||
@@ -1141,6 +1169,7 @@ namespace VEPROMS.CSLA.Library
|
||||
cm.Parameters.AddWithValue("@Name", name);
|
||||
cm.Parameters.AddWithValue("@Description", description);
|
||||
cm.Parameters.AddWithValue("@Data", data);
|
||||
cm.Parameters.AddWithValue("@Config", config);
|
||||
cm.Parameters.AddWithValue("@GenMac", genMac);
|
||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||
cm.Parameters.AddWithValue("@UserID", userID);
|
||||
@@ -1208,6 +1237,7 @@ namespace VEPROMS.CSLA.Library
|
||||
cm.Parameters.AddWithValue("@Name", _Name);
|
||||
cm.Parameters.AddWithValue("@Description", _Description);
|
||||
cm.Parameters.AddWithValue("@Data", _Data);
|
||||
cm.Parameters.AddWithValue("@Config", _Config);
|
||||
cm.Parameters.AddWithValue("@GenMac", _GenMac);
|
||||
if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS);
|
||||
cm.Parameters.AddWithValue("@UserID", _UserID);
|
||||
@@ -1243,9 +1273,9 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"];
|
||||
if (IsNew)
|
||||
_LastChanged = Format.Add(cn, ref _FormatID, _MyParent, _Name, _Description, _Data, _GenMac, _DTS, _UserID);
|
||||
_LastChanged = Format.Add(cn, ref _FormatID, _MyParent, _Name, _Description, _Data, _Config, _GenMac, _DTS, _UserID);
|
||||
else
|
||||
_LastChanged = Format.Update(cn, ref _FormatID, _ParentID, _Name, _Description, _Data, _GenMac, _DTS, _UserID, ref _LastChanged);
|
||||
_LastChanged = Format.Update(cn, ref _FormatID, _ParentID, _Name, _Description, _Data, _Config, _GenMac, _DTS, _UserID, ref _LastChanged);
|
||||
MarkOld();
|
||||
}
|
||||
if (_FormatFolders != null) _FormatFolders.Update(this);
|
||||
@@ -1264,7 +1294,7 @@ namespace VEPROMS.CSLA.Library
|
||||
MarkNew();
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
public static byte[] Update(SqlConnection cn, ref int formatID, int parentID, string name, string description, string data, string genMac, DateTime dts, string userID, ref byte[] lastChanged)
|
||||
public static byte[] Update(SqlConnection cn, ref int formatID, int parentID, string name, string description, string data, string config, string genMac, DateTime dts, string userID, ref byte[] lastChanged)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Format.Update", 0);
|
||||
try
|
||||
@@ -1280,6 +1310,7 @@ namespace VEPROMS.CSLA.Library
|
||||
cm.Parameters.AddWithValue("@Name", name);
|
||||
cm.Parameters.AddWithValue("@Description", description);
|
||||
cm.Parameters.AddWithValue("@Data", data);
|
||||
cm.Parameters.AddWithValue("@Config", config);
|
||||
cm.Parameters.AddWithValue("@GenMac", genMac);
|
||||
if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts);
|
||||
cm.Parameters.AddWithValue("@UserID", userID);
|
||||
|
@@ -152,6 +152,16 @@ namespace VEPROMS.CSLA.Library
|
||||
return _Data;
|
||||
}
|
||||
}
|
||||
private string _Config = string.Empty;
|
||||
public string Config
|
||||
{
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
get
|
||||
{
|
||||
CanReadProperty("Config", true);
|
||||
return _Config;
|
||||
}
|
||||
}
|
||||
private string _GenMac = string.Empty;
|
||||
public string GenMac
|
||||
{
|
||||
@@ -417,6 +427,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_Name = tmp.Name;
|
||||
_Description = tmp.Description;
|
||||
_Data = tmp.Data;
|
||||
_Config = tmp.Config;
|
||||
_GenMac = tmp.GenMac;
|
||||
_DTS = tmp.DTS;
|
||||
_UserID = tmp.UserID;
|
||||
@@ -483,6 +494,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_Name = dr.GetString("Name");
|
||||
_Description = dr.GetString("Description");
|
||||
_Data = dr.GetString("Data");
|
||||
_Config = dr.GetString("Config");
|
||||
_GenMac = dr.GetString("GenMac");
|
||||
_DTS = dr.GetDateTime("DTS");
|
||||
_UserID = dr.GetString("UserID");
|
||||
|
@@ -103,6 +103,7 @@ namespace VEPROMS.CSLA.Library
|
||||
public static void Reset()
|
||||
{
|
||||
_FormatInfoList = null;
|
||||
_SortedFormatInfoList = null;
|
||||
}
|
||||
// CSLATODO: Add alternative gets -
|
||||
//public static FormatInfoList Get(<criteria>)
|
||||
|
Reference in New Issue
Block a user