Exemple #1
0
        public void Execute(IJobExecutionContext context)
        {
            _logger = LogManager.GetCurrentClassLogger();

            JobDataMap dataMap = context.JobDetail.JobDataMap;
            DividendUpdateJobSettings settings;

            try
            {
                settings = JsonConvert.DeserializeObject <DividendUpdateJobSettings>((string)dataMap["settings"]);
            }
            catch (Exception e)
            {
                _logger.Error(e, "Failed to deserialize data update job settings");
                return;
            }

            _logger.Info($"Dividend Update job {settings.Name} triggered.");

            _broker.Error += _broker_Error;

            int totalCount = 0;
            var requests   = GenerateRequests(settings);

            foreach (var req in requests)
            {
                var releases = _broker.RequestDividends(req).Result; //no async support in Quartz, and no need for it anyway, this runs on its own thread
                totalCount += releases.Count;
            }

            _logger.Trace($"Dividend update job downloaded {totalCount} items");

            JobComplete();
        }
Exemple #2
0
        public DividendsModule(IDividendsBroker broker)
            : base("/dividends")
        {
            this.RequiresAuthentication();

            Get("/", async(_, token) =>
            {
                var request = this.Bind <DividendRequest>();

                if (request == null)
                {
                    return(HttpStatusCode.BadRequest);
                }

                return(await broker.RequestDividends(request).ConfigureAwait(false));
            });

            Get("/datasources", _ => broker.DataSources.Keys.ToList());
        }