Пример #1
0
        private FindPrintInfo GetFindPrintInfo()
        {
            FindPrintInfo findPrintInfo = new FindPrintInfo();

            findPrintInfo.found       = _found;
            findPrintInfo.sourceTitle = _sourceTitle;
            findPrintInfo.printType   = _printType;

            findPrintInfo.name          = _name;
            findPrintInfo.title         = _title;
            findPrintInfo.DayTitle      = _dayTitle;
            findPrintInfo.directory     = _directory;
            findPrintInfo.date          = _date;
            findPrintInfo.dateType      = _dateType;
            findPrintInfo.number        = _number;
            findPrintInfo.special       = _special;
            findPrintInfo.specialText   = _specialText;
            findPrintInfo.label         = _label;
            findPrintInfo.file          = _file;
            findPrintInfo.remainText    = _remainText;
            findPrintInfo.print         = _print;
            findPrintInfo.findPrintType = _findPrintType;
            findPrintInfo.titleInfo     = _titleInfo;

            return(findPrintInfo);
        }
Пример #2
0
        public bool TryDownloadPost(IPostToDownload post, string downloadDirectory = null, bool forceDownloadAgain = false, bool forceSelect = false, bool simulateDownload = false)
        {
            if (_downloadAllPrintType != null)
            {
                forceSelect = forceSelect || _downloadAllPrintType(post.GetPrintType());
            }
            FindPrintInfo findPrint = FindPrint(post.GetTitle(), post.GetPrintType(), forceSelect);

            if (!findPrint.found)
            {
                TracePost(post, "post not selected");
                return(false);
            }

            ServerKey key = new ServerKey {
                Server = post.GetServer(), Id = post.GetKey()
            };
            // state : NotDownloaded, WaitToDownload, DownloadStarted, DownloadCompleted, DownloadFailed
            DownloadState state = GetDownloadFileState(key);

            if ((state == DownloadState.WaitToDownload || state == DownloadState.DownloadStarted || state == DownloadState.DownloadCompleted) && !forceDownloadAgain)
            {
                if (FilterTracePost(state))
                {
                    TracePost(post, "post " + GetDownloadStateText1(state), findPrint.file);
                }
                return(false);
            }

            string file = findPrint.file;

            if (downloadDirectory != null)
            {
                file = downloadDirectory + "\\" + file;
            }

            if (simulateDownload)
            {
                TracePost(post, "simulate start download", file);
                return(false);
            }
            else
            {
                TracePost(post, "start download", file);
            }

            // file : "print\.02_hebdo\Challenges\Challenges - 2016-03-31 - no 481"
            if (_downloadManager != null)
            {
                Try(() => _downloadManager.AddFileToDownload(key, post.GetDownloadLinks(), file));
            }

            return(true);
        }
Пример #3
0
        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
                }
            };
        }
Пример #4
0
        private FindPrintInfo GetFindPrintInfo()
        {
            FindPrintInfo findPrintInfo = new FindPrintInfo();
            findPrintInfo.found = _found;
            findPrintInfo.sourceTitle = _sourceTitle;
            findPrintInfo.printType = _printType;

            findPrintInfo.name = _name;
            findPrintInfo.title = _title;
            findPrintInfo.DayTitle = _dayTitle;
            findPrintInfo.directory = _directory;
            findPrintInfo.date = _date;
            findPrintInfo.dateType = _dateType;
            findPrintInfo.number = _number;
            findPrintInfo.special = _special;
            findPrintInfo.specialText = _specialText;
            findPrintInfo.label = _label;
            findPrintInfo.file = _file;
            findPrintInfo.remainText = _remainText;
            findPrintInfo.print = _print;
            findPrintInfo.findPrintType = _findPrintType;
            findPrintInfo.titleInfo = _titleInfo;

            return findPrintInfo;
        }
Пример #5
0
        //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);
        }