EntryPoint.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Mime;
  6. using System.Runtime.InteropServices;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using SinoChemFC2PosProxy.Communicator;
  11. using Wayne.Fusion.Framework.Core;
  12. using Wayne.Lib;
  13. using Wayne.Lib.Log;
  14. namespace SinoChemFC2PosProxy
  15. {
  16. public class EntryPoint
  17. {
  18. public static FdcCommunicator FdcComm;
  19. //private static DebugLogger debugLogger = new DebugLogger(new IdentifiableEntity(0, "FC2PosProxyMain", "", null));
  20. static NLog.Logger debugLogger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("PumpHandler");
  21. private const char CRYPT_FORMAT = '3'; // Fusion message crypt format
  22. private const char MESSAGE_VERSION = '2'; // Fusion message version
  23. private const int FUSION_MESSAGE_ROUTER_PORT = 3011; // Fusion message router server port;
  24. public static void Main(string[] args)
  25. {
  26. //SetupLogger();
  27. //AppDomain.CurrentDomain.UnhandledException += (sender, arg) => debugLogger.Add(string.Format("Unhandled exception from AppDomain.UnhandledException event! {0}", arg.ExceptionObject), DebugLogLevel.Normal);
  28. //always start the config scanner first to force a syncing.
  29. var c = new SiteConfigScannerCommunicator(1000 * 60 * 5);
  30. var mustSucceed = c.Start();
  31. if (!mustSucceed)
  32. {
  33. Console.WriteLine("Failed to init the site configuration, pls check log. Will quit...");
  34. }
  35. else
  36. {
  37. var init = new InitSiteCommunicator();
  38. init.Start();
  39. //var msgRouterServerIPEndPoint = new IPEndPoint(IPAddress.Parse(System.Configuration.ConfigurationManager.AppSettings["MessageRouterServerIp"]), FUSION_MESSAGE_ROUTER_PORT);
  40. //var msgRouterClient = new MessageRouterClient(msgRouterServerIPEndPoint, CRYPT_FORMAT, MESSAGE_VERSION);
  41. //var msgRouterComm = new MessageRouterCommunicator(msgRouterClient);
  42. //msgRouterComm.Start();
  43. FdcComm = new FdcCommunicator(new MessageRouterClient(msgRouterServerIPEndPoint, CRYPT_FORMAT, MESSAGE_VERSION));
  44. FdcComm.Start();
  45. var logPurge = new LogPurge();
  46. logPurge.Start();
  47. Console.WriteLine("SinoChemFC2PosProxy is on running...");
  48. }
  49. //while (true)
  50. //{
  51. // Console.ReadKey();
  52. //}
  53. }
  54. //private static void SetupLogger()
  55. //{
  56. // try
  57. // {
  58. // Logger.SetConfigFile(@"%ExeDir%\ProxyLogConfig.xml", @"%ExeDir%\ProxyEventLogConfig.xml");
  59. // Logger.RefreshConfig();
  60. // }
  61. // catch (LogException le)
  62. // {
  63. // Console.WriteLine("Exception when setting up logger\r\n" + le.Message);
  64. // }
  65. //}
  66. }
  67. }