using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Mime; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using SinoChemFC2PosProxy.Communicator; using Wayne.Fusion.Framework.Core; using Wayne.Lib; using Wayne.Lib.Log; namespace SinoChemFC2PosProxy { public class EntryPoint { public static FdcCommunicator FdcComm; //private static DebugLogger debugLogger = new DebugLogger(new IdentifiableEntity(0, "FC2PosProxyMain", "", null)); static NLog.Logger debugLogger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("PumpHandler"); private const char CRYPT_FORMAT = '3'; // Fusion message crypt format private const char MESSAGE_VERSION = '2'; // Fusion message version private const int FUSION_MESSAGE_ROUTER_PORT = 3011; // Fusion message router server port; public static void Main(string[] args) { //SetupLogger(); //AppDomain.CurrentDomain.UnhandledException += (sender, arg) => debugLogger.Add(string.Format("Unhandled exception from AppDomain.UnhandledException event! {0}", arg.ExceptionObject), DebugLogLevel.Normal); //always start the config scanner first to force a syncing. var c = new SiteConfigScannerCommunicator(1000 * 60 * 5); var mustSucceed = c.Start(); if (!mustSucceed) { Console.WriteLine("Failed to init the site configuration, pls check log. Will quit..."); } else { var init = new InitSiteCommunicator(); init.Start(); //var msgRouterServerIPEndPoint = new IPEndPoint(IPAddress.Parse(System.Configuration.ConfigurationManager.AppSettings["MessageRouterServerIp"]), FUSION_MESSAGE_ROUTER_PORT); //var msgRouterClient = new MessageRouterClient(msgRouterServerIPEndPoint, CRYPT_FORMAT, MESSAGE_VERSION); //var msgRouterComm = new MessageRouterCommunicator(msgRouterClient); //msgRouterComm.Start(); FdcComm = new FdcCommunicator(new MessageRouterClient(msgRouterServerIPEndPoint, CRYPT_FORMAT, MESSAGE_VERSION)); FdcComm.Start(); var logPurge = new LogPurge(); logPurge.Start(); Console.WriteLine("SinoChemFC2PosProxy is on running..."); } //while (true) //{ // Console.ReadKey(); //} } //private static void SetupLogger() //{ // try // { // Logger.SetConfigFile(@"%ExeDir%\ProxyLogConfig.xml", @"%ExeDir%\ProxyEventLogConfig.xml"); // Logger.RefreshConfig(); // } // catch (LogException le) // { // Console.WriteLine("Exception when setting up logger\r\n" + le.Message); // } //} } }