Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9016


Ignore:
Timestamp:
12/10/12 13:33:47 (12 years ago)
Author:
ascheibe
Message:

#1986

  • added missing license headers
  • renamed appointments to downtimes
  • removed unnecessary XML attributes
  • cleaned up HiveDowntime (former HiveAppointment)
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  
    104104  <ItemGroup>
    105105    <Compile Include="HiveRoles.cs" />
    106     <Compile Include="Views\AppointmentTypeDialog.cs">
     106    <Compile Include="Views\DowntimeTypeDialog.cs">
    107107      <SubType>Form</SubType>
    108108    </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>
    117117    </Compile>
    118118    <Compile Include="Views\HiveAdministratorView.cs">
     
    122122      <DependentUpon>HiveAdministratorView.cs</DependentUpon>
    123123    </Compile>
    124     <Compile Include="HiveAppointment.cs">
     124    <Compile Include="HiveDowntime.cs">
    125125      <SubType>Code</SubType>
    126126    </Compile>
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/RecurrentEvent.cs

    r8957 r9016  
    2929    public bool AllDay { get; set; }
    3030    public HashSet<DayOfWeek> WeekDays { get; set; }
    31     public DowntimeType AppointmentType { get; set; }
     31    public DowntimeType DowntimeType { get; set; }
    3232  }
    3333}
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.Designer.cs

    r8957 r9016  
    6363      this.cbTuesday = new System.Windows.Forms.CheckBox();
    6464      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();
    6666      this.gbDowntimeType = new System.Windows.Forms.GroupBox();
    6767      this.gbAppointment.SuspendLayout();
     
    258258      // appointmentTypeView
    259259      //
    260       this.appointmentTypeView.AppointmentType = HeuristicLab.Clients.Hive.DowntimeType.Offline;
     260      this.appointmentTypeView.DowntimeType = HeuristicLab.Clients.Hive.DowntimeType.Offline;
    261261      this.appointmentTypeView.Location = new System.Drawing.Point(10, 19);
    262262      this.appointmentTypeView.Name = "appointmentTypeView";
     
    318318    private System.Windows.Forms.CheckBox cbTuesday;
    319319    private System.Windows.Forms.CheckBox cbMonday;
    320     private AppointmentTypeView appointmentTypeView;
     320    private DowntimeTypeView appointmentTypeView;
    321321    private System.Windows.Forms.GroupBox gbDowntimeType;
    322322  }
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.cs

    r8957 r9016  
    5454          AllDay = chbade.Checked,
    5555          WeekDays = days,
    56           AppointmentType = appointmentTypeView.AppointmentType
     56          DowntimeType = appointmentTypeView.DowntimeType
    5757        };
    5858
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.Designer.cs

    r8058 r9016  
    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;
     
    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);
  • trunk/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs

    r8957 r9016  
    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(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) {
    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, dtType));
     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, dtType));
     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, dtType));
     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, dtType));
     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, DowntimeType downtimeType) {
    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 = downtimeType.ToString();
    135       app.Recurring = false;
    136       return app;
    137     }
    138 
    139     private HiveAppointment CreateAppointment(DateTime startDate, DateTime endDate, bool allDay, bool recurring, Guid recurringId, DowntimeType downtimeType) {
    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 = downtimeType.ToString();
    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));
     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));
    166163    }
    167164
    168165    public void DialogClosed(RecurrentEvent e) {
    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) {
     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) {
    173170      DateTime incDate = dateFrom;
    174171      Guid guid = Guid.NewGuid();
     
    176173      while (incDate.Date <= dateTo.Date) {
    177174        if (daysOfWeek.Contains(incDate.Date.DayOfWeek))
    178           offlineTimes.Add(CreateAppointment(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));
    179176        incDate = incDate.AddDays(1);
    180177      }
     
    184181
    185182    private void btbDelete_Click(object sender, EventArgs e) {
    186       HiveAppointment selectedAppointment = (HiveAppointment)dvOnline.SelectedAppointment;
     183      HiveDowntime selectedDowntime = (HiveDowntime)dvOnline.SelectedAppointment;
    187184      if (dvOnline.SelectedAppointment != null) {
    188         if (!selectedAppointment.Recurring)
    189           DeleteAppointment();
     185        if (!selectedDowntime.Recurring)
     186          DeleteDowntime();
    190187        else {
    191188          DialogResult res = MessageBox.Show("Delete all events in this series?", "Delete recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    192189          if (res != DialogResult.Yes)
    193             DeleteAppointment();
     190            DeleteDowntime();
    194191          else
    195             DeleteRecurringAppointment(selectedAppointment.RecurringId);
    196         }
    197       }
    198       dvOnline.Invalidate();
    199     }
    200 
    201     private void DeleteAppointment() {
     192            DeleteRecurringDowntime(selectedDowntime.RecurringId);
     193        }
     194      }
     195      dvOnline.Invalidate();
     196    }
     197
     198    private void DeleteDowntime() {
    202199      try {
    203         HiveAppointment 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;
    205202      }
    206203      catch (InvalidOperationException) {
     
    239236
    240237    private void btnClearCal_Click(object sender, System.EventArgs e) {
    241       foreach (HiveAppointment app in offlineTimes) {
     238      foreach (HiveDowntime app in offlineTimes) {
    242239        app.Deleted = true;
    243240      }
     
    256253        txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString();
    257254        txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString();
    258         btCreate.Text = "Create Appointment";
     255        btCreate.Text = "Create Downtime";
    259256      }
    260257
     
    271268      if (dvOnline.Selection == SelectionType.None) {
    272269        //also change the caption of the save button
    273         btCreate.Text = "Create Appointment";
     270        btCreate.Text = "Create Downtime";
    274271      }
    275272    }
     
    283280        DowntimeType dtType;
    284281        DialogResult result;
    285         AppointmentTypeDialog dialog = new AppointmentTypeDialog();
     282        DowntimeTypeDialog dialog = new DowntimeTypeDialog();
    286283        result = dialog.ShowDialog(this);
    287284        dtType = dialog.AppointmentType;
    288285        dialog.Dispose();
    289286        if (result == DialogResult.Cancel) return;
    290         CreateAppointment(dtType);
     287        CreateDowntime(dtType);
    291288      } else {
    292289        //now we want to change an existing appointment
    293290        if (!dvOnline.SelectedAppointment.Recurring) {
    294           if (CreateAppointment(GetDowntimeTypeOfSelectedAppointment()))
    295             DeleteAppointment();
     291          if (CreateDowntime(GetDowntimeTypeOfSelectedDowntime()))
     292            DeleteDowntime();
    296293        } else {
    297294          //change recurring appointment
     
    299296          DialogResult res = MessageBox.Show("Change all events in this series?", "Change recurrences", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    300297          if (res != DialogResult.Yes) {
    301             if (CreateAppointment(GetDowntimeTypeOfSelectedAppointment()))
    302               DeleteAppointment();
     298            if (CreateDowntime(GetDowntimeTypeOfSelectedDowntime()))
     299              DeleteDowntime();
    303300          } else
    304             ChangeRecurrenceAppointment(((HiveAppointment)dvOnline.SelectedAppointment).RecurringId);
     301            ChangeRecurrenceDowntime(((HiveDowntime)dvOnline.SelectedAppointment).RecurringId);
    305302        }
    306303      }
     
    316313    private void btnSaveCal_Click(object sender, EventArgs e) {
    317314      if (HiveAdminClient.Instance.DowntimeForResourceId == null || HiveAdminClient.Instance.DowntimeForResourceId == Guid.Empty) {
    318         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);
    319316      } else {
    320         List<Downtime> appointments = new List<Downtime>();
    321         foreach (HiveAppointment app in 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);
    327324          }
    328325        }
    329         foreach (Downtime dt in appointments) {
     326        foreach (Downtime dt in downtimes) {
    330327          dt.Store();
    331328        }
     
    333330    }
    334331
    335     private HiveAppointment ToHiveAppointment(Downtime downtime) {
    336       HiveAppointment app = new HiveAppointment {
     332    private HiveDowntime ToHiveDowntime(Downtime downtime) {
     333      HiveDowntime app = new HiveDowntime {
    337334        AllDayEvent = downtime.AllDayEvent,
    338335        EndDate = downtime.EndDate,
     
    350347    }
    351348
    352     private Downtime ToDowntime(HiveAppointment app) {
     349    private Downtime ToDowntime(HiveDowntime app) {
    353350      Downtime downtime = new Downtime {
    354351        AllDayEvent = app.AllDayEvent,
     
    364361    }
    365362
    366     private DowntimeType GetDowntimeTypeOfSelectedAppointment() {
    367       return (DowntimeType)Enum.Parse(typeof(DowntimeType), ((HiveAppointment)dvOnline.SelectedAppointment).Subject);
     363    private DowntimeType GetDowntimeTypeOfSelectedDowntime() {
     364      return (DowntimeType)Enum.Parse(typeof(DowntimeType), ((HiveDowntime)dvOnline.SelectedAppointment).Subject);
    368365    }
    369366  }
Note: See TracChangeset for help on using the changeset viewer.