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:
parent
5eeb573a43
commit
c63d792953
@ -17,6 +17,8 @@ using System.Configuration;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace VEPROMS.CSLA.Library
|
namespace VEPROMS.CSLA.Library
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -253,4 +255,312 @@ namespace VEPROMS.CSLA.Library
|
|||||||
internal DbCslaException(string message) : base(message) { ;}
|
internal DbCslaException(string message) : base(message) { ;}
|
||||||
internal DbCslaException() : base() { ;}
|
internal DbCslaException() : base() { ;}
|
||||||
} // Class
|
} // 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
|
} // Namespace
|
||||||
|
@ -375,6 +375,13 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
Text = _VEObject.ToString();
|
Text = _VEObject.ToString();
|
||||||
ItemInfo myItemInfo = _VEObject as ItemInfo;
|
ItemInfo myItemInfo = _VEObject as ItemInfo;
|
||||||
|
if (myItemInfo != null && myItemInfo.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
|
||||||
|
{
|
||||||
|
int k = myItemInfo.MyDocVersion.DocVersionConfig.SelectedSlave;
|
||||||
|
myItemInfo.MyDocVersion.DocVersionConfig.SelectedSlave = 0;
|
||||||
|
Text = myItemInfo.ToString();
|
||||||
|
myItemInfo.MyDocVersion.DocVersionConfig.SelectedSlave = k;
|
||||||
|
}
|
||||||
if (myItemInfo != null && myItemInfo.IsSection)
|
if (myItemInfo != null && myItemInfo.IsSection)
|
||||||
{
|
{
|
||||||
myItemInfo.RefreshConfig();
|
myItemInfo.RefreshConfig();
|
||||||
|
151
PROMS/Volian.Base.Library/BigNum.cs
Normal file
151
PROMS/Volian.Base.Library/BigNum.cs
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace Volian.Base.Library
|
||||||
|
{
|
||||||
|
[Serializable()]
|
||||||
|
//[XmlRoot("BigNum")]
|
||||||
|
public class BigNum
|
||||||
|
{
|
||||||
|
#region fields
|
||||||
|
private SortedDictionary<uint, ulong> _MyValue = new SortedDictionary<uint, ulong>();
|
||||||
|
private const ulong one = 1;
|
||||||
|
private SortedDictionary<uint, ulong> MyValue
|
||||||
|
{
|
||||||
|
get { return _MyValue; }
|
||||||
|
set { _MyValue = value; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region constructors
|
||||||
|
public BigNum()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public BigNum(int value)
|
||||||
|
{
|
||||||
|
SetFlag(value);
|
||||||
|
}
|
||||||
|
public BigNum(string values)
|
||||||
|
{
|
||||||
|
SetFlags(values);
|
||||||
|
}
|
||||||
|
public BigNum(ICollection<int> values)
|
||||||
|
{
|
||||||
|
SetFlags(values);
|
||||||
|
}
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return FlagList;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region operators
|
||||||
|
public static BigNum operator |(BigNum bn1, BigNum bn2)
|
||||||
|
{
|
||||||
|
BigNum bn = new BigNum(bn1.GetFlags());
|
||||||
|
bn.SetFlags(bn2.GetFlags());
|
||||||
|
return bn;
|
||||||
|
}
|
||||||
|
public static BigNum operator &(BigNum bn1, BigNum bn2)
|
||||||
|
{
|
||||||
|
BigNum bn = new BigNum(0);
|
||||||
|
foreach (uint k1 in bn1.MyValue.Keys)
|
||||||
|
{
|
||||||
|
if (bn2.MyValue.ContainsKey(k1) && (bn1.MyValue[k1] & bn2.MyValue[k1]) != 0)
|
||||||
|
bn.MyValue[k1] = (bn1.MyValue[k1] & bn2.MyValue[k1]);
|
||||||
|
}
|
||||||
|
return bn;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region methods
|
||||||
|
//public override string ToString()
|
||||||
|
//{
|
||||||
|
// return GenericSerializer<BigNum>.StringSerialize(this);
|
||||||
|
//}
|
||||||
|
public bool Includes(BigNum other)
|
||||||
|
{
|
||||||
|
List<int> mine = GetFlags();
|
||||||
|
if (mine.Count == 0) return true;
|
||||||
|
List<int> yours = other.GetFlags();
|
||||||
|
if (yours.Count == 0) return false;
|
||||||
|
foreach (int y in yours)
|
||||||
|
if (mine.Contains(y)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void SetFlags(string values)
|
||||||
|
{
|
||||||
|
if (values == string.Empty) return;
|
||||||
|
string[] myvalues = values.Split(',');
|
||||||
|
foreach (string v in myvalues)
|
||||||
|
SetFlag(int.Parse(v));
|
||||||
|
}
|
||||||
|
public List<int> GetFlags()
|
||||||
|
{
|
||||||
|
List<int> myints = new List<int>();
|
||||||
|
//if (MyValue.Count == 0)//1 && MyValue.ContainsKey(0) && MyValue[0] == 0)
|
||||||
|
//{
|
||||||
|
// myints.Add(-1);
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
foreach (uint key in MyValue.Keys)
|
||||||
|
{
|
||||||
|
ulong y = MyValue[key];
|
||||||
|
for (int i = 0; i < 64; i++)
|
||||||
|
{
|
||||||
|
if (((y >> i) & one) == one)
|
||||||
|
myints.Add((int)(i + (key * 64)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
return myints;
|
||||||
|
}
|
||||||
|
public void SetFlag(int flag)
|
||||||
|
{
|
||||||
|
//if (flag == -1)
|
||||||
|
//{
|
||||||
|
// MyValue = new SortedDictionary<uint, ulong>();
|
||||||
|
// //MyValue.Add(0, 0);
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
uint offset = (uint)(flag / 64);
|
||||||
|
ulong x = one << (flag % 64);
|
||||||
|
if (MyValue.ContainsKey(offset))
|
||||||
|
MyValue[offset] |= x;
|
||||||
|
else
|
||||||
|
MyValue.Add(offset, x);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
public void SetFlags(ICollection<int> flags)
|
||||||
|
{
|
||||||
|
foreach (int f in flags)
|
||||||
|
SetFlag(f);
|
||||||
|
}
|
||||||
|
public static BigNum MakeBigNum(string numbers)
|
||||||
|
{
|
||||||
|
if (numbers == "-1")
|
||||||
|
return null;
|
||||||
|
return new BigNum(numbers);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region properties
|
||||||
|
[XmlAttribute]
|
||||||
|
public string FlagList
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
string sep = "";
|
||||||
|
foreach (int i in GetFlags())
|
||||||
|
{
|
||||||
|
sb.Append(sep + i.ToString());
|
||||||
|
sep = ",";
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
set { SetFlags(value); }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user