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); }
//\"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); }
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); }
internal void Fill(HashSet <PermissionAssignment> perms, Role role, IPermissionProvider prov) { NpgsqlCommand cmd = Db.GetCmd(Db.RoleConnectionString); cmd.CommandText = Db.SelectRolePermissions + Db.SelectRoleByRoleId; cmd.Parameters.AddWithValue("rid", role.Id); NpgsqlDataReader rdr = Db.ExecuteReader(cmd); if (rdr != null) { try { while (rdr.Read()) { Guid pid = DbReaderUtils.GetGuid(rdr, 1); bool isGrant = DbReaderUtils.GetBoolean(rdr, 2); Permission p = prov.Get(pid); if (p != null) { PermissionAssignment pa = new PermissionAssignment(p, isGrant ? GrantType.Grant : GrantType.Deny); perms.Add(pa); } } if (cmd.Connection.State == System.Data.ConnectionState.Open) { cmd.Connection.Close(); } } catch { } finally { cmd.Dispose(); } } }
public WaterQualityDeployment Build(DbDataReader reader) { WaterQualityDeployment tmp = new WaterQualityDeployment(new CompoundIdentity(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetGuid(reader, 1)), DbReaderUtils.GetString(reader, 2), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 3), DbReaderUtils.GetGuid(reader, 4)), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 5), DbReaderUtils.GetGuid(reader, 6)), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 7), DbReaderUtils.GetGuid(reader, 8)), DateRange.Create(Db.FixDate(DbReaderUtils.GetNullableDateTime(reader, 9)), Db.FixDate(DbReaderUtils.GetNullableDateTime(reader, 10))), DbReaderUtils.GetString(reader, 11), DbReaderUtils.GetBoolean(reader, 12)); if (tmp.IsPrivate) { if (prov == null) { return(null); //can't verify } if (!prov.HasAffiliationForSampleEvent(tmp.SampleEventId, false)) { return(null); } } return(tmp); }
//\"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); }