Commit 262a14433f77cec7839e1da3e1aa6dd081fdfaee
1 parent
ca09d8bb
v1.2.0
- monitor profilok megadási lehetőségének beépítése -pl: <add key="WebServerHostedService_iSchedulerHangfire:configlist" value="ALMiSchedulerMonitor:config=ALMiSchedulerMonitor:120,CPiSchedulerMonitor:config=CPiSchedulerMonitor:120" />
Showing
13 changed files
with
234 additions
and
76 deletions
Show diff stats
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +using System; | ||
| 2 | +using System.Collections.Generic; | ||
| 3 | +using System.Linq; | ||
| 4 | +using System.Text; | ||
| 5 | +using System.Threading.Tasks; | ||
| 6 | + | ||
| 7 | +namespace TEST | ||
| 8 | +{ | ||
| 9 | + class Program | ||
| 10 | + { | ||
| 11 | + static void Main(string[] args) | ||
| 12 | + { | ||
| 13 | + int sec; | ||
| 14 | + sec = 55; Console.WriteLine($"*/{(int)(sec / 60)} * * * *"); | ||
| 15 | + sec = 75; Console.WriteLine($"*/{(int)(sec / 60)} * * * *"); | ||
| 16 | + sec = 120; Console.WriteLine($"*/{(int)(sec / 60)} * * * *"); | ||
| 17 | + Console.ReadLine(); | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | +} |
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +using System.Reflection; | ||
| 2 | +using System.Runtime.CompilerServices; | ||
| 3 | +using System.Runtime.InteropServices; | ||
| 4 | + | ||
| 5 | +// General Information about an assembly is controlled through the following | ||
| 6 | +// set of attributes. Change these attribute values to modify the information | ||
| 7 | +// associated with an assembly. | ||
| 8 | +[assembly: AssemblyTitle("TEST")] | ||
| 9 | +[assembly: AssemblyDescription("")] | ||
| 10 | +[assembly: AssemblyConfiguration("")] | ||
| 11 | +[assembly: AssemblyCompany("")] | ||
| 12 | +[assembly: AssemblyProduct("TEST")] | ||
| 13 | +[assembly: AssemblyCopyright("Copyright © 2023")] | ||
| 14 | +[assembly: AssemblyTrademark("")] | ||
| 15 | +[assembly: AssemblyCulture("")] | ||
| 16 | + | ||
| 17 | +// Setting ComVisible to false makes the types in this assembly not visible | ||
| 18 | +// to COM components. If you need to access a type in this assembly from | ||
| 19 | +// COM, set the ComVisible attribute to true on that type. | ||
| 20 | +[assembly: ComVisible(false)] | ||
| 21 | + | ||
| 22 | +// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
| 23 | +[assembly: Guid("fa347448-26b1-4c84-a0e4-319744116dd7")] | ||
| 24 | + | ||
| 25 | +// Version information for an assembly consists of the following four values: | ||
| 26 | +// | ||
| 27 | +// Major Version | ||
| 28 | +// Minor Version | ||
| 29 | +// Build Number | ||
| 30 | +// Revision | ||
| 31 | +// | ||
| 32 | +// You can specify all the values or you can default the Build and Revision Numbers | ||
| 33 | +// by using the '*' as shown below: | ||
| 34 | +// [assembly: AssemblyVersion("1.0.*")] | ||
| 35 | +[assembly: AssemblyVersion("1.0.0.0")] | ||
| 36 | +[assembly: AssemblyFileVersion("1.0.0.0")] |
| @@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 3 | + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
| 4 | + <PropertyGroup> | ||
| 5 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| 6 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
| 7 | + <ProjectGuid>{FA347448-26B1-4C84-A0E4-319744116DD7}</ProjectGuid> | ||
| 8 | + <OutputType>Exe</OutputType> | ||
| 9 | + <RootNamespace>TEST</RootNamespace> | ||
| 10 | + <AssemblyName>TEST</AssemblyName> | ||
| 11 | + <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> | ||
| 12 | + <FileAlignment>512</FileAlignment> | ||
| 13 | + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
| 14 | + <Deterministic>true</Deterministic> | ||
| 15 | + </PropertyGroup> | ||
| 16 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
| 17 | + <PlatformTarget>AnyCPU</PlatformTarget> | ||
| 18 | + <DebugSymbols>true</DebugSymbols> | ||
| 19 | + <DebugType>full</DebugType> | ||
| 20 | + <Optimize>false</Optimize> | ||
| 21 | + <OutputPath>bin\Debug\</OutputPath> | ||
| 22 | + <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
| 23 | + <ErrorReport>prompt</ErrorReport> | ||
| 24 | + <WarningLevel>4</WarningLevel> | ||
| 25 | + </PropertyGroup> | ||
| 26 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
| 27 | + <PlatformTarget>AnyCPU</PlatformTarget> | ||
| 28 | + <DebugType>pdbonly</DebugType> | ||
| 29 | + <Optimize>true</Optimize> | ||
| 30 | + <OutputPath>bin\Release\</OutputPath> | ||
| 31 | + <DefineConstants>TRACE</DefineConstants> | ||
| 32 | + <ErrorReport>prompt</ErrorReport> | ||
| 33 | + <WarningLevel>4</WarningLevel> | ||
| 34 | + </PropertyGroup> | ||
| 35 | + <ItemGroup> | ||
| 36 | + <Reference Include="System" /> | ||
| 37 | + <Reference Include="System.Core" /> | ||
| 38 | + <Reference Include="System.Xml.Linq" /> | ||
| 39 | + <Reference Include="System.Data.DataSetExtensions" /> | ||
| 40 | + <Reference Include="Microsoft.CSharp" /> | ||
| 41 | + <Reference Include="System.Data" /> | ||
| 42 | + <Reference Include="System.Net.Http" /> | ||
| 43 | + <Reference Include="System.Xml" /> | ||
| 44 | + </ItemGroup> | ||
| 45 | + <ItemGroup> | ||
| 46 | + <Compile Include="Program.cs" /> | ||
| 47 | + <Compile Include="Properties\AssemblyInfo.cs" /> | ||
| 48 | + </ItemGroup> | ||
| 49 | + <ItemGroup> | ||
| 50 | + <None Include="App.config" /> | ||
| 51 | + </ItemGroup> | ||
| 52 | + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
| 53 | +</Project> | ||
| 0 | \ No newline at end of file | 54 | \ No newline at end of file |
Vrh.Web.Reporting.sln
| @@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vrh.Web.iScheduler.Report.L | @@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vrh.Web.iScheduler.Report.L | ||
| 28 | EndProject | 28 | EndProject |
| 29 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vrh.Web.Reporting", "Vrh.Web.Reporting\Vrh.Web.Reporting.csproj", "{C0EE2B4C-A281-4C18-BFC7-48427985F732}" | 29 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vrh.Web.Reporting", "Vrh.Web.Reporting\Vrh.Web.Reporting.csproj", "{C0EE2B4C-A281-4C18-BFC7-48427985F732}" |
| 30 | EndProject | 30 | EndProject |
| 31 | +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEST", "TEST\TEST.csproj", "{FA347448-26B1-4C84-A0E4-319744116DD7}" | ||
| 32 | +EndProject | ||
| 31 | Global | 33 | Global |
| 32 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | 34 | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
| 33 | Debug|Any CPU = Debug|Any CPU | 35 | Debug|Any CPU = Debug|Any CPU |
| @@ -74,6 +76,10 @@ Global | @@ -74,6 +76,10 @@ Global | ||
| 74 | {C0EE2B4C-A281-4C18-BFC7-48427985F732}.Debug|Any CPU.Build.0 = Debug|Any CPU | 76 | {C0EE2B4C-A281-4C18-BFC7-48427985F732}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| 75 | {C0EE2B4C-A281-4C18-BFC7-48427985F732}.Release|Any CPU.ActiveCfg = Release|Any CPU | 77 | {C0EE2B4C-A281-4C18-BFC7-48427985F732}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| 76 | {C0EE2B4C-A281-4C18-BFC7-48427985F732}.Release|Any CPU.Build.0 = Release|Any CPU | 78 | {C0EE2B4C-A281-4C18-BFC7-48427985F732}.Release|Any CPU.Build.0 = Release|Any CPU |
| 79 | + {FA347448-26B1-4C84-A0E4-319744116DD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 80 | + {FA347448-26B1-4C84-A0E4-319744116DD7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| 81 | + {FA347448-26B1-4C84-A0E4-319744116DD7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| 82 | + {FA347448-26B1-4C84-A0E4-319744116DD7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| 77 | EndGlobalSection | 83 | EndGlobalSection |
| 78 | GlobalSection(SolutionProperties) = preSolution | 84 | GlobalSection(SolutionProperties) = preSolution |
| 79 | HideSolutionNode = FALSE | 85 | HideSolutionNode = FALSE |
Vrh.Web.Reporting/Properties/AssemblyInfo.cs
| @@ -36,6 +36,6 @@ using System.Runtime.InteropServices; | @@ -36,6 +36,6 @@ using System.Runtime.InteropServices; | ||
| 36 | // You can specify all the values or you can default the Build and Revision Numbers | 36 | // You can specify all the values or you can default the Build and Revision Numbers |
| 37 | // by using the '*' as shown below: | 37 | // by using the '*' as shown below: |
| 38 | // [assembly: AssemblyVersion("1.0.*")] | 38 | // [assembly: AssemblyVersion("1.0.*")] |
| 39 | -[assembly: AssemblyVersion("1.1.2.0")] | ||
| 40 | -[assembly: AssemblyFileVersion("1.1.2.0")] | ||
| 41 | -[assembly: AssemblyInformationalVersion("1.1.2")] | 39 | +[assembly: AssemblyVersion("1.2.0.0")] |
| 40 | +[assembly: AssemblyFileVersion("1.2.0.0")] | ||
| 41 | +[assembly: AssemblyInformationalVersion("1.2.0")] |
Vrh.Web.Reporting/WebServerHostedServiceStarter.cs
| @@ -217,27 +217,30 @@ namespace Vrh.Web.WebServerHostedServiceStarterNS | @@ -217,27 +217,30 @@ namespace Vrh.Web.WebServerHostedServiceStarterNS | ||
| 217 | private object ExternalInitializerStarStopLocker = new object(); | 217 | private object ExternalInitializerStarStopLocker = new object(); |
| 218 | private static readonly WebServerHostedServiceStarter IISHostedServiceStarterInstance = new WebServerHostedServiceStarter(); | 218 | private static readonly WebServerHostedServiceStarter IISHostedServiceStarterInstance = new WebServerHostedServiceStarter(); |
| 219 | private static List<Tuple<Action, Action>> externalinitializerList = new List<Tuple<Action, Action>>(); | 219 | private static List<Tuple<Action, Action>> externalinitializerList = new List<Tuple<Action, Action>>(); |
| 220 | - private static bool Config_DisablAutoStart | 220 | + #endregion private members |
| 221 | + | ||
| 222 | + #region private members - appconfig elements | ||
| 223 | + private static bool Config_DisableAutoStart | ||
| 221 | { | 224 | { |
| 222 | get | 225 | get |
| 223 | { | 226 | { |
| 224 | - if (!config_disablautostart.HasValue) | 227 | + if (!config_disableautostart.HasValue) |
| 225 | { | 228 | { |
| 226 | string disableautostartstring = ConfigurationManager.AppSettings[DISABLEAUTOSTART]; | 229 | string disableautostartstring = ConfigurationManager.AppSettings[DISABLEAUTOSTART]; |
| 227 | - if (string.IsNullOrWhiteSpace(disableautostartstring)) config_disablautostart = DISABLEAUTOSTARTDEFAULT; | ||
| 228 | - else if (disableautostartstring.ToLower() == bool.TrueString.ToLower()) config_disablautostart = true; | ||
| 229 | - else if (disableautostartstring.ToLower() != bool.FalseString.ToLower()) config_disablautostart = false; | ||
| 230 | - else config_disablautostart = DISABLEAUTOSTARTDEFAULT; | 230 | + if (string.IsNullOrWhiteSpace(disableautostartstring)) config_disableautostart = DISABLEAUTOSTARTDEFAULT; |
| 231 | + else if (disableautostartstring.ToLower() == bool.TrueString.ToLower()) config_disableautostart = true; | ||
| 232 | + else if (disableautostartstring.ToLower() != bool.FalseString.ToLower()) config_disableautostart = false; | ||
| 233 | + else config_disableautostart = DISABLEAUTOSTARTDEFAULT; | ||
| 231 | } | 234 | } |
| 232 | - return config_disablautostart.Value; | 235 | + return config_disableautostart.Value; |
| 233 | } | 236 | } |
| 234 | } | 237 | } |
| 235 | - private static bool? config_disablautostart = null; | ||
| 236 | - private const string IISHOSTEDSERVICESTARTER = "IISHostedServiceStarter:"; | 238 | + private static bool? config_disableautostart = null; |
| 239 | + private const string IISHOSTEDSERVICESTARTER = "WebServerHostedServiceStarter:"; | ||
| 237 | private const string DISABLEAUTOSTART = IISHOSTEDSERVICESTARTER + "disableautostart"; | 240 | private const string DISABLEAUTOSTART = IISHOSTEDSERVICESTARTER + "disableautostart"; |
| 238 | private const bool DISABLEAUTOSTARTDEFAULT = false; | 241 | private const bool DISABLEAUTOSTARTDEFAULT = false; |
| 239 | private const string NOEXTERNALINITIALIZERSAREREGISTERED = "No external initializers are registered!"; | 242 | private const string NOEXTERNALINITIALIZERSAREREGISTERED = "No external initializers are registered!"; |
| 240 | - #endregion private members | 243 | + #endregion private members - appconfig elements |
| 241 | 244 | ||
| 242 | #region private method - _SetupAutoStart | 245 | #region private method - _SetupAutoStart |
| 243 | /// <summary> | 246 | /// <summary> |
| @@ -302,8 +305,8 @@ namespace Vrh.Web.WebServerHostedServiceStarterNS | @@ -302,8 +305,8 @@ namespace Vrh.Web.WebServerHostedServiceStarterNS | ||
| 302 | le.AddDataField("SetupAutoStart serviceAutoStartProviderTypeFullName", serviceAutoStartProviderTypeFullName); | 305 | le.AddDataField("SetupAutoStart serviceAutoStartProviderTypeFullName", serviceAutoStartProviderTypeFullName); |
| 303 | le.AddDataField("SetupAutoStart serviceAutoStartProviderAssassemblyName", serviceAutoStartProviderAssassemblyName); | 306 | le.AddDataField("SetupAutoStart serviceAutoStartProviderAssassemblyName", serviceAutoStartProviderAssassemblyName); |
| 304 | 307 | ||
| 305 | - if (!disablemode.HasValue) disablemode = Config_DisablAutoStart; | ||
| 306 | - le.AddDataField("DisablAautoStart", disablemode.Value); | 308 | + if (!disablemode.HasValue) disablemode = Config_DisableAutoStart; |
| 309 | + le.AddDataField("DisableautoStart", disablemode.Value); | ||
| 307 | 310 | ||
| 308 | string filecontent; | 311 | string filecontent; |
| 309 | bool configchanged; | 312 | bool configchanged; |
Vrh.Web.iScheduler.Report.Lib/Areas/iSchedulerReport/Controllers/iSchedulerReportController.cs
| @@ -627,7 +627,7 @@ namespace Vrh.Web.iScheduler.Report.Areas.iSchedulerReport.Controllers | @@ -627,7 +627,7 @@ namespace Vrh.Web.iScheduler.Report.Areas.iSchedulerReport.Controllers | ||
| 627 | try | 627 | try |
| 628 | { | 628 | { |
| 629 | SchedulerPlugin schedulerPlugin = new SchedulerPlugin(); | 629 | SchedulerPlugin schedulerPlugin = new SchedulerPlugin(); |
| 630 | - ReturnInfoJSON ri = schedulerPlugin.TimedTask( | 630 | + ReturnInfoJSON ri = schedulerPlugin.ExecuteScheduledTask( |
| 631 | model.XmlCs, | 631 | model.XmlCs, |
| 632 | base.ForcedLanguageCode, | 632 | base.ForcedLanguageCode, |
| 633 | model.PackageName, | 633 | model.PackageName, |
| @@ -710,7 +710,7 @@ namespace Vrh.Web.iScheduler.Report.Areas.iSchedulerReport.Controllers | @@ -710,7 +710,7 @@ namespace Vrh.Web.iScheduler.Report.Areas.iSchedulerReport.Controllers | ||
| 710 | OperationId = OperationId ?? (SRConstants.Operations.EXECUTE_KEY); CheckIfParameterIsEmpty(OperationId, "OperationId"); | 710 | OperationId = OperationId ?? (SRConstants.Operations.EXECUTE_KEY); CheckIfParameterIsEmpty(OperationId, "OperationId"); |
| 711 | 711 | ||
| 712 | if (String.IsNullOrEmpty(xml)) xml = "???"; | 712 | if (String.IsNullOrEmpty(xml)) xml = "???"; |
| 713 | - executionmessage = (new SchedulerPlugin()).TimedTask(xml, base.ForcedLanguageCode, ObjectId, OperationId, TimeStamp, GroupId).ReturnMessage; | 713 | + executionmessage = (new SchedulerPlugin()).ExecuteScheduledTask(xml, base.ForcedLanguageCode, ObjectId, OperationId, TimeStamp, GroupId).ReturnMessage; |
| 714 | rijson.ReturnValue = 0; | 714 | rijson.ReturnValue = 0; |
| 715 | } | 715 | } |
| 716 | catch (Exception ex) | 716 | catch (Exception ex) |
Vrh.iScheduler.Interface/ISchedulerPlugin.cs
| @@ -51,7 +51,7 @@ namespace Vrh.iScheduler.Interfaces | @@ -51,7 +51,7 @@ namespace Vrh.iScheduler.Interfaces | ||
| 51 | /// <returns> | 51 | /// <returns> |
| 52 | /// Egy <c>ReturnInfoJSON</c> objektum a message részében formázott html üzenettel. | 52 | /// Egy <c>ReturnInfoJSON</c> objektum a message részében formázott html üzenettel. |
| 53 | /// </returns> | 53 | /// </returns> |
| 54 | - ReturnInfoJSON TimedTask(string xml, string lcid, string objectId, string operationId, string timeStamp, string groupId = null); | 54 | + ReturnInfoJSON ExecuteScheduledTask(string xml, string lcid, string objectId, string operationId, string timeStamp, string groupId = null); |
| 55 | 55 | ||
| 56 | /// <summary> | 56 | /// <summary> |
| 57 | /// Ütemezendő objektumok létezésének ellenőrzése. | 57 | /// Ütemezendő objektumok létezésének ellenőrzése. |
Vrh.iScheduler.Report/SchedulerPlugin.cs
| @@ -249,14 +249,14 @@ namespace Vrh.iScheduler.Report | @@ -249,14 +249,14 @@ namespace Vrh.iScheduler.Report | ||
| 249 | /// <returns> | 249 | /// <returns> |
| 250 | /// Egy <c>ReturnInfoJSON</c> objektum a message részében formázott html üzenettel. | 250 | /// Egy <c>ReturnInfoJSON</c> objektum a message részében formázott html üzenettel. |
| 251 | /// </returns> | 251 | /// </returns> |
| 252 | - public ReturnInfoJSON TimedTask(string xml, string lcid, string objectId, string operationId, string timeStamp, string groupId = null) | 252 | + public ReturnInfoJSON ExecuteScheduledTask(string xml, string lcid, string objectId, string operationId, string timeStamp, string groupId = null) |
| 253 | { | 253 | { |
| 254 | string errorOccured = "Error occured when the TimedTask method is running."; | 254 | string errorOccured = "Error occured when the TimedTask method is running."; |
| 255 | try | 255 | try |
| 256 | { | 256 | { |
| 257 | #region DEBUG | 257 | #region DEBUG |
| 258 | #if DEBUG | 258 | #if DEBUG |
| 259 | - string thisfn = string.Concat(nameof(SchedulerPlugin), ".", nameof(TimedTask), ": "); | 259 | + string thisfn = string.Concat(nameof(SchedulerPlugin), ".", nameof(ExecuteScheduledTask), ": "); |
| 260 | System.Diagnostics.Debug.WriteLine($"{thisfn}START"); | 260 | System.Diagnostics.Debug.WriteLine($"{thisfn}START"); |
| 261 | var sw = new System.Diagnostics.Stopwatch(); | 261 | var sw = new System.Diagnostics.Stopwatch(); |
| 262 | sw.Start(); | 262 | sw.Start(); |
Vrh.iScheduler/Monitor .cs
| @@ -32,16 +32,18 @@ namespace Vrh.iScheduler | @@ -32,16 +32,18 @@ namespace Vrh.iScheduler | ||
| 32 | var le = new DCLogEntry(LogLevel.Information, $"{typeof(WAHostedMonitorHangfire).FullName}.{System.Reflection.MethodBase.GetCurrentMethod().Name}"); | 32 | var le = new DCLogEntry(LogLevel.Information, $"{typeof(WAHostedMonitorHangfire).FullName}.{System.Reflection.MethodBase.GetCurrentMethod().Name}"); |
| 33 | try | 33 | try |
| 34 | { | 34 | { |
| 35 | - _MonitorHangfireInstance._StartHangfire(le); | ||
| 36 | - string ischedulerMonitorXml = "config=ALMiSchedulerMonitor";//TODO:hogy lehet ezt paraméterben átadni?????? | ||
| 37 | - string ischedulerXml = ""; // vagy "config=ALMiScheduler;"; | ||
| 38 | - var m_xmlp = new iSchedulerXMLProcessor(ischedulerMonitorXml, ischedulerXml); | ||
| 39 | - Monitor.SetiSchedulerCommonXMLProcessor(m_xmlp); | ||
| 40 | - if (m_xmlp.EnableWebAppExecution && m_xmlp.CheckInterval > 0) | 35 | + _StartHangfire(le); |
| 36 | + | ||
| 37 | + foreach (string cf in Config_iSchedulerConfigList) | ||
| 41 | { | 38 | { |
| 42 | - IntervalCronExpression = Cron.MinuteInterval((int)(m_xmlp.CheckInterval / 60));//"*/1 * * * *" | ||
| 43 | - //RecurringJob.RemoveIfExists("ischedulermonitorcycle"); | ||
| 44 | - RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor().Examination(null), IntervalCronExpression); | 39 | + if (!ParseiSchedulerConfigString(cf, out string jobid, out string xmlcs, out int checkintervalinseconds)) { le.AddDataField("Adding iScheduler job", $"iScheduler job definition error, job skipped! definition:{cf}"); continue; }; |
| 40 | + le.AddDataField("Adding iScheduler job", cf); | ||
| 41 | + | ||
| 42 | + IntervalCronExpression = $"*/{(int)(checkintervalinseconds / 60)} * * * *"; | ||
| 43 | + RecurringJob.AddOrUpdate(jobid, () => Monitor.ExaminationRunOnce(Process.GetCurrentProcess().Id, xmlcs), IntervalCronExpression); | ||
| 44 | + //Hangfire.SqlServer.SqlServerStorageOptions. | ||
| 45 | + //IntervalCronExpression = Cron.MinuteInterval((int)(m_xmlp.CheckIntervalInSeconds / 60));//"*/1 * * * *" | ||
| 46 | + //RecurringJob.RemoveIfExists("ischedulermonitorcycle"); | ||
| 45 | //var HanfireJobId = BackgroundJob.Enqueue(() => new Monitor().Examination(null)); | 47 | //var HanfireJobId = BackgroundJob.Enqueue(() => new Monitor().Examination(null)); |
| 46 | //RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor(m_xmlp).Examination(null), intervalcron); //minutes interval | 48 | //RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor(m_xmlp).Examination(null), intervalcron); //minutes interval |
| 47 | //RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor(m_xmlp).Examination(null), $"{(int)(m_xmlp.CheckInterval / 60)} * * * *"); // cron expression | 49 | //RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor(m_xmlp).Examination(null), $"{(int)(m_xmlp.CheckInterval / 60)} * * * *"); // cron expression |
| @@ -54,12 +56,12 @@ namespace Vrh.iScheduler | @@ -54,12 +56,12 @@ namespace Vrh.iScheduler | ||
| 54 | public static void Stop() | 56 | public static void Stop() |
| 55 | { | 57 | { |
| 56 | var le = new DCLogEntry(LogLevel.Information, $"{typeof(WAHostedMonitorHangfire).FullName}.{System.Reflection.MethodBase.GetCurrentMethod().Name}"); | 58 | var le = new DCLogEntry(LogLevel.Information, $"{typeof(WAHostedMonitorHangfire).FullName}.{System.Reflection.MethodBase.GetCurrentMethod().Name}"); |
| 57 | - try { _MonitorHangfireInstance._StopHangfire(le); } | 59 | + try { _StopHangfire(le); } |
| 58 | catch (Exception ex) { le.AddExceptionResult(ex); le.SetLogLevel(LogLevel.Error); } | 60 | catch (Exception ex) { le.AddExceptionResult(ex); le.SetLogLevel(LogLevel.Error); } |
| 59 | finally { le.Write(); } | 61 | finally { le.Write(); } |
| 60 | } | 62 | } |
| 61 | 63 | ||
| 62 | - | 64 | + #region private members - Cron expression |
| 63 | /// <summary> | 65 | /// <summary> |
| 64 | /// Cron Expression | 66 | /// Cron Expression |
| 65 | /// <minute> <hour> <day-of-month> <month> <day-of-week> | 67 | /// <minute> <hour> <day-of-month> <month> <day-of-week> |
| @@ -143,15 +145,10 @@ namespace Vrh.iScheduler | @@ -143,15 +145,10 @@ namespace Vrh.iScheduler | ||
| 143 | /// At Every 4 Months at 6am on the 10th: "0 06 10 */4 *" | 145 | /// At Every 4 Months at 6am on the 10th: "0 06 10 */4 *" |
| 144 | /// </summary> | 146 | /// </summary> |
| 145 | private static string IntervalCronExpression = null; | 147 | private static string IntervalCronExpression = null; |
| 146 | - private static WAHostedMonitorHangfire _MonitorHangfireInstance = new WAHostedMonitorHangfire(); | 148 | + #endregion private members - Cron expression |
| 147 | 149 | ||
| 148 | - private BackgroundJobServer _HangfireBackgroundJobServer { get; set; } | ||
| 149 | - private static readonly object _HangfireStarterLocker = new object(); | ||
| 150 | - private static bool _HangFireRunning = false; | ||
| 151 | - const string HANGFIRE = "HangfireBootstrapper:"; | ||
| 152 | - const string HANGFIREDBCONNECTIONSTRING = HANGFIRE + "dbconnectionstring"; | ||
| 153 | - const string HANGFIRESQLDBCONNECTIONSTRINGNAMEDEFAULT = "HANGFIRESQLDB"; | ||
| 154 | - private void _StartHangfire(DCLogEntry le) | 150 | + #region private members - _StartHangfire,_StopHangfire |
| 151 | + private static void _StartHangfire(DCLogEntry le) | ||
| 155 | { | 152 | { |
| 156 | lock (_HangfireStarterLocker) | 153 | lock (_HangfireStarterLocker) |
| 157 | { | 154 | { |
| @@ -165,7 +162,7 @@ namespace Vrh.iScheduler | @@ -165,7 +162,7 @@ namespace Vrh.iScheduler | ||
| 165 | _HangFireRunning = true; | 162 | _HangFireRunning = true; |
| 166 | } | 163 | } |
| 167 | } | 164 | } |
| 168 | - private void _StopHangfire(DCLogEntry le) | 165 | + private static void _StopHangfire(DCLogEntry le) |
| 169 | { | 166 | { |
| 170 | lock (_HangfireStarterLocker) | 167 | lock (_HangfireStarterLocker) |
| 171 | { | 168 | { |
| @@ -175,20 +172,59 @@ namespace Vrh.iScheduler | @@ -175,20 +172,59 @@ namespace Vrh.iScheduler | ||
| 175 | _HangFireRunning = false; | 172 | _HangFireRunning = false; |
| 176 | } | 173 | } |
| 177 | } | 174 | } |
| 178 | - private string Config_HangFireConnectionString | 175 | + //private static WAHostedMonitorHangfire _MonitorHangfireInstance = new WAHostedMonitorHangfire(); |
| 176 | + private static BackgroundJobServer _HangfireBackgroundJobServer { get; set; } | ||
| 177 | + private static readonly object _HangfireStarterLocker = new object(); | ||
| 178 | + private static bool _HangFireRunning = false; | ||
| 179 | + #endregion private members - _StartHangfire,_StopHangfire | ||
| 180 | + | ||
| 181 | + #region appconfig elements | ||
| 182 | + const string WSHSHANGFIRE = "WebServerHostedService_iSchedulerHangfire:"; | ||
| 183 | + const string HANGFIREDBCONNECTIONSTRING = WSHSHANGFIRE + "dbconnectionstring"; | ||
| 184 | + const string HANGFIRECONFIGLIST = WSHSHANGFIRE + "configlist"; | ||
| 185 | + private static List<string> Config_iSchedulerConfigList | ||
| 186 | + { | ||
| 187 | + get | ||
| 188 | + { | ||
| 189 | + if (config_ischedulerconfiglist == null) | ||
| 190 | + { | ||
| 191 | + string configliststring = ConfigurationManager.AppSettings[HANGFIRECONFIGLIST]; | ||
| 192 | + if (string.IsNullOrWhiteSpace(configliststring)) configliststring = ""; | ||
| 193 | + config_ischedulerconfiglist = configliststring.Split(new char[] { ',', ';' },StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
| 194 | + } | ||
| 195 | + return config_ischedulerconfiglist; | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + private static List<string> config_ischedulerconfiglist = null; | ||
| 199 | + private static bool ParseiSchedulerConfigString(string cf, out string jobid, out string xmlcs, out int checkintervalinseconds) | ||
| 200 | + { | ||
| 201 | + jobid = "";xmlcs = ""; checkintervalinseconds = 60; | ||
| 202 | + if (string.IsNullOrWhiteSpace(cf)) return false; | ||
| 203 | + try | ||
| 204 | + { | ||
| 205 | + jobid = cf.Split(':')[0]; | ||
| 206 | + xmlcs = cf.Split(':')[1]; | ||
| 207 | + checkintervalinseconds = int.Parse(cf.Split(':')[2]); | ||
| 208 | + } | ||
| 209 | + catch { } | ||
| 210 | + if (checkintervalinseconds < 60) checkintervalinseconds = 60; | ||
| 211 | + return !string.IsNullOrWhiteSpace(jobid) && !string.IsNullOrWhiteSpace(xmlcs) && checkintervalinseconds >= 60; | ||
| 212 | + } | ||
| 213 | + private static string Config_HangFireConnectionString | ||
| 179 | { | 214 | { |
| 180 | get | 215 | get |
| 181 | { | 216 | { |
| 182 | if (config_hangfireconnectionstring == null) | 217 | if (config_hangfireconnectionstring == null) |
| 183 | { | 218 | { |
| 184 | string HangfireSqlDBConnectionString = ConfigurationManager.AppSettings[HANGFIREDBCONNECTIONSTRING]; | 219 | string HangfireSqlDBConnectionString = ConfigurationManager.AppSettings[HANGFIREDBCONNECTIONSTRING]; |
| 185 | - if (string.IsNullOrWhiteSpace(HangfireSqlDBConnectionString)) HangfireSqlDBConnectionString = HANGFIRESQLDBCONNECTIONSTRINGNAMEDEFAULT; | 220 | + if (string.IsNullOrWhiteSpace(HangfireSqlDBConnectionString)) HangfireSqlDBConnectionString = "HANGFIRESQLDB"; |
| 186 | config_hangfireconnectionstring = ConnectionStringStore.GetSQL(HangfireSqlDBConnectionString); | 221 | config_hangfireconnectionstring = ConnectionStringStore.GetSQL(HangfireSqlDBConnectionString); |
| 187 | } | 222 | } |
| 188 | return config_hangfireconnectionstring; | 223 | return config_hangfireconnectionstring; |
| 189 | } | 224 | } |
| 190 | } | 225 | } |
| 191 | - private string config_hangfireconnectionstring = null; | 226 | + private static string config_hangfireconnectionstring = null; |
| 227 | + #endregion appconfig elements | ||
| 192 | } | 228 | } |
| 193 | } | 229 | } |
| 194 | namespace Vrh.iScheduler | 230 | namespace Vrh.iScheduler |
| @@ -273,12 +309,7 @@ namespace Vrh.iScheduler | @@ -273,12 +309,7 @@ namespace Vrh.iScheduler | ||
| 273 | #region Private members | 309 | #region Private members |
| 274 | 310 | ||
| 275 | private Timer m_timer; | 311 | private Timer m_timer; |
| 276 | - private iSchedulerXMLProcessor m_xmlp; | ||
| 277 | - private static iSchedulerXMLProcessor CommonM_xmlp; | ||
| 278 | - public static void SetiSchedulerCommonXMLProcessor(iSchedulerXMLProcessor m_xmlp) | ||
| 279 | - { | ||
| 280 | - CommonM_xmlp = m_xmlp; | ||
| 281 | - } | 312 | + private iSchedulerXMLProcessor m_xmlp=null; |
| 282 | #endregion Private members | 313 | #endregion Private members |
| 283 | 314 | ||
| 284 | #region Constructor | 315 | #region Constructor |
| @@ -290,32 +321,26 @@ namespace Vrh.iScheduler | @@ -290,32 +321,26 @@ namespace Vrh.iScheduler | ||
| 290 | /// <param name="scheduleXmlPath">ScheduleExecute akció által használt iScheduler.xml elérési helye a névvel együtt | 321 | /// <param name="scheduleXmlPath">ScheduleExecute akció által használt iScheduler.xml elérési helye a névvel együtt |
| 291 | /// <param name="pluginReference">Az indító plugin példányra mutató referencia | 322 | /// <param name="pluginReference">Az indító plugin példányra mutató referencia |
| 292 | /// a távoli gépen. Ha egy gépen fut, akkor nem kötelező.</param> | 323 | /// a távoli gépen. Ha egy gépen fut, akkor nem kötelező.</param> |
| 293 | - public Monitor(string scheduleMonitorXmlPath, string scheduleXmlPath) | ||
| 294 | - { | ||
| 295 | - Init(new iSchedulerXMLProcessor(scheduleMonitorXmlPath, scheduleXmlPath)); | ||
| 296 | - } | ||
| 297 | - public Monitor(iSchedulerXMLProcessor m_xmlp) | ||
| 298 | - { | ||
| 299 | - Init(m_xmlp); | ||
| 300 | - } | ||
| 301 | - public Monitor() | ||
| 302 | - { | ||
| 303 | - Init(CommonM_xmlp); | ||
| 304 | - } | ||
| 305 | - private void Init(iSchedulerXMLProcessor m_xmlp) | 324 | + public Monitor(string scheduleMonitorXmlPath, string scheduleXmlPath) { Init(new iSchedulerXMLProcessor(scheduleMonitorXmlPath, scheduleXmlPath)); } |
| 325 | + public Monitor(iSchedulerXMLProcessor m_xmlp) { Init(m_xmlp); } | ||
| 326 | + public Monitor() { } | ||
| 327 | + private void Init(iSchedulerXMLProcessor m_xmlp,bool enabletimer=true) | ||
| 306 | { | 328 | { |
| 307 | this.m_xmlp = m_xmlp; | 329 | this.m_xmlp = m_xmlp; |
| 308 | //try | 330 | //try |
| 309 | //{ | 331 | //{ |
| 310 | - m_timer = new Timer(m_xmlp.CheckInterval * 1000); // !!! Ez itt a jó sor !!! m_timer = new Timer(20000); meg a debug !!! | ||
| 311 | - m_timer.Elapsed += OnExamination; | 332 | + if (!enabletimer) |
| 333 | + { | ||
| 334 | + m_timer = new Timer(m_xmlp.CheckIntervalInSeconds * 1000); // !!! Ez itt a jó sor !!! m_timer = new Timer(20000); meg a debug !!! | ||
| 335 | + m_timer.Elapsed += OnExamination; | ||
| 336 | + } | ||
| 312 | 337 | ||
| 313 | var le = new DCLogEntry(LogLevel.Information, nameof(Monitor) + " constructor. Preparation ready."); | 338 | var le = new DCLogEntry(LogLevel.Information, nameof(Monitor) + " constructor. Preparation ready."); |
| 314 | le.AddDataField("iSchedulerMonitor xml path", m_xmlp.ScheduleMonitorXmlPath); | 339 | le.AddDataField("iSchedulerMonitor xml path", m_xmlp.ScheduleMonitorXmlPath); |
| 315 | le.AddDataField("iScheduler xml path", m_xmlp.ScheduleXmlPath); | 340 | le.AddDataField("iScheduler xml path", m_xmlp.ScheduleXmlPath); |
| 316 | le.AddDataField("Scheduled object type", m_xmlp.ObjectType); | 341 | le.AddDataField("Scheduled object type", m_xmlp.ObjectType); |
| 317 | le.AddDataField("Group Id", m_xmlp.GroupId); | 342 | le.AddDataField("Group Id", m_xmlp.GroupId); |
| 318 | - le.AddDataField("Check interval", m_xmlp.CheckInterval.ToString()); | 343 | + le.AddDataField("Check interval", m_xmlp.CheckIntervalInSeconds.ToString()); |
| 319 | le.Write(); | 344 | le.Write(); |
| 320 | 345 | ||
| 321 | //} | 346 | //} |
| @@ -346,7 +371,7 @@ namespace Vrh.iScheduler | @@ -346,7 +371,7 @@ namespace Vrh.iScheduler | ||
| 346 | private void OnExamination(object sender, ElapsedEventArgs e) | 371 | private void OnExamination(object sender, ElapsedEventArgs e) |
| 347 | { | 372 | { |
| 348 | m_timer.Stop(); | 373 | m_timer.Stop(); |
| 349 | - Examination(e.SignalTime); | 374 | + Examination(e.SignalTime,null); |
| 350 | m_timer.Start(); | 375 | m_timer.Start(); |
| 351 | } | 376 | } |
| 352 | 377 | ||
| @@ -356,23 +381,25 @@ namespace Vrh.iScheduler | @@ -356,23 +381,25 @@ namespace Vrh.iScheduler | ||
| 356 | /// </summary> | 381 | /// </summary> |
| 357 | /// <param name="signalTime"></param> | 382 | /// <param name="signalTime"></param> |
| 358 | [DisableConcurrentExecution(1000)] | 383 | [DisableConcurrentExecution(1000)] |
| 359 | - public void Examination(DateTime? signalTime) | 384 | + public void Examination(DateTime? signalTime,DCLogEntry le) |
| 360 | { | 385 | { |
| 361 | - var le = new DCLogEntry(LogLevel.Debug,nameof(Examination)); | 386 | + bool writele = false; |
| 387 | + if (le == null) { le = new DCLogEntry(LogLevel.Debug, nameof(Examination)); writele = true; } | ||
| 362 | if (!signalTime.HasValue) signalTime = DateTime.Now; | 388 | if (!signalTime.HasValue) signalTime = DateTime.Now; |
| 363 | try | 389 | try |
| 364 | { | 390 | { |
| 365 | using (SqlConnection cnn = new SqlConnection(m_xmlp.DatabaseConnectionString)) | 391 | using (SqlConnection cnn = new SqlConnection(m_xmlp.DatabaseConnectionString)) |
| 366 | { | 392 | { |
| 367 | cnn.Open(); | 393 | cnn.Open(); |
| 368 | - le.AddDataField("Database connection opened", $"Connection string: {m_xmlp.DatabaseConnectionString}"); | 394 | + le.AddDataField($"{nameof(Examination)}: Database connection opened", $"Connection string: {m_xmlp.DatabaseConnectionString}"); |
| 369 | 395 | ||
| 370 | string scmd = string.Concat( | 396 | string scmd = string.Concat( |
| 371 | " select *", | 397 | " select *", |
| 372 | " from iScheduler.Schedules s", | 398 | " from iScheduler.Schedules s", |
| 373 | " inner join iScheduler.ScheduleObjects so on s.ScheduleObjectId = so.Id", | 399 | " inner join iScheduler.ScheduleObjects so on s.ScheduleObjectId = so.Id", |
| 374 | " where s.[State] = 0 and s.OperationTime < @signalTime", | 400 | " where s.[State] = 0 and s.OperationTime < @signalTime", |
| 375 | - " and so.ObjectType = @objectType and so.ObjectGroupId = @groupId"); | 401 | + " and so.ObjectType = @objectType and so.ObjectGroupId = @groupId" |
| 402 | + ); | ||
| 376 | using (SqlCommand cmd = new SqlCommand(scmd, cnn)) | 403 | using (SqlCommand cmd = new SqlCommand(scmd, cnn)) |
| 377 | { | 404 | { |
| 378 | cmd.Parameters.Add(new SqlParameter("signalTime", signalTime)); | 405 | cmd.Parameters.Add(new SqlParameter("signalTime", signalTime)); |
| @@ -395,13 +422,13 @@ namespace Vrh.iScheduler | @@ -395,13 +422,13 @@ namespace Vrh.iScheduler | ||
| 395 | ScheduledJobCounter++; | 422 | ScheduledJobCounter++; |
| 396 | int id = rdr.GetInt32(ixID); | 423 | int id = rdr.GetInt32(ixID); |
| 397 | DateTime jobstartedat = DateTime.Now; | 424 | DateTime jobstartedat = DateTime.Now; |
| 398 | - le.AddDataField($"Scheduled job #{ScheduledJobCounter} started", $"id={id}"); | 425 | + le.AddDataField($"{nameof(Examination)}: Scheduled job #{ScheduledJobCounter} started", $"id={id}"); |
| 399 | se.Run(id); | 426 | se.Run(id); |
| 400 | - le.AddDataField($"Scheduled job #{ScheduledJobCounter} finished at", (DateTime.Now).Subtract(jobstartedat).ToString(@"hh\:mm\:ss")); | ||
| 401 | - le.AddSuccessResult("Scheduled job execution SUCCESS"); | 427 | + le.AddDataField($"{nameof(Examination)}: Scheduled job #{ScheduledJobCounter} finished at", (DateTime.Now).Subtract(jobstartedat).ToString(@"hh\:mm\:ss")); |
| 428 | + le.AddSuccessResult($"{nameof(Examination)}: Scheduled job execution SUCCESS"); | ||
| 402 | }//while (rdr.Read()) | 429 | }//while (rdr.Read()) |
| 403 | }//if (rdr.HasRows) | 430 | }//if (rdr.HasRows) |
| 404 | - else { le.AddSuccessResult($"No scheduled job found!"); } | 431 | + else { le.AddSuccessResult($"{nameof(Examination)}: No scheduled job found!"); } |
| 405 | } | 432 | } |
| 406 | } | 433 | } |
| 407 | } | 434 | } |
| @@ -410,6 +437,13 @@ namespace Vrh.iScheduler | @@ -410,6 +437,13 @@ namespace Vrh.iScheduler | ||
| 410 | le.SetLogLevel(LogLevel.Error); | 437 | le.SetLogLevel(LogLevel.Error); |
| 411 | le.AddExceptionResult(ex); | 438 | le.AddExceptionResult(ex); |
| 412 | } | 439 | } |
| 440 | + finally { if (writele) le.Write(); } | ||
| 441 | + } | ||
| 442 | + public static void ExaminationRunOnce(int pid, string xmlcs) | ||
| 443 | + { | ||
| 444 | + var le = new DCLogEntry(LogLevel.Debug, nameof(ExaminationRunOnce)); | ||
| 445 | + try { (new Monitor(xmlcs, "")).Examination(null, le); } | ||
| 446 | + catch (Exception ex) { le.AddExceptionResult(ex); } | ||
| 413 | finally { le.Write(); } | 447 | finally { le.Write(); } |
| 414 | } | 448 | } |
| 415 | #endregion Examination | 449 | #endregion Examination |
Vrh.iScheduler/ScheduleExecute.cs
| @@ -164,7 +164,7 @@ namespace Vrh.iScheduler | @@ -164,7 +164,7 @@ namespace Vrh.iScheduler | ||
| 164 | #region Plugin elérési mód esetén | 164 | #region Plugin elérési mód esetén |
| 165 | try | 165 | try |
| 166 | { | 166 | { |
| 167 | - rijson = this.Plugin.TimedTask( | 167 | + rijson = this.Plugin.ExecuteScheduledTask( |
| 168 | this.Scheduler.Plugin.ObjectXml, | 168 | this.Scheduler.Plugin.ObjectXml, |
| 169 | this.Scheduler.LCID, | 169 | this.Scheduler.LCID, |
| 170 | sch.ScheduleObject.ObjectId, | 170 | sch.ScheduleObject.ObjectId, |
Vrh.iScheduler/iSchedulerXMLProcessor.cs
| @@ -126,7 +126,7 @@ namespace Vrh.iScheduler | @@ -126,7 +126,7 @@ namespace Vrh.iScheduler | ||
| 126 | /// Minimum: 60 sec (1perc), maximum: 86400 sec (1nap). | 126 | /// Minimum: 60 sec (1perc), maximum: 86400 sec (1nap). |
| 127 | /// Ha a tulajdonság nem létezik, vagy értelmezhetetlen, akkor a minimum lesz. | 127 | /// Ha a tulajdonság nem létezik, vagy értelmezhetetlen, akkor a minimum lesz. |
| 128 | /// </summary> | 128 | /// </summary> |
| 129 | - public int CheckInterval | 129 | + public int CheckIntervalInSeconds |
| 130 | { | 130 | { |
| 131 | get | 131 | get |
| 132 | { | 132 | { |