Esempio n. 1
0
        public void Startup()
        {
            myEventLog.WriteEntry(string.Format("{0} is starting.", this.myServerKey));

            filingsFolderInfo = new DirectoryInfo(filingsFolder);
            processingFolderInfo = new DirectoryInfo(processingFolder);
            reportsFolderInfo = new DirectoryInfo(reportsFolder);

            ServiceUtilities.RegisterChannel(this.myPortNumber);
            ServiceUtilities.RegisterService(typeof(ReportBuilderRemotable), this.myEndPoint);

            string errorMsg;
            IFilingDispatcherRemotable dispatcher;
            if (TryGetDispatcherRemotable(out dispatcher, out errorMsg))
            {
                try
                {
                    string myUri = string.Format("tcp://{0}:{1}/{2}", System.Environment.MachineName, myPortNumber, myEndPoint);
                    dispatcher.RegisterProcessor(myUri, this.myServerKey);
                }
                catch (Exception ex)
                {
                    myEventLog.WriteEntry("Exception thrown while trying to connect to the Dispatcher: " + ex.Message, EventLogEntryType.Error);
                    throw ex;
                }
            }
            else
            {
                myEventLog.WriteEntry("Unable to connect to the Dispatcher: " + errorMsg, EventLogEntryType.Error);
                throw new Exception("Unable to connect to the Dispatcher: " + errorMsg);
            }

            myWokerPool = new WorkerThreadPool(maxBuilderThreads);

            myTimer = new System.Timers.Timer((double)(processingFrequency * 1000));
            myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
            myTimer.Start();
        }
        public void Startup(bool bStartTimer)
        {
            WriteLogEntry(string.Format("{0} is starting.", this.myServerKey), EventLogEntryType.Information);

            if (filingProcessor == null)
            {
                WriteLogEntry("Can not start FilingProcessorManager.\r\n\tFilingProcessorManager requires a non-null IFilingProcessor to peform the actualy processing.", EventLogEntryType.Error);
                throw new Exception("Can not start FilingProcessorManager with a null IFilingProcessor");
            }

            //Raj - Reuters processor services may not have filingsFolder,processingFolder & reportsFolder defined in config file.
            //      These values are set by dispatcher through AssignMarketToProcessor method call.
            //      The service should still register as remotable service and register with dispatcher.
            ServiceUtilities.RegisterChannel(this.myPortNumber);
            ServiceUtilities.RegisterService(typeof(FilingProcessorRemotable), this.myEndPoint);

            string errorMsg;
            IFilingDispatcherRemotable dispatcher;
            if (TryGetDispatcherRemotable(out dispatcher, out errorMsg))
            {
                try
                {
                    string myUri = string.Format("tcp://{0}:{1}/{2}", System.Environment.MachineName, myPortNumber, myEndPoint);
                    dispatcher.RegisterProcessor(myUri, this.myServerKey);
                }
                catch (Exception ex)
                {
                    WriteLogEntry("Exception thrown while trying to connect to the Dispatcher: " + ex.Message, EventLogEntryType.Error);
                    throw ex;
                }
            }
            else
            {
                WriteLogEntry("Unable to connect to the Dispatcher: " + errorMsg, EventLogEntryType.Error);
                throw new Exception("Unable to connect to the Dispatcher: " + errorMsg);
            }

            myWokerPool = new WorkerThreadPool(this.maxBuilderThreads);

            if (bStartTimer)
            {
                myTimer = new System.Timers.Timer((double)(processingFrequency * 1000));
                myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
                myTimer.Start();
            }
            else
            {
                /*
                 *
                 * bStartTimer is false for reuters services. We want the timer to start after market has been associated
                 * with this service through the web UI.
                 * On startup we want the service to figure out the market it was associated with.
                 * This is particularly useful when service is restarted after a market had been associated to the service.
                 *
                 * When the service is started for the first time it will not associated with any market.
                 *
                 * */
                LoadAssociatedMarketInfo();
            }
        }