public void insert_photo_info(string old_photo_url, Guid photoID, string photo_author, string input_camera_model) { String camera_model = ""; String f_stop = ""; String exposure_time = ""; String iso_speed = ""; String exposure_bias = ""; String focal_length = ""; String max_aperture = ""; String meeting_mode = ""; String subject_distance = ""; String flash_mode = ""; String shutter = ""; String aperture = ""; try { Goheer.EXIF.EXIFextractor image_info; //save image EXIF information image_info = CheckEXIF(old_photo_url); if (input_camera_model.Length == 0) { try { camera_model = image_info["Equip Model"].ToString(); } catch (Exception e) { camera_model = ""; } } else { camera_model = input_camera_model; } try { f_stop = image_info["F-Number"].ToString(); } catch (Exception e) { f_stop = ""; } try { exposure_time = image_info["Exposure Time"].ToString(); } catch (Exception e) { exposure_time = ""; } try { iso_speed = image_info["ISO Speed"].ToString(); } catch (Exception e) { iso_speed = ""; } try { exposure_bias = image_info["Exposure Bias"].ToString(); } catch (Exception e) { exposure_bias = ""; } try { focal_length = image_info["FocalLength"].ToString(); } catch (Exception e) { focal_length = ""; } try { max_aperture = image_info["MaxAperture"].ToString(); } catch (Exception e) { max_aperture = ""; } try { meeting_mode = image_info["Metering Mode"].ToString(); } catch (Exception e) { meeting_mode = ""; } try { subject_distance = image_info["Subject Loc"].ToString(); } catch (Exception e) { subject_distance = ""; } try { flash_mode = image_info["Flash"].ToString(); } catch (Exception e) { flash_mode = ""; } try { aperture = image_info["Aperture"].ToString(); } catch (Exception e) { aperture = ""; } try { shutter = image_info["Shutter Speed"].ToString(); } catch (Exception e) { shutter = ""; } } catch (Exception ex) { returnResult += string.Format("[Insert Photo Info]Error of {0}. RowID: {1} \r\n", ex.Message.ToString(), rowID); file.WriteLine(string.Format("[Insert Photo Info]Error of {0}. RowID: {1} \r\n", ex.Message.ToString(), rowID)); //Bitmap bmp = new Bitmap(old_photo_url); //// Get the PropertyItems property from image. //PropertyItem[] propItems = bmp.PropertyItems; //foreach (PropertyItem propItem in propItems) //{ // if (propItem.Id.ToString("x") == "110") // { // if (input_camera_model.Length == 0) // { // camera_model = System.Text.Encoding.Unicode.GetString(propItem.Value); // } // else // { // camera_model = input_camera_model; // } // } // if (propItem.Id.ToString("x") == "829D") // { // f_stop = propItem.GetType().ToString(); // f_stop = Convert.ToDouble(propItem.Value).ToString(); // } // if (propItem.Id.ToString("x") == "829A") // { // exposure_time = Convert.ToInt32(propItem.Value).ToString(); // } // if (propItem.Id.ToString("x") == "8827") // { // iso_speed = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "9204") // { // exposure_bias = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "920A") // { // focal_length = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "9205") // { // max_aperture = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "9207") // { // meeting_mode = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "A214") // { // subject_distance = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "9209") // { // flash_mode = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "9202") // { // aperture = System.Text.Encoding.UTF8.GetString(propItem.Value); // } // if (propItem.Id.ToString("x") == "9201") // { // shutter = System.Text.Encoding.UTF8.GetString(propItem.Value); // } //} } AlbumPhoto_info photo_info = new AlbumPhoto_info { PhotoID = photoID, camera_model = camera_model, f_stop = f_stop, exposure_time = exposure_time, iso_speed = iso_speed, exposure_bias = exposure_bias, focal_length = focal_length, max_aperture = max_aperture, meeting_mode = meeting_mode, subject_distance = subject_distance, flash_mode = flash_mode, Author = photo_author, aperture = aperture, shutter = shutter }; // Add the new object to the Orders collection. HKSPA_ms_db.AlbumPhoto_infos.InsertOnSubmit(photo_info); // Submit the change to the database. try { HKSPA_ms_db.SubmitChanges(); } catch (Exception e) { returnResult += string.Format("[insert_photo_info]Error of {0}. RowID: {1} \r\n", e.Message.ToString(), rowID); file.WriteLine(string.Format("[Insert Photo Info]Error of {0}. RowID: {1} \r\n", e.Message.ToString(), rowID)); // Make some adjustments. // ... // Try again. HKSPA_ms_db.SubmitChanges(); } }
partial void UpdateAlbumPhoto_info(AlbumPhoto_info instance);
partial void DeleteAlbumPhoto_info(AlbumPhoto_info instance);
partial void InsertAlbumPhoto_info(AlbumPhoto_info instance);