diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index 81464e88..63fecf58 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -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(@" -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@" -1)); - if (haslinks) - { - // Get all links in original list - RtfToDisplayTextElements(OriginalText); - List 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 ctReplacements = BuildCtReplacements(_MyItem.MyContent.ContentTransitions); - Dictionary 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(@" -1) || (OriginalText != null && OriginalText != "" && OriginalText.IndexOf(@" -1)); + if (haslinks) + { + // Get all links in original list + RtfToDisplayTextElements(OriginalText); + List 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 ctReplacements = BuildCtReplacements(_MyItem.MyContent.ContentTransitions); + Dictionary 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) {