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:
parent
b83ec3520b
commit
55a78eb845
@ -13,6 +13,7 @@ using DevComponents.DotNetBar.Controls;
|
||||
using System.Drawing.Imaging;
|
||||
using VEPROMS.Properties;
|
||||
using DescriptiveEnum;
|
||||
using Volian.Controls.Library;
|
||||
|
||||
namespace VEPROMS
|
||||
{
|
||||
@ -150,8 +151,8 @@ namespace VEPROMS
|
||||
ppCmbxFormat.DataSource = null;
|
||||
ppCmbxFormat.DisplayMember = "FullName";
|
||||
ppCmbxFormat.ValueMember = "FullName";
|
||||
ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList;
|
||||
if (_FolderConfig != null && _FolderConfig.MyFolder != null) _cmbxformatOriginal = _FolderConfig.MyFolder.FormatID;
|
||||
ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList);
|
||||
if (_FolderConfig != null && _FolderConfig.MyFolder != null) _cmbxformatOriginal = _FolderConfig.MyFolder.FormatID;
|
||||
if (_FolderConfig.FormatSelection != null)
|
||||
{
|
||||
ppCmbxFormat.SelectedValue = _FolderConfig.FormatSelection;
|
||||
|
@ -18,7 +18,6 @@ namespace VEPROMS
|
||||
{
|
||||
public partial class frmProcedureProperties : DevComponents.DotNetBar.Office2007Form
|
||||
{
|
||||
private readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private bool _Initializing = false;
|
||||
private string _DefaultFormatName = null;
|
||||
//private string _DefaultPagination = null;
|
||||
@ -189,7 +188,7 @@ namespace VEPROMS
|
||||
ppCmbxFormat.ValueMember = "FullName";
|
||||
|
||||
//C2023-017: Retrieves a filtered list of formats for the current plant
|
||||
ppCmbxFormat.DataSource = PopulateFormatList(FormatInfoList.SortedFormatInfoList);
|
||||
ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList);
|
||||
if (_ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat != null) _cmbxformatOriginal = _ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat.FormatID;
|
||||
if (_ProcedureConfig.FormatSelection != null)
|
||||
ppCmbxFormat.SelectedValue = _ProcedureConfig.FormatSelection;
|
||||
@ -259,51 +258,6 @@ namespace VEPROMS
|
||||
|
||||
}
|
||||
|
||||
//C2023-017: Remove any formats that are not applicable to the current plant
|
||||
private IList<FormatInfo> PopulateFormatList(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;
|
||||
}
|
||||
|
||||
#region General tab
|
||||
|
||||
/// <summary>
|
||||
|
@ -364,7 +364,7 @@ namespace VEPROMS
|
||||
ppCmbxFormat.DataSource = null;
|
||||
ppCmbxFormat.DisplayMember = "FullName";
|
||||
ppCmbxFormat.ValueMember = "FullName";
|
||||
ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList;
|
||||
ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList);
|
||||
if (_SectionConfig.MySection.MySectionInfo.ActiveFormat != null) _cmbxformatOriginal = (int)_SectionConfig.MySection.MySectionInfo.ActiveFormat.FormatID;
|
||||
if (_SectionConfig.FormatSelection != null)
|
||||
ppCmbxFormat.SelectedValue = _SectionConfig.FormatSelection;
|
||||
|
@ -168,7 +168,7 @@ namespace VEPROMS
|
||||
ppCmbxFormat.DataSource = null;
|
||||
ppCmbxFormat.DisplayMember = "FullName";
|
||||
ppCmbxFormat.ValueMember = "FullName";
|
||||
ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList;
|
||||
ppCmbxFormat.DataSource = FormatUtility.GetFilteredFormatList(FormatInfoList.SortedFormatInfoList);
|
||||
_cmbxformatOriginal = _DocVersionConfig.MyDocVersion.FormatID;
|
||||
|
||||
if (_DocVersionConfig.FormatSelection != null)
|
||||
|
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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user