public void Test_Construction() { Assert.AreEqual(TestData.definition_hash, m_historic.getStreamHash(), "Stream hash is incorrect"); Assert.AreEqual(TestData.historic_name, m_historic.getName(), "Name is incorrect"); Assert.AreEqual(TestData.historic_start, m_historic.getStartDate(), "Start date is incorrect"); Assert.AreEqual(TestData.historic_end, m_historic.getEndDate(), "End date is incorrect"); Assert.AreEqual("created", m_historic.getStatus(), "Status is incorrect"); Assert.AreEqual(0, m_historic.getProgress(), "Progress is incorrect"); Assert.AreEqual(TestData.historic_sample, m_historic.getSample(), "Sample is incorrect"); }
private void lstHistoricsQueries_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { ListView.SelectedListViewItemCollection lvis = GetSelectedItems(); bool start = true; bool stop = true; bool delete = true; if (lvis.Count == 0) { start = stop = delete = false; } else { foreach (ListViewItem lvi in GetSelectedItems()) { Historic h = (Historic)lvi.Tag; switch (h.getStatus()) { case "init": stop = false; break; case "queued": case "submitted": case "prep": case "running": case "finishing": start = false; break; case "finished": case "succeeded": default: start = false; stop = false; break; } } } mnuStart.Enabled = btnStart.Enabled = start; mnuStop.Enabled = btnStop.Enabled = stop; mnuDelete.Enabled = btnDelete.Enabled = delete; }
public void AddOrUpdateHistoricItem(Historic h, ListViewItem lvi = null) { if (lstHistoricsQueries.InvokeRequired) { AddOrUpdateHistoricItemCallback cb = new AddOrUpdateHistoricItemCallback(AddOrUpdateHistoricItem); this.Invoke(cb, new object[] { h, lvi }); } else { lstHistoricsQueries.BeginUpdate(); try { if (lvi == null) { // No ListViewItem given, try to find a matching row foreach (ListViewItem lvi_candidate in lstHistoricsQueries.Items) { if (h.getHash() == ((Historic)lvi_candidate.Tag).getHash()) { lvi = lvi_candidate; break; } } } if (h.isDeleted()) { if (lvi != null) { lstHistoricsQueries.Items.Remove(lvi); } } else { if (lvi == null) { // Still not found it, add it lvi = lstHistoricsQueries.Items.Add(h.getName()); lvi.SubItems.Add(h.getStatus()); lvi.SubItems.Add(h.getProgress().ToString()); lvi.SubItems.Add(h.getStartDate().ToString()); lvi.SubItems.Add(h.getEndDate().ToString()); lvi.SubItems.Add(string.Join(", ", h.getSources().ToArray())); } else { // Already exists, update the pieces lvi.SubItems[0].Text = h.getName(); lvi.SubItems[1].Text = h.getStatus(); lvi.SubItems[2].Text = h.getProgress().ToString(); lvi.SubItems[3].Text = h.getStartDate().ToString(); lvi.SubItems[4].Text = h.getEndDate().ToString(); lvi.SubItems[5].Text = string.Join(", ", h.getSources().ToArray()); } // Store the Historic in the item lvi.Tag = h; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } lstHistoricsQueries.EndUpdate(); } }