From 28c681a5623d73c4fc0c07c2ad90ca60b33bd2c3 Mon Sep 17 00:00:00 2001 From: mschill Date: Fri, 1 Aug 2025 13:53:08 -0400 Subject: [PATCH] C2025-024 Electronic Procedures Phase 2 - XML Export Enhanced Doc Links --- PROMS/Formats/Formats.csproj | 1 + PROMS/Formats/fmtall/EPTSTBCK1all.xml | Bin 0 -> 51866 bytes .../VEPROMS User Interface/dlgExportImport.cs | 16 +- .../dlgExportImportEP.cs | 13 + .../Format/EPFormatFile.cs | 744 +++++++++--------- .../frmEPAnnotationDetails.cs | 6 +- 6 files changed, 408 insertions(+), 372 deletions(-) create mode 100644 PROMS/Formats/fmtall/EPTSTBCK1all.xml diff --git a/PROMS/Formats/Formats.csproj b/PROMS/Formats/Formats.csproj index e950a1ee..c1ca80da 100644 --- a/PROMS/Formats/Formats.csproj +++ b/PROMS/Formats/Formats.csproj @@ -180,6 +180,7 @@ + diff --git a/PROMS/Formats/fmtall/EPTSTBCK1all.xml b/PROMS/Formats/fmtall/EPTSTBCK1all.xml new file mode 100644 index 0000000000000000000000000000000000000000..4fd3f7b2ee3f41bf4d8708686d768f6b97ebef93 GIT binary patch literal 51866 zcmeI5*>fC6a>hISCWjs22S506EQdCBH5nr zy{z`Dz3M-z&#SA|m(|z$f222i)wZ5L)!V)5dHwcHbyPj8uBg;4mHA8c=jtD;zpw68 z|EgzKsx`H>UmfW8OVvKAw)E+pT3S{8XL@s}UbpnzdK;<6s9LUTysPUxuU_cwsJbQ! zu2nbni4s4m#IEXWsg+T+qTfd~)z;5gpU2go^oCxxMg6E+Qh7!P9oFW!{)>`~mr*}e zNoe*Ftf>Y)997>(l-k?RG{O~)E`Ia9+TN}E9#xN2^R+(1zfG0g&~GSR)9<(re|fFX zCp~{wb+taK?$v#4*JC+2;T=7tEpLj`2P!*~Y>-||Q%?J4O(BvtJ)r!O#=fVKBQ=+h zx49}R=STm>^f{*?aN^J609phe;xXN; zDcQ=#(wDz*;EnVF8KH-x>aPCZu3kwa(9$;=?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e5{+f!@Z%t`f59t*M}WTeK#66>P~<5ZHPIY_9Pd1Rlc6G-)pz3LcGpz z@5Xw5xxJz_t?)Sw+`e*czAtoJoU_xvZE+{=qkYVr>+*=2eD1!Mn$G%{S-boO8t35r z^K9PsHJvJ$u4x~eRW2?=6=99+AHzWF#T;jDJ@txetk(`1cxcU%k9{MJz9# z1=>%84)?A;#I63emDy*N?bEkTx zIl>2RqYSa8pf$|=ajsI!D{!DYT|{o5*Yr{Asxo$%CkAi0#ZUAXS)dc#>8F(Et@EDq z_qWuJwc;hxT!J^X`-8V^WvESFi<}lRd3%{W0|1&r?hyEjw#6f5tmbQv)F$zeu}0~+ zOI`Y->ID&evo25;-~LC-FH0atY^JaCU`^PyJUgU`Tb?gQ zg(uZ?D(yS@s`h;;WV;?IPvJ|Ie4$TqT%1_Ksyy59%{CUTB>VPj#lwk56D2(T4#j{C z7X=&2Q;F@^aDMk7`$f~-&gVgk>H8+PC-*+uRyfxuXcJpAtHn=mb+f2_`MzFBpS{rm zc`gd_lqW9Qk;is-K14>~en@k1;wc|y4HRS9e4fedn81!D2*4h$`6YY<$eY?b!H2<9 z340%wb=h_TOFzcGiM5{}GpuoDJE?KLYn%a177?AjSZLCOG=9R1cWd=22qN&z9EbHC J$Row*{~r$9As_$% literal 0 HcmV?d00001 diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 93ad460c..5e56d913 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -1824,7 +1824,7 @@ namespace VEPROMS //item audits ExportItemAudits(xe, ii); - ExportContent(xe, ii.MyContent, "content"); + ExportContent(xe, ii, "content"); if (ii.ItemAnnotationCount > 0) foreach (AnnotationInfo ai in ii.ItemAnnotations) @@ -1844,6 +1844,11 @@ namespace VEPROMS //do nothing - this will be for Electronic procedures only //and handled/overridden in dlgExportEP.cs } + protected virtual void SetEPEnhancedDocLinks(ref XmlElement xe, ItemInfo ii) + { + //do nothing - this will be for Electronic procedures only + //and handled/overridden in dlgExportEP.cs + } //C2025-024 Electronic Procedures Phase 2 - XML Export //use overridden method to set the location for ROs @@ -1908,8 +1913,9 @@ namespace VEPROMS } } - private void ExportContent(XmlElement xn, ContentInfo ci, string nodename) + private void ExportContent(XmlElement xn, ItemInfo ii, string nodename) { + ContentInfo ci = ii.MyContent; /* ContentID Number @@ -1939,7 +1945,11 @@ namespace VEPROMS xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ci.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ci.UserID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatfilename", formatFileName)); - if (_ExportBothConvertedandNot) xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "textwithlinks", ci.Text)); + if (_ExportBothConvertedandNot) + { + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "textwithlinks", ci.Text)); + SetEPEnhancedDocLinks(ref xe, ii); + } //content audits ExportContentAudits(xe, ci); diff --git a/PROMS/VEPROMS User Interface/dlgExportImportEP.cs b/PROMS/VEPROMS User Interface/dlgExportImportEP.cs index a310e864..07151940 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImportEP.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImportEP.cs @@ -322,6 +322,19 @@ namespace VEPROMS if (!string.IsNullOrEmpty(imgfile)) xindivid.Attributes.SetNamedItem(AddAttribute(xindivid.OwnerDocument, "Location", imgfile)); } + //overridden - used to set specific enhanced doc info + protected override void SetEPEnhancedDocLinks(ref XmlElement xe, ItemInfo ii) + { + EnhancedDocuments eds = ii.GetMyEnhancedDocuments(); + + if (eds != null && eds.Count == 1) + { + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "EnhancedDocType", eds[0].Type.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "EnhancedDocToItemID", eds[0].ItemID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "EnhancedDocToDbSeq", dbSeq(eds[0].ItemID))); + } + } + //clear objects to release memory private void OnClose(object sender, EventArgs e) { diff --git a/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs b/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs index 9bdb1720..1d75f875 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs @@ -11,157 +11,157 @@ using static VEPROMS.CSLA.Library.ROFSTLookup; namespace VEPROMS.CSLA.Library { - //C2025-023 - Electronic Procedures - Modifications to PROMS - // class to handle storage and access of EPFormatFile and EPFormatFile details - #region EPFormatFiles - [TypeConverter(typeof(vlnListConverter))] - public class EPFormatFiles : vlnFormatList - { - public EPFormatFiles(XmlNodeList xmlNodeList) : base(xmlNodeList) { } - } - #endregion - #region EPFormatFile - public class EPFormatFile : vlnFormatItem - { - #region Constructor - public EPFormatFile(XmlNode xmlNode) : base(xmlNode) { } - public EPFormatFile() : base() { } - #endregion - #region Business Fields - // Name of the EP Viewer Format File - private LazyLoad _Name; - [DisplayName("Name")] - [Description("EP Viewer File Name")] - public string Name - { - get - { - return LazyLoad(ref _Name, "@Name"); - } - } - // Name of the EP Viewer Format File - private LazyLoad _Description; - [DisplayName("Description")] - [Description("EP Viewer Description")] - public string Description - { - get - { - return LazyLoad(ref _Description, "@Description"); - } - } - // Id of Annotation Type Associated with this file - private LazyLoad _AnnotationTypeID; - [DisplayName("AnnotationTypeID")] - [Description("Id of Annotation Type Associated with this file")] - public int? AnnotationTypeID - { - get - { - return LazyLoad(ref _AnnotationTypeID, "@AnnotationTypeID"); - } - } + //C2025-023 - Electronic Procedures - Modifications to PROMS + // class to handle storage and access of EPFormatFile and EPFormatFile details + #region EPFormatFiles + [TypeConverter(typeof(vlnListConverter))] + public class EPFormatFiles : vlnFormatList + { + public EPFormatFiles(XmlNodeList xmlNodeList) : base(xmlNodeList) { } + } + #endregion + #region EPFormatFile + public class EPFormatFile : vlnFormatItem + { + #region Constructor + public EPFormatFile(XmlNode xmlNode) : base(xmlNode) { } + public EPFormatFile() : base() { } + #endregion + #region Business Fields + // Name of the EP Viewer Format File + private LazyLoad _Name; + [DisplayName("Name")] + [Description("EP Viewer File Name")] + public string Name + { + get + { + return LazyLoad(ref _Name, "@Name"); + } + } + // Name of the EP Viewer Format File + private LazyLoad _Description; + [DisplayName("Description")] + [Description("EP Viewer Description")] + public string Description + { + get + { + return LazyLoad(ref _Description, "@Description"); + } + } + // Id of Annotation Type Associated with this file + private LazyLoad _AnnotationTypeID; + [DisplayName("AnnotationTypeID")] + [Description("Id of Annotation Type Associated with this file")] + public int? AnnotationTypeID + { + get + { + return LazyLoad(ref _AnnotationTypeID, "@AnnotationTypeID"); + } + } - // Return Name of Annotation that EP Format File is Attached to - public string AnnotationName() - { - return AnnotationTypeInfo.Get((int) AnnotationTypeID).Name; - } + // Return Name of Annotation that EP Format File is Attached to + public string AnnotationName() + { + return AnnotationTypeInfo.Get((int) AnnotationTypeID).Name; + } - //if xml value is blank, should element export? - //defaults to true - private LazyLoad _exportblank; - [DisplayName("exportblank")] - [Description("if xml value is blank, should element export?")] - public bool exportblank - { - get - { - return LazyLoad(ref _exportblank, "@exportblank"); - } - } - // returns a list of fields that are defined in the EP format's structure - private EPFields _FieldList; - public EPFields FieldList - { - get - { - XmlDocument xd = GetEPFormatData(Name); - return _FieldList == null ? _FieldList = new EPFields(xd.SelectNodes("/EPFormat/EPField")) : _FieldList; - } - } - #endregion - #region Business Methods - // update all in-use annotation types that have Electronic Procedures - public static void UpdateAllInUseEPAnnotationTypes() - { - foreach (int formatid in GetAllInUseFormats()) - { - PlantFormat frmt = FormatInfo.Get(formatid).PlantFormat; - foreach (EPFormatFile EP in frmt.EPFormatFiles) + //if xml value is blank, should element export? + //defaults to true + private LazyLoad _exportblank; + [DisplayName("exportblank")] + [Description("if xml value is blank, should element export?")] + public bool exportblank + { + get + { + return LazyLoad(ref _exportblank, "@exportblank"); + } + } + // returns a list of fields that are defined in the EP format's structure + private EPFields _FieldList; + public EPFields FieldList + { + get + { + XmlDocument xd = GetEPFormatData(Name); + return _FieldList ?? (_FieldList = new EPFields(xd.SelectNodes("/EPFormat/EPField"))); + } + } + #endregion + #region Business Methods + // update all in-use annotation types that have Electronic Procedures + public static void UpdateAllInUseEPAnnotationTypes() + { + foreach (int formatid in GetAllInUseFormats()) + { + PlantFormat frmt = FormatInfo.Get(formatid).PlantFormat; + foreach (EPFormatFile EP in frmt.EPFormatFiles) { - UpdateAnnotationTypeAsEP((int) EP.AnnotationTypeID); - } - } - } - #endregion - #region Data Access - // static - Load EP Format details - save to db (insert/update) - public static void UpdateEPFormat(string name, string data, string userID) - { - using (SqlConnection cn = Database.VEPROMS_SqlConnection) - { - using (SqlCommand cm = cn.CreateCommand()) - { - cm.CommandType = CommandType.StoredProcedure; - cm.CommandText = "vesp_UpdateEPFormat"; - cm.Parameters.AddWithValue("@name", name); - cm.Parameters.AddWithValue("@data", data); - cm.Parameters.AddWithValue("@userID", userID); - cm.CommandTimeout = Database.DefaultTimeout; - cm.ExecuteNonQuery(); - } - } - } + UpdateAnnotationTypeAsEP((int) EP.AnnotationTypeID); + } + } + } + #endregion + #region Data Access + // static - Load EP Format details - save to db (insert/update) + public static void UpdateEPFormat(string name, string data, string userID) + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "vesp_UpdateEPFormat"; + cm.Parameters.AddWithValue("@name", name); + cm.Parameters.AddWithValue("@data", data); + cm.Parameters.AddWithValue("@userID", userID); + cm.CommandTimeout = Database.DefaultTimeout; + cm.ExecuteNonQuery(); + } + } + } - // load data for getting fieldlist for this EPFormat - public static XmlDocument GetEPFormatData(string name) - { - name = name.Replace(".xml", ""); + // load data for getting fieldlist for this EPFormat + public static XmlDocument GetEPFormatData(string name) + { + name = name.Replace(".xml", ""); - using (SqlConnection cn = Database.VEPROMS_SqlConnection) - { - using (SqlCommand cm = cn.CreateCommand()) - { - cm.CommandType = CommandType.Text; - cm.CommandText = "Select Data FROM EPFormats where Name = @Name"; - cm.Parameters.AddWithValue("@Name", name); - cm.CommandTimeout = Database.DefaultTimeout; - using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) - { - if (dr.Read()) - { - XmlDocument xd = new XmlDocument(); - xd.XmlResolver = null; - xd.LoadXml(dr.GetString("Data")); - return xd; - } - } - } - } + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.Text; + cm.CommandText = "Select Data FROM EPFormats where Name = @Name"; + cm.Parameters.AddWithValue("@Name", name); + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + if (dr.Read()) + { + XmlDocument xd = new XmlDocument(); + xd.XmlResolver = null; + xd.LoadXml(dr.GetString("Data")); + return xd; + } + } + } + } - return null; - } + return null; + } - // Get all in-use formats - public static List GetAllInUseFormats() - { - using (SqlConnection cn = Database.VEPROMS_SqlConnection) - { - using (SqlCommand cm = cn.CreateCommand()) - { - cm.CommandType = CommandType.Text; - cm.CommandText = @"SELECT Distinct Formats.[FormatID] + // Get all in-use formats + public static List GetAllInUseFormats() + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.Text; + cm.CommandText = @"SELECT Distinct Formats.[FormatID] FROM ( SELECT FormatID FROM Contents @@ -172,260 +172,272 @@ namespace VEPROMS.CSLA.Library ) inuse inner join Formats on inuse.FormatID = Formats.FormatID"; - cm.CommandTimeout = Database.DefaultTimeout; + cm.CommandTimeout = Database.DefaultTimeout; - using (DataTable dt = new DataTable()) - { - using (SqlDataAdapter da = new SqlDataAdapter(cm)) - { - da.Fill(dt); - return dt.AsEnumerable().Select(x => x.Field("FormatID")).ToList(); - } - } + using (DataTable dt = new DataTable()) + { + using (SqlDataAdapter da = new SqlDataAdapter(cm)) + { + da.Fill(dt); + return dt.AsEnumerable().Select(x => x.Field("FormatID")).ToList(); + } + } - } - } - } + } + } + } - // update an annotation type as an Electronic Procedure Annotation Type - public static void UpdateAnnotationTypeAsEP(int typeID) - { - using (SqlConnection cn = Database.VEPROMS_SqlConnection) - { - using (SqlCommand cm = cn.CreateCommand()) - { - cm.CommandType = CommandType.Text; - cm.CommandText = @"Update AnnotationTypes + // update an annotation type as an Electronic Procedure Annotation Type + public static void UpdateAnnotationTypeAsEP(int typeID) + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.Text; + cm.CommandText = @"Update AnnotationTypes SET IsEPAnnotationType = 1 WHERE TypeID = @typeID"; - cm.Parameters.AddWithValue("@typeID", typeID); - cm.CommandTimeout = Database.DefaultTimeout; - cm.ExecuteNonQuery(); - } - } - } + cm.Parameters.AddWithValue("@typeID", typeID); + cm.CommandTimeout = Database.DefaultTimeout; + cm.ExecuteNonQuery(); + } + } + } - // Returns true if there are any EP Annotation Types - public static bool IsEPAnnotationType() - { - try - { - using (SqlConnection cn = Database.VEPROMS_SqlConnection) - { - using (SqlCommand cm = cn.CreateCommand()) - { - cm.CommandType = CommandType.Text; - cm.CommandText = @"SELECT RESULT = CASE WHEN + // Returns true if there are any EP Annotation Types + public static bool IsEPAnnotationType() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.Text; + cm.CommandText = @"SELECT RESULT = CASE WHEN EXISTS(SELECT 1 FROM AnnotationTypes where IsEPAnnotationType = 1) THEN 1 ELSE 0 END"; - cm.CommandTimeout = Database.DefaultTimeout; - using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) - { - if (dr.Read() && dr.GetInt32("RESULT") == 1) - return true; - } - } - } - } - catch - { - // EP Support has not yet been added for this DB - // IsEPAnnotationType does not exist - // need to run PROMS Fixes - // until then will ignore EP code - // instead of crashing for a field not found - } + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + if (dr.Read() && dr.GetInt32("RESULT") == 1) + return true; + } + } + } + } + catch + { + // EP Support has not yet been added for this DB + // IsEPAnnotationType does not exist + // need to run PROMS Fixes + // until then will ignore EP code + // instead of crashing for a field not found + } - return false; - } - #endregion - } + return false; + } + #endregion + } - public class EPFields : vlnFormatList - { + public class EPFields : vlnFormatList + { public EPFields() { } public EPFields(XmlNodeList xmlNodeList) : base(xmlNodeList) { } - } - // EP field class - public class EPField : vlnFormatItem - { - public EPField(XmlNode xmlNode) : base(xmlNode) { } - public EPField() : base() { } - private LazyLoad _name; - public string name - { - get - { - return LazyLoad(ref _name, "@name"); - } - } - private LazyLoad _type; - public string type - { - get - { - return LazyLoad(ref _type, "@type"); - } - } - private LazyLoad _label; - public string label - { - get - { - string tmp = LazyLoad(ref _label, "@label"); + } + // EP field class + public class EPField : vlnFormatItem + { + public EPField(XmlNode xmlNode) : base(xmlNode) { } + public EPField() : base() { } + private LazyLoad _name; + public string name + { + get + { + return LazyLoad(ref _name, "@name"); + } + } + private LazyLoad _type; + public string type + { + get + { + return LazyLoad(ref _type, "@type"); + } + } + private LazyLoad _label; + public string label + { + get + { + string tmp = LazyLoad(ref _label, "@label"); - if (string.IsNullOrEmpty(tmp)) - return LazyLoad(ref _name, "@name"); - else - return tmp; - } - } - private LazyLoad _text; - public string text - { - get - { - return LazyLoad(ref _text, "@text"); - } - } - //roid of group item that individual sub-items will be the choices for the list/combobox for ROSINGLE and ROMULTI - private LazyLoad _rosource; - public string rosource - { - get - { - return LazyLoad(ref _rosource, "@rosource"); - } - } - //the columns in the RO that will be included in the exports - private LazyLoad _returncols; - public List returncols() - { - try - { - string tmp = LazyLoad(ref _returncols, "@returncols"); + if (string.IsNullOrEmpty(tmp)) + return LazyLoad(ref _name, "@name"); + else + return tmp; + } + } + private LazyLoad _text; + public string text + { + get + { + return LazyLoad(ref _text, "@text"); + } + } + //roid of group item that individual sub-items will be the choices for the list/combobox for ROSINGLE and ROMULTI + private LazyLoad _rosource; + public string rosource + { + get + { + return LazyLoad(ref _rosource, "@rosource"); + } + } + //the columns in the RO that will be included in the exports + private LazyLoad _returncols; + public List returncols() + { + try + { + string tmp = LazyLoad(ref _returncols, "@returncols"); - if (string.IsNullOrEmpty(tmp)) - return new List(); - else - return tmp.Split(',').Select(p => p.Trim()).ToList(); - } - catch - { - throw new ArgumentException($"Error in returncols for EP file: {((EPFormatFile)MyParentFormat).Name}.xml, field: {name}"); - } - } + if (string.IsNullOrEmpty(tmp)) + return new List(); + else + return tmp.Split(',').Select(p => p.Trim()).ToList(); + } + catch + { + throw new ArgumentException($"Error in returncols for EP file, field: {name}"); + } + } - //number of lines for a multi-line text box to span - private LazyLoad _numlines; - public int numlines - { - get - { - int? tmp = LazyLoad(ref _numlines, "@numlines"); + //number of lines for a multi-line text box to span + private LazyLoad _numlines; + public int numlines + { + get + { + int? tmp = LazyLoad(ref _numlines, "@numlines"); - if (tmp == null) - return 1; + if (tmp == null) + return 1; - return (int) tmp; - } - } - //step types that the EPForma Item is valid for (as a list of types) - private LazyLoad _validforsteptypes; + return (int) tmp; + } + } + //step types that the EPForma Item is valid for (as a list of types) + private LazyLoad _validforsteptypes; public List validforsteptypes() - { - try - { - string tmp = LazyLoad(ref _validforsteptypes, "@validforsteptypes"); - return tmp.Split(',').Select(p => p.Trim()).ToList(); - } - catch - { - throw new ArgumentException($"Error in validforsteptypes for EP file: {((EPFormatFile) MyParentFormat).Name}.xml, field: {name}"); - } - } - public bool IsValidForStepType(string StepType) - { - List tmp = validforsteptypes(); - return tmp.Contains(StepType); - } + { + try + { + string tmp = LazyLoad(ref _validforsteptypes, "@validforsteptypes"); + return tmp.Split(',').Select(p => p.Trim()).ToList(); + } + catch + { + throw new ArgumentException($"Error in validforsteptypes for EP file, field: {name}"); + } + } + public bool IsValidForStepType(string StepType) + { + List tmp = validforsteptypes(); + return tmp.Contains(StepType); + } - //return a list of items based on the ROsource specified in the EPFormat File - //will return all RO items under the Group that's roid = the rosource - public List getROList(AnnotationInfo currAnn, bool includeblank) - { - if (string.IsNullOrEmpty(rosource)) - return new List(); + //return a list of items based on the ROsource specified in the EPFormat File + //will return all RO items under the Group that's roid = the rosource + public List getROList(AnnotationInfo currAnn, bool includeblank) + { + if (string.IsNullOrEmpty(rosource)) + return new List(); - try - { - DocVersionInfo MyDocVersion = currAnn.MyItem.MyDocVersion; - ROFSTLookup lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); + try + { + DocVersionInfo MyDocVersion = currAnn.MyItem.MyDocVersion; - string roid = FormatRoidKey(rosource, false); - rochild[] children = lookup.GetRoChildrenByRoid(roid); + if (MyDocVersion.DocVersionAssociations != null && MyDocVersion.DocVersionAssociations.Any()) + { + ROFSTLookup lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); - List mylist = children.Select(x => new ROListItem(x.title, x.roid.Substring(0, 12))).ToList(); - if (includeblank) - mylist.Insert(0, new ROListItem("", "")); + string roid = FormatRoidKey(rosource, false); + rochild[] children = lookup.GetRoChildrenByRoid(roid); - return mylist; - } - catch (Exception Ex) - { - throw new ArgumentException($"Error in rosource for EP file: {((EPFormatFile)MyParentFormat).Name}.xml, field: {name}"); - } - } + List mylist = children.Select(x => new ROListItem(x.title, x.roid.Substring(0, 12))).ToList(); + if (includeblank) + mylist.Insert(0, new ROListItem("", "")); - //return a list of values for the specified ROID - //given the EP items return columns - //will return all RO items under the Group that's roid = the rosource - public List getROValuesList(AnnotationInfo currAnn, string roid) - { - if (string.IsNullOrEmpty(roid)) - return new List(); + return mylist; + } + else + { + return new List + { + new ROListItem("", "") + }; + } - List values = new List(); - DocVersionInfo MyDocVersion = currAnn.MyItem.MyDocVersion; - ROFSTLookup lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); - rochild ro = lookup.GetRoChild(roid); + } + catch + { + throw new ArgumentException($"Error in rosource for EP file, field: {name}"); + } + } - List rtncols = returncols(); + //return a list of values for the specified ROID + //given the EP items return columns + //will return all RO items under the Group that's roid = the rosource + public List getROValuesList(AnnotationInfo currAnn, string roid) + { + if (string.IsNullOrEmpty(roid)) + return new List(); - if (rtncols.Count == 0) - { - values.Add(ro.value); - } - else - { - foreach (string rcol in rtncols) - { - rochild ro_indiv = Array.Find(ro.children, x => x.appid.EndsWith($".{rcol}")); - if (ro_indiv.value != null) values.Add(ro_indiv.value); - } - } + List values = new List(); + DocVersionInfo MyDocVersion = currAnn.MyItem.MyDocVersion; + ROFSTLookup lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); + rochild ro = lookup.GetRoChild(roid); - return values; + List rtncols = returncols(); - } - } + if (rtncols.Count == 0) + { + values.Add(ro.value); + } + else + { + foreach (string rcol in rtncols) + { + rochild ro_indiv = Array.Find(ro.children, x => x.appid.EndsWith($".{rcol}")); + if (ro_indiv.value != null) values.Add(ro_indiv.value); + } + } - #endregion - //C2025-023 - Electronic Procedures - Modifications to PROMS - // class to handle return of RO Lists - #region EPFormatFiles - public class ROListItem - { - public string Text { get; private set; } - public string Value { get; private set; } - public ROListItem(string _text, string _value) - { - Text = _text; Value = _value; - } - } - #endregion + return values; + + } + } + + #endregion + //C2025-023 - Electronic Procedures - Modifications to PROMS + // class to handle return of RO Lists + #region EPFormatFiles + public class ROListItem + { + public string Text { get; private set; } + public string Value { get; private set; } + public ROListItem(string _text, string _value) + { + Text = _text; Value = _value; + } + } + #endregion } diff --git a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs index a641fd1c..518e63c7 100644 --- a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs +++ b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs @@ -120,7 +120,7 @@ namespace Volian.Controls.Library foreach (string t in tmps) cmb.Items.Add(t.Trim()); string val = MyConfig.GetValue("EP", EP.name); if (val != null && val != "") cmb.SelectedItem = val; - cmb.DropDownWidth = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Length).First(), cmb.Font).Width + SystemInformation.VerticalScrollBarWidth; + cmb.DropDownWidth = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Length).FirstOrDefault(), cmb.Font).Width + SystemInformation.VerticalScrollBarWidth; cmb.Width = cmb.DropDownWidth; _DicComboBox.Add(EP.name, cmb); panelEP.Controls.Add(cmb, 1, panelEP.RowCount - 1); @@ -135,7 +135,7 @@ namespace Volian.Controls.Library cmb.ValueMember = "Value"; cmb.DataSource = tmps; cmb.DropDownStyle = ComboBoxStyle.DropDownList; - cmb.DropDownWidth = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).First().Text, cmb.Font).Width + SystemInformation.VerticalScrollBarWidth; + cmb.DropDownWidth = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).FirstOrDefault()?.Text, cmb.Font).Width + SystemInformation.VerticalScrollBarWidth; cmb.Width = cmb.DropDownWidth; _DicSingleRO.Add(EP.name, cmb); @@ -148,7 +148,7 @@ namespace Volian.Controls.Library List tmps = EP.getROList(currAnn, false); lb.DisplayMember = "Text"; lb.ValueMember = "Value"; - lb.Width = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).First().Text, lb.Font).Width + SystemInformation.VerticalScrollBarWidth; + lb.Width = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).FirstOrDefault()?.Text, lb.Font).Width + SystemInformation.VerticalScrollBarWidth; lb.DataSource = tmps; _DicMultiRO.Add(EP.name, lb);