Пример #1
0
        public void TestMethod()
        {
            var title = "The.Forbidden.Girl.2013.1080p.BluRay.x264.DTS-FGT.mkv";
            var controller = new MainViewController(title, new DummyView(), new AggregateDb());
            var result = controller.Query();

        }
Пример #2
0
        /// <summary>Processes the request.</summary>
        /// <param name="targets">The targets.</param>
        /// <param name="view">The view.</param>
        /// <param name="success">The success.</param>
        /// <param name="fail">The fail.</param>
        private void ProcessRequest(IReadOnlyList<string> targets, IView view, ref int success, ref int fail)
        {
            var retry = false;
            for (this.activeIndex = 0; this.activeIndex < targets.Count; this.activeIndex++)
            {
                var currentIndex = this.activeIndex;
                try
                {
                    var currentFile = targets[this.activeIndex];
                    var fileSizeLimit = 10 * 1024 * 1024;
                    var fileInfo = new FileInfo(currentFile);
                    if (!fileInfo.Exists || fileInfo.Length < fileSizeLimit)
                    {
                        continue;
                    }

                    if (retry)
                    {
                        retry = false;
                    }
                    else
                    {
                        this.activeController = new MainViewController(currentFile, view, new AggregateDb());
                    }

                    view.ShowProgress(this.activeIndex, targets.Count);
                    var entryResult = this.activeController.Query();

                    retry = this.activeIndex != currentIndex;
                    if (entryResult == Status.Success || entryResult == Status.Skipped)
                    {
                        success++;
                    }
                    else if (entryResult == Status.Failure)
                    {
                        fail++;
                    }
                    else if (entryResult == Status.Cancelled)
                    {
                        break; // Users cancel
                    }
                }
                catch (Exception ex)
                {
                    fail++;
                    Trace.TraceError(ex.ToString());
                }
            }
        }