C2019-036 View Only mode work with Checked Out Procedures

This commit is contained in:
2025-11-17 07:05:52 -05:00
parent b0e4128d3c
commit bd89af5e8c
9 changed files with 208 additions and 27 deletions

View File

@@ -603,6 +603,8 @@ namespace Volian.Controls.Library
{
ItemInfo myItemInfo = myItemInfo2;
bool viewonlymode = false;
//B2025-046 Remember Tabs failing when swapping versions of PROMS
if (myItemInfo?.MyDocVersion == null) // bug fix: B2016-108 disconnected data will not have a MyDocVersion
{
@@ -620,8 +622,11 @@ namespace Volian.Controls.Library
{
if (!MySessionInfo.CanCheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message))
{
FlexibleMessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return null;
//C2019-036 View Only mode work with Checked Out Procedures
if (MessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
viewonlymode = true;
else
return null;
}
}
else
@@ -682,7 +687,7 @@ namespace Volian.Controls.Library
// C2023-016 if a Word section and doing Find/Replace don't open Word section, position to section title in step editor instead
if (myItemInfo.MyContent.MyEntry == null || doingFindReplace) // If it is not a Word document open in step editor
{
return OpenStepTabPage(myItemInfo, setFocus);
return OpenStepTabPage(myItemInfo, setFocus, viewonlymode);
}
else // Otherwise open it in the Word editor
{
@@ -1178,7 +1183,7 @@ namespace Volian.Controls.Library
//}
//public Dictionary<DocVersionInfo, frmEnhanced> dicEnhancedDocuments = new Dictionary<DocVersionInfo, frmEnhanced>();
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo, bool setFocus)
private DisplayTabItem OpenStepTabPage(ItemInfo myItemInfo, bool setFocus, bool viewonlymode = false)
{
ItemInfo proc = myItemInfo.MyProcedure; // Find procedure Item
string key = "Item - " + proc.ItemID.ToString();
@@ -1197,7 +1202,7 @@ namespace Volian.Controls.Library
}
else // If not already open, create a new Page
{
pg = new DisplayTabItem(this.components, this, proc, key); // Open a new Procedure Tab
pg = new DisplayTabItem(this.components, this, proc, key, viewonlymode); // Open a new Procedure Tab
_MyDisplayTabItems.Add(key, pg);
if (setFocus)
{

View File

@@ -98,13 +98,18 @@ namespace Volian.Controls.Library
}
#endregion
#region Constructors
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey)
public DisplayTabItem(IContainer container, DisplayTabControl myDisplayTabControl, ItemInfo myItemInfo, string myKey, bool viewonlymode = false)
{
_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);
//C2019-036 View Only mode work with Checked Out Procedures
//don't want to check out if opening in View Only Mode Due to someone else having it checked out
if (!viewonlymode)
{
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;
@@ -112,7 +117,7 @@ namespace Volian.Controls.Library
InitializeComponent();
this.Click += new EventHandler(DisplayTabItem_Click);
if (myItemInfo.MyContent.MyEntry == null)
SetupStepTabPanel();
SetupStepTabPanel(viewonlymode);
else
SetupDSOTabPanel();
SetupSecurity(myItemInfo);
@@ -128,6 +133,11 @@ namespace Volian.Controls.Library
private bool MesssageShown = false;
public void SetupSecurity(ItemInfo myItem)
{
//C2019-036 View Only mode work with Checked Out Procedures
//is in View Only Mode, so do not set up the Security
if (OwnerID == 0)
return;
UserInfo ui = UserInfo.GetByUserID(OwnerInfo.Get(OwnerID).SessionUserID);
if (ui == null)
@@ -246,7 +256,7 @@ namespace Volian.Controls.Library
/// <summary>
/// Creates and sets-up a StepTabPanel
/// </summary>
private void SetupStepTabPanel()
private void SetupStepTabPanel(bool viewonlymode = false)
{
((System.ComponentModel.ISupportInitialize)(_MyDisplayTabControl.MyBar)).BeginInit();
_MyDisplayTabControl.MyBar.SuspendLayout();
@@ -276,7 +286,7 @@ namespace Volian.Controls.Library
_MyDisplayTabControl.MyBar.ResumeLayout(false);
DocVersionInfo dvi = _MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo; //MyRTBItem.MyItemInfo.MyProcedure.ActiveParent as DocVersionInfo;
if (dvi == null) return;
if (dvi.VersionType > 127)
if (dvi.VersionType > 127 || viewonlymode)
MyStepTabPanel.MyStepPanel.VwMode = E_ViewMode.View;
// C2021 - 027: Procedure level PC/PC - add _MyIteminfo to argument list
if (dvi.MultiUnitCount > 1)

View File

@@ -9,6 +9,7 @@ using System.Drawing;
using System.Text.RegularExpressions;
using Volian.Base.Library;
using JR.Utils.GUI.Forms;
using System.Linq;
namespace Volian.Controls.Library
{
@@ -386,6 +387,26 @@ namespace Volian.Controls.Library
// The following line expands the items needed to display SelectedItemInfo
ExpandAsNeeded(myItemInfo);
}
//C2019-036 View Only mode work with Checked Out Procedures
public void ResetAll()
{
List<int> itemIDs = Controls.OfType<RTBItem>().Where(t => t?.MyItemInfo?.ActiveParent != null && t.MyItemInfo.ActiveParent.GetType() == typeof(ItemInfo)).Select(x => (x.MyItemInfo.ActiveParent as ItemInfo).ItemID).Distinct().ToList();
foreach (int itemID in itemIDs)
{
ItemInfo.ResetParts(itemID);
}
// The following line actually reloads the procedure item
MyProcedureItemInfo = ItemInfo.Get(MyProcedureItemInfo.ItemID, true);
MyProcedureItemInfo.RefreshConfig();
ContentInfo.Refresh(Content.Get(MyProcedureItemInfo.MyContent.ContentID, true));
// The following line expands the items needed to display SelectedItemInfo
ExpandAsNeeded(SelectedItemInfo);
}
/// <summary>
/// Currently selected StepRTB
/// </summary>

View File

@@ -16,6 +16,8 @@ using DevComponents.DotNetBar;
using Microsoft.Win32;
using System.Diagnostics;
using JR.Utils.GUI.Forms;
using System.Collections.Concurrent;
using System.Threading.Tasks;
namespace Volian.Controls.Library
{
@@ -906,6 +908,11 @@ namespace Volian.Controls.Library
// //SetButtonAndMenuEnabling(false);
//}
private Bitmap createTextBitmap(char ch)
{
return createTextBitmap(ch, new Font("FreeMono", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel));
}
private Bitmap createTextBitmap(char ch, Font objFont)
{
string txt = string.Format("{0}", ch);
Bitmap objBmpImage = new Bitmap(1, 1);
@@ -916,8 +923,6 @@ namespace Volian.Controls.Library
// Create the Font object for the image text drawing.
// later on, we could add logic to use either FreeMono or Arial Unicode MS based on the format being used
// but for now, we are going to use FreeMono to create the symbol list
Font objFont = new Font("FreeMono", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
//Font objFont = new Font("Arial Unicode MS", 18, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
// Create a graphics object to measure the text's width and height.
Graphics objGraphics = Graphics.FromImage(objBmpImage);
@@ -937,7 +942,6 @@ namespace Volian.Controls.Library
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
objGraphics.TextContrast = 0;
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
//objGraphics.DrawString(txt, objFont, new SolidBrush(Color.FromArgb(102, 102, 102)), 0, 0);
objGraphics.DrawString(txt, objFont, new SolidBrush(Color.Black),0,0);
objGraphics.Flush();
return (objBmpImage);
@@ -2067,6 +2071,9 @@ namespace Volian.Controls.Library
rtabHome.Select();
rtabTableGridTools.Visible = false;
SetButtonMenuEnabledDisabledOnStepType(false);
//C2019-036 View Only mode work with Checked Out Procedures
//Is in View Only Mode so show button as selected
btnEditMode.Checked = btnCMEditMode1.Checked = true;
this.Refresh();
return;
}
@@ -3338,10 +3345,43 @@ namespace Volian.Controls.Library
public void SetupAdminMode()
{
}
//C2019-036 View Only mode work with Checked Out Procedures
public event StepTabRibbonEvent EnableDisableStepProperties;
private void OnEnableDisableStepProperties(StepTabRibbonEventArgs args)
{
if (EnableDisableStepProperties != null)
EnableDisableStepProperties(this, args);
}
private void btnToggleEditView_Click(object sender, EventArgs e)
{
if (MyEditItem == null) return;
//C2019-036 View Only mode work with Checked Out Procedures
string message = string.Empty;
if (MyEditItem.MyStepPanel.VwMode == E_ViewMode.View && !MySessionInfo.CanCheckOutItem(MyEditItem.MyItemInfo.MyProcedure.ItemID, CheckOutType.Procedure, ref message))
{
//someone else has the procedure checked out so cannot swap out of view only mode
message = message.Replace("\r\nWould You like to open the procedure in View Only Mode?", "\r\n\r\nYou will be unable to turn off View Only Mode for this procedure until it is checked in by the user specified above.");
MessageBox.Show(this, message, "Procedure Already Checked Out", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else if (MyEditItem.MyStepPanel.VwMode == E_ViewMode.View)
{
//swapping into edit mode, so check out procedure and Setup Security
(this.Parent as StepTabPanel).MyDisplayTabItem.OwnerID = MySessionInfo.CheckOutItem(MyEditItem.MyItemInfo.MyProcedure.ItemID, 0);
(this.Parent as StepTabPanel).MyDisplayTabItem.SetupSecurity(MyItemInfo);
}
else
{
//swapping into View Only mode, so check in procedure
OwnerInfo oi = OwnerInfo.GetByItemID(MyEditItem.MyItemInfo.MyProcedure.ItemID, CheckOutType.Procedure);
MySessionInfo.CheckInItem(oi.OwnerID);
}
MyEditItem.MyStepPanel.VwMode = MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit ? E_ViewMode.View : E_ViewMode.Edit;
//enable / disable the Step Properties Panel based on the ViewMode
OnEnableDisableStepProperties(new StepTabRibbonEventArgs(MyEditItem.MyItemInfo, 0, MyEditItem.MyStepPanel.VwMode));
MyEditItem.ToggleEditView(MyEditItem.MyStepPanel.VwMode);
SetButtonAndMenuEnabling(true);
SetStepButtonAndMenuEnabling(true);
@@ -3355,7 +3395,62 @@ namespace Volian.Controls.Library
// btnEnhancedDocSync.Checked = !btnEnhancedDocSync.Checked;
//}
//C2019-036 View Only mode work with Checked Out Procedures
// using a blocking collection to make it thread safe in case someone
// spams hitting the refresh button
private BlockingCollection<bool> blockingRefreshProcedure = new BlockingCollection<bool>();
//C2019-036 View Only mode work with Checked Out Procedures
private void btnRefreshProcedure_Click(object sender, EventArgs e)
{
//Consumer
Task.Run(() =>
{
//Blocks until a newRefresh Procedure Run is available
while (!blockingRefreshProcedure.IsCompleted)
{
_ = blockingRefreshProcedure.Take();
RefreshProcedure();
}
});
//Producer
Task.Run(() => { blockingRefreshProcedure.Add(true); });
}
public void RefreshProcedure()
{
StepTabPanel stab_Panel = Parent as StepTabPanel;
if (MyEditItem != null)
{
if (!MyEditItem.MyStepPanel.ContainsFocus)
this.Invoke((Action)(() => { MyEditItem.MyStepPanel.Focus(); }));
E_ViewMode mode = MyEditItem.MyStepPanel.VwMode;
Application.DoEvents();
this.Invoke((Action)(() => {MyEditItem.MyStepPanel.ResetAll();}));
Application.DoEvents();
this.Invoke((Action)(() => {MyEditItem.MyStepPanel.Refresh();}));
Application.DoEvents();
MyEditItem.MyStepPanel.VwMode = mode;
Application.DoEvents();
}
else if (stab_Panel != null)
{
if (!stab_Panel.MyStepPanel.ContainsFocus)
this.Invoke((Action)(() => {stab_Panel.MyStepPanel.Focus();}));
E_ViewMode mode = stab_Panel.MyStepPanel.VwMode;
Application.DoEvents();
this.Invoke((Action)(() => {stab_Panel.MyStepPanel.ResetAll();}));
Application.DoEvents();
this.Invoke((Action)(() => {stab_Panel.MyStepPanel.Refresh();}));
Application.DoEvents();
stab_Panel.MyStepPanel.VwMode = mode;
Application.DoEvents();
}
}
private void btnROEdit_Click(object sender, EventArgs e)
{
if (VlnSettings.ReleaseMode.Equals("DEMO"))
@@ -4865,10 +4960,11 @@ namespace Volian.Controls.Library
public class StepTabRibbonEventArgs : EventArgs
{
public StepTabRibbonEventArgs() { ; }
public StepTabRibbonEventArgs(ItemInfo proc, int oringFlg = 0)
public StepTabRibbonEventArgs(ItemInfo proc, int oringFlg = 0, E_ViewMode viewMode = E_ViewMode.Edit)
{
_Proc = proc;
OringFlg = oringFlg;
ViewMode = viewMode;
}
private ItemInfo _Proc;
@@ -4884,6 +4980,9 @@ namespace Volian.Controls.Library
get { return _OringFlg; }
set { _OringFlg = value; }
}
//C2019-036 View Only mode work with Checked Out Procedures
public E_ViewMode ViewMode { get; set; }
}
public delegate void StepTabRibbonEvent(object sender, StepTabRibbonEventArgs args);