From 52e1db8b0c1a516d34813d36efcb25d0882b0cca Mon Sep 17 00:00:00 2001 From: John Date: Thu, 27 Sep 2018 15:11:50 +0000 Subject: [PATCH] B2017-230 logic to call stored procedure that checks for the usage of a given applicability --- .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index de92f462..0e15dc1f 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -6474,6 +6474,153 @@ namespace VEPROMS.CSLA.Library this.RaiseListChangedEvents = true; } #endregion + #region Applicability Search + public static ItemInfoList GetListFromApplicabilitySearch(string docVersionList, string stepTypeList, string searchString, int caseSensitive, ItemSearchIncludeLinks includeLinks, bool includeRtfFormatting, bool includeSpecialCharacters, string unitPrefix, string applicSetting) + { + try + { + ItemInfoList tmp = DataPortal.Fetch(new ItemListApplicabilitySearchCriteria(docVersionList, stepTypeList, searchString, caseSensitive, includeLinks, includeRtfFormatting, includeSpecialCharacters, unitPrefix, applicSetting)); + tmp.SourceOfList = "Search"; + ItemInfo.AddList(tmp); + tmp.AddEvents(); + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on ItemInfoList.GetListFromApplicabilitySearch", ex); + } + } + [Serializable()] + private class ItemListApplicabilitySearchCriteria + { + private string _DocVersionList; + public string DocVersionList + { + get { return _DocVersionList; } + set { _DocVersionList = value; } + } + private string _StepTypeList; + public string StepTypeList + { + get { return _StepTypeList; } + set { _StepTypeList = value; } + } + private string _SearchString; + public string SearchString + { + get { return _SearchString; } + set { _SearchString = value; } + } + private int _CaseSensitive; + public int CaseSensitive + { + get { return _CaseSensitive; } + set { _CaseSensitive = value; } + } + private ItemSearchIncludeLinks _IncludeLinks; + public ItemSearchIncludeLinks IncludeLinks + { + get { return _IncludeLinks; } + set { _IncludeLinks = value; } + } + private bool _IncludeRtfFormatting; + public bool IncludeRtfFormatting + { + get { return _IncludeRtfFormatting; } + set { _IncludeRtfFormatting = value; } + } + private bool _IncludeSpecialCharacters; + public bool IncludeSpecialCharacters + { + get { return _IncludeSpecialCharacters; } + set { _IncludeSpecialCharacters = value; } + } + private string _UnitPrefix; + + public string UnitPrefix + { + get { return _UnitPrefix; } + set { _UnitPrefix = value; } + } + private string _ApplicSetting; + + public string ApplicSetting + { + get { return _ApplicSetting; } + set { _ApplicSetting = value; } + } + public ItemListApplicabilitySearchCriteria(string docVersionList, string stepTypeList, string searchString, + int caseSensitive, ItemSearchIncludeLinks includeLinks, bool includeRtfFormatting, bool includeSpecialCharacters, string unitPrefix, string applicSetting) + { + _DocVersionList = docVersionList; + _StepTypeList = stepTypeList; + _SearchString = searchString; + _CaseSensitive = caseSensitive; + _IncludeLinks = includeLinks; + _IncludeRtfFormatting = includeRtfFormatting; + _IncludeSpecialCharacters = includeSpecialCharacters; + _UnitPrefix = unitPrefix; + _ApplicSetting = applicSetting; + } + } + private void DataPortal_Fetch(ItemListApplicabilitySearchCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "vesp_SearchSepcifiedApplicability"; + cm.Parameters.AddWithValue("@DocVersionList", criteria.DocVersionList); + cm.Parameters.AddWithValue("@StepTypeList", criteria.StepTypeList); + cm.Parameters.AddWithValue("@SearchString", criteria.SearchString); + cm.Parameters.AddWithValue("@CaseSensitive", criteria.CaseSensitive); + cm.Parameters.AddWithValue("@IncludeLinks", (int)criteria.IncludeLinks); + cm.Parameters.AddWithValue("@IncludeRtfFormatting", criteria.IncludeRtfFormatting ? 1 : 0); + cm.Parameters.AddWithValue("@IncludeSpecialCharacters", criteria.IncludeSpecialCharacters ? 1 : 0); + cm.Parameters.AddWithValue("@UnitPrefix", criteria.UnitPrefix); + cm.Parameters.AddWithValue("@ApplicSetting", criteria.ApplicSetting); + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + while (dr.Read()) + { + ItemInfo itemInfo = null; + int itemType = dr.GetInt32("Type") / 10000; + switch (itemType) + { + case 0: + itemInfo = new ProcedureInfo(dr); + break; + case 1: + itemInfo = new SectionInfo(dr); + break; + default: + itemInfo = new StepInfo(dr); + break; + } + itemInfo.AddContent(dr); + itemInfo._SearchDVPath = dr.GetString("DVPath"); + itemInfo._SearchPath = dr.GetString("Path"); + IsReadOnly = false; + this.Add(itemInfo); + IsReadOnly = true; + } + } + } + } + } + catch (Exception ex) + { + Database.LogException("ItemInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("ItemInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion } #endregion #region new class TransitionLookup