/// <summary> /// Retrieves the simulators listed in table Assets and if available what their reservations are. /// </summary> private void GetMasterList() { _masterList = new SimReservedList(); using (AssetInventoryContext aie = DbConnect.AssetInventoryContext()) { var matches = (from ds in aie.Assets.OfType <DeviceSimulator>() join ar in aie.AssetReservations on ds.AssetId equals ar.AssetId into mgtGroup from item in mgtGroup.DefaultIfEmpty() select new { ds.AssetId, ds.Product, ds.Address, ds.VirtualMachine, SessionId = item.SessionId == null ? "" : item.SessionId, ReservedFor = item.ReservedFor == null ? "" : item.ReservedFor }); foreach (var m in matches) { SimReserved ent = new SimReserved(); ent.AssetId = m.AssetId; ent.Product = m.Product; ent.HostAddress = m.Address; ent.VirtualMachine = m.VirtualMachine; ent.SessionId = m.SessionId; ent.ReservedFor = m.ReservedFor; _masterList.Add(ent); } } }
private void reservedFor_ToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { string reservedFor = " all available reservations."; // Uncheck all items so that there's no hidden selected items BulkUpdateSimulatorCheckbox(false); if (reservedFor_ToolStripComboBox.SelectedIndex != 0) { reservedFor = reservedFor_ToolStripComboBox.SelectedItem.ToString(); var matches = (from sr in _masterList where sr.ReservedFor.Equals(reservedFor) select sr); SimReservedList lst = new SimReservedList(); foreach (SimReserved item in matches) { lst.Add(item); } BindSimMgtGrid(lst); } else { BindSimMgtGrid(_masterList); } SetReservedForMessage(reservedFor); }
private void BindSimMgtGrid(SimReservedList listSimReserved) { simReservedListBindingSource.DataSource = listSimReserved; simReservedListBindingSource.ResetBindings(false); }