static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //清理主状态缓冲区 WatchNodeCache.Init(); try { //启动WCF服务 ServiceHost WcfHost = new ServiceHost(typeof(SWCommandService)); WcfHost.Open(); if (args.Length == 0) { #if DEBUG Application.Run(new frmServiceMain()); #else System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new SysWatchService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); #endif } else if (args[0].ToLower() == "/f" || args[0].ToLower() == "-f") { Application.Run(new frmServiceMain()); } } catch (Exception ex) { EventLogSystemLog _log = new EventLogSystemLog("SinoSysWatchServiceLog"); _log.WriteLog(ex.Message, EventLogEntryType.Error); } }
public bool WriteMessage(string _message, System.Diagnostics.EventLogEntryType LogType) { EventLogSystemLog _log = new EventLogSystemLog("SinoMonitorCenterServiceLog"); _log.WriteLog(_message, LogType); return(true); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { SystemConfigSection CurrentSysList = (SystemConfigSection)ConfigurationManager.GetSection("SystemList"); foreach (SystemConfigurationElement _el in CurrentSysList.PluginCollection) { SystemStateItem _item = new SystemStateItem(_el.Name, _el.URL, _el.Description); WatchSystemLib.AddSystem(_item); } if (args.Length == 0) { #if DEBUG Application.Run(new frmMain()); #else System.ServiceProcess.ServiceBase[] ServicesToRun; ServicesToRun = new System.ServiceProcess.ServiceBase[] { new SinoMonitorCenterService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); #endif } else if (args[0].ToLower() == "/f" || args[0].ToLower() == "-f") { Application.Run(new frmMain()); } } catch (Exception ex) { EventLogSystemLog _log = new EventLogSystemLog("SinoMonitorCenterServiceLog"); _log.WriteLog(ex.Message, EventLogEntryType.Error); } }
protected override void OnStop() { // TODO: 在此处添加代码以执行停止服务所需的关闭操作。 if (CurrentServer != null) { } EventLogSystemLog _log = new EventLogSystemLog("SinoSysWatchServiceLog"); _log.WriteLog("缉私系统运行监控维护服务停止!", EventLogEntryType.Information); }
public bool WriteMessage(string _message, EventLogEntryType LogType) { StringBuilder _sb = new StringBuilder(); _sb.Append(string.Format("[{0}]", DateTime.Now.ToString("yyyyMMdd HH:mm:ss"))); _sb.Append(_message); _sb.Append("\r\n"); EventLogSystemLog _log = new EventLogSystemLog("SinoSysWatchServiceLog"); _log.WriteLog(_sb.ToString(), LogType); return(true); }
private void frmServiceMain_Load(object sender, EventArgs e) { EventLogSystemLog _log = new EventLogSystemLog("SinoSysWatchServiceLog"); _log.WriteLog("缉私系统运行监控维护服务开始启动(程序方式)!", EventLogEntryType.Information); serverPluginService = new ServerPluginService(this); serviceContainer.AddService(typeof(IServerPluginService), serverPluginService); Assembly SysAssembly = Assembly.GetEntryAssembly(); AssemblyName SysAssemblyName = SysAssembly.GetName(); this.label1.Text = string.Format("版本号:{0}", SysAssemblyName.Version.ToString()); //启动所有的WCF服务 serverPluginService.LoadAllPlugin(); serverPluginService.LoadPluginDescript(); ServerCommon _sc = new ServerCommon(); _sc.Init(this as IServerApplication, false); }
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); }