private void RunTasksJob() { var tasks = TCAdmin.TaskScheduler.SDK.Objects.Task.GetTasks(DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)), DateTime.UtcNow, true, true, false, true, true, 0, null, null).ToArray(); foreach (TCAdmin.TaskScheduler.SDK.Objects.Task task in tasks) { if (_snapshotTasksIds.Contains(task.TaskId)) { continue; } _snapshotTasksIds.Add(task.TaskId); TaskCreated?.Invoke(task); } }
protected override void RunAction() { using (IRepository <Template, long> repository = PersistentFactory.GetContext().GetRepository <Template, long>()) { foreach (Template template in repository.GetAll()) { if (template.SatisfiesCondition()) { Task newTask = template.CreateTask(); TaskCreated?.Invoke(newTask); repository.Update(template); Log.Info($"Task {newTask.Name} was created from template", this); } } } }
public async Task CreateTask(TaskViewModel taskViewModel) { var result = await Create(taskViewModel.ToCreateTaskCommand()); if (result != null) { var updatedList = (await GetAllTasks()).Payload; if (updatedList != null) { _tasks = updatedList; SelectNullTask(); TaskCreated?.Invoke(this, null); return; } CreateTaskFailed?.Invoke(this, "The creation was successful, but we can no longer get an updated list of members from the server."); } CreateTaskFailed?.Invoke(this, "Unable to create record."); }
public void RaiseTaskCreated(Task task, [CallerMemberName] string taskName = default) { var status = $"[Created] Task: {taskName}"; TaskCreated?.Invoke(this, new TaskStatusChangedEventArgs(task, status)); }
private async Task TaskLoop(CancellationToken ct) { try { while (!ct.IsCancellationRequested) { State = NetworkServiceState.Finding; var result = await _netService.WaitForOneConnection(ct); var connection = result.Key; var commingType = result.Value; var writer = new BinaryWriter(connection.GetStream()); var reader = new BinaryReader(connection.GetStream()); if (commingType == ConnectionCommingType.FromListen) { var jsontask = reader.ReadString(); var task = JsonConvert.DeserializeObject <CreatedNetworkTaskData>(jsontask); TaskCreated?.Invoke(this, new DataEventArgs <CreatedNetworkTaskData>(task)); } else { //todo: generate task... var task = new CreatedNetworkTaskData() { Frequency = 33100, FrequencyNumber = new Random().Next(0, 10), Id = Guid.NewGuid() }; var jsontask = JsonConvert.SerializeObject(task); writer.Write(jsontask); writer.Flush(); TaskCreated?.Invoke(this, new DataEventArgs <CreatedNetworkTaskData>(task)); } State = NetworkServiceState.RequestForConfirm; var remoteConfirm = TaskEx.Run(() => { var confirmationResult = reader.ReadString(); var isConfirmed = JsonConvert.DeserializeObject <ConfirmationResult>(confirmationResult); return(isConfirmed); }); var localConfirm = _completationConfirm.Task.ContinueWith(t => { var cjs = JsonConvert.SerializeObject(t.Result); writer.Write(cjs); writer.Flush(); return(t.Result); }, TaskContinuationOptions.NotOnFaulted | TaskContinuationOptions.NotOnCanceled); var bothConfirmation = await TaskEx.WhenAll(remoteConfirm, localConfirm); bool isBothConfimed = bothConfirmation.All(x => x.Result); if (isBothConfimed) { TaskStarted?.Invoke(this, new DataEventArgs <CreatedNetworkTaskData>()); } connection.Close(); } } catch (TaskCanceledException) { } catch (Exception ex) { SimpleLogger.Log(ex); } }
private void QualityListItem_Selected(object sender, RoutedEventArgs e) { DownloadTask downloadTask = new DownloadTask(new DownloadInfo(((VideoInfo.Page.Quality)((ListBoxItem)sender).Tag), ConfigManager.GetSettings().DownloadThreads)); TaskCreated?.Invoke(downloadTask); }
private void OnTaskCreated(ITaskObserver task, object sender = null) { TaskCreated?.Invoke(sender ?? this, new TaskModifiedEventArgs(task, TaskObserveStatus.Running)); }
/// <summary> /// Executed whenever a new TaskItem is created. Invokes the delegates attached to the /// TaskCreated event. /// </summary> /// <param name="taskItem"> /// A newly created TaskItem /// </param> protected void OnTaskCreated(TaskItemModel taskItem) { TaskCreated?.Invoke(this, taskItem); }
private void QualityListItem_Selected(object sender, RoutedEventArgs e) { DownloadTask downloadTask = new DownloadTask(new DownloadInfo(((VideoInfo.Page.Quality)((ListBoxItem)sender).Tag), Bili_dl.SettingPanel.settings.DownloadThreads)); TaskCreated?.Invoke(downloadTask); }