Added reference to System.Collections.Generic
Added PurgeDataCommand class based on CSLA CommandBase class Added CanTransitionBeCreatedCommand class based on CSLA CommandBase class Added WillTransitionsBeValidCommand class based on CSLA CommandBase class Added InvalidTransition class Added ProposedTransition class Changed NodeText_Changed method to support multi unit Added BigNum class to support applicability for multi unit
This commit is contained in:
@@ -17,6 +17,8 @@ using System.Configuration;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
/// <summary>
|
||||
@@ -253,4 +255,312 @@ namespace VEPROMS.CSLA.Library
|
||||
internal DbCslaException(string message) : base(message) { ;}
|
||||
internal DbCslaException() : base() { ;}
|
||||
} // Class
|
||||
#region commandbase object jcb
|
||||
[Serializable()]
|
||||
public class PurgeDataCommand : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private int _RowsAffected;
|
||||
public int RowsAffected
|
||||
{
|
||||
get { return _RowsAffected; }
|
||||
set { _RowsAffected = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static int Execute()
|
||||
{
|
||||
PurgeDataCommand cmd = new PurgeDataCommand();
|
||||
cmd = DataPortal.Execute<PurgeDataCommand>(cmd);
|
||||
return cmd.RowsAffected;
|
||||
}
|
||||
private PurgeDataCommand()
|
||||
{ /* require use of factory methods */ }
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("purgedata", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
RowsAffected = cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Purge Error", ex);
|
||||
throw new ApplicationException("Failure on Purge", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
[Serializable()]
|
||||
public class CanTransitionBeCreatedCommand : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
private ProposedTransition _ProposedTransition;
|
||||
public ProposedTransition ProposedTransition
|
||||
{
|
||||
get { return _ProposedTransition; }
|
||||
set { _ProposedTransition = value; }
|
||||
}
|
||||
private int _FromID;
|
||||
public int FromID
|
||||
{
|
||||
get { return _FromID; }
|
||||
set { _FromID = value; }
|
||||
}
|
||||
private int _ToID;
|
||||
public int ToID
|
||||
{
|
||||
get { return _ToID; }
|
||||
set { _ToID = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static ProposedTransition Execute(int fromID, int toID)
|
||||
{
|
||||
CanTransitionBeCreatedCommand cmd = new CanTransitionBeCreatedCommand();
|
||||
cmd.FromID = fromID;
|
||||
cmd.ToID = toID;
|
||||
cmd = DataPortal.Execute<CanTransitionBeCreatedCommand>(cmd);
|
||||
return cmd.ProposedTransition;
|
||||
}
|
||||
private CanTransitionBeCreatedCommand()
|
||||
{ /* require use of factory methods */ }
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] CanTransitionBeCreatedCommand.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
_ProposedTransition = new ProposedTransition(dr.GetInt32("status"), dr.GetString("fromappl"), dr.GetString("toappl"), dr.GetString("fromstep"), dr.GetString("tostep"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Detail.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("CanTransitionBeCreatedCommand.ReadData", ex);
|
||||
}
|
||||
}
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_CanTransitionBeCreated", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.AddWithValue("fromItemID", _FromID);
|
||||
cmd.Parameters.AddWithValue("toItemID", _ToID);
|
||||
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("CanTransitionBeCreatedCommand Error", ex);
|
||||
throw new ApplicationException("Failure on CanTransitionBeCreatedCommand", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
[Serializable()]
|
||||
public class WillTransitionsBeValidCommand : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private string _ErrorMessage = string.Empty;
|
||||
public string ErrorMessage
|
||||
{
|
||||
get { return _ErrorMessage; }
|
||||
}
|
||||
private List<InvalidTransition> _InvalidTransitions;
|
||||
public List<InvalidTransition> InvalidTransitions
|
||||
{
|
||||
get { return _InvalidTransitions; }
|
||||
}
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
private string _NewAppl;
|
||||
public string NewAppl
|
||||
{
|
||||
get { return _NewAppl; }
|
||||
set { _NewAppl = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static List<InvalidTransition> Execute(int itemID, string newAppl)
|
||||
{
|
||||
WillTransitionsBeValidCommand cmd = new WillTransitionsBeValidCommand();
|
||||
cmd.ItemID = itemID;
|
||||
cmd.NewAppl = newAppl;
|
||||
cmd = DataPortal.Execute<WillTransitionsBeValidCommand>(cmd);
|
||||
return cmd.InvalidTransitions;
|
||||
}
|
||||
private WillTransitionsBeValidCommand()
|
||||
{ /* require use of factory methods */ }
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
private void ReadData(SafeDataReader dr)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Detail.ReadData", GetHashCode());
|
||||
try
|
||||
{
|
||||
do
|
||||
{
|
||||
_InvalidTransitions.Add(new InvalidTransition(dr.GetInt32("myitemid"), dr.GetString("srcappl"), dr.GetString("tgtappl"), dr.GetString("srcstep"), dr.GetString("tgtstep")));
|
||||
} while (dr.Read());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("WillTransitionsBeValidCommand.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("WillTransitionsBeValidCommand.ReadData", ex);
|
||||
}
|
||||
}
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
//SqlConnection cn = VEPROMS_SqlConnection;
|
||||
//SqlCommand cmd = new SqlCommand("purgedata", cn);
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_WillTransitionsBeValid", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.Parameters.AddWithValue("ItemID", _ItemID);
|
||||
cmd.Parameters.AddWithValue("NewAppl", _NewAppl);
|
||||
using (SafeDataReader dr = new SafeDataReader(cmd.ExecuteReader()))
|
||||
{
|
||||
_InvalidTransitions = new List<InvalidTransition>();
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("WillTransitionsBeValidCommand Error", ex);
|
||||
throw new ApplicationException("Failure on WillTransitionsBeValidCommand", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
[Serializable()]
|
||||
public class InvalidTransition
|
||||
{
|
||||
private int _MyItemID;
|
||||
public int MyItemID
|
||||
{
|
||||
get { return _MyItemID; }
|
||||
set { _MyItemID = value; }
|
||||
}
|
||||
private string _SrcAppl;
|
||||
public string SrcAppl
|
||||
{
|
||||
get { return _SrcAppl; }
|
||||
set { _SrcAppl = value; }
|
||||
}
|
||||
private string _TgtAppl;
|
||||
public string TgtAppl
|
||||
{
|
||||
get { return _TgtAppl; }
|
||||
set { _TgtAppl = value; }
|
||||
}
|
||||
private string _SrcStep;
|
||||
public string SrcStep
|
||||
{
|
||||
get { return _SrcStep; }
|
||||
set { _SrcStep = value; }
|
||||
}
|
||||
private string _TgtStep;
|
||||
public string TgtStep
|
||||
{
|
||||
get { return _TgtStep; }
|
||||
set { _TgtStep = value; }
|
||||
}
|
||||
public InvalidTransition(int myItemID, string srcAppl, string tgtAppl, string srcStep, string tgtStep)
|
||||
{
|
||||
_MyItemID = myItemID;
|
||||
_SrcAppl = srcAppl;
|
||||
_TgtAppl = tgtAppl;
|
||||
_SrcStep = srcStep;
|
||||
_TgtStep = tgtStep;
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
public class ProposedTransition
|
||||
{
|
||||
private int _Status;
|
||||
public int Status
|
||||
{
|
||||
get { return _Status; }
|
||||
set { _Status = value; }
|
||||
}
|
||||
private string _FromAppl;
|
||||
public string FromAppl
|
||||
{
|
||||
get { return _FromAppl; }
|
||||
set { _FromAppl = value; }
|
||||
}
|
||||
private string _ToAppl;
|
||||
public string ToAppl
|
||||
{
|
||||
get { return _ToAppl; }
|
||||
set { _ToAppl = value; }
|
||||
}
|
||||
private string _FromStep;
|
||||
public string FromStep
|
||||
{
|
||||
get { return _FromStep; }
|
||||
set { _FromStep = value; }
|
||||
}
|
||||
private string _ToStep;
|
||||
public string ToStep
|
||||
{
|
||||
get { return _ToStep; }
|
||||
set { _ToStep = value; }
|
||||
}
|
||||
public ProposedTransition(int status, string fromAppl, string toAppl, string fromStep, string toStep)
|
||||
{
|
||||
_Status = status;
|
||||
_FromAppl = fromAppl;
|
||||
_ToAppl = toAppl;
|
||||
_FromStep = fromStep;
|
||||
_ToStep = toStep;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
} // Namespace
|
||||
|
Reference in New Issue
Block a user