Improved conversion ot Referenced Objects and Transitions to text

Added code to implement deleting pdfs
Fixed problems with searching by Textm Annotations, Referenced Objects and Transitions
This commit is contained in:
Rich 2015-02-18 02:36:42 +00:00
parent f16fcf1470
commit cb52bad3e9
4 changed files with 167 additions and 46 deletions

View File

@ -32,13 +32,25 @@ namespace VEPROMS.CSLA.Library
// if (g.ToString() != transText)
// Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
//}
string newvalue = tran.ResolvePathTo();
string newvalue = tran != null ? tran.ResolvePathTo() : string.Empty;
if (forceConvertToText)
newvalue = "?";
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:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
string lookFor;
if (tran == null)
{
int loc1 = Text.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
int loc2 = Text.IndexOf(" ", loc1);
string trantype = Text.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
loc2 = Text.IndexOf(" ", loc1);
string tranid = Text.Substring(loc1, loc2 - loc1);
lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", trantype, tranid);
}
else
lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
foreach (Match mm in ms)
{
Match m = Regex.Match(mm.Value, lookFor, RegexOptions.Singleline);
@ -57,8 +69,9 @@ namespace VEPROMS.CSLA.Library
{
string rv = ConvertTransitionToText(tran, newvalue);
//Text = Text.Substring(0, myIndex - 14) + gg + Text.Substring(myIndex + myLength);
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, ItemInfo.VolianCommentType, "", string.Format("Transition ({0}) converted to text", ItemInfo.ConvertToDisplayText(gg)), null);
Transition.Delete(tran.TransitionID);
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, AnnotationType.GetByName("Verification Required"), "", string.Format("Transition ({0}) converted to text", ItemInfo.ConvertToDisplayText(gg)), null);
if(tran != null)
Transition.Delete(tran.TransitionID);
break;
}
else if ((gg.Contains("\\u8209?") ? gg.Replace("\\u8209?", "-") : gg) != (newvalue.Contains("\\u8209?") ? newvalue.Replace("\\u8209?", "-") : newvalue))
@ -69,7 +82,7 @@ namespace VEPROMS.CSLA.Library
}
}
// see if there is a grid to update too.
if (tran.MyContent.MyGrid != null)
if (tran != null && tran.MyContent.MyGrid != null)
{
//string lookForXml = string.Format(@"&lt;START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v'? \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END&gt;", tran.TranType, tran.TransitionID);
//Match mg = Regex.Match(MyGrid.Data, lookForXml);
@ -128,7 +141,19 @@ namespace VEPROMS.CSLA.Library
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);
string lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
string lookFor;
if (tran == null)
{
int loc1 = Text.IndexOf("#Link:Transition:", 0) + ("#Link:Transition:").Length;
int loc2 = Text.IndexOf(" ", loc1);
string trantype = Text.Substring(loc1, loc2 - loc1);
loc1 = loc2 + 1;
loc2 = Text.IndexOf(" ", loc1);
string tranid = Text.Substring(loc1, loc2 - loc1);
lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", trantype, tranid);
}
else
lookFor = string.Format(@"^<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~])(.*?)(\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
int lastIndex = 0;
string newText = Text;
foreach (Match mm in ms)
@ -403,7 +428,7 @@ namespace VEPROMS.CSLA.Library
if (value == "?")
{
retval = this.ConvertROToText(rousg, value, rotype, origROFstInfo);
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, ItemInfo.VolianCommentType, "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(retval)), null);
Annotation.MakeAnnotation(this.ContentItems[0].MyItem, AnnotationType.GetByName("Verification Required"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(retval)), null);
RoUsage.Delete(rousg.ROUsageID);
return retval;
}
@ -545,9 +570,9 @@ namespace VEPROMS.CSLA.Library
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii)
{
FixTransitionText(tran, tranLookup, ii, false);
FixTransitionText(tran, tranLookup, ii, "");
}
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, bool forceConvertToText)
public void FixTransitionText(TransitionInfo tran, TransitionLookup tranLookup, ItemInfo ii, string forceConvertToText)
{
//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);
@ -565,7 +590,7 @@ namespace VEPROMS.CSLA.Library
newvalue = tran.ResolvePathTo();
else
newvalue = tran.ResolvePathTo(tranLookup);
if (forceConvertToText)
if (forceConvertToText != string.Empty)
newvalue = "?";
string findLink = @"<START\].*?\[END>";
MatchCollection ms = Regex.Matches(Text, findLink);
@ -592,7 +617,7 @@ namespace VEPROMS.CSLA.Library
if (newvalue == "?")
{
gg = ItemInfo.ConvertToDisplayText(gg);
newvalue = "Invalid Transition";
newvalue = forceConvertToText;
OnStaticContentInfoChange(ii, new StaticContentInfoEventArgs(gg, newvalue, "TX"));
break;
}
@ -666,9 +691,9 @@ namespace VEPROMS.CSLA.Library
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii)
{
FixTransitionText(tran, ii, false);
FixTransitionText(tran, ii, "");
}
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, bool forceConvertToText)
public void FixTransitionText(TransitionInfo tran, ItemInfo ii, string forceConvertToText)
{
FixTransitionText(tran, null, ii, forceConvertToText);
//string transText = tran.ResolvePathTo(tranLookup);

View File

@ -585,26 +585,26 @@ namespace VEPROMS.CSLA.Library
{
bool forceConvertToText = false;
TranCheckCount++;
if (TransitionsToNonEditable != null)
{
if (IsTransitionToNonEditable(traninfo))
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, true);
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
}
}
else
//if (TransitionsToNonEditable != null)
//{
// if (IsTransitionToNonEditable(traninfo))
// {
// forceConvertToText = true;
// TranFixCount++;
// itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to Non-Editable Step");
// Content content = Content.Get(itemInfo.MyContent.ContentID);
// content.FixTransitionText(traninfo, true);
// content.Save();
// }
//}
if (!forceConvertToText)
{
SectionConfig sc = traninfo.MyItemToID.ActiveSection.MyConfig as SectionConfig;
forceConvertToText = (sc.SubSection_Edit == "N");
if (forceConvertToText)
{
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, true);
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to Non-Editable Step");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
@ -617,7 +617,7 @@ namespace VEPROMS.CSLA.Library
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, true);
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to External Procedure using Internal Format");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
@ -627,12 +627,15 @@ namespace VEPROMS.CSLA.Library
{
if (itemInfo.MyDocVersion.VersionID != traninfo.MyItemToID.MyDocVersion.VersionID) //different doc version
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, true);
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
if (!itemInfo.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[traninfo.TranType].TransMenu.Contains("Proc")) //internal format
{
forceConvertToText = true;
TranFixCount++;
itemInfo.MyContent.FixTransitionText(traninfo, itemInfo, "Reason for Change: Transition to Outside Procedure using Internal Format");
Content content = Content.Get(itemInfo.MyContent.ContentID);
content.FixTransitionText(traninfo, true);
content.Save();
}
}
}
if (!forceConvertToText)
@ -710,7 +713,7 @@ namespace VEPROMS.CSLA.Library
if (roval == "?")
{
oldText = content.ConvertROToText(rousage, roval, roch.type, rofstinfo);
Annotation.MakeAnnotation(content.ContentItems[0].MyItem, VolianCommentType, "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
Annotation.MakeAnnotation(content.ContentItems[0].MyItem, AnnotationType.GetByName("Verification Required"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
}
else
content.FixContentText(rousage, roval, roch.type, rofstinfo);
@ -748,7 +751,7 @@ namespace VEPROMS.CSLA.Library
if (roval == "?")
{
oldText = content.ConvertROToText(rousage, roval, roch.type, rofstinfo);
Annotation.MakeAnnotation(content.ContentItems[0].MyItem, VolianCommentType, "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
Annotation.MakeAnnotation(content.ContentItems[0].MyItem, AnnotationType.GetByName("Verification Required"), "", string.Format("RO value ({0}) converted to text", ItemInfo.ConvertToDisplayText(oldText)), null);
}
else
content.FixContentText(rousage, roval, roch.type, rofstinfo);
@ -5559,14 +5562,14 @@ namespace VEPROMS.CSLA.Library
{
return (Procedure)(_Editable = Procedure.Get(ItemID));
}
public static void RefreshTransitions(ProcedureInfo tmp)
{
RefreshTransitions(tmp, null, null);
}
public static void RefreshTransitions(ProcedureInfo tmp, TransitionInfoList transitionToDisconnected, TransitionInfoList transitionsToNonEditable)
//public static void RefreshTransitions(ProcedureInfo tmp)
//{
// RefreshTransitions(tmp, null, null);
//}
public static void RefreshTransitions(ProcedureInfo tmp)//, TransitionInfoList transitionToDisconnected, TransitionInfoList transitionsToNonEditable)
{
TransitionsToDisconnected = transitionToDisconnected;
TransitionsToNonEditable = transitionsToNonEditable;
//TransitionsToDisconnected = transitionToDisconnected;
//TransitionsToNonEditable = transitionsToNonEditable;
TransitionLookup tranLookup = new TransitionLookup(0, tmp.ItemID, tmp.MyLookup);
tranLookup.ApplicabilityUnit = tmp.MyDocVersion.DocVersionConfig.SelectedSlave;
tranLookup.NewLookupNeeded += new TransitionLookupEvent(GetNewLookup);

View File

@ -92,4 +92,51 @@ namespace VEPROMS.CSLA.Library
public partial class PdfInfoList
{
}
public class ExecuteStoredProcedure : CommandBase
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
#region Factory Methods
private string _StoredProcedure;
public string StoredProcedure
{
get { return _StoredProcedure; }
set { _StoredProcedure = value; }
}
private int _AffectedRows;
public int AffectedRows
{
get { return _AffectedRows; }
set { _AffectedRows = value; }
}
public static int Execute(string storedProcedure)
{
ExecuteStoredProcedure cmd = new ExecuteStoredProcedure();
cmd.StoredProcedure = storedProcedure;
DataPortal.Execute<ExecuteStoredProcedure>(cmd);
return cmd.AffectedRows;
}
#endregion
#region Server-Side code
protected override void DataPortal_Execute()
{
try
{
using (SqlConnection cn = Database.VEPROMS_SqlConnection)
{
using (SqlCommand cmd = new SqlCommand(StoredProcedure, cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 0;
AffectedRows = cmd.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
if (_MyLog.IsErrorEnabled) _MyLog.Error("ExecuteStoredProcedure Error", ex);
throw new ApplicationException("Failure on ExecuteStoredProcedure", ex);
}
}
#endregion
}
}

View File

@ -150,6 +150,21 @@ namespace Volian.Controls.Library
{
if (e.NewTab == tabTranSearch)
{
//enable-disable doc version nodes based on version type if selected
if (cbxTranVersion.SelectedIndex > -1)
{
if (dicExpandedDocVersionNodes.Count > 0)
{
foreach (DevComponents.AdvTree.Node n in dicExpandedDocVersionNodes.Keys)
{
DocVersionInfo dvi = (DocVersionInfo)n.Tag;
if(cbxTranVersion.Tag.ToString().Contains(dvi.VersionID.ToString()))
n.Enabled = true;
else
n.Enabled = false;
}
}
}
//setup transition format versions
this.Cursor = Cursors.WaitCursor;
if (myFormatVersionList == null)
@ -170,6 +185,19 @@ namespace Volian.Controls.Library
}
this.Cursor = Cursors.Default;
}
else
{
foreach (DevComponents.AdvTree.Node n in dicExpandedDocVersionNodes.Keys)
n.Enabled = true;
if (dicSelectedDocVersionNodes.Count > 0)
{
foreach (DevComponents.AdvTree.Node n in dicSelectedDocVersionNodes.Keys)
{
n.Enabled = true;
}
dicSelectedDocVersionNodes.Clear();
}
}
}
void cbxTranFormat_SelectedIndexChanged(object sender, EventArgs e)
@ -254,6 +282,18 @@ namespace Volian.Controls.Library
}
cbxTranVersion.Tag = versionList;
cbxTranFormatFillIn(versionList);
if (dicExpandedDocVersionNodes.Count > 0)
{
foreach (DevComponents.AdvTree.Node n in dicExpandedDocVersionNodes.Keys)
{
DocVersionInfo dvi = (DocVersionInfo)n.Tag;
if (cbxTranVersion.Tag.ToString().Contains(dvi.VersionID.ToString()))
n.Enabled = true;
else
n.Enabled = false;
}
}
List<DevComponents.AdvTree.Node> uncheckNodes = new List<Node>();
foreach (DevComponents.AdvTree.Node n in dicSelectedDocVersionNodes.Keys)
{
@ -456,6 +496,7 @@ namespace Volian.Controls.Library
// vlnStackTrace.ShowStackLocal(e.Node.Text,1,10);
//}
private Dictionary<DevComponents.AdvTree.Node, bool> dicSelectedDocVersionNodes = new Dictionary<DevComponents.AdvTree.Node, bool>();
private Dictionary<DevComponents.AdvTree.Node, bool> dicExpandedDocVersionNodes = new Dictionary<DevComponents.AdvTree.Node, bool>();
void advTreeProcSets_BeforeExpand(object sender, DevComponents.AdvTree.AdvTreeNodeCancelEventArgs e)
{
DevComponents.AdvTree.Node par = e.Node;
@ -498,10 +539,15 @@ namespace Volian.Controls.Library
newnode.CheckBoxStyle = eCheckBoxStyle.CheckBox;
newnode.CheckBoxThreeState = false;
newnode.CheckBoxVisible = true;
if (!dicSelectedDocVersionNodes.ContainsKey(newnode)) dicSelectedDocVersionNodes.Add(newnode, false);
newnode.Enabled = cbxTranVersion.Tag != null ? cbxTranVersion.Tag.ToString().Contains(dv.VersionID.ToString()) : false;
if (tabSearchTypes.SelectedTab == tabTranSearch)
{
if (!dicSelectedDocVersionNodes.ContainsKey(newnode)) dicSelectedDocVersionNodes.Add(newnode, false);
newnode.Enabled = cbxTranVersion.Tag != null ? cbxTranVersion.Tag.ToString().Contains(dv.VersionID.ToString()) : false;
}
else
newnode.Enabled = true;
par.Nodes.Add(newnode);
dicExpandedDocVersionNodes.Add(newnode, newnode.Enabled);
//}
}
}