Exercise 6: Configuring FSCI programmatically
File System Classification Infrastructure provides a fully supported API that can be used by developers and IT professionals to simplify the management and deployment of File Classification configurations.
Do you need to create and configure a wide set of properties, rules, and tasks? Do you need to organize deployment of all these configurations through several servers on your network and perhaps coordinate the task among different server administrators?
Consolidating all of these configurations into a script will make the task easier for everybody, but will also provide consistency, reduce the chances of human error in the configurations and make the process a lot more agile, saving you time and therefore, costly resources.
Because this API is built as a COM interface, it can be used from many programming languages and scripting languages. Whether you are a C++ developer, .NET expert, an experienced VBScript writer, or developing PowerShell scripts, you can access these objects and start improving the deployment processes.
In this exercise you will manipulate a C# application that works with the Report Manager and the Classification Manager. These two elements are part of the set of managers offered by the File System Classification Infrastructure; the list also includes managers for File Groups, File Screens, File Management, Paths, Quotas, and Report Schedulers.
Part 1: Working with the Report Manager
The Report Manager is one of the many components that grants access to the options offered by the File System Classification Infrastructure. In this exercise you will use it to list and run existing reports.
- Open the File Server Resource Manager from the Start menu:
Control Panel > Administrative Tools > File Server Resource Manager
Right click the Storage Reports Management node and select Schedule a New Report Task:
Under the Scope section, click the Add button:
Figure 72
Select the C:\ drive and click OK:
From the Report data section, make sure Quota Usage is the only one selected:
- Click on the Schedule Tab and click Create Schedule
Click on the New button and then click OK:
- Click the OK button to close the Storage Reports dialog.
Open an elevated Visual Studio instance by accessing:
Start All Programs Microsoft Visual Studio 2008
And right clicking on the Microsoft Visual Studio 2008 icon and then selecting Run as Administrator:
- When prompted with the UAC message, click Yes to launch Visual Studio with administrator privileges.
Go to the File menu and select Open > Project/Solution
Browse for the following solution file and click Open.
C:\Server 2008 R2 Labs\File System Classification Infrastructure\Exercise-6\FsciDistribution\FsciDistribution.sln
In the Solution Explorer, typically on the right side of the screen in Visual Studio, double click on the FsrmLogic.cs file.
The FsrmLogic class contains static methods that implement queries and configurations for FSRM. The application has a simple Graphical User Interface that locates these static methods automatically and gives you the option to execute them.
Go to the View menu and select the Task List option.
In the Task List window (typically at the bottom of the screen), make sure to select Comments as the type of item:
- Double click on the first TODO item in the list, labeled as:
//TODO: 01_Enumerate Jobs var reportMan; IFsrmCollection collection;
To work with reports and their jobs you need an instance of a report manager. Replace the declaration of reportMan above with the following declaration/instantiation:
var reportMan = new FsrmReportManager();
As you type this line, Intellisense will show a list of other managers. Feel free to take a quick look.
- The intention here is to have the collection variable contain all enumerated reports. Replace the declaration of collection with the following declaration/instantiation:
IFsrmCollection collection = reportMan.EnumReportJobs(_FsrmEnumOptions.FsrmEnumOptions_None);
- In the Tasks List, select the second item labeled as:
//TODO: 02_Get report job based on the task name IFsrmReportJob job;
- Replace the declaration of the job variable above, with the following declaration/instantiation statement:
IFsrmReportJob job = reportMan.GetReportJob(task);
Perhaps, you can take a few seconds to check the methods the report manager. Visual Studio’s intellisense capabilities can be very useful in the discovery of all the classes and methods available in this API.
Let’s test it out. Select the Start Debugging option from the Debug menu.
- Wait for the application to compile and run.
Make sure to select EnumerateReports as the function and press Enter, or alternatively click Go. A listing of report jobs should appear:
- Select the name of the report task as shown above and copy it to the clipboard (use CTRL + C).
The GUID for the task, or even the entire name may look different in your system. There may be even more reports in your system. Don’t panic! Simply select the first task name as indicated even if it has a different naming convention.
In the Function dropdown select the RunJob function. You should see an input box appear right next to the drop down.
Paste the task name into the new task field.
Get ready (but don’t switch yet) to quickly switch back to the File Server Resource Manager window that you opened at the beginning of this exercise.
- Click on the Go button, or alternatively press Enter.
Quickly switch back to FSRM and click on the Storage Reports Management node in the left pane.
You should see that the Status for the first report task appears as Queued. Within a few seconds after that the status should change to Running (you may need to refresh to see the status change)
Go back to the FSCI Distribution application.
You should see an output similar to the following
Close the application and go back to Visual Studio.
Part 2: Working with the Classification Manager
In this second part of the exercise you will see how the classification manager can help you create property definitions, assign property values to a file, and query the property values associated with a file.
- Back in Visual Studio, double click on the third item of the Task List, labeled as:
//TODO: 03_Create property definition var classMan; IFsrmPropertyDefinition property;
- Uncomment the following lines of code:
//var classMan; //IFsrmPropertyDefinition property; //property.Name = propertyName; //property.Type = _FsrmPropertyDefinitionType.FsrmPropertyDefinitionType_MultiChoiceList; //property.PossibleValues = possibleValues; //property.Commit();
- Replace the declaration of the classMan variable above to the following declaration/instantiation statement:
var classMan = new FsrmClassificationManager();
The instantiated classification manager can create the new property that we need to instantiate
- Replace the declaration of property with the following declaration/instantiation statement:
IFsrmPropertyDefinition property = classMan.CreatePropertyDefinition();
The lines following this declaration set the values for the property, and at the end, it commits the new property:
property.Name = propertyName; property.Type = _FsrmPropertyDefinitionType.FsrmPropertyDefinitionType_MultiChoiceList; property.PossibleValues = possibleValues; property.Commit();
- Take a few seconds to review the code for the entire CreateEnumProperty method, and the two methods following it: SetFileProperty and EnumFileProperties.
The CreateEnumProperty method creates a Multiple Choice List property based on the input string from the user.
Select the Start Debugging option from the Debug menu.
- Wait for the application to compile and run.
Make sure to select CreateEnumProperty as the function.
You should see an arguments field appear:
- Specify the following string in the arguments field:
Importance: High, Medium, Low
The arguments should follow the format:
[Property Name]: [Element 1], [Element 2], … , [Element N]
Click Go, or alternatively press Enter.
The output should be similar to the following:
Select the SetFileProperty option from the Function drop down.
The SetFileProperty also has an arguments field. The format for this argument is as follows:
[File Path], [Property Name]: [Property Value]
- Set the arguments field to the following value:
C:\Server 2008 R2 Labs\File System Classification Infrastructure\Exercise-6\FsciDistribution\bin\Debug\MySampleFile.txt, Importance: Medium
MySampleFile.txt is an empty file that has been added to the solution and is overwritten in the output directory of the project every time you debug it. You may substitute this with argument with a path to a file of your choice.
Click Go, or press Enter.
The output should be similar to the following:
Set the EnumFileProperties option from the Function drop down.
This will make the filePath field appear:
- Specify the same file path to:
C:\Server 2008 R2 Labs\File System Classification Infrastructure\Exercise-6\FsciDistribution\bin\Debug\MySampleFile.txt
Click Go, or press Enter.
The output should be similar to the following. You should see how the file was tagged with a Medium value for the Importance property:
Close the FSCI Distribution application.
Please wait for the Instructor to resume the lecture.
Done Early? Try the Extra Credit! Extend the FsrmLogic class with your own static method to clear the properties of a file. You may also implement another functionality. The GUI will pick up the methods for you to test them.