C2023-017:
~Moved original code for populating the filtered list to a separate static class named FormatUtility in Volian.Controls.Library ~Renamed method to GetFilteredFormatList ~Updated code to reference new static class and method ~Added logic to other applicable forms
This commit is contained in:
61
PROMS/Volian.Controls.Library/FormatUtility.cs
Normal file
61
PROMS/Volian.Controls.Library/FormatUtility.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user