diff --git a/Bot-Utils/Bot-Utils.csproj b/Bot-Utils/Bot-Utils.csproj index d603c05..c66700b 100644 --- a/Bot-Utils/Bot-Utils.csproj +++ b/Bot-Utils/Bot-Utils.csproj @@ -64,6 +64,11 @@ + + + + + {91a14cd2-2940-4500-8193-56d37edddbaa} diff --git a/Bot-Utils/Bot-Utils_Core.csproj b/Bot-Utils/Bot-Utils_Core.csproj new file mode 100644 index 0000000..47330d5 --- /dev/null +++ b/Bot-Utils/Bot-Utils_Core.csproj @@ -0,0 +1,52 @@ + + + + netcoreapp3.0 + BlubbFish.Utils.IoT.Bots + Bot-Utils + Bots.IoT.Utils.BlubbFish + 1.2.1 + 1.2.1 + 1.2.1 + de-DE + Bot-Utils are helpers for programming a bot + BlubbFish + BlubbFish + Copyright © BlubbFish 2018 - 30.08.2019 + LICENSE + http://git.blubbfish.net/vs_utils/Bot-Utils + http://git.blubbfish.net/vs_utils/Bot-Utils.git + git + 1.2.1 When using Dispose, kill also mqtt connection and other tiny fixes +1.2.0 Refactor Bot to ABot and refere MultiSourceBot, Webserver and Bot to it. Add MultiSourceBot. Rewrite Mqtt module so that it not need to watch the connection. +1.1.9 Modify Output of SendFileResponse +1.1.8 Add logger to Webserver Class +1.1.7 Restrucutre loading, so that all is init and after the listener is started, REQUEST_URL_HOST gives now host and port +1.1.6 rename functions and make SendFileResponse with a parameter for the folder (default resources), also put returntype boolean, add function that parse post params, if path is a dictionary try to load index.html +1.1.5 add a function to send an object as json directly +1.1.4 add Woff as Binary type +1.1.3 Variables parsing now as a String +1.1.2 Fixing bug for Contenttype +1.1.1 Update to local librarys +1.1.0 Remove Helper from Bot-Utils + + + + + + + + + + + + + + + + True + + + + + diff --git a/Bot-Utils/Events/ModulEventArgs.cs b/Bot-Utils/Events/ModulEventArgs.cs index cabef82..26d4696 100644 --- a/Bot-Utils/Events/ModulEventArgs.cs +++ b/Bot-Utils/Events/ModulEventArgs.cs @@ -14,8 +14,6 @@ namespace BlubbFish.Utils.IoT.Bots.Events { public String Property { get; protected set; } public String Value { get; protected set; } public String Source { get; protected set; } - public override String ToString() { - return this.Source + ": " + this.Address + " set " + this.Property + " to " + this.Value; - } + public override String ToString() => this.Source + ": " + this.Address + " set " + this.Property + " to " + this.Value; } } diff --git a/Bot-Utils/Events/MqttEvent.cs b/Bot-Utils/Events/MqttEvent.cs index 4af1a4d..67298f1 100644 --- a/Bot-Utils/Events/MqttEvent.cs +++ b/Bot-Utils/Events/MqttEvent.cs @@ -9,8 +9,6 @@ namespace BlubbFish.Utils.IoT.Bots.Events { this.Value = text; this.Source = "MQTT"; } - public override String ToString() { - return this.Source + ": on " + this.Address + " set " + this.Value; - } + public override String ToString() => this.Source + ": on " + this.Address + " set " + this.Value; } } diff --git a/Bot-Utils/Events/SenmlEvent.cs b/Bot-Utils/Events/SenmlEvent.cs index e3071d5..71c68be 100644 --- a/Bot-Utils/Events/SenmlEvent.cs +++ b/Bot-Utils/Events/SenmlEvent.cs @@ -9,8 +9,6 @@ namespace BlubbFish.Utils.IoT.Bots.Events { this.Value = text; this.Source = "Senml"; } - public override String ToString() { - return this.Source + ": on " + this.Address + " set " + this.Value; - } + public override String ToString() => this.Source + ": on " + this.Address + " set " + this.Value; } } diff --git a/Bot-Utils/Events/StatusPollingEvent.cs b/Bot-Utils/Events/StatusPollingEvent.cs index 273fc2d..9d602e9 100644 --- a/Bot-Utils/Events/StatusPollingEvent.cs +++ b/Bot-Utils/Events/StatusPollingEvent.cs @@ -11,8 +11,6 @@ namespace BlubbFish.Utils.IoT.Bots.Events { this.Source = "POLLING"; } - public override String ToString() { - return this.Source + ": " + this.Value + " on " + this.Address; - } + public override String ToString() => this.Source + ": " + this.Value + " on " + this.Address; } } diff --git a/Bot-Utils/Moduls/AModul.cs b/Bot-Utils/Moduls/AModul.cs index 59c90cd..af77bbe 100644 --- a/Bot-Utils/Moduls/AModul.cs +++ b/Bot-Utils/Moduls/AModul.cs @@ -39,7 +39,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { if (this.HasConfig && this.ConfigPublic) { Dictionary> ret = new Dictionary>(this.config); if (ret.ContainsKey("modul")) { - ret.Remove("modul"); + _ = ret.Remove("modul"); } return ret; } @@ -61,7 +61,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { public void SetConfig(Dictionary> newconf) { if (this.HasConfig && this.ConfigPublic) { if (newconf.ContainsKey("modul")) { - newconf.Remove("modul"); + _ = newconf.Remove("modul"); } if (this.config.ContainsKey("modul")) { newconf.Add("modul", this.config["modul"]); diff --git a/Bot-Utils/Moduls/CronJob.cs b/Bot-Utils/Moduls/CronJob.cs index dcd6fc8..cc00e69 100644 --- a/Bot-Utils/Moduls/CronJob.cs +++ b/Bot-Utils/Moduls/CronJob.cs @@ -30,7 +30,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { #region Cronjobrunner protected void Runner() { - Thread.Sleep(DateTime.Now.AddMinutes(1).AddSeconds(DateTime.Now.Second * (-1)).AddMilliseconds(DateTime.Now.Millisecond * (-1)) - DateTime.Now); + Thread.Sleep(DateTime.Now.AddMinutes(1).AddSeconds(DateTime.Now.Second * -1).AddMilliseconds(DateTime.Now.Millisecond * -1) - DateTime.Now); while (true) { if (this.crontime.Minute != DateTime.Now.Minute) { this.crontime = DateTime.Now; @@ -140,9 +140,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { #endregion #region AModul - public override void SetInterconnection(String cron, Action hook, Object data) { - this.internalCron.Add(new Tuple, Object>(cron, hook, data)); - } + public override void SetInterconnection(String cron, Action hook, Object data) => this.internalCron.Add(new Tuple, Object>(cron, hook, data)); protected override void UpdateConfig() { } #endregion @@ -164,7 +162,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { } public override void Dispose() { - Dispose(true); + this.Dispose(true); GC.SuppressFinalize(this); } #endregion diff --git a/Bot-Utils/Moduls/Overtaker.cs b/Bot-Utils/Moduls/Overtaker.cs index a77ff33..3031c67 100644 --- a/Bot-Utils/Moduls/Overtaker.cs +++ b/Bot-Utils/Moduls/Overtaker.cs @@ -6,9 +6,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { protected readonly Dictionary> events = new Dictionary>(); #region Constructor - public Overtaker(T lib, InIReader settings) : base(lib, settings) { - this.ParseIni(); - } + public Overtaker(T lib, InIReader settings) : base(lib, settings) => this.ParseIni(); #endregion #region Overtakerfunctions @@ -63,9 +61,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { #region AModul public override void Interconnect(Dictionary> moduls) { } - protected override void UpdateConfig() { - this.ParseIni(); - } + protected override void UpdateConfig() => this.ParseIni(); #endregion #region IDisposable Support @@ -80,7 +76,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { } public override void Dispose() { - Dispose(true); + this.Dispose(true); GC.SuppressFinalize(this); } #endregion diff --git a/Bot-Utils/Moduls/Statuspolling.cs b/Bot-Utils/Moduls/Statuspolling.cs index c521e2c..3df061a 100644 --- a/Bot-Utils/Moduls/Statuspolling.cs +++ b/Bot-Utils/Moduls/Statuspolling.cs @@ -45,7 +45,7 @@ namespace BlubbFish.Utils.IoT.Bots.Moduls { } public override void Dispose() { - Dispose(true); + this.Dispose(true); GC.SuppressFinalize(this); } #endregion diff --git a/Bot-Utils/Properties/AssemblyInfo.cs b/Bot-Utils/Properties/AssemblyInfo.cs index 4f8f907..3126b45 100644 --- a/Bot-Utils/Properties/AssemblyInfo.cs +++ b/Bot-Utils/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -using System.Reflection; +#if NETCOREAPP +#else +using System.Reflection; using System.Resources; using System.Runtime.InteropServices; @@ -10,7 +12,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyProduct("Bot-Utils")] -[assembly: AssemblyCopyright("Copyright © 2018 - 30.08.2019")] +[assembly: AssemblyCopyright("Copyright © BlubbFish 2018 - 30.08.2019")] [assembly: AssemblyTrademark("© BlubbFish")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("de-DE")] @@ -51,3 +53,4 @@ using System.Runtime.InteropServices; * 1.2.0 Refactor Bot to ABot and refere MultiSourceBot, Webserver and Bot to it. Add MultiSourceBot. Rewrite Mqtt module so that it not need to watch the connection. * 1.2.1 When using Dispose, kill also mqtt connection and other tiny fixes */ +#endif \ No newline at end of file diff --git a/Bot-Utils/Webserver.cs b/Bot-Utils/Webserver.cs index d5d8877..c105022 100644 --- a/Bot-Utils/Webserver.cs +++ b/Bot-Utils/Webserver.cs @@ -48,7 +48,7 @@ namespace BlubbFish.Utils.IoT.Bots { public static Boolean SendFileResponse(HttpListenerContext cont, String folder = "resources", Boolean printOutput = true) { String restr = cont.Request.Url.PathAndQuery; if(restr.StartsWith("/")) { - restr = restr.IndexOf("?") != -1 ? restr.Substring(1, restr.IndexOf("?") - 1) : restr.Substring(1); + restr = restr.IndexOf("?") != -1 ? restr[1..restr.IndexOf("?")] : restr.Substring(1); if(Directory.Exists(folder + "/" + restr)) { restr += "/index.html"; } diff --git a/Bot-Utils_Core.sln b/Bot-Utils_Core.sln new file mode 100644 index 0000000..e927cce --- /dev/null +++ b/Bot-Utils_Core.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29519.87 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bot-Utils_Core", "Bot-Utils\Bot-Utils_Core.csproj", "{CB48457C-C567-42BC-9E5B-DAE5A3383108}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils-IoT_Core", "..\Utils-IoT\Utils-IoT\Utils-IoT_Core.csproj", "{86E9D6ED-EE31-4FE7-AEA6-555DBBAA69A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils_Core", "..\Utils\Utils\Utils_Core.csproj", "{110EB1ED-1567-4A7E-B8B5-E46F421E0684}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "litjson_Core", "..\..\Librarys\litjson\litjson\litjson_Core.csproj", "{A6EB1FF2-A3F1-4C97-8E7F-0F2CE4A8A820}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB48457C-C567-42BC-9E5B-DAE5A3383108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB48457C-C567-42BC-9E5B-DAE5A3383108}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB48457C-C567-42BC-9E5B-DAE5A3383108}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB48457C-C567-42BC-9E5B-DAE5A3383108}.Release|Any CPU.Build.0 = Release|Any CPU + {86E9D6ED-EE31-4FE7-AEA6-555DBBAA69A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86E9D6ED-EE31-4FE7-AEA6-555DBBAA69A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86E9D6ED-EE31-4FE7-AEA6-555DBBAA69A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86E9D6ED-EE31-4FE7-AEA6-555DBBAA69A4}.Release|Any CPU.Build.0 = Release|Any CPU + {110EB1ED-1567-4A7E-B8B5-E46F421E0684}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {110EB1ED-1567-4A7E-B8B5-E46F421E0684}.Debug|Any CPU.Build.0 = Debug|Any CPU + {110EB1ED-1567-4A7E-B8B5-E46F421E0684}.Release|Any CPU.ActiveCfg = Release|Any CPU + {110EB1ED-1567-4A7E-B8B5-E46F421E0684}.Release|Any CPU.Build.0 = Release|Any CPU + {A6EB1FF2-A3F1-4C97-8E7F-0F2CE4A8A820}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6EB1FF2-A3F1-4C97-8E7F-0F2CE4A8A820}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6EB1FF2-A3F1-4C97-8E7F-0F2CE4A8A820}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6EB1FF2-A3F1-4C97-8E7F-0F2CE4A8A820}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0F0DF907-D03F-41A9-B0A2-CA229CC259EE} + EndGlobalSection +EndGlobal