public static string BuildJsonFromArgs(IJobArgs args) { if (args == null) return ""; var keys = new List<string>(args.GetKeys()); if (keys.Count == 0) return ""; var sb = new StringBuilder(); sb.Append("["); bool firstkey = true; foreach (var k in keys) { foreach (var v in args.GetValues(k)) { if (!firstkey) sb.Append(","); sb.Append("\""); sb.Append(EscapeJson(k + ":=" + v)); sb.Append("\""); firstkey = false; } } sb.Append("]"); return sb.ToString(); }
public ClientConfig() { ManagerUrl = ""; Assemblies = new List<string>(); JobType = ""; JobArgs = new DefaultJobArgs(); Instances = 5; }
public ManagerJob() { ID = ""; // newjob.ID = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10); CallbackUrl = ""; Workers = new List<WorkerInfo>(); State = ManagerJobState.Preparing; JobType = ""; JobArgs = new DefaultJobArgs(); Timeout = 5; Assemblies = new Dictionary<string, byte[]>(); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceJob{T}" /> class. /// </summary> /// <param name="invokeMethodName">Name of the invoke method.</param> /// <param name="args">The arguments.</param> /// <exception cref="ArgumentNullException">invokeMethodName</exception> /// <exception cref="ServiceInitializationException"></exception> public ServiceJob(string invokeMethodName, IJobArgs args) { if (invokeMethodName == null) { throw new ArgumentNullException(nameof(invokeMethodName)); } JobClassType = typeof(T); JobArgs = args ?? throw new ArgumentNullException(nameof(args)); InvokeMethodInfo = BuildInvokeMethodInfo(invokeMethodName); }
public WorkerJob() { // LoadedAssemblies = new List<Assembly>(); SandboxPath = Path.GetTempPath() + Path.DirectorySeparatorChar + "wa-" + Guid.NewGuid().ToString(); if (!Directory.Exists(SandboxPath)) Directory.CreateDirectory(SandboxPath); var setup = new AppDomainSetup(); setup.ApplicationBase = SandboxPath; var perms = new PermissionSet(System.Security.Permissions.PermissionState.Unrestricted); Sandbox = AppDomain.CreateDomain("Temp sandbox", null, setup, perms, new StrongName[] { }); JobType = ""; JobArgs = new DefaultJobArgs(); }
/// <summary> /// Initializes a new instance of the <see cref="CrontabSchedulerJob{T}" /> class. /// </summary> /// <param name="settings">The settings.</param> /// <param name="crontabProcessorFactory">The crontab processor factory.</param> /// <param name="invokeMethodName">Name of the invoke method.</param> /// <param name="args">The job arguments.</param> /// <exception cref="ArgumentNullException">settings /// or /// invokeMethodName</exception> /// <exception cref="SchedulerInitializationException"></exception> /// <exception cref="ArgumentNullException">settings /// or /// invokeMethodName</exception> public CrontabSchedulerJob(ISchedulerJobSettings settings, ICrontabProcessorFactory crontabProcessorFactory, string invokeMethodName, IJobArgs args) : base(invokeMethodName, args) { if (invokeMethodName == null) { throw new ArgumentNullException(nameof(invokeMethodName)); } Settings = settings ?? throw new ArgumentNullException(nameof(settings)); _crontabProcessorFactory = crontabProcessorFactory ?? throw new ArgumentNullException(nameof(crontabProcessorFactory)); }
public void Run(IJobArgs args) { if (_isRunning) { throw new SimplifyWindowsServicesException("TwoSecondStepProcessor is running a duplicate!"); } _isRunning = true; Trace.WriteLine("TwoSecondStepProcessor launched"); Trace.WriteLine($"TwoSecondStepProcessor args startup args is: {args.StartupArgs}"); Trace.WriteLine($"TwoSecondStepProcessor args service name is: {args.ServiceName}"); Thread.Sleep(3670); _isRunning = false; }
public static void FillArgsFromJson(IJobArgs args, object jsonvalue) { if( jsonvalue == null ) return; var strings = jsonvalue as string[]; if( strings == null ) return; foreach(var s in strings) { var i = s.IndexOf(":="); if( i == -1 ) continue; args.Add(s.Substring(0,i), s.Substring(i+2)); } }
public string RunJob(AppDomain domain, string jobtype, IJobArgs args) { string ret = ""; Console.WriteLine("SandboxProxy: Trying to create a " + jobtype); try { var aa = jobtype.Split(','); var t = domain.CreateInstanceAndUnwrap(aa[1].Trim(), aa[0].Trim()) as ISandboxedJob; // var t = Activator.CreateInstance(Type.GetType(jobtype)) as ISandboxedJob; Console.WriteLine("Created type " + t); Console.WriteLine("---------------------------------------------------------"); ret = t.Run(args); Console.WriteLine("---------------------------------------------------------"); } catch (Exception z) { Console.WriteLine(z); } return ret; }