diff --git a/NHB3/ApiConnect.cs b/NHB3/ApiConnect.cs index 331120f..4831ea9 100644 --- a/NHB3/ApiConnect.cs +++ b/NHB3/ApiConnect.cs @@ -236,17 +236,6 @@ public ApiSettings readSettings() { return new ApiSettings(); } - public OrdersSettings readOrdersSettings() - { - String fileName = Path.Combine(Directory.GetCurrentDirectory(), "orders.json"); - if (File.Exists(fileName)) - { - OrdersSettings saved = JsonConvert.DeserializeObject(File.ReadAllText(@fileName)); - return saved; - } - return new OrdersSettings(); - } - public JObject getAlgo(string algo) { foreach (JObject obj in algorithms) { @@ -263,8 +252,8 @@ private string getApiUrl(int Enviorment) if (Enviorment == 1) { return "https://api2.nicehash.com"; - } - else if (Enviorment == 99) { + } else if (Enviorment == 99) + { return "https://api-test-dev.nicehash.com"; } return "https://api-test.nicehash.com"; @@ -280,18 +269,5 @@ public class ApiSettings public int Enviorment { get; set; } } - - public class OrdersSettings - { - public List OrderList { get; set; } - } - - public class OrderSettings - { - - public string Id { get; set; } - - public string MaxPrice { get; set; } - } } } diff --git a/NHB3/Home.cs b/NHB3/Home.cs index 3b5bcbb..859159f 100644 --- a/NHB3/Home.cs +++ b/NHB3/Home.cs @@ -31,7 +31,6 @@ public Home() ac = new ApiConnect(); ApiSettings saved = ac.readSettings(); - OrdersSettings orders = ac.readOrdersSettings(); if (saved.OrganizationID != null) { ac.setup(saved); @@ -102,9 +101,6 @@ private void refreshBalance() { private void refreshOrders(bool fromThread) { - //read custom order settings - ApiConnect.OrdersSettings cos = ac.readOrdersSettings(); - if (ac.connected) { orders = ac.getOrders(); @@ -131,9 +127,6 @@ private void refreshOrders(bool fromThread) cleanOrder.Add("limit", "" + order["limit"]); cleanOrder.Add("price", "" + order["price"]); - //max price - cleanOrder.Add("maxPrice", getMaxPrice("" + order["id"], cos)); - cleanOrder.Add("rigsCount", "" + order["rigsCount"]); cleanOrder.Add("acceptedCurrentSpeed", "" + order["acceptedCurrentSpeed"]); cleanOrders.Add(cleanOrder); @@ -157,17 +150,6 @@ private void refreshOrders(bool fromThread) } } - private string getMaxPrice(string id, ApiConnect.OrdersSettings cos) { - foreach (var order in cos.OrderList) - { - if (id.Equals(order.Id)) - { - return order.MaxPrice; - } - } - return ""; - } - private void refreshMarket() { if (ac.connected) { @@ -218,9 +200,6 @@ private void runBot() { toolStripStatusLabel1.Text = "Working"; - //read order individual settings - ApiConnect.OrdersSettings cos = ac.readOrdersSettings(); - BotSettings saved = JsonConvert.DeserializeObject(File.ReadAllText(@fileName)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("bot iteration tasks {0} {1} {2}", saved.reffilOrder, saved.lowerPrice, saved.increasePrice); @@ -261,13 +240,6 @@ private void runBot() { string order_type = "" + order["type"]["code"]; if (order_type.Equals("STANDARD")) { - //get order custom settings - String omp = getMaxPrice("" + order["id"], cos); - float maxOrderPriceLimit = 0F; - if (!String.IsNullOrEmpty(omp)) { - maxOrderPriceLimit = float.Parse("" + omp, CultureInfo.InvariantCulture); - } - JObject algo = ac.getAlgo("" + order["algorithm"]["algorithm"]); float order_speed = float.Parse("" + order["acceptedCurrentSpeed"], CultureInfo.InvariantCulture); float rigs_count = float.Parse("" + order["rigsCount"], CultureInfo.InvariantCulture); @@ -275,21 +247,13 @@ private void runBot() { float price_step_down = float.Parse("" + algo["priceDownStep"], CultureInfo.InvariantCulture); Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine("?adjust price?; order {0}, speed {1}, rigs {2}, price {3}, step_down {4}, max order limit {5}", order["id"], order_speed, rigs_count, order_price, price_step_down, maxOrderPriceLimit); + Console.WriteLine("?adjust price?; order {0}, speed {1}, rigs {2}, price {3}, step_down {4}", order["id"], order_speed, rigs_count, order_price, price_step_down); if (saved.increasePrice && (order_speed == 0 || rigs_count == 0)) { float new_price = (float)Math.Round(order_price + (price_step_down * -1), 4); - - if (maxOrderPriceLimit > 0 && new_price > maxOrderPriceLimit) { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("===> price up denied - max limit enforced {0} {1}", new_price, maxOrderPriceLimit); - } - else - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine("===> price up order to {0}", new_price); - ac.updateOrder("" + order["algorithm"]["algorithm"], "" + order["id"], new_price.ToString(new CultureInfo("en-US")), "" + order["limit"]); - } + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("===> price up order to {0}", new_price); + ac.updateOrder("" + order["algorithm"]["algorithm"], "" + order["id"], new_price.ToString(new CultureInfo("en-US")), "" + order["limit"]); } else if (saved.lowerPrice && (order_speed > 0 || rigs_count > 0)) { Dictionary market = getOrderPriceRangesForAlgoAndMarket("" + order["algorithm"]["algorithm"], "" + order["market"]); var list = market.Keys.ToList(); diff --git a/NHB3/OrderForm.Designer.cs b/NHB3/OrderForm.Designer.cs index a5adf45..a4e24ce 100644 --- a/NHB3/OrderForm.Designer.cs +++ b/NHB3/OrderForm.Designer.cs @@ -58,30 +58,23 @@ private void InitializeComponent() this.label16 = new System.Windows.Forms.Label(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.tbId = new System.Windows.Forms.TextBox(); - this.amountDetailsLbl2 = new System.Windows.Forms.Label(); this.tbAvailableAmount = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.limitDetailsLbl2 = new System.Windows.Forms.Label(); - this.priceDetailsLbl2 = new System.Windows.Forms.Label(); this.btnCancel = new System.Windows.Forms.Button(); this.btnUpdate = new System.Windows.Forms.Button(); - this.tabPage3 = new System.Windows.Forms.TabPage(); - this.btnSave = new System.Windows.Forms.Button(); - this.btnLoad = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.tbMaxPrice = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.lblCreate = new System.Windows.Forms.Label(); this.lblPool = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.lblErrorCreate = new System.Windows.Forms.Label(); + this.amountDetailsLbl2 = new System.Windows.Forms.Label(); + this.priceDetailsLbl2 = new System.Windows.Forms.Label(); + this.limitDetailsLbl2 = new System.Windows.Forms.Label(); + this.tbId = new System.Windows.Forms.TextBox(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); - this.tabPage3.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); @@ -351,9 +344,8 @@ private void InitializeComponent() // this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage2); - this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Enabled = false; - this.tabControl1.Location = new System.Drawing.Point(12, 385); + this.tabControl1.Location = new System.Drawing.Point(12, 392); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; this.tabControl1.Size = new System.Drawing.Size(610, 147); @@ -376,25 +368,6 @@ private void InitializeComponent() this.tabPage1.Text = "Refill order"; this.tabPage1.UseVisualStyleBackColor = true; // - // tbId - // - this.tbId.Location = new System.Drawing.Point(156, 75); - this.tbId.Name = "tbId"; - this.tbId.Size = new System.Drawing.Size(237, 26); - this.tbId.TabIndex = 32; - this.tbId.Visible = false; - // - // amountDetailsLbl2 - // - this.amountDetailsLbl2.AutoSize = true; - this.amountDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.amountDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.amountDetailsLbl2.Location = new System.Drawing.Point(399, 11); - this.amountDetailsLbl2.Name = "amountDetailsLbl2"; - this.amountDetailsLbl2.Size = new System.Drawing.Size(63, 17); - this.amountDetailsLbl2.TabIndex = 31; - this.amountDetailsLbl2.Text = "[amount]"; - // // tbAvailableAmount // this.tbAvailableAmount.Enabled = false; @@ -430,28 +403,6 @@ private void InitializeComponent() this.tabPage2.Text = "Edit order"; this.tabPage2.UseVisualStyleBackColor = true; // - // limitDetailsLbl2 - // - this.limitDetailsLbl2.AutoSize = true; - this.limitDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.limitDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.limitDetailsLbl2.Location = new System.Drawing.Point(399, 43); - this.limitDetailsLbl2.Name = "limitDetailsLbl2"; - this.limitDetailsLbl2.Size = new System.Drawing.Size(55, 17); - this.limitDetailsLbl2.TabIndex = 31; - this.limitDetailsLbl2.Text = "[speed]"; - // - // priceDetailsLbl2 - // - this.priceDetailsLbl2.AutoSize = true; - this.priceDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.priceDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.priceDetailsLbl2.Location = new System.Drawing.Point(399, 11); - this.priceDetailsLbl2.Name = "priceDetailsLbl2"; - this.priceDetailsLbl2.Size = new System.Drawing.Size(47, 17); - this.priceDetailsLbl2.TabIndex = 31; - this.priceDetailsLbl2.Text = "[price]"; - // // btnCancel // this.btnCancel.ForeColor = System.Drawing.Color.DarkRed; @@ -473,68 +424,6 @@ private void InitializeComponent() this.btnUpdate.UseVisualStyleBackColor = true; this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); // - // tabPage3 - // - this.tabPage3.Controls.Add(this.btnSave); - this.tabPage3.Controls.Add(this.btnLoad); - this.tabPage3.Controls.Add(this.label5); - this.tabPage3.Controls.Add(this.label7); - this.tabPage3.Controls.Add(this.tbMaxPrice); - this.tabPage3.Location = new System.Drawing.Point(4, 29); - this.tabPage3.Name = "tabPage3"; - this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(602, 114); - this.tabPage3.TabIndex = 2; - this.tabPage3.Text = "Bot settings"; - this.tabPage3.UseVisualStyleBackColor = true; - // - // btnSave - // - this.btnSave.Location = new System.Drawing.Point(454, 72); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(140, 32); - this.btnSave.TabIndex = 36; - this.btnSave.Text = "Save"; - this.btnSave.UseVisualStyleBackColor = true; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); - // - // btnLoad - // - this.btnLoad.Location = new System.Drawing.Point(10, 72); - this.btnLoad.Name = "btnLoad"; - this.btnLoad.Size = new System.Drawing.Size(140, 32); - this.btnLoad.TabIndex = 35; - this.btnLoad.Text = "Load"; - this.btnLoad.UseVisualStyleBackColor = true; - this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label5.ForeColor = System.Drawing.SystemColors.ControlDarkDark; - this.label5.Location = new System.Drawing.Point(399, 11); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(47, 17); - this.label5.TabIndex = 34; - this.label5.Text = "[price]"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(6, 9); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(76, 20); - this.label7.TabIndex = 32; - this.label7.Text = "Max price"; - // - // tbMaxPrice - // - this.tbMaxPrice.Location = new System.Drawing.Point(142, 6); - this.tbMaxPrice.Name = "tbMaxPrice"; - this.tbMaxPrice.Size = new System.Drawing.Size(251, 26); - this.tbMaxPrice.TabIndex = 33; - // // groupBox1 // this.groupBox1.Controls.Add(this.rbEU); @@ -590,6 +479,47 @@ private void InitializeComponent() this.lblErrorCreate.Text = "Error creating order"; this.lblErrorCreate.Visible = false; // + // amountDetailsLbl2 + // + this.amountDetailsLbl2.AutoSize = true; + this.amountDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.amountDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + this.amountDetailsLbl2.Location = new System.Drawing.Point(399, 11); + this.amountDetailsLbl2.Name = "amountDetailsLbl2"; + this.amountDetailsLbl2.Size = new System.Drawing.Size(63, 17); + this.amountDetailsLbl2.TabIndex = 31; + this.amountDetailsLbl2.Text = "[amount]"; + // + // priceDetailsLbl2 + // + this.priceDetailsLbl2.AutoSize = true; + this.priceDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.priceDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + this.priceDetailsLbl2.Location = new System.Drawing.Point(399, 11); + this.priceDetailsLbl2.Name = "priceDetailsLbl2"; + this.priceDetailsLbl2.Size = new System.Drawing.Size(47, 17); + this.priceDetailsLbl2.TabIndex = 31; + this.priceDetailsLbl2.Text = "[price]"; + // + // limitDetailsLbl2 + // + this.limitDetailsLbl2.AutoSize = true; + this.limitDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.limitDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; + this.limitDetailsLbl2.Location = new System.Drawing.Point(399, 43); + this.limitDetailsLbl2.Name = "limitDetailsLbl2"; + this.limitDetailsLbl2.Size = new System.Drawing.Size(55, 17); + this.limitDetailsLbl2.TabIndex = 31; + this.limitDetailsLbl2.Text = "[speed]"; + // + // tbId + // + this.tbId.Location = new System.Drawing.Point(156, 75); + this.tbId.Name = "tbId"; + this.tbId.Size = new System.Drawing.Size(237, 26); + this.tbId.TabIndex = 32; + this.tbId.Visible = false; + // // OrderForm // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -625,8 +555,6 @@ private void InitializeComponent() this.tabPage1.PerformLayout(); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); - this.tabPage3.ResumeLayout(false); - this.tabPage3.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); @@ -681,11 +609,5 @@ private void InitializeComponent() private System.Windows.Forms.Label limitDetailsLbl2; private System.Windows.Forms.Label priceDetailsLbl2; private System.Windows.Forms.TextBox tbId; - private System.Windows.Forms.TabPage tabPage3; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.TextBox tbMaxPrice; - private System.Windows.Forms.Button btnLoad; - private System.Windows.Forms.Button btnSave; } } \ No newline at end of file diff --git a/NHB3/OrderForm.cs b/NHB3/OrderForm.cs index 782eff9..3bb8d53 100644 --- a/NHB3/OrderForm.cs +++ b/NHB3/OrderForm.cs @@ -29,9 +29,9 @@ public OrderForm(ApiConnect ac) InitializeComponent(); this.Show(); this.ac = ac; - + this.currencyLbl.Text = ac.currency; - + //pools dropdown this.comboPools.DisplayMember = "name"; this.comboPools.ValueMember = "id"; @@ -61,8 +61,8 @@ private void comboAlgorithm_SelectedIndexChanged(object sender, EventArgs e) this.limitDetailsLbl.Text = "> " + this.algo["minSpeedLimit"] + " AND < " + this.algo["maxSpeedLimit"] + " OR 0 // no speed limit"; this.amountDetailsLbl.Text = "> " + this.algo["minimalOrderAmount"]; - this.tbLimit.Text = ""+this.algo["minSpeedLimit"]; - this.tbAmount.Text = ""+this.algo["minimalOrderAmount"]; + this.tbLimit.Text = "" + this.algo["minSpeedLimit"]; + this.tbAmount.Text = "" + this.algo["minimalOrderAmount"]; //filter pools this.comboPools.Items.Clear(); @@ -71,31 +71,36 @@ private void comboAlgorithm_SelectedIndexChanged(object sender, EventArgs e) foreach (JObject pool in ac.getPools(false)) { - if (this.comboAlgorithm.SelectedItem.Equals(pool["algorithm"])) { + if (this.comboAlgorithm.SelectedItem.Equals(pool["algorithm"])) + { this.comboPools.Items.Add(pool); } } - if (!edit) { + if (!edit) + { formDataUpdate(); } } private void formChanged(object sender, EventArgs e) { - if (!edit) { + if (!edit) + { formDataUpdate(); } } - private void formDataUpdate() { - this.tbPrice.Enabled = true; + private void formDataUpdate() + { + this.tbPrice.Enabled = true; this.btnCreate.Enabled = true; - this.lblPool.Visible = false; + this.lblPool.Visible = false; this.lblCreate.Visible = false; this.lblErrorCreate.Visible = false; - if (this.comboPools.SelectedItem == null) { + if (this.comboPools.SelectedItem == null) + { this.btnCreate.Enabled = false; this.lblPool.Visible = true; return; @@ -104,7 +109,8 @@ private void formDataUpdate() { string algo = "" + this.comboAlgorithm.SelectedItem; string limit = "" + this.tbLimit.Text; string market = "EU"; - if (this.rbUSA.Checked) { + if (this.rbUSA.Checked) + { market = "USA"; } @@ -129,7 +135,7 @@ private void formDataUpdate() { private void btnCreate_Click(object sender, EventArgs e) { - string algo = ""+this.comboAlgorithm.SelectedItem; + string algo = "" + this.comboAlgorithm.SelectedItem; string market = "EU"; if (this.rbUSA.Checked) { @@ -142,23 +148,24 @@ private void btnCreate_Click(object sender, EventArgs e) } JObject pool = (JObject)this.comboPools.SelectedItem; - string price = ""+this.tbPrice.Text; - string limit = ""+this.tbLimit.Text; - string amount = ""+this.tbAmount.Text; + string price = "" + this.tbPrice.Text; + string limit = "" + this.tbLimit.Text; + string amount = "" + this.tbAmount.Text; - JObject order = ac.createOrder(algo, market, type, ""+pool["id"], price, limit, amount); + JObject order = ac.createOrder(algo, market, type, "" + pool["id"], price, limit, amount); if (order["id"] != null) { this.lblErrorCreate.Visible = false; setEditMode(order); } - else + else { this.lblErrorCreate.Visible = true; } } - public void setEditMode(JObject order) { + public void setEditMode(JObject order) + { edit = true; this.Text = "Edit order " + order["id"]; @@ -179,40 +186,49 @@ public void setEditMode(JObject order) { this.tbLimit.Enabled = false; this.tbAmount.Enabled = false; - if (order["type"]["code"].Equals("FIXED")) { + if (order["type"]["code"].Equals("FIXED")) + { this.tbNewLimit.Enabled = false; this.tbNewPrice.Enabled = false; this.btnUpdate.Enabled = false; - } else { + } + else + { this.tbNewLimit.Enabled = true; this.tbNewPrice.Enabled = true; this.btnUpdate.Enabled = true; } //set values - this.tbId.Text = ""+order["id"]; + this.tbId.Text = "" + order["id"]; this.comboAlgorithm.SelectedItem = order["algorithm"]["algorithm"]; - if ((""+order["market"]).Equals("EU")) + if (("" + order["market"]).Equals("EU")) { this.rbEU.Checked = true; this.rbUSA.Checked = false; - } else { + } + else + { this.rbEU.Checked = false; this.rbUSA.Checked = true; } - if ((""+order["type"]["code"]).Equals("STANDARD")) + if (("" + order["type"]["code"]).Equals("STANDARD")) { this.rbStd.Checked = true; this.rbFixed.Checked = false; - } else { + } + else + { this.rbStd.Checked = false; this.rbFixed.Checked = true; } int idx = 0; - foreach (JObject pool in this.comboPools.Items) { - if (order["pool"]["id"].Equals(pool["id"])) { + foreach (JObject pool in this.comboPools.Items) + { + if (order["pool"]["id"].Equals(pool["id"])) + { break; } idx++; @@ -222,7 +238,7 @@ public void setEditMode(JObject order) { this.tbPrice.Text = "" + order["price"]; this.tbLimit.Text = "" + order["limit"]; this.tbAmount.Text = "" + order["amount"]; - + this.tbNewAmount.Text = "" + this.algo["minimalOrderAmount"]; this.tbAvailableAmount.Text = "" + order["availableAmount"]; this.tbNewPrice.Text = "" + order["price"]; @@ -271,49 +287,5 @@ private void btnCancel_Click(object sender, EventArgs e) this.Close(); } } - - private void btnLoad_Click(object sender, EventArgs e) - { - string id = "" + this.tbId.Text; - ApiConnect.OrdersSettings cos = ac.readOrdersSettings(); - - foreach (var order in cos.OrderList) { - if (id.Equals(order.Id)) { - this.tbMaxPrice.Text = ""+order.MaxPrice; - } - } - } - - private void btnSave_Click(object sender, EventArgs e) - { - string id = "" + this.tbId.Text; - - ApiConnect.OrdersSettings wos = ac.readOrdersSettings(); - wos.OrderList = new List(); - - ApiConnect.OrdersSettings cos = ac.readOrdersSettings(); - - bool added = false; - foreach (var order in cos.OrderList) - { - if (id.Equals(order.Id)) - { - order.MaxPrice = this.tbMaxPrice.Text; - added = true; - } - wos.OrderList.Add(order); - } - - if (!added) { - ApiConnect.OrderSettings osNew = new ApiConnect.OrderSettings(); - osNew.Id = id; - osNew.MaxPrice = this.tbMaxPrice.Text; - wos.OrderList.Add(osNew); - } - - String fileName = Path.Combine(Directory.GetCurrentDirectory(), "orders.json"); - File.WriteAllText(fileName, JsonConvert.SerializeObject(wos)); - this.Close(); - } } } \ No newline at end of file