By Wayne Brill
Applies to:
Autodesk® Vault Collaboration 2012
Autodesk® Vault Professional 2012
Autodesk® Vault Workgroup 2012
Issue
I am using the RestrictOperations SDK sample. AddRestriction() is not getting added for the UpdateFileLifeCycleState event even though it is checked in the Configurator. Is there a way to get this to work in the sample?
Solution
There is a typo in Configulator tool, and was fixed in the 2013 release.
This code snippet is from Form1.cs and is a list of strings that is used to determine which event will be restricted by a call to AddRestriction(). Notice that the "c" in "UpdateFileLifecycleState" is lower case.
public partial class Form1 : Form
{
private List<string> m_commands =
new List<string>()
{
// File commands
"AddFile",
"CheckinFile",
"CheckoutFile" ,
"DeleteFile",
"DownloadFile",
"UpdateFileLifecycleState",
This code from EventHandlers.cs compares the event type name with the setting stored by Configulator tool to determine if AddRestriction() should be called. The Contains() function returns false because the commandName string is UpdateFileLifeCycleState which has an upper case "C", but the stored setting is “UpdateFileLifecycleState” which has a lower case. This causes the AddRestriction not to be called.
private void
RestrictOperation
(WebServiceCommandEventArgs eventArgs)
{
string commandName = eventArgs.GetType().Name;
if (commandName.EndsWith("CommandEventArgs"))
commandName = commandName.Remove
(commandName.Length -
"CommandEventArgs".Length);
RestrictSettings settings =
RestrictSettings.Load();
if (settings.RestrictedOperations.Contains
(commandName))
eventArgs.AddRestriction
(new ExtensionRestriction
("", "Test restriction"));
}