diff --git a/Matchstick/src/GamesManager/GamesManager.Model/Entities/JsonEntity.cs b/Matchstick/src/GamesManager/GamesManager.Model/Entities/JsonEntity.cs index 2c77c539..b98f8450 100644 --- a/Matchstick/src/GamesManager/GamesManager.Model/Entities/JsonEntity.cs +++ b/Matchstick/src/GamesManager/GamesManager.Model/Entities/JsonEntity.cs @@ -119,9 +119,8 @@ public static string ReadOptionalValue(this JObject json, string name) public static string ReadRequiredValue(this JToken json, string name) { - string result = json[name].Value(); - if (string.IsNullOrEmpty(result)) throw new Exception("Required attribute '" + name + "' missing"); - return result; + if (json[name] == null) throw new Exception("Required attribute '" + name + "' missing"); + return json[name].Value(); } } } \ No newline at end of file diff --git a/Matchstick/src/GamesManager/GamesManager.Model/Entities/SettingsManager.cs b/Matchstick/src/GamesManager/GamesManager.Model/Entities/SettingsManager.cs index 4f380197..2d9bd37d 100644 --- a/Matchstick/src/GamesManager/GamesManager.Model/Entities/SettingsManager.cs +++ b/Matchstick/src/GamesManager/GamesManager.Model/Entities/SettingsManager.cs @@ -60,7 +60,7 @@ public static void Dispose() protected override void Load(JObject json) { - var game = json["game"].First; + var game = json["game"]; if (game!=null) { var gameSource = new GameSettings @@ -71,7 +71,7 @@ protected override void Load(JObject json) }; if (game["statisticsserviceenabled"]!=null) { - gameSource.StatisticsServiceEnabled = bool.Parse(game["statisticsserviceenabled"].Value()); + gameSource.StatisticsServiceEnabled = game["statisticsserviceenabled"].Value(); } Settings = gameSource; } @@ -93,7 +93,8 @@ public void Save() writer.WriteRequiredValue("uid", Settings.GameUid); if (Settings.StatisticsServiceEnabled.HasValue) { - writer.WriteRequiredValue("statisticsserviceenabled", Settings.StatisticsServiceEnabled.ToString()); + writer.WritePropertyName("statisticsserviceenabled"); + writer.WriteValue(Settings.StatisticsServiceEnabled.Value); } writer.WriteRequiredValue("username", Settings.UserName ?? string.Empty); writer.WriteRequiredValue("passwordhash",DPAPI.Encrypt(Settings.Password ?? string.Empty)); diff --git a/Matchstick/src/GamesManager/GamesManager.Model/StatisticsServiceClient.cs b/Matchstick/src/GamesManager/GamesManager.Model/StatisticsServiceClient.cs index 833e58ff..1f2369ce 100644 --- a/Matchstick/src/GamesManager/GamesManager.Model/StatisticsServiceClient.cs +++ b/Matchstick/src/GamesManager/GamesManager.Model/StatisticsServiceClient.cs @@ -89,7 +89,9 @@ public StatisticsSession(string gameUid,string serviceUrl,string filename) { do { - string line = reader.ReadLine(); + string line = reader.ReadLine().Trim(); + if (string.IsNullOrEmpty(line)) continue; + int index = line.IndexOf(' '); string[] prefix = line.Substring(0,index).Split(new[]{':'}); diff --git a/Matchstick/src/GamesManager/GamesManager.StatisticsService.Contracts/Messages/AddStatisticsResponse.cs b/Matchstick/src/GamesManager/GamesManager.StatisticsService.Contracts/Messages/AddStatisticsResponse.cs index 1900cc4e..94832ead 100644 --- a/Matchstick/src/GamesManager/GamesManager.StatisticsService.Contracts/Messages/AddStatisticsResponse.cs +++ b/Matchstick/src/GamesManager/GamesManager.StatisticsService.Contracts/Messages/AddStatisticsResponse.cs @@ -18,6 +18,6 @@ public List Errors } [DataMember] - public bool Success { get { return _errors.Count == 0; } } + public bool Success { get; set; } } } \ No newline at end of file diff --git a/Matchstick/src/GamesManager/GamesManager/MVP/Views/Impl/SendStatisticsView.cs b/Matchstick/src/GamesManager/GamesManager/MVP/Views/Impl/SendStatisticsView.cs index 0ebc217a..b83238d5 100644 --- a/Matchstick/src/GamesManager/GamesManager/MVP/Views/Impl/SendStatisticsView.cs +++ b/Matchstick/src/GamesManager/GamesManager/MVP/Views/Impl/SendStatisticsView.cs @@ -47,8 +47,8 @@ private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs { try { - Uri statisticsPrviacyPolicy = new Uri(_game.StatisticsPrivacyPolicy); - Process.Start(statisticsPrviacyPolicy.ToString()); + Uri statisticsPrivacyPolicy = new Uri(_game.StatisticsPrivacyPolicy); + Process.Start(statisticsPrivacyPolicy.ToString()); } catch (Exception) {