Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/13 13:13:41 (12 years ago)
Author:
spimming
Message:

#1888:

  • Merged revisions from trunk
Location:
branches/OaaS
Files:
6 edited
4 copied

Legend:

Unmodified
Added
Removed
  • branches/OaaS

  • branches/OaaS/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.Designer.cs

    r7967 r9363  
    1 namespace HeuristicLab.Clients.Hive.Administrator.Views {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22namespace HeuristicLab.Clients.Hive.Administrator.Views {
    223  partial class Recurrence {
    324    /// <summary>
     
    4263      this.cbTuesday = new System.Windows.Forms.CheckBox();
    4364      this.cbMonday = new System.Windows.Forms.CheckBox();
     65      this.appointmentTypeView = new HeuristicLab.Clients.Hive.Administrator.Views.DowntimeTypeView();
     66      this.gbDowntimeType = new System.Windows.Forms.GroupBox();
    4467      this.gbAppointment.SuspendLayout();
    4568      this.gbWeekly.SuspendLayout();
     69      this.gbDowntimeType.SuspendLayout();
    4670      this.SuspendLayout();
    4771      //
     
    82106      // dtpToTime
    83107      //
    84       this.dtpToTime.CustomFormat = "HH:00";
     108      this.dtpToTime.CustomFormat = "HH:mm";
    85109      this.dtpToTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    86110      this.dtpToTime.Location = new System.Drawing.Point(226, 56);
     
    109133      // dtpFromTime
    110134      //
    111       this.dtpFromTime.CustomFormat = "HH:00";
     135      this.dtpFromTime.CustomFormat = "HH:mm";
    112136      this.dtpFromTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    113137      this.dtpFromTime.Location = new System.Drawing.Point(226, 19);
     
    128152      // btSaveRecurrence
    129153      //
    130       this.btSaveRecurrence.Location = new System.Drawing.Point(2, 217);
     154      this.btSaveRecurrence.Location = new System.Drawing.Point(2, 298);
    131155      this.btSaveRecurrence.Name = "btSaveRecurrence";
    132156      this.btSaveRecurrence.Size = new System.Drawing.Size(147, 23);
     
    138162      // btCancelRecurrence
    139163      //
    140       this.btCancelRecurrence.Location = new System.Drawing.Point(241, 217);
     164      this.btCancelRecurrence.Location = new System.Drawing.Point(241, 298);
    141165      this.btCancelRecurrence.Name = "btCancelRecurrence";
    142166      this.btCancelRecurrence.Size = new System.Drawing.Size(147, 23);
     
    232256      this.cbMonday.UseVisualStyleBackColor = true;
    233257      //
     258      // appointmentTypeView
     259      //
     260      this.appointmentTypeView.DowntimeType = 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      //
    234276      // Recurrence
    235277      //
    236       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    237278      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    238       this.ClientSize = new System.Drawing.Size(393, 243);
     279      this.ClientSize = new System.Drawing.Size(393, 332);
     280      this.Controls.Add(this.gbDowntimeType);
    239281      this.Controls.Add(this.gbWeekly);
    240282      this.Controls.Add(this.btCancelRecurrence);
     
    242284      this.Controls.Add(this.gbAppointment);
    243285      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    244       this.Icon = HeuristicLab.Common.Resources.HeuristicLab.Icon;
    245286      this.Name = "Recurrence";
     287      this.ShowIcon = false;
     288      this.ShowInTaskbar = false;
    246289      this.Text = "Recurrence";
     290      this.TopMost = true;
    247291      this.gbAppointment.ResumeLayout(false);
    248292      this.gbAppointment.PerformLayout();
    249293      this.gbWeekly.ResumeLayout(false);
    250294      this.gbWeekly.PerformLayout();
     295      this.gbDowntimeType.ResumeLayout(false);
    251296      this.ResumeLayout(false);
    252297
     
    273318    private System.Windows.Forms.CheckBox cbTuesday;
    274319    private System.Windows.Forms.CheckBox cbMonday;
     320    private DowntimeTypeView appointmentTypeView;
     321    private System.Windows.Forms.GroupBox gbDowntimeType;
    275322  }
    276323}
  • branches/OaaS/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.cs

    r7259 r9363  
    5353          DateTo = dateTo,
    5454          AllDay = chbade.Checked,
    55           WeekDays = days
     55          WeekDays = days,
     56          DowntimeType = appointmentTypeView.DowntimeType
    5657        };
    5758
  • branches/OaaS/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r8089 r9363  
    437437
    438438      try {
     439        if (!Access.UserInformation.Instance.UserExists) {
     440          //do a refresh just in case that the user has changed his usr and pwd in between
     441          Access.UserInformation.Instance.Refresh();
     442        }
    439443        HiveAdminClient.Instance.Refresh();
    440444        Content = HiveAdminClient.Instance.Resources;
  • branches/OaaS/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.Designer.cs

    r8058 r9363  
    7171      this.dvOnline.ActiveTool = drawTool1;
    7272      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)
    7575            | System.Windows.Forms.AnchorStyles.Right)));
    7676      this.dvOnline.AppointmentDuration = Calendar.AppointmentSlotDuration.SixtyMinutes;
     
    9696      // txttimeTo
    9797      //
    98       this.txttimeTo.CustomFormat = "HH:00";
     98      this.txttimeTo.CustomFormat = "HH:mm";
    9999      this.txttimeTo.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    100100      this.txttimeTo.Location = new System.Drawing.Point(164, 45);
     
    106106      // txttimeFrom
    107107      //
    108       this.txttimeFrom.CustomFormat = "HH:00";
     108      this.txttimeFrom.CustomFormat = "HH:mm";
    109109      this.txttimeFrom.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
    110110      this.txttimeFrom.Location = new System.Drawing.Point(164, 12);
     
    212212      this.btCreate.Size = new System.Drawing.Size(242, 26);
    213213      this.btCreate.TabIndex = 20;
    214       this.btCreate.Text = "Create Appointment";
    215       this.toolTip.SetToolTip(this.btCreate, "Create a new appointment in the calender");
     214      this.btCreate.Text = "Create Downtime";
     215      this.toolTip.SetToolTip(this.btCreate, "Create a new downtime in the calender");
    216216      this.btCreate.UseVisualStyleBackColor = true;
    217217      this.btCreate.Click += new System.EventHandler(this.btCreate_Click);
     
    247247      // mcOnline
    248248      //
    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)
    250250            | System.Windows.Forms.AnchorStyles.Right)));
    251251      this.mcOnline.CalendarDimensions = new System.Drawing.Size(2, 1);
  • branches/OaaS/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs

    r8075 r9363  
    2525using System.Linq;
    2626using System.Windows.Forms;
    27 using System.Xml.Serialization;
    2827using Calendar;
    2928using HeuristicLab.Core;
     
    4039    }
    4140
    42     [XmlArray("Appointments")]
    43     [XmlArrayItem("HiveAppointment", typeof(HiveAppointment))]
    44     public List<HiveAppointment> offlineTimes = new List<HiveAppointment>();
     41    public List<HiveDowntime> offlineTimes = new List<HiveDowntime>();
    4542
    4643    //delegate fired, if a dialog is being closed
     
    5956
    6057    private void dvOnline_OnResolveAppointments(object sender, ResolveAppointmentsEventArgs e) {
    61       List<HiveAppointment> apps = new List<HiveAppointment>();
    62 
    63       foreach (HiveAppointment app in offlineTimes) {
     58      List<HiveDowntime> apps = new List<HiveDowntime>();
     59
     60      foreach (HiveDowntime app in offlineTimes) {
    6461        if (app.StartDate >= e.StartDate && app.StartDate <= e.EndDate && !app.Deleted) {
    6562          apps.Add(app);
     
    6865
    6966      e.Appointments.Clear();
    70       foreach (HiveAppointment app in apps) {
     67      foreach (HiveDowntime app in apps) {
    7168        e.Appointments.Add(app);
    7269      }
     
    7471
    7572    private void dvOnline_OnNewAppointment(object sender, NewAppointmentEventArgs e) {
    76       HiveAppointment 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);
    8178    }
    8279
     
    8481      offlineTimes.Clear();
    8582      if (Content != null) {
    86         foreach (Downtime app in Content) {
    87           offlineTimes.Add(ToHiveAppointment(app));
    88         }
    89       }
    90       dvOnline.Invalidate();
    91     }
    92 
    93     private bool CreateAppointment() {
     83        foreach (Downtime downtime in Content) {
     84          offlineTimes.Add(ToHiveDowntime(downtime));
     85        }
     86      }
     87      dvOnline.Invalidate();
     88    }
     89
     90    private bool CreateDowntime(DowntimeType dtType) {
    9491      DateTime from, to;
    9592
     
    9895          //whole day appointment, only dates are visible
    9996          if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to)
    100             offlineTimes.Add(CreateAppointment(from, to.AddDays(1), true));
     97            offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType));
    10198          else
    10299            MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     
    105102          if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) {
    106103            if (from.Date == to.Date)
    107               offlineTimes.Add(CreateAppointment(from, to, false));
     104              offlineTimes.Add(CreateDowntime(from, to, false, dtType));
    108105            else {
    109106              //more than 1 day selected
    110107              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));
     108                offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType));
    112109                from = from.AddDays(1);
    113110              }
    114               offlineTimes.Add(CreateAppointment(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false));
     111              offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType));
    115112            }
    116113          } else
     
    120117        return true;
    121118      } 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);
    123120        return false;
    124121      }
    125122    }
    126123
    127     private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay) {
    128       HiveAppointment 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 = "Offline";
    135       app.Recurring = false;
    136       return app;
    137     }
    138 
    139     private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId) {
    140       HiveAppointment 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 = "Offline";
    147       app.Recurring = recurring;
    148       app.RecurringId = recurringId;
    149       return app;
    150     }
    151 
    152     private void DeleteRecurringAppointment(Guid recurringId) {
    153       foreach (HiveAppointment app in offlineTimes) {
    154         if (app.RecurringId == recurringId) {
    155           app.Deleted = true;
    156         }
    157       }
    158     }
    159 
    160     private void ChangeRecurrenceAppointment(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) {
    161158      int hourfrom = int.Parse(txttimeFrom.Text.Substring(0, txttimeFrom.Text.IndexOf(':')));
    162159      int hourTo = int.Parse(txttimeTo.Text.Substring(0, txttimeTo.Text.IndexOf(':')));
    163       List<HiveAppointment> recurringAppointments = offlineTimes.Where(appointment => ((HiveAppointment)appointment).RecurringId == recurringId).ToList();
    164       recurringAppointments.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0));
    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);
     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));
    169163    }
    170164
    171165    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) {
     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) {
    176170      DateTime incDate = dateFrom;
    177171      Guid guid = Guid.NewGuid();
     
    179173      while (incDate.Date <= dateTo.Date) {
    180174        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));
     175          offlineTimes.Add(CreateDowntime(incDate, new DateTime(incDate.Year, incDate.Month, incDate.Day, dateTo.Hour, dateTo.Minute, 0), allDay, true, guid, appointmentType));
    182176        incDate = incDate.AddDays(1);
    183177      }
     
    187181
    188182    private void btbDelete_Click(object sender, EventArgs e) {
    189       HiveAppointment selectedAppointment = (HiveAppointment)dvOnline.SelectedAppointment;
     183      HiveDowntime selectedDowntime = (HiveDowntime)dvOnline.SelectedAppointment;
    190184      if (dvOnline.SelectedAppointment != null) {
    191         if (!selectedAppointment.Recurring)
    192           DeleteAppointment();
     185        if (!selectedDowntime.Recurring)
     186          DeleteDowntime();
    193187        else {
    194188          DialogResult res = MessageBox.Show("Delete all events in this series?", "Delete recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    195189          if (res != DialogResult.Yes)
    196             DeleteAppointment();
     190            DeleteDowntime();
    197191          else
    198             DeleteRecurringAppointment(selectedAppointment.RecurringId);
    199         }
    200       }
    201       dvOnline.Invalidate();
    202     }
    203 
    204     private void DeleteAppointment() {
     192            DeleteRecurringDowntime(selectedDowntime.RecurringId);
     193        }
     194      }
     195      dvOnline.Invalidate();
     196    }
     197
     198    private void DeleteDowntime() {
    205199      try {
    206         HiveAppointment app = offlineTimes.First(s => s.Equals((HiveAppointment)dvOnline.SelectedAppointment));
    207         app.Deleted = true;
     200        HiveDowntime downtime = offlineTimes.First(s => s.Equals((HiveDowntime)dvOnline.SelectedAppointment));
     201        downtime.Deleted = true;
    208202      }
    209203      catch (InvalidOperationException) {
     
    242236
    243237    private void btnClearCal_Click(object sender, System.EventArgs e) {
    244       foreach (HiveAppointment app in offlineTimes) {
     238      foreach (HiveDowntime app in offlineTimes) {
    245239        app.Deleted = true;
    246240      }
     
    259253        txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString();
    260254        txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString();
    261         btCreate.Text = "Create Appointment";
     255        btCreate.Text = "Create Downtime";
    262256      }
    263257
     
    274268      if (dvOnline.Selection == SelectionType.None) {
    275269        //also change the caption of the save button
    276         btCreate.Text = "Create Appointment";
     270        btCreate.Text = "Create Downtime";
    277271      }
    278272    }
     
    284278    private void btCreate_Click(object sender, EventArgs e) {
    285279      if (dvOnline.Selection != SelectionType.Appointment) {
    286         CreateAppointment();
     280        DowntimeType dtType;
     281        DialogResult result;
     282        DowntimeTypeDialog dialog = new DowntimeTypeDialog();
     283        result = dialog.ShowDialog(this);
     284        dtType = dialog.AppointmentType;
     285        dialog.Dispose();
     286        if (result == DialogResult.Cancel) return;
     287        CreateDowntime(dtType);
    287288      } else {
    288289        //now we want to change an existing appointment
    289290        if (!dvOnline.SelectedAppointment.Recurring) {
    290           if (CreateAppointment())
    291             DeleteAppointment();
     291          if (CreateDowntime(GetDowntimeTypeOfSelectedDowntime()))
     292            DeleteDowntime();
    292293        } else {
    293294          //change recurring appointment
     
    295296          DialogResult res = MessageBox.Show("Change all events in this series?", "Change recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    296297          if (res != DialogResult.Yes) {
    297             if (CreateAppointment())
    298               DeleteAppointment();
     298            if (CreateDowntime(GetDowntimeTypeOfSelectedDowntime()))
     299              DeleteDowntime();
    299300          } else
    300             ChangeRecurrenceAppointment(((HiveAppointment)dvOnline.SelectedAppointment).RecurringId);
     301            ChangeRecurrenceDowntime(((HiveDowntime)dvOnline.SelectedAppointment).RecurringId);
    301302        }
    302303      }
     
    312313    private void btnSaveCal_Click(object sender, EventArgs e) {
    313314      if (HiveAdminClient.Instance.DowntimeForResourceId == null || HiveAdminClient.Instance.DowntimeForResourceId == Guid.Empty) {
    314         MessageBox.Show("You have to save the goup 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);
    315316      } else {
    316         List<Downtime> appointments = new List<Downtime>();
    317         foreach (HiveAppointment app in offlineTimes) {
    318           if (app.Deleted && app.Id != Guid.Empty) {
    319             HiveAdminClient.Delete(ToDowntime(app));
    320           } else if (app.Changed || app.Id == null || app.Id == Guid.Empty) {
    321             Downtime dt = ToDowntime(app);
    322             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);
    323324          }
    324325        }
    325         foreach (Downtime dt in appointments) {
     326        foreach (Downtime dt in downtimes) {
    326327          dt.Store();
    327328        }
     
    329330    }
    330331
    331     private HiveAppointment ToHiveAppointment(Downtime downtime) {
    332       HiveAppointment app = new HiveAppointment {
     332    private HiveDowntime ToHiveDowntime(Downtime downtime) {
     333      HiveDowntime hiveDowntime = new HiveDowntime {
    333334        AllDayEvent = downtime.AllDayEvent,
    334335        EndDate = downtime.EndDate,
     
    339340        BorderColor = Color.Red,
    340341        Locked = true,
    341         Subject = "Offline",
     342        Subject = downtime.DowntimeType.ToString(),
    342343        Changed = downtime.Modified,
    343344        Id = downtime.Id
    344345      };
    345       return app;
    346     }
    347 
    348     private Downtime ToDowntime(HiveAppointment app) {
     346      return hiveDowntime;
     347    }
     348
     349    private Downtime ToDowntime(HiveDowntime hiveDowntime) {
    349350      Downtime downtime = new Downtime {
    350         AllDayEvent = app.AllDayEvent,
    351         EndDate = app.EndDate,
    352         StartDate = app.StartDate,
    353         Recurring = app.Recurring,
    354         RecurringId = app.RecurringId,
     351        AllDayEvent = hiveDowntime.AllDayEvent,
     352        EndDate = hiveDowntime.EndDate,
     353        StartDate = hiveDowntime.StartDate,
     354        Recurring = hiveDowntime.Recurring,
     355        RecurringId = hiveDowntime.RecurringId,
    355356        ResourceId = HiveAdminClient.Instance.DowntimeForResourceId,
    356         Id = app.Id
     357        Id = hiveDowntime.Id,
     358        DowntimeType = (DowntimeType)Enum.Parse(typeof(DowntimeType), hiveDowntime.Subject)
    357359      };
    358360      return downtime;
    359361    }
     362
     363    private DowntimeType GetDowntimeTypeOfSelectedDowntime() {
     364      return (DowntimeType)Enum.Parse(typeof(DowntimeType), ((HiveDowntime)dvOnline.SelectedAppointment).Subject);
     365    }
    360366  }
    361367}
Note: See TracChangeset for help on using the changeset viewer.