public NewDownloadViewModel() : base(null) { _downloadManager = DownloadManager.GetInstance(); _downloadManager.Queues.CollectionChanged += QueueChanged; UpdateQueueList(); SelectedQueue = Queues.FirstOrDefault(x => x.Number == Queue.DefaultNumber); }
private Thread BuildListenerThread() { return(new Thread(() => { while (!isDisposing) { BasicDeliverEventArgs item = null; // grab the first item where any of the consumer queues has a value var queue = Queues .FirstOrDefault(q => q.TryTake(out item)); // if we're dead and we didn't find an item, // it means it's time to pack up and go home if (isDisposing && queue == null) { break; } // if we're not dead and we didn't find an item // lets go around again if (!isDisposing && queue == null) { continue; } if (item == null) { continue; } var delivery = new Delivery( item.DeliveryTag, item.Body, item.RoutingKey, item.Exchange, item.BasicProperties.ContentType, item.BasicProperties.CorrelationId, item.BasicProperties.ReplyTo, item.BasicProperties.Headers); // register the queue as a delivery listener on the delivery so that // we can ack or nack the message depending on whether or not it was processed delivery.RegisterDeliveryListener(queue); // deliver the message to the delivery strategy deliveryStrategy.Deliver(delivery); } logger.DebugFormat("Subscription thread terminated for: {0}", this); })); }
private void EditQueueAction() { var queue = Queues.FirstOrDefault(i => i.Id.ToString() == SelectedItem.Id.ToString()); if (queue != null) { queue.Name = SelectedItem.Name; if (!SelectedItem.IsStartLoadAt) { NewStartTime = TimeSpan.Zero; } if (!SelectedItem.IsStopLoadAt) { NewStopTime = TimeSpan.Zero; } queue.IsStartLoadAt = SelectedItem.IsStartLoadAt; queue.StartDownload = NewStartTime.ToString(); queue.IsStopLoadAt = SelectedItem.IsStopLoadAt; queue.StopDownload = NewStopTime.ToString(); } dataStorage.Save(Queues); }
private async void RemoveQueueAction(Queue file) { if (file == null) { ContentDialog notSelectQueueDialog = new ContentDialog() { Title = resourceMap.GetValue("titleErrorDeleteQueueDialog", resourceContext).ValueAsString, Content = resourceMap.GetValue("contentErrorRemoveQueueDialog", resourceContext).ValueAsString, PrimaryButtonText = "ОК" }; ContentDialogResult result = await notSelectQueueDialog.ShowAsync(); return; } var item = Queues.FirstOrDefault(i => i.Id.ToString() == file.Id.ToString()); if (item != null) { Queues.Remove(item); } dataStorage.Save(Queues); }
public List <string> GetState() { var taskDataList = TaskDataVault; var listQueue = Queues.FirstOrDefault(t => t.Id == ListQueueId); var downloadQueue = Queues.FirstOrDefault(t => t.Id == DownloadQueueId); var listTaskDataList = taskDataList.OfType <YandeListTaskData>().ToList(); var downloadTaskDataList = taskDataList.OfType <DownloadTaskData>().ToList(); var listSuccess = listTaskDataList.Count(a => a.ExecutionResult == TaskDataExecutionResult.Complete); var listFailed = listTaskDataList.Sum(a => a.TryTimes - 1); var downloadSuccess = downloadTaskDataList.Count(a => a.ExecutionResult == TaskDataExecutionResult.Complete); var downloadFailed = downloadTaskDataList.Sum(a => Math.Max(a.TryTimes - 1, 0)); var table = new List <List <string> > { new List <string> { $"[{Status}]", $"Last Ids: {_lastImageIds.Count}" }, new List <string> { "[List]", $"Threads: {listQueue?.ActiveThreadCount ?? 0}/{listQueue?.MaxThreadCount ?? 0}", $"Progress: {listSuccess}/{listTaskDataList.Count}", $"Failed: {listFailed}" }, new List <string> { "[Image]", $"Threads: {downloadQueue?.ActiveThreadCount ?? 0}/{downloadQueue?.MaxThreadCount ?? 0}", $"Progress: {downloadSuccess}/{downloadTaskDataList.Count}", $"Skipped: {downloadTaskDataList.Count(a => a.DownloadResult == DownloadTaskDataResult.Skipped)}", $"Failed: {downloadFailed}" } }; return(table.BeautifyTable()); }