public IDataStoreItem GetItem(int ID, Type t) { return(retriever.RetrieveItem(ID, t)); }
public override void UIThreadInitialize() { logger.Trace("UIThreadInitialize()..."); base.UIThreadInitialize(); StudyTypeBridges = new AsyncObservableCollection <ProcedureTypeBridge>(); WardBridges = new AsyncObservableCollection <WardBridge>(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = Properties.Settings.Default.InterfaceConnString; conn.Open(); // Create the command SqlCommand command = new SqlCommand("SELECT * FROM dbo.StudyTypeBridges", conn); /* Get the rows and display on the screen! * This section of the code has the basic code * that will display the content from the Database Table * on the screen using an SqlDataReader. */ using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { ProcedureTypeBridge stb = new ProcedureTypeBridge(); stb.ID = Convert.ToInt32(reader[0]); stb.ForeignKey = reader[1].ToString(); stb.ForeignName = reader[2].ToString(); logger.Trace("ProcedureTypeBridge- ID: " + stb.ID + "; ForeignKey: " + stb.ForeignKey + "; ForeignName: " + stb.ForeignName); if (reader[3] != System.DBNull.Value) { stb.LocalKey = Convert.ToInt32(reader[3]); //ok now we have to get the studytype for this stb.StudyType = (StudyType)retriever.RetrieveItem(stb.LocalKey, typeof(StudyType)); logger.Trace("Linked Study Type: " + stb.StudyType.Name); } stb.IsFollowUp = reader[4] as bool? ?? false; if (reader[5] != System.DBNull.Value) { stb.Range = Convert.ToInt32(reader[5]); } if (!reader.IsDBNull(6)) { stb.SetNumInjections(Convert.ToInt32(reader[6])); logger.Trace("stb.NumInjections = " + stb.NumInjections.ToString()); for (int x = 1; x < stb.NumInjections + 1; x = x + 1) { InjectionDetail id = new InjectionDetail(); id.InjectionDelay = Convert.ToInt32(reader["Injection" + (x).ToString() + "Delay"]); if (Convert.ToInt32(reader["Injection" + (x).ToString() + "RadiopharmaceuticalID"]) > 0) { id.Radiopharmaceutical = retriever.RetrieveItem(Convert.ToInt32(reader["Injection" + (x).ToString() + "RadiopharmaceuticalID"]), typeof(Chemical)); } id.InjectionActivity = Convert.ToInt32(reader["Injection" + (x).ToString() + "Activity"]); var tmp1 = reader["Injection" + x.ToString() + "Route"] as int? ?? -1; if (tmp1 == -1) { id.AdministrationRoute = null; } else { id.AdministrationRoute = (AdministrationRoute)Enum.ToObject(typeof(AdministrationRoute), tmp1); } stb.InjectionDetails.Add(id); logger.Trace("Delay: " + id.InjectionDelay.ToString() + "; Chemical: " + ((Chemical)id.Radiopharmaceutical).Name + "; Activity: " + id.InjectionActivity.ToString()); } if (Convert.IsDBNull(reader["NumberOfScans"])) { stb.SetNumScans(0); logger.Trace("Number of scans: " + stb.NumScans); } else { stb.SetNumScans(Convert.ToInt32(reader["NumberOfScans"])); logger.Trace("Number of scans: " + stb.NumScans); for (int y = 1; y < stb.NumScans + 1; y = y + 1) { ScanDetail sd = new ScanDetail(); sd.ScanDelay = Convert.ToInt32(reader["Scan" + (y).ToString() + "Delay"]); sd.ScanDuration = Convert.ToInt32(reader["Scan" + (y).ToString() + "Duration"]); if (Convert.ToInt32(reader["Scan" + (y).ToString() + "RoomID"]) > 0) { sd.Room = retriever.RetrieveItem(Convert.ToInt32(reader["Scan" + (y).ToString() + "RoomID"]), typeof(Room)); } stb.ScanDetails.Add(sd); logger.Trace("Scan" + y.ToString() + " - Delay: " + sd.ScanDelay + "; ScanDuration: " + sd.ScanDuration + "; Room: " + (sd.Room as Room).Name); } } } StudyTypeBridges.Add(stb); } } command = new SqlCommand("SELECT * FROM dbo.WardBridges", conn); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { WardBridge stb = new WardBridge(); stb.ID = Convert.ToInt32(reader[0]); stb.ForeignKey = reader[1].ToString(); stb.ForeignName = reader[2].ToString(); if (reader[3] != System.DBNull.Value) { stb.LocalID = Convert.ToInt32(reader[3]); //ok now we have to get the studytype for this stb.Ward = (Ward)retriever.RetrieveItem(stb.LocalID, typeof(Ward)); } WardBridges.Add(stb); } } } }