// delete the CheckSum row that was moved so that CheckSum still reflects the folder scan, and remove the 2 CheckSumDups rows as the duplicate has been removed private void Db_Delete(CheckSum photo1, CheckSumDup checkSumDup1, CheckSumDup checkSumDup2) { Program.popsModel.CheckSums.Remove(photo1); Program.popsModel.CheckSumDups.Remove(checkSumDup1); Program.popsModel.CheckSumDups.Remove(checkSumDup2); Program.popsModel.SaveChanges(); }
// constructor called by form SelectbySHA passing in the SHA string of the selected duplicates public DisplayPhotos4SHA(string SHA) { InitializeComponent(); // query the model for the CheckSum rows with the selected SHA string IQueryable <CheckSum> query = Program.popsModel.CheckSums.Where(checkSum => checkSum.SHA == SHA).OrderBy(x => x.Id); // cast the query to an array of CheckSum rows checkSums = query.ToArray(); Photo1 = checkSums[0]; Photo2 = checkSums[1]; this.toolStripStatusLabel.Text = $"{checkSums.Length} duplicate photos - {SHA}"; // get the CheckSumDup rows from the db for the 2 photos IQueryable <CheckSumDup> query2 = Program.popsModel.CheckSumDups.Where(a => a.Id == Photo1.Id || a.Id == Photo2.Id).OrderBy(b => b.Id); this.checkSumDups = query2.ToArray(); if (this.checkSumDups.Length == 1) { this.toolStripStatusLabel.Text = "ERROR - Only 1 photo found for this SHA value."; return; } this.checkSumDup1 = checkSumDups[0]; this.checkSumDup2 = checkSumDups[1]; // Note the escape character used (@) when specifying the path. try { this.pictureBox1.Image = Image.FromStream(new MemoryStream(File.ReadAllBytes(@Photo1.TheFileName))); this.pictureBox2.Image = Image.FromStream(new MemoryStream(File.ReadAllBytes(@Photo2.TheFileName))); } catch (Exception) { MessageBox.Show($"Truncation error - Photo1 {Photo1.TheFileName} or 2 {Photo2.TheFileName} could not be found."); Close(); } //this.pictureBox1.Image = Image.FromFile(Photo1.TheFileName); //this.pictureBox2.Image = Image.FromFile(Photo2.TheFileName); this.tbPhoto1.Text = Photo1.TheFileName; this.tbPhoto2.Text = Photo2.TheFileName; this.dateTimePhoto1.Format = DateTimePickerFormat.Custom; this.dateTimePhoto2.Format = DateTimePickerFormat.Custom; this.dateTimePhoto1.CustomFormat = "yyyy-MM-dd hh:mm:ss"; this.dateTimePhoto2.CustomFormat = "yyyy-MM-dd hh:mm:ss"; this.dateTimePhoto1.Value = Photo1.FileCreateDt; this.dateTimePhoto2.Value = Photo2.FileCreateDt; this.cbPhoto1.Text = $"Move photo1 with Id {Photo1.Id.ToString()}"; this.cbPhoto2.Text = $"Move photo2 with Id {Photo2.Id.ToString()}"; }