Skip to content

This repository is part of our JOpt-REST-Suite. It provides examples of how to set up a REST client in C# to access DNA Evolution's web services.

License

Notifications You must be signed in to change notification settings

DNA-Evolutions/C-Sharp-REST-Client-Examples

Repository files navigation

C#-REST-Client-Examples by DNA-Evolutions

DNA-Evolutions

Containerizing an application helps to use it more conveniently across different platforms and, most importantly, as a microservice. Further, scaling an application becomes more straightforward as various standardized orchestration tools can be utilized. A Microservice can be launched either (locally) or, for example, as a highly-scalable web-micro-service in a Kubernetes cluster.


Further Documentation, Contact and Links

If you need any help, don't hesitate to get in contact with us via our company website www.dna-evolutions.com or write an email to [email protected].


Short Introduction

This repository is part of our JOpt-REST-Suite. It provides examples of how to set up a REST client in C# to access the following DNA Evolution's web services:

  • JOpt-TourOptimizer based on JOpt-Core (available as a local Container and via Azure)

The service can be called via an API-Key using our Microsoft Azure-Kubernetes Infrastructure. If you are interested in hosting our JOpt-REST-GeoCoder and JOpt-REST-GeoRouter products in your environment, please get in contact with us.

All our RESTful Services utilize Spring WebFlux and Swagger. Internally the Java version of TourOptimizer is used. Indeed all specifications for the different services are derived from the core library, leading to guaranteed compatibility between all three services.

DNA-Evolutions Integration

JOpt-TourOptimizer

Optimize a problem consisting of Nodes, Resources, and optionally externally provided connections. In contrast to our other services, we allow you to host your JOpt-TourOptimizer locally. Please refer to "How to start JOpt TourOptimizer in docker" for more help.


Outline of this repository

Examples

  1. TourOptimizer Examples

Each of the sections has its README.


The architecture of the generated REST-Client-API

The C#-REST-Client class files used by the examples of this repository were generated utilizing the openapi-csharp-netcore Generator by OpenAPI Tools.

For creating the models, we used the containerized version of Open-API-Generator by calling:

docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate  -i '/local/swagger/touroptimizer/spec/touroptimizer_spec.json' -g csharp -o /local/generated/dna-netcore-models --library=httpclient

where ${PWD} needs to be adjusted to find the Open-API-docs under /local/swagger/touroptimizer/spec/touroptimizer_spec.json when mounting the volume ${PWD} into /local. Calling the command will generate the folders /Org.OpenApiTools and /Org.OpenApiTools.Test that are also part of this repository. You can find the touroptimizer_spec.json here.

You can also generate a client in the programming language of your choice utilizing our API-docs. REST facilitates software integration in your desired language (including famous ones like C#, Java, JS, Scala, Python, and many more ). Don't hesitate to reach out to us if you need help setting up your client.

For setting up a local test enviorment with database support, please refer to the separate Hands-on Tutorial: Setting Up a Local Fire and Forget TourOptimizer-Database Test Environment tutorial.


Getting started

You can start using our examples:

Prerequisites

  • Dotnet SKD 8.x (link)
  • Working Docker environment for local TourOptimizer instance

Clone this repository

Clone this repository and open it, for example, with Visual Code. The DNA.Evolutions.Csharp.Rest.sln file contains three util-projects that need to be built. In addition, it contains multiple example-projects that will be built.

Build necessary files

You can call (from the main folder):

	dotnet restore
	dotnet build

The call will generate the OpenApiTools.dll, Dna.Utils.dll and the example-executables (e.g. TourOptimizerExample.exe) and will download all dependencies. The target-framework is netstandard2.0 (for the libraries) and net8.0 (for the executables). You can also use Microsoft Visual Studio and perform the standard solution build process.

Run the examples

For example, go to src\Dna.Example\TourOptimizer\optimize\bin\Debug\net8.0\ and call the executable TourOptimizerExample.exe. By default, it expects a locally running TourOptimizer at http://localhost:8081.

Why use JOpt products from DNA Evolutions?

JOpt is a flexible routing optimization engine written in Java, allowing to solve tour-optimization problems that are highly restricted. For example, regarding time windows, skills, and even mandatory constraints can be applied.

Click to open our video:

Introduction Video for DNA's JOpt


Agreement

For reading our license agreement and for further information about license plans, please visit www.dna-evolutions.com.


Authors

A product by dna-evolutions ©