public ActionResult GetAllSchedulerData() { var dal = new SchedulerDAL(); var result = dal.GetAllScheduler(); return(Json(result, JsonRequestBehavior.AllowGet)); }
private List <SchedulerModel> GetSchedulersFromDB() { List <SchedulerModel> result = new List <SchedulerModel>(); SchedulerDAL dal = new SchedulerDAL(); var schs = dal.GetAllScheduler(); foreach (var sch in schs) { SchedulerModel item = new SchedulerModel() { SchedulerId = sch.SchedulerId, SchedulerName = sch.SchedulerName, Directory = sch.Directory, FileName = sch.FileName, Port = sch.Port, IsEnable = sch.IsEnable }; result.Add(item); } return(result); }
public SchedulerDictionary ReviseAll() { SchedulerDictionary result = new SchedulerDictionary(); SchedulerManager.Instance.RefreshHosts(); var dal = new SchedulerDAL(); var schedulers = dal.GetAllScheduler(); foreach (var s in schedulers) { result.Add(s.SchedulerName, new SchedulerCollection() { SchedulerId = s.SchedulerId, List = new Dictionary <string, SchedulerModel>(), Summary = new Summary() }); } Parallel.ForEach(SchedulerManager.Instance.Hosts, host => { HttpClient client = new HttpClient(); try { var response = client.GetAsync("http://" + host + "/api/CurrentServer/ReviseAll").Result; var list = response.Content.ReadAsAsync <List <SchedulerModel> >().Result; foreach (var s in list) { result[s.SchedulerName].List.Add(host, s); } } catch (Exception ex) { foreach (var kv in result) { kv.Value.List.Add(host, null); } } }); foreach (var kv in result) { var item = kv.Value; foreach (var s in item.List) { if (s.Value == null) { item.Summary.Error++; continue; } switch (s.Value.Status) { case SchedulerStatus.None: item.Summary.None++; break; case SchedulerStatus.Stop: item.Summary.Stop++; break; case SchedulerStatus.Running: item.Summary.Running++; break; case SchedulerStatus.ProcessRunning: item.Summary.ProcessRunning++; break; default: break; } } } return(result); }