internal SampleEventMap Create(CompoundIdentity sampleEventId) { if (this.connString != null && sampleEventId != null && !sampleEventId.IsEmpty && this.Get(sampleEventId) == null) { try { SampleEventMap map = SampleEventMap.Create(sampleEventId); NpgsqlCommand cmd = GetCmd(this.connString); cmd.CommandText = Insert; cmd.Parameters.AddWithValue("sid", map.SampleEventId.DataStoreIdentity); cmd.Parameters.AddWithValue("id", map.SampleEventId.Identity); List <Guid> fileIds = new List <Guid>(); List <int> fileTypes = new List <int>(); List <bool> privacies = new List <bool>(); cmd.Parameters.AddWithValue("fts", fileTypes.ToArray()); cmd.Parameters.AddWithValue("fis", fileIds.ToArray()); cmd.Parameters.AddWithValue("bis", EncodeBundleIds(map)); cmd.Parameters.AddWithValue("pri", privacies.ToArray()); ExecuteNonQuery(cmd); return(map); } catch { } } return(null); }
internal SampleEventMap Get(CompoundIdentity sampleEventId) { if (this.connString != null && sampleEventId != null && !sampleEventId.IsEmpty) { NpgsqlCommand cmd = GetCmd(connString); cmd.CommandText = Select + " WHERE \"SampleEventSystemId\"=:sid AND \"SampleEventId\"=:id"; cmd.Parameters.AddWithValue("sid", sampleEventId.DataStoreIdentity); cmd.Parameters.AddWithValue("id", sampleEventId.Identity); NpgsqlDataReader rdr = ExecuteReader(cmd); try { if (rdr.Read()) { int[] fileTypes = (int[])rdr[2]; Guid[] fileIds = (Guid[])rdr[3]; bool[] privacies = (bool[])rdr[5]; SampleEventMap tmp = SampleEventMap.Create(sampleEventId); for (int i = 0; i < fileTypes.Length; i++) { tmp.Add(fileIds[i], (KnownDetType)fileTypes[i], privacies[i]); } if (!DBNull.Value.Equals(rdr[4])) { DecodeBundleIds((string)rdr[4], tmp); } return(tmp); } } catch { } finally { cmd.Dispose(); } } return(null); }
internal SampleEventMap Get(Guid fileId) { if (this.connString != null && !Guid.Empty.Equals(fileId)) { NpgsqlCommand cmd = GetCmd(connString); cmd.CommandText = Select + " WHERE :id = ANY(\"FileIds\")"; cmd.Parameters.AddWithValue("id", fileId); NpgsqlDataReader rdr = ExecuteReader(cmd); try { if (rdr.Read()) { CompoundIdentity id = new CompoundIdentity((Guid)rdr[0], (Guid)rdr[1]); int[] fileTypes = (int[])rdr[2]; Guid[] fileIds = (Guid[])rdr[3]; bool[] privacies = (bool[])rdr[5]; SampleEventMap tmp = SampleEventMap.Create(id); for (int i = 0; i < fileTypes.Length; i++) { tmp.Add(fileIds[i], (KnownDetType)fileTypes[i], privacies[i]); } if (!DBNull.Value.Equals(rdr[4])) { DecodeBundleIds((string)rdr[4], tmp); } return(tmp); } } catch { } finally { cmd.Dispose(); } } return(null); }