From 0ab1473d22bd17088215e369eb85a28c621b6a31 Mon Sep 17 00:00:00 2001 From: Duke Jones Date: Sat, 20 Jun 2015 17:37:01 +0200 Subject: [PATCH] 1.84_0.27_1 * changed EDDN sending routine to v2 schema * cleaned up a little bit the involved codes --- RegulatedNoise/EDDB_Data/EDMilkyway.cs | 28 +- RegulatedNoise/EDDN.cs | 206 --------------- RegulatedNoise/EDDN/EDDNCommunicator.cs | 239 ++++++++++++++++++ RegulatedNoise/EDDN/Schema_v2.cs | 96 +++++++ RegulatedNoise/EditOcrResults.Designer.cs | 2 +- .../RegulatedNoiseSettings.cs | 5 + RegulatedNoise/Form1.cs | 27 +- RegulatedNoise/RegulatedNoise.csproj | 3 +- ToDo.txt | 5 + 9 files changed, 373 insertions(+), 238 deletions(-) delete mode 100644 RegulatedNoise/EDDN.cs create mode 100644 RegulatedNoise/EDDN/EDDNCommunicator.cs create mode 100644 RegulatedNoise/EDDN/Schema_v2.cs diff --git a/RegulatedNoise/EDDB_Data/EDMilkyway.cs b/RegulatedNoise/EDDB_Data/EDMilkyway.cs index bdd7cda..3d70485 100644 --- a/RegulatedNoise/EDDB_Data/EDMilkyway.cs +++ b/RegulatedNoise/EDDB_Data/EDMilkyway.cs @@ -703,21 +703,21 @@ public void calculateNewPriceLimits(string FileName = "") //Debug.Print(""); //Debug.Print(""); //Debug.Print(CommodityBasedata.Name + " :"); - //Debug.Print("Demand Buy Min \t\t" + Commodity.BuyPrices_Demand.Min().ToString("F0")); - //Debug.Print("Demand Buy Average\t" + Commodity.BuyPrices_Demand.Average().ToString("F0") + " (" + Commodity.BuyPrices_Demand.Count() + " values)"); - //Debug.Print("Demand Buy Max\t\t" + Commodity.BuyPrices_Demand.Max().ToString("F0")); + //Debug.Print("Demand Buy Min \t\t" + Commodity_Class.BuyPrices_Demand.Min().ToString("F0")); + //Debug.Print("Demand Buy Average\t" + Commodity_Class.BuyPrices_Demand.Average().ToString("F0") + " (" + Commodity_Class.BuyPrices_Demand.Count() + " values)"); + //Debug.Print("Demand Buy Max\t\t" + Commodity_Class.BuyPrices_Demand.Max().ToString("F0")); //Debug.Print(""); - //Debug.Print("Demand Sell Min\t\t" + Commodity.SellPrices_Demand.Min().ToString("F0")); - //Debug.Print("Demand Sell Average\t" + Commodity.SellPrices_Demand.Average().ToString("F0") + " (" + Commodity.SellPrices_Demand.Count() + " values)"); - //Debug.Print("Demand Sell Max\t\t" + Commodity.SellPrices_Demand.Max().ToString("F0")); + //Debug.Print("Demand Sell Min\t\t" + Commodity_Class.SellPrices_Demand.Min().ToString("F0")); + //Debug.Print("Demand Sell Average\t" + Commodity_Class.SellPrices_Demand.Average().ToString("F0") + " (" + Commodity_Class.SellPrices_Demand.Count() + " values)"); + //Debug.Print("Demand Sell Max\t\t" + Commodity_Class.SellPrices_Demand.Max().ToString("F0")); //Debug.Print(""); - //Debug.Print("Supply Buy Min\t\t" + Commodity.BuyPrices_Supply.Min().ToString("F0")); - //Debug.Print("Supply Buy Average\t" + Commodity.BuyPrices_Supply.Average().ToString("F0") + " (" + Commodity.BuyPrices_Supply.Count() + " values)"); - //Debug.Print("Supply Buy Max\t\t" + Commodity.BuyPrices_Supply.Max().ToString("F0")); + //Debug.Print("Supply Buy Min\t\t" + Commodity_Class.BuyPrices_Supply.Min().ToString("F0")); + //Debug.Print("Supply Buy Average\t" + Commodity_Class.BuyPrices_Supply.Average().ToString("F0") + " (" + Commodity_Class.BuyPrices_Supply.Count() + " values)"); + //Debug.Print("Supply Buy Max\t\t" + Commodity_Class.BuyPrices_Supply.Max().ToString("F0")); //Debug.Print(""); - //Debug.Print("Supply Sell Min\t\t" + Commodity.SellPrices_Supply.Min().ToString("F0")); - //Debug.Print("Supply Sell Average\t" + Commodity.SellPrices_Supply.Average().ToString("F0") + " (" + Commodity.SellPrices_Supply.Count() + " values)"); - //Debug.Print("Supply Sell Max\t\t" + Commodity.SellPrices_Supply.Max().ToString("F0")); + //Debug.Print("Supply Sell Min\t\t" + Commodity_Class.SellPrices_Supply.Min().ToString("F0")); + //Debug.Print("Supply Sell Average\t" + Commodity_Class.SellPrices_Supply.Average().ToString("F0") + " (" + Commodity_Class.SellPrices_Supply.Count() + " values)"); + //Debug.Print("Supply Sell Max\t\t" + Commodity_Class.SellPrices_Supply.Max().ToString("F0")); } if (!String.IsNullOrEmpty(FileName)) @@ -937,7 +937,7 @@ internal void ChangeAddStation(string Systemname, EDStation m_currentStationdata System = ownSystems.Find(x => x.Name.Equals(Systemname, StringComparison.CurrentCultureIgnoreCase)); if(System == null) { - // own system is not existing, look for a EDDN system + // own system is not existing, look for a EDDNCommunicator system System = mergedSystems.Find(x => x.Name.Equals(Systemname, StringComparison.CurrentCultureIgnoreCase)); if(System == null) @@ -948,7 +948,7 @@ internal void ChangeAddStation(string Systemname, EDStation m_currentStationdata if (m_Systems[(int)enDataType.Data_Own].Count > 0) newSystemIndex = m_Systems[(int)enDataType.Data_Own].Max(X => X.Id) + 1; - // and add the EDDN system as a new system to the local list + // and add the EDDNCommunicator system as a new system to the local list System = new EDSystem(newSystemIndex, System); ownSystems.Add(System); diff --git a/RegulatedNoise/EDDN.cs b/RegulatedNoise/EDDN.cs deleted file mode 100644 index 42f8605..0000000 --- a/RegulatedNoise/EDDN.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Collections; -using System.IO; -using System.IO.Compression; -using System.Threading; -using ZeroMQ; -using RegulatedNoise.Enums_and_Utility_Classes; -using System.Globalization; -using System.Net; -using CodeProject.Dialog; -using System.Diagnostics; - - -namespace RegulatedNoise -{ - public class EDDN - { - - private Form1 _caller; - private Thread _Spool2EDDN; - private Queue _SendItems = new Queue(100,10); - private SingleThreadLogger _logger; - - public EDDN(Form1 caller) - { - - _caller = caller; - - _logger = new SingleThreadLogger(ThreadLoggerType.EddnSubscriber); - _logger.Log("Initialising...\n"); - - _Spool2EDDN = new Thread(new ThreadStart(EDDNSender)); - _Spool2EDDN.Name = "Spool2EDDN"; - _Spool2EDDN.Start(); - - _logger.Log("Initialising...\n"); - - } - - public void Subscribe() - { - - using (var ctx = ZmqContext.Create()) - { - using (var socket = ctx.CreateSocket(SocketType.SUB)) - { - socket.SubscribeAll(); - - socket.Connect("tcp://eddn-relay.elite-markets.net:9500"); - - _caller.SetListening(); - - while (true) - { - var byteArray = new byte[10240]; - - int i = socket.Receive(byteArray, TimeSpan.FromTicks(50)); - - var decompressedFileStream = new MemoryStream(); - if(i != -1) - using (decompressedFileStream) - { - Stream stream = new MemoryStream(byteArray); - - // Don't forget to ignore the first two bytes of the stream (!) - stream.ReadByte(); - stream.ReadByte(); - using (var decompressionStream = new DeflateStream(stream, CompressionMode.Decompress)) - { - decompressionStream.CopyTo(decompressedFileStream); - } - - decompressedFileStream.Position = 0; - var sr = new StreamReader(decompressedFileStream); - var myStr = sr.ReadToEnd(); - - _caller.OutputEddnRawData(myStr); - decompressedFileStream.Close(); - } - Thread.Sleep(10); - } - } - } -// ReSharper disable once FunctionNeverReturns - } - - - private void EDDNSender() - { - do - { - try - { - - Thread.Sleep(1000); - - while ((_SendItems.Count > 0) && (!_caller.IsDisposed)) - { - PostJsonToEddn((CsvRow)_SendItems.Dequeue()); - Debug.Print("Items in Queue : " + _SendItems.Count.ToString()); - } - } - catch (Exception ex) - { - _logger.Log("Error uploading Json", true); - _logger.Log(ex.ToString(), true); - _logger.Log(ex.Message, true); - _logger.Log(ex.StackTrace, true); - if (ex.InnerException != null) - _logger.Log(ex.InnerException.ToString(), true); - - cErr.showError(ex, "Error in EDDN-Sending-Thread"); - } - - } while (!_caller.IsDisposed); - - _SendItems.Clear(); - } - - public void sendToEdDDN(CsvRow CommodityData) - { - _SendItems.Enqueue(CommodityData); - } - - private void PostJsonToEddn(CsvRow rowToPost) - { - string json; - string UserID; - - System.Diagnostics.Debug.Print("eddn send : " + rowToPost.ToString()); - - if (Form1.RegulatedNoiseSettings.UseEddnTestSchema) - { - json = - @"{""$schemaRef"": ""http://schemas.elite-markets.net/eddn/commodity/1/test"",""header"": {""uploaderID"": ""$0$"",""softwareName"": ""RegulatedNoise__DJ"",""softwareVersion"": ""v" + - Form1.RegulatedNoiseSettings.Version.ToString(CultureInfo.InvariantCulture) + "_" + Form1.RegulatedNoiseSettings.VersionDJ.ToString(CultureInfo.InvariantCulture) + - @"""},""message"": {""buyPrice"": $2$,""timestamp"": ""$3$"",""stationStock"": $4$,""stationName"": ""$5$"",""systemName"": ""$6$"",""demand"": $7$,""sellPrice"": $8$,""itemName"": ""$9$""}}"; - } - else - { - json = - @"{""$schemaRef"": ""http://schemas.elite-markets.net/eddn/commodity/1"",""header"": {""uploaderID"": ""$0$"",""softwareName"": ""RegulatedNoise__DJ"",""softwareVersion"": ""v" + - Form1.RegulatedNoiseSettings.Version.ToString(CultureInfo.InvariantCulture) + "_" + Form1.RegulatedNoiseSettings.VersionDJ.ToString(CultureInfo.InvariantCulture) + - @"""},""message"": {""buyPrice"": $2$,""timestamp"": ""$3$"",""stationStock"": $4$,""stationName"": ""$5$"",""systemName"": ""$6$"",""demand"": $7$,""sellPrice"": $8$,""itemName"": ""$9$""}}"; - } - - string commodity = _caller.getCommodityBasename(rowToPost.CommodityName); - - // if it's a user added commodity send it anyhow to see that there's a unknown commodities - if(commodity.Equals(Program.COMMODITY_NOT_SET)) - commodity = rowToPost.CommodityName; - - if(!String.IsNullOrEmpty(commodity)) - { - if(Form1.RegulatedNoiseSettings.usePilotsName) - UserID = System.Net.WebUtility.HtmlEncode(Form1.RegulatedNoiseSettings.PilotsName); - else - UserID = System.Net.WebUtility.HtmlEncode(Form1.RegulatedNoiseSettings.UserName); - - string commodityJson = json.Replace("$0$", UserID) - .Replace("$2$", (rowToPost.BuyPrice.ToString(CultureInfo.InvariantCulture))) - .Replace("$3$", (rowToPost.SampleDate.ToString("s", CultureInfo.InvariantCulture) + rowToPost.SampleDate.ToString("zzz", CultureInfo.InvariantCulture))) - .Replace("$4$", (rowToPost.Supply.ToString(CultureInfo.InvariantCulture))) - .Replace("$5$", (rowToPost.StationID.Replace(" [" + rowToPost.SystemName + "]", ""))) - .Replace("$6$", (rowToPost.SystemName)) - .Replace("$7$", (rowToPost.Demand.ToString(CultureInfo.InvariantCulture))) - .Replace("$8$", (rowToPost.SellPrice.ToString(CultureInfo.InvariantCulture))) - .Replace("$9$", (commodity) - ); - - using (var client = new WebClient()) - { - try - { - client.UploadString("http://eddn-gateway.elite-markets.net:8080/upload/", "POST", commodityJson); - } - catch (WebException ex) - { - _logger.Log("Error uploading Json", true); - _logger.Log(ex.ToString(), true); - _logger.Log(ex.Message, true); - _logger.Log(ex.StackTrace, true); - if (ex.InnerException != null) - _logger.Log(ex.InnerException.ToString(), true); - - using (WebResponse response = ex.Response) - { - using (Stream data = response.GetResponseStream()) - { - if (data != null) - { - StreamReader sr = new StreamReader(data); - MsgBox.Show(sr.ReadToEnd(), "Error while uploading to EDDN"); - } - } - } - } - finally - { - client.Dispose(); - } - } - } - } - } -} diff --git a/RegulatedNoise/EDDN/EDDNCommunicator.cs b/RegulatedNoise/EDDN/EDDNCommunicator.cs new file mode 100644 index 0000000..6b142c6 --- /dev/null +++ b/RegulatedNoise/EDDN/EDDNCommunicator.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections; +using System.IO; +using System.IO.Compression; +using System.Threading; +using ZeroMQ; +using RegulatedNoise.Enums_and_Utility_Classes; +using System.Globalization; +using System.Net; +using CodeProject.Dialog; +using System.Diagnostics; +using Newtonsoft.Json; + + + +namespace RegulatedNoise.EDDN +{ + public class EDDNCommunicator + { + + private Form1 _caller; + private Thread _Spool2EDDN; + private Queue _SendItems = new Queue(100,10); + private SingleThreadLogger _logger; + private System.Timers.Timer _SendDelayTimer; + + public EDDNCommunicator(Form1 caller) + { + + _caller = caller; + _SendDelayTimer = new System.Timers.Timer(2000); + _SendDelayTimer.AutoReset = false; + _SendDelayTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.SendDelayTimer_Elapsed); + + _logger = new SingleThreadLogger(ThreadLoggerType.EddnSubscriber); + + } + + public void Subscribe() + { + + using (var ctx = ZmqContext.Create()) + { + using (var socket = ctx.CreateSocket(SocketType.SUB)) + { + socket.SubscribeAll(); + + socket.Connect("tcp://eddn-relay.elite-markets.net:9500"); + + _caller.SetListening(); + + while (true) + { + var byteArray = new byte[10240]; + + int i = socket.Receive(byteArray, TimeSpan.FromTicks(50)); + + var decompressedFileStream = new MemoryStream(); + if(i != -1) + using (decompressedFileStream) + { + Stream stream = new MemoryStream(byteArray); + + // Don't forget to ignore the first two bytes of the stream (!) + stream.ReadByte(); + stream.ReadByte(); + using (var decompressionStream = new DeflateStream(stream, CompressionMode.Decompress)) + { + decompressionStream.CopyTo(decompressedFileStream); + } + + decompressedFileStream.Position = 0; + var sr = new StreamReader(decompressedFileStream); + var myStr = sr.ReadToEnd(); + + _caller.OutputEddnRawData(myStr); + decompressedFileStream.Close(); + } + Thread.Sleep(10); + } + } + } +// ReSharper disable once FunctionNeverReturns + } + + /// + /// sending routine for registered data: + /// It's called by the delay-timer "_SendDelayTimer" + /// + private void EDDNSender() + { + try + { + String UserID; + Schema_v2 Data = new Schema_v2(); + String TimeStamp; + String commodity; + + TimeStamp = DateTime.Now.ToString("s", CultureInfo.InvariantCulture) + DateTime.Now.ToString("zzz", CultureInfo.InvariantCulture); + + // get the user id + if(Form1.RegulatedNoiseSettings.usePilotsName) + UserID = System.Net.WebUtility.HtmlEncode(Form1.RegulatedNoiseSettings.PilotsName); + else + UserID = System.Net.WebUtility.HtmlEncode(Form1.RegulatedNoiseSettings.UserName); + + // test or real ? + if (Form1.RegulatedNoiseSettings.UseEddnTestSchema) + Data.SchemaRef = "http://schemas.elite-markets.net/eddn/commodity/2/test"; + else + Data.SchemaRef = "http://schemas.elite-markets.net/eddn/commodity/2"; + + // fill the header + Data.Header = new Schema_v2.Header_Class() {SoftwareName = "RegulatedNoise__DJ", + SoftwareVersion = Form1.RegulatedNoiseSettings.getVersionString(), + GatewayTimestamp = TimeStamp, + UploaderID = UserID}; + + // prepare the message object + Data.Message = new Schema_v2.Message_Class() {SystemName = "", + StationName = "", + Timestamp = TimeStamp, + Commodities = new Schema_v2.Commodity_Class[_SendItems.Count]}; + + // collect the commodity data + for (int i = 0; i <= Data.Message.Commodities.GetUpperBound(0); i++) + { + CsvRow Row = (CsvRow)_SendItems.Dequeue(); + + commodity = _caller.getCommodityBasename(Row.CommodityName); + + // if it's a user added commodity send it anyhow to see that there's a unknown commodity + if(commodity.Equals(Program.COMMODITY_NOT_SET)) + commodity = Row.CommodityName; + + Data.Message.Commodities[i] = new Schema_v2.Commodity_Class() {Name = commodity, + BuyPrice = (Int32)Math.Floor(Row.BuyPrice), + SellPrice = (Int32)Math.Floor(Row.SellPrice), + Demand = (Int32)Math.Floor(Row.Demand), + DemandLevel = (Row.DemandLevel == "") ? null : Row.DemandLevel, + Supply = (Int32)Math.Floor(Row.Supply), + SupplyLevel = (Row.SupplyLevel == "") ? null : Row.SupplyLevel, + }; + + if(i==0){ + Data.Message.SystemName = Row.SystemName; + Data.Message.StationName = Row.StationName; + + } + + } + + using (var client = new WebClient()) + { + try + { + Debug.Print(JsonConvert.SerializeObject(Data, new JsonSerializerSettings() {NullValueHandling = NullValueHandling.Ignore})); + + client.UploadString("http://eddn-gateway.elite-markets.net:8080/upload/", "POST", JsonConvert.SerializeObject(Data, new JsonSerializerSettings() {NullValueHandling = NullValueHandling.Ignore})); + } + catch (WebException ex) + { + _logger.Log("Error uploading Json (v2)", true); + _logger.Log(ex.ToString(), true); + _logger.Log(ex.Message, true); + _logger.Log(ex.StackTrace, true); + if (ex.InnerException != null) + _logger.Log(ex.InnerException.ToString(), true); + + using (WebResponse response = ex.Response) + { + using (Stream data = response.GetResponseStream()) + { + if (data != null) + { + StreamReader sr = new StreamReader(data); + MsgBox.Show(sr.ReadToEnd(), "Error while uploading to EDDN (v2)"); + } + } + } + } + finally + { + client.Dispose(); + } + } + + } + catch (Exception ex) + { + _logger.Log("Error uploading Json (v2)", true); + _logger.Log(ex.ToString(), true); + _logger.Log(ex.Message, true); + _logger.Log(ex.StackTrace, true); + if (ex.InnerException != null) + _logger.Log(ex.InnerException.ToString(), true); + + cErr.showError(ex, "Error in EDDN-Sending-Thread (v2)"); + } + + } + + /// + /// register everything for sending with this function. + /// 2 seconds after the last registration all data will be sent automatically + /// + /// + public void sendToEdDDN(CsvRow CommodityData) + { + // register next data row + _SendItems.Enqueue(CommodityData); + + // reset the timer + _SendDelayTimer.Start(); + + } + + /// + /// timer routine for sending all registered data to EDDN + /// + /// + /// + public void SendDelayTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e) + { + try{ + + // it's time to start the EDDN transmission + _Spool2EDDN = new Thread(new ThreadStart(EDDNSender)); + _Spool2EDDN.Name = "Spool2EDDN"; + _Spool2EDDN.IsBackground = true; + + _Spool2EDDN.Start(); + + }catch (Exception ex){ + cErr.showError(ex, "Error while sending EDDN data"); + } + } + } +} diff --git a/RegulatedNoise/EDDN/Schema_v2.cs b/RegulatedNoise/EDDN/Schema_v2.cs new file mode 100644 index 0000000..4eec35d --- /dev/null +++ b/RegulatedNoise/EDDN/Schema_v2.cs @@ -0,0 +1,96 @@ +// Generated by Xamasoft JSON Class Generator +// http://www.xamasoft.com/json-class-generator + +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace RegulatedNoise.EDDN +{ + + /// + /// schema class, + /// based on the structure from + /// https://github.com/jamesremuscat/EDDN/blob/master/schemas/commodity-v2.0.json + /// + internal partial class Schema_v2 + { + internal class Header_Class + { + + [JsonProperty("softwareVersion")] + public string SoftwareVersion { get; set; } + + [JsonProperty("gatewayTimestamp")] + public string GatewayTimestamp { get; set; } + + [JsonProperty("softwareName")] + public string SoftwareName { get; set; } + + [JsonProperty("uploaderID")] + public string UploaderID { get; set; } + } + } + + internal partial class Schema_v2 + { + internal class Commodity_Class + { + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("buyPrice")] + public int BuyPrice { get; set; } + + [JsonProperty("supplyLevel")] + public string SupplyLevel { get; set; } + + [JsonProperty("supply")] + public int Supply { get; set; } + + [JsonProperty("demand")] + public int Demand { get; set; } + + [JsonProperty("sellPrice")] + public int SellPrice { get; set; } + + [JsonProperty("demandLevel")] + public string DemandLevel { get; set; } + } + } + + internal partial class Schema_v2 + { + internal class Message_Class + { + + [JsonProperty("commodities")] + public Commodity_Class[] Commodities { get; set; } + + [JsonProperty("timestamp")] + public string Timestamp { get; set; } + + [JsonProperty("systemName")] + public string SystemName { get; set; } + + [JsonProperty("stationName")] + public string StationName { get; set; } + } + } + + internal partial class Schema_v2 + { + + [JsonProperty("header")] + public Header_Class Header { get; set; } + + [JsonProperty("$schemaRef")] + public string SchemaRef { get; set; } + + [JsonProperty("message")] + public Message_Class Message { get; set; } + } + +} diff --git a/RegulatedNoise/EditOcrResults.Designer.cs b/RegulatedNoise/EditOcrResults.Designer.cs index c722e96..5c8401b 100644 --- a/RegulatedNoise/EditOcrResults.Designer.cs +++ b/RegulatedNoise/EditOcrResults.Designer.cs @@ -226,7 +226,7 @@ private void InitializeComponent() this.Stationname.ReadOnly = true; this.Stationname.Width = 150; // - // Commodity + // Commodity_Class // this.Commodity.HeaderText = "Commodity"; this.Commodity.Name = "Commodity"; diff --git a/RegulatedNoise/Enums and Utility Classes/RegulatedNoiseSettings.cs b/RegulatedNoise/Enums and Utility Classes/RegulatedNoiseSettings.cs index 4b40677..254993d 100644 --- a/RegulatedNoise/Enums and Utility Classes/RegulatedNoiseSettings.cs +++ b/RegulatedNoise/Enums and Utility Classes/RegulatedNoiseSettings.cs @@ -312,6 +312,11 @@ public void prepareVersion() lastVersion = Version; lastVersionDJ = VersionDJ; } + + public String getVersionString() + { + return Version.ToString(CultureInfo.InvariantCulture) + "_" + VersionDJ.ToString(CultureInfo.InvariantCulture); + } } public partial class Form1 diff --git a/RegulatedNoise/Form1.cs b/RegulatedNoise/Form1.cs index a398057..dcd1d7f 100644 --- a/RegulatedNoise/Form1.cs +++ b/RegulatedNoise/Form1.cs @@ -25,6 +25,7 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Text.RegularExpressions; using CodeProject.Dialog; + namespace RegulatedNoise { @@ -54,7 +55,7 @@ private enum enDoSpecial public static Form1 InstanceObject; - public EDDN Eddn; + public RegulatedNoise.EDDN.EDDNCommunicator EDDNComm; public Random random = new Random(); public Guid SessionGuid; public PropertyInfo[] LogEventProperties; @@ -200,7 +201,7 @@ public Form1() _Splash.InfoChange("create ocr calibrator..."); _Splash.InfoAdd("prepare EDDN interface..."); - Eddn = new EDDN(this); + EDDNComm = new RegulatedNoise.EDDN.EDDNCommunicator(this); _logger.Log(" - created EDDN object"); _Splash.InfoChange("prepare EDDN interface..."); @@ -453,7 +454,7 @@ private void ImportSystemLocations() _Splash.InfoAdd("create milkyway..."); _Milkyway = new EDMilkyway(); - // 1. load the EDDN data + // 1. load the EDDNCommunicator data { bool needPriceCalculation = !myMilkyway.loadCommodityData(@"./Data/commodities.json", @"./Data/commodities_RN.json", true, true); @@ -975,7 +976,7 @@ private void ApplySettings() } /// - /// selects, which ID to use for sending to EDDN + /// selects, which ID to use for sending to EDDNCommunicator /// private void selectEDDN_ID() { @@ -1506,7 +1507,7 @@ private void ImportCsvString(string line, bool suspendDuplicateChecking = false, CommodityDirectory[currentRow.CommodityName].Add(currentRow); if (postToEddn && cbPostOnImport.Checked && currentRow.SystemName != "SomeSystem") - Eddn.sendToEdDDN(currentRow); + EDDNComm.sendToEdDDN(currentRow); } } } @@ -3887,12 +3888,12 @@ private void button15_Click(object sender, EventArgs e) private void startEDDNListening() { - _eddnSubscriberThread = new Thread(() => Eddn.Subscribe()); + _eddnSubscriberThread = new Thread(() => EDDNComm.Subscribe()); _eddnSubscriberThread.IsBackground = true; _eddnSubscriberThread.Start(); } - #region EDDN Delegates + #region EDDNCommunicator Delegates private DateTime _lastGuiUpdate; private delegate void SetTextCallback(object text); @@ -3968,7 +3969,7 @@ public void OutputEddnRawData(object text) private void ParseEddnJson(object text, Dictionary headerDictionary, IDictionary messageDictionary, bool import) { string txt = text.ToString(); - // .. we're here because we've received some data from EDDN + // .. we're here because we've received some data from EDDNCommunicator if (txt != "") try @@ -4053,7 +4054,7 @@ private void ParseEddnJson(object text, Dictionary headerDiction if(!String.IsNullOrEmpty(commodity)) { - //System;Station;Commodity;Sell;Buy;Demand;;Supply;;Date; + //System;Station;Commodity_Class;Sell;Buy;Demand;;Supply;;Date; if (headerDictionary["uploaderID"] != tbUsername.Text) // Don't import our own uploads... { string csvFormatted = cachedSystem.Name + ";" + @@ -5053,13 +5054,7 @@ private void Form_Shown(object sender, System.EventArgs e) private void Form_Load(object sender, EventArgs e) { - Text += RegulatedNoiseSettings.Version.ToString(CultureInfo.InvariantCulture); - -#if DukeJones - RegulatedNoiseSettings.CheckVersion2(); - Text += "_" + RegulatedNoiseSettings.VersionDJ.ToString(CultureInfo.InvariantCulture); -#endif - + Text += RegulatedNoiseSettings.getVersionString(); if (((DateTime.Now.Day == 24 || DateTime.Now.Day == 25 || DateTime.Now.Day == 26) && DateTime.Now.Month == 12) || (DateTime.Now.Day == 31 && DateTime.Now.Month == 12) || diff --git a/RegulatedNoise/RegulatedNoise.csproj b/RegulatedNoise/RegulatedNoise.csproj index 94a8340..183cc24 100644 --- a/RegulatedNoise/RegulatedNoise.csproj +++ b/RegulatedNoise/RegulatedNoise.csproj @@ -128,6 +128,7 @@ + Component @@ -175,7 +176,7 @@ - + Form diff --git a/ToDo.txt b/ToDo.txt index ba70d7f..e212654 100644 --- a/ToDo.txt +++ b/ToDo.txt @@ -21,6 +21,11 @@ todo: * default setting for new systems + +1.84_0.27_1 + * changed EDDN sending routine to v2 schema + * cleaned up a little bit the involved codes +------------------------------------------------------------------------------------- 1.84_0.26_3 * added latest EDDB files -------------------------------------------------------------------------------------