public void SaveFieldMapping(string fieldName, string mappingName)
        {
            var priceLevelRepository = new PriceLevelRepository(Settings.ConnectionString);

            priceLevelRepository.SaveFieldMapping(fieldName, mappingName);
            Logger.Instance.Debug($"Pricing Levels field mapping saved: (Field: {fieldName}, MappingField: {mappingName})");
        }
        public void SaveTableMapping(string dsnName, string tableName)
        {
            var priceLevelRepository = new PriceLevelRepository(Settings.ConnectionString);

            priceLevelRepository.SaveTableMapping(dsnName, tableName, "PriceLevels");
            Logger.Instance.Debug($"Pricing Levels table mapping saved: (DSN: {dsnName}, Table: {tableName})");
        }
        public bool Empty()
        {
            var priceLevelRepository = new PriceLevelRepository(Settings.ConnectionString);

            priceLevelRepository.ClearAll();
            return(true);
        }
示例#4
0
 public UnitOfWork(ArchimedesContext context)
 {
     _context   = context;
     Price      = new PriceRepository(_context);
     Candle     = new CandleRepository(_context);
     Trade      = new TradeRepository(_context);
     Market     = new MarketRepository(_context);
     PriceLevel = new PriceLevelRepository(_context);
     Strategy   = new StrategyRepository(_context);
 }
        public bool Publish(out List <string> publishDetails, BackgroundWorker bw = null)
        {
            publishDetails = new List <string>();
            string apiKey = Settings.GetApiKey();

            if (!string.IsNullOrEmpty(apiKey))
            {
                var priceLevelRepo  = new PriceLevelRepository(Settings.ConnectionString);
                var levelsToImport  = priceLevelRepo.GetAll().ToList();
                var existingLevels  = WebServiceHelper.GetExistingPricingLevels();
                var importCounter   = 0;
                var existingCounter = 0;

                foreach (var level in levelsToImport)
                {
                    if (existingLevels.Any(lvl => lvl.Name == level.Name))
                    {
                        existingCounter++;
                        continue;
                    }

                    var effectiveDate = level.EffectiveDate ?? DateTime.Now.ToUniversalTime();
                    if (level.EndDate < effectiveDate)
                    {
                        level.EndDate = null;
                    }
                    var request = new PricingLevelRequest
                    {
                        Name = level.Name,
                        ExternalReference = level.ExternalReference,
                        InventoryItems    = new List <PricingLevelItemRequest>(),
                        EffectiveDate     = effectiveDate,
                        EndDate           = level.EndDate
                    };

                    WebServiceHelper.PushPricingLevel(request);
                    importCounter++;
                }

                publishDetails.Insert(0,
                                      $"{existingCounter} price levels already existing in LinkGreen and were not pushed.");
                publishDetails.Insert(0, $"{importCounter} price levels have been pushed to LinkGreen");

                return(true);
            }

            Logger.Instance.Warning("No Api Key set while executing price level publish.");
            return(false);
        }
 public PriceLevelController()
 {
     this.repo = new PriceLevelRepository();
 }