コード例 #1
0
ファイル: ServiceManager.cs プロジェクト: luoyiminga/ServerX
        private void Notify(string level, string src, string msg)
        {
            NotificationLogBuffer.Add(null, null, null, null, level, src, msg);
            var handler = ServiceManagerNotificationReceived;

            if (handler != null)
            {
                handler(level, src, msg);
            }
        }
コード例 #2
0
ファイル: ServiceManager.cs プロジェクト: luoyiminga/ServerX
        public ServiceManager()
        {
            ServiceManagerNotificationTarget.ServiceManager = this;
            _logger = LogManager.GetCurrentClassLogger();

            ExtensionNotificationReceived      += (procID, extID, extName, level, source, message) => CallbackEachClient <IServiceManagerCallback>(c => c.ServerExtensionNotify(procID, extID, extName, level, source, message));
            ServiceManagerNotificationReceived += (level, source, message) => CallbackEachClient <IServiceManagerCallback>(c => c.Notify(level, source, message));

            _extensionsBaseDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions"));
            if (!_extensionsBaseDir.Exists)
            {
                _extensionsBaseDir.Create();
            }
            if (_extensionsBaseDir.GetFiles().Select(f => f.Extension.ToLower()).Any(ext => _extensionFileExtensions.Contains(ext)))
            {
                throw new Exception("The extensions directory currently contains assemblies and/or executables. Extensions should be located in subdirectories of the Extensions folder; not the Extensions directory itself.");
            }

            _extProcMgr = new ExtensionProcessManager(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ServerX.Run.exe"),
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions")
                );

            _extClientMgr = new ExtensionClientManager(_extProcMgr);
            _extClientMgr.ExtensionNotificationReceived += (procID, extID, extName, level, source, message) =>
            {
                NotificationLogBuffer.Add(procID, _extProcMgr.GetExtensionDirectoryName(procID), extID, extName, level, source, message);
                var handler = ExtensionNotificationReceived;
                if (handler != null)
                {
                    handler(procID, extID, extName, level, source, message);
                }
            };

            _extProcMgr.StartMonitoring();

            _extCfgMgr = new ExtensionsConfigFileManager(_extProcMgr);
            Task.Factory.StartNew(() => _extCfgMgr.Init());

            _cmdRunner = new CommandRunner(this, _extClientMgr);
            _cronMgr   = new CronManager(this);
        }