private static void CreateNewTask() { Guid ProjectGuid = new Guid("b7dfde50 - 7a2d - e611 - 9bf8 - 681729bb2204"); var Project = projectContext.Projects.GetByGuid(ProjectGuid); var draftProject = Project.CheckOut(); TaskCreationInformation task = new TaskCreationInformation(); task.Id = Guid.NewGuid(); task.Name = "New Task"; task.Start = DateTime.Today.Date; task.IsManual = false; DraftTask draftTask = draftProject.Tasks.Add(task); draftProject.Update(); draftProject.Publish(true); //Publish and check-in the Project projectContext.ExecuteQuery(); }
private List <TaskCreationInformation> CreateTasks() { List <TaskCreationInformation> draftTasks = new List <TaskCreationInformation>(); for (int taskCount = 1; taskCount <= numTasks.Value; taskCount++) { TaskCreationInformation taskCreationInformation = new TaskCreationInformation { Name = txtTaskName.Text + 1, IsManual = false, Duration = $"{RandomEx.Random.Next(1, 16)}d" }; draftTasks.Add(taskCreationInformation); } return(draftTasks); }
public void UpdateTasksInProject() { ProjectContext projContext = new ProjectContext("http://tpserver/pwa/"); var projCollection = projContext.LoadQuery(projContext.Projects.Where(p => p.Name == "Test")); projContext.ExecuteQuery(); foreach (PublishedProject pubProj in projCollection) { DraftProject projCheckedOut = pubProj.CheckOut(); TaskCreationInformation newTask = new TaskCreationInformation(); newTask.Name = "Тестовая задача Андрея"; newTask.IsManual = false; newTask.Duration = "3d"; newTask.Start = DateTime.Today; projCheckedOut.Tasks.Add(newTask); projCheckedOut.StartDate = DateTime.Now.AddYears(1); projCheckedOut.Publish(true); QueueJob qJob = projContext.Projects.Update(); JobState jobState = projContext.WaitForQueue(qJob, 10); } }
private IEnumerable <IEnumerable <TaskCreationInformation> > CreateTask(TaskModel model) { // Save different level task: lstTask[0,...], the index = level List <List <TaskCreationInformation> > lstTask = new List <List <TaskCreationInformation> >(); for (int i = 0; i < model.Count; i++) { int levelDepth = RandomHelper.Random(0, lstTask.Count); Guid parentId = levelDepth == 0 ? default(Guid) : lstTask[levelDepth - 1][RandomHelper.Random(0, lstTask[levelDepth - 1].Count - 1)].Id; TaskCreationInformation task = NewTask(model, i, parentId); if (levelDepth == lstTask.Count) { lstTask.Add(new List <TaskCreationInformation> { task }); } else { lstTask[levelDepth].Add(task); } } return(lstTask); }
private List<TaskCreationInformation> CreateTasks() { List<TaskCreationInformation> draftTasks = new List<TaskCreationInformation>(); for (int taskCount = 1; taskCount <= numTasks.Value; taskCount++) { TaskCreationInformation taskCreationInformation = new TaskCreationInformation { Name = txtTaskName.Text + 1, IsManual = false, Duration = $"{RandomEx.Random.Next(1, 16)}d" }; draftTasks.Add(taskCreationInformation); } return draftTasks; }