예제 #1
0
        // used to download one post
        public bool TryDownloadPost(IPostToDownload_v1 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);
            }

            // corrigé le 20/11/2014
            //DownloadPostKey key = new DownloadPostKey { server = post.server, id = post.id };
            DownloadPostKey_v1 key = new DownloadPostKey_v1 {
                server = post.GetServer(), id = post.GetKey()
            };
            // state : NotDownloaded, WaitToDownload, DownloadStarted, DownloadCompleted, DownloadFailed
            DownloadState state = GetDownloadFileState(key);

            //if (state != DownloadState.NotDownloaded && !forceDownloadAgain)
            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);
            }

            if (_downloadManager_v1 != null)
            {
                Try(() => _downloadManager_v1.DownloadFile(key, post.GetDownloadLinks(), file));
            }
            if (_downloadManager != null)
            {
                Try(() => _downloadManager.AddFileToDownload(key, post.GetDownloadLinks_new(), file));
            }

            return(true);
        }
예제 #2
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
                }
            };
        }
예제 #3
0
        //public static TestFindPrint FindPrint(DownloadAutomateManager_v1 downloadAutomate, TestPrint print)
        public static TestFindPrint FindPrint(DownloadAutomateManager downloadAutomate, TestPrint print)
        {
            //FindPrint findPrint = null;
            //if (downloadAutomate.FindPrintManager != null)
            //    findPrint = downloadAutomate.FindPrint(print.title, print.category);
            //else if (downloadAutomate.FindPrintManager_new != null)
            //    findPrint = downloadAutomate.FindPrint_new(print.title, print.postType);
            FindPrintInfo findPrint     = downloadAutomate.FindPrint(print.title, print.postType);
            TestFindPrint testFindPrint = new TestFindPrint();

            testFindPrint.post_title    = print.title;
            testFindPrint.post_category = print.category;
            testFindPrint.post_isPrint  = print.postType == PrintType.Print;
            //testFindPrint.post_postType = print.postType;

            testFindPrint.findPrint_file          = findPrint.file;
            testFindPrint.findPrint_type          = findPrint.findPrintType;
            testFindPrint.findPrint_name          = findPrint.name;
            testFindPrint.findPrint_title         = findPrint.title;
            testFindPrint.print_name              = findPrint.print != null ? findPrint.print.Name : null;
            testFindPrint.print_title             = findPrint.print != null ? findPrint.print.Title : null;
            testFindPrint.titleInfo_formatedTitle = findPrint.titleInfo != null ? findPrint.titleInfo.FormatedTitle : null;

            testFindPrint.findPrint_date     = findPrint.date;
            testFindPrint.findPrint_dateType = findPrint.dateType;
            if (findPrint.titleInfo != null)
            {
                testFindPrint.findPrint_dateCapture = RegexCaptureValues.CreateRegexCaptureValues(findPrint.titleInfo.DateMatch, allValues: true);
                //testFindPrint.findPrint_dateOtherCaptureList = RegexCaptureValues.CreateRegexCaptureValuesList(findPrint.titleInfo.DateOtherMatchList, allValues: true);
            }
            testFindPrint.findPrint_number = findPrint.number;
            if (findPrint.titleInfo != null)
            {
                testFindPrint.findPrint_numberCapture = RegexCaptureValues.CreateRegexCaptureValues(findPrint.titleInfo.NumberMatch, allValues: true);
            }
            testFindPrint.findPrint_special = findPrint.special;
            if (findPrint.titleInfo != null)
            {
                testFindPrint.findPrint_specialCapture = RegexCaptureValues.CreateRegexCaptureValues(findPrint.titleInfo.SpecialMatch, allValues: true);
            }
            testFindPrint.findPrint_specialText = findPrint.specialText;

            testFindPrint.findPrint_remainText = findPrint.remainText;
            testFindPrint.warnings             = __traceMessages.ToArray();
            __traceMessages.Clear();

            return(testFindPrint);
        }