private static void Main_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = (Exception)e.ExceptionObject;

            ModelQueue.LogToOracle(0, "Main", "unhandled exception", ex.Message);

            #if _PERFORMANCE_LOG_
            PerfLog.Enter("UNHANDLED EXCEPTION:" + ex.Message);
            #endif
        }
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        private static void Main()
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Main_UnhandledException);
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["debugmode"].ToString()))
                {
                    // Debug code: this allows the process to run as a non-service.
                    // It will kick off the service start point, but never kill it.
                    // Shut down the debugger to exit
                    #if _PERFORMANCE_LOG_
                    PerfLog.Enter("Program.InDebugBase");
                    #endif

                    ModelQueue.LogToOracle(0, "Main", "InDebugBase", "starting up");

                    var service = new Service1();
                    service.MainProcessor();
                    Thread.Sleep(Timeout.Infinite);
                }
                else
                {
                    #if _PERFORMANCE_LOG_
                    PerfLog.Enter("Program.InServiceBase");
                    #endif

                    //ModelQueue.LogToOracle(0, "Main", "InServiceBase", "starting up");

                    ServiceBase[] ServicesToRun;
                    ServicesToRun = new ServiceBase[]
                    {
                        new Service1()
                    };
                    ServiceBase.Run(ServicesToRun);
                }
            }
            catch (Exception e)
            {
                #if _PERFORMANCE_LOG_
                PerfLog.Enter("Program.Exception-" + e.Message);
                #endif

                ModelQueue.LogToOracle(0, "Main", "fatal exception", e.Message);

                Logger.Fatal("Unhandled Exception.", e);
                throw;
            }
            finally
            {
            }

            #if _PERFORMANCE_LOG_
            PerfLog.Exit();
            #endif
        }
Beispiel #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
            }
        }