Skip to content

Commit ef1e85f

Browse files
authored
Merge pull request #1 from route4me/Editing
Editing
2 parents e55a234 + 3f1420c commit ef1e85f

File tree

76 files changed

+8048
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+8048
-362
lines changed

AspNetCoreExample/.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31424.327
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreExample", "AspNetCoreExample\AspNetCoreExample.csproj", "{9525CECE-A049-459B-8BDF-6F4419098BF7}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{9525CECE-A049-459B-8BDF-6F4419098BF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9525CECE-A049-459B-8BDF-6F4419098BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9525CECE-A049-459B-8BDF-6F4419098BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9525CECE-A049-459B-8BDF-6F4419098BF7}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {0D3ED22E-94D1-47BD-B68C-A6C481698852}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<UserSecretsId>404d548e-4694-4b4f-9d6d-88985afef9b6</UserSecretsId>
6+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<None Remove="lib\Route4MeSDKLibrary.dll" />
11+
<None Remove="lib\Route4MeSDKLibrary.pdb" />
12+
<None Remove="lib\SocketIoClientDotNet.core_2.2.dll" />
13+
<None Remove="lib\SocketIoClientDotNet.core_2.2.pdb" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<Content Include="lib\Route4MeSDKLibrary.dll">
18+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19+
</Content>
20+
<Content Include="lib\Route4MeSDKLibrary.pdb">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</Content>
23+
<Content Include="lib\SocketIoClientDotNet.core_2.2.dll">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</Content>
26+
<Content Include="lib\SocketIoClientDotNet.core_2.2.pdb">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</Content>
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.14" />
33+
</ItemGroup>
34+
35+
<ItemGroup>
36+
<Reference Include="Route4MeSDKLibrary">
37+
<HintPath>lib\Route4MeSDKLibrary.dll</HintPath>
38+
</Reference>
39+
<Reference Include="SocketIoClientDotNet.core_2.2">
40+
<HintPath>lib\SocketIoClientDotNet.core_2.2.dll</HintPath>
41+
</Reference>
42+
</ItemGroup>
43+
44+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
4+
WORKDIR /app
5+
EXPOSE 80
6+
EXPOSE 443
7+
8+
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
9+
WORKDIR /src
10+
COPY ["AspNetCoreExample/AspNetCoreExample.csproj", "AspNetCoreExample/"]
11+
RUN dotnet restore "AspNetCoreExample/AspNetCoreExample.csproj"
12+
COPY . .
13+
WORKDIR "/src/AspNetCoreExample"
14+
RUN dotnet build "AspNetCoreExample.csproj" -c Release -o /app/build
15+
16+
FROM build AS publish
17+
RUN dotnet publish "AspNetCoreExample.csproj" -c Release -o /app/publish
18+
19+
FROM base AS final
20+
WORKDIR /app
21+
COPY --from=publish /app/publish .
22+
ENTRYPOINT ["dotnet", "AspNetCoreExample.dll"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Hosting;
3+
4+
namespace AspNetCoreExample
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
CreateHostBuilder(args).Build().Run();
11+
}
12+
13+
public static IHostBuilder CreateHostBuilder(string[] args) =>
14+
Host.CreateDefaultBuilder(args)
15+
.ConfigureWebHostDefaults(webBuilder =>
16+
{
17+
webBuilder.UseStartup<Startup>();
18+
});
19+
}
20+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:59576",
7+
"sslPort": 44389
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"AspNetCoreExample": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development"
23+
},
24+
"applicationUrl": "https://localhost:5001;http://localhost:5000"
25+
},
26+
"Docker": {
27+
"commandName": "Docker",
28+
"launchBrowser": true,
29+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
30+
"publishAllPorts": true,
31+
"useSSL": true
32+
}
33+
}
34+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
using Route4MeSDK;
2+
using Route4MeSDK.DataTypes;
3+
using Route4MeSDK.QueryTypes;
4+
using System;
5+
using System.Collections.Generic;
6+
7+
namespace AspNetCoreExample
8+
{
9+
public class RunExamples
10+
{
11+
public string c_ApiKey { get; set; }
12+
13+
/// <summary>
14+
/// The example demonstrates the process of creating a new route with 10 destinations.
15+
/// </summary>
16+
public DataObject SingleDriverRoute10Stops(out string errorString)
17+
{
18+
Console.WriteLine("SingleDriverRoute10Stops");
19+
20+
// Create the manager with the api key
21+
Route4MeManager route4Me = new Route4MeManager(c_ApiKey);
22+
23+
// Prepare the addresses
24+
Address[] addresses = new Address[]
25+
{
26+
#region Addresses
27+
28+
new Address() { AddressString = "151 Arbor Way Milledgeville GA 31061",
29+
//indicate that this is a departure stop
30+
//single depot routes can only have one departure depot
31+
IsDepot = true,
32+
33+
//required coordinates for every departure and stop on the route
34+
Latitude = 33.132675170898,
35+
Longitude = -83.244743347168,
36+
37+
//the expected time on site, in seconds. this value is incorporated into the optimization engine
38+
//it also adjusts the estimated and dynamic eta's for a route
39+
Time = 0,
40+
41+
42+
//input as many custom fields as needed, custom data is passed through to mobile devices and to the manifest
43+
CustomFields = new Dictionary<string, string>() {{"color", "red"}, {"size", "huge"}}
44+
},
45+
46+
new Address() { AddressString = "230 Arbor Way Milledgeville GA 31061",
47+
Latitude = 33.129695892334,
48+
Longitude = -83.24577331543,
49+
Time = 0 },
50+
51+
new Address() { AddressString = "148 Bass Rd NE Milledgeville GA 31061",
52+
Latitude = 33.143497,
53+
Longitude = -83.224487,
54+
Time = 0 },
55+
56+
new Address() { AddressString = "117 Bill Johnson Rd NE Milledgeville GA 31061",
57+
Latitude = 33.141784667969,
58+
Longitude = -83.237518310547,
59+
Time = 0 },
60+
61+
new Address() { AddressString = "119 Bill Johnson Rd NE Milledgeville GA 31061",
62+
Latitude = 33.141086578369,
63+
Longitude = -83.238258361816,
64+
Time = 0 },
65+
66+
new Address() { AddressString = "131 Bill Johnson Rd NE Milledgeville GA 31061",
67+
Latitude = 33.142036437988,
68+
Longitude = -83.238845825195,
69+
Time = 0 },
70+
71+
new Address() { AddressString = "138 Bill Johnson Rd NE Milledgeville GA 31061",
72+
Latitude = 33.14307,
73+
Longitude = -83.239334,
74+
Time = 0 },
75+
76+
new Address() { AddressString = "139 Bill Johnson Rd NE Milledgeville GA 31061",
77+
Latitude = 33.142734527588,
78+
Longitude = -83.237442016602,
79+
Time = 0 },
80+
81+
new Address() { AddressString = "145 Bill Johnson Rd NE Milledgeville GA 31061",
82+
Latitude = 33.143871307373,
83+
Longitude = -83.237342834473,
84+
Time = 0 },
85+
86+
new Address() { AddressString = "221 Blake Cir Milledgeville GA 31061",
87+
Latitude = 33.081462860107,
88+
Longitude = -83.208511352539,
89+
Time = 0 }
90+
91+
#endregion
92+
};
93+
94+
// Set parameters
95+
RouteParameters parameters = new RouteParameters();
96+
97+
parameters.AlgorithmType = AlgorithmType.TSP;
98+
// parameters.StoreRoute = false;
99+
parameters.RouteName = "Single Driver Route 10 Stops";
100+
parameters.RouteDate = R4MeUtils.ConvertToUnixTimestamp(DateTime.UtcNow.Date.AddDays(1));
101+
parameters.RouteTime = 60 * 60 * 7;
102+
parameters.Optimize = Optimize.Distance.Description();
103+
parameters.DistanceUnit = DistanceUnit.MI.Description();
104+
parameters.DeviceType = DeviceType.Web.Description();
105+
106+
OptimizationParameters optimizationParameters = new OptimizationParameters()
107+
{
108+
Addresses = addresses,
109+
Parameters = parameters
110+
};
111+
112+
// Run the query
113+
DataObject dataObject = route4Me.RunOptimization(optimizationParameters, out errorString);
114+
115+
return dataObject;
116+
117+
}
118+
}
119+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.AspNetCore.Http;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.Hosting;
6+
using Route4MeSDK.DataTypes;
7+
using System;
8+
9+
namespace AspNetCoreExample
10+
{
11+
public class Startup
12+
{
13+
// This method gets called by the runtime. Use this method to add services to the container.
14+
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
15+
public void ConfigureServices(IServiceCollection services)
16+
{
17+
}
18+
19+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
20+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
21+
{
22+
if (env.IsDevelopment())
23+
{
24+
app.UseDeveloperExceptionPage();
25+
}
26+
27+
app.UseRouting();
28+
29+
app.UseEndpoints(endpoints =>
30+
{
31+
endpoints.MapGet("/", async context =>
32+
{
33+
RunExamples runExamples = new RunExamples();
34+
35+
// Please, change the demo API key with your own API key
36+
runExamples.c_ApiKey = "11111111111111111111111111111111";
37+
38+
var dataObject = runExamples.SingleDriverRoute10Stops(out string errorString);
39+
40+
string outputMessage = (dataObject != null && dataObject.GetType() == typeof(DataObject))
41+
? $"Created the optimization with ID={dataObject.OptimizationProblemId} and route name = {dataObject.Parameters.RouteName}"
42+
: $"Cannot create the optimization - change input data and try again{Environment.NewLine} {errorString}";
43+
44+
await context.Response.WriteAsync(outputMessage);
45+
});
46+
});
47+
}
48+
}
49+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)