internal T_Result ReadDependencies(string solutionFolder) { var result = new T_Result(); var packagesDirectory = DirectoryTools.SearchDirectory(solutionFolder, GetPackagesFolder); if (string.IsNullOrEmpty(packagesDirectory)) { Log.Error("Can't fing packages folder in {solutionDirectory}. Aborting nuget reference scan.", solutionFolder); return(null); } foreach (var folder in Directory.GetDirectories(packagesDirectory)) { var nuspec = Directory.GetFiles(folder, "*.nupkg", SearchOption.TopDirectoryOnly).FirstOrDefault(); if (nuspec == null) { Log.Warning("Can't find nuspec in {source}", folder); continue; } var package = new ZipPackage(nuspec); var id = package.Id; var version = package.Version; var dependencies = package.DependencySets; if (result.ContainsKey(id)) { result[id].Add(version, dependencies); } else { var temp = new Dictionary <SemanticVersion, IEnumerable <PackageDependencySet> >() { { version, dependencies } }; result.Add(id, temp); } } return(result); }
private void DeletePreviewPictures(IEnumerable <PreviewPictures> pics, int articleId) { if (pics != null && pics.Count() > 0) { foreach (var pic in pics) { if (pic.LargeSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.LargeSizePath, AppConstants.dirNewsPreview); } if (pic.SmallSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.SmallSizePath, AppConstants.dirNewsPreview); } } newsSrv.RemovePicture(articleId, null); } }
public ActionResult DeletePicture(int picId, int articleId) { var pic = newsSrv.GetPicture(picId); if (pic != null) { if (pic.LargeSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.LargeSizePath); } if (pic.SmallSizePath != null) { DirectoryTools.DeleteFile(HttpContext, pic.SmallSizePath); } newsSrv.RemovePicture(picId); } return(RedirectToAction("Edit", new { id = articleId })); }
private void CopyFileRDirToWDir2(string file, string name_option) { string destFile = FileTools.GetCounteredPath(file, RDir, WDir); string midFile = StringTools.Combine(WorkDir, "CopyFileRDirToWDir.mid"); Gnd.ConvLog.Writeln("COPY-FILE-BY-OPTION_" + name_option); Gnd.ConvLog.Writeln("< " + file); Gnd.ConvLog.Writeln("$ " + midFile); Gnd.ConvLog.Writeln("> " + destFile); FileTools.DeleteFileIfExist(midFile); File.Copy(file, midFile); // 出力ファイルのクリア { DirectoryTools.DeletePath(destFile); Directory.CreateDirectory(destFile); Directory.Delete(destFile); } if (File.Exists(destFile)) { throw new Exception("ファイルのコピーに失敗しました。(出力ファイルをクリア出来ません) OPTION_" + name_option); } #if true File.Copy(midFile, destFile); File.Delete(midFile); #else // 権限とか圧縮状態とか引き継いでしまうので、没.. File.Move(midFile, destFile); #endif if (File.Exists(destFile) == false) { throw new Exception("ファイルのコピーに失敗しました。(出力ファイルを生成出来ません) OPTION_" + name_option); } if (File.Exists(midFile)) { throw new Exception("ファイルのコピーに失敗しました。(midFile exist) OPTION_" + name_option); } }
internal static void DaemonGet(Library library, string fingerprint) { string filename_full = PDFDocumentFileLocations.DocumentPath(library, fingerprint, "pdf"); string filename_short = Path.GetFileName(filename_full); string pdf_path = IntranetLibraryTools.GetLibraryPDFPath(library.WebLibraryDetail.IntranetPath, filename_short); DirectoryTools.CreateDirectory(Path.GetDirectoryName(filename_full)); Logging.Info("+Copying down {0}", fingerprint); File.Copy(pdf_path, filename_full); Logging.Info("-Copying down {0}", fingerprint); // Write the audit if (true) { string audit_filename = IntranetLibraryTools.GetLibraryAuditFilename(library.WebLibraryDetail.IntranetPath); string audit_directory = Path.GetDirectoryName(audit_filename); if (Directory.Exists(audit_directory)) { string audit_data = String.Format( "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\r\n" , DateTime.UtcNow.ToString("yyyyMMdd.hhmmss") , ConfigurationManager.Instance.ConfigurationRecord.Account_Username , ConfigurationManager.Instance.ConfigurationRecord.Account_Nickname , Environment.UserName , filename_short , pdf_path ); try { File.AppendAllText(audit_filename, audit_data); } catch (Exception ex) { Logging.Warn(ex, "Unable to write intranet sync audit data."); } } } }
private static void Main() { var documents = DirectoryTools.ReadStringDictionary(InputFile); var groundTruth = DuplicateRates.FromLines(File.ReadLines(GroundTruthFile), documents.Keys); var result = new { Min1 = ProcessMinHash(groundTruth, documents, 1), Min5 = ProcessMinHash(groundTruth, documents, 5), Min10 = ProcessMinHash(groundTruth, documents, 10), Min30 = ProcessMinHash(groundTruth, documents, 30), Min50 = ProcessMinHash(groundTruth, documents, 50), Min100 = ProcessMinHash(groundTruth, documents, 100), Sim8 = ProcessSimHash(groundTruth, documents, 8 / 8), Sim16 = ProcessSimHash(groundTruth, documents, 16 / 8), Sim64 = ProcessSimHash(groundTruth, documents, 64 / 8), Sim128 = ProcessSimHash(groundTruth, documents, 128 / 8), Sim256 = ProcessSimHash(groundTruth, documents, 256 / 8), }; DirectoryTools.SaveAsJson(result, OutputFile); }
/// <summary> /// Deflate (compress) an archive /// </summary> /// /// <param name="DirectoryPath">The directory path to the files to be processed</param> /// <param name="OutStream">The stream receiving the compressed and encrypted archive</param> public void Deflate(string DirectoryPath, Stream OutStream) { if (!m_isInitialized) { throw new CryptoProcessingException("CompressionCipher:Compress", "The class is not be Initialized!", new ArgumentException()); } if (!DirectoryTools.Exists(DirectoryPath)) { throw new CryptoProcessingException("CompressionCipher:Deflate", "The directory does not exist!", new ArgumentException()); } if (DirectoryTools.FileCount(DirectoryPath) < 1) { throw new CryptoProcessingException("CompressionCipher:Deflate", "There are no files in this directory!", new ArgumentException()); } // compress MemoryStream inStream = m_cmpEngine.CompressArchive(DirectoryPath); inStream.Seek(0, SeekOrigin.Begin); // encrypt output base.Write(inStream, OutStream); OutStream.Seek(0, SeekOrigin.Begin); }
/// <summary> /// Inflate (decompress) an archive /// </summary> /// /// <param name="DirectoryPath">The directory path where files will be written</param> /// <param name="InStream">The stream containing the compressed archive</param> public void Inflate(string DirectoryPath, Stream InStream) { if (!m_isInitialized) { throw new CryptoProcessingException("CompressionCipher:Compress", "The class is not be Initialized!", new ArgumentException()); } if (!DirectoryTools.Exists(DirectoryPath)) { Directory.CreateDirectory(DirectoryPath); } if (!DirectoryTools.IsWritable(DirectoryPath)) { throw new CryptoProcessingException("CompressionCipher:InFlate", "Directory path is not writable! Check permissions.", new AccessViolationException()); } // decrypt stream MemoryStream outStream = new MemoryStream(); base.Write(InStream, outStream); outStream.Seek(0, SeekOrigin.Begin); // decompress m_cmpEngine.DeCompressArchive(outStream, DirectoryPath); }
private void SavePreviewPictrures(HttpPostedFileBase[] files, int articleId, string alt, bool isHeader = false) { if (files != null && files.Length <= 4) { if (files[0] != null) { int smWidth = 150, smHeight = 150, lgWidth = 280, lgHeight = 280; DirectoryTools.CheckDirectoryExist(AppConstants.dirNewsPreview); var pics = newsSrv.GetPictures.Where(x => x.ArticleId == articleId); DeletePreviewPictures(pics, articleId); foreach (HttpPostedFileBase pic in files) { lgHeight = 280; lgWidth = 280; if (isHeader) { lgWidth = 1920; lgHeight = 720; smWidth = 450; smHeight = 290; } isHeader = false; string smSize = ImageResize.Resize(pic, AppConstants.dirNewsPreview, smWidth, smHeight, true), lgSize = ImageResize.Resize(pic, AppConstants.dirNewsPreview, lgWidth, lgHeight, true); newsSrv.SavePicture(articleId, smSize, lgSize, $"{alt}"); } } } }
public ActionResult Edit(OrganizationViewModel model) { model.IsInRole = User.IsInRole; if (ModelState.IsValid) { if (model.ImgFile != null) { DirectoryTools.CheckDirectoryExist(AppConstants.directoryProfileAvatar); var entity = orgService.GetById(model.Id); if (entity != null) { if (entity.SmallPathImage != null) { DirectoryTools.DeleteFile(HttpContext, entity.SmallPathImage); } if (entity.LargePathImage != null) { DirectoryTools.DeleteFile(HttpContext, entity.LargePathImage); } } model.SmallPathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 50, 50); model.LargePathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 250, 250); } var result = orgService.Edit(OrganizationMapper.ToEntity(model)); if (result != null) { return(RedirectToAction("Index", "Organization")); } } ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name"); return(View(model)); }
public void GetOwnershipTest() { // Arrange var tmpDir = Path.Combine(Path.GetTempPath(), "dirtools-test-" + Guid.NewGuid().ToString()); var localSystem = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null); var dirSec = new DirectorySecurity(); dirSec.SetOwner(localSystem); Directory.CreateDirectory(tmpDir, dirSec); // Act var curIdentity = new NTAccount(Environment.UserDomainName, Environment.UserName); DirectoryTools.GetOwnershipForDirectory(tmpDir, curIdentity); // Assert var curDirsec = new DirectorySecurity(tmpDir, AccessControlSections.Owner); IdentityReference owner = curDirsec.GetOwner(typeof(NTAccount)); Assert.IsTrue(curIdentity == owner); }
/// <summary> /// Test the VolumeCipher class implementation /// </summary> public static void VolumeCipherTest(string InputDirectory) { string[] paths = DirectoryTools.GetFiles(InputDirectory); // key will be written to this stream MemoryStream keyStream = new MemoryStream(); // encrypt the files in the directory using (VolumeCipher vc = new VolumeCipher()) { keyStream = vc.CreateKey(CipherDescription.AES256CTR, paths.Length); vc.Initialize(keyStream); vc.Encrypt(paths); } // decrypt the files using (VolumeCipher vc = new VolumeCipher()) { vc.Initialize(keyStream); vc.Decrypt(paths); } // manual inspection of files.. }
private bool EnsureIntranetLibraryExists(string db_base_path, string db_title, string db_description) { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); try { string base_path = db_base_path; if (!Directory.Exists(base_path)) { DirectoryTools.CreateDirectory(base_path); } EnsureWarningFilesArePresent(base_path); // If the file exists, check that we don't need to update its details string library_detail_path = IntranetLibraryTools.GetLibraryDetailPath(base_path); if (File.Exists(library_detail_path)) { try { IntranetLibraryDetail library_detail = IntranetLibraryDetail.Read(library_detail_path); if (library_detail.Title != db_title || library_detail.Description != db_description) { library_detail.Title = db_title; library_detail.Description = db_description; IntranetLibraryDetail.Write(library_detail_path, library_detail); } } catch (Exception ex) { Logging.Error(ex, "There was an error while updating an Intranet Library path, so will try to delete and recreate... (path: {0})", base_path); FileTools.Delete(library_detail_path); } } // If the file does not exist, create it from scratch if (!File.Exists(library_detail_path)) { IntranetLibraryDetail library_detail = new IntranetLibraryDetail(); library_detail.Id = IntranetLibraryDetail.GetRandomId(); library_detail.Title = db_title; library_detail.Description = db_description; IntranetLibraryDetail.Write(library_detail_path, library_detail); } // If the sync database does not exist, put one in place. IntranetLibraryDB db = new IntranetLibraryDB(base_path); // Notify the WebLibraryManager WebLibraryManager.Instance.UpdateKnownWebLibraryFromIntranet(base_path, suppress_flush_to_disk: false, extra_info_message_on_skip: String.Format("as specified in file {0}", library_detail_path)); // make sure the PDF/documents database is loaded into memory: WebLibraryManager.Instance.InitAllLoadedLibraries(); return(true); } catch (Exception ex) { Logging.Error(ex, "Problem accessing Intranet Library for the first time."); MessageBoxes.Error("There was a problem while trying to connect to this Intranet Library. Are you sure you have permission to access this folder? Your Network or System Administrator can grant you this permission.\n\nThe detailed error message is:\n" + ex.Message); return(false); } }
private static void Main() { var documents = DirectoryTools.LoadDirectory(InputDirectory); DirectoryTools.SaveAsJson(documents, OutputFile); }
private ConvFileRet_e ConvFile(string file) { if (this.Cancelled) // ★★★ 中止チェック { throw new Exception("要求により、中止しました。(ConvFile)"); } Gnd.BusyDlg.SetMessage(GetLocalFileUI(file) + " を処理しています。パス名=" + file); string ext = Path.GetExtension(file); Gnd.ConvLog.Writeln("ext: " + ext); if (AudioMovieExts.Contains(ext) == false) { Gnd.ConvLog.Writeln("登録されている動画・音楽ファイルの拡張子ではありません。"); return(ConvFileRet_e.OTHER_FILE); } DirectoryTools.DeletePath(WorkDatDir); Directory.CreateDirectory(WorkDatDir); try { string destFile = StringTools.Combine(WorkDatDir, "0001" + ext); Gnd.ConvLog.Writeln("< " + file); Gnd.ConvLog.Writeln("> " + destFile); File.Copy(file, destFile); if (File.Exists(destFile) == false) { throw new Exception("ファイルのコピーに失敗しました。(対象ファイルにアクセス出来ない?)"); } } catch (Exception e) { Gnd.ConvLog.Writeln(e); return(ConvFileRet_e.ERROR); } Run_ffprobe("0001" + ext + " 2> 0002.txt"); MediaInfo mi = new MediaInfo(StringTools.Combine(WorkDatDir, "0002.txt")); foreach (MediaInfo.AudioStream stream in mi.AudioStreams) { Gnd.ConvLog.Writeln("音声ストリーム.mapIndex=" + stream.MapIndex); } foreach (MediaInfo.VideoStream stream in mi.VideoStreams) { Gnd.ConvLog.Writeln("映像ストリーム.mapIndex=" + stream.MapIndex); } if (mi.AudioStreams.Count == 0 && mi.VideoStreams.Count == 0) { Gnd.ConvLog.Writeln("映像・音声ストリームが無いため、多分これは動画・音楽ファイルではありません。"); return(ConvFileRet_e.OTHER_FILE); } if (mi.AudioStreams.Count == 0) { Gnd.ConvLog.Writeln("音声ストリームが無いため、動画・音楽ファイルと見なしません。"); return(ConvFileRet_e.OTHER_FILE); } Gnd.ConvLog.Writeln("PROC-AUDIO"); int audioProcessedCount = 0; for (int index = 0; index < mi.AudioStreams.Count; index++) { string lWavFile = index + ".wav"; string wavFile = StringTools.Combine(WorkDatDir, lWavFile); try { Gnd.ConvLog.Writeln("音声ストリームを処理します。index=" + index + ", mapIndex=" + mi.AudioStreams[index].MapIndex); // ステレオにする。 Run_ffmpeg("-i 0001" + ext + " -map 0:" + mi.AudioStreams[index].MapIndex + " -ac 2 " + lWavFile); if (File.Exists(wavFile) == false) { throw new Exception("音声ストリームの抽出に失敗しました。"); // -> ConvFileRet_e.ERROR } File.Delete(StringTools.Combine(WorkDatDir, "0003.wav")); File.Delete(StringTools.Combine(WorkDatDir, "0004.report")); File.Delete(StringTools.Combine(WorkDatDir, "0004.report-main")); Gnd.ConvLog.Writeln("音量を均一化します。"); try { Run_WavMaster("/E " + Consts.EV_MASTER_CANCEL + " " + lWavFile + " 0003.wav 0004.report-main > 0004.report"); if (File.Exists(StringTools.Combine(WorkDatDir, "0004.report-main")) == false) // -> ConvFileRet_e.ERROR { File.Delete(wavFile); throw new Exception("0004.report-main does not exist."); } if (File.Exists(StringTools.Combine(WorkDatDir, "0004.report")) == false) // -> ConvFileRet_e.ERROR { File.Delete(wavFile); throw new Exception("0004.report does not exist."); } } finally { try { Gnd.ConvLog.Writeln("WAV-MASTER REPORT BEGIN"); using (StreamReader rfs = new StreamReader(StringTools.Combine(WorkDatDir, "0004.report"), StringTools.ENCODING_SJIS)) { for (; ;) { string line = rfs.ReadLine(); if (line == null) { break; } Gnd.ConvLog.Writeln(line); } } Gnd.ConvLog.Writeln("WAV-MASTER REPORT END"); } catch { Gnd.ConvLog.Writeln("WAV-MASTER REPORT ERROR"); } } if (File.Exists(StringTools.Combine(WorkDatDir, "0003.wav")) == false) { throw new Exception("音量の均一化はキャンセルされました。(多分、処理不要)"); // -> 継続 } Gnd.ConvLog.Writeln("音量を均一化しました。"); File.Delete(wavFile); File.Move( StringTools.Combine(WorkDatDir, "0003.wav"), wavFile ); Gnd.ConvLog.Writeln("音声ストリームの処理に成功しました。"); audioProcessedCount++; } catch (Exception e) { Gnd.ConvLog.Writeln(e); } if (this.Cancelled) { throw new Exception("要求により、中止しました。(PROC-AUDIO)"); } if (File.Exists(wavFile) == false) { Gnd.ConvLog.Writeln("Conv_Error: 音声ストリームの処理に問題が発生しました。"); return(ConvFileRet_e.ERROR); } } Gnd.ConvLog.Writeln("audioProcessedCount: " + audioProcessedCount); if (audioProcessedCount == 0) { Gnd.ConvLog.Writeln("音量均一化を実行した音声ストリームはありません。"); return(ConvFileRet_e.NOT_PROCESSED); } Gnd.ConvLog.Writeln("PROC-AUDIO OK"); Gnd.ConvLog.Writeln("MAKE-DEST"); if (StringTools.IsSame(ext, ".wav", true) && mi.AudioStreams.Count == 1) { string rFile = Path.Combine(WorkDatDir, "0.wav"); string wFile = Path.Combine(WorkDatDir, "0005.wav"); Gnd.ConvLog.Writeln("SIMPLE_COPY"); Gnd.ConvLog.Writeln("< " + rFile); Gnd.ConvLog.Writeln("> " + wFile); File.Copy(rFile, wFile); Gnd.ConvLog.Writeln("SIMPLE_COPY_DONE"); } else { List <string> args = new List <string>(); bool hasVideoStream = 1 <= mi.VideoStreams.Count; if (hasVideoStream) { args.Add("-i"); args.Add("0001" + ext); } for (int index = 0; index < mi.AudioStreams.Count; index++) // 音楽 { args.Add("-i"); args.Add(index + ".wav"); } int fileIndex = 0; if (hasVideoStream) { for (int index = 0; index < mi.VideoStreams.Count; index++) // 動画 { args.Add("-map"); args.Add(fileIndex + ":" + mi.VideoStreams[index].MapIndex); } fileIndex++; } for (int index = 0; index < mi.AudioStreams.Count; index++) // 音楽 { args.Add("-map"); args.Add(fileIndex + ":0"); fileIndex++; } if (hasVideoStream) { args.Add("-vcodec"); args.Add("copy"); } args.Add(ExtOptions.GetOption(ext)); args.Add("0005" + ext); Run_ffmpeg(string.Join(" ", args)); } if (File.Exists(StringTools.Combine(WorkDatDir, "0005" + ext)) == false) { Gnd.ConvLog.Writeln("Conv_Error: 動画・音楽ファイルの再生成に失敗しました。"); return(ConvFileRet_e.ERROR); } Gnd.ConvLog.Writeln("MAKE-DEST OK"); try { string rFile = StringTools.Combine(WorkDatDir, "0005" + ext); string destFile = FileTools.GetCounteredPath(file, RDir, WDir); Gnd.ConvLog.Writeln("COPY-DEST"); Gnd.ConvLog.Writeln("< " + rFile); Gnd.ConvLog.Writeln("> " + destFile); // 出力ファイルのクリア { DirectoryTools.DeletePath(destFile); Directory.CreateDirectory(destFile); Directory.Delete(destFile); } if (File.Exists(destFile)) { throw new Exception("ファイルのコピーに失敗しました。(出力ファイルをクリア出来ません)"); } #if true File.Copy(rFile, destFile); File.Delete(rFile); #else // 権限とか圧縮状態とか引き継いでしまうので、没.. File.Move(rFile, destFile); #endif if (File.Exists(destFile) == false) { throw new Exception("ファイルのコピーに失敗しました。(出力ファイルを生成出来ません)"); } if (File.Exists(rFile)) { throw new Exception("ファイルのコピーに失敗しました。(rFile exists)"); } } catch (Exception e) { Gnd.ConvLog.Writeln(e); return(ConvFileRet_e.ERROR); } Gnd.ConvLog.Writeln("COPY-DEST OK"); return(ConvFileRet_e.SUCCESSFUL); }
/// <summary> /// ワーカースレッドから呼ばれる。 /// </summary> public void Main() { Gnd.ConvLog.Writeln("本処理を開始しました。"); // 保留してたコピーを実行 { Gnd.ConvLog.Writeln("Files_PrepCopy.1"); for (int index = 0; index < Files_PrepCopy.Count; index += 2) { string rFile = Files_PrepCopy[index + 0]; string wFile = Files_PrepCopy[index + 1]; Gnd.ConvLog.Writeln("< " + rFile); Gnd.ConvLog.Writeln("> " + wFile); File.Copy(rFile, wFile); } Gnd.ConvLog.Writeln("Files_PrepCopy.2"); } ffmpegのテスト(); SameDir = Gnd.SameDir; if (SameDir) { ErrorFileCopy = false; NotProcessedFileCopy = false; OtherFileCopy = false; } else { ErrorFileCopy = Gnd.ErrorFileCopy; NotProcessedFileCopy = Gnd.NotProcessedCopy; OtherFileCopy = Gnd.OtherFileCopy; } Gnd.ConvLog.Writeln("SameDir: " + SameDir); Gnd.ConvLog.Writeln("ErrorFileCopy: " + ErrorFileCopy); Gnd.ConvLog.Writeln("NotProcessedFileCopy: " + NotProcessedFileCopy); Gnd.ConvLog.Writeln("OtherFileCopy: " + OtherFileCopy); Gnd.ConvLog.Writeln("audio_movie_extensions: " + string.Join(" ", AudioMovieExts.GetExts())); List <string> files = DirectoryTools.GetAllFile(RDir); TotalFileCount = files.Count; for (int index = 0; index < files.Count; index++) { GC.Collect(); //Gnd.BusyDlg.RequestGC = true; Gnd.BusyDlg.SetProgress((index + 1) * 1.0 / (files.Count + 1)); { string trailer = ""; Color statusColor = Color.Black; if (this.LastFailedFile != null) { trailer = "\n最後に失敗したファイル:" + this.LastFailedFile; } if (1 <= this.ErrorFileCount || 1 <= this.FailedCopyFileCount) { statusColor = Color.Red; } Gnd.BusyDlg.SetStatus( "総数:" + this.TotalFileCount + "\n成功:" + this.ProcessedFileCount + " , 失敗:" + this.ErrorFileCount + " , 処理不要:" + this.NotProcessedFileCount + " , その他:" + this.OtherFileCount + "\nコピー失敗:" + this.FailedCopyFileCount + trailer, statusColor ); } string file = files[index]; Gnd.ConvLog.Writeln("----"); Gnd.ConvLog.Writeln("[" + index + " / " + files.Count + "]"); Gnd.ConvLog.Writeln("対象ファイル: " + file); switch (ConvFile(file)) { case ConvFileRet_e.SUCCESSFUL: Gnd.ConvLog.Writeln("対象ファイルの処理に成功しました。"); ProcessedFileCount++; break; case ConvFileRet_e.ERROR: Gnd.ConvLog.Writeln("対象ファイルの処理に失敗しました。"); ErrorFileCount++; LastFailedFile = GetLocalFileUI(file); if (ErrorFileCopy) { CopyFileRDirToWDir(file, "ERROR"); } break; case ConvFileRet_e.NOT_PROCESSED: Gnd.ConvLog.Writeln("対象ファイルは既に音量均一化されています。(処理不要)"); NotProcessedFileCount++; if (NotProcessedFileCopy) { CopyFileRDirToWDir(file, "NO-PROC"); } break; case ConvFileRet_e.OTHER_FILE: Gnd.ConvLog.Writeln("対象ファイルは動画・音楽ファイルではありません。"); OtherFileCount++; if (OtherFileCopy) { CopyFileRDirToWDir(file, "OTHER"); } break; default: throw null; } } Gnd.ConvLog.Writeln("----"); Gnd.ConvLog.Writeln("本処理を終了しました。"); Gnd.ConvLog.Writeln("===="); Gnd.ConvLog.Writeln("ファイルの総数: " + TotalFileCount); Gnd.ConvLog.Writeln("処理に成功したファイル数: " + ProcessedFileCount); Gnd.ConvLog.Writeln("エラーになったファイル数: " + ErrorFileCount); Gnd.ConvLog.Writeln("既に音量均一化されていて処理しなかったファイル数: " + NotProcessedFileCount); Gnd.ConvLog.Writeln("その他のファイル数: " + OtherFileCount); Gnd.ConvLog.Writeln("コピーに失敗したファイル数: " + FailedCopyFileCount); }
public static DirectoryInfo GetParentOfGitDirectory(string beginningDirectory) => DirectoryTools.GetDirectoryOfDirectoryAbove(".git", beginningDirectory, includeBeginningDirectory: true);
private void DeleteIndex() { Logging.Info("Deleting the index at path '{0}'", LIBRARY_INDEX_BASE_PATH); DirectoryTools.DeleteDirectory(LIBRARY_INDEX_BASE_PATH, true); }
/// <summary> /// Copy the project to the target user and set it as shared by the source user /// </summary> /// <param name="project"></param> /// <param name="sourceUserName"></param> /// <param name="targetUserName"></param> /// <returns></returns> private bool copyProject(Project project, string sourceUserName, string targetUserName) { string sourceProjectName = project.ProjectName; string submissionId = project.SubmissionId; // Create share revision var revision = new ProjectRevision { RevisionId = project.RevisionHistory.Last().RevisionId + 1, Name = sourceProjectName, Date = DateTime.Now, Owner = sourceUserName, Action = ActionTypes.Share }; project.RevisionHistory.Add(revision); // Fix name collisions var targetProjectName = sourceProjectName; string xmlFilename = String.Format("{0}_{1}", submissionId, sourceProjectName ?? ""); if (XmlUserData.Exists(xmlFilename, "PkView", targetUserName)) { // Add a project rename entry by the destination user var renameRevision = new ProjectRevision { RevisionId = project.RevisionHistory.Last().RevisionId + 1, Date = DateTime.Now, Owner = targetUserName, Action = ActionTypes.Rename }; project.RevisionHistory.Add(renameRevision); // Add an incremental numeric suffix while a collision is found int i = 1; do { renameRevision.Name = string.Format("{0} ({1})", sourceProjectName, i++); xmlFilename = String.Format("{0}_{1}", submissionId, renameRevision.Name ?? ""); } while (XmlUserData.Exists(xmlFilename, "PkView", targetUserName)); targetProjectName = renameRevision.Name; project.ProjectName = targetProjectName; // also change the project name of individual studies project.Studies.ForEach(s => { s.ProfileName = targetProjectName; }); } // Save the project for the target user this.CreateOrUpdate(project, targetUserName); // Output paths var sourcePath = string.Format(@"\\{0}\Output Files\PkView\{1}\{2}\{3}", iPortalApp.AppServerName, sourceUserName, sourceProjectName, submissionId); var targetPath = string.Format(@"\\{0}\Output Files\PkView\{1}\{2}\{3}", iPortalApp.AppServerName, targetUserName, targetProjectName, submissionId); // Copy each study foreach (var study in project.Studies) { var sourceStudyPath = Path.Combine(sourcePath, study.SupplementNumber, study.StudyCode); var targetStudyPath = Path.Combine(targetPath, study.SupplementNumber, study.StudyCode); if (Directory.Exists(sourceStudyPath)) { DirectoryTools.DirectoryCopy(sourceStudyPath, targetStudyPath, true, true); } } return(true); }
/// <summary> /// Share a project with the target user /// </summary> /// <param name="submissionId">Parent submission for the project</param> /// <param name="projectName">Project name</param> /// <param name="sourceUserName">user the project belongs to</param> /// <returns></returns> public bool Share(string submissionId, string projectName, string targetUserName, List <string> selectedStudies = null) { // source username var sourceUserName = Users.GetCurrentUserName(); // Find the source project var sourceProject = this.Find(submissionId, projectName, sourceUserName); if (sourceProject == null) { return(false); } // Leave only selected studies in the source project if (selectedStudies != null && selectedStudies.Count != sourceProject.Studies.Count) { var sourceStudies = from study in sourceProject.Studies join studyId in selectedStudies on study.StudyCode equals studyId select study; sourceProject.Studies = sourceStudies.ToList(); } // Locate matching projects by submission var targetProjectNames = this.List(submissionId, targetUserName); var targetProjects = targetProjectNames .Select(name => this.Find(submissionId, name, targetUserName)).ToList(); // Filter the list leaving only entries with matching creation date and shared by the source user var sourceCreation = sourceProject.RevisionHistory.Single(h => h.RevisionId == 1); var targetProjectsWithDate = Enumerable.Empty <object>() .Select(o => new { p = new Project(), d = new DateTime() }).ToList(); foreach (var tp in targetProjects) { // Ensure revision history is sorted tp.RevisionHistory.OrderBy(h => h.RevisionId); // If creation entry does not match, remove it from the list if (tp.RevisionHistory.First().Equals(sourceCreation)) { // Find the last share or import entry in the history var lastShareOrImport = tp.RevisionHistory .Last(h => h.Action == ActionTypes.Share || h.Action == ActionTypes.Import); // If it is a share by the source user, add the project to the list of target projects with the share date if (lastShareOrImport.Action == ActionTypes.Share && lastShareOrImport.Owner == sourceUserName) { targetProjectsWithDate.Add(new { p = tp, d = lastShareOrImport.Date }); } } } targetProjectsWithDate.OrderByDescending(tpd => tpd.d); // If no previously shared projects were found, just copy the project to the target user if (targetProjectsWithDate.Count == 0) { return(copyProject(sourceProject, sourceUserName, targetUserName)); } // Find the most recently shared project with compatible settings Project targetProject = null; List <Tuple <StudySettings, StudySettings> > matchedStudies = null; foreach (var tpd in targetProjectsWithDate) { // Match the studies being shared from the source project to the studies in the target project matchedStudies = (from sourceStudy in sourceProject.Studies join targetStudy in tpd.p.Studies on sourceStudy.StudyCode equals targetStudy.StudyCode into matched from match in matched.DefaultIfEmpty() select new Tuple <StudySettings, StudySettings> (sourceStudy, match)).ToList(); // Check for study compatibility bool compatible = true; foreach (var match in matchedStudies) { // If study has results in the target, check for settings compatibility if (match.Item2 != null && match.Item2.Pharmacokinetics != null) { // If revision id of the two studies is identical no additional check is needed if (match.Item1.RevisionId != match.Item2.RevisionId) { compatible = match.Item1.IsCompatible(match.Item2); if (!compatible) { break; } } } } // if the project is compatible stop looking if (compatible) { targetProject = tpd.p; break; } } // if no compatible project was found, just create a new copy of the project if (targetProject == null) { return(copyProject(sourceProject, sourceUserName, targetUserName)); } // Create shared revision in the target project var shareRevisionId = targetProject.RevisionHistory.Max(h => h.RevisionId) + 1; var revision = new ProjectRevision { RevisionId = shareRevisionId, Name = projectName, Date = DateTime.Now, Owner = sourceUserName, Action = ActionTypes.Share }; targetProject.RevisionHistory.Add(revision); var sourcePath = string.Format(@"\\{0}\Output Files\PkView\{1}\{2}\{3}", iPortalApp.AppServerName, sourceUserName, projectName, submissionId); var targetPath = string.Format(@"\\{0}\Output Files\PkView\{1}\{2}\{3}", iPortalApp.AppServerName, targetUserName, targetProject.ProjectName, submissionId); // Copy each study to the target foreach (var match in matchedStudies) { // if matching study exist but has no results bool removed = false; if (match.Item2 != null && match.Item2.Pharmacokinetics == null) { // If revisionId is identical ignore this entry otherwise delete the entry for re-copy if (match.Item1.RevisionId == match.Item2.RevisionId) { continue; } else { targetProject.Studies.Remove(match.Item2); removed = true; } } // If target study does not exist or was removed if (match.Item2 == null || removed) { match.Item1.ProfileName = targetProject.ProjectName; match.Item1.RevisionId = shareRevisionId; targetProject.Studies.Add(match.Item1); // if results exist, copy output files if (match.Item1.Pharmacokinetics != null) { var supplementNumber = match.Item1.SupplementNumber; var studyCode = match.Item1.StudyCode; var sourceStudyPath = Path.Combine(sourcePath, supplementNumber, studyCode); var targetStudyPath = Path.Combine(targetPath, supplementNumber, studyCode); // Copy output files if (Directory.Exists(sourceStudyPath)) { DirectoryTools.DirectoryCopy(sourceStudyPath, targetStudyPath, true, true); } } } else // If the study does exist and has results, copy the missing reports from the source { // if the study doesnt have reports, there is nothing else to do for this study if (match.Item1.Reports == null || match.Item1.Reports.Count == 0) { continue; } // if the target study does not have reports copy everything over if (match.Item2.Reports == null || match.Item2.Reports.Count == 0) { match.Item2.Reports = match.Item1.Reports; continue; } // Copy each report var potentialMatches = match.Item2.Reports.ToDictionary(r => r.Name); foreach (var sharedReport in match.Item1.Reports) { // while a report is found but the settings are different, look at the next incremental name String reportBaseName = sharedReport.Name; int i = 1; while (potentialMatches.ContainsKey(sharedReport.Name) && !sharedReport.Equals(potentialMatches[sharedReport.Name])) { // assign a report name with an incremental suffix sharedReport.Name = string.Format("{0} ({1})", reportBaseName, i++); } // if no report was found with the current name and identical settings, copy the source report if (!potentialMatches.ContainsKey(sharedReport.Name)) { match.Item2.Reports.Add(sharedReport); var supplementNumber = match.Item1.SupplementNumber; var studyCode = match.Item1.StudyCode; var sourceReportPath = Path.Combine(sourcePath, supplementNumber, studyCode, reportBaseName); var targetReportPath = Path.Combine(targetPath, supplementNumber, studyCode, sharedReport.Name); // Copy report files if (Directory.Exists(sourceReportPath)) { DirectoryTools.DirectoryCopy(sourceReportPath, targetReportPath, true, true); } } } } } // Save the project for the target user this.CreateOrUpdate(targetProject, targetUserName); return(true); }
/// <summary> /// Import a project from the source user /// </summary> /// <param name="submissionId">Parent submission for the project</param> /// <param name="projectName">Project name</param> /// <param name="sourceUserName">user the project belongs to</param> /// <returns></returns> public bool Import(string submissionId, string projectName, string sourceUserName) { // Find the source project var project = this.Find(submissionId, projectName, sourceUserName); if (project == null) { return(false); } // destination username var targetUserName = Users.GetCurrentUserName(); // Create share revision var revision = new ProjectRevision { RevisionId = project.RevisionHistory.Last().RevisionId + 1, Name = projectName, Date = DateTime.Now, Owner = sourceUserName, Action = ActionTypes.Import }; project.RevisionHistory.Add(revision); // Fix name collisions var targetProjectName = projectName; string xmlFilename = String.Format("{0}_{1}", submissionId, projectName ?? ""); if (XmlUserData.Exists(xmlFilename, "PkView", targetUserName)) { // Add a project rename entry by the destination user var renameRevision = new ProjectRevision { RevisionId = project.RevisionHistory.Last().RevisionId + 1, Date = DateTime.Now, Owner = targetUserName, Action = ActionTypes.Rename }; project.RevisionHistory.Add(renameRevision); // Add an incremental numeric suffix while a collision is found int i = 1; do { renameRevision.Name = string.Format("{0} ({1})", projectName, i++); xmlFilename = String.Format("{0}_{1}", submissionId, renameRevision.Name ?? ""); } while (XmlUserData.Exists(xmlFilename, "PkView", targetUserName)); targetProjectName = renameRevision.Name; project.ProjectName = targetProjectName; // also change the project name of individual studies project.Studies.ForEach(s => { s.ProfileName = targetProjectName; }); } // Save the project for the target user this.CreateOrUpdate(project, targetUserName); // Copy output folder var sourcePath = string.Format(@"\\{0}\Output Files\PkView\{1}\{2}\{3}", iPortalApp.AppServerName, sourceUserName, projectName, submissionId); var destPath = string.Format(@"\\{0}\Output Files\PkView\{1}\{2}\{3}", iPortalApp.AppServerName, targetUserName, targetProjectName, submissionId); if (Directory.Exists(sourcePath)) { DirectoryTools.DirectoryCopy(sourcePath, destPath, true, true); } // Copy ouptut package if it exists FileInfo pkgFile = new FileInfo(sourcePath + ".zip"); if (pkgFile.Exists) { pkgFile.CopyTo(destPath + ".zip", true); } return(true); }
public static DirectoryInfo GetParentOfGitVersionYamlDirectory(string beginningDirectory) => DirectoryTools.GetDirectoryOfFileAbove(BuildTaskExecutorDefaults.GitVersionFileNameWithExtension, beginningDirectory, includeBeginningDirectory: true);
private bool EnsureIntranetLibraryExists() { try { string base_path = TxtPath.Text; if (!Directory.Exists(base_path)) { DirectoryTools.CreateDirectory(base_path); } EnsureWarningFilesArePresent(base_path); // If the file exists, check that we don't need to update it's details string library_detail_path = IntranetLibraryTools.GetLibraryDetailPath(base_path); if (File.Exists(library_detail_path)) { try { IntranetLibraryDetail library_detail = IntranetLibraryDetail.Read(library_detail_path); if (library_detail.Title != TxtTitle.Text || library_detail.Description != TxtDescription.Text) { library_detail.Title = TxtTitle.Text; library_detail.Description = TxtDescription.Text; IntranetLibraryDetail.Write(library_detail_path, library_detail); } } catch (Exception ex) { Logging.Error(ex, "There was an error while updating an Intranet Library path, so will try to delete and recreate..."); FileTools.Delete(library_detail_path); } } // If the file does not exists, create it from scratch if (!File.Exists(library_detail_path)) { IntranetLibraryDetail library_detail = new IntranetLibraryDetail(); library_detail.Id = IntranetLibraryDetail.GetRandomId(); library_detail.Title = TxtTitle.Text; library_detail.Description = TxtDescription.Text; IntranetLibraryDetail.Write(library_detail_path, library_detail); } // If the sync database does not exist, put one in place. IntranetLibraryDB db = new IntranetLibraryDB(base_path); // Notify the WebLibrearyManager WebLibraryManager.Instance.UpdateKnownWebLibraryFromIntranet(base_path); return(true); } catch (Exception ex) { Logging.Error(ex, "Problem accessing Intranet Library for the first time."); MessageBoxes.Error("There was a problem while trying to connect to this Intranet Library. Are you sure you have permission to access this folder? Your Network or System Administrator can grant you this permission.\n\nThe detailed error message is:\n" + ex.Message); return(false); } }
public static void EnsureIntranetLibraryExists(string db_base_path, string db_title, string db_description, string id = null) { WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread(); try { string base_path = db_base_path; if (!Directory.Exists(base_path)) { DirectoryTools.CreateDirectory(base_path); } EnsureWarningFilesArePresent(base_path); // If the file exists, check that we don't need to update its details string library_detail_path = IntranetLibraryTools.GetLibraryDetailPath(base_path); if (File.Exists(library_detail_path)) { try { IntranetLibraryDetail library_detail = IntranetLibraryDetail.Read(library_detail_path); if (library_detail.Title != db_title || library_detail.Description != db_description) { library_detail.Title = db_title; library_detail.Description = db_description; IntranetLibraryDetail.Write(library_detail_path, library_detail); } } catch (Exception ex) { Logging.Error(ex, "There was an error while updating an Intranet Library path, so will try to delete and recreate... (path: {0})", base_path); FileTools.Delete(library_detail_path); } } // If the file does not exist, create it from scratch if (!File.Exists(library_detail_path)) { IntranetLibraryDetail library_detail = new IntranetLibraryDetail(); library_detail.Id = String.IsNullOrEmpty(id) ? IntranetLibraryDetail.GetRandomId() : id; library_detail.Title = db_title; library_detail.Description = db_description; IntranetLibraryDetail.Write(library_detail_path, library_detail); } // If the sync database does not exist, put one in place. IntranetLibraryDB db = new IntranetLibraryDB(base_path); // Notify the WebLibraryManager WebLibraryManager.Instance.UpdateKnownWebLibraryFromIntranet(base_path, suppress_flush_to_disk: false, extra_info_message_on_skip: String.Format("as specified in file {0}", library_detail_path)); // make sure the PDF/documents database is loaded into memory: WebLibraryManager.Instance.InitAllLoadedLibraries(); } catch (Exception ex) { Logging.Error(ex, $"Problem accessing Intranet Library for the first time. (Id: {id}, path: '{db_base_path}', DB title: '{db_title}', Description: '{db_description}'"); throw; } }
public void Prep() { Gnd.ConvLog.Close(); Gnd.ConvLog.Writeln("前処理を開始しました。"); // ---- work dir ---- TmpDir = Environment.GetEnvironmentVariable("TMP"); //TmpDir = @"C:\blank wo fukumu"; // test //TmpDir = @"C:\日本語"; // test Gnd.ConvLog.Writeln("TmpDir.1: " + TmpDir); if (TmpDir == null) { throw null; } if (TmpDir == "") { throw null; } if (Directory.Exists(TmpDir) == false) { throw null; } TmpDir = FileTools.ToFullPath(TmpDir); Gnd.ConvLog.Writeln("TmpDir.2: " + TmpDir); // TMP に US-ASCII 以外の文字・空白を含む場合、ProgramDataに変更する。 try { if (TmpDir.Contains(' ')) { throw new Exception("環境変数 TMP は空白を含んでいます。-> ProgramDataを使用します。"); } byte[] bTmpDir = Encoding.ASCII.GetBytes(TmpDir); string sTmpDir = Encoding.ASCII.GetString(bTmpDir); if (TmpDir.Equals(sTmpDir) == false) { throw new Exception("環境変数 TMP は US-ASCII 以外の文字を含んでいます。-> ProgramDataを使用します。"); } } catch (Exception e) { Gnd.ConvLog.Writeln(e); string pgDt = Environment.GetEnvironmentVariable("ProgramData"); Gnd.ConvLog.Writeln("ProgramData: " + pgDt); if (pgDt == null) { throw null; } if (pgDt == "") { throw null; } TmpDir = pgDt; } Gnd.ConvLog.Writeln("TmpDir.3: " + TmpDir); if (Directory.Exists(TmpDir) == false) { throw null; } WorkDir = StringTools.Combine(TmpDir, WORK_LDIR); Gnd.ConvLog.Writeln("WorkDir: " + WorkDir); WorkBinDir = StringTools.Combine(WorkDir, "bin"); Gnd.ConvLog.Writeln("WorkBinDir: " + WorkBinDir); WorkDatDir = StringTools.Combine(WorkDir, "dat"); Gnd.ConvLog.Writeln("WorkDatDir: " + WorkDatDir); DirectoryTools.DeletePath(WorkDir); Directory.CreateDirectory(WorkDir); Directory.CreateDirectory(WorkBinDir); Directory.CreateDirectory(WorkDatDir); #if false // C:\\の直下は無くなったので、隠す必要は無くなった。 // +S +H { // WorkDir は空白を含まないはず! ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "ATTRIB.EXE"; psi.Arguments = "+S +H " + WorkDir; psi.CreateNoWindow = true; psi.UseShellExecute = false; psi.WorkingDirectory = WorkDatDir; using (Process p = Process.Start(psi)) { p.WaitForExit(); } } #endif // ---- ffmpeg dir ---- ffmpegDir = Gnd.ffmpegDir; Gnd.ConvLog.Writeln("ffmpegDir.1: " + ffmpegDir); const string ffmpegFileErrorTrailer = "\n設定 / ffmpeg / ffmpegのパスを確認して下さい。"; if (ffmpegDir == "") { throw new Exception("ffmpegのパスが設定されていません。" + ffmpegFileErrorTrailer); } if (Directory.Exists(ffmpegDir) == false) { throw new Exception("ffmpegのパスが存在しません。" + ffmpegFileErrorTrailer); } ffmpegDir = FileTools.ToFullPath(ffmpegDir); Gnd.ConvLog.Writeln("ffmpegDir.2: " + ffmpegDir); if (Directory.Exists(ffmpegDir) == false) { throw new Exception("ffmpegのパスが存在しません。(FullPath)"); } ffmpegFile = Get_ffmpegFile(ffmpegDir); if (ffmpegFile == null) { throw new Exception("ffmpeg.exe が見つかりません。" + ffmpegFileErrorTrailer); } Gnd.ConvLog.Writeln("ffmpegFile: " + ffmpegFile); ffmpegBinDir = Path.GetDirectoryName(ffmpegFile); Gnd.ConvLog.Writeln("ffmpegBinDir: " + ffmpegBinDir); // ffprobe.exe 存在チェック { string file = StringTools.Combine(ffmpegBinDir, "ffprobe.exe"); if (File.Exists(file) == false) { throw new Exception("ffprobe.exe が見つかりません。" + ffmpegFileErrorTrailer); } } foreach (string file in Directory.GetFiles(ffmpegBinDir)) { string destFile = FileTools.GetCounteredPath(file, ffmpegBinDir, WorkBinDir); Gnd.ConvLog.Writeln("< " + file); Gnd.ConvLog.Writeln("> " + destFile); //File.Copy(file, destFile); Files_PrepCopy.Add(file); Files_PrepCopy.Add(destFile); } // ---- Master.exe ---- { string file = "Master.exe"; if (File.Exists(file) == false) { file = @"C:\Factory\Program\WavMaster\Master.exe"; // dev env } string destFile = StringTools.Combine(WorkDir, "Master.exe"); Gnd.ConvLog.Writeln("Wav-Master"); Gnd.ConvLog.Writeln("< " + file); Gnd.ConvLog.Writeln("> " + destFile); //File.Copy(file, destFile); Files_PrepCopy.Add(file); Files_PrepCopy.Add(destFile); } // ---- muon.wav ---- { string file = "muon_wav.dat"; if (File.Exists(file) == false) { file = @"..\..\..\..\doc\muon_wav.dat"; // dev env } string destFile = StringTools.Combine(WorkDir, "muon.wav"); Gnd.ConvLog.Writeln("Muon-Wav"); Gnd.ConvLog.Writeln("< " + file); Gnd.ConvLog.Writeln("> " + destFile); //File.Copy(file, destFile); Files_PrepCopy.Add(file); Files_PrepCopy.Add(destFile); } // ---- R/WDir ---- RDir = Gnd.InputDir; if (Gnd.SameDir) { WDir = RDir; } else { WDir = Gnd.OutputDir; } Gnd.ConvLog.Writeln("RDir.1: " + RDir); Gnd.ConvLog.Writeln("WDir.1: " + WDir); if (RDir == "") { throw new Exception("入力フォルダが設定されていません。"); } if (WDir == "") { throw new Exception("出力フォルダが設定されていません。"); } if (Directory.Exists(RDir) == false) { throw new Exception("入力フォルダが存在しません。"); } if (Directory.Exists(WDir) == false) { throw new Exception("出力フォルダが存在しません。\n出力フォルダは作成されていなければなりません。"); } RDir = FileTools.ToFullPath(RDir); WDir = FileTools.ToFullPath(WDir); Gnd.ConvLog.Writeln("RDir.2: " + RDir); Gnd.ConvLog.Writeln("WDir.2: " + WDir); if (Directory.Exists(RDir) == false) { throw new Exception("入力フォルダが存在しません。(FullPath)"); } if (Directory.Exists(WDir) == false) { throw new Exception("出力フォルダが存在しません。(FullPath)"); } // ---- // 入力・出力フォルダにシステムドライブのルートディレクトリが指定された場合、確認する。 { string sysDrv = Environment.GetEnvironmentVariable("SystemDrive"); Gnd.ConvLog.Writeln("sysDrv: " + sysDrv); string sysRootDir = sysDrv + @"\"; Gnd.ConvLog.Writeln("sysRootDir: " + sysRootDir); if (StringTools.IsSame(sysRootDir, RDir, true)) { if (MessageBox.Show( "入力フォルダにシステムドライブのルートフォルダ (" + sysRootDir + ") が指定されています。\n続行しても宜しいですか?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) { throw new Exception("キャンセルしました。"); } } if (StringTools.IsSame(sysRootDir, WDir, true)) { if (MessageBox.Show( "出力フォルダにシステムドライブのルートフォルダ (" + sysRootDir + ") が指定されています。\n続行しても宜しいですか?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) { throw new Exception("キャンセルしました。"); } } } if (Gnd.SameDir) { if (MessageBox.Show( "オプション「入力フォルダと同じ場所に出力する」が有効になっています。入力フォルダの配下にある動画・音楽ファイルが直接処理(上書き)されます。\n続行しても宜しいですか?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) { throw new Exception("キャンセルしました。"); } } else if (StringTools.IsSame(RDir, WDir, true)) { if (MessageBox.Show( "入力フォルダと出力フォルダに同じフォルダが指定されています。\n続行しても宜しいですか?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) { throw new Exception("キャンセルしました。"); } } else if (FileTools.Is親子関係(RDir, WDir) || FileTools.Is親子関係(WDir, RDir)) { if (MessageBox.Show( "入力フォルダと出力フォルダが親子関係にあります。\n続行しても宜しいですか?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information ) != DialogResult.OK ) { throw new Exception("キャンセルしました。"); } } Gnd.ConvLog.Writeln("前処理を終了しました。"); }