public LotByGroupDictionary GetLotByGroup()
 {
     if (channel == null)
     {
         throw new Exception("TradeSharpDictionaryProxy: связь не установлена");
     }
     try
     {
         return(channel.GetLotByGroup());
     }
     catch (Exception)
     {
         RenewFactory();
         try
         {
             return(channel == null ? null : channel.GetLotByGroup());
         }
         catch (Exception ex)
         {
             Logger.Error("GetLotByGroup()", ex);
             return(null);
         }
     }
 }
Esempio n. 2
0
        private void FillDictionaries(ITradeSharpDictionary dict)
        {
            // прочитать локальную копию настроек группа - лот
            dictionaryGroupLot = LotByGroupDictionary.LoadFromFile(lotDicPath);

            if (dict != null)
            {
                try
                {
                    long lotByGroupHashCode;
                    tickers = dict.GetTickers(out lotByGroupHashCode).ToDictionary(t => t.Title, t => t);
                    if (tickers.Count > 0)
                    {
                        // контракты прочитаны, проверить словарь группа - лот
                        if (lotByGroupHashCode == 0)
                        {
                            dictionaryGroupLot.Clear();
                        }
                        else
                        {
                            if (dictionaryGroupLot.calculatedHashCode != lotByGroupHashCode)
                            {
                                var newDictionaryGroupLot = dict.GetLotByGroup();
                                if (newDictionaryGroupLot != null)
                                {
                                    dictionaryGroupLot = newDictionaryGroupLot;
                                    dictionaryGroupLot.SaveInFile(lotDicPath);
                                }
                            }
                        }

                        ConnectionWasEstablished = true;
                        return;
                    }
                    else
                    {
                        Logger.ErrorFormat("DalSpot: тикеры не получены");
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("Ошибка в DalSpot ctor (доступ к БД)", ex);
                }
            }
            InitializeDefault();
        }
Esempio n. 3
0
        private void FillDictionaries(ITradeSharpDictionary dict)
        {
            // прочитать локальную копию настроек группа - лот
            dictionaryGroupLot = LotByGroupDictionary.LoadFromFile(lotDicPath);

            if (dict != null)
            try
            {
                long lotByGroupHashCode;
                tickers = dict.GetTickers(out lotByGroupHashCode).ToDictionary(t => t.Title, t => t);
                if (tickers.Count > 0)
                {
                    // контракты прочитаны, проверить словарь группа - лот
                    if (lotByGroupHashCode == 0)
                        dictionaryGroupLot.Clear();
                    else
                    {
                        if (dictionaryGroupLot.calculatedHashCode != lotByGroupHashCode)
                        {
                            var newDictionaryGroupLot = dict.GetLotByGroup();
                            if (newDictionaryGroupLot != null)
                            {
                                dictionaryGroupLot = newDictionaryGroupLot;
                                dictionaryGroupLot.SaveInFile(lotDicPath);
                            }
                        }
                    }

                    ConnectionWasEstablished = true;
                    return;
                }
                else
                {
                    Logger.ErrorFormat("DalSpot: тикеры не получены");
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Ошибка в DalSpot ctor (доступ к БД)", ex);
            }
            InitializeDefault();
        }