Exemplo n.º 1
0
        /// <summary>
        /// Processes a set of actions, running them in a multi-threaded way based on the application's settings.
        /// </summary>
        /// <param name="theList">An ItemList to be processed.</param>
        /// <param name="showUi">Whether or not we should display a UI to inform the user about progress.</param>
        public void DoActions(ItemList?theList, bool showUi, IDialogParent owner)
        {
            if (theList is null)
            {
                Logger.Info("Asked to do actions, but none provided....");
                return;
            }

            Logger.Info("**********************");
            Logger.Info($"Doing Selected Actions.... ({theList.Count} items detected, {theList.Actions.Count} actions to be completed )");

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

            ActionQueue[] queues = ActionProcessorMakeQueues(theList);
            actionPause = false;

            // If not /hide, show CopyMoveProgress dialog

            CopyMoveProgress cmp = null;

            if (showUi)
            {
                cmp = new CopyMoveProgress(this, queues);
            }

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

            actionProcessorThread.Start(queues);

            if (showUi)
            {
                owner.ShowChildDialog(cmp);

                if (cmp.DialogResult == DialogResult.Cancel)
                {
                    actionProcessorThread.Abort();
                }
            }

            actionProcessorThread.Join();

            theList.RemoveAll(x => x is Action action && action.Outcome.Done && !action.Outcome.Error);

            foreach (Action slia in theList.Actions)
            {
                Logger.Warn(slia.Outcome.LastError, $"Failed to complete the following action: {slia.Name}, doing {slia}. Error was {slia.Outcome.LastError?.Message}");
            }

            Logger.Info("Completed Selected Actions");
            Logger.Info("**************************");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes a set of actions, running them in a multi-threaded way based on the application's settings.
        /// </summary>
        /// <param name="theList">An ItemList to be processed.</param>
        /// <param name="showUI">Whether or not we should display a UI to inform the user about progress.</param>
        public void DoActions(ItemList theList, bool showUI)
        {
            logger.Info("**********************");
            logger.Info("Doing Selected Actions....");
            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 (showUI)
            {
                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) && ((Action)x).Done && !((Action)x).Error);

            foreach (Item sli in theList)
            {
                if (sli is Action)
                {
                    Action slia = (Action)sli;
                    logger.Warn("Failed to complete the following action: {0}, doing {1}. Error was {2}", slia.Name, slia.ToString(), slia.ErrorText);
                }
            }

            logger.Info("Completed Selected Actions");
            logger.Info("**************************");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Processes a set of actions, running them in a multi-threaded way based on the application's settings.
        /// </summary>
        /// <param name="theList">An ItemList to be processed.</param>
        /// <param name="showUi">Whether or not we should display a UI to inform the user about progress.</param>
        public void DoActions([CanBeNull] ItemList theList, bool showUi)
        {
            if (theList is null)
            {
                Logger.Info("Asked to do actions, but none provided....");
                return;
            }

            Logger.Info("**********************");
            Logger.Info($"Doing Selected Actions.... ({theList.Count} items detected, {theList.Actions().Count()} actions to be completed )");

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

            ActionQueue[] queues = ActionProcessorMakeQueues(theList);
            actionPause = false;

            // If not /hide, show CopyMoveProgress dialog

            CopyMoveProgress cmp = null;

            if (showUi)
            {
                cmp = new CopyMoveProgress(this, queues);
            }

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

            actionProcessorThread.Start(queues);

            if (cmp != null && cmp.ShowDialog() == DialogResult.Cancel)
            {
                actionProcessorThread.Abort();
            }

            actionProcessorThread.Join();

            theList.RemoveAll(x => x is Action action && action.Done && !action.Error);

            foreach (Action slia in theList.Actions())
            {
                Logger.Warn(slia.LastError, "Failed to complete the following action: {0}, doing {1}. Error was {2}", slia.Name, slia.ToString(), slia.ErrorText);
            }

            Logger.Info("Completed Selected Actions");
            Logger.Info("**************************");
        }
Exemplo n.º 4
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);
        }