예제 #1
0
        public async Task <IActionResult> AddTask([FromBody] TaskModel task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var currentTime = DateTime.UtcNow;
                task.Added  = currentTime;
                task.Edited = currentTime;
                task.Status = TaskStatus.Active;

                await taskRepository.AddTask(task);

                UpdateSubscriptions();
            }
            catch (DbUpdateException)
            {
                return(InternalError());
            }

            return(this.Ok());
        }
예제 #2
0
        public int AddTask(TaskDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(TaskDTO.FormatTaskDTO(dto));

                R_Task t = TaskDTO.ConvertDTOtoEntity(dto);

                // add
                id         = Repository.AddTask(t);
                dto.TaskId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
예제 #3
0
        public Task AddTask([FromBody] Task task)
        {
            task.Notified = false;
            var res = repository.AddTask(task);

            return(res);
        }
예제 #4
0
        public async Task <IActionResult> Post([FromForm] TaskViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Insert into DB
            var task = new TaskItem
            {
                Name = vm.TaskName
            };

            if (vm.TaskFile != null && vm.TaskFile.Length > 0)
            {
                task.FileName        = vm.TaskFile.FileName;
                task.FileContentType = vm.TaskFile.ContentType;
            }

            repository.AddTask(task);
            repository.Save();

            // Upload file into storage
            if (vm.TaskFile != null && vm.TaskFile.Length > 0)
            {
                var filePath = Path.Combine(this.environment.ContentRootPath, @"FileStorage", vm.TaskFile.FileName);
                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    await vm.TaskFile.CopyToAsync(stream);
                }
            }

            return(Created("", task));
        }
예제 #5
0
        public async Task <AddTaskResponse> Handle(AddTaskCommand command, CancellationToken cancellationToken)
        {
            if (!IsValid(command))
            {
                return(null);
            }

            var tasks = new Tasks();

            tasks = tasks.AddTask(command.Name, _notification);

            if (_notification.HasNotification())
            {
                return(null);
            }

            using (var uow = _unitOfWorkManager.Begin())
            {
                await _taskRepository.AddTask(tasks);

                uow.Complete();
            }

            return(TaskResponse(tasks));
        }
예제 #6
0
        public async Task <IActionResult> CreateTask([FromBody] TaskResource taskResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var task = mapper.Map <TaskResource, Models.TaskingModels.Task>(taskResource);

            taskRepository.AddTask(task);

            task.Group = await groupRepository.GetGroup(taskResource.GroupId);

            task.Status = await statusRepository.GetStatus(taskResource.StatusId);

            taskRepository.UpdateAttachments(task, taskResource);
            taskRepository.UpdateCheckList(task, taskResource);
            taskRepository.UpdateComments(task, taskResource);
            taskRepository.UpdateActivities(task, taskResource);
            taskRepository.UpdateMembers(task, taskResource);

            await unitOfWork.Complete();

            task = await taskRepository.GetTask(task.TaskId);

            var result = mapper.Map <Models.TaskingModels.Task, TaskResource>(task);

            return(Ok(result));
        }
예제 #7
0
        private void ImportTasks(FileInfo path, string format = "json")
        {
            Log.Debug($"Importing data from file. Format: {format}, Path: {path}");
            if (!path.Exists)
            {
                Log.Error("File to import does not exist.");
                Output.WriteError($"The entered path does not exist. Please try again.");
                return;
            }

            try
            {
                var tasksFromFile = FormatData.FromType(path.ToString(), format);
                foreach (var task in tasksFromFile)
                {
                    task.Id = null;
                    _repository.AddTask(task);
                }
                _repository.SaveChanges();

                Output.WriteText($"[green]Succesfully imported data.[/] Path : {path.ToString()}");
                Output.WriteTable(new string[] { "ID", "Task", "Status", "Tags", "Added On", "Completed On" }, tasksFromFile);
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Failed to import data.");
                Output.WriteError("Failed to import data from file. Please try again.");
            }
        }
예제 #8
0
 public bool UpsertTask(TaskModel task)
 {
     log.Debug("Entered Upsert Task");
     try
     {
         if (task == null)
         {
             throw new Exception("TaskService: UpsertTask did not receive a Task!");
         }
         // update
         if (task.Id_Task > 0)
         {
             if (!TaskRepo.UpdateTask(task))
             {
                 return(false);
             }
         }
         else
         {
             //insert
             TaskRepo.AddTask(task);
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
예제 #9
0
        private void AddTask(string title, string tags = null)
        {
            if (null != tags)
            {
                tags = Sanitizer.SanitizeTags(tags);
                tags = Sanitizer.DeduplicateTags(tags);
            }

            Log.Debug($"Adding a new task : {title}, Status = {(_name == "now" ? "Doing" : "Later")}, Tags = {tags}");
            var newTask = new TaskItem
            {
                TaskDescription = title,
                AddedOn         = DateTime.Now,
                Status          = _name == "now" ? "Doing" : "Later",
                Tags            = tags
            };

            _repository.AddTask(newTask);
            var success = _repository.SaveChanges();

            if (success)
            {
                Log.Information($"Added a new task : {title}, Status = {(_name == "now" ? "Doing" : "Later")}, Tags = {tags}");
                Output.WriteText($"[green]Added a new task[/] : {title}, [aqua]Status[/] = {(_name == "now" ? "Doing" : "Later")}, [aqua]Tags[/] = {tags}");
            }
            else
            {
                Log.Error($"Failed to add task.");
                Output.WriteError($"Failed to add task. Please try again.");
            }
        }
예제 #10
0
 public void AddTask(AddUpdateTaskCommand taskCommand)
 {
     if (taskCommand != null)
     {
         Domain.Models.Task task = new Domain.Models.Task(taskCommand.Title, taskCommand.Details, taskCommand.UserId, taskCommand.Date);
         _taskRepository.AddTask(task);
     }
 }
예제 #11
0
        public async Task <ActionResult <Response> > PostTask(string dateTimeAsString, Response response)
        {
            try
            {
                if (response == null)
                {
                    return(BadRequest());
                }

                var dateTime = DateTime.Parse(dateTimeAsString);
                var date     = await taskRepository.GetDate(dateTime);

                Models.Task task;

                if (date == null)
                {
                    var addingDate = new Date
                    {
                        TimeStamp = dateTime,
                        Tasks     = new List <Models.Task>()
                    };
                    task = new Models.Task {
                        Date = addingDate, Title = response.title
                    };
                    await taskRepository.AddDate(addingDate);

                    await taskRepository.AddTask(task);
                }
                else
                {
                    task = new Models.Task {
                        Date = date, Title = response.title
                    };
                    await taskRepository.AddTask(task);
                }

                await taskRepository.Save();

                return(CreatedAtRoute(new { id = dateTimeAsString }, new { name = task.Id, response }));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Task adding to database error"));
            }
        }
        public void AddTask(Task task)
        {
            DataTask dt = new DataTask {
                Id = task.Id, Name = task.Name, UrgencyMeasure = task.UrgencyMeasure, ImportanceMeasure = task.ImportanceMeasure, Description = task.Description
            };

            idataTask.AddTask(dt);
        }
예제 #13
0
        public void Run(AddCommand command)
        {
            var item = new AddTaskData(command.Description, command.Priority);

            var currentTask = _taskRepository.AddTask(item);

            Console.WriteLine($"Added {currentTask.Print()}");
        }
예제 #14
0
 public IActionResult Create(Task task)
 {
     if (ModelState.IsValid)
     {
         Task newTask = taskRepository.AddTask(task);
         return(RedirectToAction("details", new { id = newTask.Id }));
     }
     return(View());
 }
예제 #15
0
        public int AddTask(TaskVm taskVm)
        {
            var task = TaskMapper.MapFromVm(taskVm);

            _repo.AddTask(task);
            var idTask = task.IdTask;

            return(idTask);
        }
예제 #16
0
        public bool AddTask(TaskDTO task)
        {
            Task newTask = new Task()
            {
                Name = task.Name, Description = task.Description, ColumnId = task.ColumnId, DueDateTime = task.DueDateTime
            };

            _taskRepository.AddTask(newTask);
            return(_taskRepository.Save());
        }
예제 #17
0
        public async Task <int> AddTask(ProjectTask task)
        {
            if (string.IsNullOrEmpty(task.Title))
            {
                throw new Exception("Task title can't be empty");
            }
            var id = await _taskRepository.AddTask(task);

            return(id);
        }
예제 #18
0
        public PlaceTask Create(string url)
        {
            PlaceTask cTask = new PlaceTask
            {
                TaskId = _taskRepository.AddTask(url, "pending")
            };

            _nsBusProvider.SendTaskCreatedMessage(cTask);
            return(cTask);
        }
예제 #19
0
        public ActionResult Create([Bind(Include = "TaskId,TaskTitle,TaskContent,TaskStatus")]
                                   UserTask userTask)
        {
            if (ModelState.IsValid)
            {
                taskRepository.AddTask(userTask);
                return(RedirectToAction("Index"));
            }

            return(View(userTask));
        }
예제 #20
0
        public async Task <IActionResult> Post([FromBody] TaskEntity task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await taskRepository.AddTask(task);

            return(Ok());
        }
예제 #21
0
        public async Task <IActionResult> PostTaskEntity([FromBody] TaskEntity taskEntity)
        {
//            if (!ModelState.IsValid)
//            {
//                return BadRequest(ModelState);
//            }

            await _repo.AddTask(taskEntity);

            return(CreatedAtAction("GetTaskEntity", new { id = taskEntity.Id }, taskEntity));
        }
예제 #22
0
        public void CreateTask(string name)
        {
            Task task = new Task
            {
                Name    = name,
                Date    = DateTime.Now,
                Content = String.Empty
            };

            _taskRepository.AddTask(task);
        }
        public async Task CreateTaskCommand_Execute_Success()
        {
            var todoTask = _fixture.Create <CreateTodoItemDto>();

            _taskRepositoryMock.AddTask(Arg.Any <TodoItem>()).Returns(Task.FromResult(1));

            var result = await _createTaskCommand.Execute(todoTask);

            result.IsSuccess().Should().BeTrue();
            result.Data.Id.Should().BeInRange(long.MinValue, long.MaxValue);
        }
예제 #24
0
        public async Task AddTaskAsync(TaskEntity task)
        {
            Validators.IsNotNull(task);

            if (string.IsNullOrEmpty(task.TaskNumber))
            {
                task.TaskNumber = _taskNumberGenerator.CalculateTaskNumber();
            }

            _taskRepository.AddTask(task);
            await _taskRepository.SaveAsync();
        }
예제 #25
0
        public IActionResult PostRegistration(Task task)
        {
            Guid newId = new Guid();

            task.Id = newId;

            _taskRepository.AddTask(task);
            _taskRepository.SaveChanges();

            _logger.LogInformation($"Course with id: {task.Id} has been added.");
            return(CreatedAtAction(nameof(Get), new { id = task.Id }, task));
        }
예제 #26
0
        public async Task <AppTask> AddTaskAsync(AppTask task, CancellationToken token)
        {
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            _taskRepository.AddTask(task);
            await _unitOfWork.SaveAsync(token);

            return(task);
        }
예제 #27
0
 public bool AddTask(TaskDTO task)
 {
     try
     {
         _repository.AddTask(task);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
 private void Add_Click(object sender, RoutedEventArgs e)
 {
     if (NewName.Text != "" & NewDescription.Text != "" & NewProgres.Text != "")
     {
         taskRepository.AddTask(NewName.Text, NewDescription.Text, Int32.Parse(WorkId.SelectedItem.ToString()), NewProgres.Text);
         MessageBox.Show("The task has been added correctly", "Saved");
     }
     else
     {
         MessageBox.Show("There is empty at least one empty box, fill it", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
        public ResponseBase <AddTaskResponse> AddTaskInfo(AddTaskRequest req)
        {
            var task = taskrep.FindSingle(x => x.taskname == req.TaskName && x.isdel == 0);

            if (task != null)
            {
                return(ResponseToClient <AddTaskResponse>(ResponesStatus.Failed, "当前任务名称已存在"));
            }
            DateTime dt     = DateTime.Now;
            int      taskid = taskrep.AddTask(new tb_task()
            {
                createby           = int.Parse(string.IsNullOrEmpty(req.AdminId)?"0":req.AdminId),
                createtime         = dt,
                groupid            = req.GroupId,
                isdel              = 0,
                taskclassname      = req.TaskMainClassName,
                taskdescription    = req.TaskDescription,
                taskname           = req.TaskName,
                tasknamespace      = req.TaskNameSpace,
                taskremark         = string.IsNullOrEmpty(req.TaskRemark)?"":req.TaskRemark,
                taskschedulestatus = (int)TaskScheduleStatus.NoSchedule,
                alarmtype          = req.AlarmType,
                alarmuserid        = req.AlarmUserId,
                isenablealarm      = req.IsEnabledAlarm,
                tasktype           = req.TaskType
            });

            if (taskid <= 0)
            {
                return(ResponseToClient <AddTaskResponse>(ResponesStatus.Failed, "添加任务失败"));
            }
            taskversionrep.Add(new tb_taskversion()
            {
                nodeid            = req.NodeId,
                taskcreatetime    = dt,
                taskcron          = (req.TaskType == (int)TaskType.SchedulingTask?req.TaskCorn:"[simple,,1,,]"),
                taskerrorcount    = 0,
                tasklastendtime   = Convert.ToDateTime("2099-12-30"),
                tasklasterrortime = Convert.ToDateTime("2099-12-30"),
                tasklaststarttime = Convert.ToDateTime("2099-12-30"),
                taskparams        = string.IsNullOrEmpty(req.TaskParams)?"":req.TaskParams,
                taskruncount      = 0,
                taskrunstatus     = (int)ExecuteStatus.NoExecute,
                taskupdatetime    = dt,
                version           = 1,
                versioncreatetime = dt,
                zipfile           = req.TaskDll,
                zipfilename       = req.TaskDllFileName,
                taskid            = taskid
            });
            return(ResponseToClient <AddTaskResponse>(ResponesStatus.Success, "添加任务成功"));
        }
예제 #30
0
 public bool AddTask(Task task)
 {
     if (task.ParentId == 0)
     {
         return(_repo.AddParentTask(new ParentTask {
             ParentId = task.TaskId, ParentTaskName = task.TaskName
         }));
     }
     else
     {
         return(_repo.AddTask(task));
     }
 }