diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index 84486e95..928fbb46 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -597,6 +597,7 @@ namespace VEPROMS.CSLA.Library cm.CommandType = CommandType.StoredProcedure; cm.CommandText = "getItem"; cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { if (!dr.Read()) @@ -681,6 +682,7 @@ namespace VEPROMS.CSLA.Library cm.CommandText = "vesp_ListItemAndChildren"; cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); cm.Parameters.AddWithValue("@ParentID", criteria.ParentID); + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) @@ -2808,7 +2810,7 @@ namespace VEPROMS.CSLA.Library //public void ToXml(XmlNode xn) //{ // foreach (ItemInfo itemInfo in this) - // { + // { // itemInfo.ToXml(xn); // } //} @@ -2833,6 +2835,40 @@ namespace VEPROMS.CSLA.Library throw new DbCslaException("Error on ItemInfoList.GetChildren", ex); } } + public static ItemInfoList GetListTranTo() + { + try + { + ItemInfoList tmp = DataPortal.Fetch(new ItemTranToListCriteria()); + ItemInfo.AddList(tmp); + tmp.AddEvents(); +#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList + ContentInfoList.GetList(itemID); // Performance - Load All Content +#endif + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on ItemInfoList.GetTranToList", ex); + } + } + public static ItemInfoList GetListTranFrom() + { + try + { + ItemInfoList tmp = DataPortal.Fetch(new ItemTranFromListCriteria()); + ItemInfo.AddList(tmp); + tmp.AddEvents(); +#if (!ItemWithContent) // If ItemWithContent is set, the content is returned with the ItemInfoList + ContentInfoList.GetList(itemID); // Performance - Load All Content +#endif + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on ItemInfoList.GetTranFromList", ex); + } + } public static ItemInfoList GetListByPartType(E_FromType fromType) { try @@ -2872,6 +2908,14 @@ namespace VEPROMS.CSLA.Library } } [Serializable()] + private class ItemTranToListCriteria + { + } + [Serializable()] + private class ItemTranFromListCriteria + { + } + [Serializable()] private class ItemListPartTypeCriteria { public ItemListPartTypeCriteria(E_FromType type) @@ -2901,6 +2945,7 @@ namespace VEPROMS.CSLA.Library cm.CommandText = "vesp_ListItems"; #endif cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) @@ -2933,6 +2978,102 @@ namespace VEPROMS.CSLA.Library } this.RaiseListChangedEvents = true; } + private void DataPortal_Fetch(ItemTranToListCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; +#if ItemWithContent + cm.CommandText = "vesp_ListItemsTranToAndContent"; +#else + cm.CommandText = "vesp_ListItemsTranTo"; +#endif + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + while (dr.Read()) + { + ItemInfo itemInfo = new ItemInfo(dr); + //switch ((E_FromType)criteria.Type) + //{ + // case E_FromType.Procedure: + // itemInfo = new ProcedureInfo(dr); + // break; + // case E_FromType.Section: + // itemInfo = new SectionInfo(dr); + // break; + // default: + // itemInfo = new StepInfo(dr); + // break; + //} + 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; + } + private void DataPortal_Fetch(ItemTranFromListCriteria criteria) + { + this.RaiseListChangedEvents = false; + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; +#if ItemWithContent + cm.CommandText = "vesp_ListItemsTranFromAndContent"; +#else + cm.CommandText = "vesp_ListItemsTranFrom"; +#endif + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + while (dr.Read()) + { + ItemInfo itemInfo = new ItemInfo(dr); + //switch ((E_FromType)criteria.Type) + //{ + // case E_FromType.Procedure: + // itemInfo = new ProcedureInfo(dr); + // break; + // case E_FromType.Section: + // itemInfo = new SectionInfo(dr); + // break; + // default: + // itemInfo = new StepInfo(dr); + // break; + //} + 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; + } private void DataPortal_Fetch(ItemListPartTypeCriteria criteria) { this.RaiseListChangedEvents = false; @@ -2949,6 +3090,7 @@ namespace VEPROMS.CSLA.Library cm.CommandText = "getItemsByPartType"; #endif cm.Parameters.AddWithValue("@FromType", (int) criteria.Type); + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) @@ -3086,7 +3228,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@IncludeRtfFormatting", criteria.IncludeRtfFormatting ? 1 : 0); cm.Parameters.AddWithValue("@IncludeSpecialCharacters", criteria.IncludeSpecialCharacters ? 1 : 0); cm.Parameters.AddWithValue("@UnitPrefix", criteria.UnitPrefix); - cm.CommandTimeout = 120; + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) @@ -3189,7 +3331,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@StepTypeList", criteria.StepTypeList); cm.Parameters.AddWithValue("@ROSearchString", criteria.ROSearchString); cm.Parameters.AddWithValue("@UnitPrefix", criteria.UnitPrefix); - cm.CommandTimeout = 120; + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { string FoundROs = ""; @@ -3310,7 +3452,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@SearchString", criteria.SearchString); cm.Parameters.AddWithValue("@CaseSensitive", criteria.CaseSensitive ? 1 : 0); cm.Parameters.AddWithValue("@UnitPrefix", criteria.UnitPrefix); - cm.CommandTimeout = 120; + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { while (dr.Read()) @@ -3416,7 +3558,7 @@ namespace VEPROMS.CSLA.Library cm.Parameters.AddWithValue("@StepTypeList", criteria.StepTypeList); cm.Parameters.AddWithValue("@ROSearchString", criteria.ROSearchString); cm.Parameters.AddWithValue("@UnitPrefix", criteria.UnitPrefix); - cm.CommandTimeout = 120; + cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) { string FoundROs = "";