Ejemplo n.º 1
0
        private void mainTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (_isProcessing)
            {
                return;
            }
            _isProcessing = true;

            // Check database for new items to fetch
            try
            {
                //check for shutdown flag.
                if (ShutdownHasBeenSignalled())
                {
                    if (_adHocQueueController.GlobalListOfOutstandingAdHocRequests.Count == 0)
                    {
                        NLogger.Instance.Info("No pending adhoc requests...Deleting signal file and shutting down process");
                        File.Delete(ShutdownSignalFile());
                        Application.Exit();
                    }
                    else
                    {
                        NLogger.Instance.Info("{0} pending adhoc request(s)... cannot shutdown. Will retry as long as shutdown signal exists.");
                        return;
                    }
                }

                RaiseMessageEvent(string.Format("Checking at {0}", DateTime.Now.ToString("HH:mm:ss")));

                // All items from DB

                ProcessDataRequests(Db.GetTickerItemsToProcess("EXEC GetBloombergDataRequestItems"), false);

                if (DateTime.Now > _setStatusTime)
                {
                    ApplicationStatus.SetStatus(Application.ProductName, "OK", "", 1);
                    _setStatusTime = DateTime.Now.AddSeconds(59);
                }
                else
                {
                    RaiseMessageEvent(string.Format("Next Status set {0}", _setStatusTime.ToString("dd MMM yy HH:mm:ss")));
                }
            }
            catch (SqlException ex)
            {
                NLogger.Instance.Error("Sql server error: Exiting program. Error: {0}", ex.ToString());
                Application.Exit();
            }
            catch (Exception ex)
            {
                NLogger.Instance.Fatal(ex.ToString(), ex);
                RaiseMessageEvent(string.Format("Error: {0}", ex));
                Static.EmailException("BB Field Value Retriever Error", ex.ToString(), ex);
            }
            finally
            {
                _isProcessing = false;
            }
        }