Merge pull request 'C2023-017: Added logic to filter the format list when selecting a format to be applied to a section' (#126) from C2023-017 into Development

Code review completed.  Merging into Development.
This commit is contained in:
2023-10-03 11:34:24 -04:00
8 changed files with 1052 additions and 767 deletions

View File

@@ -0,0 +1,61 @@
using Csla;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using VEPROMS.CSLA.Library;
namespace Volian.Controls.Library
{
public static class FormatUtility
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//C2023-017: Remove any formats that are not applicable to the current plant
public static IList<FormatInfo> GetFilteredFormatList(SortedBindingList<FormatInfo> RawList)
{
List<FormatInfo> result = new List<FormatInfo>();
try
{
//Get the top folder configuration XML of the PROMS treeview and load
//the Formats node to retrieve the available formats for this plant
FolderInfo fi = FolderInfo.GetTop();
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.LoadXml(fi.Config);
XmlNodeList fList = xDoc.GetElementsByTagName("Formats");
//We need to check to see if the current database has been updated with the necessary changes
//to the folder configuration value. If so then build the list of available to be returned
//to the calling code
if (fList == null)
{
_MyLog.InfoFormat("Filtered format list not available: Database update needed for config value of top folder record");
return RawList;
}
else
{
//Create a string array that we can use to filter the raw list and add the format to the return value
string[] availableFormats = fList[0].Attributes["Active"].Value.Split(',');
foreach (FormatInfo item in RawList)
{
if (Array.IndexOf(availableFormats, item.ApplicablePlant.ToString()) > -1)
{
result.Add(item);
}
}
}
}
catch (Exception ex)
{
//On any exception simply return the original list that was passed in
_MyLog.ErrorFormat("Error loading filtered format list - PopulateFormatList(): {0}", ex.Message);
return RawList;
}
return result;
}
}
}

View File

@@ -240,6 +240,7 @@
<Compile Include="FindReplace.designer.cs">
<DependentUpon>FindReplace.cs</DependentUpon>
</Compile>
<Compile Include="FormatUtility.cs" />
<Compile Include="frmEnhanced.cs">
<SubType>Form</SubType>
</Compile>