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

@@ -22,8 +22,6 @@ namespace DataLoader
{
//if (ProcNumber + "|" + stpseq == "082-002CD|A=S")
// Console.WriteLine("here");
//if (stpseq == "A;S#")
// Console.WriteLine("here");
Content content = null;
Item item = null;
@@ -76,11 +74,14 @@ namespace DataLoader
// Before we save it, handle RO & Transitions tokens.
int tokrt = Textm.IndexOf('\x15');
bool txtdirty = false;
bool bIsROTable = false;
if (tokrt > -1)
{
txtdirty = true;
stptext = MigrateRos(cn, stptext, seqcvt, content, docver, conv_caret);
stptext = stptext.TrimEnd(" ".ToCharArray());
// if this is a table RO, then save a flag in the config
bIsROTable = (Textm.Length == 1);
}
tokrt = Textm.IndexOf('\x3a6');
if (tokrt > -1)
@@ -107,7 +108,7 @@ namespace DataLoader
//string fixStpText = FixStepText(stptext,content.Type);
string fixStpText = "";
if (IsATable(content.Type))
fixStpText = ConvertTableToGrid(stptext,content,fmt);
fixStpText = ConvertTableToGrid(stptext, content, fmt, bIsROTable);
else
fixStpText = FixStepText(stptext);
if (fixStpText != stptext)
@@ -124,7 +125,7 @@ namespace DataLoader
List<string> migrationerrors = null;
if (_ContentMigrationErrors.ContainsKey(content.ContentID))
migrationerrors = _ContentMigrationErrors[content.ContentID];
content.Save();
content = content.Save();
// check if already created thru new during transition migration...
if (dicTrans_ItemIds.ContainsKey(ProcNumber + "|" + seqcvt))
{
@@ -134,13 +135,22 @@ namespace DataLoader
item.DTS = dts;
item.UserID = userid;
if (!item.IsSavable) ErrorRpt.ErrorReport(item);
item.Save();
item = item.Save();
dicTrans_ItemIds.Remove(ProcNumber + "|" + seqcvt);
dicTrans_MigrationErrors.Remove(ProcNumber + "|" + seqcvt);
}
else
item = Item.MakeItem(FromItem, content, content.DTS, content.UserID);
// If we converted a Table to a Grid, then insert an Annotation to alert the user to verify it
if (IsATable(content.Type))//item.MyContent.MyGrid != null)
{
ItemAnnotation ia = item.ItemAnnotations.Add(VerificationRequiredType);
ia.SearchText = "Verify Table Conversion";
ia.UserID = "Migration";
item.Save();
}
if (frType > 0)
{
parentItem.MyContent.ContentParts.Add(frType, item);
@@ -305,23 +315,19 @@ namespace DataLoader
return stepText;
}
//private Font GridFont = new Font("Courier New", 10);
//private Regex _RemoveComments = new Regex(@"\\v .*?\\v0 ");
private Regex _RemoveComments = new Regex(@"\\v .*?\\v0( |$)");
private string ConvertTableToGrid(string stepText, Content content, FormatInfo fmt)
private string ConvertTableToGrid(string stepText, Content content, FormatInfo fmt, bool isROTable)
{
string savethis = stepText;
string strGrid = "";
VlnFlexGrid grd = new VlnFlexGrid(1, 1);
//VE_Font vefont = content.MyFormat.PlantFormat.FormatData.StepDataList.Table.Font;
grd.IsRoTable = isROTable;
VE_Font vefont = fmt.PlantFormat.FormatData.StepDataList.Table.Font;
Font GridFont = new Font(vefont.Family, (float)vefont.Size);
grd.Font = GridFont; // this also changes the default Row Height "Rows.DefaultSize"
stepText = FixStepText(stepText);
stepText = stepText.Replace(@"\u8209?", "-");
stepText = stepText.Replace(@"\u9474?", "|");
stepText = stepText.Replace(@"\u8805?", "\xf2"); //greater than or equal
stepText = stepText.Replace(@"\u9474?", "\xB3"); // Vert Line graphic character
stepText = stepText.Replace(@"\'b0", "\xB0");
stepText = stepText.Replace(@"\up2 ", "\x9566");
stepText = stepText.Replace(@"\up0 ", "\x9567");
@@ -329,18 +335,39 @@ namespace DataLoader
stepText = stepText.Replace(@"\ul", "\xAB");
stepText = stepText.Replace(@"\{", "{");
stepText = stepText.Replace(@"\}", "}");
//stepText = stepText.Replace("\\b0", "\x2553");
//stepText = stepText.Replace("\\b", "\x2552");
stepText = stepText.Replace(@"\b0", "\xD6");
stepText = stepText.Replace(@"\b", "\xD5");
//stepText = stepText.Replace(@"\u160?", "\xA0"); //hard space
stepText = stepText.Replace(@"\u160?", "\xFF"); //hard space xFF is used in 16-bit proms
stepText = stepText.Replace(@"\u160?", "\xA0"); //hard space
stepText = stepText.Replace(@"\u916?", "\x7F"); // delta
stepText = stepText.Replace(@"\u8805?", "\xF2"); //greater than or equal
stepText = stepText.Replace(@"\u8804?", "\xF3"); // less than or equal
stepText = stepText.Replace(@"\u931?", "\xE4"); // sigma
stepText = stepText.Replace(@"\u947?", "\xE7"); // gamma
stepText = stepText.Replace(@"\u9604?", "\xFE"); // accum 2584
stepText = stepText.Replace(@"\u9679?", "\x7"); // bullet 25CF
stepText = stepText.Replace(@"\u8776?", "\xF7"); // approx eq
stepText = stepText.Replace(@"\u8773?", "\xF0"); // similar eq 2245
stepText = stepText.Replace(@"\u8730?", "\xFB"); // square root
stepText = stepText.Replace(@"\u961?", "\xE2"); // rho 3C1
stepText = stepText.Replace(@"\u960?", "\xE3"); // pi
stepText = stepText.Replace(@"\u956?", "\xE6"); // micro
stepText = stepText.Replace(@"\u948?", "\xEB"); // lower case delta
stepText = stepText.Replace(@"\u963?", "\xE5"); // lower case sigma
stepText = stepText.Replace(@"\u274?", "\x90"); // energy, 112
stepText = stepText.Replace(@"\u949?", "\xEE"); // epsilon
stepText = stepText.Replace(@"\u952?", "\xE9"); // theta, 3B8
stepText = stepText.Replace(@"\u8857?", "\xEC"); // dot in oval, 2299
stepText = stepText.Replace(@"\u964?", "\xA8"); // tau, 3C4
stepText = stepText.Replace(@"\u9830?", "\xA9"); // diamond, 2666
stepText = stepText.Replace(@"\u8593?", "\x18"); // Up Arrow - changes to \xff
stepText = stepText.Replace(@"\u8595?", "\x19"); // Down Arrow - changes to \xd6
//Console.WriteLine("B4 Parse Orig Text: '{0}'", savethis);
//Console.WriteLine("B4 Parse sym repl: '{0}'", stepText);
grd.ParseTableFromText(_RemoveComments.Replace(stepText, ""));
//grd.ParseTableFromText(_RemoveComments.Replace((stepText.Replace(@"\u8209?", "-")).Replace("\\'b0", "\xB0"), ""));
//grd.ParseTableFromText(_RemoveComments.Replace((stepText.Replace(@"\u8209?", "-")).Replace("\\par", "\n"), ""));
if (grd.IsRoTable)
grd.ParseTableFromText(_RemoveComments.Replace(stepText, ""));
else
grd.ParseTableFromText(stepText);
grd.AutoSizeCols();
grd.AutoSizeRows();
grd.MakeRTFcells();
@@ -348,8 +375,9 @@ namespace DataLoader
using (StringWriter sw = new StringWriter())
{
grd.WriteXml(sw);
Console.WriteLine(sw.GetStringBuilder().ToString());
//Console.WriteLine(sw.GetStringBuilder().ToString());
content.MyGrid.Data = sw.GetStringBuilder().ToString();
strGrid = grd.GetSearchableText();
sw.Close();
}
return strGrid;