private void RemoveResource(Resource resource) { if (resource == null) { return; } try { if (resource.Id != Guid.Empty) { SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(resource.Id).LastOrDefault(); // deal with all new, but not yet saved resources var newResources = Content.Where(x => x.ParentResourceId == resource.Id).ToList(); if (newResources.Any(x => x.Id != Guid.Empty)) { return; } foreach (var nr in newResources) { Content.Remove(nr); } HiveAdminClient.Delete(resource); UpdateResources(); } else { SelectedResource = Content.FirstOrDefault(x => x.Id == resource.ParentResourceId); Content.Remove(resource); } } catch (AnonymousUserException) { ShowHiveInformationDialog(); } }
private void btnRemoveGroup_Click(object sender, EventArgs e) { if (treeSlaveGroup.SelectedNode != null && treeSlaveGroup.SelectedNode.Tag != null) { Resource res = (Resource)treeSlaveGroup.SelectedNode.Tag; DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administrator", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (diagRes == DialogResult.Yes) { if (res is Slave) { Content.Remove(res); HiveAdminClient.Delete(res); } else if (res is SlaveGroup) { //only delete empty groups if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) { Content.Remove(res); HiveAdminClient.Delete(res); } else { MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void btnSaveCal_Click(object sender, EventArgs e) { if (HiveAdminClient.Instance.DowntimeForResourceId == null || HiveAdminClient.Instance.DowntimeForResourceId == Guid.Empty) { MessageBox.Show("You have to save the group before you can save the schedule. ", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { List <Downtime> downtimes = new List <Downtime>(); foreach (HiveDowntime downtime in offlineTimes) { if (downtime.Deleted && downtime.Id != Guid.Empty) { HiveAdminClient.Delete(ToDowntime(downtime)); } else if (downtime.Changed || downtime.Id == null || downtime.Id == Guid.Empty) { Downtime dt = ToDowntime(downtime); downtimes.Add(dt); } } foreach (Downtime dt in downtimes) { dt.Store(); } } }
private void RemoveResource(IEnumerable <Resource> resources) { if (resources == null || !resources.Any()) { return; } var ids = resources.Select(x => x.Id).ToList(); try { bool update = false; foreach (var r in resources) { if (r.Id != Guid.Empty) { if (r.Id == SelectedResource.Id) { SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(r.Id).LastOrDefault(); } // deal with all new, but not yet saved resources var newResources = Content.Where(x => x.ParentResourceId == r.Id).ToList(); if (newResources.Any(x => x.Id != Guid.Empty)) { return; } foreach (var nr in newResources) { Content.Remove(nr); } HiveAdminClient.Delete(r); update = true; } else { if (r.Id == SelectedResource.Id) { SelectedResource = Content.FirstOrDefault(x => x.Id == r.ParentResourceId); } Content.Remove(r); } } if (update) { UpdateResources(); } } catch (AnonymousUserException) { ShowHiveInformationDialog(); } }
private void RemoveProject(Project project) { if (project == null) { return; } try { if (project.Id != Guid.Empty) { SelectedProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(project.Id).LastOrDefault(); HiveAdminClient.Delete(project); UpdateProjects(); } else { SelectedProject = Content.FirstOrDefault(x => x.Id == project.ParentProjectId); Content.Remove(project); } } catch (AnonymousUserException) { ShowHiveInformationDialog(); } }