Responder Developer Guide
Create Request Object

Resource Center Home

The following sample shows how to implement a request object by implementing IDataRequest. The code sample below depicts a request object that executes a SQL query on Data Services.

  1. It is highly recommended that you use an explicit implementation of IDataRequest.Execute. This Execute method is not intended to be called on the client. Explicit implementation hides the method from the client, yet makes it available to the server (Data Services).

    The DataSource argument refers to the database, and DataSession is the database connection. These arguments are used to query data within Responder.

  2. This block demonstrates how you can query the Responder (RX_*) tables in Data Services. This is only an example. You may create your own request.

  3. Returns the dataset requested from the server.

C# Snippet
Copy Code
[Serializable]
public class CustomRequest : IDataRequest
{
    private DataSet _ds;
//1
    void IDataRequest.Execute (DataSource source, DataSession session)
    {
//2
      DbSql query = new DbSql("select * from RX_INCIDENTS where CONFIRMED = 1");
      _ds = source.ExecuteDataSet(Session,query);
    }
//3
    public DataSet RequestedDataSet
    {
      get {return _ds;}
    }
}

 

RequestedDataSetMixin Class

This sample does the same thing as the sample above, but it derives from the RequestedDataSetMixin class in addition to implementing IDataRequest. This optional class provides a property to store the resulting dataset as well as more efficient serialization of datasets across the network when using .NET Framework 1.1. It may be used to implement IDataRequest. Nothing will ever look for this RequestedDataSetMixin object specifically.

  1. It is highly recommended that you use an explicit implementation of IDataRequest.Execute. This Execute method is not intended to be called on the client. Explicit implementation hides the method from the client, yet makes it available to the server (Data Services).

    The DataSource argument refers to the database, and DataSession is the database connection. These arguments are used to query data within Responder.

  2. This block demonstrates how you can query the Responder (RX_*) tables in Data Services. This is only an example. You may create your own request.

C# Snippet
Copy Code
[Serializable]
public class CustomRequest : RequestedDataSetMixin, IDataRequest
{
//1
    void IDataRequest.Execute (DataSource source, DataSession session)
    {
//2
      DbSql Query = new DbSql("select * from RX_INCIDENTS where CONFIRMED = 1");
      RequestedDataSet = source.ExecuteDataSet(Session,query);
    }
}

 

Execute Request Object

Request objects are executed on the server using IDataServices.ExecuteRequest. Before attempting to execute a request object, you must first get a reference to the IDataServices object that resides on the server. Once you have access to this object, you may execute the request object and retrieve the requested data.

This code snippet illustrates how to execute a request object.

  1. Gets a reference to the IDataServices object on the server.

  2. Here you may pass in any information necessary to gather the requested data from the server. This information is passed to the CustomRequest object.

  3. The CustomRequest object is passed to the server, executed and returned to the client.

  4. Accesses the information retrieved by the CustomRequest.

C# Snippet
Copy Code
//1
IDataServices dataservices = ResponderServices.GetDataServices;
//2
CustomRequest r = new CustomRequest();
//3
r = (CustomRequest) dataservices.ExecuteRequest(r);
//4
DataSet ds = r.RequestedDataSet;

 

Return to Overview

 

 


Send Comment to ArcFMdocumentation@schneider-electric.com