/// <summary> /// 初始化方法 /// </summary> public void Init() { this.config = CastleServiceConfiguration.GetConfig(); this.server = new CastleService(config); this.server.OnLog += new LogEventHandler(server_OnLog); this.server.OnError += new ErrorLogEventHandler(server_OnError); //处理邮件地址 string address = ConfigurationManager.AppSettings["SendMailAddress"]; if (!string.IsNullOrEmpty(address)) { mailTo = address.Split(',', ';', '|'); } }
//private static readonly IMongo mongo = new Mongo("mongodb://192.168.1.223"); static void Main(string[] args) { System.Console.BackgroundColor = ConsoleColor.DarkBlue; System.Console.ForegroundColor = ConsoleColor.White; Program_OnLog("Service ready started...", LogType.Normal); var config = CastleServiceConfiguration.GetConfig(); var server = new CastleService(config); server.OnLog += new LogEventHandler(Program_OnLog); server.OnError += new ErrorLogEventHandler(Program_OnError); server.Start(); Program_OnLog(string.Format("Tcp server started. {0}", server.ServerUrl), LogType.Normal); Program_OnLog(string.Format("Service count -> {0} services.", server.ServiceCount), LogType.Normal); Program_OnLog(string.Format("Press any key to exit and stop service..."), LogType.Normal); System.Console.ReadLine(); }