Changeset 6756
- Timestamp:
- 09/13/11 19:29:56 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 1 added
- 14 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj
r6701 r6756 153 153 </ItemGroup> 154 154 <ItemGroup> 155 <Compile Include="HiveAdministratorClient.cs" />156 155 <Compile Include="Views\HiveAdministratorView.cs"> 157 156 <SubType>UserControl</SubType> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Common/UpdateControl.cs
r6743 r6756 21 21 22 22 using System; 23 using System.Threading.Tasks; 23 24 using System.Windows.Forms; 24 25 using TS = System.Threading.Tasks; … … 58 59 59 60 Action action = new Action(PrivUpdateAction); 60 TS.Task task = new TS.Task(action); 61 task.Start(); 61 TS.Task.Factory.StartNew(action).ContinueWith((t) => { 62 throw t.Exception; 63 }, TaskContinuationOptions.OnlyOnFaulted); 62 64 } 63 65 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.cs
r6734 r6756 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core.Views;24 23 using HeuristicLab.MainForm; 24 using HeuristicLab.MainForm.WindowsForms; 25 25 26 26 namespace HeuristicLab.Clients.Hive.Administrator.Views { 27 27 [View("Hive Administrator")] 28 [Content(typeof(HiveAdmin istratorClient), IsDefaultView = true)]29 public partial class HiveAdministratorView : ItemView {30 public new HiveAdmin istratorClient Content {31 get { return (HiveAdmin istratorClient)base.Content; }28 [Content(typeof(HiveAdminClient), IsDefaultView = true)] 29 public partial class HiveAdministratorView : AsynchronousContentView { 30 public new HiveAdminClient Content { 31 get { return (HiveAdminClient)base.Content; } 32 32 set { base.Content = value; } 33 33 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/MenuItems/AdministratorMenuItem.cs
r6688 r6756 21 21 22 22 using System.Collections.Generic; 23 using HeuristicLab.Clients.Hive .Administrator;23 using HeuristicLab.Clients.Hive; 24 24 using HeuristicLab.MainForm; 25 25 … … 33 33 } 34 34 public override void Execute() { 35 MainFormManager.MainForm.ShowContent( new HiveAdministratorClient());35 MainFormManager.MainForm.ShowContent(HiveAdminClient.Instance); 36 36 } 37 37 public override int Position { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r6688 r6756 61 61 this.updateScheduleControl = new HeuristicLab.Clients.Hive.Administrator.Views.Common.UpdateControl(); 62 62 this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView(); 63 this.progressBar = new System.Windows.Forms.ProgressBar(); 63 64 ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit(); 64 65 this.splitSlaves.Panel1.SuspendLayout(); … … 86 87 // splitSlaves.Panel1 87 88 // 89 this.splitSlaves.Panel1.Controls.Add(this.progressBar); 88 90 this.splitSlaves.Panel1.Controls.Add(this.updateSlaveGroup); 89 91 this.splitSlaves.Panel1.Controls.Add(this.btnSave); … … 224 226 this.scheduleView.Name = "scheduleView"; 225 227 this.scheduleView.ReadOnly = false; 226 this.scheduleView.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");227 228 this.scheduleView.Size = new System.Drawing.Size(568, 473); 228 229 this.scheduleView.TabIndex = 0; 230 // 231 // progressBar 232 // 233 this.progressBar.Location = new System.Drawing.Point(176, 3); 234 this.progressBar.Name = "progressBar"; 235 this.progressBar.Size = new System.Drawing.Size(70, 23); 236 this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; 237 this.progressBar.TabIndex = 7; 229 238 // 230 239 // ResourcesView … … 261 270 private System.Windows.Forms.Button btnSave; 262 271 private UpdateControl updateSlaveGroup; 272 private System.Windows.Forms.ProgressBar progressBar; 263 273 } 264 274 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r6734 r6756 23 23 using System.Drawing; 24 24 using System.Linq; 25 using System.Threading; 26 using System.Threading.Tasks; 25 27 using System.Windows.Forms; 26 28 using HeuristicLab.Clients.Hive.Views; … … 28 30 using HeuristicLab.Core.Views; 29 31 using HeuristicLab.MainForm; 32 using TS = System.Threading.Tasks; 30 33 31 34 namespace HeuristicLab.Clients.Hive.Administrator.Views { 32 [View("Resources View")]35 [View("Resources View")] 33 36 [Content(typeof(IItemList<Resource>), IsDefaultView = true)] 34 public partial class ResourcesView : ItemView {37 public partial class ResourcesView : ItemView, IDisposable { 35 38 public new IItemList<Resource> Content { 36 39 get { return (IItemList<Resource>)base.Content; } … … 41 44 private const int slaveImageIndex = 0; 42 45 private const int slaveGroupImageIndex = 1; 46 private TS.Task progressTask; 47 private bool stopProgressTask; 43 48 44 49 … … 47 52 treeSlaveGroup.ImageList.Images.Add(HiveImageLibrary.Slave); 48 53 treeSlaveGroup.ImageList.Images.Add(HiveImageLibrary.SlaveGroup); 54 //TODO: remove updatecontrol and replace with a regular button 49 55 updateScheduleControl.UpdateAction = new Action(UpdateSchedule); 50 updateSlaveGroup.UpdateAction = new Action(UpdateSlaveGroups); 51 52 updateSlaveGroup.Update(); 56 updateSlaveGroup.UpdateAction = new Action(UpdateResources); 57 58 HiveAdminClient.Instance.Refreshing += new EventHandler(Instance_Refreshing); 59 HiveAdminClient.Instance.Refreshed += new EventHandler(Instance_Refreshed); 60 61 UpdateResourcesAsync(); 62 } 63 64 public new void Dispose() { 65 HiveAdminClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing); 66 HiveAdminClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed); 67 } 68 69 private void UpdateProgress() { 70 while (!stopProgressTask) { 71 int diff = (progressBar.Maximum - progressBar.Minimum) / 10; 72 progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum; 73 //ok, this is not very clever... 74 Thread.Sleep(500); 75 } 76 progressBar.Value = progressBar.Minimum; 77 } 78 79 void Instance_Refreshing(object sender, EventArgs e) { 80 stopProgressTask = false; 81 progressTask = new TS.Task(UpdateProgress); 82 progressTask.Start(); 83 } 84 85 void Instance_Refreshed(object sender, EventArgs e) { 86 stopProgressTask = true; 53 87 } 54 88 … … 142 176 143 177 slaveView.Content = (Resource)e.Node.Tag; 144 scheduleView.ResourceId = ((Resource)e.Node.Tag).Id;178 HiveAdminClient.Instance.DowntimeForResourceId = ((Resource)e.Node.Tag).Id; 145 179 146 180 if (e.Node.Tag is SlaveGroup) { … … 149 183 150 184 if (tabSlaveGroup.SelectedIndex == 1) { 151 UpdateSchedule ();185 UpdateScheduleAsync(); 152 186 } 153 187 } … … 175 209 Resource res = (Resource)treeSlaveGroup.SelectedNode.Tag; 176 210 177 DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administrat ion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);211 DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administrator", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 178 212 if (diagRes == DialogResult.Yes) { 179 213 if (res is Slave) { 180 214 Content.Remove(res); 181 ServiceLocator.Instance.CallHiveService(service => service.DeleteSlave(res.Id));215 HiveAdminClient.Delete(res); 182 216 } else if (res is SlaveGroup) { 183 217 //only delete empty groups 184 218 if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) { 185 219 Content.Remove(res); 186 ServiceLocator.Instance.CallHiveService(service => service.DeleteSlaveGroup(res.Id));220 HiveAdminClient.Delete(res); 187 221 } else { 188 MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administrat ion", MessageBoxButtons.OK, MessageBoxIcon.Error);222 MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 189 223 } 190 224 } … … 197 231 if (res is SlaveGroup && res.Id == Guid.Empty) { 198 232 SlaveGroup slaveGroup = (SlaveGroup)res; 199 ServiceLocator.Instance.CallHiveService(service => slaveGroup.Id = service.AddSlaveGroup(slaveGroup));233 slaveGroup.Store(); 200 234 } 201 235 if (res.Id != Guid.Empty && res.Modified) { 202 if (res is SlaveGroup) { 203 ServiceLocator.Instance.CallHiveService(service => service.UpdateSlaveGroup((SlaveGroup)res)); 204 } else if (res is Slave) { 205 ServiceLocator.Instance.CallHiveService(service => service.UpdateSlave((Slave)res)); 206 } 236 res.Store(); 207 237 } 208 238 } … … 218 248 if (destNode.Text == ungroupedGroupName || (destNode.Parent != null && destNode.Parent.Text == ungroupedGroupName)) { 219 249 MessageBox.Show(String.Format("You can't drag items to the {0} group.{1}This group only contains slaves which haven't yet been assigned to a real group.", 220 ungroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrat ion", MessageBoxButtons.OK, MessageBoxIcon.Information);250 ungroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information); 221 251 return; 222 252 } … … 239 269 //save parent group to get an id 240 270 if (sgrp.Id == Guid.Empty) { 241 ServiceLocator.Instance.CallHiveService(service => sgrp.Id = service.AddSlaveGroup(sgrp));271 sgrp.Store(); 242 272 } 243 273 … … 300 330 } 301 331 slaveView.Content = null; 302 scheduleView.ResourceId = Guid.Empty; 303 } 304 305 private void UpdateSlaveGroups() { 332 if (scheduleView.Content != null) { 333 scheduleView.Content.Clear(); 334 } 335 HiveAdminClient.Instance.ResetDowntime(); 336 } 337 338 private void UpdateResources() { 306 339 if (this.InvokeRequired) { 307 340 this.Invoke(new Action(ResetView)); … … 310 343 } 311 344 312 IItemList<Resource> resources = new ItemList<Resource>(); 313 314 ServiceLocator.Instance.CallHiveService(service => { 315 service.GetSlaveGroups().ForEach(g => resources.Add(g)); 316 service.GetSlaves().ForEach(s => resources.Add(s)); 317 }); 318 Content = resources; 345 HiveAdminClient.Instance.Refresh(); 346 Content = HiveAdminClient.Instance.Resources; 347 } 348 349 private void UpdateResourcesAsync() { 350 TS.Task.Factory.StartNew(UpdateResources).ContinueWith((t) => { 351 DisplayError(t.Exception); 352 }, TaskContinuationOptions.OnlyOnFaulted); 319 353 } 320 354 321 355 private void UpdateSchedule() { 322 Guid resourceId = scheduleView.ResourceId; 323 if (resourceId != null) { 324 ServiceLocator.Instance.CallHiveService(service => { 325 var appointments = service.GetDowntimesForResource(resourceId); 326 ItemList<Downtime> ias = new ItemList<Downtime>(); 327 appointments.ForEach(a => ias.Add(a)); 328 scheduleView.Invoke(new Action(() => scheduleView.Content = ias)); 329 }); 330 } 356 HiveAdminClient.Instance.RefreshCalendar(); 357 scheduleView.Invoke(new Action(() => scheduleView.Content = HiveAdminClient.Instance.Downtimes)); 358 } 359 360 private void UpdateScheduleAsync() { 361 TS.Task.Factory.StartNew(UpdateSchedule).ContinueWith((t) => { 362 DisplayError(t.Exception); 363 }, TaskContinuationOptions.OnlyOnFaulted); 364 } 365 366 private void DisplayError(Exception ex) { 367 MessageBox.Show("An error occured updating the schedule: " + Environment.NewLine + ex.ToString(), "HeuristicLab Hive Administrator"); 331 368 } 332 369 333 370 private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) { 334 371 if (tabSlaveGroup.SelectedIndex == 1) { 335 UpdateSchedule ();372 UpdateScheduleAsync(); 336 373 } 337 374 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r6696 r6756 32 32 33 33 namespace HeuristicLab.Clients.Hive.Administrator.Views { 34 [View("Schedule View")]34 [View("Schedule View")] 35 35 [Content(typeof(IItemList<Downtime>), IsDefaultView = true)] 36 36 public partial class ScheduleView : ItemView { … … 47 47 public delegate void OnDialogClosedDelegate(RecurrentEvent e); 48 48 49 private Guid resourceId;50 public Guid ResourceId {51 get {52 return resourceId;53 }54 set {55 resourceId = value;56 }57 }58 59 49 public ScheduleView() { 60 50 InitializeComponent(); … … 93 83 private void UpdateCalendarFromContent() { 94 84 offlineTimes.Clear(); 95 foreach (Downtime app in Content) { 96 offlineTimes.Add(new HiveAppointment { 97 AllDayEvent = app.AllDayEvent, 98 EndDate = app.EndDate, 99 StartDate = app.StartDate, 100 Recurring = app.Recurring, 101 RecurringId = app.RecurringId, 102 BorderColor = Color.Red, 103 Locked = true, 104 Subject = "Offline", 105 Changed = false, 106 Id = app.Id 107 }); 85 if (Content != null) { 86 foreach (Downtime app in Content) { 87 offlineTimes.Add(ToHiveAppointment(app)); 88 } 108 89 } 109 90 dvOnline.Invalidate(); … … 233 214 #region Register Content Events 234 215 protected override void DeregisterContentEvents() { 235 // TODO: Deregister your event handlers on the Content here236 216 base.DeregisterContentEvents(); 237 217 } 238 218 protected override void RegisterContentEvents() { 239 219 base.RegisterContentEvents(); 240 // TODO: Register your event handlers on the Content here241 220 } 242 221 #endregion … … 244 223 protected override void OnContentChanged() { 245 224 base.OnContentChanged(); 246 if (Content == null) { 247 // TODO: Put code here when content is null 248 } else { 249 UpdateCalendarFromContent(); 250 } 225 UpdateCalendarFromContent(); 251 226 } 252 227 253 228 protected override void SetEnabledStateOfControls() { 254 229 base.SetEnabledStateOfControls(); 255 // TODO: Put code here to enable or disable controls based on whether the Content is/not null or the view is ReadOnly256 230 } 257 231 … … 333 307 List<Downtime> appointments = new List<Downtime>(); 334 308 foreach (HiveAppointment app in offlineTimes) { 335 if (app.Deleted) { 336 ServiceLocator.Instance.CallHiveService(service => { 337 if (app.Id != Guid.Empty) { 338 service.DeleteDowntime(app.Id); 339 } 340 }); 341 } else if (app.Changed) { 342 Downtime apdto = new Downtime { 343 AllDayEvent = app.AllDayEvent, 344 EndDate = app.EndDate, 345 Recurring = app.Recurring, 346 RecurringId = app.RecurringId, 347 StartDate = app.StartDate, 348 ResourceId = resourceId 349 }; 350 appointments.Add(apdto); 351 } 352 } 353 354 if (appointments.Count > 0) { 355 //TODO: find a sane way to do this 356 ServiceLocator.Instance.CallHiveService(service => { 357 foreach (Downtime app in appointments) { 358 service.AddDowntime(app); 359 } 360 }); 361 } 309 if (app.Deleted && app.Id != Guid.Empty) { 310 HiveAdminClient.Delete(ToDowntime(app)); 311 } else if (app.Changed || app.Id == null || app.Id == Guid.Empty) { 312 Downtime dt = ToDowntime(app); 313 appointments.Add(dt); 314 } 315 } 316 foreach (Downtime dt in appointments) { 317 dt.Store(); 318 } 319 } 320 321 private HiveAppointment ToHiveAppointment(Downtime downtime) { 322 HiveAppointment app = new HiveAppointment { 323 AllDayEvent = downtime.AllDayEvent, 324 EndDate = downtime.EndDate, 325 StartDate = downtime.StartDate, 326 Recurring = downtime.Recurring, 327 RecurringId = downtime.RecurringId, 328 Deleted = false, 329 BorderColor = Color.Red, 330 Locked = true, 331 Subject = "Offline", 332 Changed = downtime.Modified, 333 Id = downtime.Id 334 }; 335 return app; 336 } 337 338 private Downtime ToDowntime(HiveAppointment app) { 339 Downtime downtime = new Downtime { 340 AllDayEvent = app.AllDayEvent, 341 EndDate = app.EndDate, 342 StartDate = app.StartDate, 343 Recurring = app.Recurring, 344 RecurringId = app.RecurringId, 345 ResourceId = HiveAdminClient.Instance.DowntimeForResourceId, 346 Id = app.Id 347 }; 348 return downtime; 362 349 } 363 350 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj
r6744 r6756 112 112 </ItemGroup> 113 113 <ItemGroup> 114 <Compile Include="HiveAdminClient.cs" /> 114 115 <Compile Include="HiveClient.cs" /> 115 116 <Compile Include="Settings.Designer.cs"> … … 120 121 <Compile Include="Tasks\ItemTask.cs" /> 121 122 <Compile Include="RefreshableJob.cs" /> 122 <Compile Include="ServiceClients\ HiveExperimentPermission.cs" />123 <Compile Include="ServiceClients\JobPermission.cs" /> 123 124 <Compile Include="StateLogList.cs" /> 124 125 <Compile Include="StateLogListList.cs" /> … … 167 168 <Compile Include="ServiceClients\Resource.cs" /> 168 169 <Compile Include="ServiceClients\StateLog.cs" /> 169 <Compile Include="ServiceClients\ HiveExperiment.cs" />170 <Compile Include="ServiceClients\Job.cs" /> 170 171 <Compile Include="ServiceClients\SlaveGroup.cs" /> 171 172 <Compile Include="ServiceClients\Slave.cs" /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r6744 r6756 75 75 #endregion 76 76 77 p ublicHiveClient() { }77 private HiveClient() { } 78 78 79 79 #region Refresh … … 101 101 } 102 102 // remove those which were not in the list of loaded hiveexperiments 103 foreach (var experimentin oldJobs) {104 if ( experiment.Id == Guid.Empty) {103 foreach (var job in oldJobs) { 104 if (job.Id == Guid.Empty) { 105 105 // experiment not uploaded... keep 106 jobs.Add( experiment);106 jobs.Add(job); 107 107 } else { 108 experiment.RefreshAutomatically = false; // stop results polling108 job.RefreshAutomatically = false; // stop results polling 109 109 } 110 110 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/Downtime.cs
r6452 r6756 27 27 public Downtime() { } 28 28 29 public override void Store() { 30 HiveAdminClient.Store(this, new System.Threading.CancellationToken()); 31 Modified = false; 32 } 33 29 34 protected Downtime(Downtime original, Cloner cloner) 30 35 : base(original, cloner) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveItem.cs
r6479 r6756 85 85 #endregion 86 86 87 public v oid Store() {87 public virtual void Store() { 88 88 HiveClient.Store(this, new System.Threading.CancellationToken()); 89 89 Modified = false; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/ServiceClients/Resource.cs
r6372 r6756 28 28 public Resource() { } 29 29 30 public override void Store() { 31 HiveAdminClient.Store(this, new System.Threading.CancellationToken()); 32 Modified = false; 33 } 34 30 35 protected Resource(Resource original, Cloner cloner) 31 36 : base(original, cloner) { -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.3/Enums/Permission.cs
r6717 r6756 31 31 32 32 /// <summary> 33 /// User can only download and view experiments33 /// User can only download and view jobs 34 34 /// </summary> 35 35 Read, 36 36 37 37 /// <summary> 38 /// User can pause, stop, restart, delete experiment. can also grant other38 /// User can pause, stop, restart, delete jobs. can also grant other 39 39 /// </summary> 40 40 Full -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs
r6743 r6756 233 233 public DT.Job GetJob(Guid id) { 234 234 using (var db = CreateContext()) { 235 return AddStatsTo Experiment(db, DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id)));236 } 237 } 238 239 private DT.Job AddStatsTo Experiment(HiveDataContext db, DT.Job exp) {235 return AddStatsToJob(db, DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id))); 236 } 237 } 238 239 private DT.Job AddStatsToJob(HiveDataContext db, DT.Job exp) { 240 240 if (exp == null) 241 241 return null; … … 250 250 public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) { 251 251 using (var db = CreateContext()) { 252 return db.Jobs.Where(predicate).Select(x => AddStatsTo Experiment(db, DT.Convert.ToDto(x))).ToArray();252 return db.Jobs.Where(predicate).Select(x => AddStatsToJob(db, DT.Convert.ToDto(x))).ToArray(); 253 253 } 254 254 }
Note: See TracChangeset
for help on using the changeset viewer.