locked
List of all Views C# for webserce? RRS feed

  • Question

  • Is their a object within c# sdk of Service Manager that allows you get back a list of views. I am asking for need this for a webservice I am talking about when I create a view say under inccidents I am then wanting to show that view on the web.

    Regards

    David

    Thursday, June 19, 2014 1:07 PM

All replies

  • Yep. You'll want to use the "Presentation" object of your management group connection.

    That object contains various methods for querying and retrieving all aspects of the Presentation node within management packs, including Views.

    Here's a little sample code that should get you started:

    //Connect to the management group
    String strMySCSMServer = "<my management server>";
    EnterpriseManagementGroup emg = new EnterpriseManagementGroup(strMySCSMServer);
    
    //Get all Views
    IList<ManagementPackView> lstAllViews = emg.Presentation.GetViews();
    
    //Get a view by Name
    ManagementPackViewCriteria mpvc = new ManagementPackViewCriteria("Name = 'ChangeManagement.Views.AllChangeRequests'");
    IList<ManagementPackView> lstViewByName = emg.Presentation.GetViews(mpvc);


    Thursday, June 19, 2014 1:37 PM
  • Hi how does the views get generated at runtime I need to dispaly the results of a view also we have an edit form up and running ok now but views is what make boss happy
    Thursday, June 19, 2014 2:01 PM
  • That's more complicated. The console has an entire framework dedicated to parsing and displaying views..furthermore, for the most part, that framework is built into the console..it's not an SDK thing.

    Views are broken down into a few major pieces.. "generally" (and I use that term loosely) there are:

    DataAdapters (which instruct the console on how it will be making queries)
    ItemsSource (which instruct the console on what it will be querying)
    Criteria (obvious)
    Columns (instructing the console on what data to display and how)
    ViewStrings (an abstraction feature that supports different languages and loosely coupled text)

    So, if you're building your own view framework, what I would probably do is focus on the ItemsSource, Criteria, and Columns to start.

    View configurations are nothing more than a block of XML..you can see it in the "Configuration" property on any ManagementPackView.

    Within this xml block are all the nodes (among others) that I described above. Using simple xml parsing, you could grab the item source (which will be a class or type projection), then grab the criteria and run that query against the SDK using the standard methods (emg.EntityObjects, etc).

    Next, to present the information retrieved by that query, parse the "Columns" and display the information from the data set. How you display the information is up to you..web page, wpf form, windows form, whatever. The important part is that you have the data to display.

    This is a very simple approach to creating your own view framework..there are far more complicated scenarios to consider..for example, permissions (via roles) and object access (via groups). Those kinds of scenarios are handled by the data adapters, if I'm not mistaken, and the console's view framework.

    edit: Another thing to note..views are designed for WPF..so the columns are defined with binding, they can handle converters, etc etc. If you're trying to mimic a view's functionality using html or something else, most of the WPF stuff won't even apply..and you'd have to come up with your own way of implementing converters that are used by a column (if there are any).

    Last edit (I think): You could try using the console's data adapter classes to retrieve the information..they might do some of the heavy lifting for you..but I've never personally tried using those classes..I'm not sure how much is involved in utilizing them.
    Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectProjectionAdapter
    Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectAdapter


    Thursday, June 19, 2014 3:23 PM