public override int GetHashCode() { unchecked { int hashCode = (NominalCode != null ? NominalCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (NominalName != null ? NominalName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)LedgerEntryType; hashCode = (hashCode * 397) ^ Amount.GetHashCode(); return(hashCode); } }
// Обновляем котировки на листах с портфелями других брокеров private void ribbon_btnRefreshBrokersClicked() { // Портфели брокеров Dictionary <string, Dictionary <string, Orderbook> > Brokers = new Dictionary <string, Dictionary <string, Orderbook> >(); foreach (var broker in ThisAddIn.BrokersName) { if ((this.Application != null) && (this.Application.ActiveWorkbook != null)) { Excel.Worksheet BrokerSheet = null; int max_columns = 0; int max_rows = 0; int TickerNameColumn = 0; int LastDateNameColumn = 0; int PriceNameColumn = 0; int NominalNameColumn = 0; // Находим нужный лист BrokerSheet = MSExcel.GetExcelSheet(this.Application.ActiveWorkbook, broker, sh => { // Находим нужные колонки max_columns = sh.UsedRange.Columns.Count; for (int j = 1; j <= max_columns; j++) { string name = sh.Cells[1, j].Text; if (name.ToLower() == TickerName.ToLower()) { TickerNameColumn = j; } if (name.ToLower() == LastDateName.ToLower()) { LastDateNameColumn = j; } if (name.ToLower() == PriceName.ToLower()) { PriceNameColumn = j; } if (name.ToLower() == NominalName.ToLower()) { NominalNameColumn = j; } } } ); Dictionary <string, Orderbook> BrokerPapers = new Dictionary <string, Orderbook>(); if ((BrokerSheet != null) && (TickerNameColumn != 0)) { ribbon_btnRefreshValuteCursClicked(); BrokerSheet.Activate(); max_rows = BrokerSheet.UsedRange.Rows.Count; List <string> Tickers = new List <string>(); // заполняем список тикеров for (int _count = 2; _count <= max_rows; _count++) { string ticker = BrokerSheet.Cells[_count, TickerNameColumn].Text; if ((!Tickers.Contains(ticker)) && (!Currencies.IsValuteByTicker(ticker))) { Tickers.Add(ticker); } } // запрашиваем котировки this.Application.StatusBar = $"Запрашиваем котировки ценных бумаг для портфеля {broker}"; LoadBroker(broker, Tickers, BrokerPapers).GetAwaiter().GetResult(); Brokers.Add(broker, BrokerPapers); } // заполняем поля в excel this.Application.StatusBar = $"Заполняем котировки ценных бумаг для портфеля {broker} в excel"; if (BrokerSheet != null) { for (int _count = 2; _count <= max_rows; _count++) { string ticker = BrokerSheet.Cells[_count, TickerNameColumn].Text; if (BrokerPapers.ContainsKey(ticker)) { BrokerSheet.Cells[_count, LastDateNameColumn] = DateTime.Today; if (PriceNameColumn != 0) { BrokerSheet.Cells[_count, PriceNameColumn] = BrokerPapers[ticker].lastPrice; } if ((NominalNameColumn != 0) && (BrokerPapers[ticker].faceValue > 0)) { BrokerSheet.Cells[_count, NominalNameColumn] = BrokerPapers[ticker].faceValue; } } } } } } if (this.Application != null) { this.Application.StatusBar = false; } }