September 3, 2009

AzMan Create/Remove/Get Operation with C#

Seems this is kind of shaping up into a bit of a series. As a background since someone asked me yesterday, all this code was used within a webservice for AzMan a few years ago. The idea was that the MMC console is really bad, and we wanted a better way to add things. Also, not everyone had access to the server and we wanted to make this web based for those users.

We have already seen how to add a store and create an application in AzMan using C#. Now, let's go on to creating an operation using c#. I have uploaded a helper class here which has some comments not included in the short snippets below as well as some other methods. This class was designed to work with XML and AD (sorry not sql server yet).
public static IAzOperation AddOperation(IAzApplication app, string operationName)
{
if (operationName == null || operationName.Length == 0)
{
throw new ArgumentNullException("operationName", "Operation name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

IAzOperation operation = app.CreateOperation(operationName, null);

operation.Submit(0, null);

return operation;
}
Now let's delete that operation:
 public static void RemoveOperation(IAzApplication app, string operationName)
{
if (operationName == null || operationName.Length == 0)
{
throw new ArgumentNullException("operationName", "Operation name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

app.DeleteOperation(operationName , null);

app.Submit(0, null);
}
Get operation by name:
public static IAzOperation GetOperation(IAzApplication app, string operationName)
{
if (operationName == null || operationName.Length == 0)
{
throw new ArgumentNullException("operationName", "Operation name can not be null or empty.");
}
if (app == null)
{
throw new ArgumentNullException("app", "Application can not be null.");
}

return app.OpenOperation(operationName, null);
}

No comments:

Post a Comment