I was asked by a manager if I could make the ‘Cancel Cycle’ in the Actions menu be read only to everyone but certain people? Or just read only to everyone if that is not possible?
I have no idea if it is even possible so I thought I would ask here.
I have found the Name of the toolClick. It is ‘CancelPI’.
I have got it the do a message pop-up.
If I can figure out how to cancel the rest of the actions associated with the click, I will be happy with that.
I am getting:
Error: CS0246 - line 58 (145) - The type or namespace name ‘ButtonTool’ could not be found (are you missing a using directive or an assembly reference?)
Error: CS0246 - line 58 (145) - The type or namespace name ‘ButtonTool’ could not be found (are you missing a using directive or an assembly reference?)
Your idea is the easiest way - just make a menu item without the customization just for your manager. Or…I suppose you could check the user before calling your function above - if it’s Mr. Manager, don’t run that line.
For future reference to anyone who wants to do something like this:
In script Editor:
At the top, I added:
using Infragistics.Win.UltraWinToolbars;
using Ice.Core;
Then at the bottom, I added this (before the last close curly bracket):
private void CountCycleForm_Load(object sender, EventArgs args) //Change CountCycleForm to your form name.
{
// Add Event Handler Code
Ice.Core.Session session = (Ice.Core.Session)
CountCycleForm.Session;
string PN = session.UserID;
if(PN == "Example_User"){ //PN = "Your User ID HERE"
//This lets you keep the ToolButton item visible.
}else{
//Change CountCycleForm to your form name. Change CancelPI to the item name.
ButtonTool CancelPI = (ButtonTool)CountCycleForm.MainToolManager.Tools["CancelPI"];
CancelPI.SharedProps.Visible = false;
}
}
Hope this helps someone in the future.
Again, thanks to @Chris_Conn for helping me put this together.
Here’s a document I put together on how the find the item name. I got it from another website and referenced it in the footer. Find out what a click event name is.docx (134.3 KB)
I would suggest using a security group instead of hard coding the username that will have access. I use the following code to check the user security group.
private void CheckUserIdSecGrp()
{
// Get the Current User ID from the Call Context Client data set.
EpiDataView edv = (EpiDataView) this.oTrans.EpiDataViews["CallContextClientData"];
string myuser = edv.dataView[0]["CurrentUserId"].ToString();
try
{ //need to bring in userfileadapter as well via import bl assemblies to get this reference
UserFileAdapter adapterUserFile = new UserFileAdapter(this.oTrans);
adapterUserFile.BOConnect();
bool result = adapterUserFile.GetByID(myuser);
// Get the dataset by the login User session id. GetByID. Returns a DataSet given the primary key.
if (result == true)
{
if (adapterUserFile.UserFileData.UserFile[0]["SecurityMgr"].ToString() == "True" ||
adapterUserFile.UserFileData.UserFile[0]["GroupList"].ToString().IndexOf("CREATESALEORDER") != -1) // The security group name (code id).
{
fullversion = true; // fullversion should be declared at form initialization as Boolean and set to false.
}
}
// Cleanup Adapter Reference
adapterUserFile.Dispose();
}
catch (System.Exception ex)
{
ExceptionBox.Show(ex);
}
}