This commit is contained in:
203
PROMS/DataLoader/ConversionRTBProblems.cs
Normal file
203
PROMS/DataLoader/ConversionRTBProblems.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml.Schema;
|
||||
using System.IO;
|
||||
using VEPROMS.CSLA.Library;
|
||||
|
||||
namespace DataLoader
|
||||
{
|
||||
[XmlRoot("Proms2010Print")]
|
||||
//[Serializable()]
|
||||
public class ConversionRTBProblems
|
||||
{
|
||||
private RTBProblems _RTBProblems;
|
||||
|
||||
public RTBProblems RTBProblems
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_RTBProblems == null) _RTBProblems = new RTBProblems();
|
||||
return _RTBProblems;
|
||||
}
|
||||
set { _RTBProblems = value; }
|
||||
}
|
||||
public void Save(string fileName)
|
||||
{
|
||||
XmlSerializer<ConversionRTBProblems>.WriteFile(this, fileName);
|
||||
}
|
||||
public static ConversionRTBProblems LoadProblems(string fileName)
|
||||
{
|
||||
return XmlSerializer<ConversionRTBProblems>.ReadFile(fileName);
|
||||
}
|
||||
public void Add(int itemID, int contentID, string originalRTF, string oldRTF, string stepRTF, string newRTF, string stepPath)
|
||||
{
|
||||
_RTBProblems.Add(itemID, contentID, originalRTF, oldRTF, stepRTF, newRTF, stepPath);
|
||||
}
|
||||
//public void Add(int itemID, int contentID, string originalRTF, string oldRTF, string stepRTF, string newRTF, string stepPath, ItemInfo iteminfo)
|
||||
//{
|
||||
// _RTBProblems.Add(itemID, contentID, originalRTF, oldRTF, stepRTF, newRTF, stepPath, iteminfo);
|
||||
//}
|
||||
}
|
||||
public class RTBProblems : List<RTBProblem>
|
||||
{
|
||||
//public void Add(int itemID, int contentID, string originalRTF, string oldRTF, string stepRTF, string newRTF, string stepPath, ItemInfo iteminfo)
|
||||
public void Add(int itemID, int contentID, string originalRTF, string oldRTF, string stepRTF, string newRTF, string stepPath)
|
||||
{
|
||||
base.Add(new RTBProblem(itemID, contentID, originalRTF, oldRTF, stepRTF, newRTF, stepPath));
|
||||
//base.Add(new RTBProblem(itemID, contentID, originalRTF, oldRTF, stepRTF, newRTF, stepPath, iteminfo));
|
||||
}
|
||||
}
|
||||
public class RTBProblem
|
||||
{
|
||||
public RTBProblem()
|
||||
{
|
||||
}
|
||||
//public RTBProblem(int itemID, int contentID, string originalRTF, string oldRTF, string stepRTF, string newRTF, string stepPath, ItemInfo iteminfo)
|
||||
public RTBProblem(int itemID, int contentID, string originalRTF, string oldRTF, string stepRTF, string newRTF, string stepPath)
|
||||
{
|
||||
_ItemID = itemID;
|
||||
_ContentID = contentID;
|
||||
_OldRTF = oldRTF;
|
||||
_NewRTF = newRTF;
|
||||
_StepPath = stepPath;
|
||||
_OriginalRTF = originalRTF;
|
||||
_StepRtf = stepRTF;
|
||||
//_itemInfo = iteminfo;
|
||||
}
|
||||
private int _ItemID;
|
||||
[XmlAttribute("ItemID")]
|
||||
public int ItemID
|
||||
{
|
||||
get { return _ItemID; }
|
||||
set { _ItemID = value; }
|
||||
}
|
||||
private int _ContentID;
|
||||
[XmlAttribute("ContentID")]
|
||||
public int ContentID
|
||||
{
|
||||
get { return _ContentID; }
|
||||
set { _ContentID = value; }
|
||||
}
|
||||
private string _OriginalRTF;
|
||||
[XmlAttribute("OriginalRTF")]
|
||||
public string OriginalRTF
|
||||
{
|
||||
get { return _OriginalRTF; }
|
||||
set { _OriginalRTF = value; }
|
||||
}
|
||||
private string _OldRTF;
|
||||
[XmlAttribute("OldRTF")]
|
||||
public string OldRTF
|
||||
{
|
||||
get { return _OldRTF; }
|
||||
set { _OldRTF = value; }
|
||||
}
|
||||
private string _StepRtf;
|
||||
[XmlAttribute("StepRTF")]
|
||||
public string StepRtf
|
||||
{
|
||||
get { return _StepRtf; }
|
||||
set { _StepRtf = value; }
|
||||
}
|
||||
private string _NewRTF;
|
||||
[XmlAttribute("NewRTF")]
|
||||
public string NewRTF
|
||||
{
|
||||
get { return _NewRTF; }
|
||||
set { _NewRTF = value; }
|
||||
}
|
||||
private string _StepPath;
|
||||
[XmlAttribute("StepPath")]
|
||||
public string StepPath
|
||||
{
|
||||
get { return _StepPath; }
|
||||
set { _StepPath = value; }
|
||||
}
|
||||
private string _Comparison;
|
||||
[XmlIgnore]
|
||||
public string Comparison
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Comparison == null)
|
||||
_Comparison = GetComparison(_OldRTF, _NewRTF);
|
||||
return _Comparison;
|
||||
}
|
||||
}
|
||||
private string _StripRTF;
|
||||
[XmlIgnore]
|
||||
public string StripRTF
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_StripRTF == null)
|
||||
_StripRTF = GetStrip(_StepRtf);
|
||||
return _StripRTF;
|
||||
}
|
||||
set { _StripRTF = value; }
|
||||
}
|
||||
|
||||
//private ItemInfo _itemInfo;
|
||||
//[XmlIgnore]
|
||||
//public ItemInfo ItemInfo
|
||||
//{
|
||||
// get { return _itemInfo; }
|
||||
// set { _itemInfo = value; }
|
||||
//}
|
||||
|
||||
private string GetStrip(string _StepRtf)
|
||||
{
|
||||
string rttval = Volian.Controls.Library.DisplayText.StaticStripRtfCommands(_StepRtf);
|
||||
//string rttval = Volian.Controls.Library.DisplayText.StaticStripRtfCommands(_StepRtf, _itemInfo);
|
||||
//return rttval.Replace(@"\u8209?", "-");
|
||||
return rttval;
|
||||
}
|
||||
private string GetComparison(string str1, string str2)
|
||||
{
|
||||
if (str1 == str2) return str1;
|
||||
int endMatch = 0;
|
||||
int l1 = str1.Length;
|
||||
int l2 = str2.Length;
|
||||
int min = l1 > l2 ? l2 : l1;
|
||||
int startMatch = min;
|
||||
for (int i = 0; i < min; i++)
|
||||
if (str1[i] != str2[i])
|
||||
{
|
||||
startMatch = i;
|
||||
break;
|
||||
}
|
||||
min = min - startMatch;
|
||||
endMatch = min;
|
||||
for (int i = 1; i < min; i++)
|
||||
if (str1[l1 - i] != str2[l2 - i])
|
||||
{
|
||||
endMatch = i - 1;
|
||||
break;
|
||||
}
|
||||
string prefix = str1.Substring(0, startMatch);
|
||||
string part1 = str1.Substring(startMatch, l1 - (startMatch + endMatch));
|
||||
string part2 = str2.Substring(startMatch, l2 - (startMatch + endMatch));
|
||||
string suffix = str1.Substring(l1 - endMatch, endMatch);
|
||||
return prefix + "\r\n<<<" + part1 + "|||" + part2 + ">>>\r\n" + suffix;
|
||||
}
|
||||
private ItemInfo _MyItem;
|
||||
[XmlIgnore]
|
||||
public ItemInfo MyItem
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_MyItem == null)
|
||||
_MyItem = ItemInfo.Get(_ItemID);
|
||||
return _MyItem;
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return MyItem.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user