Compare commits
2
Commits
v1.2.5
...
21662a367e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21662a367e | ||
|
|
8e41d15e4e |
+17
-1
@@ -1,12 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Threading;
|
||||
|
||||
namespace BlubbFish.Utils.IoT.Bots {
|
||||
public abstract class ABot {
|
||||
private Boolean RunningProcess = true;
|
||||
private readonly ProgramLogger logger = null;
|
||||
|
||||
protected ProgramLogger logger = new ProgramLogger();
|
||||
public Boolean DebugLogging {
|
||||
get;
|
||||
} = false;
|
||||
|
||||
public ABot(String[] _, Boolean fileLogging, String configSearchPath) {
|
||||
InIReader.SetSearchPath(new List<String>() { "/etc/"+ configSearchPath, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\"+ configSearchPath });
|
||||
if(fileLogging && InIReader.ConfigExist("settings") && Boolean.TryParse(InIReader.GetInstance("settings").GetValue("logging", "enabled", "false"), out Boolean _)) {
|
||||
this.logger = new ProgramLogger(InIReader.GetInstance("settings").GetValue("logging", "path", Assembly.GetEntryAssembly().GetName().Name + ".log"));
|
||||
}
|
||||
if(InIReader.ConfigExist("settings") && Boolean.TryParse(InIReader.GetInstance("settings").GetValue("logging", "debug", "true"), out Boolean debuglog)) {
|
||||
this.DebugLogging = debuglog;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConsoleCancelEvent(Object sender, ConsoleCancelEventArgs e) {
|
||||
e.Cancel = true;
|
||||
@@ -37,6 +52,7 @@ namespace BlubbFish.Utils.IoT.Bots {
|
||||
public virtual void Dispose() {
|
||||
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.Dispose: Shutdown.");
|
||||
this.RunningProcess = false;
|
||||
this.logger?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace BlubbFish.Utils.IoT.Bots {
|
||||
|
||||
protected HttpListener httplistener;
|
||||
|
||||
public AWebserver(Dictionary<String, String> settings) => this.config = settings;
|
||||
public AWebserver(String[] args, Boolean fileLogging, String configSearchPath, Dictionary<String, String> settings) : base(args, fileLogging, configSearchPath) =>
|
||||
this.config = this.config is null ? InIReader.GetInstance("settings").GetSection("webserver") : settings;
|
||||
|
||||
protected void StartListen() {
|
||||
this.httplistener = new HttpListener();
|
||||
|
||||
@@ -7,7 +7,8 @@ using BlubbFish.Utils.IoT.Events;
|
||||
namespace BlubbFish.Utils.IoT.Bots {
|
||||
public abstract class AWebserverDataBackend : AWebserver {
|
||||
protected ABackend databackend;
|
||||
protected AWebserverDataBackend(ABackend backend, Dictionary<String, String> settings) : base(settings) => this.databackend = backend;
|
||||
protected AWebserverDataBackend(String[] args, Boolean fileLogging, String configSearchPath, ABackend backend, Dictionary<String, String> settings) : base(args, fileLogging, configSearchPath, settings) =>
|
||||
this.databackend = backend is null ? ABackend.GetInstance(InIReader.GetInstance("settings").GetSection("backend")) : backend;
|
||||
|
||||
protected void StartDataBackend() => this.databackend.MessageIncomming += this.Backend_MessageIncomming;
|
||||
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RootNamespace>BlubbFish.Utils.IoT.Bots</RootNamespace>
|
||||
<AssemblyName>Bot-Utils</AssemblyName>
|
||||
<PackageId>Bots.IoT.Utils.BlubbFish</PackageId>
|
||||
<Version>1.2.5</Version>
|
||||
<Version>1.2.6</Version>
|
||||
<NeutralLanguage>de-DE</NeutralLanguage>
|
||||
<Description>Bot-Utils are helpers for programming a bot</Description>
|
||||
<Authors>BlubbFish</Authors>
|
||||
<Company>BlubbFish</Company>
|
||||
<Copyright>Copyright © BlubbFish 2018 - 20.01.2022</Copyright>
|
||||
<Copyright>Copyright © BlubbFish 2018 - 25.01.2022</Copyright>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageProjectUrl>http://git.blubbfish.net/vs_utils/Bot-Utils</PackageProjectUrl>
|
||||
<RepositoryUrl>http://git.blubbfish.net/vs_utils/Bot-Utils.git</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageReleaseNotes>
|
||||
1.2.6 - 2022-01-25 - Makeing Logging easyier
|
||||
1.2.5 - 2022-01-20 - Better linux handling
|
||||
1.2.4 - 2022-01-18 - Config enabled module loading
|
||||
1.2.3 - 2022-01-09 - Tiny Refactoring
|
||||
|
||||
+7
-1
@@ -9,6 +9,8 @@ namespace BlubbFish.Utils.IoT.Bots {
|
||||
public abstract class Bot<T> : ABot {
|
||||
protected readonly Dictionary<String, AModul<T>> moduls = new Dictionary<String, AModul<T>>();
|
||||
|
||||
public Bot(String[] args, Boolean fileLogging, String configSearchPath) : base(args, fileLogging, configSearchPath) { }
|
||||
|
||||
protected void ModulDispose() {
|
||||
foreach (KeyValuePair<String, AModul<T>> item in this.moduls) {
|
||||
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.ModulDispose: Entlade Modul: " + item.Key);
|
||||
@@ -61,6 +63,10 @@ namespace BlubbFish.Utils.IoT.Bots {
|
||||
}
|
||||
}
|
||||
|
||||
protected void ModulUpdate(Object sender, ModulEventArgs e) => Console.WriteLine(e.ToString());
|
||||
protected void ModulUpdate(Object sender, ModulEventArgs e) {
|
||||
if(this.DebugLogging) {
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using BlubbFish.Utils.IoT.Connector;
|
||||
|
||||
namespace BlubbFish.Utils.IoT.Bots {
|
||||
@@ -10,7 +8,7 @@ namespace BlubbFish.Utils.IoT.Bots {
|
||||
protected Dictionary<String, ABackend> sources;
|
||||
protected Dictionary<String, String> settings;
|
||||
|
||||
protected MultiSourceBot(Dictionary<String, ABackend> sources, Dictionary<String, String> settings) {
|
||||
protected MultiSourceBot(String[] args, Boolean fileLogging, String configSearchPath, Dictionary<String, ABackend> sources, Dictionary<String, String> settings) : base(args, fileLogging, configSearchPath) {
|
||||
this.sources = sources;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
## 1.2.6 - 2022-01-25 - Makeing Logging easyier
|
||||
### New Features
|
||||
* Construct the Programm logger only if enabled
|
||||
* Set Searchpath by default for a Bot
|
||||
* Add an option that allows to debug logging (by default on)
|
||||
### Bugfixes
|
||||
### Changes
|
||||
* Deconstruct Programmlogger
|
||||
* Change all classes that extend ABot
|
||||
* Module messages also uses debug logging flag
|
||||
* Codingstyles
|
||||
|
||||
## 1.2.5 - 2022-01-20 - Better linux handling
|
||||
### New Features
|
||||
* Add ProcessExit Handler in ABot
|
||||
|
||||
Reference in New Issue
Block a user