Changeset 8953
- Timestamp:
- 11/27/12 19:57:06 (12 years ago)
- Location:
- branches/SlaveShutdown
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SlaveShutdown/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj
r8645 r8953 104 104 <ItemGroup> 105 105 <Compile Include="HiveRoles.cs" /> 106 <Compile Include="Views\AppointmentTypeDialog.cs"> 107 <SubType>Form</SubType> 108 </Compile> 109 <Compile Include="Views\AppointmentTypeDialog.Designer.cs"> 110 <DependentUpon>AppointmentTypeDialog.cs</DependentUpon> 111 </Compile> 112 <Compile Include="Views\AppointmentTypeView.cs"> 113 <SubType>UserControl</SubType> 114 </Compile> 115 <Compile Include="Views\AppointmentTypeView.Designer.cs"> 116 <DependentUpon>AppointmentTypeView.cs</DependentUpon> 117 </Compile> 106 118 <Compile Include="Views\HiveAdministratorView.cs"> 107 119 <SubType>UserControl</SubType> -
branches/SlaveShutdown/HeuristicLab.Clients.Hive.Administrator/3.3/RecurrentEvent.cs
r7259 r8953 27 27 public DateTime DateFrom { get; set; } 28 28 public DateTime DateTo { get; set; } 29 public bool AllDay { get; set; } 29 public bool AllDay { get; set; } 30 30 public HashSet<DayOfWeek> WeekDays { get; set; } 31 public DowntimeType AppointmentType { get; set; } 31 32 } 32 33 } -
branches/SlaveShutdown/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.Designer.cs
r8924 r8953 63 63 this.cbTuesday = new System.Windows.Forms.CheckBox(); 64 64 this.cbMonday = new System.Windows.Forms.CheckBox(); 65 this.appointmentTypeView = new HeuristicLab.Clients.Hive.Administrator.Views.AppointmentTypeView(); 66 this.gbDowntimeType = new System.Windows.Forms.GroupBox(); 65 67 this.gbAppointment.SuspendLayout(); 66 68 this.gbWeekly.SuspendLayout(); 69 this.gbDowntimeType.SuspendLayout(); 67 70 this.SuspendLayout(); 68 71 // … … 149 152 // btSaveRecurrence 150 153 // 151 this.btSaveRecurrence.Location = new System.Drawing.Point(2, 2 17);154 this.btSaveRecurrence.Location = new System.Drawing.Point(2, 298); 152 155 this.btSaveRecurrence.Name = "btSaveRecurrence"; 153 156 this.btSaveRecurrence.Size = new System.Drawing.Size(147, 23); … … 159 162 // btCancelRecurrence 160 163 // 161 this.btCancelRecurrence.Location = new System.Drawing.Point(241, 2 17);164 this.btCancelRecurrence.Location = new System.Drawing.Point(241, 298); 162 165 this.btCancelRecurrence.Name = "btCancelRecurrence"; 163 166 this.btCancelRecurrence.Size = new System.Drawing.Size(147, 23); … … 253 256 this.cbMonday.UseVisualStyleBackColor = true; 254 257 // 258 // appointmentTypeView 259 // 260 this.appointmentTypeView.AppointmentType = HeuristicLab.Clients.Hive.DowntimeType.Offline; 261 this.appointmentTypeView.Location = new System.Drawing.Point(10, 19); 262 this.appointmentTypeView.Name = "appointmentTypeView"; 263 this.appointmentTypeView.Size = new System.Drawing.Size(120, 50); 264 this.appointmentTypeView.TabIndex = 45; 265 // 266 // gbDowntimeType 267 // 268 this.gbDowntimeType.Controls.Add(this.appointmentTypeView); 269 this.gbDowntimeType.Location = new System.Drawing.Point(2, 217); 270 this.gbDowntimeType.Name = "gbDowntimeType"; 271 this.gbDowntimeType.Size = new System.Drawing.Size(386, 75); 272 this.gbDowntimeType.TabIndex = 46; 273 this.gbDowntimeType.TabStop = false; 274 this.gbDowntimeType.Text = "Type of Downtime"; 275 // 255 276 // Recurrence 256 277 // 257 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);258 278 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 259 this.ClientSize = new System.Drawing.Size(393, 243); 279 this.ClientSize = new System.Drawing.Size(393, 332); 280 this.Controls.Add(this.gbDowntimeType); 260 281 this.Controls.Add(this.gbWeekly); 261 282 this.Controls.Add(this.btCancelRecurrence); … … 263 284 this.Controls.Add(this.gbAppointment); 264 285 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 265 this.Icon = HeuristicLab.Common.Resources.HeuristicLab.Icon;266 286 this.Name = "Recurrence"; 287 this.ShowIcon = false; 288 this.ShowInTaskbar = false; 267 289 this.Text = "Recurrence"; 290 this.TopMost = true; 268 291 this.gbAppointment.ResumeLayout(false); 269 292 this.gbAppointment.PerformLayout(); 270 293 this.gbWeekly.ResumeLayout(false); 271 294 this.gbWeekly.PerformLayout(); 295 this.gbDowntimeType.ResumeLayout(false); 272 296 this.ResumeLayout(false); 273 297 … … 294 318 private System.Windows.Forms.CheckBox cbTuesday; 295 319 private System.Windows.Forms.CheckBox cbMonday; 320 private AppointmentTypeView appointmentTypeView; 321 private System.Windows.Forms.GroupBox gbDowntimeType; 296 322 } 297 323 } -
branches/SlaveShutdown/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.cs
r7259 r8953 53 53 DateTo = dateTo, 54 54 AllDay = chbade.Checked, 55 WeekDays = days 55 WeekDays = days, 56 AppointmentType = appointmentTypeView.AppointmentType 56 57 }; 57 58 -
branches/SlaveShutdown/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r8075 r8953 91 91 } 92 92 93 private bool CreateAppointment( ) {93 private bool CreateAppointment(DowntimeType dtType) { 94 94 DateTime from, to; 95 95 … … 98 98 //whole day appointment, only dates are visible 99 99 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) 100 offlineTimes.Add(CreateAppointment(from, to.AddDays(1), true ));100 offlineTimes.Add(CreateAppointment(from, to.AddDays(1), true, dtType)); 101 101 else 102 102 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); … … 105 105 if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) { 106 106 if (from.Date == to.Date) 107 offlineTimes.Add(CreateAppointment(from, to, false ));107 offlineTimes.Add(CreateAppointment(from, to, false, dtType)); 108 108 else { 109 109 //more than 1 day selected 110 110 while (from.Date != to.Date) { 111 offlineTimes.Add(CreateAppointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false ));111 offlineTimes.Add(CreateAppointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); 112 112 from = from.AddDays(1); 113 113 } 114 offlineTimes.Add(CreateAppointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false ));114 offlineTimes.Add(CreateAppointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); 115 115 } 116 116 } else … … 125 125 } 126 126 127 private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay ) {127 private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, DowntimeType downtimeType) { 128 128 HiveAppointment app = new HiveAppointment(); 129 129 app.StartDate = startDate; … … 132 132 app.BorderColor = Color.Red; 133 133 app.Locked = true; 134 app.Subject = "Offline";134 app.Subject = downtimeType.ToString(); 135 135 app.Recurring = false; 136 136 return app; 137 137 } 138 138 139 private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId ) {139 private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId, DowntimeType downtimeType) { 140 140 HiveAppointment app = new HiveAppointment(); 141 141 app.StartDate = startDate; … … 144 144 app.BorderColor = Color.Red; 145 145 app.Locked = true; 146 app.Subject = "Offline";146 app.Subject = downtimeType.ToString(); 147 147 app.Recurring = recurring; 148 148 app.RecurringId = recurringId; … … 164 164 recurringAppointments.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0)); 165 165 recurringAppointments.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, hourTo, 0, 0)); 166 167 DeleteRecurringAppointment(recurringId);168 offlineTimes.AddRange(recurringAppointments);169 166 } 170 167 171 168 public void DialogClosed(RecurrentEvent e) { 172 CreateDailyRecurrenceAppointments(e.DateFrom, e.DateTo, e.AllDay, e.WeekDays );173 } 174 175 private void CreateDailyRecurrenceAppointments(DateTime dateFrom, DateTime dateTo, bool allDay, HashSet<DayOfWeek> daysOfWeek ) {169 CreateDailyRecurrenceAppointments(e.DateFrom, e.DateTo, e.AllDay, e.WeekDays, e.AppointmentType); 170 } 171 172 private void CreateDailyRecurrenceAppointments(DateTime dateFrom, DateTime dateTo, bool allDay, HashSet<DayOfWeek> daysOfWeek, DowntimeType appointmentType) { 176 173 DateTime incDate = dateFrom; 177 174 Guid guid = Guid.NewGuid(); … … 179 176 while (incDate.Date <= dateTo.Date) { 180 177 if (daysOfWeek.Contains(incDate.Date.DayOfWeek)) 181 offlineTimes.Add(CreateAppointment(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid ));178 offlineTimes.Add(CreateAppointment(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid, appointmentType)); 182 179 incDate = incDate.AddDays(1); 183 180 } … … 284 281 private void btCreate_Click(object sender, EventArgs e) { 285 282 if (dvOnline.Selection != SelectionType.Appointment) { 286 CreateAppointment(); 283 DowntimeType dtType; 284 DialogResult result; 285 AppointmentTypeDialog dialog = new AppointmentTypeDialog(); 286 result = dialog.ShowDialog(this); 287 dtType = dialog.AppointmentType; 288 dialog.Dispose(); 289 if (result == DialogResult.Cancel) return; 290 CreateAppointment(dtType); 287 291 } else { 288 292 //now we want to change an existing appointment 289 293 if (!dvOnline.SelectedAppointment.Recurring) { 290 if (CreateAppointment( ))294 if (CreateAppointment(GetDowntimeTypeOfSelectedAppointment())) 291 295 DeleteAppointment(); 292 296 } else { … … 295 299 DialogResult res = MessageBox.Show("Change all events in this series?", "Change recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 296 300 if (res != DialogResult.Yes) { 297 if (CreateAppointment( ))301 if (CreateAppointment(GetDowntimeTypeOfSelectedAppointment())) 298 302 DeleteAppointment(); 299 303 } else … … 339 343 BorderColor = Color.Red, 340 344 Locked = true, 341 Subject = "Offline",345 Subject = downtime.DowntimeType.ToString(), 342 346 Changed = downtime.Modified, 343 347 Id = downtime.Id … … 354 358 RecurringId = app.RecurringId, 355 359 ResourceId = HiveAdminClient.Instance.DowntimeForResourceId, 356 Id = app.Id 360 Id = app.Id, 361 DowntimeType = (DowntimeType)Enum.Parse(typeof(DowntimeType), app.Subject) 357 362 }; 358 363 return downtime; 359 364 } 365 366 private DowntimeType GetDowntimeTypeOfSelectedAppointment() { 367 return (DowntimeType)Enum.Parse(typeof(DowntimeType), ((HiveAppointment)dvOnline.SelectedAppointment).Subject); 368 } 360 369 } 361 370 } -
branches/SlaveShutdown/HeuristicLab.Clients.Hive.Slave/3.3/Core.cs
r8949 r8953 25 25 using System.Threading; 26 26 using System.Threading.Tasks; 27 using HeuristicLab.Clients.Hive.SlaveCore.Properties;28 27 using HeuristicLab.Common; 29 28 using HeuristicLab.Core; … … 53 52 54 53 public Core() { 55 var log = new ThreadSafeLog(S ettings.Default.MaxLogCount);54 var log = new ThreadSafeLog(SlaveCore.Properties.Settings.Default.MaxLogCount); 56 55 this.pluginManager = new PluginManager(WcfService.Instance, log); 57 56 this.taskManager = new TaskManager(pluginManager, log); … … 454 453 455 454 private void ShutdownComputer() { 456 Shutdown(); 457 458 try { 459 Process.Start(Settings.Default.ShutdownCommand); 460 } 461 catch (Exception ex) { 462 if (ServiceEventLog != null) { 463 EventLogManager.LogException(ex); 464 } else 465 throw ex; 466 } 455 var t = TS.Task.Factory.StartNew(new Action(Shutdown)); 456 t.ContinueWith(c => { 457 try { 458 Process.Start(SlaveCore.Properties.Settings.Default.ShutdownCommand); 459 } 460 catch (Exception ex) { 461 if (ServiceEventLog != null) { 462 EventLogManager.LogException(ex); 463 } else 464 throw ex; 465 } 466 }); 467 467 } 468 468 -
branches/SlaveShutdown/HeuristicLab.Clients.Hive/3.3/ServiceClients/Downtime.cs
r7259 r8953 40 40 this.ResourceId = original.ResourceId; 41 41 this.StartDate = original.StartDate; 42 this.DowntimeType = original.DowntimeType; 42 43 } 43 44 -
branches/SlaveShutdown/HeuristicLab.Services.Hive/3.3/Manager/HeartbeatManager.cs
r8945 r8953 154 154 155 155 private bool ShutdownSlaveComputer(Guid slaveId) { 156 return dao.GetParentResources(slaveId).A ll(r => dao.GetDowntimes(x => x.ResourceId == r.Id && x.DowntimeType == DA.DowntimeType.Shutdown && DateTime.Now >= x.StartDate).Count() != 0);156 return dao.GetParentResources(slaveId).Any(r => dao.GetDowntimes(x => x.ResourceId == r.Id && x.DowntimeType == DA.DowntimeType.Shutdown && (DateTime.Now >= x.StartDate) && (DateTime.Now <= x.EndDate)).Count() != 0); 157 157 } 158 158 }
Note: See TracChangeset
for help on using the changeset viewer.