public override void ProcessRecord(string[] tokens) { currentCount++; ImageData imageData = null; imageData = new ImageData { //Rollnum = int.Parse(tokens[1]), //framenum Width = int.Parse(tokens[3]), Height = int.Parse(tokens[4]), Filesize = int.Parse(tokens[5]), //CloudCoveragePercentage = int.Parse(tokens[6]), Latitude = double.Parse(tokens[7]), Longitude = double.Parse(tokens[8]), //tokens[9] //tokens[10] Lowresurl = tokens[11] }; imageData.DatasetID = GetDataSourceID(tokens[0]); int framenum = -1; int.TryParse(tokens[2], out framenum); imageData.Framenum = framenum; int rollnum = 0; int.TryParse(tokens[1], out rollnum); imageData.Rollnum = rollnum; int cloudCoverage = 0; int.TryParse(tokens[6], out cloudCoverage); imageData.CloudCoveragePercentage = cloudCoverage; imageData.Highresurl = imageData.Lowresurl.Replace("lowres", "highres"); _database.Imagedata.Add(imageData); if (currentCount > commitCount) { _database.SaveChanges(); //_database.Dispose(); //_database = new MarbleDataBase(); _database.Configuration.AutoDetectChangesEnabled = false; var imagedatacheck = from d in _database.Imagedata where d.ImageDataID == imageData.ImageDataID select d; foreach (ImageData id in imagedatacheck) { Console.WriteLine("{0} {1} {2} {3}", id.ImageDataID, id.Latitude, id.Longitude, id.Lowresurl); } currentCount = 0; } }
/// <summary> /// Returns a list of images before and after the given image based on the passed in range. /// Images returned are from the same dataset and roll as the base image. /// </summary> /// <param name="imageStart">starting image</param> /// <param name="range">range of images to create series</param> /// <returns></returns> private IEnumerable<ImageData> GetImageSeries(ImageData imageStart, int range) { //use dataset ID and roll to query imagedata for additional images in a series IEnumerable<ImageData> data = from image in Database.Imagedata where (image.DatasetID == imageStart.DatasetID && image.Rollnum == imageStart.Rollnum && image.Framenum >= 0 && image.ImageDataID >= (imageStart.ImageDataID - range) && image.ImageDataID <= (imageStart.ImageDataID + range)) select image; return data; }
// This is no longer needed since the API has been moved out of this project. //private Uri getServerUri() //{ // Uri serverUri = new Uri("http://bigmarbleapi.azurewebsites.net/"); // Default to azure site // HttpRequest request = HttpContext.ApplicationInstance.Request; // string uriStr = request.Url.AbsoluteUri.Replace(request.Url.AbsolutePath, String.Empty); // if (Uri.IsWellFormedUriString(uriStr, UriKind.Absolute)) // { // serverUri = new Uri(uriStr); // } // return serverUri; //} private void checkIfImageExists(ImageData image) { WebRequest request = WebRequest.Create(new Uri(image.Highresurl)); request.Method = "HEAD"; try { HttpWebResponse checkResponse = (HttpWebResponse)request.GetResponse(); } catch (Exception) { // Doesn't exist image.Highresurl = image.Lowresurl; } }