Esempio n. 1
0
        protected override void OnStart(string[] args)
        {
            #if _PERFORMANCE_LOG_
            PerfLog.Enter("Starting Service1");
            #endif

            try
            {
                ModelQueue.ResetQueueAll();
                #if _PERFORMANCE_LOG_
                PerfLog.Enter("Starting Service1");
                PerfLog.Enter("Resetting Queue");
                #endif
                //StartTimer();
                MainProcessor();
            }
            catch (Exception e)
            {
                Logger.Error("Unexpected Exception.", e);
                throw;
            }
            finally
            {
            }

            #if _PERFORMANCE_LOG_
            PerfLog.Exit();
            #endif
        }
Esempio n. 2
0
        protected override void OnStop()
        {
            #if _PERFORMANCE_LOG_
            PerfLog.Enter("Stopping Service1");
            PerfLog.Enter("Resetting Queue");
            #endif

            try
            {
                //EventLog.WriteEntry("Stopped the service");
                EventLog.WriteEntry("WINLIBSVC", "Stopped the service");
                //_timer.Stop();
                ModelQueue.ResetQueueAll();
            }
            catch (Exception e)
            {
                Logger.Error("Unexpected Exception.", e);
                throw;
            }
            finally
            {
            }

            #if _PERFORMANCE_LOG_
            PerfLog.Exit();
            #endif
        }
Esempio n. 3
0
        //private void TimerElapsed(object sender, ElapsedEventArgs e)
        //{
        //    try
        //    {
        //        MainProcessor();
        //    }
        //    catch (Exception ex)
        //    {
        //        #if _PERFORMANCE_LOG_
        //            PerfLog.Enter("FATAL_ERROR CAUGHT:" + ex.Message);
        //        #endif
        //    }
        //    finally
        //    {
        //    }

        //    #if _PERFORMANCE_LOG_
        //        PerfLog.Exit();
        //    #endif
        //}


        /// <summary>
        ///     Main Processing of the queue using library service
        /// </summary>
        //this method will complete before all the threads finish, freeing it up for the next timer_Elapsed
        public void MainProcessor()
        {
            try
            {
                List <NestPost> livePosts = ModelQueue.GetAllPosts();
                if (livePosts.Count > 0)
                {
                    foreach (NestPost post in livePosts)
                    {
                        //for testing only
                        if (post.POSTNAME == "ol2")
                        {
                            Task.Factory.StartNew(() => ModelQueue.ProcessFile(post.POSTNAME, post.SYNCPOST));
                        }

                        //Task.Factory.StartNew(() => ModelQueue.ProcessFile(post.POSTNAME, post.SYNCPOST));
                    }
                }

                ModelQueue.ResetQueueAll();
                ModelQueue.LogToOracle(0, "MainProcessor", "All Posts", "Queue reset");
            }
            catch (Exception e)
            {
                ModelQueue.LogToOracle(0, "MainProcessor", "Exception", e.Message);

                #if _PERFORMANCE_LOG_
                PerfLog.Enter("MainProcessor: " + e.Message);
                #endif
            }
            finally
            {
                ModelQueue.LogToOracle(0, "MainProcessor", "", "Main completing");

                #if _PERFORMANCE_LOG_
                PerfLog.Exit();
                #endif
            }
        }