Changeset 9016
- Timestamp:
- 12/10/12 13:33:47 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3
- Files:
-
- 5 added
- 4 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj
r8957 r9016 104 104 <ItemGroup> 105 105 <Compile Include="HiveRoles.cs" /> 106 <Compile Include="Views\ AppointmentTypeDialog.cs">106 <Compile Include="Views\DowntimeTypeDialog.cs"> 107 107 <SubType>Form</SubType> 108 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>109 <Compile Include="Views\DowntimeTypeDialog.Designer.cs"> 110 <DependentUpon>DowntimeTypeDialog.cs</DependentUpon> 111 </Compile> 112 <Compile Include="Views\DowntimeTypeView.cs"> 113 <SubType>UserControl</SubType> 114 </Compile> 115 <Compile Include="Views\DowntimeTypeView.Designer.cs"> 116 <DependentUpon>DowntimeTypeView.cs</DependentUpon> 117 117 </Compile> 118 118 <Compile Include="Views\HiveAdministratorView.cs"> … … 122 122 <DependentUpon>HiveAdministratorView.cs</DependentUpon> 123 123 </Compile> 124 <Compile Include="Hive Appointment.cs">124 <Compile Include="HiveDowntime.cs"> 125 125 <SubType>Code</SubType> 126 126 </Compile> -
trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/RecurrentEvent.cs
r8957 r9016 29 29 public bool AllDay { get; set; } 30 30 public HashSet<DayOfWeek> WeekDays { get; set; } 31 public DowntimeType AppointmentType { get; set; }31 public DowntimeType DowntimeType { get; set; } 32 32 } 33 33 } -
trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.Designer.cs
r8957 r9016 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();65 this.appointmentTypeView = new HeuristicLab.Clients.Hive.Administrator.Views.DowntimeTypeView(); 66 66 this.gbDowntimeType = new System.Windows.Forms.GroupBox(); 67 67 this.gbAppointment.SuspendLayout(); … … 258 258 // appointmentTypeView 259 259 // 260 this.appointmentTypeView. AppointmentType = HeuristicLab.Clients.Hive.DowntimeType.Offline;260 this.appointmentTypeView.DowntimeType = HeuristicLab.Clients.Hive.DowntimeType.Offline; 261 261 this.appointmentTypeView.Location = new System.Drawing.Point(10, 19); 262 262 this.appointmentTypeView.Name = "appointmentTypeView"; … … 318 318 private System.Windows.Forms.CheckBox cbTuesday; 319 319 private System.Windows.Forms.CheckBox cbMonday; 320 private AppointmentTypeView appointmentTypeView;320 private DowntimeTypeView appointmentTypeView; 321 321 private System.Windows.Forms.GroupBox gbDowntimeType; 322 322 } -
trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.cs
r8957 r9016 54 54 AllDay = chbade.Checked, 55 55 WeekDays = days, 56 AppointmentType = appointmentTypeView.AppointmentType56 DowntimeType = appointmentTypeView.DowntimeType 57 57 }; 58 58 -
trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.Designer.cs
r8058 r9016 71 71 this.dvOnline.ActiveTool = drawTool1; 72 72 this.dvOnline.AmPmDisplay = false; 73 this.dvOnline.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 74 | System.Windows.Forms.AnchorStyles.Left) 73 this.dvOnline.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 74 | System.Windows.Forms.AnchorStyles.Left) 75 75 | System.Windows.Forms.AnchorStyles.Right))); 76 76 this.dvOnline.AppointmentDuration = Calendar.AppointmentSlotDuration.SixtyMinutes; … … 212 212 this.btCreate.Size = new System.Drawing.Size(242, 26); 213 213 this.btCreate.TabIndex = 20; 214 this.btCreate.Text = "Create Appointment";215 this.toolTip.SetToolTip(this.btCreate, "Create a new appointmentin the calender");214 this.btCreate.Text = "Create Downtime"; 215 this.toolTip.SetToolTip(this.btCreate, "Create a new downtime in the calender"); 216 216 this.btCreate.UseVisualStyleBackColor = true; 217 217 this.btCreate.Click += new System.EventHandler(this.btCreate_Click); … … 247 247 // mcOnline 248 248 // 249 this.mcOnline.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 249 this.mcOnline.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 250 250 | System.Windows.Forms.AnchorStyles.Right))); 251 251 this.mcOnline.CalendarDimensions = new System.Drawing.Size(2, 1); -
trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r8957 r9016 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using System.Xml.Serialization;28 27 using Calendar; 29 28 using HeuristicLab.Core; … … 40 39 } 41 40 42 [XmlArray("Appointments")] 43 [XmlArrayItem("HiveAppointment", typeof(HiveAppointment))] 44 public List<HiveAppointment> offlineTimes = new List<HiveAppointment>(); 41 public List<HiveDowntime> offlineTimes = new List<HiveDowntime>(); 45 42 46 43 //delegate fired, if a dialog is being closed … … 59 56 60 57 private void dvOnline_OnResolveAppointments(object sender, ResolveAppointmentsEventArgs e) { 61 List<Hive Appointment> apps = new List<HiveAppointment>();62 63 foreach (Hive Appointmentapp in offlineTimes) {58 List<HiveDowntime> apps = new List<HiveDowntime>(); 59 60 foreach (HiveDowntime app in offlineTimes) { 64 61 if (app.StartDate >= e.StartDate && app.StartDate <= e.EndDate && !app.Deleted) { 65 62 apps.Add(app); … … 68 65 69 66 e.Appointments.Clear(); 70 foreach (Hive Appointmentapp in apps) {67 foreach (HiveDowntime app in apps) { 71 68 e.Appointments.Add(app); 72 69 } … … 74 71 75 72 private void dvOnline_OnNewAppointment(object sender, NewAppointmentEventArgs e) { 76 Hive Appointment Appointment = new HiveAppointment();77 78 Appointment.StartDate = e.StartDate;79 Appointment.EndDate = e.EndDate;80 offlineTimes.Add( Appointment);73 HiveDowntime downtime = new HiveDowntime(); 74 75 downtime.StartDate = e.StartDate; 76 downtime.EndDate = e.EndDate; 77 offlineTimes.Add(downtime); 81 78 } 82 79 … … 84 81 offlineTimes.Clear(); 85 82 if (Content != null) { 86 foreach (Downtime appin Content) {87 offlineTimes.Add(ToHive Appointment(app));88 } 89 } 90 dvOnline.Invalidate(); 91 } 92 93 private bool Create Appointment(DowntimeType dtType) {83 foreach (Downtime downtime in Content) { 84 offlineTimes.Add(ToHiveDowntime(downtime)); 85 } 86 } 87 dvOnline.Invalidate(); 88 } 89 90 private bool CreateDowntime(DowntimeType dtType) { 94 91 DateTime from, to; 95 92 … … 98 95 //whole day appointment, only dates are visible 99 96 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) 100 offlineTimes.Add(Create Appointment(from, to.AddDays(1), true, dtType));97 offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType)); 101 98 else 102 99 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); … … 105 102 if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) { 106 103 if (from.Date == to.Date) 107 offlineTimes.Add(Create Appointment(from, to, false, dtType));104 offlineTimes.Add(CreateDowntime(from, to, false, dtType)); 108 105 else { 109 106 //more than 1 day selected 110 107 while (from.Date != to.Date) { 111 offlineTimes.Add(Create Appointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType));108 offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); 112 109 from = from.AddDays(1); 113 110 } 114 offlineTimes.Add(Create Appointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType));111 offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); 115 112 } 116 113 } else … … 120 117 return true; 121 118 } else { 122 MessageBox.Show("Error in create appointment, please fill out all textboxes!", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error);119 MessageBox.Show("Error creating downtime, please fill out all textboxes!", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 123 120 return false; 124 121 } 125 122 } 126 123 127 private Hive Appointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, DowntimeType downtimeType) {128 Hive Appointment app = new HiveAppointment();129 app.StartDate = startDate;130 app.EndDate = endDate;131 app.AllDayEvent = allDay;132 app.BorderColor = Color.Red;133 app.Locked = true;134 app.Subject = downtimeType.ToString();135 app.Recurring = false;136 return app;137 } 138 139 private Hive Appointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId, DowntimeType downtimeType) {140 Hive Appointment app = new HiveAppointment();141 app.StartDate = startDate;142 app.EndDate = endDate;143 app.AllDayEvent = allDay;144 app.BorderColor = Color.Red;145 app.Locked = true;146 app.Subject = downtimeType.ToString();147 app.Recurring = recurring;148 app.RecurringId = recurringId;149 return app;150 } 151 152 private void DeleteRecurring Appointment(Guid recurringId) {153 foreach (Hive Appointment appin offlineTimes) {154 if ( app.RecurringId == recurringId) {155 app.Deleted = true;156 } 157 } 158 } 159 160 private void ChangeRecurrence Appointment(Guid recurringId) {124 private HiveDowntime CreateDowntime(DateTime startDate, DateTime endDate, bool allDay, DowntimeType downtimeType) { 125 HiveDowntime downtime = new HiveDowntime(); 126 downtime.StartDate = startDate; 127 downtime.EndDate = endDate; 128 downtime.AllDayEvent = allDay; 129 downtime.BorderColor = Color.Red; 130 downtime.Locked = true; 131 downtime.Subject = downtimeType.ToString(); 132 downtime.Recurring = false; 133 return downtime; 134 } 135 136 private HiveDowntime CreateDowntime(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId, DowntimeType downtimeType) { 137 HiveDowntime downtime = new HiveDowntime(); 138 downtime.StartDate = startDate; 139 downtime.EndDate = endDate; 140 downtime.AllDayEvent = allDay; 141 downtime.BorderColor = Color.Red; 142 downtime.Locked = true; 143 downtime.Subject = downtimeType.ToString(); 144 downtime.Recurring = recurring; 145 downtime.RecurringId = recurringId; 146 return downtime; 147 } 148 149 private void DeleteRecurringDowntime(Guid recurringId) { 150 foreach (HiveDowntime downtime in offlineTimes) { 151 if (downtime.RecurringId == recurringId) { 152 downtime.Deleted = true; 153 } 154 } 155 } 156 157 private void ChangeRecurrenceDowntime(Guid recurringId) { 161 158 int hourfrom = int.Parse(txttimeFrom.Text.Substring(0, txttimeFrom.Text.IndexOf(':'))); 162 159 int hourTo = int.Parse(txttimeTo.Text.Substring(0, txttimeTo.Text.IndexOf(':'))); 163 List<Hive Appointment> recurringAppointments = offlineTimes.Where(appointment => ((HiveAppointment)appointment).RecurringId == recurringId).ToList();164 recurring Appointments.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0));165 recurring Appointments.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, hourTo, 0, 0));160 List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList(); 161 recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0)); 162 recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, hourTo, 0, 0)); 166 163 } 167 164 168 165 public void DialogClosed(RecurrentEvent e) { 169 CreateDailyRecurrence Appointments(e.DateFrom, e.DateTo, e.AllDay, e.WeekDays, e.AppointmentType);170 } 171 172 private void CreateDailyRecurrence Appointments(DateTime dateFrom, DateTime dateTo, bool allDay, HashSet<DayOfWeek> daysOfWeek, DowntimeType appointmentType) {166 CreateDailyRecurrenceDowntimes(e.DateFrom, e.DateTo, e.AllDay, e.WeekDays, e.DowntimeType); 167 } 168 169 private void CreateDailyRecurrenceDowntimes(DateTime dateFrom, DateTime dateTo, bool allDay, HashSet<DayOfWeek> daysOfWeek, DowntimeType appointmentType) { 173 170 DateTime incDate = dateFrom; 174 171 Guid guid = Guid.NewGuid(); … … 176 173 while (incDate.Date <= dateTo.Date) { 177 174 if (daysOfWeek.Contains(incDate.Date.DayOfWeek)) 178 offlineTimes.Add(Create Appointment(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid, appointmentType));175 offlineTimes.Add(CreateDowntime(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid, appointmentType)); 179 176 incDate = incDate.AddDays(1); 180 177 } … … 184 181 185 182 private void btbDelete_Click(object sender, EventArgs e) { 186 Hive Appointment selectedAppointment = (HiveAppointment)dvOnline.SelectedAppointment;183 HiveDowntime selectedDowntime = (HiveDowntime)dvOnline.SelectedAppointment; 187 184 if (dvOnline.SelectedAppointment != null) { 188 if (!selected Appointment.Recurring)189 Delete Appointment();185 if (!selectedDowntime.Recurring) 186 DeleteDowntime(); 190 187 else { 191 188 DialogResult res = MessageBox.Show("Delete all events in this series?", "Delete recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 192 189 if (res != DialogResult.Yes) 193 Delete Appointment();190 DeleteDowntime(); 194 191 else 195 DeleteRecurring Appointment(selectedAppointment.RecurringId);196 } 197 } 198 dvOnline.Invalidate(); 199 } 200 201 private void Delete Appointment() {192 DeleteRecurringDowntime(selectedDowntime.RecurringId); 193 } 194 } 195 dvOnline.Invalidate(); 196 } 197 198 private void DeleteDowntime() { 202 199 try { 203 Hive Appointment app = offlineTimes.First(s => s.Equals((HiveAppointment)dvOnline.SelectedAppointment));204 app.Deleted = true;200 HiveDowntime downtime = offlineTimes.First(s => s.Equals((HiveDowntime)dvOnline.SelectedAppointment)); 201 downtime.Deleted = true; 205 202 } 206 203 catch (InvalidOperationException) { … … 239 236 240 237 private void btnClearCal_Click(object sender, System.EventArgs e) { 241 foreach (Hive Appointmentapp in offlineTimes) {238 foreach (HiveDowntime app in offlineTimes) { 242 239 app.Deleted = true; 243 240 } … … 256 253 txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString(); 257 254 txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString(); 258 btCreate.Text = "Create Appointment";255 btCreate.Text = "Create Downtime"; 259 256 } 260 257 … … 271 268 if (dvOnline.Selection == SelectionType.None) { 272 269 //also change the caption of the save button 273 btCreate.Text = "Create Appointment";270 btCreate.Text = "Create Downtime"; 274 271 } 275 272 } … … 283 280 DowntimeType dtType; 284 281 DialogResult result; 285 AppointmentTypeDialog dialog = new AppointmentTypeDialog();282 DowntimeTypeDialog dialog = new DowntimeTypeDialog(); 286 283 result = dialog.ShowDialog(this); 287 284 dtType = dialog.AppointmentType; 288 285 dialog.Dispose(); 289 286 if (result == DialogResult.Cancel) return; 290 Create Appointment(dtType);287 CreateDowntime(dtType); 291 288 } else { 292 289 //now we want to change an existing appointment 293 290 if (!dvOnline.SelectedAppointment.Recurring) { 294 if (Create Appointment(GetDowntimeTypeOfSelectedAppointment()))295 Delete Appointment();291 if (CreateDowntime(GetDowntimeTypeOfSelectedDowntime())) 292 DeleteDowntime(); 296 293 } else { 297 294 //change recurring appointment … … 299 296 DialogResult res = MessageBox.Show("Change all events in this series?", "Change recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 300 297 if (res != DialogResult.Yes) { 301 if (Create Appointment(GetDowntimeTypeOfSelectedAppointment()))302 Delete Appointment();298 if (CreateDowntime(GetDowntimeTypeOfSelectedDowntime())) 299 DeleteDowntime(); 303 300 } else 304 ChangeRecurrence Appointment(((HiveAppointment)dvOnline.SelectedAppointment).RecurringId);301 ChangeRecurrenceDowntime(((HiveDowntime)dvOnline.SelectedAppointment).RecurringId); 305 302 } 306 303 } … … 316 313 private void btnSaveCal_Click(object sender, EventArgs e) { 317 314 if (HiveAdminClient.Instance.DowntimeForResourceId == null || HiveAdminClient.Instance.DowntimeForResourceId == Guid.Empty) { 318 MessageBox.Show("You have to save the g oup before you can save the schedule. ", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Stop);315 MessageBox.Show("You have to save the group before you can save the schedule. ", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Stop); 319 316 } else { 320 List<Downtime> appointments = new List<Downtime>();321 foreach (Hive Appointment appin offlineTimes) {322 if ( app.Deleted && app.Id != Guid.Empty) {323 HiveAdminClient.Delete(ToDowntime( app));324 } else if ( app.Changed || app.Id == null || app.Id == Guid.Empty) {325 Downtime dt = ToDowntime( app);326 appointments.Add(dt);317 List<Downtime> downtimes = new List<Downtime>(); 318 foreach (HiveDowntime downtime in offlineTimes) { 319 if (downtime.Deleted && downtime.Id != Guid.Empty) { 320 HiveAdminClient.Delete(ToDowntime(downtime)); 321 } else if (downtime.Changed || downtime.Id == null || downtime.Id == Guid.Empty) { 322 Downtime dt = ToDowntime(downtime); 323 downtimes.Add(dt); 327 324 } 328 325 } 329 foreach (Downtime dt in appointments) {326 foreach (Downtime dt in downtimes) { 330 327 dt.Store(); 331 328 } … … 333 330 } 334 331 335 private Hive Appointment ToHiveAppointment(Downtime downtime) {336 Hive Appointment app = new HiveAppointment{332 private HiveDowntime ToHiveDowntime(Downtime downtime) { 333 HiveDowntime app = new HiveDowntime { 337 334 AllDayEvent = downtime.AllDayEvent, 338 335 EndDate = downtime.EndDate, … … 350 347 } 351 348 352 private Downtime ToDowntime(Hive Appointmentapp) {349 private Downtime ToDowntime(HiveDowntime app) { 353 350 Downtime downtime = new Downtime { 354 351 AllDayEvent = app.AllDayEvent, … … 364 361 } 365 362 366 private DowntimeType GetDowntimeTypeOfSelected Appointment() {367 return (DowntimeType)Enum.Parse(typeof(DowntimeType), ((Hive Appointment)dvOnline.SelectedAppointment).Subject);363 private DowntimeType GetDowntimeTypeOfSelectedDowntime() { 364 return (DowntimeType)Enum.Parse(typeof(DowntimeType), ((HiveDowntime)dvOnline.SelectedAppointment).Subject); 368 365 } 369 366 }
Note: See TracChangeset
for help on using the changeset viewer.