B2018-048 Opening an item from search results would sometimes be caught in an infinite loop. The code was trying to use the dictionary for open PROMS windows even when the Separate Windows mode was not active.

This commit is contained in:
John Jenko 2018-03-15 14:16:15 +00:00
parent c10da98204
commit daf19ec057

View File

@ -532,75 +532,85 @@ namespace Volian.Controls.Library
/// </summary> /// </summary>
/// <param name="myItemInfo"></param> /// <param name="myItemInfo"></param>
/// <returns></returns> /// <returns></returns>
public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus) public DisplayTabItem OpenItem(ItemInfo myItemInfo2, bool setFocus)
{ {
ItemInfo myItemInfo = myItemInfo2; ItemInfo myItemInfo = myItemInfo2;
if (myItemInfo.MyDocVersion == null) // bug fix: B2016-108 disconnected data will not have a MyDocVersion if (myItemInfo.MyDocVersion == null) // bug fix: B2016-108 disconnected data will not have a MyDocVersion
{ {
MessageBox.Show(this, "Possible disconnected item", "Item Not Found"); MessageBox.Show(this, "Possible disconnected item", "Item Not Found");
return null; return null;
} }
string message = string.Empty; string message = string.Empty;
if (myItemInfo.MyContent.MyEntry == null) //not a document //if (!MySessionInfo.CanCheckOutItem(myItemInfo.MyDocVersion.VersionID, CheckOutType.DocVersion, ref message))
{ //{
if (!MySessionInfo.CanCheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message)) // message = "The Working Draft is being processed.\n\n" + message;
{ // MessageBox.Show(this, message, "Cannot Check Out Procedure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); //}
return null; if (myItemInfo.MyContent.MyEntry == null) //not a document
} {
} if (!MySessionInfo.CanCheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message))
else {
{ MessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (!MySessionInfo.CanCheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document, ref message)) return null;
{ }
MessageBox.Show(this, message, "Document Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
return null; else
} {
} if (!MySessionInfo.CanCheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document, ref message))
{
MessageBox.Show(this, message, "Document Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return null;
}
}
CleanUpClosedItems(); CleanUpClosedItems();
if (myItemInfo == null) return null; if (myItemInfo == null) return null;
// if this is an auto table of contents section, don't edit it: // if this is an auto table of contents section, don't edit it:
if (myItemInfo.IsAutoTOCSection) if (myItemInfo.IsAutoTOCSection)
{ {
MessageBox.Show("This is an automatically generated 'Table of Contents' section. It is not editable. It is generated during Print.", "Item not Editable", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); MessageBox.Show("This is an automatically generated 'Table of Contents' section. It is not editable. It is generated during Print.", "Item not Editable", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return SelectedDisplayTabItem; return SelectedDisplayTabItem;
} }
bool libDocAlreadyOpen = false; bool libDocAlreadyOpen = false;
if (myItemInfo.MyContent.MyEntry != null) // Trying to open a Word document - see if it's a library document that is already opened. if (myItemInfo.MyContent.MyEntry != null) // Trying to open a Word document - see if it's a library document that is already opened.
libDocAlreadyOpen = LibDocAlreadyOpen(myItemInfo); libDocAlreadyOpen = LibDocAlreadyOpen(myItemInfo);
// C2015-022 modified if statement logic to support separate windows // C2015-022 modified if statement logic to support separate windows
// if opening the first procedure in a set, and the main PROMS window has a procedure opened from a different set, // if opening the first procedure in a set, and the main PROMS window has a procedure opened from a different set,
// then create a new child window. All other procedures from that same set will open in this child window. // then create a new child window. All other procedures from that same set will open in this child window.
// _AllDTCs is a dictionary of of all procedure sets opened along with their DisplayTabContol. The key to // _AllDTCs is a dictionary of of all procedure sets opened along with their DisplayTabContol. The key to
// the dictioan is the set's VersionID // the dictioan is the set's VersionID
if (VersionID != 0)
{
if (SeparateWindows && !libDocAlreadyOpen)
{
if (!_AllDTCs.ContainsKey(myItemInfo.MyDocVersion.VersionID))
{
OnOpenInSeparateWindow(new ItemSelectedChangedEventArgs(myItemInfo2)); // create a child (separate) PROMS window
return _AllDTCs[myItemInfo.MyDocVersion.VersionID].OpenItem(myItemInfo);
}
}
if (VersionID != myItemInfo.MyDocVersion.VersionID && _AllDTCs.ContainsKey(myItemInfo.MyDocVersion.VersionID))
{
return _AllDTCs[myItemInfo.MyDocVersion.VersionID].OpenItem(myItemInfo);
}
}
if (!libDocAlreadyOpen) // B2018-048 needed to add a check to see if we are in Separate Windows
VersionID = myItemInfo.MyDocVersion.VersionID; // add it to _AllDTCs // else we get stuck in a OpenItem loop when last DocVersion ID is not equal to the current DocVersion ID
// happened when you open a procedure then close the procedure tab, do a text search in a different procedure set
// then select one of search results.
if (SeparateWindows && VersionID != 0)
{
if (!libDocAlreadyOpen)
{
if (!_AllDTCs.ContainsKey(myItemInfo.MyDocVersion.VersionID))
{
OnOpenInSeparateWindow(new ItemSelectedChangedEventArgs(myItemInfo2)); // create a child (separate) PROMS window
return _AllDTCs[myItemInfo.MyDocVersion.VersionID].OpenItem(myItemInfo);
}
}
if (VersionID != myItemInfo.MyDocVersion.VersionID && _AllDTCs.ContainsKey(myItemInfo.MyDocVersion.VersionID))
{
return _AllDTCs[myItemInfo.MyDocVersion.VersionID].OpenItem(myItemInfo);
}
}
_MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item. if (!libDocAlreadyOpen)
if (myItemInfo.MyContent.MyEntry == null) // If it is not a Word document open in step editor VersionID = myItemInfo.MyDocVersion.VersionID; // add it to _AllDTCs
return OpenStepTabPage(myItemInfo, setFocus);
else // Otherwise open it in the Word editor _MyBar = GetParentBar(myItemInfo); // Get the docking bar associated with this item.
return OpenDSOTabPage(myItemInfo); if (myItemInfo.MyContent.MyEntry == null) // If it is not a Word document open in step editor
} return OpenStepTabPage(myItemInfo, setFocus);
else // Otherwise open it in the Word editor
return OpenDSOTabPage(myItemInfo);
}
public bool PasteRTBItem(ItemInfo myItemInfo, int copyStartID, ItemInfo.EAddpingPart pasteType, int type) public bool PasteRTBItem(ItemInfo myItemInfo, int copyStartID, ItemInfo.EAddpingPart pasteType, int type)
{ {
CleanUpClosedItems(); CleanUpClosedItems();