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 }
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 }
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 }
public void GoBack(bool Reload = false) { if (ModelQueue.Count > 0) { //remove currentmodel from modelqueue ModelQueue.RemoveAt(ModelQueue.Count - 1); if (ModelQueue.Count > 0) { CurrentModel = ModelQueue[ModelQueue.Count - 1]; } else { GoToView(enumView.Logon); } } }
//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 } }
public void GoToView(enumView view) { switch (view) { // case enumView.ContactManagement: CurrentModel = ContactManagementModel; break; case enumView.LocationManagement: CurrentModel = LocationManagementModel; break; case enumView.DepartmentManagement: CurrentModel = DepartmentManagementModel; break; case enumView.PurchaseOrderDetail: CurrentModel = PurchaseOrderDetailModel; break; case enumView.PurchaseOrderManagement: CurrentModel = PurchaseOrderManagementModel; break; case enumView.SaleOrderDetail: CurrentModel = SaleOrderDetailModel; break; case enumView.SaleOrderManagement: CurrentModel = SaleOrderManagementModel; break; case enumView.ArticleManagement: CurrentModel = ArticleManagementModel; break; case enumView.IndustryManagement: CurrentModel = IndustryManagementModel; break; case enumView.BusinessManagement: CurrentModel = BusinessManagementModel; break; case enumView.CategoryManagement: CurrentModel = CategoryManagementModel; break; case enumView.CompanyManagement: CurrentModel = CompanyManagementModel; break; case enumView.Logon: CurrentModel = LogonModel; break; default: CurrentModel = LogonModel; break; } ModelQueue.Add(CurrentModel); }