void workerCommands_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

            processingCommands = false;
            //logger.Trace("Stopping command worker (images)...");
            QueueState = new QueueStateStruct()
            {
                queueState = QueueStateEnum.Idle, extraParams = new string[0]
            };
            QueueCount = 0;
        }
        public void Init()
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

            processingCommands = true;
            //logger.Trace("Starting command worker (images)...");
            QueueState = new QueueStateStruct()
            {
                queueState = QueueStateEnum.StartingImages, extraParams = new string[0]
            };
            this.workerCommands.RunWorkerAsync();
        }
Beispiel #3
0
 public QueueStateEventArgs(QueueStateStruct queueState)
 {
     QueueState = queueState;
 }
        void workerCommands_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

            processingCommands = false;
            //logger.Trace("Stopping command worker (images)...");
            QueueState = new QueueStateStruct() { queueState = QueueStateEnum.Idle, extraParams = new string[0] };
            QueueCount = 0;
        }
        void workerCommands_DoWork(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                if (workerCommands.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                // if paused we will sleep for 5 seconds, and the try again
                // we will remove the pause if it was set more than 6 hours ago
                // the pause is initiated when banned from AniDB or manually by the user
                if (Paused)
                {
                    try
                    {
                        if (workerCommands.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }

                        //logger.Trace("Images Queue is paused: {0}", pauseTime.Value);
                        TimeSpan ts = DateTime.Now - pauseTime.Value;
                        if (ts.TotalHours >= 6)
                        {
                            Paused = false;
                        }
                    }
                    catch
                    {
                    }
                    Thread.Sleep(5000);
                    continue;
                }

                //logger.Trace("Looking for next command request (images)...");

                CommandRequest crdb = RepoFactory.CommandRequest.GetNextDBCommandRequestImages();
                if (crdb == null) return;

                QueueCount = RepoFactory.CommandRequest.GetQueuedCommandCountImages();
                //logger.Trace("{0} commands remaining in queue (images)", QueueCount);

                if (workerCommands.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                //logger.Trace("Next command request (images): {0}", crdb.CommandID);

                ICommandRequest icr = CommandHelper.GetCommand(crdb);
                if (icr == null)
                {
                    //logger.Trace("No implementation found for command: {0}-{1}", crdb.CommandType, crdb.CommandID);
                    return;
                }

                if (workerCommands.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                QueueState = icr.PrettyDescription;

                //logger.Trace("Processing command request (images): {0}", crdb.CommandID);
                icr.ProcessCommand();

                //logger.Trace("Deleting command request (images): {0}", crdb.CommandID);
                RepoFactory.CommandRequest.Delete(crdb.CommandRequestID);
                QueueCount = RepoFactory.CommandRequest.GetQueuedCommandCountImages();
            }
        }
        public void Init()
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(ServerSettings.Culture);

            processingCommands = true;
            //logger.Trace("Starting command worker (images)...");
            QueueState = new QueueStateStruct() { queueState = QueueStateEnum.StartingImages, extraParams = new string[0] };
            this.workerCommands.RunWorkerAsync();
        }
 public QueueStateEventArgs(QueueStateStruct queueState)
 {
     QueueState = queueState;
 }