This commit is contained in:
parent
7801cdadf9
commit
91d6340f9d
@ -192,63 +192,66 @@ namespace Volian.Controls.Library
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
|
FormatInfo formatInfo = _MyItemInfo.ActiveFormat;
|
||||||
_MyItem = _MyItemInfo.Get();
|
using (_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)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("Save Failed because text changed outside of this edit session.");
|
// check for different text, i.e. text from this itm doesn't match
|
||||||
return false;
|
// original text, a change occurred in database, but not from this user.
|
||||||
}
|
if (OriginalText != EditText)
|
||||||
|
|
||||||
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);
|
Console.WriteLine("Save Failed because text changed outside of this edit session.");
|
||||||
// Replace Transition Text
|
return false;
|
||||||
foreach (ContentTransition ct in ctReplacements.Values)
|
}
|
||||||
using (TransitionInfo tran = TransitionInfo.Get(ct.TransitionID))
|
|
||||||
_MyItem.MyContent.FixTransitionText(tran);
|
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();
|
_MyItem.Save();
|
||||||
}
|
}
|
||||||
if (roUsgReplacements.Count > 0)
|
_MyItem = null;
|
||||||
{
|
OriginalText = modtext;
|
||||||
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();
|
|
||||||
}
|
|
||||||
OriginalText = modtext;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user