C2023-017: Added logic to filter the format list when selecting a format to be applied to a section

This commit is contained in:
Chris Glavan 2023-10-02 09:03:15 -04:00
parent 350b943066
commit b83ec3520b
2 changed files with 822 additions and 761 deletions

View File

@ -11,11 +11,14 @@ using DescriptiveEnum;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using Volian.Controls.Library;
using System.Xml;
using Csla;
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;
@ -184,7 +187,9 @@ namespace VEPROMS
ppCmbxFormat.DataSource = null;
ppCmbxFormat.DisplayMember = "FullName";
ppCmbxFormat.ValueMember = "FullName";
ppCmbxFormat.DataSource = FormatInfoList.SortedFormatInfoList;
//C2023-017: Retrieves a filtered list of formats for the current plant
ppCmbxFormat.DataSource = PopulateFormatList(FormatInfoList.SortedFormatInfoList);
if (_ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat != null) _cmbxformatOriginal = _ProcedureConfig.MyProcedure.MyProcedureInfo.ActiveFormat.FormatID;
if (_ProcedureConfig.FormatSelection != null)
ppCmbxFormat.SelectedValue = _ProcedureConfig.FormatSelection;
@ -254,6 +259,51 @@ 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>

View File

@ -192,6 +192,16 @@ namespace VEPROMS.CSLA.Library
return _UserID;
}
}
private int _ApplicablePlant = 0;
public int ApplicablePlant
{
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
get
{
CanReadProperty("ApplicablePlant", true);
return _ApplicablePlant;
}
}
private int _FormatContentCount = 0;
/// <summary>
/// Count of FormatContents for this Format
@ -518,6 +528,7 @@ namespace VEPROMS.CSLA.Library
_FormatDocVersionCount = dr.GetInt32("DocVersionCount");
_FormatFolderCount = dr.GetInt32("FolderCount");
_ChildFormatCount = dr.GetInt32("ChildCount");
_ApplicablePlant = dr.GetInt32("ApplicablePlant");
}
catch (Exception ex)
{