示例#1
0
        // write new row into the DupesAction table
        private void DupesAction_Insert(CheckSum photo, string duplicateOf)
        {
            // set up the parameters for the stored procedure
            var p = new DynamicParameters();

            p.Add("@TheFileName", photo.FullName());
            p.Add("@DuplicateOf", duplicateOf);
            p.Add("@SHA", $"Photos with the same EXIF DateTime: {photo.SCreateDateTime}");
            p.Add("@FileExt", photo.FileExt);
            p.Add("@FileSize", photo.FileSize);
            p.Add("@FileCreateDt", photo.CreateDateTime);
            p.Add("@OneDriveRemoved", "Y");
            p.Add("@GooglePhotosRemoved", "N");

            using (IDbConnection cnn = new SqlConnection(GetConnectionString()))
            {
                cnn.Execute("dbo.spDupesAction_ins", p, commandType: CommandType.StoredProcedure);
            }
        }
示例#2
0
        private static string TargetFolderCheck(CheckSum photo)
        {
            string        targetFolder = Program.targetRootFolder;
            DirectoryInfo rootFolder   = new DirectoryInfo(Program.targetRootFolder);

            // make sure the targetRootFolder exists
            if (!rootFolder.Exists)
            {
                rootFolder.Create();
            }

            // construct the targetFolder for this CheckSum photo
            targetFolder += @photo.Folder.Substring(2);

            // if target folder does not exist then create it
            DirectoryInfo diTarget = new DirectoryInfo(targetFolder);

            if (!diTarget.Exists)
            {
                diTarget.Create();
            }

            return(targetFolder);
        }
示例#3
0
        // constructor called by form SelectbySHA passing in the SHA string of the selected duplicates
        public void DisplayPhotos4DateTime()
        {
            this.toolStripStatusLabel.Text = $"INFO - {this.CheckSumDates.Count()} CheckSumDates rows with CreateDateTime count > 1.";

            // get the first date from the collection
            this.CheckSumDate = this.CheckSumDates.First();

            string mess = $"There are {this.CheckSumDate.DupesCount} photos for the CreateDateTime: {this.CheckSumDate.CreateDateTime.ToString("yyyy-MM-dd HH:mm:ss")}";

            Log(mess);
            this.toolStripStatusLabel.Text = mess;

            // get a collection of the CheckSum rows for this CreationDate
            using (IDbConnection cnn = new SqlConnection(GetConnectionString()))
            {
                string sql = $"select * from CheckSum where CreateDateTime = '{this.CheckSumDate.CreateDateTime.ToString("yyyy-MM-dd HH:mm:ss")}' order by Id";

                this.CheckSums = cnn.Query <CheckSum>(sql).ToList();
            }

            // check for count errors
            if (this.CheckSumDate.DupesCount != this.CheckSums.Count)
            {
                mess = $"his.CheckSumDate.Count {this.CheckSumDate.DupesCount} != this.CheckSums.Count {this.CheckSums.Count}";
                Log(mess);
                MessageBox.Show(mess);
                this.Close();
            }

            // get the first photo
            this.Photo1 = this.CheckSums.First();

            // get the last photo
            this.Photo2 = this.CheckSums.Last();

            if (this.Photo2 == null)
            {
                this.toolStripStatusLabel.Text = $"WARN - Photo1 with DateTime: {this.Photo1.SCreateDateTime} cannot find any other photos.";
                return;
            }

            // Note the escape character used (@) when specifying the path.
            try
            {
                using (MemoryStream stream1 = new MemoryStream(File.ReadAllBytes([email protected]())))
                {
                    this.pictureBox1.Image = Image.FromStream(stream1);
                    stream1.Dispose();
                }
                using (MemoryStream stream2 = new MemoryStream(File.ReadAllBytes([email protected]())))
                {
                    this.pictureBox2.Image = Image.FromStream(stream2);
                    stream2.Dispose();
                }
            }
            catch (Exception e)
            {
                mess = $"{DateTime.Now} - ERROR\n\r{e.ToString()}";
                Log(mess);
                MessageBox.Show(mess);
                this.Close();
            }

            this.tbPhoto1.Text     = this.Photo1.FullName();
            this.tbPhoto2.Text     = this.Photo2.FullName();
            this.tbPhoto1Size.Text = this.Photo1.FileSize.ToString("N0");
            this.tbPhoto2Size.Text = this.Photo2.FileSize.ToString("N0");


            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        = this.Photo1.CreateDateTime;
            this.dateTimePhoto2.Value        = this.Photo2.CreateDateTime;

            this.cbPhoto1.Text = $"Move photo1 with Id {this.Photo1.Id.ToString()}";
            this.cbPhoto2.Text = $"Move photo2 with Id {this.Photo2.Id.ToString()}";
        }