diff --git a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs index 773e310c..6e87068d 100644 --- a/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs +++ b/PROMS/VEPROMS User Interface/dlgApproveProcedure.cs @@ -977,7 +977,7 @@ namespace VEPROMS { ViewPDF = ViewPDF && MyProcedures.Count == 1; StringBuilder sb = new StringBuilder(); - StageInfo nsi = StageInfo.Get(RevStage); + StageInfo nsi = StageInfo.GetJustStage(RevStage); foreach (ApprovalProcedure ap in MyProcedures) //spin thru looking for updating current revision { //RevisionInfo ric = RevisionInfo.GetCurrentByItemID(ap.ProcInfo.ItemID); @@ -1092,11 +1092,11 @@ namespace VEPROMS } } DateTime currentDTS = DateTime.Now; - Check check = Check.MakeCheck(revision, Stage.Get(RevStage), RevisionInfo.BuildRevisionChecks(pi), currentDTS, VlnSettings.UserID); + Check check = Check.MakeCheck(revision, Stage.GetJustStage(RevStage), RevisionInfo.BuildRevisionChecks(pi), currentDTS, VlnSettings.UserID); //make pdf with promsprinter and get byte stream // Moved to end so that Item and Content are saved at the same time //UpdateProcedureConfig(pi, ap.RevNumber, ap.RevDate, myDTS); - string waterMark = Stage.Get(RevStage).IsApproved > 0 ? null : Stage.Get(RevStage).Name; + string waterMark = Stage.GetJustStage(RevStage).IsApproved > 0 ? null : Stage.GetJustStage(RevStage).Name; //ProcedureInfo myproc = pi; //frmPDFStatusForm frm = new frmPDFStatusForm(myproc, ap.RevNumber, /* revdate change: ap.RevDate.ToString("MM/dd/yyyy") ,*/ waterMark, false, false, ViewPDF, true, VlnSettings.TemporaryFolder, new ChangeBarDefinition(pi.MyDocVersion.MyConfig as DocVersionConfig, pi.ActiveFormat), pdfTmp, location); //myproc.ChangeBarDate = myDTS; @@ -1133,8 +1133,8 @@ namespace VEPROMS byte[] buf = new byte[pdfFile.Length]; fs.Read(buf, 0, buf.Length); fs.Close(); - VEPROMS.CSLA.Library.Version version = VEPROMS.CSLA.Library.Version.MakeVersion(revision, Stage.Get(RevStage), buf, summaryBuf, currentDTS, VlnSettings.UserID); - StageInfo si = StageInfo.Get(RevStage); + VEPROMS.CSLA.Library.Version version = VEPROMS.CSLA.Library.Version.MakeVersion(revision, Stage.GetJustStage(RevStage), buf, summaryBuf, currentDTS, VlnSettings.UserID); + StageInfo si = StageInfo.GetJustStage(RevStage); int selectedSlave = pi.MyDocVersion.DocVersionConfig.SelectedSlave; pi.MyDocVersion.DocVersionConfig.SelectedSlave = 0; if (si.IsApproved == 1) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/StageExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/StageExt.cs new file mode 100644 index 00000000..b51e543e --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Extension/StageExt.cs @@ -0,0 +1,177 @@ +// ======================================================================== +// Copyright 2015 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +//using System.Collections.Generic; +//using System.Collections.Specialized; +//using System.Text; +//using System.IO; +//using System.Xml.Serialization; +//using System.Xml; +//using System.Xml.XPath; +using Csla; +using Csla.Data; +using System.Data.SqlClient; +using System.Data; + +namespace VEPROMS.CSLA.Library +{ + public partial class StageInfo + { + public static StageInfo GetJustStage(int stageID) + { + try + { + StageInfo tmp = GetCachedByPrimaryKey(stageID); + if (tmp == null) + { + tmp = DataPortal.Fetch(new PKCriteriaJustStage(stageID)); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up StageInfo + tmp = null; + } + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on StageInfo.GetJustStage", ex); + } + } + [Serializable()] + protected class PKCriteriaJustStage + { + private int _StageID; + public int StageID + { get { return _StageID; } } + public PKCriteriaJustStage(int stageID) + { + _StageID = stageID; + } + } + private void DataPortal_Fetch(PKCriteriaJustStage criteria) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] StageInfo.DataPortal_Fetch", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + ApplicationContext.LocalContext["cn"] = cn; + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getJustStage"; + cm.Parameters.AddWithValue("@StageID", criteria.StageID); + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + if (!dr.Read()) + { + _ErrorMessage = "No Record Found"; + return; + } + ReadData(dr); + } + } + // removing of item only needed for local data portal + if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) + ApplicationContext.LocalContext.Remove("cn"); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("StageInfo.DataPortal_Fetch", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("StageInfo.DataPortal_Fetch", ex); + } + } + } + public partial class Stage + { + public static Stage GetJustStage(int stageID) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Stage"); + try + { + Stage tmp = DataPortal.Fetch(new PKCriteriaJustStage(stageID)); + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up Stage + tmp = null; + } + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on Stage.GetJustStage", ex); + } + } + private void DataPortal_Fetch(PKCriteriaJustStage criteria) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] RODb.DataPortal_Fetch", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + ApplicationContext.LocalContext["cn"] = cn; + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getJustStage"; + cm.Parameters.AddWithValue("@StageID", criteria.StageID); + cm.CommandTimeout = Database.DefaultTimeout; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + if (!dr.Read()) + { + _ErrorMessage = "No Record Found"; + return; + } + ReadData(dr); + // Don't load child objects + //dr.NextResult(); + //_StageChecks = StageChecks.Get(dr); + // load child objects + //dr.NextResult(); + //_StageVersions = StageVersions.Get(dr); + } + } + // removing of item only needed for local data portal + if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) + ApplicationContext.LocalContext.Remove("cn"); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Stage.DataPortal_Fetch", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("Stage.DataPortal_Fetch", ex); + } + } + [Serializable()] + protected class PKCriteriaJustStage + { + private int _StageID; + public int StageID + { get { return _StageID; } } + public PKCriteriaJustStage(int stageID) + { + _StageID = stageID; + } + } + + #region Log4Net + private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + } +} diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Check.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Check.cs index 124643fe..e5026641 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Check.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Check.cs @@ -163,7 +163,7 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("MyStage", true); - if (_MyStage == null && _StageID != 0) _MyStage = Stage.Get(_StageID); + if (_MyStage == null && _StageID != 0) _MyStage = Stage.GetJustStage(_StageID); return _MyStage; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/CheckInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/CheckInfo.cs index 1d89de08..373e6a9b 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/CheckInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/CheckInfo.cs @@ -140,7 +140,7 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("MyStage", true); - if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.Get(_StageID); + if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.GetJustStage(_StageID); return _MyStage; } } diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs index 886ae58e..ee54e39a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/FormatInfo.cs @@ -509,7 +509,7 @@ namespace VEPROMS.CSLA.Library using (SqlCommand cm = cn.CreateCommand()) { cm.CommandType = CommandType.StoredProcedure; - cm.CommandText = "getFormat"; + cm.CommandText = "getJustFormat"; cm.Parameters.AddWithValue("@FormatID", criteria.FormatID); cm.CommandTimeout = Database.DefaultTimeout; using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RevisionCheck.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RevisionCheck.cs index 16fdd7d5..b2945bb7 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RevisionCheck.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RevisionCheck.cs @@ -78,7 +78,7 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("MyStage", true); - if (_MyStage == null && _StageID != 0) _MyStage = Stage.Get(_StageID); + if (_MyStage == null && _StageID != 0) _MyStage = Stage.GetJustStage(_StageID); return _MyStage; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/RevisionVersion.cs b/PROMS/VEPROMS.CSLA.Library/Generated/RevisionVersion.cs index ed9ec284..ed942885 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/RevisionVersion.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/RevisionVersion.cs @@ -78,7 +78,7 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("MyStage", true); - if (_MyStage == null && _StageID != 0) _MyStage = Stage.Get(_StageID); + if (_MyStage == null && _StageID != 0) _MyStage = Stage.GetJustStage(_StageID); return _MyStage; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/StageInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/StageInfo.cs index 3d0dbaba..3cdf1410 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/StageInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/StageInfo.cs @@ -287,7 +287,7 @@ namespace VEPROMS.CSLA.Library } public virtual Stage Get() { - return _Editable = Stage.Get(_StageID); + return _Editable = Stage.GetJustStage(_StageID); } public static void Refresh(Stage tmp) { @@ -400,6 +400,7 @@ namespace VEPROMS.CSLA.Library return; } ReadData(dr); + } } // removing of item only needed for local data portal diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Version.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Version.cs index a963c09b..62a0e9fe 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/Version.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Version.cs @@ -163,7 +163,7 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("MyStage", true); - if (_MyStage == null && _StageID != 0) _MyStage = Stage.Get(_StageID); + if (_MyStage == null && _StageID != 0) _MyStage = Stage.GetJustStage(_StageID); return _MyStage; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/VersionInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/VersionInfo.cs index 2a5733e4..c7cf43f4 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/VersionInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/VersionInfo.cs @@ -140,7 +140,7 @@ namespace VEPROMS.CSLA.Library get { CanReadProperty("MyStage", true); - if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.Get(_StageID); + if (_MyStage == null && _StageID != 0) _MyStage = StageInfo.GetJustStage(_StageID); return _MyStage; } }