예제 #1
0
 internal static void FillMembers(FieldTeam item)
 {
     //\"FieldTeamSystemId\", \"FieldTeamId\", \"PersonSystemId\", \"PersonId\", \"FieldTeamMemberRoleSystemId\", \"FieldTeamMemberRoleId\"
     if (item != null)
     {
         NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
         cmd.CommandText = Db.SelectFieldTeamMembers;
         cmd.Parameters.AddWithValue("sid", item.Identity.DataStoreIdentity);
         cmd.Parameters.AddWithValue("id", item.Identity.Identity);
         NpgsqlDataReader rdr = Db.ExecuteReader(cmd);
         if (rdr != null)
         {
             try
             {
                 FieldTeamMembers m = item.Members;
                 while (rdr.Read())
                 {
                     m.Add(new FieldTeamMember(new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 2), DbReaderUtils.GetGuid(rdr, 3)), new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 4), DbReaderUtils.GetGuid(rdr, 5))));
                 }
                 if (cmd.Connection.State == System.Data.ConnectionState.Open)
                 {
                     cmd.Connection.Close();
                 }
             }
             catch
             { }
             finally
             {
                 cmd.Dispose();
             }
         }
     }
 }
예제 #2
0
        public Permission Build(DbDataReader reader)
        {
            Guid   id   = DbReaderUtils.GetGuid(reader, 0);
            string name = DbReaderUtils.GetString(reader, 1);

            return(new Permission(name, id));
        }
예제 #3
0
 public override IEnumerable <CompoundIdentity> InstrumentTypesForArchetype(CompoundIdentity archetypeId)
 {
     if (archetypeId != null && this.CanGet())
     {
         NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
         cmd.CommandText = "SELECT \"InstrumentTypeId\" FROM oncor.\"InstrumentTypeKnownArchetypes\" WHERE \"ArchetypeId\"=:aid";
         cmd.Parameters.AddWithValue("aid", archetypeId.Identity);
         NpgsqlDataReader        rdr         = Db.ExecuteReader(cmd);
         List <CompoundIdentity> permissions = new List <CompoundIdentity>();
         try
         {
             CompoundIdentity t;
             while (rdr.Read())
             {
                 t = new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(rdr, 0));
                 if (t != null)
                 {
                     permissions.Add(t);
                 }
             }
             if (cmd.Connection.State == System.Data.ConnectionState.Open)
             {
                 cmd.Connection.Close();
             }
         }
         catch
         { }
         finally
         {
             cmd.Dispose();
         }
         return(permissions);
     }
     return(null);
 }
예제 #4
0
        //\"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);
        }
예제 #5
0
 public override OrganizationHierarchy Get(CompoundIdentity hierarchyId)
 {
     if (!hierarchyId.IsNullOrEmpty() && this.CanGet())
     {
         NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
         cmd.CommandText = Db.Select + Db.WhereId;
         cmd.Parameters.AddWithValue("sid", hierarchyId.DataStoreIdentity);
         cmd.Parameters.AddWithValue("id", hierarchyId.Identity);
         NpgsqlDataReader      rdr = Db.ExecuteReader(cmd);
         OrganizationHierarchy o   = null;
         if (rdr != null)
         {
             try
             {
                 if (rdr.Read())
                 {
                     o = new PgOrgHierarchy(this.Context, new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 0), DbReaderUtils.GetGuid(rdr, 1)),
                                            new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 2), DbReaderUtils.GetGuid(rdr, 3)), DbReaderUtils.GetString(rdr, 4), DbReaderUtils.GetString(rdr, 5));
                     if (cmd.Connection.State == System.Data.ConnectionState.Open)
                     {
                         cmd.Connection.Close();
                     }
                 }
             }
             catch
             { }
             finally
             {
                 cmd.Dispose();
             }
         }
         return(o);
     }
     return(null);
 }
예제 #6
0
        public Role Build(DbDataReader reader)
        {
            Guid   id   = DbReaderUtils.GetGuid(reader, 0);
            string name = DbReaderUtils.GetString(reader, 1);

            return(new Role(name, id));
        }
예제 #7
0
파일: Db.cs 프로젝트: OSRS/Oncor_Base
        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);
        }
예제 #8
0
파일: Db.cs 프로젝트: OSRS/Oncor_OsrsLegacy
        public SensorType Build(DbDataReader reader)
        {
            CompoundIdentity parentId   = null;
            Guid             parentGuid = DbReaderUtils.GetGuid(reader, 3);

            if (!Guid.Empty.Equals(parentGuid))
            {
                parentId = new CompoundIdentity(Db.DataStoreIdentity, parentGuid);
            }

            SensorType sensorType = new SensorType(new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 0)), DbReaderUtils.GetString(reader, 1), DbReaderUtils.GetString(reader, 2), parentId);

            string s = DbReaderUtils.GetString(reader, 4);
            JToken t = JRaw.Parse(s);

            if (t is JArray)
            {
                JArray a = (JArray)t;
                HashSet <CompoundIdentity> ids = Db.ToIds(a);
                foreach (CompoundIdentity id in ids)
                {
                    sensorType.InstrumentFamilies.Add(id);
                }
            }

            return(sensorType);
        }
예제 #9
0
 private HashSet <CompoundIdentity> GetUserAffils()
 {
     if (this.orgs == null)
     {
         NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
         cmd.CommandText = Db.SelectUserAffil;
         cmd.Parameters.AddWithValue("uid", this.ctx.User.Uid);
         NpgsqlDataReader           rdr  = Db.ExecuteReader(cmd);
         HashSet <CompoundIdentity> orgs = new HashSet <CompoundIdentity>();
         if (rdr != null)
         {
             try
             {
                 while (rdr.Read())
                 {
                     orgs.Add(new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 0), DbReaderUtils.GetGuid(rdr, 1)));
                 }
                 if (cmd.Connection.State == System.Data.ConnectionState.Open)
                 {
                     cmd.Connection.Close();
                 }
                 this.orgs = orgs;
             }
             catch
             { }
             finally
             {
                 cmd.Dispose();
             }
         }
     }
     return(this.orgs);
 }
예제 #10
0
        internal CompoundIdentity GetLocalOrg(CompoundIdentity sampleEventId)
        {
            NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);

            cmd.CommandText = Db.SelectSampleEventLocal;
            cmd.Parameters.AddWithValue("sid", sampleEventId.DataStoreIdentity);
            cmd.Parameters.AddWithValue("id", sampleEventId.Identity);
            NpgsqlDataReader rdr = Db.ExecuteReader(cmd);
            CompoundIdentity tmp = null;

            if (rdr != null)
            {
                try
                {
                    if (rdr.Read())
                    {
                        tmp = new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 0), DbReaderUtils.GetGuid(rdr, 1));
                    }
                    if (cmd.Connection.State == System.Data.ConnectionState.Open)
                    {
                        cmd.Connection.Close();
                    }
                }
                catch
                { }
                finally
                {
                    cmd.Dispose();
                }
            }
            return(tmp);
        }
예제 #11
0
        //"Id", "OwnerSystemId", "OwnerId", "Name", "DataType"
        public EntityBundle Build(DbDataReader reader)
        {
            EntityBundle tmp = new EntityBundle(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetString(reader, 3),
                                                new CompoundIdentity(DbReaderUtils.GetGuid(reader, 1), DbReaderUtils.GetGuid(reader, 2)), (BundleDataType)((int)(reader[4])));

            Fill(tmp);
            return(tmp);
        }
예제 #12
0
        public FieldTeamMemberRole Build(DbDataReader reader)
        {
            Guid   sid  = DbReaderUtils.GetGuid(reader, 0);
            Guid   id   = DbReaderUtils.GetGuid(reader, 1);
            string name = DbReaderUtils.GetString(reader, 2);
            string desc = DbReaderUtils.GetString(reader, 3);

            return(new FieldTeamMemberRole(new CompoundIdentity(sid, id), name, desc));
        }
예제 #13
0
파일: Db.cs 프로젝트: OSRS/Oncor_OsrsLegacy
        public InstrumentFamily Build(DbDataReader reader)
        {
            CompoundIdentity parentId   = null;
            Guid             parentGuid = DbReaderUtils.GetGuid(reader, 3);

            if (!Guid.Empty.Equals(parentGuid))
            {
                parentId = new CompoundIdentity(Db.DataStoreIdentity, parentGuid);
            }

            return(new InstrumentFamily(new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 0)), DbReaderUtils.GetString(reader, 1), DbReaderUtils.GetString(reader, 2), parentId));
        }
예제 #14
0
        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)));
        }
예제 #15
0
        //Guid uid, UserType type, UserState state, DateTime? ExpiresAt, string name
        public PostgresUser Build(DbDataReader reader)
        {
            Guid         id    = DbReaderUtils.GetGuid(reader, 0);
            UserType     type  = (UserType)DbReaderUtils.GetInt32(reader, 1);
            UserState    state = (UserState)DbReaderUtils.GetInt32(reader, 2);
            DateTime?    exp   = DbReaderUtils.GetNullableDateTime(reader, 3);
            string       name  = DbReaderUtils.GetString(reader, 4);
            PostgresUser user  = new PostgresUser(id, type, name, state);

            user.ExpiresAt = exp;
            return(user);
        }
예제 #16
0
        public FieldTeam Build(DbDataReader reader)
        {
            Guid   sid  = DbReaderUtils.GetGuid(reader, 0);
            Guid   id   = DbReaderUtils.GetGuid(reader, 1);
            string name = DbReaderUtils.GetString(reader, 2);
            string desc = DbReaderUtils.GetString(reader, 3);

            FieldTeam ft = new FieldTeam(new CompoundIdentity(sid, id), name, desc);

            PgFieldTeamProvider.FillMembers(ft);
            return(ft);
        }
        //\"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);
        }
예제 #18
0
파일: Db.cs 프로젝트: OSRS/Oncor_OsrsLegacy
        public Sensor Build(DbDataReader reader)
        {
            CompoundIdentity manufId    = null;
            Guid             manufSysId = DbReaderUtils.GetGuid(reader, 8);

            if (!Guid.Empty.Equals(manufSysId))
            {
                manufId = new CompoundIdentity(manufSysId, DbReaderUtils.GetGuid(reader, 9));
            }

            return(new Sensor(new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 0)), new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 1)),
                              new CompoundIdentity(DbReaderUtils.GetGuid(reader, 2), DbReaderUtils.GetGuid(reader, 3)), DbReaderUtils.GetString(reader, 4), new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 5)),
                              DbReaderUtils.GetString(reader, 6), DbReaderUtils.GetString(reader, 7), manufId));
        }
예제 #19
0
        public Project Build(DbDataReader reader)
        {
            CompoundIdentity parentId    = null;
            Guid             parentSysId = DbReaderUtils.GetGuid(reader, 5);

            if (!Guid.Empty.Equals(parentSysId))
            {
                parentId = new CompoundIdentity(parentSysId, DbReaderUtils.GetGuid(reader, 6));
            }

            Project p = new Project(new CompoundIdentity(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetGuid(reader, 1)),
                                    DbReaderUtils.GetString(reader, 2), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 3), DbReaderUtils.GetGuid(reader, 4)),
                                    parentId, DbReaderUtils.GetString(reader, 7));

            Db.LoadAffiliates(p);
            return(p);
        }
예제 #20
0
        public SamplingEvent Build(DbDataReader reader)
        {
            Guid sid   = DbReaderUtils.GetGuid(reader, 0);
            Guid id    = DbReaderUtils.GetGuid(reader, 1);
            Guid ftsid = DbReaderUtils.GetGuid(reader, 2);
            Guid ftid  = DbReaderUtils.GetGuid(reader, 3);
            Guid osid  = DbReaderUtils.GetGuid(reader, 4);
            Guid oid   = DbReaderUtils.GetGuid(reader, 5);
            //Guid stsid = DbReaderUtils.GetGuid(reader, 6);
            //Guid stid = DbReaderUtils.GetGuid(reader, 7);
            string   name  = DbReaderUtils.GetString(reader, 6);
            string   desc  = DbReaderUtils.GetString(reader, 7);
            DateTime start = Db.SafeGetDate(reader, 8, DateTime.MinValue);
            DateTime end   = Db.SafeGetDate(reader, 9, DateTime.MaxValue);

            return(new SamplingEvent(new CompoundIdentity(sid, id), name, new CompoundIdentity(ftsid, ftid), new CompoundIdentity(osid, oid), new Numerics.ValueRange <DateTime>(start, end), desc));
        }
예제 #21
0
파일: Db.cs 프로젝트: OSRS/Oncor_OsrsLegacy
        //\"SystemId\", \"Id\", \"OwnerSystemId\", \"OwnerId\", \"Name\", \"Description\", \"Geom\", \"AltGeom\", \"StartDate\", \"EndDate\"
        public Site Build(DbDataReader reader)
        {
            Site tmp = new Site(new CompoundIdentity(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetGuid(reader, 1)),
                                new CompoundIdentity(DbReaderUtils.GetGuid(reader, 2), DbReaderUtils.GetGuid(reader, 3)),
                                DbReaderUtils.GetString(reader, 4), DbReaderUtils.GetString(reader, 5));

            if (!DBNull.Value.Equals(reader[6]))
            {
                tmp.Location = Osrs.Numerics.Spatial.Postgres.NpgSpatialUtils.ToGeom((NpgsqlTypes.PostgisGeometry)reader[6]);
            }

            if (!DBNull.Value.Equals(reader[7]))
            {
                tmp.LocationMark = Osrs.Numerics.Spatial.Postgres.NpgSpatialUtils.ToGeom((NpgsqlTypes.PostgisGeometry)reader[7]) as Point2 <double>;
            }

            return(tmp);
        }
예제 #22
0
        public override IEnumerable <CompoundIdentity> GetParentIds(CompoundIdentity orgId)
        {
            if (!orgId.IsNullOrEmpty())
            {
                try
                {
                    NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
                    cmd.CommandText = Db.SelectMem + Db.WhereElem;
                    cmd.Parameters.AddWithValue("sid", this.Identity.DataStoreIdentity);
                    cmd.Parameters.AddWithValue("id", this.Identity.Identity);
                    cmd.Parameters.AddWithValue("csid", orgId.DataStoreIdentity);
                    cmd.Parameters.AddWithValue("cid", orgId.Identity);

                    NpgsqlDataReader rdr = Db.ExecuteReader(cmd);
                    if (rdr != null)
                    {
                        HashSet <CompoundIdentity> res = new HashSet <CompoundIdentity>();
                        try
                        {
                            while (rdr.Read())
                            {
                                res.Add(new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 0), DbReaderUtils.GetGuid(rdr, 1)));
                            }
                            if (cmd.Connection.State == System.Data.ConnectionState.Open)
                            {
                                cmd.Connection.Close();
                            }
                        }
                        catch
                        { }
                        finally
                        {
                            cmd.Dispose();
                        }
                        return(res);
                    }
                }
                catch
                { }
            }
            return(null);
        }
예제 #23
0
파일: Db.cs 프로젝트: OSRS/Oncor_Base
        //\"Id\", \"EventSystemId\", \"EventId\", \"SiteSystemId\", \"SiteId\", \"PlotTypeId\", \"PointLocation\", \"Area\", \"ElevMin\", \"ElevMax\", \"Description\", \"IsPrivate\"
        public VegSurvey Build(DbDataReader reader)
        {
            VegSurvey tmp = new VegSurvey(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)), new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 5)),
                                          Db.GetLoc(reader, 6), DbReaderUtils.GetSingle(reader, 7), DbReaderUtils.GetSingle(reader, 8), DbReaderUtils.GetSingle(reader, 9), DbReaderUtils.GetString(reader, 10), (bool)reader[11]);

            if (tmp.IsPrivate)
            {
                if (prov == null)
                {
                    return(null); //can't verify
                }
                if (!prov.HasAffiliationForSampleEvent(tmp.SampleEventId, false))
                {
                    return(null);
                }
            }

            return(tmp);
        }
예제 #24
0
        //\"Id\", \"FishId\", \"GeneticSampleId\", \"LabSampleId\", \"StockEstimates\", \"Description\"   --NOTE Stock Estimates are an encoded value
        public FishGenetics Build(DbDataReader reader)
        {
            FishGenetics tmp = new FishGenetics(DbReaderUtils.GetGuid(reader, 0), DbReaderUtils.GetGuid(reader, 1), DbReaderUtils.GetString(reader, 2), DbReaderUtils.GetString(reader, 3), Decode(DbReaderUtils.GetString(reader, 4)), DbReaderUtils.GetString(reader, 5));

            if (!seen.Contains(tmp.FishId))
            {
                seen.Add(tmp.FishId);
                Fish e = this.helperBuilder.GetFish(tmp.FishId);
                if (e != null)
                {
                    got.Add(tmp.FishId);
                }
            }

            if (!got.Contains(tmp.FishId))
            {
                return(null);
            }

            return(tmp);
        }
예제 #25
0
 public override IEnumerable <Site> GetChildren(CompoundIdentity parentSite)
 {
     if (!parentSite.IsNullOrEmpty() && this.CanGet())
     {
         NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
         cmd.CommandText = Db.SelectHierarchy + Db.SelectHierarchyByParent + " AND" + Db.WhereCurrent;
         cmd.Parameters.AddWithValue("sid", parentSite.DataStoreIdentity);
         cmd.Parameters.AddWithValue("id", parentSite.Identity);
         NpgsqlDataReader rdr     = Db.ExecuteReader(cmd);
         List <Site>      schemes = new List <Site>();
         Site             o       = null;
         if (rdr != null)
         {
             try
             {
                 while (rdr.Read())
                 {
                     o = this.Get(new CompoundIdentity(DbReaderUtils.GetGuid(rdr, 2), DbReaderUtils.GetGuid(rdr, 3)));
                     if (o != null)
                     {
                         schemes.Add(o);
                     }
                 }
                 if (cmd.Connection.State == System.Data.ConnectionState.Open)
                 {
                     cmd.Connection.Close();
                 }
             }
             catch
             { }
             finally
             {
                 cmd.Dispose();
             }
         }
         return(schemes);
     }
     return(null);
 }
예제 #26
0
        public FieldTrip Build(DbDataReader reader)
        {
            Guid     sid   = DbReaderUtils.GetGuid(reader, 0);
            Guid     id    = DbReaderUtils.GetGuid(reader, 1);
            Guid     fasid = DbReaderUtils.GetGuid(reader, 2);
            Guid     fid   = DbReaderUtils.GetGuid(reader, 3);
            Guid     osid  = DbReaderUtils.GetGuid(reader, 4);
            Guid     oid   = DbReaderUtils.GetGuid(reader, 5);
            string   name  = DbReaderUtils.GetString(reader, 6);
            string   desc  = DbReaderUtils.GetString(reader, 7);
            DateTime start = Db.SafeGetDate(reader, 8, DateTime.MinValue);
            DateTime end   = Db.SafeGetDate(reader, 9, DateTime.MaxValue);

            if (start > DateTime.MinValue)
            {
                return(new FieldTrip(new CompoundIdentity(sid, id), name, new CompoundIdentity(fasid, fid), new CompoundIdentity(osid, oid), new Numerics.ValueRange <DateTime>(start, end), desc));
            }
            else
            {
                return(new FieldTrip(new CompoundIdentity(sid, id), name, new CompoundIdentity(fasid, fid), new CompoundIdentity(osid, oid), null, desc));
            }
        }
예제 #27
0
        /// <summary>
        /// Tuple Order: InstrumentTypeId, ArchetypeId
        /// </summary>
        /// <returns></returns>
        public override IEnumerable <Tuple <CompoundIdentity, CompoundIdentity> > GetInstrumentTypeKnownArchetypes()
        {
            //Dsid for all known archetypes
            Guid archetypeDsid = new Guid("{5F297502-B620-42BF-80BC-A4AF5A597267}");

            if (this.CanGet())
            {
                NpgsqlCommand cmd = Db.GetCmd(Db.ConnectionString);
                cmd.CommandText = Db.SelectInstrumentTypeKnownArchetype;
                NpgsqlDataReader rdr = Db.ExecuteReader(cmd);
                List <Tuple <CompoundIdentity, CompoundIdentity> > perms = new List <Tuple <CompoundIdentity, CompoundIdentity> >();
                try
                {
                    CompoundIdentity inst;
                    CompoundIdentity arch;
                    while (rdr.Read())
                    {
                        inst = new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(rdr, 0));
                        arch = new CompoundIdentity(archetypeDsid, DbReaderUtils.GetGuid(rdr, 1));
                        if (inst != null && arch != null)
                        {
                            perms.Add(new Tuple <CompoundIdentity, CompoundIdentity>(inst, arch));
                        }
                    }
                    if (cmd.Connection.State == System.Data.ConnectionState.Open)
                    {
                        cmd.Connection.Close();
                    }
                }
                catch
                { }
                finally
                {
                    cmd.Dispose();
                }
                return(perms);
            }
            return(null);
        }
예제 #28
0
파일: Db.cs 프로젝트: OSRS/Oncor_Base
        //\"Id\", \"VegSampleId\", \"TaxaUnitSystemId\", \"TaxaUnitId\", \"Dbh\", \"Description\"
        public TreeSample Build(DbDataReader reader)
        {
            TreeSample tmp = new TreeSample((Guid)reader[0], DbReaderUtils.GetGuid(reader, 1), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 2), DbReaderUtils.GetGuid(reader, 3)),
                                            DbReaderUtils.GetSingle(reader, 4), DbReaderUtils.GetString(reader, 5));

            if (!seen.Contains(tmp.VegSampleId))
            {
                seen.Add(tmp.VegSampleId);
                VegSample e = this.helperBuilder.Get(tmp.VegSampleId);
                if (e != null)
                {
                    got.Add(tmp.VegSampleId);
                }
            }

            if (!got.Contains(tmp.VegSampleId))
            {
                return(null);
            }

            return(tmp);
        }
예제 #29
0
        //\"Id\", \"CatchEffortId\", \"MetricType\", \"Value\", \"Description\"
        public CatchMetric Build(DbDataReader reader)
        {
            CatchMetric tmp = new CatchMetric(DbReaderUtils.GetGuid(reader, 0), new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 1)),
                                              DbReaderUtils.GetSingle(reader, 3), DbReaderUtils.GetString(reader, 2), DbReaderUtils.GetString(reader, 4));

            if (!seen.Contains(tmp.CatchEffortId))
            {
                seen.Add(tmp.CatchEffortId);
                CatchEffort e = this.helperBuilder.Get(tmp.CatchEffortId);
                if (e != null)
                {
                    got.Add(tmp.CatchEffortId);
                }
            }

            if (!got.Contains(tmp.CatchEffortId))
            {
                return(null);
            }

            return(tmp);
        }
예제 #30
0
        //\"Id\", \"CatchEffortId\", \"TaxaSystemId\", \"TaxaId\", \"Count\", \"Description\"
        public FishCount Build(DbDataReader reader)
        {
            FishCount tmp = new FishCount(DbReaderUtils.GetGuid(reader, 0), new CompoundIdentity(Db.DataStoreIdentity, DbReaderUtils.GetGuid(reader, 1)), new CompoundIdentity(DbReaderUtils.GetGuid(reader, 2), DbReaderUtils.GetGuid(reader, 3)),
                                          (uint)DbReaderUtils.GetInt32(reader, 4), DbReaderUtils.GetString(reader, 5));

            if (!seen.Contains(tmp.CatchEffortId))
            {
                seen.Add(tmp.CatchEffortId);
                CatchEffort e = this.helperBuilder.Get(tmp.CatchEffortId);
                if (e != null)
                {
                    got.Add(tmp.CatchEffortId);
                }
            }

            if (!got.Contains(tmp.CatchEffortId))
            {
                return(null);
            }

            return(tmp);
        }