public LuaEngine(IServiceProvider sp, string name) : base(sp, name) { // create the state this.propertyScriptCount = new SimpleConfigItemProperty <int>(this, "tw_luaengine_scripts", "Skripte", "Lua-Engine", "Anzahl der aktiven Scripte.", "{0:N0}", 0); // create the lists this.scripts = new DEList <LuaScript>(this, "tw_scripts", "Scriptlist"); this.globals = new DEList <LuaAttachedGlobal>(this, "tw_globals", "Attached scripts"); // Register the service var sc = sp.GetService <IServiceContainer>(true); sc.AddService(typeof(IDELuaEngine), this); // register context extensions LuaType.RegisterTypeExtension(typeof(HttpResponseHelper)); // create the debug options debugHook = new LuaEngineTraceLineDebugger(this); debugOptions = new LuaCompileOptions(); debugOptions.DebugEngine = debugHook; // update lua runtime sp.GetService <DEServer>(true).UpdateLuaRuntime(lua); } // ctor
public DEThreadBase(IServiceProvider sp, string name, string categoryName = ThreadCategory) { this.sp = sp; if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } // create the log information this.log = sp.LogProxy(); if (log == null) { throw new ArgumentNullException("log", "Service provider must provide logging."); } propertyRestarts = new SimpleConfigItemProperty <int>(sp, $"tw_thread_restarts_{name}", $"{name} - Neustarts", categoryName, "Anzahl der Neustarts des Threads.", "{0:N0}", 0 ); propertyRunning = new SimpleConfigItemProperty <string>(sp, $"tw_thread_running_{name}", $"{name} - Aktiv", categoryName, "Ist der Thread noch aktiv.", null, "Läuft" ); } // ctor
private void InitServerInfo() { // Zeige die Versionsnummer an RegisterProperty(new SimpleConfigItemProperty <string>(this, "tw_base_version", "Version", ServerCategory, "Versioninformation des Servers.", null, GetServerFileVersion())); // Speichereigenschaften RegisterProperty(propertyMemory = new SimpleConfigItemProperty <long>(this, "tw_base_gc", "Speicher", ServerCategory, "Aktuell größe des verwalteten Heaps.", "FILESIZE", 0)); // Angaben zum Netzwerk var hostName = Dns.GetHostName(); RegisterProperty(new SimpleConfigItemProperty <string>(this, "tw_base_hostname", "Rechnername", NetworkCategory, "Hostname des Servers.", null, hostName)); var i = 1; var he = Dns.GetHostEntry(hostName); foreach (IPAddress addr in he.AddressList) { RegisterProperty(new SimpleConfigItemProperty <string>(this, "tw_base_address_" + i.ToString(), "IP " + i.ToString(), NetworkCategory, "IP Adresse unter der der Server ereichbar ist.", null, addr.ToString())); i++; } Queue.RegisterIdle(() => { int iTmp = 0; IdleMemoryViewerRefreshValue(false, ref iTmp); }, 3000); PublishItem(new DEConfigItemPublicPanel("tw_server_info", "/wpf/ServerInfoControl.xaml") { DisplayName = "Server Informationen" }); } // proc InitServerInfo
public CronJobItem(IServiceProvider sp, string name) : base(sp, name) { this.cronEngine = new Lazy <IDECronEngine>(() => this.GetService <IDECronEngine>(false)); propertyNextRun = new SimpleConfigItemProperty <DateTime?>(this, "tw_cron_nextrun", "Next run", JobCategory, "Zeitpunkt des nächsten durchlaufs.", "{0:t}", null); propertyLastTime = new SimpleConfigItemProperty <double>(this, "tw_cron_duration", "Last duration", JobCategory, "Zuletzt benötigte Zeit für den Durchlauf", "{0:N1} min", 0.0); propertyIsRunning = new SimpleConfigItemProperty <string>(this, "tw_cron_isrunning", "Is running", JobCategory, "Status der aktuellen Aufgabe.", null, "nein"); PublishItem(new DEConfigItemPublicAction("jobstart") { DisplayName = "Start" }); } // ctor
} // func ValidateConfig protected override void OnBeginReadConfiguration(IDEConfigLoading config) { lock (securityGroups) securityGroups.Clear(); // Lösche die alten Resolveeinträge if (config.ConfigOld != null) { RemoveResolve(config.ConfigOld.Element(xnServer)); } // Lade die Erweiterungen var server = config.ConfigNew.Element(xnServer); if (server != null) { foreach (XElement cur in server.Elements()) { if (cur.Name == xnServerSecurityGroup) { var name = cur.GetAttribute("name", String.Empty).ToLower(); if (String.IsNullOrEmpty(name)) { Log.LogMsg(LogMsgType.Warning, "server/securitygroup benötigt Namen."); } else { lock (securityGroups) { string[] tmp; if (securityGroups.TryGetValue(name, out tmp)) { securityGroups[name] = CombineSecurityTokens(tmp, SplitSecurityGroup(cur.Value)); } else { securityGroups[name] = SplitSecurityGroup(cur.Value); } } } } } } securityGroupsVersion++; // Den Start verzögern if (server != null && config.ConfigOld == null) { // Dienstabhängigkeiten foreach (var dependon in server.Elements(xnServerDependOnServer)) { WaitForService(dependon.Value, dependon.GetAttribute("maxtime", 30000)); } // Warten var waitTimeout = server.GetAttribute("globalwait", 0); if (waitTimeout > 0) { LogMsg(EventLogEntryType.Information, String.Format("Wait {0}ms...", waitTimeout)); //serviceLog.RequestAdditionalTime(iWait); Thread.Sleep(waitTimeout); LogMsg(EventLogEntryType.Information, "Continue load configure..."); } } // Initialisiere die Log-Datei var newLogPath = server.GetAttribute("logpath", String.Empty); if (logPath == null) { if (String.IsNullOrEmpty(newLogPath)) { LogMsg(EventLogEntryType.Error, "server/@logpath wurde nicht nicht angegeben."); } // Lege das Verzeichnis an this.logPath = newLogPath; var di = new DirectoryInfo(logPath); if (!di.Exists) { di.Create(); } // Erzeuge Statie propertyLogCount = new SimpleConfigItemProperty <int>(this, "tw_base_logcount", "Logs", ServerCategory, "Anzahl der Log-Dateien.", "{0:N0}", 0); } else if (String.Compare(newLogPath, logPath, true) != 0) { Log.Warn("Für die Änderung des LogPath ist ein Neustart erforderlich."); } // Initialisiere die Basis base.OnBeginReadConfiguration(config); } // proc OnBeginReadConfiguration