internal static List <FilestoreFile> GetExpired(DateTime abs) { try { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectSql + " WHERE \"Expires\" < :d"; cmd.Parameters.AddWithValue("d", abs); NpgsqlDataReader rdr = ExecuteReader(cmd); List <FilestoreFile> items = new List <FilestoreFile>(); while (rdr.Read()) { Guid id = DbReaderUtils.GetGuid(rdr, 0); DateTime cr = DbReaderUtils.GetDate(rdr, 1); DateTime u = DbReaderUtils.GetDate(rdr, 2); DateTime a = DbReaderUtils.GetDate(rdr, 3); DateTime e = DbReaderUtils.GetDate(rdr, 4); bool t = DbReaderUtils.GetBoolean(rdr, 5); string fn = DbReaderUtils.GetString(rdr, 6); if (DateTime.MinValue == e) { e = DateTime.MaxValue; } items.Add(new FilestoreFile(id, cr, u, a, e, t, fn)); } return(items); } catch { } return(null); }
public ProjectStatus Build(DbDataReader reader) { CompoundIdentity statTypeId = null; if (!DBNull.Value.Equals(reader[4])) { statTypeId = new CompoundIdentity(DbReaderUtils.GetGuid(reader, 4), DbReaderUtils.GetGuid(reader, 5)); } return(new ProjectStatus(new CompoundIdentity(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetGuid(reader, 1)), DbReaderUtils.GetGuid(reader, 2), statTypeId, DbReaderUtils.GetString(reader, 6), DbReaderUtils.GetDate(reader, 3))); }
internal static FilestoreFile Open(Guid id) { if (!Guid.Empty.Equals(id)) { NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString); cmd.CommandText = Db.SelectSql + " WHERE \"Id\"=:id"; cmd.Parameters.AddWithValue("id", id); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); FilestoreFile tmp = null; try { if (rdr.Read()) { DateTime cr = DbReaderUtils.GetDate(rdr, 1); DateTime u = DbReaderUtils.GetDate(rdr, 2); DateTime a = DbReaderUtils.GetDate(rdr, 3); DateTime e = DbReaderUtils.GetDate(rdr, 4); bool t = DbReaderUtils.GetBoolean(rdr, 5); string fn = DbReaderUtils.GetString(rdr, 6); if (DateTime.MinValue == e) { e = DateTime.MaxValue; } tmp = new FilestoreFile(id, cr, u, a, e, t, fn); } if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } if (DateTime.Now >= tmp.ExpiresAt) //just handle last minute deletes { Delete(id); tmp = null; } return(tmp); } return(null); }
//\"Id\", \"VegSurveyId\", \"SiteSystemId\", \"SiteId\", \"When\", \"PointLocation\", \"ElevMin\", \"ElevMax\" public VegSample Build(DbDataReader reader) { VegSample tmp = new VegSample((Guid)reader[0], new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 1)), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 2), DbReaderUtils.GetGuid(reader, 3)), Db.FixDate(DbReaderUtils.GetDate(reader, 4)), Db.GetLoc(reader, 5), DbReaderUtils.GetSingle(reader, 6), DbReaderUtils.GetSingle(reader, 7)); if (!seen.Contains(tmp.VegSurveyId)) { seen.Add(tmp.VegSurveyId); VegSurvey e = this.helperBuilder.GetSurvey(tmp.VegSurveyId); if (e != null) { got.Add(tmp.VegSurveyId); } } if (!got.Contains(tmp.VegSurveyId)) { return(null); } return(tmp); }
public WaterQualityMeasurement Build(DbDataReader reader) { WaterQualityMeasurement tmp = new WaterQualityMeasurement(new CompoundIdentity(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetGuid(reader, 1)), Db.FixDate(DbReaderUtils.GetDate(reader, 2)), DbReaderUtils.GetNullableDouble(reader, 3), DbReaderUtils.GetNullableDouble(reader, 4), DbReaderUtils.GetNullableDouble(reader, 5), DbReaderUtils.GetNullableDouble(reader, 6), DbReaderUtils.GetNullableDouble(reader, 7), DbReaderUtils.GetNullableDouble(reader, 8), DbReaderUtils.GetNullableDouble(reader, 9)); if (!seen.Contains(tmp.DeploymentId)) { seen.Add(tmp.DeploymentId); WaterQualityDeployment depl = this.helperBuilder.Get(tmp.DeploymentId); if (depl != null) { got.Add(tmp.DeploymentId); } } if (!got.Contains(tmp.DeploymentId)) { return(null); } return(tmp); }
//\"Id\", \"OwnerType\", \"Payload\", \"Token\", \"IsLocked\", \"ValidFrom\", \"ValidTo\" internal PersistedCredential Create(NpgsqlDataReader rdr) { Guid id = DbReaderUtils.GetGuid(rdr, 0); if (!Guid.Empty.Equals(id)) { PersistedCredential cred = this.Create(id, DbReaderUtils.GetString(rdr, 2), DbReaderUtils.GetString(rdr, 3), DbReaderUtils.GetDate(rdr, 5), DbReaderUtils.GetDate(rdr, 6)); this.Update(cred, DbReaderUtils.GetBoolean(rdr, 4)); return(cred); } return(null); }
//\"Id\", \"EventSystemId\", \"EventId\", \"SiteSystemId\", \"SiteId\", \"When\", //\"PointLocation\", \"Method\", \"Strata\", \"Depth\", \"pH\", \"Temp\", \"DO\", \"Salinity\", \"Velocity\", \"Description\", \"IsPrivate\" public CatchEffort Build(DbDataReader reader) { Point2 <double> loc; if (DBNull.Value.Equals(reader[6])) { loc = null; } else { loc = Osrs.Numerics.Spatial.Postgres.NpgSpatialUtils.ToGeom((NpgsqlTypes.PostgisGeometry)reader[6]) as Point2 <double>; } CatchEffort tmp = new CatchEffort(new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 0)), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 1), DbReaderUtils.GetGuid(reader, 2)), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 3), DbReaderUtils.GetGuid(reader, 4)), Db.FixDate(DbReaderUtils.GetDate(reader, 5)), loc, DbReaderUtils.GetString(reader, 7), DbReaderUtils.GetString(reader, 8), DbReaderUtils.GetSingle(reader, 9), DbReaderUtils.GetSingle(reader, 10), DbReaderUtils.GetSingle(reader, 11), DbReaderUtils.GetSingle(reader, 12), DbReaderUtils.GetSingle(reader, 13), DbReaderUtils.GetSingle(reader, 14), DbReaderUtils.GetString(reader, 15), DbReaderUtils.GetBoolean(reader, 16)); if (tmp.IsPrivate) { if (prov == null) { return(null); //can't verify } if (!prov.HasAffiliationForSampleEvent(tmp.SampleEventId, false)) { return(null); } } return(tmp); }