/// <summary> /// Keeps the Known TaskLists in sync with the server. /// </summary> private async void OnUpdatedTaskListGuidsAsync(object source, ServerPollerEventArgs e) { if (e.Result is List <TaskListSummary> taskListSummaries) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // Add or update TaskLists for (int i = 0; i < taskListSummaries.Count; i++) { try { if (i == TaskListCollection.Count) { TaskListCollection.Insert(i, taskListSummaries[i]); } else if (!TaskListCollection[i].Equals(taskListSummaries[i])) { TaskListCollection[i] = taskListSummaries[i]; } } catch (ArgumentOutOfRangeException ex) { Debug.WriteLine(ex.AllExceptionsToString()); } } // Prune existing list int j = taskListSummaries.Count; while (TaskListCollection.Count > taskListSummaries.Count) { TaskListCollection.RemoveAt(j); } }); } }
public InternalBackendManager(IPreferences preferences) { if (preferences == null) throw new ArgumentNullException ("preferences"); this.preferences = preferences; availableBackendNodes = AddinManager .GetExtensionNodes<BackendNode> (typeof(IBackend)); taskLists = new TaskListCollection (); }
private void RunAllButton_Click(object sender, RoutedEventArgs e) { if (TaskListCollection.All(x => x.IsRunningOrPending == false)) { _ = Client.RunAllTaskLists(); } else { _ = Client.AbortAll(); } }
public InternalBackendManager(IPreferences preferences) { if (preferences == null) { throw new ArgumentNullException("preferences"); } this.preferences = preferences; availableBackendNodes = AddinManager .GetExtensionNodes <BackendNode> (typeof(IBackend)); taskLists = new TaskListCollection(); }
private async void MoveDownButton_Click(object sender, RoutedEventArgs e) { var button = sender as Button; var selectedIndex = TaskListCollection.IndexOf(GetTaskListFromButton(button)); if (selectedIndex + 1 < TaskListCollection.Count) { var itemToMoveDown = TaskListCollection[selectedIndex]; TaskListCollection.RemoveAt(selectedIndex); TaskListCollection.Insert(selectedIndex + 1, itemToMoveDown); var newOrder = new List <Guid>(); newOrder.AddRange(TaskListCollection.Select(x => x.Guid)); await Client.ReorderTaskLists(newOrder); } }
public static void Fill(this TaskListCollection tasks, ToolStrip actionPanel, ContextMenuStrip actionMenu, TaskList extra = null) { actionPanel.Items.Clear(); actionMenu?.Items.Clear(); if (extra != null) { TaskListFill(actionPanel, actionMenu, extra, extra.GetTaskItems()); } foreach (var item in tasks.GetTaskListItems(null)) { TaskListFill(actionPanel, actionMenu, item.Key, item.Value); } actionPanel.Items.RemoveAt(actionPanel.Items.Count - 1); actionMenu?.Items.RemoveAt(actionMenu.Items.Count - 1); }
// This is called when the layout is updated to update the accessible name of the edit, delete and save buttons. private void TaskListsView_LayoutUpdated(object sender, object e) { for (int i = 0; i < TaskListCollection.Count; i++) { var item = TaskListsView.ContainerFromIndex(i) as FrameworkElement; if (item != null) { var grid = VisualTreeHelper.GetChild(item, 0) as FrameworkElement; var buttonStack = VisualTreeHelper.GetChild(grid, 2) as FrameworkElement; var editButton = VisualTreeHelper.GetChild(buttonStack, 0) as FrameworkElement; var saveButton = VisualTreeHelper.GetChild(buttonStack, 1) as FrameworkElement; var deleteButton = VisualTreeHelper.GetChild(buttonStack, 2) as FrameworkElement; AutomationProperties.SetName(editButton, TaskListCollection.ElementAt(i).Name + " Edit Button"); AutomationProperties.SetName(saveButton, TaskListCollection.ElementAt(i).Name + " Save Button "); AutomationProperties.SetName(deleteButton, TaskListCollection.ElementAt(i).Name + " Delete Button"); } } }
/// <summary> /// Called when the TaskLists are reordered by drag and drop. Sends updated order to the Service. /// </summary> private async void TaskListsView_DragItemsCompleted(ListViewBase sender, DragItemsCompletedEventArgs args) { try { var newOrder = new List <Guid>(); newOrder.AddRange(TaskListCollection.Select(x => x.Guid)); await Client.ReorderTaskLists(newOrder); } catch (FactoryOrchestratorException ex) { // If it fails, the poller will update the UI to the old order. ContentDialog failedSaveDialog = new ContentDialog { Title = resourceLoader.GetString("ReorderFailed"), Content = ex.Message, CloseButtonText = resourceLoader.GetString("Ok") }; ContentDialogResult result = await failedSaveDialog.ShowAsync(); } }
protected virtual void Dispose(bool disposing) { if (disposed) return; disposed = true; if (disposing) { if (backend != null) backend.Dispose (); taskLists = null; backend = null; } }
/// <summary> /// Initializes a new instance of the <see cref="Tasque.Client.BackendManager"/> class. /// </summary> /// <param name='preferences'>The preferences.</param> /// <exception cref="System.ArgumentNullException"> /// <para> /// Thrown, when <paramref name="backendInfos"/> is <c>null</c> -or- /// </para> /// <para> /// when <paramref name="preferences"/> is <c>null</c>. /// </para> /// </exception> /// <exception cref="System.ArgumentException"> /// Thrown, when <paramref name="backendInfos"/> is empty. /// </exception> public BackendManager(IEnumerable<BackendInfo> backendInfos, IPreferences preferences) { if (backendInfos == null) throw new ArgumentNullException ("backendInfos"); if (!backendInfos.Any ()) throw new ArgumentException ("backendInfos must at least have one element"); if (preferences == null) throw new ArgumentNullException ("preferences"); AvailableBackends = new ReadOnlyCollection<BackendInfo> (backendInfos.ToList ()); this.preferences = preferences; taskLists = new TaskListCollection (); TaskLists = new ReadOnlyObservableCollection<ITaskList> (taskLists); }
public void SyncTaskLists(SyncCallback callback) { TaskListCollection tmp = new TaskListCollection(this); tmp.Resync(() => { System.Threading.Interlocked.Exchange(ref mTaskLists, tmp); callback(); }); }
public void LoadListsFromResponse(Response response) { TaskListCollection temp = new TaskListCollection(this); if (response.Lists != null) { using (new UnsyncedScope(temp)) { foreach (var list in response.Lists) { if (list.Archived == 0 && list.Deleted == 0) { TaskList newList = new TaskList(list); temp.Add(newList); } } temp.Sort(); } } System.Threading.Interlocked.Exchange(ref mTaskLists, temp); }
private async void OnUpdatedTaskListGuidAndStatusAsync(object source, ServerPollerEventArgs e) { var newSummaries = (List <TaskListSummary>)e.Result; // Get the new TaskLists if (newSummaries != null) { int newCount = newSummaries.Count; await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { if (newSummaries.Any(x => x.IsRunningOrPending)) { RunAllButton.Content = resourceLoader.GetString("AbortAllButton/Content"); ToolTipService.SetToolTip(RunAllButton, resourceLoader.GetString("AbortAllButton/ToolTipService/ToolTip")); AutomationProperties.SetName(RunAllButton, resourceLoader.GetString("AbortAllButton/ToolTipService/ToolTip")); } else { RunAllButton.Content = resourceLoader.GetString("RunAllButton/Content"); ToolTipService.SetToolTip(RunAllButton, resourceLoader.GetString("RunAllButton/ToolTipService/ToolTip")); AutomationProperties.SetName(RunAllButton, resourceLoader.GetString("RunAllButton/ToolTipService/ToolTip")); } if (newCount == 0) { // No TaskLists exist, clear everything LoadingTasksRing.IsActive = false; TaskListCollection.Clear(); ActiveListCollection.Clear(); return; } if (_trackExecution) { // Find the latest running list. If none are running find the first run pending list. var latestList = newSummaries.Where(x => x.Status == TaskStatus.Running).DefaultIfEmpty(new TaskListSummary()).LastOrDefault(); if (latestList.Guid == Guid.Empty) { latestList = newSummaries.Where(x => x.Status == TaskStatus.RunPending).DefaultIfEmpty(new TaskListSummary()).FirstOrDefault(); } if (latestList.Guid != Guid.Empty) { _selectedTaskListGuid = latestList.Guid; } } bool selectedListFound = false; for (int i = 0; i < newSummaries.Count; i++) { var newSummary = newSummaries[i]; if (newSummary.Guid == _selectedTaskListGuid) { selectedListFound = true; } // Update the TaskListCollection if (i == TaskListCollection.Count) { TaskListCollection.Insert(i, newSummary); } else if (!TaskListCollection[i].Equals(newSummary)) { // Template reselected automatically TaskListCollection[i] = newSummary; } // Ensure correct list is selected if ((_selectedTaskListGuid == newSummary.Guid) && (TaskListsView.SelectedIndex != i)) { TaskListsView.SelectedIndex = i; } } // Prune non-existent Lists int j = newSummaries.Count; while (TaskListCollection.Count > newSummaries.Count) { TaskListCollection.RemoveAt(j); } if (!selectedListFound && _selectedTaskList != -1) { // The selected list was deleted _selectedTaskList = -1; _selectedTaskListGuid = Guid.Empty; TaskListsView.SelectedIndex = -1; ActiveListCollection.Clear(); LoadingTasksRing.IsActive = false; } } catch (Exception ex) { Debug.WriteLine(ex.AllExceptionsToString()); } }); } else { // No TaskLists exist, clear everything await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LoadingTasksRing.IsActive = false; TaskListCollection.Clear(); ActiveListCollection.Clear(); EndTrackExecution(); }); } }
private async void OnUpdatedTaskListAsync(object source, ServerPollerEventArgs e) { if (e.Result != null) { TaskList list = (TaskList)e.Result; var taskArray = list.Tasks.ToArray(); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { try { LoadingTasksRing.IsActive = false; if (taskArray.Length == 0) { // No Tasks exist, clear everything ActiveListCollection.Clear(); return; } for (int i = 0; i < taskArray.Length; i++) { // Determine the template to use. Do here since it depends on the status of the list, not only the Task var newTask = taskArray[i]; var newTemplate = (((list.TaskListStatus != TaskStatus.Running) && (list.TaskListStatus != TaskStatus.RunPending)) && (newTask.LatestTaskRunPassed != null) && (newTask.LatestTaskRunPassed == false)) ? TaskViewTemplate.WithRetryButton : TaskViewTemplate.Normal; // Update the ActiveListCollection try { if (i == ActiveListCollection.Count) { ActiveListCollection.Insert(i, new TaskBaseWithTemplate(newTask, newTemplate)); } else if (!ActiveListCollection[i].Task.Equals(newTask)) { // force template reselection ActiveListCollection[i] = new TaskBaseWithTemplate(newTask, newTemplate); } } catch (ArgumentOutOfRangeException ex) { Debug.WriteLine(ex.AllExceptionsToString()); } } if (_trackExecution) { // Show mini window with latest output var latestTask = taskArray.Where(x => x.LatestTaskRunStatus == TaskStatus.Running).DefaultIfEmpty(null).LastOrDefault(); if (latestTask == null) { latestTask = taskArray.Where(x => x.LatestTaskRunStatus == TaskStatus.RunPending).DefaultIfEmpty(null).FirstOrDefault(); } if (latestTask != null) { // Select the running task var item = ActiveListCollection.Where(x => x.Task.Guid == latestTask.Guid).First(); ActiveTestsResultsView.SelectedItem = item; ActiveTestsView.SelectedItem = item; FollowOutput = true; // Ensure the running task has changed before updating UI if (_selectedTaskGuid != latestTask.Guid) { // Prepare result preview _selectedTaskGuid = latestTask.Guid; await ResultsPageEmbedded.SetupForTask(latestTask); // Make result preview visible ResultsPreviewScrollView.Visibility = Visibility.Visible; ResultsPreviewTaskName.Visibility = Visibility.Visible; ResultsPreviewTaskName.Text = latestTask.Name; LayoutRoot.RowDefinitions.Last().Height = new GridLength(1, GridUnitType.Star); LayoutRoot.RowDefinitions[2].Height = GridLength.Auto; EnsureSelectedIndexVisible(ActiveTestsView, TestsScrollView); } } else if (!TaskListCollection.Any(x => (x.Guid != _selectedTaskListGuid) && (x.IsRunningOrPending))) { // No more tasks are queued to run. Hide preview. _selectedTaskGuid = Guid.Empty; EndTrackExecution(); } } // Prune non-existent Tasks int j = taskArray.Length; while (ActiveListCollection.Count > taskArray.Length) { ActiveListCollection.RemoveAt(j); } } catch (Exception ex) { Debug.WriteLine(ex.AllExceptionsToString()); } }); } else { // No Tasks exist, clear everything await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LoadingTasksRing.IsActive = false; ActiveListCollection.Clear(); }); } }
private async void OnUpdatedTaskListAsync(object source, ServerPollerEventArgs e) { if (e.Result != null) { TaskList list = (TaskList)e.Result; var taskArray = list.Tasks.ToArray(); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { try { LoadingTasksRing.IsActive = false; if (taskArray.Length == 0) { // No Tasks exist, clear everything ActiveListCollection.Clear(); return; } for (int i = 0; i < taskArray.Length; i++) { // Determine the template to use. Do here since it depends on the status of the list, not only the Task var newTask = taskArray[i]; var newTemplate = (((list.TaskListStatus != TaskStatus.Running) && (list.TaskListStatus != TaskStatus.RunPending)) && (newTask.LatestTaskRunPassed != null) && (newTask.LatestTaskRunPassed == false)) ? TaskViewTemplate.WithRetryButton : TaskViewTemplate.Normal; // Update the ActiveListCollection try { if (i == ActiveListCollection.Count) { ActiveListCollection.Insert(i, new TaskBaseWithTemplate(newTask, newTemplate)); } else if (!ActiveListCollection[i].Task.Equals(newTask)) { // force template reselection ActiveListCollection[i] = new TaskBaseWithTemplate(newTask, newTemplate); } } catch (ArgumentOutOfRangeException ex) { Debug.WriteLine(ex.AllExceptionsToString()); } } if (Settings.TrackExecution) { // Show mini window with latest output var latestTask = taskArray.Where(x => x.LatestTaskRunStatus == TaskStatus.Running).DefaultIfEmpty(null).LastOrDefault(); if (latestTask == null) { latestTask = taskArray.Where(x => x.LatestTaskRunStatus == TaskStatus.RunPending).DefaultIfEmpty(null).FirstOrDefault(); } if (latestTask != null) { // Select the running task await TrackTaskExecution(latestTask); } else if (!TaskListCollection.Any(x => (x.Guid != _selectedTaskListGuid) && (x.IsRunningOrPending))) { // No more tasks are queued to run. Hide preview. _selectedTaskGuid = Guid.Empty; EndTrackExecution(); } } // Prune non-existent Tasks int j = taskArray.Length; while (ActiveListCollection.Count > taskArray.Length) { ActiveListCollection.RemoveAt(j); } } catch (Exception ex) { Debug.WriteLine(ex.AllExceptionsToString()); } }); } else { // No Tasks exist, clear everything await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LoadingTasksRing.IsActive = false; ActiveListCollection.Clear(); }); } }