private void btOK_Click(object sender, EventArgs e) { updateCurrentSchedule(); StringCollection sc = new StringCollection(); Ret = new SchedulerCollection(); for (int i = 0; i < treeView1.Nodes.Count; i++) { ScheduleDisplay sd = treeView1.Nodes[i] as ScheduleDisplay; if (sd != null) { Scheduler s = sd.Schedule; Ret.Add(s); if (sc.Contains(s.Name)) { MessageBox.Show(this, "Edit scheduler", string.Format(CultureInfo.InvariantCulture, "The schedule name [{0}] is duplicated. Please change the names.", s.Name), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { sc.Add(s.Name); } } } this.DialogResult = DialogResult.OK; }
public void LoadData(SchedulerCollection sc) { for (int i = 0; i < sc.Count; i++) { treeView1.Nodes.Add(new ScheduleDisplay((Scheduler)sc[i].Clone())); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { string str = value as string; SchedulerCollection sc = null; if (!string.IsNullOrEmpty(str)) { sc = SchedulerCollectionStringConverter.Converter.ConvertFromInvariantString(str) as SchedulerCollection; } if (sc == null) { sc = new SchedulerCollection(); } DialogSchedules dlg = new DialogSchedules(); dlg.LoadData(sc); if (edSvc.ShowDialog(dlg) == DialogResult.OK) { return(SchedulerCollectionStringConverter.Converter.ConvertToInvariantString(dlg.Ret)); } } } return(base.EditValue(context, provider, value)); }
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); }
/// <summary> /// Converts a ISchedulerCollection of ISchedulerJob into corresponding wrappers /// </summary> /// <param name="collection">Collection to be converted</param> /// <returns>A new collection with wrappers</returns> private static ISchedulerCollection ConvertJobList(ISchedulerCollection collection) { SchedulerCollection <ISchedulerJob> newCollection = new SchedulerCollection <ISchedulerJob>(); foreach (ISchedulerJob job in collection) { newCollection.Add(job); } return(newCollection); }
public void LoadData(ScheduleTimer tm) { _scheduleTimer = tm; SchedulerCollection sc = SchedulerCollectionStringConverter.Converter.ConvertFromInvariantString(_scheduleTimer.Schedules) as SchedulerCollection; if (sc != null) { for (int i = 0; i < sc.Count; i++) { treeView1.Nodes.Add(new ScheduleDisplay(sc[i])); } } }