Exemplo n.º 1
0
        string BuildDestinationFullFilePathname(System.IO.FileInfo sourceFi, DateTime fileDateTime, UserProject project)
        {
            string GetLevelName(int index)
            {
                string name = String.Empty;

                //[ 西元年分 月份 日期 (無) ]
                switch (project.folderStructure[index])
                {
                case "西元年分":
                    name = fileDateTime.Year.ToString() + "年";
                    break;

                case "月份":
                    name = fileDateTime.Month.ToString() + "月";
                    break;

                case "日期":
                    name = fileDateTime.Day.ToString() + "日";
                    break;
                }
                return(name);
            }

            //---------------------------------------------------------------------------------
            string dFilePathname = null, subFolder = @"\";

            //Lv: [ 西元年分 月份 日期 (無) ]
            subFolder += GetLevelName(0) + @"\";
            subFolder += GetLevelName(1) + @"\";
            string Lv3 = GetLevelName(2);

            subFolder += (Lv3 != String.Empty)?Lv3 + @"\" : "";

            string newFileName = sourceFi.Name;

            if (project.isRename)
            {
                newFileName = string.Format("{0:0000}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                            fileDateTime.Year,
                                            fileDateTime.Month,
                                            fileDateTime.Day,
                                            fileDateTime.Hour,
                                            fileDateTime.Minute,
                                            fileDateTime.Second
                                            ) + sourceFi.Extension;
            }
            dFilePathname = project.targetRootPathname + subFolder + newFileName;

            return(dFilePathname);
        }
Exemplo n.º 2
0
        private void BTN_Execution_Click(object sender, RoutedEventArgs e)
        {
            TBX_SourceFolder.Text = TBX_SourceFolder.Text.TrimEnd('\\');
            TBX_TargetFolder.Text = TBX_TargetFolder.Text.TrimEnd('\\');
            //Check Data Correct
            if (!Directory.Exists(TBX_SourceFolder.Text))
            {
                System.Windows.MessageBox.Show("來源路徑不存在,請重新設定", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (!Directory.Exists(TBX_TargetFolder.Text))
            {
                System.Windows.MessageBox.Show("目的路徑不存在,請重新設定", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (TBX_TargetFolder.Text == TBX_SourceFolder.Text)
            {
                System.Windows.MessageBox.Show("來源路徑 與 目的路徑 相同,請重新設定", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            //Take off redoundent SPACE.
            string[] imageFileExts = TBX_ImageExtends.Text.Replace(" ", null).ToLower().Split(',');
            string[] videoFileExts = TBX_VideoExtends.Text.Replace(" ", null).ToLower().Split(',');
            TBX_ImageExtends.Text = string.Join(", ", project.imageFileExts);
            TBX_VideoExtends.Text = string.Join(", ", project.videoFileExts);

            List <string> fstruct = new List <string>()
            {
                CBX_Level1.Text, CBX_Level2.Text, CBX_Level3.Text
            };

            //建立專案
            project = new UserProject()
            {
                sourceRootPathname = TBX_SourceFolder.Text,
                targetRootPathname = TBX_TargetFolder.Text,
                imageFileExts      = imageFileExts,
                videoFileExts      = videoFileExts,
                fAction            = (UserProject.FileAction)CBX_FileAct.SelectedIndex,
                folderStructure    = fstruct.ToArray(),
                isRename           = (CBX_FileRenameAsCopyMove.IsEnabled && CBX_FileRenameAsCopyMove.IsChecked == true),
                isTheSameContentByComparedBinary = (CBX_CHKBinary.IsEnabled && CBX_CHKBinary.IsChecked == true),
                isContentConfirmByComparedBinary = (CBX_ReCHKBinary.IsEnabled && CBX_ReCHKBinary.IsChecked == true),
                isAddInfoFile = (CBX_AddInfoFileAsCopyMove.IsEnabled && CBX_AddInfoFileAsCopyMove.IsChecked == true)
            };
            project.Save(); //紀錄

            if (project.isContentConfirmByComparedBinary && project.fAction == UserProject.FileAction.Move)
            {
                if (System.IO.Path.GetPathRoot(project.sourceRootPathname) == System.IO.Path.GetPathRoot(project.targetRootPathname))
                {
                    project.isContentConfirmByComparedBinary = false;
                }
                else
                {
                    //Change "project.fAction" to Copy + Delete.
                    project.fAction = UserProject.FileAction.CopyThenDelete;
                }
            }
            //執行
            ProcessWindow pw = new ProcessWindow()
            {
                project = project
            };

            pw.ShowDialog();
        }