Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit

Permalink
Updated to .NET Core 2.0, User/Password and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
John Doe com prot committed Sep 24, 2017
1 parent fde394f commit a0b42cb
Show file tree
Hide file tree
Showing 19 changed files with 380 additions and 55 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ It's the enough to run Robot Bum. But if you want to filter some traffic or if y
| -ModeSMixerURL | text |
| -TwitterAccessToken | text |
| -URLServerFolder | text |
| -User | text |
| -Password | text |
| | |
| -TwitterConsumerKey | text |
| -TwitterConsumerSecret | text |
Expand Down
13 changes: 8 additions & 5 deletions RobotBum.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RobotBumFoundationCore", "RobotBumFoundationCore\RobotBumFoundationCore.xproj", "{FD7AF56B-6280-4E71-AB1D-5CEA99E015B6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotBumFoundationCore", "RobotBumFoundationCore\RobotBumFoundationCore.csproj", "{FD7AF56B-6280-4E71-AB1D-5CEA99E015B6}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RobotBumLibCore", "RobotBumLibCore\RobotBumLibCore.xproj", "{B3FC9E54-E1E7-4A0C-AD5B-839938F45BAF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotBumLibCore", "RobotBumLibCore\RobotBumLibCore.csproj", "{B3FC9E54-E1E7-4A0C-AD5B-839938F45BAF}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RobotBumConsole", "RobotBumConsole\RobotBumConsole.xproj", "{FD48D59B-4D1E-441C-83BD-DECEA7C268CD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RobotBumConsole", "RobotBumConsole\RobotBumConsole.csproj", "{FD48D59B-4D1E-441C-83BD-DECEA7C268CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -38,4 +38,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2188533-CA15-46E0-B8B1-CF8DE588DA97}
EndGlobalSection
EndGlobal
36 changes: 23 additions & 13 deletions RobotBumConsole/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class Core
const string LongitudeYCommand = "-LongitudeY";
const string LatitudeYCommand = "-LatitudeY";

const string UserCommand = "-User";
const string PasswordCommand = "-Password";


const string TwitterConsumerKeyCommand = "-TwitterConsumerKey";
const string TwitterConsumerSecretCommand = "-TwitterConsumerSecret";
const string TwitterAccessTokenCommand = "-TwitterAccessToken";
Expand Down Expand Up @@ -92,18 +96,20 @@ public static void Start(bool isConsole, string[] cmds)
System.IO.Directory.CreateDirectory(strPath);

#if DEBUG
// Quick test line.
//cmds = new List<string>() { "-AirportICAO","SBBR",
// "-ModeSMixerURL","http://bsbradar.ddns.net:8081",
// "-URLServerFolder","server" ,
// "-ShowAllCruisesHeavyWeight","1" ,
// "-AvoidAllFlightsStartingWith","\"GLO,GOL,TAM\"",
// // "-ShowAllFlightStartingWith","\"EK,DAL\"",
// // "-AvoidAllModelsStartingWith","A32,B73",
// // "-ShowAllModelsStartingWith","\"EK,DAL\"",
// "-ShowHelicopters","1",
// // "-MessageLanguage","en-PIRATE",
// }.ToArray();
// Quick test line.
//cmds = new List<string>() { "-AirportICAO","SBBR",
// "-ModeSMixerURL","http://bsbradar.ddns.net:8081",
// "-URLServerFolder","server" ,
// "-ShowAllCruisesHeavyWeight","1" ,
// "-AvoidAllFlightsStartingWith","\"GLO,GOL,TAM\"",
// "-ShowAllFlightStartingWith","\"EK,DAL\"",
// "-AvoidAllModelsStartingWith","A32,B73",
// "-ShowAllModelsStartingWith","\"EK,DAL\"",
// "-ShowHelicopters","1",
// "-User","bsb",
// "-Password","aero",
// "-MessageLanguage","en-PIRATE",
//}.ToArray();
#endif
var commandsAnalyse = AnalyseCommands(cmds);

Expand Down Expand Up @@ -132,7 +138,7 @@ public static void Start(bool isConsole, string[] cmds)

var autoEvent = new AutoResetEvent(false);

var timer = new System.Threading.Timer(new TimerCallback(CheckStatus), null, new TimeSpan(0), new TimeSpan(0, 0, 10));
var timer = new System.Threading.Timer(new TimerCallback(CheckStatus), null, new TimeSpan(0), new TimeSpan(1, 0, 10));

if (isConsole)
{
Expand Down Expand Up @@ -260,6 +266,10 @@ private static Radar GetRadarAndSetCommands(string[] cmds)
radar.LongitudeY = GetCommandValueDouble(LongitudeYCommand, cmds);
radar.LatitudeY = GetCommandValueDouble(LatitudeYCommand, cmds);

radar.User = GetCommandValue(UserCommand, cmds);
radar.Password = GetCommandValue(PasswordCommand, cmds);


radar.TwitterConsumerKey = GetCommandValue(TwitterConsumerKeyCommand, cmds);
radar.TwitterConsumerSecret = GetCommandValue(TwitterConsumerSecretCommand, cmds);
radar.TwitterAccessToken = GetCommandValue(TwitterAccessTokenCommand, cmds);
Expand Down
30 changes: 30 additions & 0 deletions RobotBumConsole/RobotBumConsole.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.0.1</VersionPrefix>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>RobotBumConsole</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>RobotBumConsole</PackageId>
<RuntimeIdentifiers>win10-x64;ubuntu.16.04-x64</RuntimeIdentifiers>

<AssetTargetFallback>$(AssetTargetFallback);dnxcore50</AssetTargetFallback>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Version>1.1</Version>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\RobotBumFoundationCore\RobotBumFoundationCore.csproj" />
<ProjectReference Include="..\RobotBumLibCore\RobotBumLibCore.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions RobotBumConsole/RobotBumConsole.csproj.migration_in_place_backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>1.0.1</VersionPrefix>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>RobotBumConsole</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>RobotBumConsole</PackageId>
<RuntimeIdentifiers>win10-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\RobotBumFoundationCore\RobotBumFoundationCore.csproj" />
<ProjectReference Include="..\RobotBumLibCore\RobotBumLibCore.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.0" />
</ItemGroup>

</Project>
21 changes: 18 additions & 3 deletions RobotBumConsole/ServerWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,25 @@ private static void WriteFile(string currentPath, string fileName, string conten
currentPath += fileName;


if (File.Exists(currentPath))
File.Delete(currentPath);
if (!File.Exists(currentPath))
{
using (var stream = File.Create(currentPath))
{

}
}




using (var stream = File.Open(currentPath, FileMode.Open))
{
var streamWriter = new StreamWriter(stream, Encoding.UTF8, 602048);

streamWriter.Write(content);
}

File.AppendAllText(currentPath, content, Encoding.UTF8);
//File.AppendAllText(currentPath, content, Encoding.UTF8);

}

Expand Down
9 changes: 5 additions & 4 deletions RobotBumFoundationCore/AirportWeather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using System.Xml.Linq;

namespace RobotBumFoundationCore
namespace RobotBumConsole
{
/// <summary>
/// Type of Weather, if it's a rain, fog and so on.
Expand Down Expand Up @@ -311,7 +311,7 @@ private static AirportWeather GetWeatherMetar(string ICAO, string xmlMetarResult
}
if (listWeatherLines.ContainsKey("Temperature"))
{
airportWeather.Temperature = Convert.ToDouble(listWeatherLines["Temperature"]);
airportWeather.Temperature = Convert.ToDouble(listWeatherLines["Temperature"], System.Globalization.CultureInfo.InvariantCulture);
}

if (listWeatherLines.ContainsKey("FlightCategory"))
Expand Down Expand Up @@ -352,7 +352,8 @@ private static AirportWeather GetWeatherMetar(string ICAO, string xmlMetarResult

return airportWeather;

} catch (Exception e)
}
catch (Exception e)
{
throw e;
}
Expand All @@ -365,7 +366,7 @@ private static List<AirportWeather> GetWeatherTAF(string ICAO, string xmlTafResu

if (String.IsNullOrEmpty(ICAO))
throw new ArgumentException("You must to provide a valid ICAO code. For more information about what is ICAO code, see https://en.wikipedia.org/wiki/International_Civil_Aviation_Organization_airport_code.");

var airportWeatherStandart = new AirportWeather();
airportWeatherStandart.ICAO = ICAO;

Expand Down
21 changes: 21 additions & 0 deletions RobotBumFoundationCore/RobotBumFoundationCore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>RobotBumFoundationCore</AssemblyName>
<PackageId>RobotBumFoundationCore</PackageId>
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
<AssetTargetFallback>$(AssetTargetFallback);dnxcore50</AssetTargetFallback>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>RobotBumFoundationCore</AssemblyName>
<PackageId>RobotBumFoundationCore</PackageId>
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

</Project>
20 changes: 18 additions & 2 deletions RobotBumLibCore/AirplanesData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;

namespace RobotBumLibCore
{
Expand Down Expand Up @@ -33,15 +34,30 @@ static async private Task<List<AirplaneBasic>> DesarializeAirplanes(Radar radar)

string responseBodyAsText = String.Empty;
List<AirplaneBasic> listAirplanes = null;
HttpClient httpClient = new HttpClient();

var credentials = new NetworkCredential(radar.User, radar.Password);
var handler = new HttpClientHandler { Credentials = credentials };

HttpClient httpClient = new HttpClient(handler);
HttpResponseMessage response = null;


try
{
if (!String.IsNullOrEmpty(radar.EndpointUrl))
{
response = httpClient.PostAsync(radar.EndpointUrl, new StringContent("{\"req\":\"getStats\",\"data\":{\"statsType\":\"flights\",\"id\":38209319}}", Encoding.UTF8, "application/x-www-form-urlencoded")).Result;
try
{
response = httpClient.PostAsync(radar.EndpointUrl, new StringContent("{\"req\":\"getStats\",\"data\":{\"statsType\":\"flights\",\"id\":38209319}}", Encoding.UTF8, "application/x-www-form-urlencoded")).Result;
} catch(Exception e)
{
Console.WriteLine("Radar " + radar.Name + " is out.");
ErrorManager.ThrowError(e, "Radar " + radar.Name + " is out.", false);
}

responseBodyAsText = response.Content.ReadAsStringAsync().Result;

PluginsManager.LastConnectionDate = DateTime.Now;
}
else if (radar.RadarParent != null)
{
Expand Down
Loading

0 comments on commit a0b42cb

Please sign in to comment.