This commit is contained in:
2011-03-01 16:32:16 +00:00
parent 97e5cf4ee6
commit 9d2f4faa33
4 changed files with 150 additions and 25 deletions

View File

@@ -5,6 +5,9 @@ using Volian.Controls.Library;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
using Volian.Base.Library;
using Volian.Controls.Library;
using System.Xml;
using System.IO;
namespace DataLoader
{
@@ -81,6 +84,11 @@ namespace DataLoader
//MyStepRTB.ViewRTB = false;
string originalText = item.MyContent.Text;
string updatedText = item.MyContent.Text;
if (item.MyContent.MyGrid != null)
{
originalText = item.MyContent.MyGrid.Data;
updatedText = (item.MyContent.MyGrid.Data.Replace("&lt;START]", "<START]")).Replace("[END&gt;", "[END>");
}
// Exclude items that are not connected (Dummy steps for invalid transition destinations)
if (item.ItemDocVersionCount != 0 || item.MyPrevious != null || item.MyParent != null)
{
@@ -91,7 +99,10 @@ namespace DataLoader
{
try
{
updatedText = FixTransitionText(updatedText, tran);
if (item.MyContent.MyGrid != null)
updatedText = FixTableTransitionText(updatedText, tran, item.MyContent.Get());
else
updatedText = FixTransitionText(updatedText, tran);
}
catch (Exception ex)
{
@@ -100,10 +111,23 @@ namespace DataLoader
}
}
if (updatedText.EndsWith(" ")) updatedText = updatedText.Substring(0, updatedText.Length - 1);
using (Content c = item.MyContent.Get())
if (item.MyContent.MyGrid != null)
{
c.Text = updatedText;
c.Save();
using (Item itm = item.Get())
{
updatedText = (updatedText.Replace("<START]", "&lt;START]")).Replace("[END>", "[END&gt;");
string sstring = AdjustSizeAndGetSearchString(updatedText, itm);
itm.MyContent.Text = sstring;
itm.Save();
}
}
else
{
using (Content c = item.MyContent.Get())
{
c.Text = updatedText;
c.Save();
}
}
if (checkRTF)
{
@@ -154,5 +178,59 @@ namespace DataLoader
Console.WriteLine("Transition not Found");
return Text;
}
public string FixTableTransitionText(string Text, TransitionInfo tran, Content content)
{
string lookFor = string.Format(@"<START\]\\cf1\\v0 ([^#]*?)\\cf0\\v #Link:Transition[^:]*?:{0} {1}( [0-9]*){2}\[END>", tran.TranType, tran.TransitionID, "{1,2}");
string transText = tran.ResolvePathTo();
//Console.WriteLine(">>>>> FixTransitionText");
//Console.WriteLine("Text = {0}", Text);
//Console.WriteLine("lookFor = {0}", lookFor);
//Console.WriteLine("TransText = {0}", transText);
Match m = Regex.Match(Text, lookFor);
if (m != null && m.Groups.Count > 1)
{
System.Text.RegularExpressions.Group g = m.Groups[1];
if (g.ToString() != transText)
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
}
else
Console.WriteLine("Transition not Found");
//VlnFlexGrid grd = new VlnFlexGrid(1, 1);
//XmlDocument xd = new XmlDocument();
//xd.LoadXml(Text);
//grd.ReadXml(xd);
//grd.FixTableCellsHeightWidth(); // resize the column width/height
//using (StringWriter sw = new StringWriter())
//{
// grd.WriteXml(sw);
// //Console.WriteLine(sw.GetStringBuilder().ToString());
// content.MyGrid.Data = sw.GetStringBuilder().ToString();
// sw.Close();
//}
return Text;
}
private string AdjustSizeAndGetSearchString(string strXML, Item itm)
{
string rstring = "";
VlnFlexGrid grd = new VlnFlexGrid(1, 1);
XmlDocument xd = new XmlDocument();
xd.LoadXml(strXML);
grd.ReadXml(xd);
//using (StringReader sr = new StringReader(strXML))
//{
// grd.ReadXml(sr);
// sr.Close();
//}
grd.FixTableCellsHeightWidth(); // resize the column width/height
rstring = grd.GetSearchableText();
using (StringWriter sw = new StringWriter())
{
grd.WriteXml(sw);
itm.MyContent.MyGrid.Data = sw.GetStringBuilder().ToString();
sw.Close();
}
return rstring;
}
}
}