Use ‘GetJustStage’ for Stage & StageInfo gets of data.

Provide methods to use ‘GetJustStage’ from application
Use ‘GetJustFormat’ for format infos
This commit is contained in:
Kathy Ruffing 2015-02-17 17:30:47 +00:00
parent 9671a394be
commit 3053c892a1
10 changed files with 191 additions and 13 deletions

View File

@ -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)

View File

@ -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<StageInfo>(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<Stage>(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
}
}

View File

@ -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)]

View File

@ -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;
}
}

View File

@ -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()))

View File

@ -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)]

View File

@ -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)]

View File

@ -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

View File

@ -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)]

View File

@ -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;
}
}