public FindPrintInfo FindPrint(string title, PrintType postType = PrintType.Unknow, bool forceSelect = false) { FindPrintInfo findPrint = null; if (Try(() => findPrint = _findPrintManager.Find(title, postType, forceSelect))) { return(findPrint); } else { return new FindPrintInfo { found = false } }; }
//private static RenamePrintFile RenamePrintFile(FindPrintManager findPrintManager, string file, Date date, string destinationDirectory, bool simulate) private static RenamePrintFile GetRenamePrintFileInfo(FindPrintManager findPrintManager, string file, Date date) { RenamePrintFile renamePrintFile = new RenamePrintFile(); //try //{ renamePrintFile.SourceFile = file; renamePrintFile.Title = zPath.GetFileNameWithoutExtension(file); renamePrintFile.ExpectedDate = date; FindPrintInfo findPrint = findPrintManager.Find(renamePrintFile.Title, PrintType.Print, expectedDate: date); if (findPrint.DayTitle != null) { renamePrintFile.FormatedTitle = findPrint.DayTitle; } else { renamePrintFile.FormatedTitle = findPrint.titleInfo.FormatedTitle; } renamePrintFile.Name = findPrint.name; renamePrintFile.Date = findPrint.date; renamePrintFile.DateType = findPrint.dateType; renamePrintFile.Number = findPrint.number; renamePrintFile.Special = findPrint.special; renamePrintFile.SpecialText = findPrint.specialText; renamePrintFile.Label = findPrint.label; renamePrintFile.RemainText = findPrint.remainText; if (findPrint.print != null) { renamePrintFile.PrintName = findPrint.print.Name; } if (!findPrint.found) { renamePrintFile.Error = string.Format("unknow print \"{0}\" date {1} formated title \"{2}\"", zPath.GetFileName(file), findPrint.date, findPrint.titleInfo.FormatedTitle); } else if (findPrint.date == null) { renamePrintFile.Error = string.Format("date not found \"{0}\"", zPath.GetFileName(file)); } if (findPrint.found && findPrint.date != null) { int dateGap = findPrint.date.Value.Subtract(date).Days; if (dateGap < -findPrintManager.GapDayBefore || dateGap > findPrintManager.GapDayAfter) { renamePrintFile.Error = string.Format("wrong date found {0} - \"{1}\"", findPrint.date, renamePrintFile.Title); } else { renamePrintFile.RenameFile = true; renamePrintFile.File = findPrint.file + zPath.GetExtension(file); //string newfile = zPath.Combine(destinationDirectory, findPrint.file) + zPath.GetExtension(file); //newfile = zfile.GetNewFilename(newfile); //if (!simulate) //{ // zfile.CreateFileDirectory(newfile); // zFile.Move(file, newfile); //} } } //} //catch (Exception ex) //{ // Trace.WriteLine(" error print \"{0}\"", zPath.GetFileName(file)); // Trace.WriteLine(Error.GetErrorMessage(ex, true, false)); // Trace.WriteLine(); //} return(renamePrintFile); }