Example #1
0
        private void PerformScheduledWork(object state)
        {
            // Perform your work here, but be mindful of the _shutdownEvent in case
            // the service is shutting down.
            //
            // Reschedule the work to be performed.

            //DataLayer.LogMessage(LogLevel.Info, "New run scheduled.");
            try
            {
                using (var context = new Db())
                {
                    var ctx        = new Db();
                    var instrument = ctx.Instruments.OrderBy(x => x.LastPriceUpdate).FirstOrDefault();
                    instrument.LastPriceUpdate = DateTime.Now;
                    ctx.SaveChanges();
                    Intrinio.UpdatePricesForTicker(instrument.Ticker);
                }
            }
            catch (Exception e)
            {
                DataLayer.LogException(e);
            }
            _scheduleTimer.Start();
        }
Example #2
0
 private void PerformIntrinio(object state)
 {
     //DataLayer.LogMessage(LogLevel.Service, "Intrinio Invoked");
     try
     {
         using (var context = new Db())
         {
             var ctx        = new Db();
             var instrument = ctx.Instruments.OrderBy(x => x.LastPriceUpdate).FirstOrDefault();
             instrument.LastPriceUpdate = DateTime.Now;
             ctx.SaveChanges();
             Intrinio.UpdatePricesForTicker(instrument.Ticker);
         }
     }
     catch (Exception e)
     {
         DataLayer.LogException(e);
     }
     finally
     {
         thIntrinio.timer.Start();
     }
 }