예제 #1
0
        public static List<Camera> GetCameras(List<int> Ids = null)
        {
            List<Camera> Cameras = new List<Camera>();

            string selector = DbManager.SelectorBuilder(Ids);

            SqlConnection con = DbManager.GetConnection();
            SqlCommand cmd = new SqlCommand();

            cmd = con.CreateCommand();

            cmd.CommandText = "SELECT [Id],[ShortName],[LongName],[MaxResolution],[ColorSpaces] FROM [tblCameras] " + selector;

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                int id = reader.GetInt32(0);
                string shortName = reader.GetString(1);
                string longName = reader.GetString(2);
                Size maxResolution = Utilities.StringToResolution(reader.GetString(3));
                List<ColorSpace> colorSpaces = ColorSpaceController.GetColorSpaces(
                    Utilities.StringToIntList(reader.GetString(4))
                );

                Cameras.Add(new Camera(id, shortName, longName, maxResolution, colorSpaces));
            }

            con.Close();
            return Cameras;
        }
예제 #2
0
        public static List <Collection> GetCollections(List <int> Ids = null)
        {
            List <Collection> collections = new List <Collection>();

            string selector = DbManager.SelectorBuilder(Ids);

            SqlConnection con = DbManager.GetConnection();
            SqlCommand    cmd = con.CreateCommand();

            cmd.CommandText = "SELECT [Id],[CaptureDateTime],[Catalogue],[Object],[ObjectTitle]," +
                              "[NumberFrames],[FileFormat],[ColorSpace],[Camera],[Scope],[Site],[Optics]," +
                              "[Photographer],[Resolution],[Comments],[FilePath],[MetadataFilePath] " +
                              "FROM [tblCollections] " + selector;

            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                int       id = reader.GetInt32(0);
                DateTime  captureDateTime = reader.GetDateTime(1);
                Catalogue catalogue       = CatalogueController.GetCatalogues(new List <int>()
                {
                    reader.GetInt32(2)
                })[0];
                int        objectId     = reader.GetInt32(3);
                string     objectTitle  = reader.GetString(4);
                int        numberFrames = reader.GetInt32(5);
                FileFormat fileFormat   = FileFormatController.GetFileFormats(new List <int>()
                {
                    reader.GetInt32(6)
                })[0];
                ColorSpace colorSpace = ColorSpaceController.GetColorSpaces(new List <int>()
                {
                    reader.GetInt32(7)
                })[0];
                Camera camera = CameraController.GetCameras(new List <int>()
                {
                    reader.GetInt32(8)
                })[0];
                Scope scope = ScopeController.GetScopes(new List <int>()
                {
                    reader.GetInt32(9)
                })[0];
                Site site = SiteController.GetSites(new List <int>()
                {
                    reader.GetInt32(10)
                })[0];
                List <Optic> optics       = OpticsController.GetOptics(Utilities.StringToIntList(reader.GetString(11)));
                Photographer photographer = PhotographerController.GetPhotographers(new List <int>()
                {
                    reader.GetInt32(12)
                })[0];
                Size   resolution   = Utilities.StringToResolution(reader.GetString(13));
                string comments     = reader.GetString(14);
                string filePath     = reader.GetString(15);
                string metadataFile = reader.GetString(16);

                collections.Add(new Collection(id, captureDateTime, catalogue, objectId, objectTitle,
                                               numberFrames, fileFormat, colorSpace, camera, scope, site, optics, photographer,
                                               resolution, comments, filePath, metadataFile));
            }

            con.Close();
            return(collections);
        }