Esempio n. 1
0
        public async Task CreateGroupTaskAsync_Normal_ExecutesRequestProperly()
        {
            (var client, var handler) = InstrumentedTaskClient();

            string exampleResponse = "{\r\n    \"success\": true,\r\n    \"data\": {\r\n        \"text\": \"Test API Params\",\r\n        \"type\": \"todo\",\r\n        \"notes\": \"\",\r\n        \"tags\": [],\r\n        \"value\": 0,\r\n        \"priority\": 1,\r\n        \"attribute\": \"str\",\r\n        \"challenge\": {\r\n            \"id\": \"f23c12f2-5830-4f15-9c36-e17fd729a812\"\r\n        },\r\n        \"group\": {\r\n            \"assignedUsers\": [],\r\n            \"approval\": {\r\n                \"required\": false,\r\n                \"approved\": false,\r\n                \"requested\": false\r\n            }\r\n        },\r\n        \"reminders\": [],\r\n        \"_id\": \"4a29874c-0308-417b-a909-2a7d262b49f6\",\r\n        \"createdAt\": \"2017-01-13T21:23:05.949Z\",\r\n        \"updatedAt\": \"2017-01-13T21:23:05.949Z\",\r\n        \"checklist\": [],\r\n        \"collapseChecklist\": false,\r\n        \"completed\": false,\r\n        \"id\": \"4a29874c-0308-417b-a909-2a7d262b49f6\"\r\n    },\r\n    \"notifications\": []\r\n}";

            handler.Response = exampleResponse.WrapResponseBody();

            Guid groupId = Guid.NewGuid();
            var  task    = new CreateTask()
            {
                Text = "Text", Type = "daily"
            };
            var tasks = new List <CreateTask> {
                task
            };

            _ = await client.CreateGroupTaskAsync(groupId, tasks);

            var request = handler.LastRequest;

            Assert.Equal($"/api/v3/tasks/group/{groupId}", request.RequestUri.AbsolutePath);
            Assert.Equal("", request.RequestUri.Query);
            Assert.Equal(tasks.ToJson(), handler.LastRequestStringContent);
        }
Esempio n. 2
0
 public async Task CreateTask(CreateTask createTask)
 {
     await GroupBroadcast(
         _wsHubHandler.GetTaskEditorGroupName(createTask.OwnerGuid, createTask.Tasks[0].Date),
         WSMapCode.TaskEditorCreateTask.ToString(),
         createTask);
 }
Esempio n. 3
0
        public override void Execute()
        {
            if (CreateTask == null)
            {
                CreateTask = new CreateTask();
            }

            var listOfInjected = new List <string>();

            PropertyInfo[] properties = TaskContainingSubTasks.GetType().GetProperties();
            foreach (PropertyInfo propertyX in properties)
            {
                if (propertyX.PropertyType.IsSubclassOf(typeof(Task)))
                {
                    if (propertyX.CanWrite && propertyX.GetValue(TaskContainingSubTasks, null) == null)
                    {
                        CreateTask.TaskType = propertyX.PropertyType;
                        CreateTask.Execute();
                        propertyX.SetValue(TaskContainingSubTasks, CreateTask.TaskInstance, null);

                        listOfInjected.Add(propertyX.PropertyType.FullName);
                    }
                }
            }

            InjectedSubTaskPropertyNames = listOfInjected.ToArray();
        }
        public async Task <IActionResult> CreateTask([FromRoute] Guid projectId, [FromBody] CreateTask command)
        {
            command.ProjectId = projectId;
            await commandQueryBus.SendAsync(command);

            return(Created("api/project-management/tasks/", command.CreatedId));
        }
Esempio n. 5
0
        public ActionResult Create(CreateTask NewTask)
        {
            if (ModelState.IsValid)
            {
                AppUser user = db.AppUsers.Where(u => u.EmailId == User.Identity.Name).FirstOrDefault();

                DateTime startDateTime = NewTask.StartDate.Value.AddHours(NewTask.StartHours).AddMinutes(NewTask.StartMinutes);
                int      duration      = Convert.ToInt32(NewTask.Duration);
                DateTime endDateTime   = startDateTime.AddMinutes(duration);

                Task t = new Task
                {
                    Title               = NewTask.Title,
                    Description         = NewTask.Description,
                    StartDateTime       = startDateTime,
                    Duration            = duration,
                    EndDateTime         = endDateTime,
                    Progress            = 0,
                    TaskStatusId        = 1,
                    ParentTaskId        = NewTask.ParentTaskId,
                    AssignedByAppUserId = user.AppUserId,
                    AssignedToAppUserId = NewTask.AssignedToAppUserId,
                    CreatedOn           = DateTime.Now,
                    ModifiedOn          = DateTime.Now
                };

                db.Tasks.Add(t);
                db.SaveChanges();
                return(Json(new { status = "ok", data = t, message = "Task created successfully." }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { status = "error", message = "Data validation faild." }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public void Expect_daily_task_to_be_daily()
        {
            var createTask = new CreateTask(planId, this._taskId, "Create unit tests", Reccurence.Daily);

            bus.Send(createTask);
            Assert.AreEqual(((Guid)this._taskId).ToString(), this._task.AggregateId.ToString());
        }
Esempio n. 7
0
 public Task CreateTask(CreateTask task)
 {
     entity.Task entity = mapper.Map <entity.Task>(task);
     unitOfWork.TaskRepository.Add(entity);
     unitOfWork.Commit();
     return(mapper.Map <dto.Task>(entity));
 }
Esempio n. 8
0
        public ActionResult EditTask(CreateTask createTask)
        {
            var task     = unitOfWork.Tasks.GetItemById(createTask.TaskId);
            var category = unitOfWork.Category.GetAll();

            ViewBag.CategoryId = new SelectList(category, "CategoryId", "CategoryName", createTask.CategoryId);
            unitOfWork.Dispose();
            if (ModelState.IsValid)
            {
                if (task != null)
                {
                    unitOfWork = new UnitOfWork();
                    unitOfWork.Tasks.UpdateItem(TaskModelInit(createTask));
                    unitOfWork.Save();

                    return(RedirectToAction("MyTasks", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", "Ошибка");
                }
            }

            return(View(task));
        }
Esempio n. 9
0
        //public CreateTask GetFirstPendingTask()
        //{
        //    lock (LockObject)
        //    {
        //        var taskInfo = PendingTasks.FirstOrDefault(task => !task.Executing);
        //        if (taskInfo == null) return null;
        //        //var taskInfo = PendingTasks[0];
        //        taskInfo.Executing = true;
        //        PendingTasks.Remove(taskInfo);
        //        PendingTasks.Add(taskInfo);
        //        return taskInfo;
        //    }
        //}

        private void RemovePendingTask(CreateTask task)
        {
            lock (LockObject)
            {
                PendingTasks.Remove(task);
            }
        }
Esempio n. 10
0
        public void CreateTask_Action_Fails()
        {
            // Arrange
            var taskDto = TestHelper.TaskDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.TaskService.CreateTask(taskDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new CreateTask <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(taskDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
Esempio n. 11
0
        public async Task <IActionResult> SchedueleTask([FromBody] CreateTask res)
        {
            try
            {
                if (res != null)
                {
                    string UserKey = HttpContext.User?.FindFirst("UserKey").Value;
                    if (string.IsNullOrEmpty(UserKey))
                    {
                        return(BadRequest());
                    }

                    await _Context.schedueles.AddAsync(new SchedueleTable {
                        Key       = Guid.NewGuid().ToString(),
                        date      = res.date,
                        TaskName  = res.TaskName,
                        Location  = res.Location,
                        StartTime = res.StartTime,
                        EndTime   = res.EndTime,
                        IsFree    = res.IsFree,
                        UserId    = UserKey
                    });

                    await _Context.SaveChangesAsync();

                    return(Ok());
                }
                return(BadRequest());
            }catch (Exception e)
            {
                return(StatusCode(500, new { e.Message }));
            }
        }
Esempio n. 12
0
        public static T Create()
        {
            var createTask = new CreateTask {
                TaskType = typeof(T)
            };

            createTask.Execute();
            return(createTask.TaskInstance as T);
        }
Esempio n. 13
0
        public async Task <ActionResult <ResponseTaskDetail> > PostTask([FromBody] CreateTask createTask)
        {
            if (string.IsNullOrEmpty(createTask.Title))
            {
                return(UnprocessableEntity(new List <ValidatorException> {
                    new ValidatorException
                    {
                        Field = "Title",
                        Message = "TITLE_IS_REQUIRED",
                        Description = "Поле Название обязательное для заполнения"
                    }
                }));
            }


            var email  = User.Identity.Name;
            var author = await _context.Workers.SingleOrDefaultAsync(x => x.Email == email);

            var file = await _context.Files.SingleOrDefaultAsync(x => x.Id == createTask.FileId);

            var newTask = new Models.Task
            {
                Title           = createTask.Title,
                Description     = createTask.Description,
                ExpirationDate  = DateTime.ParseExact(createTask.ExpiredDate, "dd.MM.yyyy", null),
                RewardCoins     = createTask.RewardCoins,
                RewardXp        = createTask.RewardXp,
                DifficultyId    = createTask.DifficultyId,
                PriorirtyId     = createTask.PriorityId,
                AttachedFileUrl = Constans.ApiUrl + Constans.FileDownloadPart + file.Name,
                Status          = await _context.Statuses.SingleAsync(x => x.Name == "to_do"),
                WorkerId        = createTask.WorkerId,
                AuthorId        = author.Id
            };

            _context.Tasks.Add(newTask);
            await _context.SaveChangesAsync();

            var createdTask = await _context.Tasks
                              .Include(x => x.Worker)
                              .ThenInclude(x => x.Speciality)
                              .Include(x => x.Status)
                              .Include(x => x.Priorirty)
                              .Include(x => x.Difficulty)
                              .SingleAsync(x => x.Id == newTask.Id);

            var icon = await _context.Files.SingleOrDefaultAsync(x => x.Name == "Draft.png");

            return(Ok(ResponseTaskDetail.FromApiTask(createdTask,
                                                     icon: icon,
                                                     author: author,
                                                     file: file,
                                                     avatarWorker: _getAvatar(createdTask.Worker.AvatarUrl),
                                                     avatarAuthor: _getAvatar(author.AvatarUrl)
                                                     )));
        }
Esempio n. 14
0
        public IActionResult CreateTask(CreateTask createTask)
        {
            var taskDays = this._taskHandler.CreateAndSelectTaskDay(createTask.Tasks, createTask.OwnerGuid);

            this._taskHandler.CreateTasks(createTask.Tasks, taskDays);

            var tasksGuids = createTask.Tasks.Select(x => x.Guid).ToList();

            return(Ok(tasksGuids));
        }
Esempio n. 15
0
        public object Create([FromBody] CreateTask command)
        {
            var result = service.When(command.ToInternal());

            return(new
            {
                id = result.Id,
                defaultName = result.DefaultName
            });
        }
Esempio n. 16
0
File: Proxy.cs Progetto: Jaans/csla
 public DataPortalResult Create(Type objectType, object criteria, DataPortalContext context)
 {
   Thread t = new Thread(DoCreate);
   CreateTask task = new CreateTask();
   task.ObjectType = objectType;
   task.Criteria = criteria;
   task.Context = context;
   t.Start(task);
   t.Join();
   return task.Result;
 }
Esempio n. 17
0
        private void btnAddTask_Click(object sender, EventArgs e)
        {
            TaskForm form = new TaskForm();

            if (DialogResult.OK == form.ShowDialog(this))
            {
                CreateTask createTask = new CreateTask(form.textCode.Text, form.textName.Text);
                var        project    = managementService.CreateTask(createTask);
                UpdateGridTasks();
            }
        }
Esempio n. 18
0
            public void TitleEmpty()
            {
                Task NewTask = new Task {
                    Title       = "",
                    UserName    = "",
                    InitialDate = System.DateTime.Now,
                    EndDate     = System.DateTime.Now,
                    Message     = ""
                };

                Assert.That(() => CreateTask.Save(NewTask), Throws.ArgumentException.With.Message.Contains("Title cannot be empty"));
            }
Esempio n. 19
0
        private void Taskbt_Click(object sender, RoutedEventArgs e)
        {
            string     nome = tasktb.Text;
            DateTime   time = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
            CreateTask task = new CreateTask();

            task.CriaTask(nome, time);
            this.Hide();
            TaskWindow taskwindow = new TaskWindow();

            taskwindow.ShowDialog();
        }
 private async void Edit_TestTask(object sender, RoutedEventArgs e)
 {
     if (DataModel.IsRunning)
     {
         _ = MessageBox.Show("任务开始后无法修改。", "WARNING");
     }
     else
     {
         CreateTask dialog = new CreateTask(DataModel, TestTaskTree.SelectedItem as TestTask);
         _ = await DialogHost.Show(dialog);
     }
 }
Esempio n. 21
0
        public DataPortalResult Create(Type objectType, object criteria, DataPortalContext context)
        {
            Thread     t    = new Thread(DoCreate);
            CreateTask task = new CreateTask();

            task.ObjectType = objectType;
            task.Criteria   = criteria;
            task.Context    = context;
            t.Start(task);
            t.Join();
            return(task.Result);
        }
Esempio n. 22
0
        private void AddFailureLog(CreateTask task, Exception ex)
        {
            var taskLog = new CreateTaskLog(0, task.CreateType, task.SiteId, task.ChannelId, task.ContentId, task.FileTemplateId, task.SpecialId, task.Name, string.Empty, false, ex.Message, DateTime.Now);

            lock (LockObject)
            {
                if (TaskLogs.Count > 20)
                {
                    TaskLogs.RemoveAt(20);
                }
                TaskLogs.Insert(0, taskLog);
            }
        }
Esempio n. 23
0
        private void AddSuccessLog(CreateTask task, string timeSpan)
        {
            var taskLog = new CreateTaskLog(0, task.CreateType, task.SiteId, task.ChannelId, task.ContentId, task.FileTemplateId, task.SpecialId, task.Name, timeSpan, true, string.Empty, DateTime.Now);

            lock (LockObject)
            {
                if (TaskLogs.Count > 20)
                {
                    TaskLogs.RemoveAt(20);
                }
                TaskLogs.Insert(0, taskLog);
            }
        }
Esempio n. 24
0
        private CreateTask CreateTaskModelInit(Tasks task)
        {
            CreateTask tasks = new CreateTask
            {
                TaskName    = task.TaskName,
                CategoryId  = task.CategoryId,
                Description = task.Description,
                Price       = task.Price,
                TaskId      = task.TaskId
            };

            return(tasks);
        }
Esempio n. 25
0
        public int CreateTask(CreateTask task)
        {
            using (var conn = _dbConnectionProvider.GetOpenWsidnConnection())
            {
                var sql = @"
                    insert into TasksToDo
                    ([Description], IntervalByHour, UserID)
                    values (@Description, @IntervalByHour, @UserId)
                    select SCOPE_IDENTITY()";

                var id = conn.ExecuteScalar <int>(sql, task);
                return(id);
            }
        }
Esempio n. 26
0
        public async Task <IActionResult> Create([FromBody] CreateTask dto)
        {
            if (dto == null)
            {
                return(BadRequest());
            }

            try
            {
                dto.UserId = IdentityHelper.GetUserId(User);
            }
            catch (UnauthorizedAccessException)
            {
                return(Unauthorized());
            }

            CreatedTask createdTask = await _taskService.CreateAsync(dto, _createValidator);

            // Notify
            var usersToBeNotified = await _userService.GetToBeNotifiedOfListChangeAsync(dto.ListId, dto.UserId, dto.IsPrivate.HasValue&& dto.IsPrivate.Value);

            if (usersToBeNotified.Any())
            {
                var currentUser = await _userService.GetAsync(dto.UserId);

                SimpleList list = await _listService.GetAsync(dto.ListId);

                foreach (var user in usersToBeNotified)
                {
                    CultureInfo.CurrentCulture = new CultureInfo(user.Language, false);
                    var message = _localizer["CreatedTaskNotification", IdentityHelper.GetUserName(User), createdTask.Name, list.Name];

                    var createNotificationDto = new CreateOrUpdateNotification(user.Id, dto.UserId, list.Id, createdTask.Id, message);
                    var notificationId        = await _notificationService.CreateOrUpdateAsync(createNotificationDto);

                    var pushNotification = new PushNotification
                    {
                        SenderImageUri = currentUser.ImageUri,
                        UserId         = user.Id,
                        Application    = "To Do Assistant",
                        Message        = message,
                        OpenUrl        = GetNotificationsPageUrl(notificationId)
                    };

                    _senderService.Enqueue(pushNotification);
                }
            }

            return(StatusCode(201, createdTask.Id));
        }
Esempio n. 27
0
        public void should_provide_proxy_instance_if_given_type_is_decorated_with_execution_callbacks_attribute()
        {
            // Arrange
            var task = new CreateTask {
                TaskType = typeof(MockTaskWithAttributes)
            };

            // Act
            task.Execute();

            // Assert
            Assert.That(task.TaskInstance, Is.InstanceOf <MockTaskWithAttributes>());
            Assert.That(task.TaskInstance.GetType().Name, Is.EqualTo("MockTaskWithAttributesProxy"));
        }
Esempio n. 28
0
        public JsonResult ProjectsCreateTask(CreateTask Task)
        {
            string          ErrorMessage          = "";
            ObjectParameter ErrorMessageParameter = new ObjectParameter("ErrorMessage", ErrorMessage);

            int             ID          = 0;
            ObjectParameter IDParameter = new ObjectParameter("OutID", ID);

            if (ModelState.IsValid)
            {
                //DB.CreateTask(Task.SubContractorID, Task.TaskTypeID, Task.ProjectID, Task.Description, Task.ActualDurationAsTicks, IDParameter, ErrorMessageParameter);
                return(Json("Success", JsonRequestBehavior.AllowGet));
            }
            return(Json("Failed", JsonRequestBehavior.AllowGet));
        }
Esempio n. 29
0
        public async Task Create_Returns_SuccessResponse()
        {
            // Arrange
            var createTask = new CreateTask {
                Name = "New Task", Priority = 1, StartDate = new DateTime()
            };

            mockTaskService.Setup(service => service.Create(It.IsAny <Model.Task>())).Returns(Task.FromResult <int>(1));

            // Act
            var result = await controller.Create(new CreateTask());

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }
Esempio n. 30
0
        private Tasks TaskModelInit(CreateTask task)
        {
            Tasks tasks = new Tasks
            {
                TaskName    = task.TaskName,
                CategoryId  = task.CategoryId,
                Description = task.Description,
                Price       = task.Price,
                PublishDate = DateTime.Now,
                UserId      = int.Parse(User.Identity.Name),
                TaskId      = task.TaskId,
                Status      = "Размещен"
            };

            return(tasks);
        }
Esempio n. 31
0
        public IActionResult Post([FromBody] CreateTask entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.Title.ToUpper().Contains("SEX"))
                {
                    return(BadRequest(new { ErrorMessage = "Le titre contient des mots explicitement interdits par la bienséance" }));
                }

                return(Ok(_repository.Insert(new Task()
                {
                    Title = entity.Title
                })));
            }
            return(BadRequest());
        }
Esempio n. 32
0
	    public TaskPack(CreateTask createTask){
	        this.init = delegate
	        {
	            isOver_ = false;
	            task_ = createTask();
				if(task_ == null){
					isOver_ = true;
				}else{
		            TaskManager.PushBack(task_, delegate {
		                isOver_ = true;
		            });
		            TaskManager.Run(task_);
				}
	        };
	        this.isOver = delegate {
	            return isOver_;
	        };
	       
	    }
Esempio n. 33
0
 public ActionResult Create(CreateTask createTask)
 {
     commandSender.Send(createTask);
     return RedirectToAction("Details", new {id = createTask.Id});
 }
Esempio n. 34
0
 public async Task<DataPortalResult> Create(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
   var task = new CreateTask{
         ObjectType = objectType, 
         Criteria = criteria, 
         Context = context
       };
   if (isSync)
     DoCreate(task);
   else
     await Task.Factory.StartNew(DoCreate, task);
   if (task.ResultException != null)
     throw task.ResultException;
   return task.Result;
 }