This commit is contained in:
Kathy Ruffing 2009-11-03 16:41:04 +00:00
parent 7801cdadf9
commit 91d6340f9d

View File

@ -192,63 +192,66 @@ namespace Volian.Controls.Library
try
{
FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
_MyItem = _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 != EditText)
using (_MyItem = _MyItemInfo.Get())
{
Console.WriteLine("Save Failed because text changed outside of this edit session.");
return false;
}
string modtext = RtfToDbText(rtb.Rtf);
// 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(_MyItem, origList);
EditText = DteToString();
// 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(_MyItem.MyContent.ContentTransitions);
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(_MyItem.MyContent.ContentRoUsages);
_MyItem.Save();
if (ctReplacements.Count > 0)
// 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 != EditText)
{
EditText = FixCtReplacements(EditText, ctReplacements);
// Replace Transition Text
foreach (ContentTransition ct in ctReplacements.Values)
using (TransitionInfo tran = TransitionInfo.Get(ct.TransitionID))
_MyItem.MyContent.FixTransitionText(tran);
Console.WriteLine("Save Failed because text changed outside of this edit session.");
return false;
}
string modtext = RtfToDbText(rtb.Rtf);
// 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(_MyItem, origList);
EditText = DteToString();
// 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(_MyItem.MyContent.ContentTransitions);
Dictionary<int, ContentRoUsage> roUsgReplacements = BuildRoUsgReplacements(_MyItem.MyContent.ContentRoUsages);
_MyItem.Save();
if (ctReplacements.Count > 0)
{
EditText = FixCtReplacements(EditText, ctReplacements);
// Replace Transition Text
foreach (ContentTransition ct in ctReplacements.Values)
using (TransitionInfo tran = TransitionInfo.Get(ct.TransitionID))
_MyItem.MyContent.FixTransitionText(tran);
_MyItem.Save();
}
if (roUsgReplacements.Count > 0)
{
EditText = FixRoUsgReplacements(EditText, roUsgReplacements);
_MyItem.Save();
}
modtext = EditText;
}
else
{
EditText = modtext;
foreach (Csla.Validation.BrokenRule br in _MyItem.MyContent.BrokenRulesCollection)
{
Console.WriteLine("{0} - {1}", br.Property, br.Description);
}
_MyItem.Save();
}
if (roUsgReplacements.Count > 0)
{
EditText = FixRoUsgReplacements(EditText, roUsgReplacements);
_MyItem.Save();
}
modtext = EditText;
_MyItem = null;
OriginalText = modtext;
}
else
{
EditText = modtext;
foreach (Csla.Validation.BrokenRule br in _MyItem.MyContent.BrokenRulesCollection)
{
Console.WriteLine("{0} - {1}", br.Property, br.Description);
}
_MyItem.Save();
}
OriginalText = modtext;
}
catch (Exception ex)
{