Page Content

  1. Introduction
  2. Requirements
    1. .NET API documentation
  3. Simple use cases
  4. Advanced use cases

Introduction

To give the users the ability to easily create a .NET Client that integrates with ROB-EX, we have implemented the .NET Assembly deployed in Robex.Scheduler.dll. Using this the user have the same possibilities available as they would if creating a custom REST Client, but made easily accessible with methods and objects.

In the following we have described some requirements for building custom .NET integration to ROB-EX, as well as some simple use cases.

.NET Client API Documentation

For more info on methods available in Robex.Scheduler.dll
Also see the PDF-document of the full .NET Client API Documentation .

Requirements

The requirements for implementing a .NET Client are listed below.

  1. The same requirements as the REST Server (See the REST Server requirements).
  2. The RestSharp.dll and Robex.Scheduler.dll should be referenced from the .NET application.
  3. A configuration file containing the connections (See Setting up a connection).
  4. Some basic .NET programming knowledge is required, this is beyond the scope of this manual.

Setting up a connection

First thing is to setup a connection to the REST server. Connections should be define in a configuration file (e.g. “Robex.Scheduler.dll.Config”) in the following way:

<configuration>
  <startup>
    <ConnectionInfo hostId="PC-REST" hostPort="9998" connectionId="localRest" username="restuser" password="restpass" />
  </startup>
</configuration>
Tag/Parameter Description
<ConnectionInfo> tag defines a connection.
hostId is the name of the computer hosting the rest server.
hostPort if not specified the default value is 9998.
connectionId is an id the user can choose for the connection. This id will be used when the connection is referenced from code.
The username and password should be the one defined when the REST Server was started (see REST Server – Starting the REST Server).

The location and name of the config file is not important, as the exact name and location is specified as an argument, when the SchedulerServiceREST(string connectionFilePath) object is created (see examples below).

From the SchedulerServiceREST we can get the ConnectionManager. From the connection manager we can get the connections by id or all of them.

Simple use cases

In the following one can find .NET examples of how to implement common use cases in the C# language.

Error handling

All SchedulerService methods that require some communication with ROB-EX return a Response object. Where T is the requested datatype:

Response<Operation> response = getOperationById(<connectionId>, <operationId>)

The Response object has a Data and a Error property.

The Data property contain the requested data if the method return data. Methods such as the delete methods does not return any data. For an example of how to use the Data object, see the Query a list of orders example below.

The Error property contain an instance of RbxError in cases where an error has happened on the server side.

Besides the Error property of the Response object, the call to the service methods themselves can throw exceptions. Below is an example of how to handle errors:

Response<ProductionOrder> response = null;
try {
  response = schedulerService.deleteProductionOrder(connectionId, orderId);
}
catch (Exception exp) {
  Console.WriteLine(exp.Message);
  return;
}

if (response.Error != null) {
  Console.WriteLine("Error trying to delete order with id="+orderId+". Message="+response.Error.Message);
}
else {
  Console.WriteLine("Deleted order with id="+orderId);
}

Query a list of orders with status released or higher

The following is an example of how to get a list of all orders where the order state is higher than “Forecasted” (15) and where order order quantity is less than 10000.

Also notice that the layoutItem used in the Filter.value, can be looked up here: Layout item list.

SchedulerService schedulerService = new SchedulerServiceREST("Robex.Scheduler.dll.Config");
List<string> connectionIds = schedulerService.getConnectionIds();
connectionId = connectionIds[0];

RetrievalOptions retrievalOptions = new RetrievalOptions();

List<Filter> filters = new List<Filter>();

//Filter1
Filter filter = new Filter();
filter.layoutItem = "order_state_level";
filter.operatorKey = OperatorKey.GREATER;
filter.value = 15;
filters.Add(filter);
//Filter2
filter = new Filter();
filter.layoutItem = "order_quantity";
filter.operatorKey = OperatorKey.LESS;
filter.value = 10000;
filters.Add(filter);

retrievalOptions.filters = filters;

Response<List<ProductionOrder>> response = schedulerService.getProductionOrders(connectionId, retrievalOptions);
if (response.Error == null) {
    List<ProductionOrder> orders = response.Data; // notice that the response type class uses generics
}

Query list of operations on a specific resource with planned start date after a specified date.

The following is an example of how to get a list of operations for a specified resource where the operation start time time is after a specified date and time.

SchedulerService schedulerService = new SchedulerServiceREST("Robex.Scheduler.dll.Config");
List<string> connectionIds = schedulerService.getConnectionIds();
connectionId = connectionIds[0];

RetrievalOptions retrievalOptions = new RetrievalOptions();
Filter filter = new Filter();
filter.layoutItem = "opr_start_time";
filter.operatorKey = OperatorKey.Greater;
filter.value = <Specified date as DateTime>;
retrievalOptions.filter = filter;
String resId = <Specified resource id>; 
Response<List<Operation>> response = schedulerService.getPlannedOperations(connectionId, resId, retrievalOptions);
if (response.Error == null) {
    List<Operation> operations = response.Data;
}

Query list of operations on specified order. Select one of the operations and report: actual start, last progress, status and progress in quantity

SchedulerService schedulerService = new SchedulerServiceREST("Robex.Scheduler.dll.Config");
List<string> connectionIds = schedulerService.getConnectionIds();
connectionId = connectionIds[0];
String orderId = <Specified order id>;

List<Operation> operations = schedulerService.getOperationsFromOrder(connectionId, orderId, null);
if (operations != null &amp;&amp; operations.Count > 0)
{
    Operation firstOperation = operations[0];
    firstOperation.actualStartCalendar = firstOperation.startCalendar.AddHours(12); //Move forward 12 hours
    firstOperation.progressCalendar = firstOperation.startCalendar.AddHours(24); //Progress time is new start calendar plus 12 hours
    firstOperation.progressQuantity = 0.5;
    firstOperation.state = 40; //Operation status started

    schedulerService.createOrUpdateOperation(connectionId, firstOperation);
}

Create an order based on existing ROB-EX master route

The following example demonstrates how to easily create a production order. It is only necessary to specify order id, quantity, state and then the name of an existing master route and alternate route.

OrderHeader header = new OrderHeader();

header.masterRouteName = <route name>;
header.masterRouteAltName = <alternative route name>

ProductionOrder order = new ProductionOrder();
order.id = "TestOrder";
order.quantity = 24;
order.name = "TestOrder";
order.state = 40;
header.order = order;

Response<String> response = schedulerService.createOrderFromMasterRoute(connectionId, header);

if (response.Error != null) {
 Console.WriteLine(response.Error.developerMessage);
}

// The id of the newly created order is returned
String orderId = response.Data;

Advanced use cases

The REST Server Services contains high level services aimed for reporting purposes. I.e. these services will return aggregated data serving the following type of reports

  • Capacity based data – i.e. available and used capacity per resource for a specified period
  • Inventory based data – i.e. current and projected inventory for a specified period

Important: these services are still in a preliminary state – and are for ROB-EX version 5.2 not intended for broad public use. Interfaces are subject to change without notice.

Get a analysis result

All analysis results are retrieved with a call to getAnalysisResult from the SchedulerService. This method takes AnalysisParameters object and returns a AnalysisResult.

Customization of the analysis result is done by changing the parameters of the AnalysisParameters object. The following example will yield a resource analysis result, for all resources on a daily basis starting from 2014-06-16 and ranging 3 days:

SchedulerService schedulerService = new SchedulerServiceREST("Robex.Scheduler.dll.Config");
List<string> connectionIds = schedulerService.getConnectionIds();
connectionId = connectionIds[0];

AnalysisParameters parameters = new AnalysisParameters();
Resolution resolution = new Resolution();
resolution.start = Convert.ToDateTime("2014-06-16");
resolution.count = 3;
resolution.resolutionStep = ResolutionStep.DAY;

List<AnalysisResultType> resultTypesToInclude = new List<AnalysisResultType>();
resultTypesToInclude.Add(AnalysisResultType.RESOURCE);
parameters.resultTypesToInclude = resultTypesToInclude;
parameters.resolution = resolution;
parameters.includeMasterData = true;

Response<AnalysisResult> response = schedulerService.getAnalysisResult(connectionId, parameters);
if (response.Error) {
  AnalysisResult result = response.Data;
}

From the AnalysisResult we can get the master data and analysis data. The master data is the static ROB-EX basemodel data. The analysis data is the collected/calculated data.

The structure of the analysis data can be seen in the data model figure below:

From the analysis data we can get the analysis periods. Say we have added RESOURCE to the resultTypeToInclude list of the analysis parameters, then from the analysis periods we could use the getResourceAnalysisData() to get the resource analysis data.

FAQ / Troubleshooting

For HTTP error code interpretation, see The REST Client FAQ / Troubleshooting

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment