Example #1
0
        public void DbExport()
        {
            try
            {
                // Mysqlのcontentsへ登録
                DbExportContents();
                logger.Debug("DbExportContents mysql register completed");

                // SQL ServerのMOVIE_FILESへ登録
                // dbcon.BeginTransaction("MOVIE_REGISTER");
                // DbExportMovieFiles();
                // dbcon.CommitTransaction();
                logger.Debug("DbExportContents sql server register completed");

                // MOVIE_IMPORTから削除
                MovieImportService service = new MovieImportService();
                service.DbDelete(targetImportData, new MySqlDbConnection());
                logger.Debug("mysql import delete completed");
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
                dbcon.RollbackTransaction();
                throw new Exception(ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// 全削除ボタンを押下された場合に実行、dgridDestFileファイルの削除、MOVIE_IMPORT_DATAのDb削除を行う
        /// </summary>
        public void DeleteExecute(List <TargetFiles> myListTargetFiles)
        {
            if (targetImportData == null)
            {
                throw new Exception("targetImportDataが設定されていません");
            }

            try
            {
                dbcon.BeginTransaction("MOVIE_REGISTER");

                DeleteFiles(myListTargetFiles);

                dbcon.CommitTransaction();
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
                dbcon.RollbackTransaction();
                throw new Exception(ex.Message);
            }

            // MOVIE_IMPORTから削除
            MovieImportService service = new MovieImportService();

            service.DbDelete(targetImportData, new MySqlDbConnection());
        }
Example #3
0
        public void ExecuteArrangement(MovieImportData myTargetImportData, StoreData myStoreData, List <KoreanPornoFileInfo> myListFileInfo, string myComment)
        {
            List <KoreanPornoFileInfo> jpegFiles  = new List <KoreanPornoFileInfo>();
            List <KoreanPornoFileInfo> movieFiles = new List <KoreanPornoFileInfo>();

            Regex regex = new Regex(FileGeneTargetFilesCollection.REGEX_IMAGE_EXTENTION, RegexOptions.IgnoreCase);

            foreach (KoreanPornoFileInfo data in myListFileInfo)
            {
                if (data.IsSelected && regex.IsMatch(data.FileInfo.Name))
                {
                    jpegFiles.Add(data);
                }
                else if (data.IsSelected)
                {
                    movieFiles.Add(data);
                }
            }

            long   totalSize  = 0;
            string extensions = "";

            foreach (KoreanPornoFileInfo data in movieFiles)
            {
                totalSize += data.FileInfo.Length;

                string ext = data.FileInfo.Extension.Substring(1);
                if (extensions.Length <= 0)
                {
                    extensions = ext;
                }
                else
                {
                    if (extensions.IndexOf(ext, StringComparison.OrdinalIgnoreCase) < 0)
                    {
                        extensions = extensions + "," + ext;
                    }
                }
            }

            KoreanPornoData targetData = new KoreanPornoData();

            targetData.Name          = myTargetImportData.CopyText;
            targetData.Size          = totalSize;
            targetData.FileCount     = movieFiles.Count;
            targetData.Extension     = extensions.ToUpper();
            targetData.Label         = ExportPath;
            targetData.LastWriteTime = myTargetImportData.JavPostDate;
            targetData.Tag           = myTargetImportData.Tag;
            targetData.Rating        = myTargetImportData.Rating;
            targetData.Comment       = myComment;

            // ファイル移動先の生成(D:\Downloads\TEMP\KOREAN_PORNO7のフォルダを無ければ作成)
            string moveDestName = new DirectoryInfo(ExportPath).Name;
            string moveDestPath = Path.Combine(BasePath, moveDestName);

            if (!Directory.Exists(moveDestPath))
            {
                DirectoryInfo dir = Directory.CreateDirectory(moveDestPath);
                moveDestPath = dir.FullName;
            }

            // JPEGファイルsの移動
            int suffixNum = 1;

            foreach (var jpegFile in jpegFiles)
            {
                string filename = "";
                if (jpegFiles.Count == 1)
                {
                    filename = $"{myTargetImportData.CopyText}.jpg";
                }
                else
                {
                    filename = $"{myTargetImportData.CopyText}_{suffixNum}.jpg";
                }

                if (File.Exists(Path.Combine(moveDestPath, filename)))
                {
                    throw new Exception($"JPEG 既に同じファイル名が存在します {filename}");
                }

                File.Move(jpegFile.FileInfo.FullName, Path.Combine(moveDestPath, filename));
                suffixNum++;
            }

            // フォルダ作成しての動画の移動はJPEGの移動が終了してから
            if (IsCheckMoveFolder == true)
            {
                moveDestPath = Path.Combine(moveDestPath, targetData.Name);

                if (!Directory.Exists(moveDestPath))
                {
                    DirectoryInfo dir = Directory.CreateDirectory(moveDestPath);
                    moveDestPath = dir.FullName;
                }
            }

            // 動画ファイルの移動、ファイル更新日
            suffixNum = 1;
            foreach (KoreanPornoFileInfo file in movieFiles)
            {
                string filename = "";
                if (IsCheckMoveFolder == true)
                {
                    filename = file.DisplayFilename;
                }
                else
                {
                    if (movieFiles.Count == 1)
                    {
                        filename = $"{myTargetImportData.CopyText}{file.FileInfo.Extension}";
                    }
                    else
                    {
                        filename = $"{myTargetImportData.CopyText}_{suffixNum}{file.FileInfo.Extension}";
                    }
                }
                if (File.Exists(Path.Combine(moveDestPath, filename)))
                {
                    throw new Exception($"動画 既に同じファイル名が存在します {filename}");
                }

                string destFilename = System.IO.Path.Combine(moveDestPath, filename);
                // File.SetLastWriteTime(file.FileInfo.FullName, file.ChangeLastWriteTime);
                File.Move(file.FileInfo.FullName, destFilename);
                suffixNum++;
            }

            if (IsCheckMoveFolder == true)
            {
                foreach (KoreanPornoFileInfo file in myListFileInfo)
                {
                    if (file.FileInfo.Extension == ".txt")
                    {
                        continue;
                    }

                    if (file.FileInfo.Extension == ".zip")
                    {
                        continue;
                    }

                    if (!File.Exists(file.FileInfo.FullName))
                    {
                        continue;
                    }

                    string destFilename = System.IO.Path.Combine(moveDestPath, file.DisplayFilename);
                    File.Move(file.FileInfo.FullName, destFilename);
                }
            }

            DbExportContents(targetData, myStoreData);
            DbExport(targetData, new DbConnection());

            string rarFile          = myTargetImportData.ProductNumber + ".rar";
            string archiveFilePath  = System.IO.Path.Combine(BasePath, rarFile);
            string frozenFolderPath = System.IO.Path.Combine(BasePath, myTargetImportData.ProductNumber);

            // 圧縮ファイル(Rar)の削除(ゴミ箱)
            if (File.Exists(archiveFilePath))
            {
                FileSystem.DeleteFile(
                    archiveFilePath,
                    UIOption.OnlyErrorDialogs,
                    RecycleOption.SendToRecycleBin);
            }

            // 解凍フォルダの削除(ゴミ箱)
            if (!string.IsNullOrEmpty(frozenFolderPath))
            {
                if (Directory.Exists(frozenFolderPath))
                {
                    FileSystem.DeleteDirectory(frozenFolderPath,
                                               UIOption.OnlyErrorDialogs,
                                               RecycleOption.SendToRecycleBin);
                }
            }

            MovieImportService importService = new MovieImportService();

            importService.DbDelete(myTargetImportData, new MySqlDbConnection());
        }
Example #4
0
        public void Execute(MovieImportData myImportData, MovieFileContents myFileContents)
        {
            string destDir = "HD-" + myFileContents.GetLastSentenceFromLabel();

            string fullPath = Path.Combine(BasePath, destDir);

            if (!Directory.Exists(fullPath))
            {
                Directory.CreateDirectory(fullPath);
            }

            long     size = 0;
            string   ext  = "";
            DateTime dt   = new DateTime(1900, 1, 1);

            foreach (TargetFiles data in listSelectedFiles)
            {
                string destFilename = Path.Combine(fullPath, myImportData.Filename + data.FileInfo.Extension);
                size += data.FileInfo.Length;
                ext   = data.FileInfo.Extension.Substring(1);
                dt    = data.FileInfo.LastWriteTime;
                File.Move(data.FileInfo.FullName, destFilename);
            }

            // JPEGなどのファイルのファイル名を変更(ファイル名を「XXX FHD」に更新する前にファイル名変更を実行)
            string[] mvFiles = Directory.GetFiles(myFileContents.Label, myFileContents.Name + "*");
            Debug.Print(" " + myFileContents.Label + "   " + myFileContents.Name);

            foreach (string pathname in mvFiles)
            {
                FileInfo fileinfo       = new FileInfo(pathname);
                string   sourcePathname = pathname;
                string   sufix          = fileinfo.Name.Replace(myFileContents.Name, "");
                Debug.Print("sufix" + sufix + " pathname " + pathname);
                string destPathname = Path.Combine(myFileContents.Label, myImportData.Filename + sufix.ToLower());

                File.Move(sourcePathname, destPathname);
            }

            MovieFileContentsService service = new MovieFileContentsService();

            myFileContents.Name = myImportData.Filename;
            myFileContents.Size = size;
            if (!myFileContents.Extension.ToUpper().Equals(ext.ToUpper()))
            {
                MessageBoxResult result = MessageBox.Show("既存のファイルは削除しますか?", "削除確認", MessageBoxButton.OKCancel);

                if (result == MessageBoxResult.OK)
                {
                    string[] files = Directory.GetFiles(myFileContents.Label, myFileContents.Name + "*" + myFileContents.Extension);

                    List <TargetFiles> delTargetList = new List <TargetFiles>();

                    foreach (string pathname in files)
                    {
                        TargetFiles targetFiles = new TargetFiles();
                        targetFiles.FileInfo = new FileInfo(pathname);
                        delTargetList.Add(targetFiles);
                    }

                    FilesRegisterService serviceFileRegister = new FilesRegisterService(dbcon);
                    serviceFileRegister.BasePath = BasePath;
                    serviceFileRegister.SetDbMovieFilesInfo(myImportData, null);
                    serviceFileRegister.DeleteFiles(delTargetList);
                }
                myFileContents.Extension = ext;
            }

            try
            {
                dbcon.BeginTransaction("MOVIE_REGISTER");

                service.DbUpdateFileInfo(myFileContents, dbcon);

                dbcon.CommitTransaction();

                // MOVIE_IMPORTから削除
                MovieImportService serviceImportService = new MovieImportService();
                serviceImportService.DbDelete(myImportData, new MySqlDbConnection());
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
                dbcon.RollbackTransaction();
                throw new Exception(ex.Message);
            }

            return;
        }