Commit for development environment setup
This commit is contained in:
326
PROMS/VEPROMS.CSLA.Library/Extension/AnnotationExt.cs.bak
Normal file
326
PROMS/VEPROMS.CSLA.Library/Extension/AnnotationExt.cs.bak
Normal file
@@ -0,0 +1,326 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class AnnotationInfo
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return _SearchText;
|
||||
}
|
||||
#region JCB Annotation Status
|
||||
private bool _IsAnnotationNew = false;
|
||||
|
||||
public bool IsAnnotationNew
|
||||
{
|
||||
get
|
||||
{
|
||||
ProcedureInfo pi = this.MyItem.MyProcedure;
|
||||
if (pi != null)
|
||||
//todo figure out audit count
|
||||
_IsAnnotationNew = (this.DTS > pi.DTS);
|
||||
return _IsAnnotationNew;
|
||||
}
|
||||
}
|
||||
private bool _IsAnnotationChanged;
|
||||
|
||||
public bool IsAnnotationChanged
|
||||
{
|
||||
get
|
||||
{
|
||||
ProcedureInfo pi = this.MyItem.MyProcedure;
|
||||
if (pi != null)
|
||||
{
|
||||
//todo figure out audit count
|
||||
_IsAnnotationChanged = (this.DTS > pi.DTS);
|
||||
}
|
||||
return _IsAnnotationChanged;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
public partial class AnnotationType
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return _Name;
|
||||
}
|
||||
public static AnnotationType GetByName2(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
AnnotationType tmp = DataPortal.Fetch<AnnotationType>(new GetByNameCriteria(name));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationType
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationType.GetByName", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetByNameCriteria
|
||||
{
|
||||
private string _Name;
|
||||
public string Name { get { return _Name; } }
|
||||
public GetByNameCriteria(string name)
|
||||
{
|
||||
_Name = name;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetByNameCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationType.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 = "getAnnotationTypeByName";
|
||||
cm.Parameters.AddWithValue("@Name", criteria.Name);
|
||||
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("AnnotationType.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("AnnotationType.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial class AnnotationTypeInfo
|
||||
{
|
||||
public static List<AnnotationTypeInfo> AllList()
|
||||
{
|
||||
//return _AllList;
|
||||
return AnnotationTypeInfo._CacheList;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return _Name;
|
||||
}
|
||||
public static AnnotationTypeInfo GetByName(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
AnnotationTypeInfo tmp = DataPortal.Fetch<AnnotationTypeInfo>(new GetByNameCriteria(name));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up AnnotationTypeInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on AnnotationTypeInfo.GetByName", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetByNameCriteria
|
||||
{
|
||||
private string _Name;
|
||||
public string Name { get { return _Name; } }
|
||||
public GetByNameCriteria(string name)
|
||||
{
|
||||
_Name = name;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetByNameCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] AnnotationTypeInfo.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 = "getAnnotationTypeByName";
|
||||
cm.Parameters.AddWithValue("@Name", criteria.Name);
|
||||
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("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("AnnotationTypeInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial class AnnotationTypeInfoList
|
||||
{
|
||||
public static void Refresh()
|
||||
{
|
||||
Reset();
|
||||
_AnnotationTypeInfoList = Get();
|
||||
}
|
||||
}
|
||||
public partial class Annotation
|
||||
{
|
||||
/// <summary>
|
||||
/// Change the annotation type and update the Annotation record
|
||||
/// </summary>
|
||||
/// <param name="anotypeid"></param>
|
||||
public void Update(int anotypeid)
|
||||
{
|
||||
if (_TypeID != anotypeid)
|
||||
{
|
||||
_TypeID = anotypeid;
|
||||
MarkDirty(); // force the record update
|
||||
Save();
|
||||
//Update(); // commit record to database
|
||||
}
|
||||
}
|
||||
public void CommitChanges()
|
||||
{
|
||||
MarkDirty(); // force the record update
|
||||
Save(true);
|
||||
//Update();
|
||||
}
|
||||
|
||||
public static void DeleteAnnotation(AnnotationInfo obj)
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Annotation");
|
||||
try
|
||||
{
|
||||
// ItemInfo nextItem = item.NextItem;
|
||||
// ItemInfo prevItem = item.MyPrevious;
|
||||
// item.OnBeforeDelete();
|
||||
DataPortal.Delete(new DeleteCriteria(obj.AnnotationID, Volian.Base.Library.VlnSettings.UserID));
|
||||
AnnotationInfo.StaticOnInfoChanged();
|
||||
// if (nextItem != null) // Adjust PreviousID for NextItem
|
||||
// {
|
||||
// ItemInfo.RefreshPrevious(nextItem.ItemID, item.PreviousID);
|
||||
// // The order of the next two methods was required to fix a null reference
|
||||
// // when getting myparent. This bug was found when deleting a node from the
|
||||
// // tree when the RTBItem was not open (i.e. in the step editor window).
|
||||
// nextItem.RefreshItemParts();
|
||||
// //nextItem.ResetOrdinal(); - UpdateTransitionText calls ResetOrdinal
|
||||
// nextItem.UpdateTransitionText();
|
||||
// }
|
||||
// else if (prevItem != null)
|
||||
// {
|
||||
// prevItem.RefreshNextItems();
|
||||
// if (prevItem.IsCaution || prevItem.IsNote) prevItem.ResetOrdinal();
|
||||
// prevItem.UpdateTransitionText();
|
||||
// }
|
||||
// ItemInfo.DeleteItemInfoAndChildren(item.ItemID); // Dispose ItemInfo and Children
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("AnnotationExt: Stacktrace = {0}", ex.StackTrace);
|
||||
System.Data.SqlClient.SqlException exSQL = SqlException(ex);
|
||||
if (exSQL != null && exSQL.Message.Contains("###Cannot Delete Item###"))
|
||||
//return false;
|
||||
throw exSQL;
|
||||
else
|
||||
throw new DbCslaException("Error on Annotation.Delete", ex);
|
||||
}
|
||||
}
|
||||
private static System.Data.SqlClient.SqlException SqlException(Exception ex)
|
||||
{
|
||||
Type sqlExType = typeof(System.Data.SqlClient.SqlException);
|
||||
while (ex != null)
|
||||
{
|
||||
if (ex.GetType() == sqlExType) return ex as System.Data.SqlClient.SqlException;
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
[Serializable()]
|
||||
protected class DeleteCriteria
|
||||
{
|
||||
private int _AnnotationID;
|
||||
public int AnnotationID
|
||||
{ get { return _AnnotationID; } }
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{
|
||||
get { return _UserID; }
|
||||
set { _UserID = value; }
|
||||
}
|
||||
public DeleteCriteria(int annotationID, String userID)
|
||||
{
|
||||
_AnnotationID = annotationID;
|
||||
_UserID = userID;
|
||||
}
|
||||
}
|
||||
[Transactional(TransactionalTypes.TransactionScope)]
|
||||
private void DataPortal_Delete(DeleteCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Item.DataPortal_Delete", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "deleteAnnotationWithUserID";
|
||||
cm.Parameters.AddWithValue("@AnnotationID", criteria.AnnotationID);
|
||||
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
|
||||
cm.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Item.DataPortal_Delete", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("Item.DataPortal_Delete", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
//public partial class AnnotationTypeAnnotations
|
||||
//{
|
||||
// public static int GetAnnotationID()
|
||||
// {
|
||||
// return AnnotationTypeAnnotat
|
||||
// }
|
||||
//}
|
||||
}
|
1790
PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs.bak
Normal file
1790
PROMS/VEPROMS.CSLA.Library/Extension/AuditExt.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
509
PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs.bak
Normal file
509
PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs.bak
Normal file
@@ -0,0 +1,509 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Xml;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class Content
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", Number, Text);
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran)
|
||||
{
|
||||
string transText = tran.ResolvePathTo();
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (tran.MyContent.MyGrid != null)
|
||||
{
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
private string GetMySuffix(int start)
|
||||
{
|
||||
string txt = Text.Substring(start);
|
||||
int firstSlashVeeZero = txt.IndexOf(@"\v0");
|
||||
if (firstSlashVeeZero == 0 && txt.Length > 3 && txt[3] == ' ') //"\v0 "
|
||||
return Text.Substring(start, 4);
|
||||
return Text.Substring(start, firstSlashVeeZero + 3); //everything upto \v0"
|
||||
}
|
||||
private string GetMyPrefix(int start, int lastIndex)
|
||||
{
|
||||
string defPrefix = Text.Substring(start - 3, 3);
|
||||
if (defPrefix != @"\v ") throw new Exception(string.Format("rtf string {0} does not match expected format", defPrefix));
|
||||
string txt = Text.Substring(lastIndex, start - lastIndex - 3);
|
||||
int lastSlash = txt.LastIndexOf(@"\");
|
||||
int lastSpace = txt.LastIndexOf(" ");
|
||||
int lastCR = txt.LastIndexOf("\r");
|
||||
if (lastSpace < lastCR)
|
||||
lastSpace = lastCR;
|
||||
if (lastSlash <= lastSpace) //this will return "\v "
|
||||
return defPrefix;
|
||||
txt = txt.Substring(lastSlash);
|
||||
if(txt.StartsWith(@"\'")) //this is a hex
|
||||
return defPrefix;
|
||||
if (Regex.IsMatch(txt, @"\\u[0-9].*")) //this is unicode
|
||||
return defPrefix;
|
||||
return @"\v";
|
||||
}
|
||||
public string ConvertROToText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo)
|
||||
{
|
||||
string retval = null;
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
int lastIndex = 0;
|
||||
string newText = Text;
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
int offset = mm.Index;
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
string prefix = GetMyPrefix(mm.Index, lastIndex);
|
||||
string suffix = GetMySuffix(mm.Index + mm.Length);
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
string part1 = newText.Substring(0, mm.Index);
|
||||
string part2 = g.Value;
|
||||
string part3 = newText.Substring(mm.Index + mm.Length);
|
||||
//modify part1 based on prefix
|
||||
if (prefix == @"\v ")
|
||||
part1 = part1.Substring(0, part1.Length - 3);
|
||||
else
|
||||
part1 = part1.Substring(0, part1.Length - 3) + " ";
|
||||
//modify part3 based on suffix
|
||||
if (suffix == @"\v0 ")
|
||||
part3 = part3.Substring(4);
|
||||
else
|
||||
part3 = suffix.Replace(@"\v0","") + part3.Substring(suffix.Length);
|
||||
System.Text.RegularExpressions.Group g2 = m.Groups[2];
|
||||
if (g2.Value.StartsWith(@"\u8209?"))
|
||||
{
|
||||
string gg = g2.Value + " " + g.Value;
|
||||
retval = gg;
|
||||
part2 = retval;
|
||||
}
|
||||
else
|
||||
//else if (g.ToString() != newvalue)
|
||||
{
|
||||
retval = g.Value;
|
||||
part2 = retval;
|
||||
}
|
||||
Text = part1 + part2 + part3;
|
||||
break; // Text has been processed
|
||||
}
|
||||
lastIndex = mm.Index + mm.Length;
|
||||
}
|
||||
Console.WriteLine("Text: {0} NewText: {1}", Text, newText);
|
||||
// see if there is a grid to update too.
|
||||
if (rousg.MyContent.MyGrid != null)
|
||||
{
|
||||
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||
{
|
||||
if (origROFstInfo != null)
|
||||
{
|
||||
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||
if (MyGrid.Data != retlist[1])
|
||||
{
|
||||
MyGrid.Data = retlist[1];
|
||||
retval = Text;
|
||||
if (Text != retlist[0])
|
||||
Text = retlist[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||
string findLinkXml = @"<START\].*?\[END>";
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||
int nmsg = msg.Count;
|
||||
for (int i = nmsg - 1; i >= 0; i--)
|
||||
{
|
||||
Match mmg = msg[i];
|
||||
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
|
||||
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
{
|
||||
retval = g.Value;
|
||||
MyGrid.Data = MyGrid.Data.Substring(0, offset + mmg.Index + g.Index) + newvalue + MyGrid.Data.Substring(offset + mmg.Index + g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||
{
|
||||
return FixContentText(rousg, value, rotype, origROFstInfo, null);
|
||||
}
|
||||
public string FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo,string fileNameOnly) // string newvalue)
|
||||
{
|
||||
string retval = null;
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
//string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{}\\]+)*( |\\u[0-9]{1,4}?|\\'[0-9a-fA-F]{2})(.*?)(\\[^v'?{} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
int myIndex = m.Groups[4].Index + mm.Index;
|
||||
int myLength = m.Groups[4].Length;
|
||||
if(m.Groups[3] != " ")
|
||||
{
|
||||
myIndex = m.Groups[3].Index + mm.Index;
|
||||
myLength += m.Groups[3].Length;
|
||||
}
|
||||
string gg = Text.Substring(myIndex,myLength);
|
||||
if ((gg.Replace(@"\'b0", @"\'B0") != newvalue.Replace(@"\'b0", @"\'B0")) && ((fileNameOnly == null) || (gg != fileNameOnly)))
|
||||
{
|
||||
retval = gg;
|
||||
Text = Text.Substring(0, myIndex) + newvalue + Text.Substring(myIndex + myLength);
|
||||
break; // Text has been processed
|
||||
}
|
||||
}
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (rousg.MyContent.MyGrid != null)
|
||||
{
|
||||
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||
{
|
||||
if (origROFstInfo != null)
|
||||
{
|
||||
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||
if (MyGrid.Data != retlist[1])
|
||||
{
|
||||
MyGrid.Data = retlist[1];
|
||||
retval = Text;
|
||||
if (Text != retlist[0])
|
||||
Text = retlist[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||
string findLinkXml = @"<START\].*?\[END>";
|
||||
//string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{}\\]+)*( |\\u[0-9]{1,4}?|\\'[0-9a-fA-F]{2})(.*?)(\\[^v'?{} \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>$", rousg.ROUsageID);
|
||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||
foreach (Match mmg in msg)
|
||||
{
|
||||
Match mg = Regex.Match(mmg.Value, lookForXml);// Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
int myIndex = m.Groups[4].Index + mmg.Index;
|
||||
int myLength = m.Groups[4].Length;
|
||||
if (m.Groups[3] != " ")
|
||||
{
|
||||
myIndex = m.Groups[3].Index + mmg.Index;
|
||||
myLength += m.Groups[3].Length;
|
||||
}
|
||||
string gg = Text.Substring(myIndex, myLength);
|
||||
if (gg != newvalue)
|
||||
{
|
||||
retval = gg;
|
||||
MyGrid.Data = MyGrid.Data.Substring(0, myIndex) + newvalue + MyGrid.Data.Substring(myIndex + myLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
public partial class ContentInfo
|
||||
{
|
||||
public void FixTransitionText(TransitionInfo tran)
|
||||
{
|
||||
string transText = tran.ResolvePathTo();
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (tran.MyContent.MyGrid != null)
|
||||
{
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
//if (g.ToString() != transText)
|
||||
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
|
||||
{
|
||||
string transText = tran.ResolvePathTo(tranLookup);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (MyGrid != null)
|
||||
{
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
MyGrid.SetData(MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||
{
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
int offset = mm.Index;
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
{
|
||||
_Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
|
||||
break; // Text has been processed
|
||||
}
|
||||
}
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (MyGrid != null)
|
||||
{
|
||||
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||
{
|
||||
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||
if (Text != retlist[0]) _Text = retlist[0];
|
||||
//if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||
string findLinkXml = @"<START\].*?\[END>";
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||
foreach (Match mmg in msg)
|
||||
{
|
||||
//int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
|
||||
Match mg = Regex.Match(mmg.Value, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
{
|
||||
string prefix1 = MyGrid.Data.Substring(0,mmg.Index);
|
||||
string prefix2 = mmg.Value.Substring(0,g.Index);
|
||||
string suffix1 = MyGrid.Data.Substring(mmg.Index + mmg.Length);
|
||||
string suffix2 = mmg.Value.Substring(g.Index + g.Length);
|
||||
MyGrid.SetData(prefix1 + prefix2 + newvalue + suffix2 + suffix1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_Text == string.Empty)
|
||||
_Text = "?";
|
||||
}
|
||||
public void LoadNonCachedGrid()
|
||||
{
|
||||
_MyGrid = GridInfo.GetNonCached(ContentID);
|
||||
//Console.WriteLine("LoadNonCachedGrid {0},{1},{2}",ContentID,_MyGrid==null,_MyContentInfoUnique);
|
||||
}
|
||||
public PartInfoList LocalContentParts
|
||||
{
|
||||
get { return _ContentParts; }
|
||||
}
|
||||
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
|
||||
{
|
||||
if (_ContentParts == null)
|
||||
_ContentParts = new PartInfoList(dr, itemInfo);
|
||||
else
|
||||
_ContentParts.AddPartInfo(dr, itemInfo);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", Number, Text);
|
||||
}
|
||||
public void ShowChange()
|
||||
{
|
||||
OnChange();
|
||||
}
|
||||
//public XmlNode ToXml(XmlNode xn)
|
||||
//{
|
||||
// XmlNode nd = xn.OwnerDocument.CreateElement("Content");
|
||||
// xn.AppendChild(nd);
|
||||
// AddAttribute(nd, "Number", _Number);
|
||||
// AddAttribute(nd, "Text", _Text);
|
||||
// AddAttribute(nd, "FormatID", _FormatID);
|
||||
// AddAttribute(nd, "Config", _Config);
|
||||
// return nd;
|
||||
//}
|
||||
//public void AddAttribute(XmlNode xn, string name, object o)
|
||||
//{
|
||||
// if (o != null && o.ToString() != "")
|
||||
// {
|
||||
// XmlAttribute xa = xn.OwnerDocument.CreateAttribute(name);
|
||||
// xa.Value = o.ToString();
|
||||
// xn.Attributes.Append(xa);
|
||||
// }
|
||||
//}
|
||||
internal ContentInfo(SafeDataReader dr,bool ForItem)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadDataItemList(dr);
|
||||
_CacheList.Add(this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
|
||||
throw new DbCslaException("ContentInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
private void ReadDataItemList(SafeDataReader dr)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadDataItemList", GetHashCode());
|
||||
try
|
||||
{
|
||||
_ContentID = dr.GetInt32("ContentID");
|
||||
_Number = dr.GetString("Number");
|
||||
_Text = dr.GetString("Text");
|
||||
_Type = (int?)dr.GetValue("Type");
|
||||
_FormatID = (int?)dr.GetValue("FormatID");
|
||||
_Config = dr.GetString("Config");
|
||||
_DTS = dr.GetDateTime("cDTS");
|
||||
_UserID = dr.GetString("cUserID");
|
||||
_ContentDetailCount = dr.GetInt32("DetailCount");
|
||||
_ContentEntryCount = dr.GetInt32("EntryCount");
|
||||
_ContentGridCount = dr.GetInt32("GridCount");
|
||||
_ContentImageCount = dr.GetInt32("ImageCount");
|
||||
_ContentItemCount = dr.GetInt32("ItemCount");
|
||||
_ContentPartCount = dr.GetInt32("cPartCount");
|
||||
_ContentRoUsageCount = dr.GetInt32("RoUsageCount");
|
||||
_ContentTransitionCount = dr.GetInt32("TransitionCount");
|
||||
_ContentZContentCount = dr.GetInt32("ZContentCount");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ContentInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public partial class ContentInfoList
|
||||
{
|
||||
public static ContentInfoList GetList(int? itemID)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ContentListCriteria(itemID));
|
||||
ContentInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
private class ContentListCriteria
|
||||
{
|
||||
public ContentListCriteria(int? itemID)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
}
|
||||
private int? _ItemID;
|
||||
public int? ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(ContentListCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "vesp_ListContentsByItemID";
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read())
|
||||
{
|
||||
ContentInfo contentInfo = new ContentInfo(dr);
|
||||
this.Add(contentInfo);
|
||||
}
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
343
PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs.org
Normal file
343
PROMS/VEPROMS.CSLA.Library/Extension/ContentExt.cs.org
Normal file
@@ -0,0 +1,343 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Xml;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class Content
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", Number, Text);
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran)
|
||||
{
|
||||
string transText = tran.ResolvePathTo();
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (tran.MyContent.MyGrid != null)
|
||||
{
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||
{
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
int offset = mm.Index;
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
{
|
||||
Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
|
||||
break; // Text has been processed
|
||||
}
|
||||
}
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (rousg.MyContent.MyGrid != null)
|
||||
{
|
||||
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||
{
|
||||
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||
if (Text != retlist[0]) Text = retlist[0];
|
||||
if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||
string findLinkXml = @"<START\].*?\[END>";
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||
foreach (Match mmg in msg)
|
||||
{
|
||||
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public partial class ContentInfo
|
||||
{
|
||||
public void FixTransitionText(TransitionInfo tran)
|
||||
{
|
||||
string transText = tran.ResolvePathTo();
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (tran.MyContent.MyGrid != null)
|
||||
{
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
//if (g.ToString() != transText)
|
||||
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup)
|
||||
{
|
||||
string transText = tran.ResolvePathTo(tranLookup);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
_Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (tran.MyContent.MyGrid != null)
|
||||
{
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
//if (g.ToString() != transText)
|
||||
// MyGrid.Data = MyGrid.Data.Substring(0, g.Index) + transText + MyGrid.Data.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FixContentText(RoUsageInfo rousg, string value, int rotype, ROFstInfo origROFstInfo) // string newvalue)
|
||||
{
|
||||
string newvalue = value;
|
||||
string findLink = @"<START\].*?\[END>";
|
||||
MatchCollection ms = Regex.Matches(Text, findLink);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
foreach (Match mm in ms)
|
||||
{
|
||||
int offset = mm.Index;
|
||||
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
{
|
||||
_Text = Text.Substring(0, offset + g.Index) + newvalue + Text.Substring(offset + g.Index + g.Length);
|
||||
break; // Text has been processed
|
||||
}
|
||||
}
|
||||
}
|
||||
// see if there is a grid to update too.
|
||||
if (rousg.MyContent.MyGrid != null)
|
||||
{
|
||||
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
|
||||
{
|
||||
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
|
||||
if (Text != retlist[0]) _Text = retlist[0];
|
||||
//if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// if it's an ro within a table, need to process into an flex grid to save the grid data:
|
||||
string findLinkXml = @"<START\].*?\[END>";
|
||||
string lookForXml = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v '?\\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
MatchCollection msg = Regex.Matches(MyGrid.Data, findLinkXml);
|
||||
foreach (Match mmg in msg)
|
||||
{
|
||||
int offset = 0; // crashed in substring line below if using mmg.Index; Set to 0 and it worked - KBR.
|
||||
Match mg = Regex.Match(MyGrid.Data, lookForXml);
|
||||
if (mg != null && mg.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = mg.Groups[3];
|
||||
//if (g.ToString() != newvalue)
|
||||
// MyGrid.Data = MyGrid.Data.Substring(0, offset + g.Index) + newvalue + MyGrid.Data.Substring(offset + g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public PartInfoList LocalContentParts
|
||||
{
|
||||
get { return _ContentParts; }
|
||||
}
|
||||
public void AddPart(SafeDataReader dr, ItemInfo itemInfo)
|
||||
{
|
||||
if (_ContentParts == null)
|
||||
_ContentParts = new PartInfoList(dr, itemInfo);
|
||||
else
|
||||
_ContentParts.AddPartInfo(dr, itemInfo);
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} {1}", Number, Text);
|
||||
}
|
||||
public void ShowChange()
|
||||
{
|
||||
OnChange();
|
||||
}
|
||||
//public XmlNode ToXml(XmlNode xn)
|
||||
//{
|
||||
// XmlNode nd = xn.OwnerDocument.CreateElement("Content");
|
||||
// xn.AppendChild(nd);
|
||||
// AddAttribute(nd, "Number", _Number);
|
||||
// AddAttribute(nd, "Text", _Text);
|
||||
// AddAttribute(nd, "FormatID", _FormatID);
|
||||
// AddAttribute(nd, "Config", _Config);
|
||||
// return nd;
|
||||
//}
|
||||
//public void AddAttribute(XmlNode xn, string name, object o)
|
||||
//{
|
||||
// if (o != null && o.ToString() != "")
|
||||
// {
|
||||
// XmlAttribute xa = xn.OwnerDocument.CreateAttribute(name);
|
||||
// xa.Value = o.ToString();
|
||||
// xn.Attributes.Append(xa);
|
||||
// }
|
||||
//}
|
||||
internal ContentInfo(SafeDataReader dr,bool ForItem)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.Constructor", GetHashCode());
|
||||
try
|
||||
{
|
||||
ReadDataItemList(dr);
|
||||
_CacheList.Add(this);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.Constructor", ex);
|
||||
throw new DbCslaException("ContentInfo.Constructor", ex);
|
||||
}
|
||||
}
|
||||
private void ReadDataItemList(SafeDataReader dr)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ContentInfo.ReadDataItemList", GetHashCode());
|
||||
try
|
||||
{
|
||||
_ContentID = dr.GetInt32("ContentID");
|
||||
_Number = dr.GetString("Number");
|
||||
_Text = dr.GetString("Text");
|
||||
_Type = (int?)dr.GetValue("Type");
|
||||
_FormatID = (int?)dr.GetValue("FormatID");
|
||||
_Config = dr.GetString("Config");
|
||||
_DTS = dr.GetDateTime("cDTS");
|
||||
_UserID = dr.GetString("cUserID");
|
||||
_ContentDetailCount = dr.GetInt32("DetailCount");
|
||||
_ContentEntryCount = dr.GetInt32("EntryCount");
|
||||
_ContentGridCount = dr.GetInt32("GridCount");
|
||||
_ContentImageCount = dr.GetInt32("ImageCount");
|
||||
_ContentItemCount = dr.GetInt32("ItemCount");
|
||||
_ContentPartCount = dr.GetInt32("cPartCount");
|
||||
_ContentRoUsageCount = dr.GetInt32("RoUsageCount");
|
||||
_ContentTransitionCount = dr.GetInt32("TransitionCount");
|
||||
_ContentZContentCount = dr.GetInt32("ZContentCount");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ContentInfo.ReadData", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ContentInfo.ReadData", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public partial class ContentInfoList
|
||||
{
|
||||
public static ContentInfoList GetList(int? itemID)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentInfoList tmp = DataPortal.Fetch<ContentInfoList>(new ContentListCriteria(itemID));
|
||||
ContentInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ItemInfoList.GetChildren", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
private class ContentListCriteria
|
||||
{
|
||||
public ContentListCriteria(int? itemID)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
}
|
||||
private int? _ItemID;
|
||||
public int? ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(ContentListCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "vesp_ListContentsByItemID";
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
|
||||
cm.CommandTimeout = Database.DefaultTimeout;
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read())
|
||||
{
|
||||
ContentInfo contentInfo = new ContentInfo(dr);
|
||||
this.Add(contentInfo);
|
||||
}
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Database.LogException("ContentInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("ContentInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
824
PROMS/VEPROMS.CSLA.Library/Extension/DisplayTextANSI.cs
Normal file
824
PROMS/VEPROMS.CSLA.Library/Extension/DisplayTextANSI.cs
Normal file
@@ -0,0 +1,824 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Drawing;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public class DisplayText
|
||||
{
|
||||
#region Properties
|
||||
private ItemInfo _MyItemInfo;
|
||||
// list of 'pieces of text' for this item. Pieces include symbols, ros,
|
||||
// transitions & plain text.
|
||||
private List<displayTextElement> _DisplayTextElementList;
|
||||
public List<displayTextElement> DisplayTextElementList
|
||||
{
|
||||
get { return _DisplayTextElementList; }
|
||||
set { _DisplayTextElementList = value; }
|
||||
}
|
||||
// dictionary for the font table for this item. Note that this may
|
||||
// go away (it is not really used).
|
||||
private Dictionary<int, string> _dicRtfFontTable;
|
||||
public Dictionary<int, string> dicRtfFontTable
|
||||
{
|
||||
get { return _dicRtfFontTable; }
|
||||
set { _dicRtfFontTable = value; }
|
||||
}
|
||||
private VE_Font _textFont; // Font from format for this item
|
||||
public VE_Font TextFont
|
||||
{
|
||||
get { return _textFont; }
|
||||
set { _textFont = value; }
|
||||
}
|
||||
public string StartText;
|
||||
public string OriginalText; // compare for save to see if change.
|
||||
private FormatInfo _MyFormat;
|
||||
#endregion
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// DisplayText constructor:
|
||||
/// Creates a DisplayText object that converts the database text into rtf text
|
||||
/// Arguments are:
|
||||
/// ItemInfo itemInfo - the item whose text will be resolved
|
||||
/// E_EditPrintMode ep_mode - edit or print.
|
||||
/// E_ViewMode vw_mode - view or edit.
|
||||
/// bool noEdit - flags whether to edit or not (used to set data in
|
||||
/// rtb as resolved replacewords for non-active rtb.
|
||||
/// </summary>
|
||||
public DisplayText(ItemInfo itemInfo, E_EditPrintMode epMode, E_ViewMode vwMode, bool noEdit)
|
||||
{
|
||||
_MyItemInfo = itemInfo;
|
||||
OriginalText = itemInfo.MyContent.Text;
|
||||
TextFont = GetItemFont();
|
||||
string text = _MyItemInfo.MyContent.Text;
|
||||
|
||||
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
|
||||
// actual edit mode are replace words left as is.
|
||||
_MyFormat = itemInfo.ActiveFormat;
|
||||
if (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit) text = DoReplaceWords(text);
|
||||
|
||||
// adjust formatting of exponents
|
||||
if (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit)) text = DoFortranFormat(text);
|
||||
|
||||
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the
|
||||
// save portion of this code for an explanation.
|
||||
text = text.Replace(@"\~", @"\u160?");
|
||||
text = text.Replace(@"\r\n", @"\par ");
|
||||
|
||||
text = text.Replace(@"\line", @"\par");
|
||||
|
||||
// add colors around links:
|
||||
text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 ");
|
||||
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
|
||||
int indxcf = text.IndexOf("cf1");
|
||||
while (indxcf != -1)
|
||||
{
|
||||
int indxend = text.IndexOf(@"\v", indxcf);
|
||||
text = text.Insert(indxend, @"\cf0 ");
|
||||
indxcf = text.IndexOf(@"cf1", indxend);
|
||||
}
|
||||
|
||||
// Now put symbol (for fixed fonts) or unicode font (proportional) around symbols
|
||||
// These fonts are VESymbFix & Arial Unicode MS respectively, and the font table
|
||||
// is actually defined in the StepRTB code.
|
||||
int indxsym = text.IndexOf(@"\u");
|
||||
while (indxsym != -1)
|
||||
{
|
||||
int incrindx = 3;
|
||||
if (text[indxsym + 2] != 'l')
|
||||
{
|
||||
text = text.Insert(indxsym, @"\f1 ");
|
||||
int indxendsym = text.IndexOfAny(@"\ ?".ToCharArray(),indxsym+5);
|
||||
if (indxendsym == -1) // must be end of line:
|
||||
text = text.Insert(text.Length-1,@"\f0 ");
|
||||
else
|
||||
{
|
||||
if (text[indxendsym]=='?') indxendsym++;
|
||||
text = text.Insert(indxendsym, @"\f0 "); // TODO: do I need a space??
|
||||
}
|
||||
incrindx = 5;
|
||||
}
|
||||
indxsym = text.IndexOf(@"\u",indxsym + incrindx);
|
||||
}
|
||||
StartText = text;
|
||||
}
|
||||
|
||||
private string DoFortranFormat(string text)
|
||||
{
|
||||
if (text.IndexOf(@".E") < 0) return text;
|
||||
// Look for text as n.Ey, where n can be null or a number, and y can be
|
||||
// positive or negative. This translates into nx10x10y where y is
|
||||
// superscripted. For example, .E3 -> x103 where 3 is superscripted
|
||||
// and 10.E5 -> 10x10-5 where 5 is superscripted
|
||||
string pat = @"(\d*).E([+-]*\d+)";
|
||||
string retstr = text;
|
||||
// for each one that needs translated:
|
||||
foreach (Match m in Regex.Matches(text, pat))
|
||||
{
|
||||
string fnum = m.Groups[1].Value;
|
||||
string supnum = m.Groups[2].Value;
|
||||
string newstr = string.Format(@"{0}x10\super {1}\nosupersub ", fnum, supnum);
|
||||
retstr = retstr.Replace(m.Value, newstr);
|
||||
}
|
||||
return retstr;
|
||||
}
|
||||
#endregion
|
||||
#region SaveData
|
||||
public bool Save(RichTextBox rtb)
|
||||
{
|
||||
try
|
||||
{
|
||||
Item itm = _MyItemInfo.Get();
|
||||
// check for different text, i.e. text from this itm doesn't match
|
||||
// original text, a change occurred in database, but not from this user.
|
||||
if (OriginalText != itm.MyContent.Text)
|
||||
{
|
||||
Console.WriteLine("Save Failed because text changed outside of this edit session.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove rtf codes that aren't defining attributes, symbols, or links
|
||||
string modtext = RtfToDbText(rtb.Rtf);
|
||||
|
||||
if (modtext != OriginalText)
|
||||
{
|
||||
// if there are links, we'll need to do extra processing to see if
|
||||
// there were additions, deletions or modifications.
|
||||
bool haslinks = ((modtext.IndexOf(@"<START]") > -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@"<START]") > -1));
|
||||
if (haslinks)
|
||||
{
|
||||
// Get all links in original list
|
||||
RtfToDisplayTextElements(OriginalText);
|
||||
List<displayLinkElement> origList = GetLinkList(DisplayTextElementList);
|
||||
// now get new text into displaytext elements for comparison for links:
|
||||
RtfToDisplayTextElements(rtb.Rtf);
|
||||
|
||||
// Compare ro/transition lists and delete or add any to the item for any ros/transitions that have been
|
||||
// added/deleted or modified.
|
||||
ProcessRoTranChanges(itm, origList);
|
||||
itm.MyContent.Text = DteToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
itm.MyContent.Text = modtext;
|
||||
itm.Save();
|
||||
}
|
||||
|
||||
if (haslinks)
|
||||
{
|
||||
// if new transitions/ros, we need to 'fix' the string in the embedded link to contain the
|
||||
// transition or usage record.
|
||||
Dictionary<int, ContentTransition> ctReplacements = BuildCtReplacements(itm.MyContent.ContentTransitions);
|
||||
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(itm.MyContent.ContentRoUsages);
|
||||
itm.Save();
|
||||
if (ctReplacements.Count > 0)
|
||||
{
|
||||
itm.MyContent.Text = FixCtReplacements(itm.MyContent.Text, ctReplacements);
|
||||
itm.Save();
|
||||
}
|
||||
if (roUsgReplacements.Count > 0)
|
||||
{
|
||||
itm.MyContent.Text = FixRoUsgReplacements(itm.MyContent.Text, roUsgReplacements);
|
||||
itm.Save();
|
||||
}
|
||||
modtext = itm.MyContent.Text;
|
||||
}
|
||||
OriginalText = modtext;
|
||||
}
|
||||
else
|
||||
return true; // no text changed, but did not fail so return true.
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Save Failed with error: {0}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private string DteToString()
|
||||
{
|
||||
StringBuilder sret = new StringBuilder();
|
||||
foreach (displayTextElement vte in DisplayTextElementList)
|
||||
{
|
||||
if (vte.Type == E_TextElementType.Text || vte.Type == E_TextElementType.Symbol)
|
||||
sret.Append(vte.Text);
|
||||
else
|
||||
{
|
||||
displayLinkElement dle = vte as displayLinkElement;
|
||||
if (vte != null) sret.Append(dle.TextAndLink);
|
||||
}
|
||||
}
|
||||
string modtext = sret.ToString();
|
||||
return modtext;
|
||||
}
|
||||
private string FixRoUsgReplacements(string p, Dictionary<int, ContentRoUsage> roUsgReplacements)
|
||||
{
|
||||
foreach (int oldid in roUsgReplacements.Keys)
|
||||
{
|
||||
p = p.Replace(string.Format("<CROUSGID={0}>", oldid), roUsgReplacements[oldid].ROUsageID.ToString());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
private Dictionary<int, ContentRoUsage> BuildRoUsgReplacements(ContentRoUsages contentRoUsages)
|
||||
{
|
||||
Dictionary<int, ContentRoUsage> retval = new Dictionary<int, ContentRoUsage>();
|
||||
foreach (ContentRoUsage rou in contentRoUsages)
|
||||
{
|
||||
if (rou.ROUsageID < 0) retval.Add(rou.ROUsageID, rou);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
private string FixCtReplacements(string p, Dictionary<int, ContentTransition> ctReplacements)
|
||||
{
|
||||
foreach (int oldid in ctReplacements.Keys)
|
||||
{
|
||||
p = p.Replace(string.Format("<CTID={0}>",oldid),ctReplacements[oldid].TransitionID.ToString());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
private Dictionary<int, ContentTransition> BuildCtReplacements(ContentTransitions contentTransitions)
|
||||
{
|
||||
Dictionary<int, ContentTransition> retval = new Dictionary<int, ContentTransition>();
|
||||
foreach (ContentTransition ct in contentTransitions)
|
||||
{
|
||||
if (ct.TransitionID < 0) retval.Add(ct.TransitionID, ct);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
private void ProcessRoTranChanges(Item itm, List<displayLinkElement> origList)
|
||||
{
|
||||
// go through list. Note that only linked items are in the origList.
|
||||
// 1) delete any that are in origList but not in the DisplayTextElementList
|
||||
// (that represents the current text & links)
|
||||
// 2) add any that are only in DisplayTextElementList
|
||||
// 3) delete/add for modify?
|
||||
|
||||
// delete first - if in original, but not in current list, delete the one
|
||||
// in the original list.
|
||||
foreach (displayLinkElement odte in origList)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (displayTextElement dte in DisplayTextElementList)
|
||||
{
|
||||
if (dte.Type == odte.Type)
|
||||
{
|
||||
displayLinkElement l_dte = (displayLinkElement)dte;
|
||||
if (odte.Link == l_dte.Link)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove the link element from the item.
|
||||
if (!found)
|
||||
{
|
||||
// Get record id for ro or trans and then find the associated ro or transition
|
||||
// in the item's list. remove it.
|
||||
int recid = -1;
|
||||
if (odte.Type != E_TextElementType.ReferencedObject)
|
||||
{
|
||||
int sp = odte.Link.IndexOf(" ") + 1; // get past tran type
|
||||
string srecid = odte.Link.Substring(sp, odte.Link.IndexOf(" ", sp) - sp);
|
||||
recid = System.Convert.ToInt32(srecid);
|
||||
foreach (ContentTransition ct in itm.MyContent.ContentTransitions)
|
||||
{
|
||||
if (ct.TransitionID == recid)
|
||||
{
|
||||
itm.MyContent.ContentTransitions.Remove(ct);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int sp = odte.Link.IndexOf(" ");
|
||||
//rousageid starts after "ReferencedObject:", i.e. index in link of 17
|
||||
string srecid = odte.Link.Substring(17, sp-17);
|
||||
recid = System.Convert.ToInt32(srecid);
|
||||
foreach (ContentRoUsage cr in itm.MyContent.ContentRoUsages)
|
||||
{
|
||||
if (cr.ROUsageID == recid)
|
||||
{
|
||||
itm.MyContent.ContentRoUsages.Remove(cr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// now do insert, i.e. in new list, but not in old.
|
||||
foreach (displayTextElement dte in DisplayTextElementList)
|
||||
{
|
||||
bool found = false;
|
||||
if (dte.Type == E_TextElementType.ReferencedObject || dte.Type == E_TextElementType.Transition || dte.Type == E_TextElementType.TransitionRange)
|
||||
{
|
||||
foreach (displayLinkElement odte in origList)
|
||||
{
|
||||
if (dte.Type == odte.Type)
|
||||
{
|
||||
// if the link is the same, it exists, so no action is required.
|
||||
displayLinkElement l_dte = (displayLinkElement)dte;
|
||||
if (odte.Link == l_dte.Link)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Insert the link (ro or transition) to the item
|
||||
if (!found)
|
||||
{
|
||||
if (dte.Type == E_TextElementType.ReferencedObject) // do ro
|
||||
{
|
||||
displayLinkElement l_dte = (displayLinkElement)dte;
|
||||
Match m = Regex.Match(l_dte.Link, "([A-Za-z]*):(.*)");
|
||||
string linkstr = m.Groups[2].Value;
|
||||
string[] roparts = linkstr.Split(" ".ToCharArray());
|
||||
ContentRoUsage rousg = null;
|
||||
using (RODb rodb = RODb.Get(Convert.ToInt32(roparts[2])))
|
||||
{
|
||||
rousg = itm.MyContent.ContentRoUsages.Add(roparts[1], rodb);
|
||||
}
|
||||
l_dte.Link = l_dte.Link.Replace("<NewID>", string.Format("<CROUSGID={0}>", rousg.ROUsageID));
|
||||
l_dte.TextAndLink = l_dte.TextAndLink.Replace("<NewID>", string.Format("<CROUSGID={0}>", rousg.ROUsageID));
|
||||
break;
|
||||
}
|
||||
else if (dte.Type == E_TextElementType.TransitionRange || dte.Type == E_TextElementType.Transition)
|
||||
{
|
||||
displayLinkElement l_dte = (displayLinkElement)dte;
|
||||
Match m = Regex.Match(l_dte.Link, "([A-Za-z]*):(.*)");
|
||||
string linkstr = m.Groups[2].Value;
|
||||
string[] tparts = linkstr.Split(" ".ToCharArray());
|
||||
int type = System.Convert.ToInt32(tparts[0]);
|
||||
int tr1 = System.Convert.ToInt32(tparts[2]); // tparts[1] is token for tranid
|
||||
Item itm1 = Item.Get(tr1);
|
||||
Item itm2 = null;
|
||||
if (dte.Type == E_TextElementType.TransitionRange)
|
||||
{
|
||||
itm2 = Item.Get(System.Convert.ToInt32(tparts[2]));
|
||||
}
|
||||
else
|
||||
itm2 = itm1;
|
||||
ContentTransition ct = itm.MyContent.ContentTransitions.Add(itm1, itm2);
|
||||
ct.TranType = type;
|
||||
l_dte.Link = l_dte.Link.Replace("<NewID>", string.Format("<CTID={0}>", ct.TransitionID));
|
||||
l_dte.TextAndLink = l_dte.TextAndLink.Replace("<NewID>", string.Format("<CTID={0}>", ct.TransitionID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<displayLinkElement> GetLinkList(List<displayTextElement> locDisplayTextElementList)
|
||||
{
|
||||
List<displayLinkElement> retList = new List<displayLinkElement>();
|
||||
foreach (displayTextElement vte in locDisplayTextElementList)
|
||||
{
|
||||
if (vte.Type == E_TextElementType.ReferencedObject || vte.Type == E_TextElementType.TransitionRange || vte.Type == E_TextElementType.Transition)
|
||||
{
|
||||
displayLinkElement tmp = (displayLinkElement)vte;
|
||||
displayLinkElement copy_vte = new displayLinkElement();
|
||||
copy_vte.Type = tmp.Type;
|
||||
copy_vte.Link = tmp.Link;
|
||||
copy_vte.Text = tmp.Text;
|
||||
retList.Add(copy_vte);
|
||||
}
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
private void RtfToDisplayTextElements(string text)
|
||||
{
|
||||
// get original text into displaytext elements for comparison for links:
|
||||
if (DisplayTextElementList == null)
|
||||
DisplayTextElementList = new List<displayTextElement>();
|
||||
else
|
||||
DisplayTextElementList.Clear();
|
||||
|
||||
if (text == null || text == "") return;
|
||||
|
||||
string noExtraRtfStr = RtfToDbText(text);
|
||||
|
||||
int startIndex = 0;
|
||||
int index = -1;
|
||||
while ((index = FindTokenChar(noExtraRtfStr, startIndex)) > -1)
|
||||
{
|
||||
// Do any 'plain' text that preceeds the token.
|
||||
if (index > startIndex) DoTextElement(noExtraRtfStr, startIndex, index);
|
||||
|
||||
if (noExtraRtfStr[index + 1] == 'v')
|
||||
index = DoLink(noExtraRtfStr, index);
|
||||
else
|
||||
index = DoSymbol(noExtraRtfStr, startIndex, index);
|
||||
startIndex = index; // +1;
|
||||
if (startIndex >= noExtraRtfStr.Length) break;
|
||||
}
|
||||
// Add any remaining text.
|
||||
if (startIndex < noExtraRtfStr.Length) DoTextElement(noExtraRtfStr, startIndex, index);
|
||||
}
|
||||
private string RtfToDbText(string text)
|
||||
{
|
||||
// For hardspaces, the windows richtextbox does some 'quirky' things:
|
||||
// A unicode representation of \u160? is sent INTO the rtb. Coming out,
|
||||
// that \u160? was translated to a \~ (by the underlying windows rtb).
|
||||
// Note that if the \~ is sent to the rtb, it is treated as a regular space,
|
||||
// i.e. no longer a hardspace, and actually is converted to a regular space.
|
||||
// SO, on the way out, convert any \~ to \u160?
|
||||
string noExtraRtfStr = text.Replace(@"\~", @"\u160?");
|
||||
|
||||
// Check for two links in a row & if found, add separating rtf comment
|
||||
// commands (these get removed in the richtextbox:
|
||||
noExtraRtfStr = noExtraRtfStr.Replace(@"[END><START]", @"[END>\v0 \v <START]");
|
||||
|
||||
// GetFontTable returns a non-negative number font number in the
|
||||
// font table for the unicode font, if it is used (otherwise -1)
|
||||
//int unicodeFont = GetFontTable(rtb.Rtf);
|
||||
|
||||
// strip off all rtf commands...
|
||||
noExtraRtfStr = StripRtfCommands(noExtraRtfStr);
|
||||
|
||||
// the indent character was translated in the richtextbox, change it back:
|
||||
if (noExtraRtfStr.IndexOf(@"\'05") > -1) noExtraRtfStr = noExtraRtfStr.Replace(@"\'05", "\x05");
|
||||
|
||||
return noExtraRtfStr;
|
||||
}
|
||||
private string RemoveRtfStyles(string rtf)
|
||||
{
|
||||
string retval = rtf;
|
||||
// remove rtf commands for any styles that were added. Note that if
|
||||
// the entire item has a style, and also contains 'pieces' of text with
|
||||
// the same style, the underlying rtf box removes the embedded rtf commands,
|
||||
// for example, if the entire step is bolded, and 'THEN' has bold on/off
|
||||
// surrounding it, the rtf box removes the bold around the 'THEN'
|
||||
// These remove the command with a following space or the command alone,
|
||||
// either case may exist, because if there are rtf commands following the
|
||||
// style command, there will be no space character following the style command.
|
||||
if (((TextFont.Style & E_Style.Bold) > 0) || ((TextFont.Style & E_Style.MmBold) > 0))
|
||||
{
|
||||
retval = Regex.Replace(retval, @"\\b0 ?", "");
|
||||
retval = Regex.Replace(retval, @"\\b ?","");
|
||||
}
|
||||
if ((TextFont.Style & E_Style.Underline) > 0)
|
||||
{
|
||||
retval = Regex.Replace(retval, @"\\ulnone ?", "");
|
||||
retval = Regex.Replace(retval, @"\\ul ?", "");
|
||||
}
|
||||
if ((TextFont.Style & E_Style.Italics) > 0)
|
||||
{
|
||||
retval = Regex.Replace(retval, @"\\i0 ?", "");
|
||||
retval = Regex.Replace(retval, @"\\i ?", "");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
public string ReplaceRTFClause(Match m)
|
||||
{
|
||||
switch (m.Value[1])
|
||||
{
|
||||
case 'u':
|
||||
if (Regex.IsMatch(m.Value, @"\\u[0-9]+"))
|
||||
return m.Value; // Special Charcaters
|
||||
if (Regex.IsMatch(m.Value, @"\\ulnone"))
|
||||
return m.Value;
|
||||
if (Regex.IsMatch(m.Value, @"\\ul.*"))
|
||||
return m.Value; // Underline
|
||||
break;
|
||||
case '\'': // Special Character
|
||||
return m.Value;
|
||||
case 'b': // Bold
|
||||
return m.Value;
|
||||
case 's': // sub or super....
|
||||
if (m.Value == @"\sub") return m.Value;
|
||||
if (m.Value == @"\super") return m.Value;
|
||||
break;
|
||||
case 'n': // nosubsuper...
|
||||
if (m.Value == @"\nosupersub") return m.Value;
|
||||
break;
|
||||
case 'i': // Italics
|
||||
return m.Value;
|
||||
case '{': // look for escape for curly braces:
|
||||
return m.Value;
|
||||
case '}':
|
||||
return m.Value;
|
||||
case 'v': // save link hidden info
|
||||
if (m.Value == @"\v") return m.Value; // comment part of link
|
||||
// end comment may end in space or may end in '\' if another rtf command,
|
||||
// or may end at end of string. First check for space, keep it in string
|
||||
// if it is there.
|
||||
if (Regex.IsMatch(m.Value, @"\\v0 "))
|
||||
return m.Value;
|
||||
if (Regex.IsMatch(m.Value, @"\\v0"))
|
||||
return m.Value;
|
||||
break;
|
||||
case 'l':
|
||||
if (m.Value == @"\line") return m.Value;
|
||||
break;
|
||||
case 'p':
|
||||
if (m.Value == @"\par") return @"\par";
|
||||
//if (m.Value == @"\protect")
|
||||
// return m.Value;
|
||||
//if (m.Value == @"\protect0")
|
||||
// return m.Value;
|
||||
if (m.Value.Length>=6 && m.Value.Substring(0,6) == "\\par\r\n") return m.Value.Replace("\r\n", " ");
|
||||
break;
|
||||
case 'f': // handle fonts separately because they may or may not have a space after them
|
||||
if (m.Value[2]>='0' && m.Value[2]<='9')return m.Value;
|
||||
break;
|
||||
}
|
||||
return "";//Strip All
|
||||
}
|
||||
private string StripRtfCommands(string rtf)
|
||||
{
|
||||
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
|
||||
// are rtf so were getting removed and/or not handled correctly.
|
||||
string retval = rtf.Replace(@"\{", @"(![");
|
||||
retval = retval.Replace(@"\}", @"(!]");
|
||||
|
||||
// remove carriage return/newlines after \par commands (these are introduced by rtb
|
||||
// for hard returns, goes into rtb as \par and comes out as \par\r\n):
|
||||
retval = Regex.Replace(retval, @"\\par\r\n([^\\.*?])", "\\par $1");
|
||||
retval = Regex.Replace(retval, @"\\par\r\n([\\.*?])", "\\par$1");
|
||||
|
||||
retval = Regex.Replace(retval, @"[\r\n]", "", RegexOptions.Singleline); // Strip Carriage Returns and Newlines
|
||||
retval = Regex.Replace(retval, @"^\{(.*)\}$", "$1", RegexOptions.Singleline); // Strip Opening and Closing Braces
|
||||
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
|
||||
retval = Regex.Replace(retval, @"\{[^{]*?\}", "", RegexOptions.Singleline); // Strip Clauses - remove anything from curly braces
|
||||
retval = Regex.Replace(retval, @"\\f[0-9] ", ""); // remove font command with ending space
|
||||
retval = Regex.Replace(retval, @"\\f[0-9]", ""); // remove font command without ending space
|
||||
retval = Regex.Replace(retval, @"\\[^ \\?]+", new MatchEvaluator(ReplaceRTFClause)); // take backslash xyz and evaluates them
|
||||
// remove a space if there is one as the first character or the last character
|
||||
if (retval[0]==' ')retval = retval.Remove(0, 1);
|
||||
retval = retval.TrimEnd(' ');
|
||||
// remove \r\n and \par at end of string.
|
||||
if (retval.Substring(retval.Length - 2, 2) == "\r\n") retval = retval.Remove(retval.Length - 2, 2);
|
||||
if (retval.Substring(retval.Length - 4, 4) == @"\par") retval = retval.Remove(retval.Length - 4, 4);
|
||||
|
||||
if (retval.Length == 0) return "";
|
||||
if (retval.Substring(retval.Length - 2, 2) == @"\v") retval = retval.Remove(retval.Length - 2, 2);
|
||||
retval = RemoveRtfStyles(retval);
|
||||
retval = retval.Replace(@"(![", @"\{");
|
||||
retval = retval.Replace(@"(!]", @"\}");
|
||||
return retval;
|
||||
}
|
||||
#endregion
|
||||
#region StyleData
|
||||
private VE_Font GetItemFont()
|
||||
{
|
||||
VE_Font font = null;
|
||||
FormatInfo format = _MyItemInfo.ActiveFormat;
|
||||
int type = (int)_MyItemInfo.MyContent.Type;
|
||||
switch (type/10000)
|
||||
{
|
||||
case 0: // procedure
|
||||
font = format.PlantFormat.FormatData.Font;
|
||||
break;
|
||||
case 1: // section
|
||||
font = format.PlantFormat.FormatData.SectData.SectionHeader.Font;
|
||||
break;
|
||||
case 2: // step types
|
||||
int typindx = type - 20000; // what to do for other types rather than steps
|
||||
font = format.PlantFormat.FormatData.StepDataList[typindx].Font;
|
||||
break;
|
||||
}
|
||||
TextFont = font;
|
||||
return font;
|
||||
}
|
||||
#endregion
|
||||
#region DoListElements
|
||||
private int FindTokenChar(string txt, int startIndex)
|
||||
{
|
||||
// 'tokens' are for symbols and links (ro & transitions). symbols are represented by \u<num>
|
||||
// and links are represented by \v <START]\v0 'link text'\v #'link info'[END>\v0
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
int indx = txt.IndexOf('\\', startIndex);
|
||||
if (indx < 0) return indx;
|
||||
// see if symbol (but not underline) or another rtf command: has a 'u'
|
||||
// followed by a non-underline or single quote, and if so, return it.
|
||||
if (((txt[indx + 1] == 'u' && txt[indx + 2] != 'l')) || (txt[indx + 1] == '\'')) return indx;
|
||||
// see if link
|
||||
if (txt[indx + 1] == 'v') return indx;
|
||||
// Otherwise, get next index, must have been a slash or other rtf command.
|
||||
startIndex = indx + 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private int DoTextElement(string text, int startIndex, int index)
|
||||
{
|
||||
displayTextElement vte = new displayTextElement();
|
||||
vte.Type = E_TextElementType.Text;
|
||||
int len = (index == -1) ? text.Length - startIndex : index - startIndex;
|
||||
vte.Text = text.Substring(startIndex, len);
|
||||
DisplayTextElementList.Add(vte);
|
||||
return index+1;
|
||||
}
|
||||
private int DoLink(string text, int startIndex)
|
||||
{
|
||||
int retval = -1;
|
||||
int fnd = text.IndexOf("#Link:", startIndex);
|
||||
if (text.Substring(fnd + 6, 3) == "Ref")
|
||||
retval = DoRO(text, startIndex);
|
||||
else
|
||||
retval = DoTran(text, startIndex);
|
||||
return retval;
|
||||
}
|
||||
private int DoRO(string text, int index)
|
||||
{
|
||||
displayLinkElement vte = new displayLinkElement();
|
||||
vte.Type = E_TextElementType.ReferencedObject;
|
||||
return DoLinkElements(text, index, vte);
|
||||
}
|
||||
private string FixTransition(string link, string text)
|
||||
{
|
||||
if (link.IndexOf("<NewID>") != -1) return text;
|
||||
int transitionID = Convert.ToInt32(link.Split(" ".ToCharArray())[1]);
|
||||
// Find the transition
|
||||
if (_MyItemInfo.MyContent.ContentTransitionCount <= 0) return "*Resolved Transition Text*";
|
||||
foreach (TransitionInfo ti in _MyItemInfo.MyContent.ContentTransitions)
|
||||
{
|
||||
if (ti.TransitionID == transitionID)
|
||||
{
|
||||
string path = ti.ResolvePathTo(_MyFormat, _MyItemInfo, ItemInfo.Get(ti.ToID), ti.RangeID==0?null:ItemInfo.Get(ti.RangeID));
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
private int DoTran(string text,int index)
|
||||
{
|
||||
displayLinkElement vte = new displayLinkElement();
|
||||
|
||||
// determine if Range by checking for "R" after Transition (otherwise ":")
|
||||
int linkindx = text.IndexOf(@"#Link", index);
|
||||
vte.Type = (text[linkindx+16]=='R')?E_TextElementType.TransitionRange:E_TextElementType.Transition;
|
||||
return DoLinkElements(text, index, vte);
|
||||
}
|
||||
private int DoLinkElements(string text, int index, displayLinkElement vte)
|
||||
{
|
||||
// Find the 'end comment' for the <START], can't count characters
|
||||
// because there may be formatting characters such as \b or \ul before
|
||||
// the \v0
|
||||
int linkIndx = text.IndexOf(@"#Link", index);
|
||||
int endStartTknIndx = text.IndexOf(@"\v0 ", index);
|
||||
int endTextIndx = text.IndexOf(@"\v ", endStartTknIndx); // find end of text
|
||||
vte.Text = text.Substring(endStartTknIndx + 4, endTextIndx - endStartTknIndx - 4); // 4 for \v0
|
||||
|
||||
// Now get the link part. It can be terminated by a '\v0' or an [END>
|
||||
int endLinkIndxV = text.IndexOf(@"\v0 ", linkIndx);
|
||||
if (endLinkIndxV == -1) endLinkIndxV = text.IndexOf(@"\v0", linkIndx); // at end of string
|
||||
int endLinkIndxE = text.IndexOf(@"[END>", linkIndx);
|
||||
int endLinkIndx = (endLinkIndxV < endLinkIndxE) ? endLinkIndxV : endLinkIndxE;
|
||||
vte.Link = text.Substring(linkIndx + 6, endLinkIndx - linkIndx - 6); // 6 for #Link:
|
||||
|
||||
string tmptxt = null;
|
||||
if (vte.Type != E_TextElementType.ReferencedObject)
|
||||
{
|
||||
tmptxt = FixTransition(vte.Link, vte.Text);
|
||||
vte.Text = tmptxt;
|
||||
}
|
||||
|
||||
// Now get the entire text & link. Account for various ending possibilities:
|
||||
// ends with '\v0\'; ends with '\v0 '; ends with '\v0' (end of string);
|
||||
// ends with '[END>' if two in a row - will have <START]
|
||||
int endToken = (endLinkIndx == endLinkIndxE)?endLinkIndx+3:text.IndexOf(@"[END>", endLinkIndx + 3); // get past end of link
|
||||
int endComment = text.IndexOf(@"\v0", endToken);
|
||||
|
||||
int rettoken = 0;
|
||||
int retlen = 4;
|
||||
if (endComment + 3 == text.Length) retlen = 3;
|
||||
else if (text[endComment + 3] == '\\') retlen = 3;
|
||||
vte.TextAndLink = text.Substring(index, endComment - index + retlen);
|
||||
rettoken = endComment + retlen;
|
||||
if (vte.Type != E_TextElementType.ReferencedObject) vte.TextAndLink = vte.TextAndLink = vte.TextAndLink.Replace("(Resolved Transition Text)", tmptxt);
|
||||
DisplayTextElementList.Add(vte);
|
||||
return rettoken;
|
||||
}
|
||||
private int DoSymbol(string text, int startIndex, int index)
|
||||
{
|
||||
displayTextElement vte = new displayTextElement();
|
||||
vte.Type = E_TextElementType.Symbol;
|
||||
// symbols are the unicode/rtf command. A symbol can be represented by \'xy or
|
||||
// in the text from the database \uxyz?. If the \'xy is used the length of the
|
||||
// symbol number will always be two, otherwise find the index of the '?' to
|
||||
// find the end.
|
||||
int endindx = -1;
|
||||
if (text[index + 1] == '\'') endindx = index + 3;
|
||||
else endindx = text.IndexOf("?", index);
|
||||
vte.Text = text.Substring(index, endindx - index + 1);
|
||||
DisplayTextElementList.Add(vte);
|
||||
return endindx+1;
|
||||
}
|
||||
#endregion
|
||||
#region ReplaceWords
|
||||
private ReplaceStr _rs;
|
||||
//private string ReplaceIt(Match m)
|
||||
//{
|
||||
// string s = m.ToString();
|
||||
// string t = s.Replace(_rs.ReplaceWord, _rs.ReplaceWith);
|
||||
// return m.ToString().Replace(_rs.ReplaceWord, _rs.ReplaceWith);
|
||||
//}
|
||||
private string DoReplaceWords(string Text)
|
||||
{
|
||||
ReplaceStrList rsl = _MyFormat.PlantFormat.FormatData.SectData.ReplaceStrList;
|
||||
foreach (ReplaceStr rs in rsl)
|
||||
{
|
||||
if (_MyItemInfo.MyContent.Type < 20000) return Text; // for now only replace in steps.
|
||||
bool replaceit = false;
|
||||
|
||||
// note that the order of this check is important. Check in this order...
|
||||
// background here
|
||||
if (_MyItemInfo.IsHigh && (rs.Flag & E_ReplaceFlags.High)>0) replaceit = true;
|
||||
else if ((_MyItemInfo.IsTable || _MyItemInfo.IsFigure) && (rs.Flag & E_ReplaceFlags.Table) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsInRNO && (rs.Flag & E_ReplaceFlags.RNO) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsCaution && (rs.Flag & E_ReplaceFlags.Caution) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsNote && (rs.Flag & E_ReplaceFlags.Note) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsInFirstLevelSubStep && (rs.Flag & E_ReplaceFlags.Substep) > 0) replaceit = true;
|
||||
else if (_MyItemInfo.IsAccPages & (rs.Flag & E_ReplaceFlags.Attach) > 0) replaceit = true;
|
||||
|
||||
if (replaceit)
|
||||
{
|
||||
// CASEINSENS: Do ReplaceWords for all words that match, regardless of case, and replace
|
||||
// with the ReplaceWith string as is
|
||||
if ((rs.Flag & E_ReplaceFlags.CaseInsens) > 0)
|
||||
{
|
||||
string res = "";
|
||||
string fortest = Text.ToUpper();
|
||||
string pat = @"(?<=\W|^)" + rs.ReplaceWord.ToUpper() + @"(?=\W|$)";
|
||||
int cpindx = 0;
|
||||
foreach (Match m in Regex.Matches(fortest, pat))
|
||||
{
|
||||
res += Text.Substring(cpindx, m.Index-cpindx);
|
||||
cpindx += (m.Index - cpindx);
|
||||
res += rs.ReplaceWith;
|
||||
cpindx += rs.ReplaceWord.Length;
|
||||
}
|
||||
if (cpindx < Text.Length) res += Text.Substring(cpindx, Text.Length - cpindx);
|
||||
Text = res;
|
||||
}
|
||||
// CASEINSENSALL: Do ReplaceWords for all words that match the ReplaceWord, regardless of case
|
||||
else if ((rs.Flag & E_ReplaceFlags.CaseInsensAll) > 0)
|
||||
{
|
||||
// not in hlp
|
||||
}
|
||||
// CASEINSENSFIRST: Do ReplaceWords for all words that exactly match the ReplaceWord,
|
||||
// except the case where the first character may be different
|
||||
else if ((rs.Flag & E_ReplaceFlags.CaseInsensFirst) > 0)
|
||||
{
|
||||
// not in hlp
|
||||
}
|
||||
else
|
||||
{
|
||||
string pat = @"(?<=\W|^)" + rs.ReplaceWord + @"(?=\W|$)";
|
||||
Text = Regex.Replace(Text, pat, rs.ReplaceWith);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return Text;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region displayTextElementClass
|
||||
public enum E_TextElementType : uint
|
||||
{
|
||||
Text = 0,
|
||||
Transition = 1,
|
||||
TransitionRange = 2,
|
||||
ReferencedObject = 3,
|
||||
Symbol = 4
|
||||
};
|
||||
public class displayTextElement
|
||||
{
|
||||
private E_TextElementType _Type;
|
||||
public E_TextElementType Type
|
||||
{
|
||||
get { return _Type; }
|
||||
set { _Type = value; }
|
||||
}
|
||||
private string _Text;
|
||||
public string Text
|
||||
{
|
||||
get { return _Text; }
|
||||
set { _Text = value; }
|
||||
}
|
||||
}
|
||||
public class displayLinkElement : displayTextElement
|
||||
{
|
||||
private string _Link;
|
||||
public string Link
|
||||
{
|
||||
get { return _Link; }
|
||||
set { _Link = value; }
|
||||
}
|
||||
private string _TextAndLink;
|
||||
public string TextAndLink
|
||||
{
|
||||
get { return _TextAndLink; }
|
||||
set { _TextAndLink = value; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
512
PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs.bak
Normal file
512
PROMS/VEPROMS.CSLA.Library/Extension/DocVersionExt.cs.bak
Normal file
@@ -0,0 +1,512 @@
|
||||
// ========================================================================
|
||||
// Copyright 2006 - Volian Enterprises, Inc. All rights reserved.
|
||||
// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
|
||||
// ------------------------------------------------------------------------
|
||||
// $Workfile: $ $Revision: $
|
||||
// $Author: $ $Date: $
|
||||
//
|
||||
// $History: $
|
||||
// ========================================================================
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
using System.Collections.Generic;
|
||||
//using VEPROMS.Properties;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class DocVersion: IVEDrillDown
|
||||
{
|
||||
#region VersionType
|
||||
public VersionTypeEnum eVersionType
|
||||
{
|
||||
get { return (VersionTypeEnum)_VersionType; }
|
||||
set { _VersionType = (int)value; }
|
||||
}
|
||||
#endregion
|
||||
#region DocVersion Config
|
||||
[NonSerialized]
|
||||
private DocVersionConfig _DocVersionConfig;
|
||||
public DocVersionConfig DocVersionConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DocVersionConfig == null)
|
||||
{
|
||||
_DocVersionConfig = new DocVersionConfig(this);
|
||||
_DocVersionConfig.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_DocVersionConfig_PropertyChanged);
|
||||
}
|
||||
return _DocVersionConfig;
|
||||
}
|
||||
}
|
||||
private void _DocVersionConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
Config = _DocVersionConfig.ToString();
|
||||
}
|
||||
#endregion
|
||||
#region UserSettings
|
||||
/// <summary>
|
||||
/// These settings are set on the user interface side.
|
||||
/// This is used to control whether the Name and/or Title is displayed
|
||||
/// next to the tree nodes in the user interface
|
||||
/// </summary>
|
||||
private bool _DisplayTreeNodeNames = true;
|
||||
public bool DisplayTreeNodeNames
|
||||
{
|
||||
get { return _DisplayTreeNodeNames; }
|
||||
set { _DisplayTreeNodeNames = value; }
|
||||
}
|
||||
private bool _DisplayTreeNodeTitles = false;
|
||||
|
||||
public bool DisplayTreeNodeTitles
|
||||
{
|
||||
get { return _DisplayTreeNodeTitles; }
|
||||
set { _DisplayTreeNodeTitles = value; }
|
||||
}
|
||||
#endregion
|
||||
public override string ToString()
|
||||
{
|
||||
// assume that at least one of the two options was selected
|
||||
string rtnstr = "";
|
||||
if (_DisplayTreeNodeNames) rtnstr = Name;
|
||||
if (_DisplayTreeNodeTitles)
|
||||
{
|
||||
if (rtnstr.Length > 0) rtnstr += " - ";
|
||||
rtnstr += Title;
|
||||
}
|
||||
return rtnstr;
|
||||
//return string.Format("{0} - {1}", Name, Title);
|
||||
}
|
||||
#region IVEDrillDown
|
||||
//public System.Collections.IList GetChildren()
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
//public bool HasChildren
|
||||
//{
|
||||
// get { return _ItemID > 0; }
|
||||
//}
|
||||
//public IVEDrillDown ActiveParent
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return MyFolder;
|
||||
// }
|
||||
//}
|
||||
//private Format _ActiveFormat = null;
|
||||
//public Format ActiveFormat
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (_ActiveFormat == null)
|
||||
// _ActiveFormat = LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat;
|
||||
// return _ActiveFormat;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// _ActiveFormat = null;
|
||||
// }
|
||||
//}
|
||||
//public Format LocalFormat
|
||||
//{
|
||||
// get { return MyFormat; }
|
||||
//}
|
||||
public ConfigDynamicTypeDescriptor MyConfig
|
||||
{
|
||||
get { return DocVersionConfig; }
|
||||
}
|
||||
#endregion
|
||||
public DocVersionInfo MyDocVersionInfo
|
||||
{ get { return DocVersionInfo.Get(VersionID); } }
|
||||
}
|
||||
public partial class DocVersionInfo : IVEDrillDownReadOnly
|
||||
{
|
||||
#region SearchPaths
|
||||
public string _SearchDVPath;
|
||||
public string SearchDVPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SearchDVPath == null)
|
||||
_SearchDVPath = ActiveParent.SearchDVPath + "\u0007" + Name;
|
||||
return _SearchDVPath;
|
||||
}
|
||||
}
|
||||
public string SearchPath { get { return ""; } }
|
||||
#endregion
|
||||
|
||||
#region DocVersion Config
|
||||
[NonSerialized]
|
||||
private DocVersionConfig _DocVersionConfig;
|
||||
public DocVersionConfig DocVersionConfig
|
||||
{ get { return (_DocVersionConfig != null ? _DocVersionConfig : _DocVersionConfig = new DocVersionConfig(this)); } }
|
||||
private void DocVersionConfigRefresh()
|
||||
{
|
||||
_DocVersionConfig = null;
|
||||
}
|
||||
#endregion
|
||||
#region MOVE TO DOCVERSION CONFIG
|
||||
private string GetProfile(string grp, string nam)
|
||||
{
|
||||
return GetProfile(grp, nam, false);
|
||||
}
|
||||
|
||||
private string GetProfile(string grp, string nam, bool flag)
|
||||
{
|
||||
DocVersionConfig dvcfg = DocVersionConfig;
|
||||
string buff = null;
|
||||
if (grp != null && !grp.Equals(string.Empty))
|
||||
{
|
||||
buff = dvcfg.GetValue(grp, nam); // get the value of 'nam' in 'grp'
|
||||
if (buff == null || buff.Equals(string.Empty))
|
||||
{
|
||||
if (!flag)
|
||||
buff = string.Format("<{0}-{1}>", grp, nam);
|
||||
else
|
||||
buff = null;
|
||||
}
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
||||
|
||||
public string UnitSpecific(string str, int len)
|
||||
{
|
||||
|
||||
// This routine retrieves the procedure number format from the
|
||||
// current directory and uses it to adjust the procedure number
|
||||
// in the specified string
|
||||
string retvalu = "";
|
||||
string asis = "#";
|
||||
if (str == null || str.Equals(string.Empty)) return retvalu; // return a null (empty) string
|
||||
/*
|
||||
* Bug fix: B2005-017 3/2/2005
|
||||
* Need to use the largest procedure number length that's in the
|
||||
* SET.DFF file. "LargestNumber" is the largest length after the
|
||||
* procedure number is replaced via the SET.INI file "replace" list.
|
||||
*
|
||||
if(len==0)len=LargestNumber;
|
||||
*/
|
||||
// TODO: Do we need this line?-->>> if(len==0)len=LargestRawSetNumber;
|
||||
|
||||
//GetPrivateProfileString("unit", "procedure number", asis, mstr, MAXPATH, "proc.ini");
|
||||
string pnum = asis;
|
||||
//rhm/jcb stuff 20120511
|
||||
//string mstr = GetProfile("Unit", "ProcedureNumber", true);
|
||||
string mstr = DocVersionConfig.Unit_ProcedureNumber;
|
||||
if (mstr != null && !mstr.Equals(string.Empty))
|
||||
pnum = mstr;
|
||||
if (pnum.Equals(asis))
|
||||
retvalu = str;
|
||||
else if (pnum[0] == '!')
|
||||
{
|
||||
// look for mstr in SET.INI
|
||||
// GetPrivateProfileString("replace", mstr, mstr, tonum, 24, "set.ini");
|
||||
|
||||
// TODO: NOT SURE IF SET.INI AND PROC.INI HAVE UNIQUE GROUP NAMES!!!!!!!
|
||||
//mstr = GetProfile("Replace", mstr);
|
||||
mstr = GetProfile("Replace", mstr, true); // true allow it to return a null if not found
|
||||
if (mstr == null) retvalu = str; // no replacement, use procedure number as is
|
||||
}
|
||||
else
|
||||
{
|
||||
retvalu = "";
|
||||
string[] pnumsplit = pnum.Split(new Char[] { '#' });
|
||||
int cnt = 0;
|
||||
foreach (string s in pnumsplit)
|
||||
{
|
||||
if (!s.Equals(string.Empty))
|
||||
{
|
||||
if ((cnt == 0) && (str.StartsWith(" ")))
|
||||
{
|
||||
string padding = new string(' ', s.Length);
|
||||
retvalu += padding;
|
||||
}
|
||||
else
|
||||
retvalu += s;
|
||||
}
|
||||
else
|
||||
retvalu += str.Trim();
|
||||
cnt++;
|
||||
}
|
||||
// append trailing blanks or procedure number (str)
|
||||
if (str.EndsWith(" "))
|
||||
{
|
||||
// count number of trailing blanks and append them to retvalu
|
||||
cnt = str.Length - 1;
|
||||
while (cnt > 0 && str[cnt] == ' ') cnt--;
|
||||
retvalu += new string(' ', str.Length - cnt - 1);
|
||||
}
|
||||
}
|
||||
return retvalu;
|
||||
}
|
||||
|
||||
public string Evaluate(string str, int len)
|
||||
{
|
||||
string retval = null;
|
||||
string swhir = "PSU"; /* order inwhich to check */
|
||||
string pn;
|
||||
if (str.Length > 1 && str[1] == '-')
|
||||
{
|
||||
int swptr = swhir.IndexOf((str.ToUpper())[0]);
|
||||
//char swchar = '';
|
||||
//if (swptr != -1)
|
||||
// swchar = swhir[swptr];
|
||||
|
||||
string sav = str.Substring(len);
|
||||
str = str.Substring(0, len);
|
||||
string substr = str.Substring(2);
|
||||
substr = substr.Replace(" ","");
|
||||
while (swptr >= 0 && swptr < swhir.Length && retval == null) //retval.Equals(string.Empty))
|
||||
{
|
||||
switch (swhir[swptr])
|
||||
{
|
||||
case 'U':
|
||||
//retval = GetProfile("Unit", substr, true);
|
||||
if (substr.ToLower() == "id")
|
||||
retval = this.DocVersionConfig.Unit_ID;
|
||||
if (substr.ToLower() == "name")
|
||||
retval = this.DocVersionConfig.Unit_Name;
|
||||
if (substr.ToLower() == "number")
|
||||
retval = this.DocVersionConfig.Unit_Number;
|
||||
if (substr.ToLower() == "text")
|
||||
retval = this.DocVersionConfig.Unit_Text;
|
||||
//retval = this.DocVersionConfig.Other_Unit_ID;
|
||||
//retval = this.DocVersionConfig.Other_Unit_Name;
|
||||
//retval = this.DocVersionConfig.Other_Unit_Number;
|
||||
//retval = this.DocVersionConfig.Other_Unit_Text;
|
||||
break;
|
||||
case 'S':
|
||||
//retval = GetProfile("Procedure_Set", substr, true);
|
||||
if(substr.ToLower() == "id")
|
||||
retval = this.DocVersionConfig.Unit_ProcedureSetID;
|
||||
if (substr.ToLower() == "name")
|
||||
retval = this.DocVersionConfig.Unit_ProcedureSetName;
|
||||
break;
|
||||
case 'P':
|
||||
//TODO: THIS IS A GLOBAL IN THE 16 BIT CODE!!!!
|
||||
string procnumber = "";
|
||||
pn = UnitSpecific(procnumber, 0);
|
||||
retval = GetProfile(pn, substr, true);
|
||||
break;
|
||||
}
|
||||
if (retval == null) // .Equals(string.Empty))
|
||||
swptr++;
|
||||
}
|
||||
str += sav;
|
||||
}
|
||||
else if (len == 1 && (str.ToUpper())[0] == 'U')
|
||||
{
|
||||
retval = this.DocVersionConfig.Unit_Number;
|
||||
}
|
||||
else if (len == 2 && str.StartsWith("ID"))
|
||||
{
|
||||
retval = this.DocVersionConfig.Unit_ID;
|
||||
}
|
||||
// if the return value is empty, then the resulting
|
||||
// evaluation should repeat the token string including
|
||||
// the braces. - the beginning brace is not passed in.
|
||||
//if (retval.Equals(string.Empty))
|
||||
//{
|
||||
// retval = (char*)mallocq(len + 3);
|
||||
// strncpy(retval, str - 1, len + 2);
|
||||
//}
|
||||
if (retval == null)
|
||||
retval = string.Format("<{0}>", str.Substring(0, len));
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
public string ProcessDocVersionSpecificInfo(string rawvalue)
|
||||
{
|
||||
string str = rawvalue;
|
||||
string rtnstr = "";
|
||||
int l = rawvalue.Length;
|
||||
while (l > 0)
|
||||
{
|
||||
int ptr = str.IndexOf('<'); //nextDelimiter("<", str, l);
|
||||
int cptr = (ptr == -1) ? -1 : str.IndexOf('>'); //nextDelimiter(">", ptr, strlen(ptr));
|
||||
// jsj 2/5/10 added "|| (ptr > cptr)" to fix bug where rawvalue = "Insert token for ->Step<- to transition back to."
|
||||
if (ptr == -1 || (ptr > -1 && ((cptr == -1) || (ptr > cptr))))
|
||||
{
|
||||
//add(new seText(str, l));
|
||||
//str += l;
|
||||
rtnstr += str;
|
||||
l = 0; // jump out of while loop
|
||||
}
|
||||
else
|
||||
{
|
||||
int cnt = ptr;
|
||||
if (cnt > 0)
|
||||
{
|
||||
//add(new seText(str, cnt));
|
||||
rtnstr += str.Substring(0, cnt);
|
||||
l -= cnt;
|
||||
str = str.Substring(ptr);
|
||||
}
|
||||
ptr = str.IndexOf('>')+1; //nextDelimiter(">", str, l) + 1;
|
||||
cnt = ptr; //(int)(ptr - str);
|
||||
//add(new seUser(str + 1, cnt - 2));
|
||||
rtnstr += Evaluate(str.Substring(1, cnt - 2),cnt-2);
|
||||
l -= cnt;
|
||||
str = str.Substring(ptr); //ptr;
|
||||
}
|
||||
}
|
||||
return rtnstr;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
ItemInfoList _Procedures = null;
|
||||
public ItemInfoList Procedures
|
||||
{ get { return (_Procedures != null ? _Procedures : _Procedures = ItemInfoList.GetList(_ItemID, (int)E_FromType.Procedure)); } }
|
||||
public void ResetProcedures()
|
||||
{
|
||||
_Procedures = null;
|
||||
}
|
||||
#region IVEReadOnlyItem
|
||||
public System.Collections.IList GetChildren()
|
||||
{
|
||||
return Procedures;
|
||||
}
|
||||
//public bool ChildrenAreLoaded
|
||||
//{
|
||||
// get { return _iil == null; }
|
||||
//}
|
||||
public bool HasChildren
|
||||
{
|
||||
get { return _ItemID > 0; }
|
||||
}
|
||||
public IVEDrillDownReadOnly ActiveParent
|
||||
{
|
||||
get
|
||||
{
|
||||
return MyFolder;
|
||||
}
|
||||
}
|
||||
public FormatInfo ActiveFormat
|
||||
{
|
||||
get {return LocalFormat != null ? LocalFormat : ActiveParent.ActiveFormat;}
|
||||
}
|
||||
public FormatInfo LocalFormat
|
||||
{
|
||||
get {
|
||||
//Console.WriteLine("DV Local {0} {1} {2}", (MyFormat == null) ? "MYformat is null" : MyFormat.Name,FormatID,(MyFormat == null)?0:MyFormat.FormatID);
|
||||
return MyFormat;
|
||||
}
|
||||
}
|
||||
public ConfigDynamicTypeDescriptor MyConfig
|
||||
{
|
||||
get { return Get().DocVersionConfig; }
|
||||
}
|
||||
//public bool HasStandardSteps()
|
||||
//{ return false; }
|
||||
#region UserSettings
|
||||
/// <summary>
|
||||
/// These settings are set on the user interface side.
|
||||
/// This is used to control whether the Name and/or Title is displayed
|
||||
/// next to the tree nodes in the user interface
|
||||
/// </summary>
|
||||
private bool _DisplayTreeNodeNames = true;
|
||||
public bool DisplayTreeNodeNames
|
||||
{
|
||||
get { return _DisplayTreeNodeNames; }
|
||||
set { _DisplayTreeNodeNames = value; }
|
||||
}
|
||||
private bool _DisplayTreeNodeTitles = false;
|
||||
|
||||
public bool DisplayTreeNodeTitles
|
||||
{
|
||||
get { return _DisplayTreeNodeTitles; }
|
||||
set { _DisplayTreeNodeTitles = value; }
|
||||
}
|
||||
#endregion
|
||||
public override string ToString()
|
||||
{
|
||||
// assume that at least one of the two options was selected
|
||||
string rtnstr = "";
|
||||
if (_DisplayTreeNodeNames) rtnstr = Name;
|
||||
if (_DisplayTreeNodeTitles)
|
||||
{
|
||||
if (rtnstr.Length > 0) rtnstr += " - ";
|
||||
rtnstr += Title;
|
||||
}
|
||||
return rtnstr;
|
||||
//return string.Format("{0} - {1}", Name, Title);
|
||||
}
|
||||
//public string ToString(string str,System.IFormatProvider ifp)
|
||||
//{
|
||||
// return ToString();
|
||||
//}
|
||||
public ItemInfo LastChild()
|
||||
{
|
||||
return MyItem.LastSibling;
|
||||
}
|
||||
public ItemInfo FirstChild()
|
||||
{
|
||||
return MyItem;
|
||||
}
|
||||
#endregion
|
||||
#region Extension
|
||||
partial class DocVersionInfoExtension : extensionBase
|
||||
{
|
||||
public override void Refresh(DocVersionInfo tmp)
|
||||
{
|
||||
tmp.DocVersionConfigRefresh();
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
public ROFstInfo GetROFst(int rodbid)
|
||||
{
|
||||
foreach (AssociationInfo dva in DocVersionAssociations)
|
||||
{
|
||||
if (dva.MyROFst.RODbID == rodbid)
|
||||
return dva.MyROFst;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public int MultiUnitCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return DocVersionConfig.Unit_Count;
|
||||
}
|
||||
}
|
||||
private string[] _UnitNames;
|
||||
public string[] UnitNames
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UnitNames == null)
|
||||
{
|
||||
// _UnitNames = DocVersionConfig.Unit_Name.Split(',');
|
||||
_UnitNames = new string[DocVersionConfig.Unit_Count];
|
||||
int j = 0;
|
||||
for (int k = 1; k <= DocVersionConfig.MaxSlaveIndex; k++)
|
||||
{
|
||||
DocVersionConfig.SelectedSlave = k;
|
||||
try
|
||||
{
|
||||
_UnitNames[j] = DocVersionConfig.Unit_Name;
|
||||
j++;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return _UnitNames;
|
||||
}
|
||||
}
|
||||
}
|
||||
public enum VersionTypeEnum : int
|
||||
{
|
||||
WorkingDraft = 0, Temporary = 1, Revision = 128, Approved = 129
|
||||
}
|
||||
}
|
1387
PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs.bak
Normal file
1387
PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
15
PROMS/VEPROMS.CSLA.Library/Extension/GroupMembershipExt.cs
Normal file
15
PROMS/VEPROMS.CSLA.Library/Extension/GroupMembershipExt.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace Volian.Object.Library
|
||||
{
|
||||
public partial class GroupMembership : BusinessBase<GroupMembership>
|
||||
{
|
||||
public string User_FullName
|
||||
{
|
||||
get { return User_LastName + ", " + User_FirstName; }
|
||||
}
|
||||
}
|
||||
}
|
3721
PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs.bak
Normal file
3721
PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
1081
PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs.bak
Normal file
1081
PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
401
PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.org
Normal file
401
PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.org
Normal file
@@ -0,0 +1,401 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class ItemInfo
|
||||
{
|
||||
#region Old Insert
|
||||
//public ItemInfo InsertSiblingBeforeOld(string text)
|
||||
//{
|
||||
// return InsertSiblingBefore(text, null);
|
||||
//}
|
||||
//public ItemInfo InsertSiblingBeforeOld(string text, string number)
|
||||
//{
|
||||
// ItemInfo prevItemInfo = MyPrevious;
|
||||
// ItemInfo newItemInfo = null;
|
||||
// PartInfoList partInfoList = null;
|
||||
// if (MyParent != null && MyParent.MyContent != null)
|
||||
// {
|
||||
// MyParent.MyContent.RefreshContentParts();
|
||||
// partInfoList = MyParent.MyContent.ContentParts;
|
||||
// }
|
||||
// using (Item prevItem = prevItemInfo == null ? null : prevItemInfo.Get()) // Get the previous Item
|
||||
// {
|
||||
// using (Item newItem = Item.MakeItem(prevItem, Content.MakeContent(number, text, MyContent.Type, null, null))) // Create the new Item
|
||||
// {
|
||||
// using (Item thisItem = Get()) // Get the next item in the list
|
||||
// {
|
||||
// thisItem.MyPrevious = newItem; // Point to the new item
|
||||
// thisItem.Save(); // Save Changes
|
||||
// if (prevItem == null)
|
||||
// {
|
||||
// PartInfo partInfo = partInfoList.Find(this);
|
||||
// using (Part part = partInfo.Get())
|
||||
// {
|
||||
// part.MyItem = newItem;
|
||||
// part.Save();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // ToDo: Need change PartInfo in PartInfoList
|
||||
// newItemInfo = ItemInfo.Get(newItem.ItemID);
|
||||
// newItemInfo.ResetOrdinal();
|
||||
// }
|
||||
// }
|
||||
// return newItemInfo;
|
||||
//}
|
||||
//public ItemInfo InsertSiblingAfterOld(string text)
|
||||
//{
|
||||
// return InsertSiblingAfter(text, null);
|
||||
//}
|
||||
//public ItemInfo InsertSiblingAfterOld(string text, string number)
|
||||
//{
|
||||
// return InsertSiblingAfter(text, number, MyContent.Type);
|
||||
//}
|
||||
//public ItemInfo InsertSiblingAfterOld(string text, string number, int? type)
|
||||
//{
|
||||
// ItemInfo nextItemInfo = NextItem;
|
||||
// ItemInfo newItemInfo = null;
|
||||
// using (Item thisItem = Get()) // Get the Current Item
|
||||
// {
|
||||
// using (Item newItem = Item.MakeItem(thisItem, Content.MakeContent(number, text, type, null, null))) // Create the new Item
|
||||
// {
|
||||
// if (nextItemInfo != null) // Simple case, adding to end of list:
|
||||
// using (Item nextItem = nextItemInfo.Get()) // Get the next item in the list
|
||||
// {
|
||||
// nextItem.MyPrevious = newItem; // Point to the new item
|
||||
// nextItem.Save(); // Save Changes
|
||||
// }
|
||||
// // ToDo: Need change PartInfo in PartInfoList
|
||||
// newItemInfo = ItemInfo.Get(newItem.ItemID);
|
||||
// newItemInfo.ResetOrdinal();
|
||||
// }
|
||||
// }
|
||||
// return newItemInfo;
|
||||
//}
|
||||
//public ItemInfo InsertChildOld(E_FromType fromType, int type, string text)
|
||||
//{
|
||||
// return InsertChild(fromType, type, text, null);
|
||||
//}
|
||||
//public ItemInfo InsertChildOld(E_FromType fromType, int type, string text, string number)
|
||||
//{
|
||||
// ItemInfo newItemInfo = null;
|
||||
// using (Item thisItem = Get()) // Get the Current Item
|
||||
// {
|
||||
// using (Item newItem = Item.MakeItem(null, Content.MakeContent(number, text, type, null, null))) // Create the new Item
|
||||
// {
|
||||
// PartInfo partInfo = MyContent.ContentParts == null ? null : MyContent.ContentParts.Find(fromType);
|
||||
// if (partInfo != null)
|
||||
// {
|
||||
// //this could be equivalent to adding a sibling with a specific type
|
||||
// using (Part part = partInfo.Get())
|
||||
// {
|
||||
// part.MyItem.MyPrevious = newItem;
|
||||
// part.MyItem.Save();
|
||||
// part.MyItem = newItem;
|
||||
// part.Save();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // This means that a part needs to be added to point to the new item
|
||||
// //using (Part part = Part.MakePart(thisItem.MyContent, ))
|
||||
// //{ ;}
|
||||
// thisItem.MyContent.ContentParts.Add((int)fromType, newItem);
|
||||
// thisItem.Save();
|
||||
// }
|
||||
// newItemInfo = ItemInfo.Get(newItem.ItemID);
|
||||
// }
|
||||
// }
|
||||
// ResetParts();
|
||||
// return newItemInfo;
|
||||
//}
|
||||
#endregion
|
||||
#region Insert Before
|
||||
public ItemInfo InsertSiblingBefore(string text)
|
||||
{
|
||||
return InsertSiblingBefore(text, null);
|
||||
}
|
||||
public ItemInfo InsertSiblingBefore(string text, string number)
|
||||
{
|
||||
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Before, number, text, null, null, null, null, DateTime.Now, Environment.UserName);
|
||||
// this item is updated in SQL so we have to manually force the iteminfo updates
|
||||
// Refresh ItemInfo to update Previous
|
||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
|
||||
tmp.UpdateTransitionText();
|
||||
return tmp;
|
||||
}
|
||||
#endregion
|
||||
#region Insert After
|
||||
public ItemInfo InsertSiblingAfter(string text)
|
||||
{
|
||||
return InsertSiblingAfter(text, null);
|
||||
}
|
||||
public ItemInfo InsertSiblingAfter(string text, string number)
|
||||
{
|
||||
return InsertSiblingAfter(text, number, MyContent.Type);
|
||||
}
|
||||
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
|
||||
{
|
||||
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName);
|
||||
//tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(ItemID, EAddpingPart.After, number, text, type, null, null, null, DateTime.Now, Environment.UserName));
|
||||
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
|
||||
// Refresh ItemInfo to update PreviousID field
|
||||
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
|
||||
tmp.UpdateTransitionText();
|
||||
return tmp;
|
||||
}
|
||||
private ItemInfo NewItemInfoFetch(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
|
||||
{
|
||||
ItemInfo tmp;
|
||||
if (addType == EAddpingPart.Child)
|
||||
{
|
||||
// adding children. Type is based on 'fromType'
|
||||
switch ((E_FromType)fromType)
|
||||
{
|
||||
case E_FromType.Procedure:
|
||||
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
break;
|
||||
case E_FromType.Section:
|
||||
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
break;
|
||||
default:
|
||||
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetType() == typeof(ProcedureInfo))
|
||||
tmp = DataPortal.Fetch<ProcedureInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
else if (GetType() == typeof(SectionInfo))
|
||||
tmp = DataPortal.Fetch<SectionInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
else
|
||||
tmp = DataPortal.Fetch<StepInfo>(new AddingPartCriteria(itemID, addType, number, text, type, fromType, formatID, config, dts, userID));
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
public void UpdateTransitionText()
|
||||
{
|
||||
// Update Ordinals from here down
|
||||
ResetOrdinal();
|
||||
// This returns a list of all of the transitions that may have been affected
|
||||
using(TransitionInfoList trans = TransitionInfoList.GetAffected(this.ItemID))
|
||||
{
|
||||
foreach (TransitionInfo tran in trans)
|
||||
{
|
||||
using (Content content = tran.MyContent.Get())
|
||||
{
|
||||
content.FixTransitionText(tran);
|
||||
if (content.IsDirty)
|
||||
content.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Insert Child
|
||||
public ItemInfo InsertChild(E_FromType fromType, int type, string text)
|
||||
{
|
||||
return InsertChild(fromType, type, text, null);
|
||||
}
|
||||
public ItemInfo InsertChild(E_FromType fromType, int type, string text, string number)
|
||||
{
|
||||
ItemInfo tmp = NewItemInfoFetch(ItemID, EAddpingPart.Child, number, text, type, (int?) fromType, null, null, DateTime.Now, Environment.UserName);
|
||||
// if next exists, it is updated in SQL so we have to manually force the iteminfo updates
|
||||
// Refresh ItemInfo to update PreviousID field
|
||||
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
// Update all of the content records that have transitions that point to the Siblings or Sibling Children of the new item
|
||||
tmp.UpdateTransitionText();
|
||||
return tmp;
|
||||
}
|
||||
#endregion
|
||||
#region DataPortal
|
||||
private void DataPortal_Fetch(AddingPartCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
ApplicationContext.LocalContext["cn"] = cn;
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID); //ABC After Before Child
|
||||
cm.Parameters.AddWithValue("@Number", criteria.Number); //ABC
|
||||
cm.Parameters.AddWithValue("@Text", criteria.Text); //ABC
|
||||
cm.Parameters.AddWithValue("@FormatID", criteria.FormatID); //ABC
|
||||
cm.Parameters.AddWithValue("@Config", criteria.Config); //ABC
|
||||
cm.Parameters.AddWithValue("@Type", criteria.Type); //ABC
|
||||
cm.Parameters.AddWithValue("@DTS", criteria.DTS); //ABC
|
||||
cm.Parameters.AddWithValue("@UserID", criteria.UserID); //ABC
|
||||
SqlParameter param_ContentID = new SqlParameter("@newItemID", SqlDbType.Int);
|
||||
param_ContentID.Direction = ParameterDirection.Output;
|
||||
cm.Parameters.Add(param_ContentID);
|
||||
switch (criteria.AddType)
|
||||
{
|
||||
case EAddpingPart.Child:
|
||||
cm.CommandText = "addItemChild";
|
||||
cm.Parameters.AddWithValue("@FromType", criteria.FromType); //--C
|
||||
break;
|
||||
case EAddpingPart.Before:
|
||||
cm.CommandText = "addItemSiblingBefore";
|
||||
break;
|
||||
case EAddpingPart.After:
|
||||
cm.CommandText = "addItemSiblingAfter";
|
||||
break;
|
||||
}
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
//newItemID = (int)cm.Parameters["@newContentID"].Value;
|
||||
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("ItemInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
[Serializable()]
|
||||
protected class AddingPartCriteria
|
||||
{
|
||||
#region Properties
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
private EAddpingPart _AddType;
|
||||
public EAddpingPart AddType
|
||||
{
|
||||
get { return _AddType; }
|
||||
set { _AddType = value; }
|
||||
}
|
||||
private string _Number=null;
|
||||
public string Number
|
||||
{
|
||||
get { return _Number; }
|
||||
set { _Number = value; }
|
||||
}
|
||||
private string _Text=null;
|
||||
public string Text
|
||||
{
|
||||
get { return _Text; }
|
||||
set { _Text = value; }
|
||||
}
|
||||
private int? _FromType = null;
|
||||
public int? FromType
|
||||
{
|
||||
get { return _FromType; }
|
||||
set { _FromType = value; }
|
||||
}
|
||||
private int? _Type=null;
|
||||
public int? Type
|
||||
{
|
||||
get { return _Type; }
|
||||
set { _Type = value; }
|
||||
}
|
||||
private int? _FormatID=null;
|
||||
public int? FormatID
|
||||
{
|
||||
get { return _FormatID; }
|
||||
set { _FormatID = value; }
|
||||
}
|
||||
private string _Config=null;
|
||||
public string Config
|
||||
{
|
||||
get { return _Config; }
|
||||
set { _Config = value; }
|
||||
}
|
||||
private DateTime _DTS;
|
||||
public DateTime DTS
|
||||
{
|
||||
get { return _DTS; }
|
||||
set { _DTS = value; }
|
||||
}
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{
|
||||
get { return _UserID; }
|
||||
set { _UserID = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Constructor
|
||||
public AddingPartCriteria(int itemID, EAddpingPart addType, string number, string text, int? type, int? fromType, int? formatID, string config, DateTime dts, string userID)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
_AddType = addType;
|
||||
_Number = number;
|
||||
_Text = text;
|
||||
_Type = type;
|
||||
_FromType = fromType;
|
||||
_FormatID = formatID;
|
||||
_Config = config;
|
||||
_DTS = dts;
|
||||
_UserID = userID;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public enum EAddpingPart
|
||||
{
|
||||
Child=0,
|
||||
Before=1,
|
||||
After=2
|
||||
}
|
||||
public ItemInfo NextItem
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NextItemCount > 0 && NextItems.Count > 0)
|
||||
return NextItems[0];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private static void ResetOrdinal(int itemID)
|
||||
{
|
||||
ConvertListToDictionary();
|
||||
string key = itemID.ToString();
|
||||
while (key != null && _CacheByPrimaryKey.ContainsKey(key))
|
||||
{
|
||||
ItemInfo[] items = _CacheByPrimaryKey[key].ToArray();
|
||||
key = null;
|
||||
foreach (ItemInfo item in items)
|
||||
{
|
||||
//Console.WriteLine("item = {0}, ordinal = {1}",item,item.Ordinal);
|
||||
item._Ordinal = null;
|
||||
item._TagsSetup = false;
|
||||
if (key == null && item.NextItem != null)
|
||||
key = item.NextItem.ItemID.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ResetOrdinal()
|
||||
{
|
||||
ResetOrdinal(ItemID);
|
||||
}
|
||||
}
|
||||
}
|
115
PROMS/VEPROMS.CSLA.Library/Extension/LinkText.cs
Normal file
115
PROMS/VEPROMS.CSLA.Library/Extension/LinkText.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class LinkText
|
||||
{
|
||||
public LinkText(string linkInfoText)
|
||||
{
|
||||
_LinkInfoText = linkInfoText;
|
||||
}
|
||||
public void ParseLink()
|
||||
{
|
||||
if (_MyParsedLinkType == ParsedLinkType.NotParsed)
|
||||
{
|
||||
if (_LinkInfoText == null) return;
|
||||
// First parse the string
|
||||
_LinkInfoText = _LinkInfoText.Replace(@"\v ", "");
|
||||
// for tran : "2, #, #, # and 4#Link:TransitionRange:2 10 173 166"
|
||||
Match m = Regex.Match(_LinkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
|
||||
_MyValue = m.Groups[1].Value;
|
||||
_MyLink = "#Link:" + m.Groups[2].Value + ":" + m.Groups[3].Value;
|
||||
switch (m.Groups[2].Value)
|
||||
{
|
||||
case "ReferencedObject":
|
||||
_MyParsedLinkType = ParsedLinkType.ReferencedObject;
|
||||
string[] subs = m.Groups[3].Value.Split(" ".ToCharArray());
|
||||
if (subs[0] == "<NewID>")
|
||||
_MyRoUsageInfo = null;
|
||||
else
|
||||
{
|
||||
int roUsageid = Convert.ToInt32(subs[0]);
|
||||
_MyRoUsageInfo = RoUsageInfo.Get(roUsageid);
|
||||
}
|
||||
break;
|
||||
case "Transition":
|
||||
case "TransitionRange":
|
||||
_MyParsedLinkType = (ParsedLinkType)Enum.Parse(_MyParsedLinkType.GetType(), m.Groups[2].Value);
|
||||
if (m.Groups[3].Value.Split(" ".ToCharArray())[1] == "<NewID>")
|
||||
_MyTransitionInfo = null;
|
||||
else
|
||||
{
|
||||
int transitionID = Convert.ToInt32(m.Groups[3].Value.Split(" ".ToCharArray())[1]);
|
||||
_MyTransitionInfo = TransitionInfo.Get(transitionID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _LinkInfoText;
|
||||
public string LinkInfoText
|
||||
{
|
||||
get { return _LinkInfoText; }
|
||||
}
|
||||
private TransitionInfo _MyTransitionInfo = null;
|
||||
public TransitionInfo MyTransitionInfo
|
||||
{
|
||||
get { ParseLink(); return _MyTransitionInfo; }
|
||||
}
|
||||
public ItemInfo MyTranToItemInfo
|
||||
{
|
||||
get { ParseLink(); return _MyTransitionInfo.MyItemToID; }
|
||||
}
|
||||
public ItemInfo MyTranRangeItemInfo
|
||||
{
|
||||
get { ParseLink(); return _MyTransitionInfo.MyItemRangeID; }
|
||||
}
|
||||
private string _MyValue = null;
|
||||
public string MyValue
|
||||
{
|
||||
get { ParseLink(); return _MyValue; }
|
||||
}
|
||||
private string _MyLink = null;
|
||||
public string MyLink
|
||||
{
|
||||
get { ParseLink(); return _MyLink; }
|
||||
}
|
||||
private RoUsageInfo _MyRoUsageInfo;
|
||||
public RoUsageInfo MyRoUsageInfo
|
||||
{
|
||||
get { ParseLink(); return _MyRoUsageInfo; }
|
||||
}
|
||||
//private string _Roid = null; // TODO: need to return Referenced Object rather than just roid
|
||||
//public string Roid
|
||||
//{
|
||||
// get { ParseLink(); return _Roid; }
|
||||
//}
|
||||
//private string _RoUsageid = null; // TODO: need to return Referenced Object rather than just roid
|
||||
//public string RoUsageid
|
||||
//{
|
||||
// get { ParseLink(); return _RoUsageid; }
|
||||
//}
|
||||
//private string _RoDbid = null; // TODO: need to return Referenced Object rather than just roid
|
||||
//public string RoDbid
|
||||
//{
|
||||
// get { ParseLink(); return _RoDbid; }
|
||||
//}
|
||||
private ParsedLinkType _MyParsedLinkType = ParsedLinkType.NotParsed;
|
||||
public ParsedLinkType MyParsedLinkType
|
||||
{
|
||||
get { ParseLink(); return _MyParsedLinkType; }
|
||||
}
|
||||
|
||||
}
|
||||
#region enums
|
||||
public enum ParsedLinkType : int
|
||||
{
|
||||
NotParsed = 0,
|
||||
Transition = 1,
|
||||
TransitionRange = 2,
|
||||
ReferencedObject = 3
|
||||
}
|
||||
#endregion
|
||||
}
|
890
PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs.bak
Normal file
890
PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs.bak
Normal file
@@ -0,0 +1,890 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text.RegularExpressions;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
#region Enum stuff
|
||||
public enum CheckOutType : int
|
||||
{
|
||||
Procedure = 0, Document = 1, DocVersion = 2
|
||||
}
|
||||
#endregion
|
||||
#region SessionInfoList stuff
|
||||
public partial class SessionInfoList
|
||||
{
|
||||
[Serializable()]
|
||||
public class CanCheckOutItemCriteria
|
||||
{
|
||||
private int _ObjectID;
|
||||
public int ObjectID
|
||||
{ get { return _ObjectID; } }
|
||||
private CheckOutType _ObjectType;
|
||||
public CheckOutType ObjectType
|
||||
{ get { return _ObjectType; } }
|
||||
public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
|
||||
{
|
||||
_ObjectID = objectID;
|
||||
_ObjectType = objectType;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(CanCheckOutItemCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfoList.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "vesp_SessionCanCheckOutItem";
|
||||
cm.Parameters.AddWithValue("@ObjectID", criteria.ObjectID);
|
||||
cm.Parameters.AddWithValue("@ObjectType", criteria.ObjectType);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read()) this.Add(new SessionInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("SessionInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("SessionInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region SessionInfo stuff
|
||||
public partial class SessionInfo
|
||||
{
|
||||
public static SessionInfo BeginSession(string machineName, int processID)
|
||||
{
|
||||
try
|
||||
{
|
||||
SessionInfo tmp = DataPortal.Fetch<SessionInfo>(new BeginSessionCriteria(Volian.Base.Library.VlnSettings.UserID, machineName, processID));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up SessionInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on SessionInfo.BeginSession", ex);
|
||||
}
|
||||
}
|
||||
public List<int> PingSession()
|
||||
{
|
||||
List<int> myList = new List<int>();
|
||||
SessionPing.Execute(this.SessionID);
|
||||
OwnerInfoList oil = OwnerInfoList.GetBySessionID(this.SessionID);
|
||||
foreach (OwnerInfo oi in oil)
|
||||
myList.Add(oi.OwnerID);
|
||||
return myList;
|
||||
}
|
||||
public void EndSession()
|
||||
{
|
||||
SessionEnd.Execute(this.SessionID);
|
||||
}
|
||||
public bool CanCheckOutItem(int objectID, CheckOutType objectType, ref string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
SessionInfoList sil = DataPortal.Fetch<SessionInfoList>(new SessionInfoList.CanCheckOutItemCriteria(objectID, objectType));
|
||||
if (sil.Count == 0)
|
||||
return true;
|
||||
bool rv = true;
|
||||
foreach (SessionInfo si in sil)
|
||||
{
|
||||
if (si.SessionID != this.SessionID && objectType == CheckOutType.Procedure)
|
||||
{
|
||||
message = string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(objectID).MyProcedure.DisplayNumber, si.UserID);
|
||||
rv = rv && false;
|
||||
}
|
||||
else if (si.SessionID != this.SessionID && objectType == CheckOutType.Document)
|
||||
{
|
||||
message = string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(objectID).DocumentEntries[0].MyContent.Text, si.UserID);
|
||||
rv = rv && false;
|
||||
}
|
||||
else if (si.SessionID != this.SessionID && objectType == CheckOutType.DocVersion)
|
||||
{
|
||||
OwnerInfo oi = OwnerInfo.GetBySessionIDandVersionID(si.SessionID, objectID);
|
||||
if(oi.OwnerType == 0)
|
||||
message = message + string.Format("The procedure {0} is already checked out to {1}", ItemInfo.Get(oi.OwnerItemID).MyProcedure.DisplayNumber, si.UserID) + Environment.NewLine;
|
||||
else if (oi.OwnerType == 1)
|
||||
message = message + string.Format("The document {0} is already checked out to {1}", DocumentInfo.Get(oi.OwnerItemID).DocumentEntries[0].MyContent.Text, si.UserID) + Environment.NewLine;
|
||||
else if (oi.OwnerType == 2)
|
||||
message = message + string.Format("The working draft is already checked out to {0}", si.UserID);
|
||||
rv = rv && false;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on SessionInfo.Get", ex);
|
||||
}
|
||||
}
|
||||
public int CheckOutItem(int itemID, CheckOutType itemType)
|
||||
{
|
||||
int ownerID = SessionCheckOutItem.Execute(this.SessionID, itemID, itemType);
|
||||
return ownerID;
|
||||
}
|
||||
public void CheckInItem(int ownerID)
|
||||
{
|
||||
SessionCheckInItem.Execute(ownerID);
|
||||
}
|
||||
private void DataPortal_Fetch(BeginSessionCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.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 = "vesp_SessionBegin";
|
||||
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
|
||||
cm.Parameters.AddWithValue("@MachineName", criteria.MachineName);
|
||||
cm.Parameters.AddWithValue("@ProcessID", criteria.ProcessID);
|
||||
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("SessionInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
//private void DataPortal_Fetch(CanCheckOutItemCriteria criteria)
|
||||
//{
|
||||
// if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] SessionInfo.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 = "vesp_SessionCanCheckOutItem";
|
||||
// cm.Parameters.AddWithValue("@ObjectID", criteria.ObjectID);
|
||||
// cm.Parameters.AddWithValue("@ObjectType", criteria.ObjectType);
|
||||
// using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
// {
|
||||
// while(dr.Read())
|
||||
|
||||
// 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("SessionInfo.DataPortal_Fetch", ex);
|
||||
// _ErrorMessage = ex.Message;
|
||||
// throw new DbCslaException("SessionInfo.DataPortal_Fetch", ex);
|
||||
// }
|
||||
//}
|
||||
[Serializable()]
|
||||
protected class BeginSessionCriteria
|
||||
{
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{ get { return _UserID; } }
|
||||
private string _MachineName;
|
||||
public string MachineName
|
||||
{ get { return _MachineName; } }
|
||||
private int _ProcessID;
|
||||
public int ProcessID
|
||||
{ get { return _ProcessID; } }
|
||||
public BeginSessionCriteria(string userID, string machineName, int processID)
|
||||
{
|
||||
_UserID = userID;
|
||||
_MachineName = machineName;
|
||||
_ProcessID = processID;
|
||||
}
|
||||
}
|
||||
//[Serializable()]
|
||||
//protected class CanCheckOutItemCriteria
|
||||
//{
|
||||
// private int _ObjectID;
|
||||
// public int ObjectID
|
||||
// { get { return _ObjectID; } }
|
||||
// private CheckOutType _ObjectType;
|
||||
// public CheckOutType ObjectType
|
||||
// { get { return _ObjectType; } }
|
||||
// public CanCheckOutItemCriteria(int objectID, CheckOutType objectType)
|
||||
// {
|
||||
// _ObjectID = objectID;
|
||||
// _ObjectType = objectType;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
public class ResetSecurity : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#region Factory Methods
|
||||
public static void Execute()
|
||||
{
|
||||
ResetSecurity cmd = new ResetSecurity();
|
||||
DataPortal.Execute<ResetSecurity>(cmd);
|
||||
}
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_ResetSecurity", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Reset Security Error", ex);
|
||||
throw new ApplicationException("Failure on Reset Security", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class SessionPing : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private int _SessionID;
|
||||
public int SessionID
|
||||
{
|
||||
get { return _SessionID; }
|
||||
set { _SessionID = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static void Execute(int sessionID)
|
||||
{
|
||||
SessionPing cmd = new SessionPing();
|
||||
cmd.SessionID = sessionID;
|
||||
DataPortal.Execute<SessionPing>(cmd);
|
||||
}
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_SessionPing", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.Parameters.AddWithValue("@SessionID", SessionID);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session Ping Error", ex);
|
||||
throw new ApplicationException("Failure on Session Ping", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class SessionEnd : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private int _SessionID;
|
||||
public int SessionID
|
||||
{
|
||||
get { return _SessionID; }
|
||||
set { _SessionID = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static void Execute(int sessionID)
|
||||
{
|
||||
SessionEnd cmd = new SessionEnd();
|
||||
cmd.SessionID = sessionID;
|
||||
DataPortal.Execute<SessionEnd>(cmd);
|
||||
}
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_SessionEnd", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.Parameters.AddWithValue("@SessionID", SessionID);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session End Error", ex);
|
||||
throw new ApplicationException("Failure on Session End", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class SessionCheckOutItem : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private int _SessionID;
|
||||
public int SessionID
|
||||
{
|
||||
get { return _SessionID; }
|
||||
set { _SessionID = value; }
|
||||
}
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
private int _ItemType;
|
||||
public int ItemType
|
||||
{
|
||||
get { return _ItemType; }
|
||||
set { _ItemType = value; }
|
||||
}
|
||||
private int _OwnerID;
|
||||
public int OwnerID
|
||||
{
|
||||
get { return _OwnerID; }
|
||||
set { _OwnerID = value; }
|
||||
}
|
||||
#region Factory Methods
|
||||
public static int Execute(int sessionID, int itemID, CheckOutType itemType)
|
||||
{
|
||||
SessionCheckOutItem cmd = new SessionCheckOutItem();
|
||||
cmd.SessionID = sessionID;
|
||||
cmd.ItemID = itemID;
|
||||
cmd.ItemType = (int)itemType;
|
||||
cmd = DataPortal.Execute<SessionCheckOutItem>(cmd);
|
||||
return cmd.OwnerID;
|
||||
}
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_SessionCheckOutItem", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.Parameters.AddWithValue("@SessionID", SessionID);
|
||||
cmd.Parameters.AddWithValue("@ItemID", ItemID);
|
||||
cmd.Parameters.AddWithValue("@ItemType", ItemType);
|
||||
SqlParameter parm = cmd.Parameters.AddWithValue("@OwnerID", 0);
|
||||
parm.Direction = ParameterDirection.Output;
|
||||
cmd.ExecuteNonQuery();
|
||||
OwnerID = (int)cmd.Parameters["@OwnerID"].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session End Error", ex);
|
||||
throw new ApplicationException("Failure on Session End", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
public class SessionCheckInItem : CommandBase
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private int _OwnerID;
|
||||
public int OwnerID
|
||||
{
|
||||
get { return _OwnerID; }
|
||||
set { _OwnerID = value; }
|
||||
}
|
||||
private int _ItemID;
|
||||
#region Factory Methods
|
||||
public static void Execute(int ownerID)
|
||||
{
|
||||
SessionCheckInItem cmd = new SessionCheckInItem();
|
||||
cmd.OwnerID = ownerID;
|
||||
DataPortal.Execute<SessionCheckInItem>(cmd);
|
||||
}
|
||||
#endregion
|
||||
#region Server-Side code
|
||||
protected override void DataPortal_Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cmd = new SqlCommand("vesp_SessionCheckInItem", cn))
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.Parameters.AddWithValue("@OwnerID", OwnerID);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("Session End Error", ex);
|
||||
throw new ApplicationException("Failure on Session End", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
#region OwnerInfo stuff
|
||||
public partial class OwnerInfoList
|
||||
{
|
||||
public static OwnerInfoList GetBySessionID(int sessionID)
|
||||
{
|
||||
OwnerInfoList tmp = DataPortal.Fetch<OwnerInfoList>(new GetBySessionIDCriteria(sessionID));
|
||||
return tmp;
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetBySessionIDCriteria
|
||||
{
|
||||
private int _SessionID;
|
||||
public int SessionID { get { return _SessionID; } }
|
||||
public GetBySessionIDCriteria(int sessionID)
|
||||
{
|
||||
_SessionID = sessionID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetBySessionIDCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfoList.DataPortal_Fetch", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getOwnersBySessionID";
|
||||
cm.Parameters.AddWithValue("@SessionID", criteria.SessionID);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read()) this.Add(new OwnerInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("OwnerInfoList.DataPortal_Fetch", ex);
|
||||
throw new DbCslaException("OwberInfoList.DataPortal_Fetch", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
public partial class OwnerInfo
|
||||
{
|
||||
public static OwnerInfo GetBySessionIDandVersionID(int sessionID, int versionID)
|
||||
{
|
||||
try
|
||||
{
|
||||
OwnerInfo tmp = DataPortal.Fetch<OwnerInfo>(new GetBySessionIDandVersionIDCriteria(sessionID, versionID));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up SessionInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on OwnerInfo.GetBySessionIDandVersionID", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetBySessionIDandVersionIDCriteria
|
||||
{
|
||||
private int _SessionID;
|
||||
public int SessionID
|
||||
{ get { return _SessionID; } }
|
||||
private int _VersionID;
|
||||
public int VersionID
|
||||
{ get { return _VersionID; } }
|
||||
public GetBySessionIDandVersionIDCriteria(int sessionID, int versionID)
|
||||
{
|
||||
_SessionID = sessionID;
|
||||
_VersionID = versionID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetBySessionIDandVersionIDCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.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 = "getOwnerBySessionIDandVersionID";
|
||||
cm.Parameters.AddWithValue("@SessionID", criteria.SessionID);
|
||||
cm.Parameters.AddWithValue("@VersionID", criteria.VersionID);
|
||||
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("OwnerInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
public static OwnerInfo GetByItemID(int itemID, CheckOutType itemType)
|
||||
{
|
||||
try
|
||||
{
|
||||
OwnerInfo tmp = DataPortal.Fetch<OwnerInfo>(new GetByItemIDCriteria(itemID, itemType));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up SessionInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on OwnerInfo.GetByItemID", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetByItemIDCriteria
|
||||
{
|
||||
private int _ItemID;
|
||||
public int ItemID
|
||||
{ get { return _ItemID; } }
|
||||
private CheckOutType _ItemType;
|
||||
public CheckOutType ItemType
|
||||
{ get { return _ItemType; } }
|
||||
public GetByItemIDCriteria(int itemID, CheckOutType itemType)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
_ItemType = itemType;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetByItemIDCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] OwnerInfo.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 = "getOwnerByItemID";
|
||||
cm.Parameters.AddWithValue("@ItemID", criteria.ItemID);
|
||||
cm.Parameters.AddWithValue("@ItemType", (int)criteria.ItemType);
|
||||
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("OwnerInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("OwnerInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
public string SessionUserID
|
||||
{
|
||||
get
|
||||
{
|
||||
SessionInfo si = SessionInfo.Get(this.SessionID);
|
||||
return si.UserID;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region UserInfo stuff
|
||||
public partial class UserInfo
|
||||
{
|
||||
public bool IsAdministrator()
|
||||
{
|
||||
if (this.UserMembershipCount == 0)
|
||||
return false;
|
||||
foreach (MembershipInfo mi in this.UserMemberships)
|
||||
{
|
||||
if (mi.EndDate == string.Empty)
|
||||
{
|
||||
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
|
||||
{
|
||||
if (ai.FolderID == 1 && ai.MyRole.Name == "Administrator")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool IsSetAdministrator(FolderInfo fi)
|
||||
{
|
||||
if (this.UserMembershipCount == 0)
|
||||
return false;
|
||||
foreach (MembershipInfo mi in this.UserMemberships)
|
||||
{
|
||||
if (mi.EndDate == string.Empty)
|
||||
{
|
||||
Dictionary<int, int> folders = new Dictionary<int, int>();
|
||||
//FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
|
||||
while (fi.FolderID > 1)
|
||||
{
|
||||
folders.Add(fi.FolderID, fi.FolderID);
|
||||
fi = fi.MyParent;
|
||||
}
|
||||
folders.Add(1, 1);
|
||||
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
|
||||
{
|
||||
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Set Administrator")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool IsSetAdministrator(DocVersionInfo dv)
|
||||
{
|
||||
if (this.UserMembershipCount == 0)
|
||||
return false;
|
||||
foreach (MembershipInfo mi in this.UserMemberships)
|
||||
{
|
||||
if (mi.EndDate == string.Empty)
|
||||
{
|
||||
Dictionary<int, int> folders = new Dictionary<int, int>();
|
||||
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
|
||||
while (fi.FolderID > 1)
|
||||
{
|
||||
folders.Add(fi.FolderID, fi.FolderID);
|
||||
fi = fi.MyParent;
|
||||
}
|
||||
folders.Add(1, 1);
|
||||
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
|
||||
{
|
||||
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Set Administrator")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool IsWriter(DocVersionInfo dv)
|
||||
{
|
||||
if (this.UserMembershipCount == 0)
|
||||
return false;
|
||||
foreach (MembershipInfo mi in this.UserMemberships)
|
||||
{
|
||||
if (mi.EndDate == string.Empty)
|
||||
{
|
||||
Dictionary<int, int> folders = new Dictionary<int, int>();
|
||||
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
|
||||
while (fi.FolderID > 1)
|
||||
{
|
||||
folders.Add(fi.FolderID, fi.FolderID);
|
||||
fi = fi.MyParent;
|
||||
}
|
||||
folders.Add(1, 1);
|
||||
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
|
||||
{
|
||||
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Writer")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool IsReviewer(DocVersionInfo dv)
|
||||
{
|
||||
if (this.UserMembershipCount == 0)
|
||||
return false;
|
||||
foreach (MembershipInfo mi in this.UserMemberships)
|
||||
{
|
||||
if (mi.EndDate == string.Empty)
|
||||
{
|
||||
Dictionary<int, int> folders = new Dictionary<int, int>();
|
||||
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
|
||||
while (fi.FolderID > 1)
|
||||
{
|
||||
folders.Add(fi.FolderID, fi.FolderID);
|
||||
fi = fi.MyParent;
|
||||
}
|
||||
folders.Add(1, 1);
|
||||
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
|
||||
{
|
||||
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "Reviewer")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool IsROEditor(DocVersionInfo dv)
|
||||
{
|
||||
if (this.UserMembershipCount == 0)
|
||||
return false;
|
||||
foreach (MembershipInfo mi in this.UserMemberships)
|
||||
{
|
||||
if (mi.EndDate == string.Empty)
|
||||
{
|
||||
Dictionary<int, int> folders = new Dictionary<int, int>();
|
||||
FolderInfo fi = FolderInfo.Get(dv.MyFolder.FolderID);
|
||||
while (fi.FolderID > 1)
|
||||
{
|
||||
folders.Add(fi.FolderID, fi.FolderID);
|
||||
fi = fi.MyParent;
|
||||
}
|
||||
folders.Add(1, 1);
|
||||
foreach (AssignmentInfo ai in mi.MyGroup.GroupAssignments)
|
||||
{
|
||||
if (folders.ContainsKey(ai.FolderID) && ai.MyRole.Name == "RO Editor")
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static UserInfo GetByUserID(string userID)
|
||||
{
|
||||
try
|
||||
{
|
||||
UserInfo tmp = DataPortal.Fetch<UserInfo>(new GetByUserIDCriteria(userID));
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up SessionInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on UserInfo.GetByUserID", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class GetByUserIDCriteria
|
||||
{
|
||||
private string _UserID;
|
||||
public string UserID
|
||||
{ get { return _UserID; } }
|
||||
public GetByUserIDCriteria(string userID)
|
||||
{
|
||||
_UserID = userID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(GetByUserIDCriteria criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] UserInfo.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 = "getUserByUserID";
|
||||
cm.Parameters.AddWithValue("@UserID", criteria.UserID);
|
||||
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("UserInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("UserInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
1287
PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs.org
Normal file
1287
PROMS/VEPROMS.CSLA.Library/Extension/MultiUserExt.cs.org
Normal file
File diff suppressed because it is too large
Load Diff
91
PROMS/VEPROMS.CSLA.Library/Extension/PermissionExt.cs
Normal file
91
PROMS/VEPROMS.CSLA.Library/Extension/PermissionExt.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class Permission
|
||||
{
|
||||
private static List<vlnValueKey> _permADLookup;
|
||||
private static List<vlnValueKey> _permLevelLookup;
|
||||
private static void setupLookup()
|
||||
{
|
||||
if (_permADLookup == null)
|
||||
{
|
||||
_permADLookup = new List<vlnValueKey>();
|
||||
_permADLookup.Add(new vlnValueKey(0,"Allow"));
|
||||
_permADLookup.Add(new vlnValueKey(1, "Deny"));
|
||||
}
|
||||
if (_permLevelLookup == null)
|
||||
{
|
||||
_permLevelLookup = new List<vlnValueKey>();
|
||||
_permLevelLookup.Add(new vlnValueKey(0, "Security"));
|
||||
_permLevelLookup.Add(new vlnValueKey(1, "System"));
|
||||
_permLevelLookup.Add(new vlnValueKey(2, "RO"));
|
||||
_permLevelLookup.Add(new vlnValueKey(3, "Procedure"));
|
||||
_permLevelLookup.Add(new vlnValueKey(4, "Sections"));
|
||||
_permLevelLookup.Add(new vlnValueKey(5, "Steps"));
|
||||
_permLevelLookup.Add(new vlnValueKey(6, "Comments"));
|
||||
}
|
||||
}
|
||||
public static List<vlnValueKey> PermADLookup
|
||||
{
|
||||
get { setupLookup(); return _permADLookup; }
|
||||
}
|
||||
public static List<vlnValueKey> PermLevelLookup
|
||||
{
|
||||
get { setupLookup(); return _permLevelLookup; }
|
||||
}
|
||||
public bool ReadAccess
|
||||
{
|
||||
get { return ((PermValue & 1) == 1); }
|
||||
set { PermValue = (value?PermValue|1:PermValue^(PermValue&1));}
|
||||
}
|
||||
public bool WriteAccess
|
||||
{
|
||||
get { return ((PermValue & 2) == 2); }
|
||||
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
|
||||
}
|
||||
public bool CreateAccess
|
||||
{
|
||||
get { return ((PermValue & 4) == 4); }
|
||||
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
|
||||
}
|
||||
public bool DeleteAccess
|
||||
{
|
||||
get { return ((PermValue & 8) == 8); }
|
||||
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
|
||||
}
|
||||
// partial class Extension : extensionBase
|
||||
// {
|
||||
// TODO: Override automatic defaults
|
||||
// public virtual int DefaultPermad
|
||||
// {
|
||||
// get { return 0; }
|
||||
// }
|
||||
// public virtual SmartDate DefaultStartDate
|
||||
// {
|
||||
// get { return DateTime.Now.ToShortDateString(); }
|
||||
// }
|
||||
// public virtual DateTime DefaultDts
|
||||
// {
|
||||
// get { return DateTime.Now; }
|
||||
// }
|
||||
// public virtual string DefaultUsrid
|
||||
// {
|
||||
// get { return Environment.UserName.ToUpper(); }
|
||||
// }
|
||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||
// {
|
||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
808
PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs.bak
Normal file
808
PROMS/VEPROMS.CSLA.Library/Extension/ROFSTExt.cs.bak
Normal file
@@ -0,0 +1,808 @@
|
||||
// ========================================================================
|
||||
// Copyright 2006 - 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 System.Text.RegularExpressions;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using Csla;
|
||||
using Csla.Data;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class ROFst
|
||||
{
|
||||
// put in for debug
|
||||
//public static int CacheCountPrimaryKey
|
||||
//{ get { return _CacheByPrimaryKey.Count; } }
|
||||
//public static int CacheCountByRODbID_DTS
|
||||
//{ get { return _CacheByRODbID_DTS.Count; } }
|
||||
//public static int CacheCountList
|
||||
//{ get { return _CacheList.Count; } }
|
||||
|
||||
[NonSerialized]
|
||||
private ROFSTLookup _ROFSTLookup;
|
||||
public ROFSTLookup ROFSTLookup
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ROFSTLookup == null)
|
||||
{
|
||||
_ROFSTLookup = new ROFSTLookup(this);
|
||||
}
|
||||
return _ROFSTLookup;
|
||||
}
|
||||
}
|
||||
public static ROFst GetJustROFst(int rOFstID)
|
||||
{
|
||||
if (!CanGetObject())
|
||||
throw new System.Security.SecurityException("User not authorized to view a ROFst");
|
||||
try
|
||||
{
|
||||
ROFst tmp = GetCachedByPrimaryKey(rOFstID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<ROFst>(new PKCriteriaJustROFst(rOFstID));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up ROFst
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ROFst.Get", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class PKCriteriaJustROFst
|
||||
{
|
||||
private int _ROFstID;
|
||||
public int ROFstID
|
||||
{ get { return _ROFstID; } }
|
||||
public PKCriteriaJustROFst(int rOFstID)
|
||||
{
|
||||
_ROFstID = rOFstID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteriaJustROFst criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFst.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 = "getJustROFst";
|
||||
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
if (!dr.Read())
|
||||
{
|
||||
_ErrorMessage = "No Record Found";
|
||||
return;
|
||||
}
|
||||
ReadData(dr);
|
||||
// load child objects
|
||||
//dr.NextResult();
|
||||
//_ROFstAssociations = ROFstAssociations.Get(dr);
|
||||
// load child objects
|
||||
//dr.NextResult();
|
||||
//_ROFstFigures = ROFstFigures.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("ROFst.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ROFst.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public delegate List<string> ROFstInfoROTableUpdateEvent(object sender, ROFstInfoROTableUpdateEventArgs args);
|
||||
public partial class ROFstInfo
|
||||
{
|
||||
// put in for debug
|
||||
//public static int CacheCountPrimaryKey
|
||||
//{ get { return _CacheByPrimaryKey.Count; } }
|
||||
//public static int CacheCountList
|
||||
//{ get { return _CacheList.Count; } }
|
||||
#region Log4Net
|
||||
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
#region PropertiesAndData
|
||||
private DocVersionInfo _docVer;
|
||||
public DocVersionInfo docVer
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_docVer == null)
|
||||
{
|
||||
if (ROFstAssociations.Count == 0) return null;
|
||||
// _docVer = DocVersion.Get(this.ROFstAssociations[0].MyDocVersion.VersionID);
|
||||
_docVer = this.ROFstAssociations[0].MyDocVersion;
|
||||
}
|
||||
return _docVer;
|
||||
}
|
||||
set
|
||||
{
|
||||
_docVer = value;
|
||||
|
||||
}
|
||||
}
|
||||
[NonSerialized]
|
||||
private ROFSTLookup _ROFSTLookup;
|
||||
public ROFSTLookup ROFSTLookup
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_ROFSTLookup == null)
|
||||
{
|
||||
_ROFSTLookup = new ROFSTLookup(this);
|
||||
}
|
||||
return _ROFSTLookup;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region AppSupport
|
||||
//public static ROImageInfo Get(RODbInfo rodbinfo, string filename)
|
||||
//{
|
||||
// if (rodbinfo.RODbROImageCount != 0)
|
||||
// {
|
||||
// foreach (ROImageInfo ri in rodbinfo.RODbROImages)
|
||||
// {
|
||||
// if (ri.FileName == filename) return ri;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
public string GetDefaultROPrefix()
|
||||
{
|
||||
if (docVer != null)
|
||||
return docVer.DocVersionConfig.RODefaults_setpointprefix;
|
||||
else
|
||||
return "SP1"; // Not Sure about this...
|
||||
}
|
||||
public string GetDefaultGraphicsPrefix()
|
||||
{
|
||||
if (docVer != null)
|
||||
return docVer.DocVersionConfig.RODefaults_graphicsprefix;
|
||||
else
|
||||
return "IG1"; // Not Sure about this...
|
||||
}
|
||||
#region Add New Ro Fst
|
||||
/// <summary>
|
||||
/// Adds an ro.fst into a sql database.
|
||||
/// </summary>
|
||||
/// <param name="rdi" - the Rodb to use as the path for updating the ro.fst, i.e.
|
||||
/// import from there.
|
||||
/// <param name="docver" - hook into this doc version></param>
|
||||
/// <returns>ROFst: Returns the created rofst object</returns>
|
||||
public static ROFst AddRoFst(RODbInfo rdi, DocVersion docver)
|
||||
{
|
||||
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
|
||||
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
|
||||
if (!di.Exists) return null;
|
||||
if (!File.Exists(rofstfilepath)) return null;
|
||||
|
||||
// check if this rofst has been loaded, i.e. dts on file versus dts in db...
|
||||
// if so, just make association with docversion.
|
||||
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, di.LastWriteTimeUtc);
|
||||
if (rofst != null)
|
||||
{
|
||||
docver.DocVersionAssociations.Add(rofst);
|
||||
docver.Save();
|
||||
return rofst;
|
||||
}
|
||||
|
||||
// Next read in the rofst & make the rofst record.
|
||||
FileStream fsIn = new FileStream(rofstfilepath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
// Create an instance of StreamReader that can read characters from the FileStream.
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
fsIn.Close();
|
||||
|
||||
using (RODb rodb = RODb.Get(rdi.RODbID))
|
||||
{
|
||||
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbID(rdi.RODbID))
|
||||
{
|
||||
Dictionary<string, int> myExistingROImages = BuildROImagesList(myROImages);
|
||||
List<int> myUnChangedROImages = new List<int>();
|
||||
List<string> myAddedROImages = new List<string>();
|
||||
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
|
||||
// Hook this into the current docversion by replacing the rofstid field in the doc version
|
||||
// association object:
|
||||
docver.DocVersionAssociations.Add(rofst);
|
||||
docver.Save();
|
||||
|
||||
// Now load any images in... type 8 - integrated graphics ro type
|
||||
for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++)
|
||||
{
|
||||
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
|
||||
if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null)
|
||||
{
|
||||
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
|
||||
{
|
||||
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);// TODO: Need to add MyImages
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myUnChangedROImages.Count > 0)
|
||||
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
|
||||
return rofst;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Update Ro Values
|
||||
/// <summary>
|
||||
/// Updates an ro.fst into a sql database.
|
||||
/// </summary>
|
||||
/// <param name="rdi" - the Rodb to use as the path for updating the ro.fst, i.e.
|
||||
/// import from there.
|
||||
/// <param name="dva" - the association record to modify, i.e. make new rofst
|
||||
/// the current one.
|
||||
/// <param name="docver" - hook into this doc version></param>
|
||||
/// <returns>ROFst: Returns the created rofst object</returns>
|
||||
public static ROFst UpdateRoFst(RODbInfo rdi, DocVersionAssociation dva, DocVersion docver, ROFstInfo origROFst)
|
||||
{
|
||||
DirectoryInfo di = new DirectoryInfo(rdi.FolderPath);
|
||||
// check if this rofst has been loaded, i.e. dts on file versus dts in db...
|
||||
// if so, just make association to existing with docversion.
|
||||
ROFst rofst = ROFst.GetByRODbID_DTS(rdi.RODbID, di.LastWriteTimeUtc);
|
||||
if (rofst != null)
|
||||
{
|
||||
docver.DocVersionAssociations[0].MyROFst = rofst;
|
||||
docver.Save();
|
||||
return rofst;
|
||||
}
|
||||
|
||||
// Read in the rofst & make the rofst record.
|
||||
string rofstfilepath = rdi.FolderPath + @"\ro.fst";
|
||||
FileStream fsIn = new FileStream(rofstfilepath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
// Create an instance of StreamReader that can read characters from the FileStream.
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
fsIn.Close();
|
||||
using (RODb rodb = RODb.GetJustRoDb(rdi.RODbID))
|
||||
{
|
||||
rofst = ROFst.MakeROFst(rodb, ab, null, di.LastWriteTimeUtc, rdi.UserID);
|
||||
// Hook this into the current docversion by replacing the rofstid field in the doc version
|
||||
// association object:
|
||||
dva.MyROFst = rofst;
|
||||
docver.Save();
|
||||
// Now load any images in... type 8 - integrated graphics ro type
|
||||
using (ROImageInfoList myROImages = ROImageInfoList.GetByRODbIDNoData(rdi.RODbID))
|
||||
{
|
||||
Dictionary<string, int> myExistingROImages = BuildROImagesList(myROImages);
|
||||
List<int> myUnChangedROImages = new List<int>();
|
||||
List<string> myAddedROImages = new List<string>();
|
||||
using (ROFstInfo rfi = ROFstInfo.Get(rofst.ROFstID))
|
||||
{
|
||||
for (int i = 0; i < rofst.ROFSTLookup.myHdr.myDbs.Length; i++)
|
||||
{
|
||||
// walk through the rofst 'database' searching for all nodes that are integrated graphics, type 8:
|
||||
if (rofst.ROFSTLookup.myHdr.myDbs[i].children != null)
|
||||
{
|
||||
rfi.MigrateRoFstGraphics(rdi, rofst.ROFSTLookup.myHdr.myDbs[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add references for existing RO Images to the Figure table (Figure table relates ro.fst with its images)
|
||||
if (myUnChangedROImages.Count > 0)
|
||||
using (FigureInfoList fil = FigureInfoList.AddByROFstIDImageIDs(rofst.ROFstID, buildImageIDString(myUnChangedROImages))) ;
|
||||
}
|
||||
// Now update the usages: compare old to new rofsts and update usages accordingly, i.e. modified
|
||||
// values, deleted ros, etc.
|
||||
UpdateROValuesText(origROFst, rofst);
|
||||
return rofst;
|
||||
}
|
||||
}
|
||||
private static Dictionary<string,int> BuildROImagesList(ROImageInfoList myROImages)
|
||||
{
|
||||
Dictionary<string,int> myRoImagesList = new Dictionary<string,int>();
|
||||
foreach (ROImageInfo myROImage in myROImages)
|
||||
myRoImagesList.Add(ROImageKey(myROImage.FileName, myROImage.DTS),myROImage.ImageID);
|
||||
return myRoImagesList;
|
||||
}
|
||||
private static string ROImageKey(string fileName, DateTime dts)
|
||||
{
|
||||
return string.Format("{0}:{1}", fileName, dts);
|
||||
}
|
||||
private static string buildImageIDString(List<int> myROImageIDs)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string sep = "";
|
||||
foreach (int imageID in myROImageIDs)
|
||||
{
|
||||
sb.Append(sep + imageID.ToString());
|
||||
sep = ",";
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
private static void UpdateROValuesText(ROFstInfo origROFstInfo, ROFst newROFst)
|
||||
{
|
||||
ROFSTLookup origLU = new ROFSTLookup(origROFstInfo);
|
||||
ROFSTLookup newLU = new ROFSTLookup(newROFst);
|
||||
List<string> delList = new List<string>();
|
||||
List<string> chgList = newLU.GetValueDifferences(origLU, ref delList);
|
||||
string RoidList = GetRoidList(newROFst.RODbID, chgList);
|
||||
List<string> activeRoids = BuildActiveROIDsForRoUsages(RoidList);
|
||||
foreach (string chg in chgList)
|
||||
{
|
||||
if (activeRoids.Contains(chg))
|
||||
{
|
||||
ROFSTLookup.rochild roch = newLU.GetRoChild(chg);
|
||||
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLU.GetRoValue(chg), roch.value);
|
||||
// roid's are stored in database as 16 characters long in the rousages table. They may be stored
|
||||
// as 12 characters in the ro.fst.
|
||||
string padroid = chg.Length <= 12 ? chg + "0000" : chg;
|
||||
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid, desc, "Changed"))
|
||||
{
|
||||
foreach (RoUsageInfo roUsg in affected)
|
||||
{
|
||||
using (Content content = Content.Get(roUsg.MyContent.ContentID))
|
||||
{
|
||||
foreach (ItemInfo ii in roUsg.MyContent.ContentItems)
|
||||
{
|
||||
string val = newLU.GetTranslatedRoValue(padroid, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
|
||||
content.FixContentText(roUsg, val, roch.type, origROFstInfo);
|
||||
if (content.IsDirty)
|
||||
{
|
||||
// Update UserID and DTS when RO Value is updated.
|
||||
content.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
content.DTS = DateTime.Now;
|
||||
content.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
activeRoids = BuildActiveROIDsForDRoUsages(RoidList);
|
||||
foreach (string chg in chgList)
|
||||
{
|
||||
if (activeRoids.Contains(chg))
|
||||
{
|
||||
ROFSTLookup.rochild roch = newLU.GetRoChild(chg);
|
||||
string desc = string.Format("Change in RO Values: Old value = {0}, New value = {1}", origLU.GetRoValue(chg), roch.value);
|
||||
// roid's are stored in database as 16 characters long in the rousages table. They may be stored
|
||||
// as 12 characters in the ro.fst.
|
||||
string padroid = chg.Length <= 12 ? chg + "0000" : chg;
|
||||
using (DROUsageInfoList affected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroid.Substring(0,12), desc, "Changed"))
|
||||
{
|
||||
foreach (DROUsageInfo droUsg in affected)
|
||||
{
|
||||
Pdf.DeleteAll(droUsg.DocID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (string del in delList)
|
||||
{
|
||||
string desc = string.Format("Deleted RO: Value = {0}", origLU.GetRoValue(del));
|
||||
string padroiddel = del.Length <= 12 ? del + "0000" : del;
|
||||
using (RoUsageInfoList affected = RoUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, padroiddel, desc, "Deleted"))
|
||||
{
|
||||
foreach (RoUsageInfo roUsg in affected)
|
||||
{
|
||||
using (Content content = Content.Get(roUsg.MyContent.ContentID))
|
||||
{
|
||||
content.FixContentText(roUsg, "?", 0, origROFstInfo);
|
||||
if (content.IsDirty)
|
||||
{
|
||||
// Update UserID and DTS when RO Value is updated.
|
||||
content.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
content.DTS = DateTime.Now;
|
||||
content.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using (DROUsageInfoList Daffected = DROUsageInfoList.GetAffected(origROFstInfo.MyRODb.RODbID, del.Substring(0,12), desc, "Deleted"))
|
||||
{
|
||||
foreach (DROUsageInfo droUsg in Daffected)
|
||||
{
|
||||
Pdf.DeleteAll(droUsg.DocID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static List<string> BuildActiveROIDsForRoUsages(string RoidList)
|
||||
{
|
||||
List<string> activeRoids = new List<string>();
|
||||
using (RoUsageInfoList activeList = RoUsageInfoList.GetROUSagesByROIDs(RoidList))
|
||||
{
|
||||
foreach (RoUsageInfo roui in activeList)
|
||||
{
|
||||
string roid = roui.ROID.ToUpper();
|
||||
if (roid.EndsWith("0000")) roid = roid.Substring(0, 12);
|
||||
if (!activeRoids.Contains(roid))
|
||||
activeRoids.Add(roid);
|
||||
}
|
||||
}
|
||||
return activeRoids;
|
||||
}
|
||||
private static List<string> BuildActiveROIDsForDRoUsages(string RoidList)
|
||||
{
|
||||
List<string> activeRoids = new List<string>();
|
||||
using (DROUsageInfoList activeList = DROUsageInfoList.GetDROUsagesByROIDs(RoidList))
|
||||
{
|
||||
foreach (DROUsageInfo roui in activeList)
|
||||
{
|
||||
string roid = roui.ROID;
|
||||
if (roid.EndsWith("0000")) roid = roid.Substring(0, 12);
|
||||
if (!activeRoids.Contains(roid))
|
||||
activeRoids.Add(roid);
|
||||
}
|
||||
}
|
||||
return activeRoids;
|
||||
}
|
||||
private static string GetRoidList(int dbid, List<string> chgList)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(string.Format("{0}", dbid));
|
||||
string sep=":";
|
||||
foreach (string roid in chgList)
|
||||
{
|
||||
sb.Append(sep + roid);
|
||||
sep = ",";
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
private static string NewROName(string roName)
|
||||
{
|
||||
string retval = roName;
|
||||
int iSuffix = -1;
|
||||
RODbInfoList rodblist = RODbInfoList.Get();
|
||||
|
||||
|
||||
foreach (RODbInfo rdi in rodblist)
|
||||
{
|
||||
if (rdi.ROName.StartsWith(roName))
|
||||
{
|
||||
if (rdi.ROName == roName)
|
||||
iSuffix = 0;
|
||||
else if (Regex.IsMatch(rdi.ROName, roName + "[_][0-9]+"))
|
||||
{
|
||||
int ii = int.Parse(rdi.ROName.Substring(1 + roName.Length));
|
||||
if (ii > iSuffix) iSuffix = ii;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (iSuffix >= 0)
|
||||
retval = string.Format("{0}_{1}", roName, iSuffix + 1);
|
||||
return retval;
|
||||
}
|
||||
private void MigrateRoFstGraphics(RODbInfo rdi, ROFSTLookup.rochild[] rochild, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages)
|
||||
{
|
||||
for (int i = 0; i < rochild.Length; i++)
|
||||
{
|
||||
if (rochild[i].type == 8) this.AddGraphic(rdi, rochild[i].value, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);
|
||||
if (rochild[i].children != null) this.MigrateRoFstGraphics(rdi, rochild[i].children, rodb, rofst, myExistingROImages, myUnChangedROImages, myAddedROImages);
|
||||
}
|
||||
}
|
||||
private void AddGraphic(RODbInfo rdi, string p, RODb rodb, ROFst rofst, Dictionary<string, int> myExistingROImages, List<int> myUnChangedROImages, List<string> myAddedROImages)
|
||||
{
|
||||
if (p == null) return;
|
||||
string imgname = p.Substring(0, p.IndexOf('\n'));
|
||||
int thedot = imgname.LastIndexOf('.');
|
||||
string fname = imgname;
|
||||
if (thedot == -1 || (thedot != (imgname.Length - 4)))
|
||||
{
|
||||
RODbConfig roDbCfg = new RODbConfig(rdi.Config);
|
||||
fname += string.Format(".{0}", roDbCfg.GetDefaultGraphicExtension());
|
||||
}
|
||||
|
||||
string imgfile = rdi.FolderPath + @"\" + fname;
|
||||
|
||||
ROImage roImg = null;
|
||||
if (File.Exists(imgfile))
|
||||
{
|
||||
FileInfo fi = new FileInfo(imgfile);
|
||||
// if the roimage record exists, don't create a new one...
|
||||
string key = ROImageKey(imgname, fi.LastWriteTimeUtc);
|
||||
if (myExistingROImages.ContainsKey(key))
|
||||
{
|
||||
int imageID = myExistingROImages[key];
|
||||
if (!myUnChangedROImages.Contains(imageID))
|
||||
myUnChangedROImages.Add(imageID);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!myAddedROImages.Contains(key))
|
||||
{
|
||||
FileStream fsIn = new FileStream(imgfile, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
BinaryReader r = new BinaryReader(fsIn);
|
||||
byte[] ab = r.ReadBytes((int)fsIn.Length);
|
||||
r.Close();
|
||||
fsIn.Close();
|
||||
byte[] cmp = ROImageInfo.Compress(ab);
|
||||
int existingImageID = FindExisting(myExistingROImages, imgname, imgfile, cmp, ab);
|
||||
if (existingImageID != 0)
|
||||
{
|
||||
if (!myUnChangedROImages.Contains(existingImageID))
|
||||
myUnChangedROImages.Add(existingImageID);
|
||||
return;
|
||||
}
|
||||
ROImageConfig rc = new ROImageConfig();
|
||||
rc.Image_Size = ab.Length.ToString();
|
||||
using (roImg = ROImage.MakeROImage(rodb, imgname, ROImageInfo.Compress(ab), rc.ToString(), fi.LastWriteTimeUtc, "Migration"))
|
||||
{
|
||||
using (Figure figure = Figure.GetByROFstID_ImageID(this.ROFstID, roImg.ImageID))
|
||||
{
|
||||
if (figure != null) return;
|
||||
Figure.MakeFigure(rofst, roImg, null).Dispose();
|
||||
myAddedROImages.Add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int FindExisting(Dictionary<string, int> myExistingROImages, string imgname, string imgfile, byte[] cmpFileContents, byte[] fileContents)
|
||||
{
|
||||
// the reason the following check is necessary is that the DTS can be off by hours
|
||||
// because of the way windows handles Daylight savings time for file DTS.
|
||||
|
||||
FileInfo fi = new FileInfo(imgfile);
|
||||
DateTime dts = fi.LastWriteTimeUtc;
|
||||
|
||||
// loop through myExistingROImages looking for matching name.
|
||||
foreach (string key in myExistingROImages.Keys)
|
||||
{
|
||||
// if found, compare the date/time stamp
|
||||
string part1 = Regex.Replace(key, ":.*$", "");
|
||||
string part2 = Regex.Replace(key, "^.*?:", "");
|
||||
if (part1.ToUpper() == imgname.ToUpper())
|
||||
{
|
||||
// if date/time stamps matches date, minutes & seconds, compare contents
|
||||
string cmp1 = Regex.Replace(dts.ToString(), " [0-9]*:", " x:");
|
||||
cmp1 = Regex.Replace(cmp1, " [AP]", " x");
|
||||
string cmp2 = Regex.Replace(part2, " [0-9]*:", " x:");
|
||||
cmp2 = Regex.Replace(cmp2, " [AP]", " x");
|
||||
if (cmp1==cmp2)
|
||||
{
|
||||
// compare contents
|
||||
int imgId = myExistingROImages[key];
|
||||
using (ROImageInfo roii = ROImageInfo.Get(imgId))
|
||||
{
|
||||
ROImageConfig roicfg = new ROImageConfig(roii);
|
||||
int size = Convert.ToInt32(roicfg.Image_Size);
|
||||
byte[] tmpb = ROImageInfo.Decompress(roii.Content, size);
|
||||
|
||||
if (ByteArrayCompare(roii.Content, cmpFileContents))
|
||||
return imgId;
|
||||
if (ByteArrayCompare(tmpb, fileContents))
|
||||
return imgId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private bool ByteArrayCompare(byte[] ba1, byte[] ba2)
|
||||
{
|
||||
// we wrote our own byte array comparinson because the system's 'equals' did not work!
|
||||
if (ba1.Length != ba2.Length) return false;
|
||||
for (int i = 0; i < ba1.Length; i++)
|
||||
if (ba1[i] != ba2[i]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private ROImageInfo GetMyImage(Dictionary<string, ROImageInfo> myImages, string imgname, DateTime dts)
|
||||
{
|
||||
string key = string.Format("{0}:{1}", imgname, dts);
|
||||
if(myImages.ContainsKey(key))
|
||||
return myImages[key];
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
public bool IsSetpointDB(int id)
|
||||
{
|
||||
ROFSTLookup.rodbi[] dbs = ROFSTLookup.GetRODatabaseList();
|
||||
foreach (ROFSTLookup.rodbi rodbi in dbs)
|
||||
{
|
||||
if (id == rodbi.dbiID)
|
||||
return (rodbi.dbiAP.StartsWith("SP"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public event ROFstInfoROTableUpdateEvent ROTableUpdate;
|
||||
public List<string> OnROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
|
||||
{
|
||||
if (ROTableUpdate != null) return ROTableUpdate(sender, args);
|
||||
return null;
|
||||
}
|
||||
public static ROFstInfo GetJustROFst(int rOFstID)
|
||||
{
|
||||
//if (!CanGetObject())
|
||||
// throw new System.Security.SecurityException("User not authorized to view a ROFst");
|
||||
try
|
||||
{
|
||||
ROFstInfo tmp = GetCachedByPrimaryKey(rOFstID);
|
||||
if (tmp == null)
|
||||
{
|
||||
tmp = DataPortal.Fetch<ROFstInfo>(new PKCriteriaJustROFst(rOFstID));
|
||||
AddToCache(tmp);
|
||||
}
|
||||
if (tmp.ErrorMessage == "No Record Found")
|
||||
{
|
||||
tmp.Dispose(); // Clean-up ROFstInfo
|
||||
tmp = null;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on ROFstInfo.Get", ex);
|
||||
}
|
||||
}
|
||||
[Serializable()]
|
||||
protected class PKCriteriaJustROFst
|
||||
{
|
||||
private int _ROFstID;
|
||||
public int ROFstID
|
||||
{ get { return _ROFstID; } }
|
||||
public PKCriteriaJustROFst(int rOFstID)
|
||||
{
|
||||
_ROFstID = rOFstID;
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(PKCriteriaJustROFst criteria)
|
||||
{
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfo.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 = "getJustROFst";
|
||||
cm.Parameters.AddWithValue("@ROFstID", criteria.ROFstID);
|
||||
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("ROFstInfo.DataPortal_Fetch", ex);
|
||||
_ErrorMessage = ex.Message;
|
||||
throw new DbCslaException("ROFstInfo.DataPortal_Fetch", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public class ROFstInfoROTableUpdateEventArgs
|
||||
{
|
||||
private string _ROText;
|
||||
public string ROText
|
||||
{
|
||||
get { return _ROText; }
|
||||
set { _ROText = value; }
|
||||
}
|
||||
private string _OldGridXml;
|
||||
public string OldGridXml
|
||||
{
|
||||
get { return _OldGridXml; }
|
||||
set { _OldGridXml = value; }
|
||||
}
|
||||
public ROFstInfoROTableUpdateEventArgs(string rotext, string oldgridxml)
|
||||
{
|
||||
_ROText = rotext;
|
||||
_OldGridXml = oldgridxml;
|
||||
}
|
||||
}
|
||||
public partial class ROFstInfoList
|
||||
{
|
||||
[Serializable()]
|
||||
private class RoFstSizeCriteria
|
||||
{
|
||||
public RoFstSizeCriteria(int roDbID, int len)
|
||||
{
|
||||
_RODbID = roDbID;
|
||||
_Len = len;
|
||||
}
|
||||
private int _RODbID;
|
||||
public int RODbID
|
||||
{
|
||||
get { return _RODbID; }
|
||||
set { _RODbID = value; }
|
||||
}
|
||||
private int _Len;
|
||||
public int Len
|
||||
{
|
||||
get { return _Len; }
|
||||
set { _Len = value; }
|
||||
}
|
||||
}
|
||||
public static ROFstInfoList GetBySize(int roDbID, int len)
|
||||
{
|
||||
try
|
||||
{
|
||||
ROFstInfoList tmp = DataPortal.Fetch<ROFstInfoList>(new RoFstSizeCriteria(roDbID, len));
|
||||
ROFstInfo.AddList(tmp);
|
||||
tmp.AddEvents();
|
||||
return tmp;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new DbCslaException("Error on RoFstInfoList.GetBySize", ex);
|
||||
}
|
||||
}
|
||||
private void DataPortal_Fetch(RoFstSizeCriteria criteria)
|
||||
{
|
||||
this.RaiseListChangedEvents = false;
|
||||
if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ROFstInfoList.DataPortal_FetchBySize", GetHashCode());
|
||||
try
|
||||
{
|
||||
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
|
||||
{
|
||||
using (SqlCommand cm = cn.CreateCommand())
|
||||
{
|
||||
cm.CommandType = CommandType.StoredProcedure;
|
||||
cm.CommandText = "getRoFstBySize";
|
||||
cm.Parameters.AddWithValue("@RODbID", criteria.RODbID);
|
||||
cm.Parameters.AddWithValue("@Len", criteria.Len);
|
||||
|
||||
using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader()))
|
||||
{
|
||||
IsReadOnly = false;
|
||||
while (dr.Read())
|
||||
this.Add(new ROFstInfo(dr));
|
||||
IsReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_MyLog.IsErrorEnabled) _MyLog.Error("ROFstInfoList.DataPortal_FetchBySize", ex);
|
||||
throw new DbCslaException("ROFstInfoList.DataPortal_FetchBySize", ex);
|
||||
}
|
||||
this.RaiseListChangedEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
1596
PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs.bak
Normal file
1596
PROMS/VEPROMS.CSLA.Library/Extension/RevisionInfoExt.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
54
PROMS/VEPROMS.CSLA.Library/Extension/RolePermissionExt.cs
Normal file
54
PROMS/VEPROMS.CSLA.Library/Extension/RolePermissionExt.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class RolePermission : BusinessBase<RolePermission>
|
||||
{
|
||||
public static RolePermission New()
|
||||
{
|
||||
return new RolePermission(1, 1, 1);
|
||||
}
|
||||
public bool ReadAccess
|
||||
{
|
||||
get { return ((PermValue & 1) == 1); }
|
||||
set { PermValue = (value ? PermValue | 1 : PermValue ^ (PermValue & 1)); }
|
||||
}
|
||||
public bool WriteAccess
|
||||
{
|
||||
get { return ((PermValue & 2) == 2); }
|
||||
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
|
||||
}
|
||||
public bool CreateAccess
|
||||
{
|
||||
get { return ((PermValue & 4) == 4); }
|
||||
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
|
||||
}
|
||||
public bool DeleteAccess
|
||||
{
|
||||
get { return ((PermValue & 8) == 8); }
|
||||
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
|
||||
}
|
||||
public List<vlnValueKey> PermADLookup
|
||||
{
|
||||
get { return Permission.PermADLookup; }
|
||||
}
|
||||
public List<vlnValueKey> PermLevelLookup
|
||||
{
|
||||
get { return Permission.PermLevelLookup; }
|
||||
}
|
||||
}
|
||||
public class PermLookup
|
||||
{
|
||||
public List<vlnValueKey> PermADLookup
|
||||
{
|
||||
get { return Permission.PermADLookup; }
|
||||
}
|
||||
public List<vlnValueKey> PermLevelLookup
|
||||
{
|
||||
get { return Permission.PermLevelLookup; }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class Permission
|
||||
{
|
||||
private static List<vlnValueKey> _permADLookup;
|
||||
private static List<vlnValueKey> _permLevelLookup;
|
||||
private static void setupLookup()
|
||||
{
|
||||
if (_permADLookup == null)
|
||||
{
|
||||
_permADLookup = new List<vlnValueKey>();
|
||||
_permADLookup.Add(new vlnValueKey(0,"Allow"));
|
||||
_permADLookup.Add(new vlnValueKey(1, "Deny"));
|
||||
}
|
||||
if (_permLevelLookup == null)
|
||||
{
|
||||
_permLevelLookup = new List<vlnValueKey>();
|
||||
_permLevelLookup.Add(new vlnValueKey(0, "Security"));
|
||||
_permLevelLookup.Add(new vlnValueKey(1, "System"));
|
||||
_permLevelLookup.Add(new vlnValueKey(2, "RO"));
|
||||
_permLevelLookup.Add(new vlnValueKey(3, "Procedure"));
|
||||
_permLevelLookup.Add(new vlnValueKey(4, "Sections"));
|
||||
_permLevelLookup.Add(new vlnValueKey(5, "Steps"));
|
||||
_permLevelLookup.Add(new vlnValueKey(6, "Comments"));
|
||||
}
|
||||
}
|
||||
public static List<vlnValueKey> PermADLookup
|
||||
{
|
||||
get { setupLookup(); return _permADLookup; }
|
||||
}
|
||||
public static List<vlnValueKey> PermLevelLookup
|
||||
{
|
||||
get { setupLookup(); return _permLevelLookup; }
|
||||
}
|
||||
public bool ReadAccess
|
||||
{
|
||||
get { return ((PermValue & 1) == 1); }
|
||||
set { PermValue = (value?PermValue|1:PermValue^(PermValue&1));}
|
||||
}
|
||||
public bool WriteAccess
|
||||
{
|
||||
get { return ((PermValue & 2) == 2); }
|
||||
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
|
||||
}
|
||||
public bool CreateAccess
|
||||
{
|
||||
get { return ((PermValue & 4) == 4); }
|
||||
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
|
||||
}
|
||||
public bool DeleteAccess
|
||||
{
|
||||
get { return ((PermValue & 8) == 8); }
|
||||
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
|
||||
}
|
||||
// partial class Extension : extensionBase
|
||||
// {
|
||||
// TODO: Override automatic defaults
|
||||
// public virtual int DefaultPermad
|
||||
// {
|
||||
// get { return 0; }
|
||||
// }
|
||||
// public virtual SmartDate DefaultStartDate
|
||||
// {
|
||||
// get { return DateTime.Now.ToShortDateString(); }
|
||||
// }
|
||||
// public virtual DateTime DefaultDts
|
||||
// {
|
||||
// get { return DateTime.Now; }
|
||||
// }
|
||||
// public virtual string DefaultUsrid
|
||||
// {
|
||||
// get { return Environment.UserName.ToUpper(); }
|
||||
// }
|
||||
// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules)
|
||||
// {
|
||||
// //rules.AllowRead(Dbid, "<Role(s)>");
|
||||
// }
|
||||
// public new void AddValidationRules(Csla.Validation.ValidationRules rules)
|
||||
// {
|
||||
// rules.AddRule(
|
||||
// Csla.Validation.CommonRules.StringMaxLength,
|
||||
// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100));
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public partial class RolePermission : BusinessBase<RolePermission>
|
||||
{
|
||||
public static RolePermission New()
|
||||
{
|
||||
return new RolePermission(1, 1, 1);
|
||||
}
|
||||
public bool ReadAccess
|
||||
{
|
||||
get { return ((PermValue & 1) == 1); }
|
||||
set { PermValue = (value ? PermValue | 1 : PermValue ^ (PermValue & 1)); }
|
||||
}
|
||||
public bool WriteAccess
|
||||
{
|
||||
get { return ((PermValue & 2) == 2); }
|
||||
set { PermValue = (value ? PermValue | 2 : PermValue ^ (PermValue & 2)); }
|
||||
}
|
||||
public bool CreateAccess
|
||||
{
|
||||
get { return ((PermValue & 4) == 4); }
|
||||
set { PermValue = (value ? PermValue | 4 : PermValue ^ (PermValue & 4)); }
|
||||
}
|
||||
public bool DeleteAccess
|
||||
{
|
||||
get { return ((PermValue & 8) == 8); }
|
||||
set { PermValue = (value ? PermValue | 8 : PermValue ^ (PermValue & 8)); }
|
||||
}
|
||||
public List<vlnValueKey> PermADLookup
|
||||
{
|
||||
get { return Permission.PermADLookup; }
|
||||
}
|
||||
public List<vlnValueKey> PermLevelLookup
|
||||
{
|
||||
get { return Permission.PermLevelLookup; }
|
||||
}
|
||||
}
|
||||
public class PermLookup
|
||||
{
|
||||
public List<vlnValueKey> PermADLookup
|
||||
{
|
||||
get { return Permission.PermADLookup; }
|
||||
}
|
||||
public List<vlnValueKey> PermLevelLookup
|
||||
{
|
||||
get { return Permission.PermLevelLookup; }
|
||||
}
|
||||
}
|
||||
}
|
30
PROMS/VEPROMS.CSLA.Library/Extension/Security/vlnValueKey.cs
Normal file
30
PROMS/VEPROMS.CSLA.Library/Extension/Security/vlnValueKey.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public class vlnValueKey
|
||||
{
|
||||
public vlnValueKey() { ;}
|
||||
public vlnValueKey(int key, string value)
|
||||
{
|
||||
_key = key;
|
||||
_value = value;
|
||||
}
|
||||
private int _key;
|
||||
public int Key
|
||||
{
|
||||
get { return _key; }
|
||||
}
|
||||
private string _value;
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
}
|
1153
PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs.bak
Normal file
1153
PROMS/VEPROMS.CSLA.Library/Extension/TransitionExt.cs.bak
Normal file
File diff suppressed because it is too large
Load Diff
17
PROMS/VEPROMS.CSLA.Library/Extension/UserInfoListExt.cs
Normal file
17
PROMS/VEPROMS.CSLA.Library/Extension/UserInfoListExt.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Csla;
|
||||
namespace Volian.Object.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Extensions
|
||||
/// </summary>
|
||||
public partial class UserInfo : ReadOnlyBase<UserInfo>
|
||||
{
|
||||
public string FullName
|
||||
{
|
||||
get { return LastName + ", " + FirstName; }
|
||||
}
|
||||
}
|
||||
}
|
40
PROMS/VEPROMS.CSLA.Library/Extension/transtypes.TXT
Normal file
40
PROMS/VEPROMS.CSLA.Library/Extension/transtypes.TXT
Normal file
@@ -0,0 +1,40 @@
|
||||
Adding special flag chars to tokens:
|
||||
|
||||
?. means the following for !section transitions
|
||||
|
||||
for proc - if current, don't put out text, if !current, put out text
|
||||
for sect - if curproc: if cursect, don't put out text; if !cursect, put out text
|
||||
if !curproc: if default sect, don't put out text; if !default sect, put out text
|
||||
|
||||
DONE: "0" TransFormat="{Proc Num}, {Proc Title}, Step {First Step}" TransUI="ProcMenu, SectDefault, StepAllowNone, StepFirst"
|
||||
DONE: "1" TransFormat="{First Step}" TransUI="ProcCur, SectCur, StepFirst"
|
||||
DONE: "2" TransFormat="{First Step}, {.}, {.}, {.} and {Last Step}" TransUI="ProcCur, SectCur, StepFirst, StepLast"
|
||||
DONE: "3" TransFormat="{First Step} thru {Last Step} of {?.Proc Num}, {?.Proc Title}, {?.Sect Hdr}" TransUI="ProcMenu, SectMenuStep, StepFirst, StepLast"
|
||||
DONE: "4" TransFormat="{?.Sect Title}, Step {First Step}" TransUI="ProcCur, SectMenuAny, StepAllowNone, StepFirst"
|
||||
DONE: "5" TransFormat="{Proc Num}, {Proc Title}, {?.Sect Hdr}, Step {First Step}"TransUI="ProcMenu, SectMenuAny, StepAllowNone, StepFirst"
|
||||
|
||||
|
||||
SECTION TRANSITIONS (calloway used as test...
|
||||
|
||||
Menu [format] comment
|
||||
|
||||
"{Proc Num}, {Proc Title}, Step {Sect Num}{First Step}", same as menu
|
||||
"{Sect Num}{First Step} ( Within the current section )", {Sect Num}{First Step}
|
||||
"{Sect Num}{First Step}, {.}, {.}, {.} and {Sect Num}{Last Step}", same as menu current section
|
||||
"{Sect Num}{First Step} thru {Sect Num}{Last Step}", same as menu step section in current proc
|
||||
"{Sect Num}{First Step} ( To a different section )", {Sect Num}, Step {?.Sect Num}{?.First Step} - no stepnumber needed
|
||||
"{Sect Num}{First Step}, {Sect Title} ( To a different section )" {Sect Hdr}, Step{{Sect Num}{First Step} - puts all out even if current.
|
||||
"{Sect Num}" {Sect Num} - prompts for step too, but only lists sect num, Go To step though
|
||||
"{Step}" {Step} - prompts for proc, step sect & step number. (sometimes gives ?)
|
||||
|
||||
// made up the following string so that the token processing for setting
|
||||
// up the menu enums would work as expected.
|
||||
private string[] DefaultSectionTransTokenStr =
|
||||
{
|
||||
"{Proc Num}, {Proc Title}, Step {First Step}",
|
||||
"{First Step} ( Within the current section )",
|
||||
"{First Step}, {.}, {.}, {.} and {Last Step}",
|
||||
"{Sect Num}.{First Step} thru {Sect Num}.{Last Step}",
|
||||
"{Sect Num}.{First Step} ( To a different section )",
|
||||
"{Sect Num}.{First Step}, {Sect Title} ( To a different section )"
|
||||
};
|
39
PROMS/VEPROMS.CSLA.Library/Extension/transtypes.TXT.bak
Normal file
39
PROMS/VEPROMS.CSLA.Library/Extension/transtypes.TXT.bak
Normal file
@@ -0,0 +1,39 @@
|
||||
Adding special flag chars to tokens:
|
||||
|
||||
?. means the following for !section transitions
|
||||
|
||||
for proc - if current, don't put out text, if !current, put out text
|
||||
for sect - if curproc: if cursect, don't put out text; if !cursect, put out text
|
||||
if !curproc: if default sect, don't put out text; if !default sect, put out text
|
||||
|
||||
DONE: "0" TransFormat="{Proc Num}, {Proc Title}, Step {First Step}" TransUI="ProcMenu, SectDefault, StepAllowNone, StepFirst"
|
||||
DONE: "1" TransFormat="{First Step}" TransUI="ProcCur, SectCur, StepFirst"
|
||||
DONE: "2" TransFormat="{First Step}, {.}, {.}, {.} and {Last Step}" TransUI="ProcCur, SectCur, StepFirst, StepLast"
|
||||
DONE: "3" TransFormat="{First Step} thru {Last Step} of {?.Proc Num}, {?.Proc Title}, {?.Sect Hdr}" TransUI="ProcMenu, SectMenuStep, StepFirst, StepLast"
|
||||
DONE: "4" TransFormat="{?.Sect Title}, Step {First Step}" TransUI="ProcCur, SectMenuAny, StepAllowNone, StepFirst"
|
||||
DONE: "5" TransFormat="{Proc Num}, {Proc Title}, {?.Sect Hdr}, Step {First Step}"TransUI="ProcMenu, SectMenuAny, StepAllowNone, StepFirst"
|
||||
|
||||
|
||||
SECTION TRANSITIONS (calloway used as test...
|
||||
|
||||
Menu [format] comment
|
||||
|
||||
"{Proc Num}, {Proc Title}, Step {Sect Num}{First Step}", same as menu
|
||||
"{Sect Num}{First Step} ( Within the current section )", {Sect Num}{First Step}
|
||||
"{Sect Num}{First Step}, {.}, {.}, {.} and {Sect Num}{Last Step}", same as menu current section
|
||||
"{Sect Num}{First Step} thru {Sect Num}{Last Step}", same as menu step section in current proc
|
||||
"{Sect Num}{First Step} ( To a different section )", {Sect Num}, Step {?.Sect Num}{?.First Step} - no stepnumber needed
|
||||
"{Sect Num}{First Step}, {Sect Title} ( To a different section )" {Sect Hdr}, Step{{Sect Num}{First Step} - puts all out even if current.
|
||||
|
||||
|
||||
// made up the following string so that the token processing for setting
|
||||
// up the menu enums would work as expected.
|
||||
private string[] DefaultSectionTransTokenStr =
|
||||
{
|
||||
"{Proc Num}, {Proc Title}, Step {First Step}",
|
||||
"{First Step} ( Within the current section )",
|
||||
"{First Step}, {.}, {.}, {.} and {Last Step}",
|
||||
"{Sect Num}.{First Step} thru {Sect Num}.{Last Step}",
|
||||
"{Sect Num}.{First Step} ( To a different section )",
|
||||
"{Sect Num}.{First Step}, {Sect Title} ( To a different section )"
|
||||
};
|
30
PROMS/VEPROMS.CSLA.Library/Extension/vlnValueKey.cs
Normal file
30
PROMS/VEPROMS.CSLA.Library/Extension/vlnValueKey.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public class vlnValueKey
|
||||
{
|
||||
public vlnValueKey() { ;}
|
||||
public vlnValueKey(int key, string value)
|
||||
{
|
||||
_key = key;
|
||||
_value = value;
|
||||
}
|
||||
private int _key;
|
||||
public int Key
|
||||
{
|
||||
get { return _key; }
|
||||
}
|
||||
private string _value;
|
||||
public string Value
|
||||
{
|
||||
get { return _value; }
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user