Example #1
0
        public ImportJob(
            IImportJobRepository importJobRepository,
            InMemoryCache <TradeAccountModel> tradeAcccountModel,
            InMemoryCache <TradeMasterAccountModel> tradeMasterAccountModel,
            InMemoryCache <TradeInstrumentModel> tradeInstrumentModel,
            InMemoryCache <TradeFeeTypeModel> tradeFeeTypesModel,
            IContract wcf,
            FileNameMatcher fileNameMatcher,
            IExtractFileService extractFileService) : base(wcf)
        {
            _job = Job.Import;

            _tradeAccountModel       = tradeAcccountModel;
            _tradeInstrumentModel    = tradeInstrumentModel;
            _tradeFeeTypesModel      = tradeFeeTypesModel;
            _tradeMasterAccountModel = tradeMasterAccountModel;
            _importJobRepository     = importJobRepository;
            _extractFileService      = extractFileService;
            _fileNameMatcher         = fileNameMatcher;
            using (var tradeContext = _importJobRepository.BeginOperation())
            {
                foreach (var masterAccount in _importJobRepository.GetAllMasterAccounts())
                {
                    _tradeMasterAccountModel.Add(masterAccount.AccountName,
                                                 new TradeMasterAccountModel {
                        Id = masterAccount.Id
                    });
                }

                foreach (var instrument in _importJobRepository.GetTradeInstrument())
                {
                    _tradeInstrumentModel.Add(instrument.InstrumentName,
                                              new TradeInstrumentModel {
                        Id = instrument.Id
                    });
                }

                foreach (var trade in _importJobRepository.GetTradeAccount())
                {
                    _tradeAccountModel.Add(trade.AccountName, new TradeAccountModel {
                        Id = trade.Id
                    });
                }

                foreach (var tradeFeeType in _importJobRepository.GetTradeFeeType())
                {
                    _tradeFeeTypesModel.Add(tradeFeeType.TradeFeeTypeName,
                                            new TradeFeeTypeModel {
                        Id = tradeFeeType.Id
                    });
                }
            }
        }
Example #2
0
        public ImportJob(
            IImportJobRepository importJobRepository,
            InMemoryCache <TradeAccountModel> tradeAcccountModel,
            InMemoryCache <TradeInstrumentModel> tradeInstrumentModel,
            InMemoryCache <TradeFeeTypeModel> tradeFeeTypesModel,
            FileNameMatcher fileNameMatcher,
            IExtractFileService extractFileService)
        {
            var jobInterval = ConfigurationManager.AppSettings["job:ImportJobInterval"];

            if (string.IsNullOrEmpty(jobInterval))
            {
                throw new ConfigurationErrorsException("Please add 'job:ImportJobInterval' settigns to .config file.");
            }

            JobInterval = int.Parse(jobInterval);

            _tradeAccountModel    = tradeAcccountModel;
            _tradeInstrumentModel = tradeInstrumentModel;
            _tradeFeeTypesModel   = tradeFeeTypesModel;
            _importJobRepository  = importJobRepository;
            _extractFileService   = extractFileService;
            _fileNameMatcher      = fileNameMatcher;

            using (var tradeContext = _importJobRepository.BeginOperation())
            {
                foreach (var instrument in _importJobRepository.GetTradeInstrument())
                {
                    _tradeInstrumentModel.Add(instrument.InstrumentName,
                                              new TradeInstrumentModel {
                        Id = instrument.Id
                    });
                }

                foreach (var trade in _importJobRepository.GetTradeAccount())
                {
                    _tradeAccountModel.Add(trade.AccountName, new TradeAccountModel {
                        Id = trade.Id
                    });
                }

                foreach (var tradeFeeType in _importJobRepository.GetTradeFeeType())
                {
                    _tradeFeeTypesModel.Add(tradeFeeType.TradeFeeTypeName,
                                            new TradeFeeTypeModel {
                        Id = tradeFeeType.Id
                    });
                }
            }
        }