using NetLibrary.Common.Configuration; using NetLibrary.Log; using System; using System.Collections.Generic; using System.Linq; using System.ServiceProcess; using System.Windows.Forms; using TradeManageNew; namespace TradeServer { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { try { //var or = new OrderInfoService(); //or.ImportAmazon2(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1), new List() { 48 }); ////or.GetTemuOrderPostFee(1164590); //return; //var or = new OrderInfoService(); //List ListModel = new List() { 96 }; //or.ImportTemuForTM(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1), ListModel); //return; string SetupPath = AppDomain.CurrentDomain.BaseDirectory + "Setup.ini"; string ServiceType = ConfigurationSourceSection.LoadXml_Attribute(SetupPath, "ServiceType"); if (ServiceType == "0") { Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.Run(new Form1()); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); } } catch (Exception ex) { ErrorFollow.TraceWrite(ex.TargetSite.Name, ex.StackTrace, ex.Message); System.Diagnostics.Process.GetCurrentProcess().Kill(); } } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception ex = e.ExceptionObject as Exception; DeleteTemp(ex.TargetSite.Name, ex.StackTrace, ex.Message); System.Diagnostics.Process.GetCurrentProcess().Kill(); } static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { DeleteTemp(e.Exception.TargetSite.Name, e.Exception.StackTrace, e.Exception.Message); System.Diagnostics.Process.GetCurrentProcess().Kill(); } static void DeleteTemp(string Name, string StackTrace, string errormsg) { ErrorFollow.TraceWrite("全局错误:" + Name, "", errormsg); } } }