Share via


Exercise 6: Configuring FSCI programmatically

Figure 1

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

Figure 2

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.

  1. Open the File Server Resource Manager from the Start menu:

    Control Panel > Administrative Tools > File Server Resource Manager
  2. Right click the Storage Reports Management node and select Schedule a New Report Task:

    Figure 3

  3. Under the Scope section, click the Add button:

    Figure 72

  4. Select the C:\ drive and click OK:

    Figure 4

  5. From the Report data section, make sure Quota Usage is the only one selected:

    Figure 5

  6. Click on the Schedule Tab and click Create Schedule
  7. Click on the New button and then click OK:

    Figure 6

  8. Click the OK button to close the Storage Reports dialog.
  9. 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:

    Figure 7

  10. When prompted with the UAC message, click Yes to launch Visual Studio with administrator privileges.
  11. Go to the File menu and select Open > Project/Solution

    Figure 8

  12. Browse for the following solution file and click Open.

    C:\Server 2008 R2 Labs\File System Classification Infrastructure\Exercise-6\FsciDistribution\FsciDistribution.sln

    Figure 9

  13. In the Solution Explorer, typically on the right side of the screen in Visual Studio, double click on the FsrmLogic.cs file.

    Figure 10

    Note:
     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.
  14. Go to the View menu and select the Task List option.

    Figure 11

  15. In the Task List window (typically at the bottom of the screen), make sure to select Comments as the type of item:

    Figure 12

  16. Double click on the first TODO item in the list, labeled as:

    C#

    //TODO: 01_Enumerate Jobs var reportMan; IFsrmCollection collection;
  17. 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();
    Note:
     As you type this line, Intellisense will show a list of other managers. Feel free to take a quick look.

    Figure 13

  18. The intention here is to have the collection variable contain all enumerated reports. Replace the declaration of collection with the following declaration/instantiation:

    C#

    IFsrmCollection collection = reportMan.EnumReportJobs(_FsrmEnumOptions.FsrmEnumOptions_None);
  19. In the Tasks List, select the second item labeled as:

    C#

    //TODO: 02_Get report job based on the task name IFsrmReportJob job;
  20. Replace the declaration of the job variable above, with the following declaration/instantiation statement:

    C#

    IFsrmReportJob job = reportMan.GetReportJob(task);
    Note:
     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.
  21. Let’s test it out. Select the Start Debugging option from the Debug menu.

    Figure 14

  22. Wait for the application to compile and run.
  23. Make sure to select EnumerateReports as the function and press Enter, or alternatively click Go. A listing of report jobs should appear:

    Figure 15

  24. Select the name of the report task as shown above and copy it to the clipboard (use CTRL + C).
    Note:
     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.
  25. In the Function dropdown select the RunJob function. You should see an input box appear right next to the drop down.

    Figure 16

  26. Paste the task name into the new task field.

    Figure 17

    Note:
     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.
  27. Click on the Go button, or alternatively press Enter.
  28. Quickly switch back to FSRM and click on the Storage Reports Management node in the left pane.

    Note:
     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)

    Figure 18

  29. Go back to the FSCI Distribution application.

    Note:
     You should see an output similar to the following

    Figure 19

  30. Close the application and go back to Visual Studio.

Part 2: Working with the Classification Manager

Figure 20

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.

  1. Back in Visual Studio, double click on the third item of the Task List, labeled as:

    C#

    //TODO: 03_Create property definition var classMan; IFsrmPropertyDefinition property;
  2. Uncomment the following lines of code:

    C#

    //var classMan; //IFsrmPropertyDefinition property; //property.Name = propertyName; //property.Type = _FsrmPropertyDefinitionType.FsrmPropertyDefinitionType_MultiChoiceList; //property.PossibleValues = possibleValues; //property.Commit();
  3. Replace the declaration of the classMan variable above to the following declaration/instantiation statement:

    var classMan = new FsrmClassificationManager();
    Note:
     The instantiated classification manager can create the new property that we need to instantiate
  4. Replace the declaration of property with the following declaration/instantiation statement:

    C#

    IFsrmPropertyDefinition property = classMan.CreatePropertyDefinition();
    Note:
     The lines following this declaration set the values for the property, and at the end, it commits the new property:

    C#

    property.Name = propertyName; property.Type = _FsrmPropertyDefinitionType.FsrmPropertyDefinitionType_MultiChoiceList; property.PossibleValues = possibleValues; property.Commit();
  5. Take a few seconds to review the code for the entire CreateEnumProperty method, and the two methods following it: SetFileProperty and EnumFileProperties.
    Note:
     The CreateEnumProperty method creates a Multiple Choice List property based on the input string from the user.
  6. Select the Start Debugging option from the Debug menu.

    Figure 21

  7. Wait for the application to compile and run.
  8. Make sure to select CreateEnumProperty as the function.

    Note:
     You should see an arguments field appear:

    Figure 22

  9. Specify the following string in the arguments field:

    Importance: High, Medium, Low
    Note:
     The arguments should follow the format:

    [Property Name]: [Element 1], [Element 2], … , [Element N]
  10. Click Go, or alternatively press Enter.

    Note:
     The output should be similar to the following:

    Figure 23

  11. Select the SetFileProperty option from the Function drop down.

    Note:
     The SetFileProperty also has an arguments field. The format for this argument is as follows:

    [File Path], [Property Name]: [Property Value]
  12. 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
    Note:
     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.
  13. Click Go, or press Enter.

    Note:
     The output should be similar to the following:

    Figure 24

  14. Set the EnumFileProperties option from the Function drop down.

    Note:
     This will make the filePath field appear:

    Figure 25

  15. Specify the same file path to:

    C:\Server 2008 R2 Labs\File System Classification Infrastructure\Exercise-6\FsciDistribution\bin\Debug\MySampleFile.txt
  16. Click Go, or press Enter.

    Note:
     The output should be similar to the following. You should see how the file was tagged with a Medium value for the Importance property:

    Figure 26

  17. Close the FSCI Distribution application.

    Note:
    Please wait for the Instructor to resume the lecture.

    Note:
    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.