public SchedulerCollection Revise(SchedulerWebApiModel sch) { SchedulerCollection result = new SchedulerCollection() { SchedulerId = sch.schId, List = new Dictionary <string, SchedulerModel>(), Summary = new Summary() }; Parallel.ForEach(SchedulerManager.Instance.Hosts, (host) => { HttpClient client = new HttpClient(); try { var response = client.PostAsync <SchedulerWebApiModel>("http://" + host + "/api/CurrentServer/Revise", sch, new System.Net.Http.Formatting.JsonMediaTypeFormatter()).Result; var item = response.Content.ReadAsAsync <SchedulerModel>().Result; result.List.Add(host, item); } catch (Exception ex) { result.List.Add(host, null); } }); foreach (var s in result.List) { if (s.Value == null) { result.Summary.Error++; continue; } switch (s.Value.Status) { case SchedulerStatus.None: result.Summary.None++; break; case SchedulerStatus.Stop: result.Summary.Stop++; break; case SchedulerStatus.Running: result.Summary.Running++; break; case SchedulerStatus.ProcessRunning: result.Summary.ProcessRunning++; break; default: break; } } return(result); }
public CallbackModel StartScheduler(SchedulerWebApiModel sch) { try { SchedulerManager.Instance.StartScheduler(HostingEnvironment.ApplicationPhysicalPath, sch.schId); return(new CallbackModel(true)); } catch (Exception ex) { return(new CallbackModel(false, ex.Message)); } }
public CallbackModel StopScheduler(SchedulerWebApiModel sch) { try { SchedulerManager.Instance.ShutDownScheduler(sch.schId); return(new CallbackModel(true)); } catch (Exception ex) { return(new CallbackModel(false, ex.Message)); } }
public CallbackModel KillProcess(SchedulerWebApiModel sch) { try { SchedulerManager.Instance.KillProcess(sch.schId); return(new CallbackModel(true)); } catch (Exception ex) { return(new CallbackModel(false, ex.Message)); } }
public SchedulerModel ReviseHostScheduler(SchedulerWebApiModel sch) { HttpClient client = new HttpClient(); try { var response = client.PostAsync <SchedulerWebApiModel>("http://" + sch.host + "/api/CurrentServer/Revise", sch, new System.Net.Http.Formatting.JsonMediaTypeFormatter()).Result; var result = response.Content.ReadAsAsync <SchedulerModel>().Result; return(result); } catch (Exception ex) { return(null); } }
public CallbackModel KillProcess(SchedulerWebApiModel sch) { HttpClient client = new HttpClient(); try { var response = client.PostAsync <SchedulerWebApiModel>("http://" + sch.host + "/api/CurrentServer/KillProcess", sch, new System.Net.Http.Formatting.JsonMediaTypeFormatter()).Result; var result = response.Content.ReadAsAsync <CallbackModel>().Result; return(result); } catch (Exception ex) { return(new CallbackModel(false, ex.Message)); } }
public List <HostCallbackModel> StopAllHostScheduler(SchedulerWebApiModel sch) { List <HostCallbackModel> result = new List <HostCallbackModel>(); Parallel.ForEach(SchedulerManager.Instance.Hosts, (host) => { HttpClient client = new HttpClient(); try { var response = client.PostAsync <SchedulerWebApiModel>("http://" + host + "/api/CurrentServer/StopScheduler", sch, new System.Net.Http.Formatting.JsonMediaTypeFormatter()).Result; var callback = response.Content.ReadAsAsync <CallbackModel>().Result; result.Add(new HostCallbackModel(callback.result, callback.msg, host)); } catch (Exception ex) { result.Add(new HostCallbackModel(false, ex.Message, host)); } }); return(result); }
public SchedulerModel Revise(SchedulerWebApiModel sch) { return(SchedulerManager.Instance.ReviseScheduler(sch.schId)); }