コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
        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.");
        }
コード例 #4
0
        public void RaiseTaskCreated(Task task, [CallerMemberName] string taskName = default)
        {
            var status = $"[Created] Task: {taskName}";

            TaskCreated?.Invoke(this, new TaskStatusChangedEventArgs(task, status));
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 private void OnTaskCreated(ITaskObserver task, object sender = null)
 {
     TaskCreated?.Invoke(sender ?? this, new TaskModifiedEventArgs(task, TaskObserveStatus.Running));
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
        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);
        }