Ejemplo n.º 1
0
        public ActionQueue[] ActionProcessorMakeQueues(ScanListItemList theList)
        {
            // Take a single list
            // Return an array of "ActionQueue" items.
            // Each individual queue is processed sequentially, but all the queues run in parallel
            // The lists:
            //     - #0 all the cross filesystem moves, and all copies
            //     - #1 all quick "local" moves
            //     - #2 NFO Generator list
            //     - #3 Downloads (rss torrent, thumbnail, folder.jpg) across Settings.ParallelDownloads lists
            // We can discard any non-action items, as there is nothing to do for them

            ActionQueue[] queues = new ActionQueue[4];
            queues[0] = new ActionQueue("Move/Copy", 1); // cross-filesystem moves (slow ones)
            queues[1] = new ActionQueue("Move", 2); // local rename/moves
            queues[2] = new ActionQueue("Write NFO/pyTivo Meta", 4); // writing XBMC NFO files
            queues[3] = new ActionQueue("Download", this.Settings.ParallelDownloads); // downloading torrents, banners, thumbnails

            foreach (ScanListItem sli in theList)
            {
                Action action = sli as Action;

                if (action == null)
                    continue; // skip non-actions

                if (action is ActionNFO || action is ActionPyTivoMeta)
                    queues[2].Actions.Add(action);
                else if ((action is ActionDownload) || (action is ActionRSS))
                    queues[3].Actions.Add(action);
                else if (action is ActionCopyMoveRename)
                    queues[(action as ActionCopyMoveRename).QuickOperation() ? 1 : 0].Actions.Add(action);
            }
            return queues;
        }
Ejemplo n.º 2
0
        public ActionQueue[] ActionProcessorMakeQueues(ScanListItemList theList)
        {
            // Take a single list
            // Return an array of "ActionQueue" items.
            // Each individual queue is processed sequentially, but all the queues run in parallel
            // The lists:
            //     - #0 all the cross filesystem moves, and all copies
            //     - #1 all quick "local" moves
            //     - #2 NFO Generator list
            //     - #3 Downloads (rss torrent, thumbnail, folder.jpg) across Settings.ParallelDownloads lists
            // We can discard any non-action items, as there is nothing to do for them

            ActionQueue[] queues = new ActionQueue[4];
            queues[0] = new ActionQueue("Move/Copy", 1); // cross-filesystem moves (slow ones)
            queues[1] = new ActionQueue("Move", 2); // local rename/moves
            queues[2] = new ActionQueue("Write Metadata", 4); // writing XBMC NFO files, etc.
            queues[3] = new ActionQueue("Download", TVSettings.Instance.ParallelDownloads); // downloading torrents, banners, thumbnails

            foreach (ScanListItem sli in theList)
            {
                Action action = sli as Action;

                if (action == null)
                    continue; // skip non-actions

                if (action is ActionWriteMetadata) // base interface that all metadata actions are derived from
                    queues[2].Actions.Add(action);
                else if ((action is ActionDownload) || (action is ActionRSS))
                    queues[3].Actions.Add(action);
                else if (action is ActionCopyMoveRename)
                    queues[(action as ActionCopyMoveRename).QuickOperation() ? 1 : 0].Actions.Add(action);
                else
                {
#if DEBUG
                    System.Diagnostics.Debug.Fail("Unknown action type for making processing queue");
#endif
                    queues[3].Actions.Add(action); // put it in this queue by default
                }
            }
            return queues;
        }
Ejemplo n.º 3
0
        public void DoActions(ScanListItemList theList)
        {
            if (theList == null)
                return;

            // Run tasks in parallel (as much as is sensible)

            ActionQueue[] queues = this.ActionProcessorMakeQueues(theList);
            this.ActionPause = false;

            // If not /hide, show CopyMoveProgress dialog

            CopyMoveProgress cmp = null;
            if (!this.Args.Hide)
                cmp = new CopyMoveProgress(this, queues);

            this.ActionProcessorThread = new Thread(this.ActionProcessor) {
                                                                              Name = "ActionProcessorThread"
                                                                          };

            this.ActionProcessorThread.Start(queues);

            if ((cmp != null) && (cmp.ShowDialog() == DialogResult.Cancel))
                this.ActionProcessorThread.Abort();

            this.ActionProcessorThread.Join();

            theList.RemoveAll(x => (x is Action) && (x as Action).Done && !(x as Action).Error);
        }
Ejemplo n.º 4
0
        public void Go(ListView lv, WhichResults which)
        {
            //this.uTorrenting = new System.Collections.Generic.List<ItemuTorrenting>();
            this.Missing = new System.Collections.Generic.List<ItemMissing>();
            this.RSS = new System.Collections.Generic.List<ActionRSS>();
            this.CopyMove = new System.Collections.Generic.List<ActionCopyMoveRename>();
            this.Rename = new System.Collections.Generic.List<ActionCopyMoveRename>();
            this.Download = new System.Collections.Generic.List<ActionDownload>();
            this.NFO = new System.Collections.Generic.List<ActionNFO>();
            this.PyTivoMeta = new System.Collections.Generic.List<ActionPyTivoMeta>();
            this.FlatList = new ScanListItemList();

            System.Collections.Generic.List<ListViewItem> sel = new System.Collections.Generic.List<ListViewItem>();
            if (which == WhichResults.Checked)
            {
                ListView.CheckedListViewItemCollection ss = lv.CheckedItems;
                foreach (ListViewItem lvi in ss)
                    sel.Add(lvi);
            }
            else if (which == WhichResults.Selected)
            {
                ListView.SelectedListViewItemCollection ss = lv.SelectedItems;
                foreach (ListViewItem lvi in ss)
                    sel.Add(lvi);
            }
            else // all
            {
                foreach (ListViewItem lvi in lv.Items)
                    sel.Add(lvi);
            }

            this.Count = sel.Count;

            if (sel.Count == 0)
                return;

            System.Type firstType = ((Item) (sel[0].Tag)).GetType();

            this.AllSameType = true;
            foreach (ListViewItem lvi in sel)
            {
                if (lvi == null)
                    continue;

                Item action = (Item) (lvi.Tag);
                if (action is ScanListItem)
                    this.FlatList.Add(action as ScanListItem);

                if (action.GetType() != firstType)
                    this.AllSameType = false;

                if (action is ActionCopyMoveRename)
                {
                    ActionCopyMoveRename cmr = action as ActionCopyMoveRename;
                    if (cmr.Operation == ActionCopyMoveRename.Op.Rename)
                        this.Rename.Add(cmr);
                    else // copy/move
                        this.CopyMove.Add(cmr);
                }
                else if (action is ActionDownload)
                    this.Download.Add((ActionDownload) (action));
                else if (action is ActionRSS)
                    this.RSS.Add((ActionRSS) (action));
                else if (action is ItemMissing)
                    this.Missing.Add((ItemMissing) (action));
                else if (action is ActionNFO)
                    this.NFO.Add((ActionNFO) (action));
                else if (action is ActionPyTivoMeta)
                    this.PyTivoMeta.Add((ActionPyTivoMeta) (action));
                //else if (action is ItemuTorrenting)
                //    this.uTorrenting.Add((ItemuTorrenting) (action));
            }
        }