You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
3.0 KiB
C#

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
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
try
{
//var or = new OrderInfoService();
//or.ImportAmazon2(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1), new List<int>() { 48 });
////or.GetTemuOrderPostFee(1164590);
//return;
//var or = new OrderInfoService();
//List<int> ListModel = new List<int>() { 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);
}
}
}