Projektdateien hinzufügen.
This commit is contained in:
47
FileinterfaceCronScheduler/RuntimeFactory.cs
Normal file
47
FileinterfaceCronScheduler/RuntimeFactory.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using FileInterface.Scheduler;
|
||||
|
||||
namespace FileinterfaceCronScheduler
|
||||
{
|
||||
internal static class RuntimeFactory
|
||||
{
|
||||
public static SchedulerRuntime Create()
|
||||
{
|
||||
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
|
||||
string cronConfigFile = Get("Scheduler.ConfigFile", "cronjobs.json");
|
||||
string watcherConfigFile = Get("Watcher.ConfigFile", "watcherjobs.json");
|
||||
|
||||
if (!Path.IsPathRooted(cronConfigFile)) cronConfigFile = Path.Combine(baseDir, cronConfigFile);
|
||||
if (!Path.IsPathRooted(watcherConfigFile)) watcherConfigFile = Path.Combine(baseDir, watcherConfigFile);
|
||||
|
||||
var options = new SchedulerOptions
|
||||
{
|
||||
ConfigFile = cronConfigFile,
|
||||
WatcherConfigFile = watcherConfigFile,
|
||||
WebPrefix = Get("Scheduler.WebPrefix", "http://127.0.0.1:8095/"),
|
||||
WebUser = Get("Scheduler.WebUser", "admin"),
|
||||
WebPassword = Get("Scheduler.WebPassword", "admin")
|
||||
};
|
||||
|
||||
var invoker = new ImsCustomFunctionInvoker();
|
||||
try
|
||||
{
|
||||
invoker.Connect();
|
||||
return new SchedulerRuntime(invoker, options, invoker);
|
||||
}
|
||||
catch
|
||||
{
|
||||
invoker.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static string Get(string key, string fallback)
|
||||
{
|
||||
string value = ConfigurationManager.AppSettings[key];
|
||||
return String.IsNullOrWhiteSpace(value) ? fallback : value.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user