How-to consume Global DCC
Managed Consumers (C#)
To consume the global dcc from C#:
- Contact Armand Michaud in order to get some credentials
- Either
Using GlobalDcc.Api.Client
In your project, install the Nuget Package GlobalDcc.Api.Client, newest version.
The package will work for both .Net Core and .Net Framework applications.
It is necessary to initialize GlobalDcc.Api.Client. This is done by calling
GlobalDcc.Api.Client.Client.Initialize
with the base url for GlobalDcc (for
development this is https://gdcc-dev.amcsplatform.com/), a username and
password. Once Client
has been initialized request can be sent to GlobalDcc
through a GlobalDcc.Api.Client.Version0Client
.
If GlobalDcc.Api.Client is used in a Microsoft Extensions Dependency Injection
setup, Version0Client
can use a System.Net.Http.IHttpClientFactory
.
Version0Client
can also be constructed without an IHttpClientFactory
in
which case GlobalDcc.Api.Client will take care of creating and persisting an
HttpClient
and recreating it if a DNS change is suspected.
Example
// Initialize Global DCC client
GlobalDcc.Api.Client.Client.Initialize("https://gdcc-dev.amcsplatform.com/",
"MyUsername", "MyPassword");
// Create a Version0Client GlobalDcc.Api.Client.Version0Client client = new
GlobalDcc.Api.Client.Version0Client();
// Prepare a trace request GlobalDcc.Api.Client.TraceRequest traceRequest = new
GlobalDcc.Api.Client.TraceRequest() { Source = new
GlobalDcc.Api.Client.Coordinate() { Latitude = 55.704105M, Longitude =
12.552734M }, Destination = new GlobalDcc.Api.Client.Coordinate() { Latitude =
55.701723M, Longitude = 12.584791M } };
// Call the trace method of Global DCC GlobalDcc.Api.Client.TraceReply
traceReply = client.Trace("DK", traceRequest);
Console.WriteLine($"This trace has {traceReply.Answer.Trace.Count}
coordinates.");
In case of problems
Contact Armand Michaud
Versions
Currently (2023-09-14) the client is build as netstandard2.0, so it can be consumed from both net core and net framework applications
Using an OpenAPI Reference
This will only work for .Net Core applications.
- In visual studio right click on the project and select "Add" -> "Service Reference...".
- Select OpenApi in the dialog box.
- Select URL and point to the live gdcc yaml file: https://eu-gdcc-prd.amcsplatform.com/swagger/v1/swagger.yaml
- Fill out the class name and select "Finish".
Example
static HttpClient DccHttpClient { get; } = CreateHttpClient("my username", "my password");
private static HttpClient CreateHttpClient(string username, string password)
{
HttpClient client = new HttpClient { BaseAddress = new Uri("https://gdcc-dev.amcsplatform.com") };
//Authenticate
string auth = $"{username}:{password}";
string encodedAuth = Convert.ToBase64String(Encoding.ASCII.GetBytes(auth));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", encodedAuth);
return client;
}
static async Task<List<RoadNetInfo>> Main(string[] args)
{
GdccClient client = new GdccClient(DccHttpClient);
ICollection<RoadNetInfo> roadNets = await client.RoadNetsAsync();
return roadNets.ToList();
}
Native Consumers (C++)
For c++ programs you can use the DccFacade package. It is not recommended to add the DccFacade to new projects, but if you need to, you can refer to the dcc repository for information on how to configure it.
This page will only show how to configure it for the existing projects, Fleet Planner and Route Planner
Fleet Planner
- Contact Armand Michaud in order to get some credentials
- Set the dcc host in QueueNamesettings.xml to:
gdccs://gdcc-dev.amcsplatform.com#username#password
- Username and password should be the urlencoded version of the credentials you got from Armand
- Set the roadnet id (eg "dk") in the process specific registry setting
HKLM\SOFTWARE\Transvision\Fleet Planner\{process}\DCC\DCCMultiServerServiceName
Route Planner
- Contact Armand Michaud in order to get some credentials
- Go to the "File" tab
- Select "Parameters"
- Go to the "DCC" tab
- Set the "DCCMulti server host name to":
gdccs://gdcc-dev.amcsplatform.com#username#password
- Username and password should be the urlencoded version of the credentials you got from Armand
- Set the "DCCMulti server service name" to the roadnet id (eg "dk")