コード例 #1
0
        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);
        }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
 public CallbackModel StopScheduler(SchedulerWebApiModel sch)
 {
     try
     {
         SchedulerManager.Instance.ShutDownScheduler(sch.schId);
         return(new CallbackModel(true));
     }
     catch (Exception ex)
     {
         return(new CallbackModel(false, ex.Message));
     }
 }
コード例 #4
0
 public CallbackModel KillProcess(SchedulerWebApiModel sch)
 {
     try
     {
         SchedulerManager.Instance.KillProcess(sch.schId);
         return(new CallbackModel(true));
     }
     catch (Exception ex)
     {
         return(new CallbackModel(false, ex.Message));
     }
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public SchedulerModel Revise(SchedulerWebApiModel sch)
 {
     return(SchedulerManager.Instance.ReviseScheduler(sch.schId));
 }