protected override void OnStart(string[] args) { // TODO: Add code here to start your service. bool _oracleReady = SqlHelper.IsReady(); int _count = 0; while (!_oracleReady && (_count < 15)) { Thread.Sleep(new System.TimeSpan(0, 1, 0)); _oracleReady = SqlHelper.IsReady(); if (!_oracleReady) { WriteMessage(string.Format("第{0}次测试ORACLE连接失败!", _count)); } _count++; } ServerCommon.Init(this as IServerApplication, false); serverPluginService.LoadAllPlugin(); serverPluginService.LoadAllWCFService(this.WcfHostLib); WriteMessage(string.Format("{0}启动成功!", ConfigFile.SystemDisplayName)); }
public static void Init(IServerApplication app, bool isWinSvc) { // 发出开始启动服务提示音 ServerCommon.SvcBeep(SvcAction.Starting); application = app; IsWinSvc = isWinSvc; WriteTaskInfo = ConfigFile.WriteTaskStartInfo; //加载ZHTJ_CSB中的参数 #region 查看ORACLE服务是否已经成功运行 int TestTimes = 10; int SleepTime = 60000; #if DEBUG SleepTime = 100; #endif while (!OracleHelper.IsReady() && TestTimes-- > 0) { Thread.Sleep(SleepTime); } if (TestTimes < 1) { EventLogSystemLog _event = new EventLogSystemLog("SinoSZJSLog"); string _log = "因数据库无法连接,启动服务失败!"; _event.WriteLog(_log, EventLogEntryType.Error); throw new Exception(); } #endregion ConfigFile.Client_ShowPendingAlert = LoadDB_CSB_Bool("Client_ShowPendingAlert"); //建立系统日志和用户日志的写入器 SystemLogWriter.ICS_SystemLog = new OraSysLogWriter(); UserLogWriter.ICS_UserLog = new OraUserLogWriter(); application.WriteMessage("服务开始启动!"); //清除验证票据缓存 TicketLib.Clear(); // 加载代码表Cache application.WriteMessage("开始加载代码表缓存!"); InitRefCodeCache(); application.WriteMessage("代码表缓存加载完毕!"); // 加载授权信息Cache application.WriteMessage("开始加载授权信息缓存!"); InitPermissionCache(); application.WriteMessage("授权信息缓存加载完毕!"); // 初始化Remoting服务 application.WriteMessage("初始化Remoting服务!"); //RemotingServerSvc.Init(); application.WriteMessage("Remoting服务初始化完毕!"); application.WriteMessage("注册Remoting服务工厂!"); //RemotingServerSvc.RegisterService(typeof(IServiceFactory), typeof(BizServiceFactory)); application.WriteMessage("Remoting服务工厂注册完毕!"); // 启动任务服务 application.WriteMessage("初始化任务服务!"); InitTask(); application.WriteMessage("任务服务初始化完成!"); // 发出启动成功提示音 ServerCommon.SvcBeep(SvcAction.Started); }