B2022-055 Fix to help prevent crashing when opening/closing/re-opening procedures.

This commit is contained in:
John Jenko 2022-05-25 19:59:41 +00:00
parent b9a444c941
commit e0acae62c9

View File

@ -17,9 +17,9 @@ namespace Volian.Controls.Library
private StepTabPanel _MyStepTabPanel;
private string _MyKey;
private DSOTabPanel _MyDSOTabPanel;
private DocumentInfo _MyDocumentInfo;
private DocumentInfo _MyDocumentInfo;
#endregion
#region Properties
/// <summary>
@ -78,50 +78,58 @@ namespace Volian.Controls.Library
/// </summary>
public ItemInfo SelectedItemInfo
{
get
get
{
if (_MyStepTabPanel == null) return null;
return _MyStepTabPanel.SelectedItemInfo;
}
set {// B2018-074 Don't crash if opening MSWord section from Tools window in Debug Mode
if (_MyStepTabPanel != null)
_MyStepTabPanel.SelectedItemInfo = value;
set
{// B2018-074 Don't crash if opening MSWord section from Tools window in Debug Mode
if (_MyStepTabPanel != null)
_MyStepTabPanel.SelectedItemInfo = value;
}
}
/// <summary>
/// Current DocumentInfo for this page - only set if library document
/// </summary>
public DocumentInfo MyDocumentInfo
{
get { return _MyDocumentInfo; }
}
/// <summary>
/// Current DocumentInfo for this page - only set if library document
/// </summary>
public DocumentInfo MyDocumentInfo
{
get { return _MyDocumentInfo; }
}
#endregion
#region Constructors
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey)
{
_MyItemInfo = myItemInfo;
if (MyItemInfo.MyContent.MyEntry == null)
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure);
else
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document);
//Console.WriteLine("DisplayTabItem");
_MyKey = myKey;
_MyDisplayTabControl = myDisplayTabControl;
container.Add(this);
InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click);
if (myItemInfo.MyContent.MyEntry == null)
SetupStepTabPanel();
else
SetupDSOTabPanel();
SetupSecurity(myItemInfo);
if (MyDSOTabPanel == null || MyDSOTabPanel.MyEdWord != null) // B2017-219 check needed if we could not open a word attachment
Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID);
}
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey)
{
_MyItemInfo = myItemInfo;
if (MyItemInfo.MyContent.MyEntry == null)
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure);
else
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document);
//Console.WriteLine("DisplayTabItem");
_MyKey = myKey;
_MyDisplayTabControl = myDisplayTabControl;
container.Add(this);
InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click);
if (myItemInfo.MyContent.MyEntry == null)
SetupStepTabPanel();
else
SetupDSOTabPanel();
SetupSecurity(myItemInfo);
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//if (MyDSOTabPanel == null || MyDSOTabPanel.MyEdWord != null) // B2017-219 check needed if we could not open a word attachment
//{
// //Name = string.Format("DisplayTabItem {0}", myItemInfo.ItemID);
//}
}
private bool MesssageShown = false;
public void SetupSecurity(ItemInfo myItem)
{
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
if (ui == null)
{
if (!MesssageShown)
@ -133,8 +141,9 @@ namespace Volian.Controls.Library
}
else if (ui.IsAdministrator())
{
if(_MyStepTabPanel != null)
if (_MyStepTabPanel != null)
_MyStepTabPanel.MyStepTabRibbon.SetupAdminMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Administrator";
}
else if (ui.IsSetAdministrator(myItem.MyDocVersion))
@ -143,10 +152,10 @@ namespace Volian.Controls.Library
_MyStepTabPanel.MyStepTabRibbon.SetupSetAdminMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Set Administrator";
}
else if (ui.IsROEditor(myItem.MyDocVersion) && !ui.IsWriter(myItem.MyDocVersion))
else if (ui.IsROEditor(myItem.MyDocVersion) && !ui.IsWriter(myItem.MyDocVersion))
{
if (_MyStepTabPanel != null)
_MyStepTabPanel.MyStepTabRibbon.SetupROEditorMode();
if (_MyStepTabPanel != null)
_MyStepTabPanel.MyStepTabRibbon.SetupROEditorMode();
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - RO Editor";
}
else if (ui.IsWriter(myItem.MyDocVersion))
@ -168,27 +177,30 @@ namespace Volian.Controls.Library
MyUserRole = Volian.Base.Library.VlnSettings.UserID + " - Reviewer";
}
}
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, DocumentInfo myDocumentInfo, string myKey)
{
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myDocumentInfo.DocID, CheckOutType.Document);
_MyKey = myKey;
_MyDisplayTabControl = myDisplayTabControl;
_MyDocumentInfo = myDocumentInfo;
container.Add(this);
InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click);
SetupLibraryDocumentDSOTabPanel();
Name = string.Format("DisplayTabLibraryDocument {0}", myDocumentInfo.DocID);
}
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, DocumentInfo myDocumentInfo, string myKey)
{
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myDocumentInfo.DocID, CheckOutType.Document);
_MyKey = myKey;
_MyDisplayTabControl = myDisplayTabControl;
_MyDocumentInfo = myDocumentInfo;
container.Add(this);
InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click);
SetupLibraryDocumentDSOTabPanel();
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = string.Format("DisplayTabLibraryDocument {0}", myDocumentInfo.DocID);
}
protected override void OnDisplayedChanged()
{
//Console.WriteLine("=>=>=>=> OnDisplayedChanged");
if(_MyStepTabPanel != null)
if (_MyStepTabPanel != null)
_MyStepTabPanel.MyStepPanel.DisplayItemChanging = true;
base.OnDisplayedChanged();
if (_MyStepTabPanel != null)
_MyStepTabPanel.MyStepPanel.DisplayItemChanging = false;
_MyStepTabPanel.MyStepPanel.DisplayItemChanging = false;
//Console.WriteLine("<=<=<=<= OnDisplayedChanged");
}
@ -222,12 +234,12 @@ namespace Volian.Controls.Library
{
// Tell the TabControl that the ItemSelected has changed
DisplayTabItem myTabItem = sender as DisplayTabItem;
if(myTabItem == null)return;
if (myTabItem == null) return;
StepTabPanel myTabPanel = myTabItem.MyStepTabPanel as StepTabPanel;
if(myTabPanel == null) return;
if (myTabPanel == null) return;
if (MyStepTabPanel.SelectedEditItem == null) return;
MyStepTabPanel.MyDisplayTabControl.HandleChangeId(MyStepTabPanel.SelectedEditItem.MyItemInfo, myTabItem);
_MyDisplayTabControl.OnItemSelectedChanged(this,new ItemSelectedChangedEventArgs(MyStepTabPanel.SelectedEditItem));
_MyDisplayTabControl.OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(MyStepTabPanel.SelectedEditItem));
}
#endregion
#region private Methods
@ -243,7 +255,10 @@ namespace Volian.Controls.Library
// tabItem
//
Control = _MyStepTabPanel;
Name = "tabItem Item " + _MyItemInfo.ItemID;
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = "tabItem Item " + _MyItemInfo.ItemID;
Text = _MyItemInfo.TabTitle;
_MyItemInfo.Changed += new ItemInfoEvent(_MyItemInfo_Changed);
Tooltip = _Tooltip = _MyItemInfo.TabToolTip.Replace("\u2011", "-").Replace(@"\u9586?", @"\");
@ -274,7 +289,7 @@ namespace Volian.Controls.Library
}
void DisplayTabItem_LostFocus(object sender, EventArgs e)
{
if(Tooltip != _Tooltip)
if (Tooltip != _Tooltip)
Tooltip = _Tooltip;
}
private string _Tooltip;
@ -285,7 +300,7 @@ namespace Volian.Controls.Library
void DisplayTabItem_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
string newTooltip = e.Y > 30 ? null : _Tooltip;
if(Tooltip != newTooltip)
if (Tooltip != newTooltip)
Tooltip = newTooltip;
}
/// <summary>
@ -295,13 +310,16 @@ namespace Volian.Controls.Library
{
EntryInfo myEntry = _MyItemInfo.MyContent.MyEntry;
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
_MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl, _MyItemInfo, UserInfo.CanEdit(ui,MyItemInfo.MyDocVersion));
_MyDSOTabPanel = new DSOTabPanel(myEntry.MyDocument, _MyDisplayTabControl, _MyItemInfo, UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion));
if (_MyDSOTabPanel.MyEdWord == null) return; // B2017-219 if we could not open the word attachment just return
//
// tabItem
//
Control = _MyDSOTabPanel;
Name = "tabItem Item " + _MyItemInfo.ItemID;
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = "tabItem Item " + _MyItemInfo.ItemID;
Text = _MyItemInfo.TabTitle;
Tooltip = _Tooltip = _MyItemInfo.TabToolTip.Replace("\u2011", "-").Replace(@"\u9586?", @"\");
MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove);
@ -310,7 +328,7 @@ namespace Volian.Controls.Library
DSOTabPanel.IgnoreEnter = true;
//Console.WriteLine("AddRange {0}", Name);
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
this});
this});
//
// tabPanel
//
@ -318,34 +336,37 @@ namespace Volian.Controls.Library
_MyDSOTabPanel.MyDisplayTabItem = this;
DSOTabPanel.IgnoreEnter = false;
}
private void SetupLibraryDocumentDSOTabPanel()
{
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
// B2016-131 if myiteminfo is null, then the lib doc is not referenced.
// - Allow editting only if you are an Administrator
// - Cannot check if you are a Writer or Set Aministrator because we don't have a Doc Verion
_MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo, (MyItemInfo != null) ? UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion):ui.IsAdministrator());
//
// tabItem
//
Control = _MyDSOTabPanel;
Name = "tabLibraryDocument " + _MyDocumentInfo.DocID;
Text = _MyDocumentInfo.LibTitle;
DocumentConfig dc = new DocumentConfig(_MyDocumentInfo);
Tooltip = _Tooltip = dc.LibDoc_Comment;
private void SetupLibraryDocumentDSOTabPanel()
{
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
// B2016-131 if myiteminfo is null, then the lib doc is not referenced.
// - Allow editting only if you are an Administrator
// - Cannot check if you are a Writer or Set Aministrator because we don't have a Doc Verion
_MyDSOTabPanel = new DSOTabPanel(_MyDocumentInfo, _MyDisplayTabControl, _MyItemInfo, (MyItemInfo != null) ? UserInfo.CanEdit(ui, MyItemInfo.MyDocVersion) : ui.IsAdministrator());
//
// tabItem
//
Control = _MyDSOTabPanel;
// B2022-055 assigning the Name caused a duplicate name error
// we found that the procedure tab control remained in the Control list after the procedure was closed
// later on we need to find out why it isn't removed when the procedure is closed
//Name = "tabLibraryDocument " + _MyDocumentInfo.DocID;
Text = _MyDocumentInfo.LibTitle;
DocumentConfig dc = new DocumentConfig(_MyDocumentInfo);
Tooltip = _Tooltip = dc.LibDoc_Comment;
MouseMove += new System.Windows.Forms.MouseEventHandler(DisplayTabItem_MouseMove);
LostFocus += new EventHandler(DisplayTabItem_LostFocus);
_MyDisplayTabControl.Controls.Add(_MyDSOTabPanel);
DSOTabPanel.IgnoreEnter = true;
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
this});
//
// tabPanel
//
_MyDisplayTabControl.SelectDisplayTabItem(this);
_MyDSOTabPanel.MyDisplayTabItem = this;
DSOTabPanel.IgnoreEnter = false;
}
DSOTabPanel.IgnoreEnter = true;
_MyDisplayTabControl.MyBar.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {
this});
//
// tabPanel
//
_MyDisplayTabControl.SelectDisplayTabItem(this);
_MyDSOTabPanel.MyDisplayTabItem = this;
DSOTabPanel.IgnoreEnter = false;
}
#endregion
public override string ToString()
{