public ResultWithData DataFromResult(AliveResult it) { CRONExecution c; CustomData cd; switch (it.Process.ToLower()) { case "ping": var p1 = Executors.First(p => (p as PingAddress)?.NameSite == it.To); c = p1; cd = p1.CustomData; break; case "webrequest": var w1 = Executors.First(w => (w as WebAdress)?.URL == it.To); c = w1; cd = w1.CustomData; break; case "receiverdatabaseserver": var r1 = Executors.First(r => (r as DatabaseConnection)?.ConnectionString == it.To); c = r1; cd = r1.CustomData; break; case "process": var pr1 = Executors.First(p => { var r = (p as StartProcess); if (r == null) { return(false); } return(r.FileName + r.Parameters == it.To); }); c = pr1; cd = pr1.CustomData; break; default: throw new ArgumentException($"not a good process {it.Process.ToLower()}"); } var res = new CronExecutionBase(); res.CopyFrom(c); cd.UserName = this.UserName; return(new ResultWithData() { AliveResult = it, CustomData = cd, CRONExecution = res, MyType = c.baseObject().GetType().FullName }); }
public void CopyFrom(CronExecutionBase c) { this.CRON = c.CRON; this.LastRunTime = c.LastRunTime; this.NextRunTime = c.NextRunTime; }