Ejemplo n.º 1
0
        // Add new Task
        public void AddParentTask(ParentTask newTask)
        {
            ProjectManagerContext dbCtxt = new ProjectManagerContext();

            dbCtxt.ParentTasks.Add(newTask);
            dbCtxt.SaveChanges();
        }
Ejemplo n.º 2
0
        public ParentTask PostParentTask(ParentTask parentTask)
        {
            db.ParentTasks.Add(parentTask);
            db.SaveChanges();

            return(parentTask);
        }
        public IHttpActionResult Put(int ParentTaskId, ParentTask ParentTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (ParentTaskId != ParentTask.ParentId)
            {
                return(BadRequest());
            }
            try
            {
                ParentTaskDetailsGetter.UpdateParentTask(ParentTask);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ParentTaskDetailsGetter.IsParentTaskExist(ParentTaskId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 4
0
        internal protected Variable GetSharedVariable(string key, out Task task)
        {
            Variable variable;

            if (sharedVariables != null)
            {
                variable = sharedVariables.Get(key);
            }
            else
            {
                variable = null;
            }

            if (variable != null)  // Found in current task
            {
                task = this;
            }
            else if (ParentTask != null)   // Try find in ancestor nodes
            {
                variable = ParentTask.GetSharedVariable(key, out task);
            }
            else
            {
                task = null;
            }

            return(variable);
        }
Ejemplo n.º 5
0
        public void PostParentTaskTest()
        {
            //var mockRepository = new Mock<ITasksRepository>();
            //mockRepository.Setup(x => x.GetTask(1))
            //    .Returns(new Task { Task_ID = 1 });

            int count = _randomParentTask.Count;

            var controller = new ParentTaskController(ParentTaskRepository);

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            ParentTask task = new ParentTask()
            {
                Parent_ID = 2
            };
            // Act
            var response = controller.Post(task);

            Assert.IsNotNull(response.Content);
            Assert.IsNotNull(response.Content.Headers.ContentType);
            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK);



            var responseString = response.Content.ReadAsStringAsync().Result;

            // Assert
            //dynamic jsonObject = JObject.Parse(responseString);
            //int status = (int)jsonObject.Task_ID;
            Assert.AreEqual(count + 1, _randomParentTask.Count);
            //Assert.IsTrue(response.TryGetContentValue<Task>(out task));
            //Assert.AreEqual(10, task.Task_ID);
        }
Ejemplo n.º 6
0
        public void PutParentTaskTest()
        {
            var controller = new ParentTaskController(ParentTaskRepository);

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();
            ParentTask task = new ParentTask()
            {
                Parent_ID = 1, Parent_Task = "Test1"
            };
            // Act
            var response = controller.Put(1, task);

            Assert.IsNotNull(response.Content);
            Assert.IsNotNull(response.Content.Headers.ContentType);
            Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK);
            Assert.AreEqual(_randomParentTask.Find(a => a.Parent_ID == 1).Parent_Task, "Test1");


            var responseString = response.Content.ReadAsStringAsync().Result;
            // Assert
            //dynamic jsonObject = JObject.Parse(responseString);
            //int status = (int)jsonObject.Task_ID;
            //Assert.AreEqual(0, responseString);
        }
        public ParentTask InsertParentTask(ParentTask parentTask)
        {
            var entity = _mapper.Map <DataAccess.Entity.ParentTask>(parentTask);
            var result = _parentTaskRepository.Create(entity);

            return(_mapper.Map <ParentTask>(result));
        }
Ejemplo n.º 8
0
 public IHttpActionResult CreateTask(Task task)
 {
     if (task != null)
     {
         if (task.IsParentTask)
         {
             var parentTask = new ParentTask();
             parentTask.ParentTaskName = task.TaskName;
             db.ParentTasks.Add(parentTask);
             db.SaveChanges();
         }
         else
         {
             var taskAdded = db.Tasks.Add(task);
             db.SaveChanges();
             if (task.UserID.HasValue)
             {
                 var user = db.Users.FirstOrDefault(x => x.UserID == task.UserID);
                 user.TaskID    = taskAdded.TaskID;
                 user.ProjectID = taskAdded.ProjectID;
             }
             db.SaveChanges();
         }
     }
     return(Ok());
 }
Ejemplo n.º 9
0
        public void AddParentTask_Failure_Test()
        {
            ParentTaskViewModel ptaskVModel = new ParentTaskViewModel();

            ptaskVModel.TaskName = "PTest2";
            ParentTask ptaskAdd = new ParentTask()
            {
                TaskName = ptaskVModel.TaskName
            };


            ParentTask ptaskList1 = new ParentTask();

            ptaskList1.TaskName = "PTest2";
            ParentTask ptaskList2 = new ParentTask();

            ptaskList2.TaskName = "PTest3";
            List <ParentTask> ptaskList = new List <ParentTask>();

            ptaskList.Add(ptaskList1);
            ptaskList.Add(ptaskList2);
            IQueryable <ParentTask> pTasks = ptaskList.AsQueryable();
            var mockRepo = new Mock <IParentTaskRepository>();

            mockRepo.Setup(p => p.GetParentTasks()).Returns(pTasks);
            var handler = new ParentTaskhandler(mockRepo.Object);

            Assert.That(() => handler.AddParentTask(ptaskVModel),
                        Throws.TypeOf <CustomException>());
        }
Ejemplo n.º 10
0
        public ParentTask DeleteParentTask(ParentTask parentTask)
        {
            db.ParentTasks.Remove(parentTask);
            db.SaveChanges();

            return(parentTask);
        }
        public object AddParentTask(ParentTask request)
        {
            var apiResponse = new APIParentTaskResponseModel();

            try
            {
                var response = Service.AddParentTask(request);
                if (response)
                {
                    apiResponse.Message = "Parent Task added Sucessfully";
                    apiResponse.Success = true;
                }
                else
                {
                    apiResponse.Message = "Errror while adding Parent Task";
                    apiResponse.Success = false;
                }

                return(apiResponse);
            }
            catch (Exception Ex)
            {
                apiResponse.Message = "Errror while adding Parent Task";
                apiResponse.Success = false;
                return(apiResponse);
            }
        }
Ejemplo n.º 12
0
        // Token: 0x060001F7 RID: 503 RVA: 0x00012608 File Offset: 0x00010808
        public static Dictionary <string, object> SerializeTask(Task task, bool serializeChildren, ref List <Object> unityObjects)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.Add("Type", task.GetType());
            dictionary.Add("NodeData", JSONSerialization.SerializeNodeData(task.NodeData));
            dictionary.Add("ID", task.ID);
            dictionary.Add("Name", task.FriendlyName);
            dictionary.Add("Instant", task.IsInstant);
            if (task.Disabled)
            {
                dictionary.Add("Disabled", task.Disabled);
            }
            JSONSerialization.SerializeFields(task, ref dictionary, ref unityObjects);
            if (serializeChildren && task is ParentTask)
            {
                ParentTask parentTask = task as ParentTask;
                if (parentTask.Children != null && parentTask.Children.Count > 0)
                {
                    Dictionary <string, object>[] array = new Dictionary <string, object> [parentTask.Children.Count];
                    for (int i = 0; i < parentTask.Children.Count; i++)
                    {
                        array[i] = JSONSerialization.SerializeTask(parentTask.Children[i], serializeChildren, ref unityObjects);
                    }
                    dictionary.Add("Children", array);
                }
            }
            return(dictionary);
        }
Ejemplo n.º 13
0
    private static void ExportNode(StreamWriter fileWriter, string parentName, Task task, int indentDepth, ref int nodeIdx)
    {
        string nodeName = string.Format("node{0}", ++nodeIdx);
        string indent   = string.Empty;

        for (int i = 0; i < indentDepth; ++i)
        {
            indent += "\t";
        }

        fileWriter.Write(string.Format("{0}local {1} = {2}.New()", indent, nodeName, task.FriendlyName) + line_end);
        fileWriter.Write(string.Format("{0}{1}:AddChild({2})", indent, parentName, nodeName) + line_end);


        if (task is ParentTask)
        {
            ParentTask parentTask = task as ParentTask;
            if (parentTask.Children != null && parentTask.Children.Count > 0)
            {
                fileWriter.Write(string.Format("{0}do", indent) + line_end);

                int childIndentDepth = indentDepth + 1;
                for (int i = 0; i < parentTask.Children.Count; i++)
                {
                    ExportToLua.ExportNode(fileWriter, nodeName, parentTask.Children[i], childIndentDepth, ref nodeIdx);
                }

                fileWriter.Write(string.Format("{0}end", indent) + line_end);
            }
        }
    }
Ejemplo n.º 14
0
        private void ResetValue(Task task)
        {
            Dictionary <string, object> dictionary;

            if (task == null || !this.defaultValues.TryGetValue(task, out dictionary))
            {
                return;
            }
            using (Dictionary <string, object> .Enumerator enumerator = dictionary.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <string, object> current = enumerator.Current;
                    task.GetType().GetField(current.Key)?.SetValue((object)task, current.Value);
                }
            }
            if (!(task is ParentTask))
            {
                return;
            }
            ParentTask parentTask = task as ParentTask;

            if (parentTask.Children == null)
            {
                return;
            }
            for (int index = 0; index < parentTask.Children.Count; ++index)
            {
                this.ResetValue(parentTask.Children[index]);
            }
        }
Ejemplo n.º 15
0
        private void ResetValue(Task task, ref int index)
        {
            if (task == null)
            {
                return;
            }
            Dictionary <string, object> dictionary = this.defaultValues[index];

            index++;
            foreach (KeyValuePair <string, object> current in dictionary)
            {
                FieldInfo field = task.GetType().GetField(current.Key);
                if (field != null)
                {
                    field.SetValue(task, current.Value);
                }
            }
            if (task is ParentTask)
            {
                ParentTask parentTask = task as ParentTask;
                if (parentTask.Children != null)
                {
                    for (int i = 0; i < parentTask.Children.Count; i++)
                    {
                        this.ResetValue(parentTask.Children[i], ref index);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private bool TaskContainsMethod(string methodName, Task task)
        {
            if (task == null)
            {
                return(false);
            }
            MethodInfo method = task.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (method != null && task.GetType().Equals(method.DeclaringType))
            {
                return(true);
            }
            if (task is ParentTask)
            {
                ParentTask parentTask = task as ParentTask;
                if (parentTask.Children != null)
                {
                    for (int i = 0; i < parentTask.Children.Count; i++)
                    {
                        if (this.TaskContainsMethod(methodName, parentTask.Children[i]))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 17
0
        //Performance Method used for Adding new Tasks
        public void AddTaskTest()
        {
            List <ParentTask> result1 = ObjBl.GetAllParentTasks();
            ParentTask        obj1    = result1.Find(x => x.Parent_Task == "Task New Parent");
            int parentTaskIdDummy     = obj1.ParentId;


            List <User> result2     = ObjBl.GetAllUsers();
            User        obj2        = result2.Find(x => x.FirstName == "Nivi");
            int         userIdDummy = obj2.UserId;

            List <Project> result3        = ObjBl.GetAllProjects();
            Project        obj3           = result3.Find(x => x.ProjectName == "Project New");
            int            projectIdDummy = obj3.ProjectId;

            Task obj = new Task();

            obj.TaskId        = 0;
            obj.TaskName      = "Task New";
            obj.Project_ID    = projectIdDummy;
            obj.TaskStartDate = DateTime.Now;
            obj.TaskEndDate   = DateTime.Now;
            obj.Priority      = 3;
            obj.User_ID       = userIdDummy;
            ObjBl.AddTask(obj);
        }
Ejemplo n.º 18
0
        public IHttpActionResult PutParentTask(int id, ParentTask parentTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != parentTask.Parent_ID)
            {
                return(BadRequest());
            }

            db.Entry(parentTask).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ParentTaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 19
0
        public IHttpActionResult PostParentTask(ParentTask parentTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ParentTasks.Add(parentTask);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (ParentTaskExists(parentTask.Parent_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = parentTask.Parent_ID }, parentTask));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Add New Task
        /// </summary>
        /// <param name="Task"></param>
        public void AddTask(Task Task)
        {
            ParentTask pTask = new ParentTask();

            if (Task.Status == "Parent")
            {
                pTask.Parent_Task = Task.Task1;
                db.ParentTasks.Add(pTask);
                db.SaveChanges();
            }

            var pt = db.ParentTasks.ToList();


            foreach (ParentTask t in pt)
            {
                if (t.Parent_Task == Task.Task1)
                {
                    Task.Parent__ID = t.Parent_ID;
                }
            }

            db.Tasks.Add(Task);
            db.SaveChanges();
        }
Ejemplo n.º 21
0
                public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
                {
                    if (container == null)
                    {
                        // Currently in a layout without a container, so no reason to create our view.
                        return(null);
                    }

                    View view = inflater.Inflate(Resource.Layout.Prayer_Post, container, false);

                    view.SetOnTouchListener(this);

                    view.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));

                    ResultView = new UIResultView(view, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetCurrentContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels),
                                                  delegate
                    {
                        if (Success == true)
                        {
                            // leave
                            ParentTask.OnClick(this, 0);
                        }
                        else
                        {
                            // retry
                            SubmitPrayerRequest( );
                        }
                    });

                    BlockerView = new UIBlockerView(view, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetCurrentContainerDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels));


                    return(view);
                }
        public void UpdateTaskInDB()
        {
            TaskData    taskData    = new TaskData();
            UserData    userData    = new UserData();
            ProjectData projectdata = new ProjectData();

            userData.CreateUser(new User {
                FirstName = "SampleFName", LastName = "SampleLName", Employee_ID = 1
            });
            user = userData._dbContext.Users.Where(a => a.Employee_ID == 1).FirstOrDefault();

            projectdata.CreateProject(new Project {
                Project1 = "SampleProject", Priority = 1
            });
            project = projectdata._dbContext.Projects.Where(a => a.Project1 == "SampleProject").FirstOrDefault();

            taskData.CreateParentTask(new ParentTask {
                Parent_Task = "SampleParentTask"
            });
            parentTask = taskData._dbContext.ParentTasks.Where(a => a.Parent_Task == "SampleParentTask").FirstOrDefault();

            taskData.CreateTask(new Task()
            {
                Task1 = "SampleTask", Priority = 1, StartDate = DateTime.Now.Date, EndDate = DateTime.Now.Date.AddDays(1), Parent_ID = parentTask.Parent_ID, Project_ID = project.Project_ID
            });
            task = taskData._dbContext.Tasks.Where(a => a.Task1 == "SampleTask").FirstOrDefault();

            var result = taskData.UpdateTask(task, task.Task_ID);

            Assert.AreEqual(true, result);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// AddTask
        /// </summary>
        /// <param name="taskModel"></param>
        /// <returns></returns>
        public bool AddTask(TaskModel taskModel)
        {
            TaskManagerEntities entity = new TaskManagerEntities();
            Task addTask = new Task();

            addTask.Task1 = taskModel.Task;
            if (taskModel.StartDateString != null)
            {
                addTask.Start_Date = Convert.ToDateTime(taskModel.StartDateString);
            }
            if (taskModel.EndDateString != null)
            {
                addTask.End_Date = Convert.ToDateTime(taskModel.EndDateString);
            }
            addTask.Priority  = taskModel.Priority;
            addTask.Parent_Id = taskModel.ParentId;
            if (!string.IsNullOrEmpty(taskModel.ParentTask))
            {
                ParentTask pTask = new ParentTask();
                pTask.Parent_Task  = taskModel.ParentTask;
                addTask.ParentTask = pTask;
            }
            entity.Tasks.Add(addTask);
            entity.SaveChanges();
            return(true);
        }
Ejemplo n.º 24
0
        public void AddParenTask_Test()
        {
            ParentTaskViewModel ptaskVModel = new ParentTaskViewModel();

            ptaskVModel.TaskName = "PTest1";
            ParentTask ptaskAdd = new ParentTask()
            {
                TaskName = ptaskVModel.TaskName
            };


            ParentTask ptaskList1 = new ParentTask();

            ptaskList1.TaskName = "PTest2";
            ParentTask ptaskList2 = new ParentTask();

            ptaskList2.TaskName = "PTest3";
            List <ParentTask> ptaskList = new List <ParentTask>();

            ptaskList.Add(ptaskList1);
            ptaskList.Add(ptaskList2);
            IQueryable <ParentTask> pTasks = ptaskList.AsQueryable();
            var mockRepo = new Mock <IParentTaskRepository>();

            mockRepo.Setup(p => p.AddParentTask(ptaskAdd));
            mockRepo.Setup(p => p.GetParentTasks()).Returns(pTasks);
            var handler = new ParentTaskhandler(mockRepo.Object);

            handler.AddParentTask(ptaskVModel);
            mockRepo.Verify(mock => mock.GetParentTasks(), Times.Once());
        }
Ejemplo n.º 25
0
        //Performance Method used for Adding new Tasks
        public void AddParentTaskTest()
        {
            ParentTask obj = new ParentTask();

            obj.Parent_Task = "Task New Parent";
            ObjBl.AddParentTask(obj);
        }
Ejemplo n.º 26
0
        private bool TaskContainsMethod(string methodName, Task task)
        {
            if (task == null)
            {
                return(false);
            }
            MethodInfo method = task.GetType().GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (method != null && method.DeclaringType.IsAssignableFrom(task.GetType()))
            {
                return(true);
            }
            if (task is ParentTask)
            {
                ParentTask parentTask = task as ParentTask;
                if (parentTask.Children != null)
                {
                    for (int index = 0; index < parentTask.Children.Count; ++index)
                    {
                        if (this.TaskContainsMethod(methodName, parentTask.Children[index]))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 27
0
        public void AddTask()
        {
            List<ParentTask> result1 = ObjBl.GetAllParentTasks();
            ParentTask obj1 = result1.Find(x => x.Parent_Task == "Task New Parent");
            parentTaskIdDummy = obj1.ParentId;

            List<User> result2 = ObjBl.GetAllUsers();
            User obj2 = result2.Find(x => x.FirstName == "Nivy Updated");
            userIdDummy = obj2.UserId;

            List<Project> result3 = ObjBl.GetAllProjects();
            Project obj3 = result3.Find(x => x.ProjectName == "Project updated");
            projectIdDummy = obj3.ProjectId;

            Task obj = new Task();
            obj.TaskId = 0;
            obj.TaskName= "Task New";
            obj.ParentId = parentTaskIdDummy;
            obj.IsParent = false;
            obj.Project_ID = projectIdDummy;
            obj.TaskStartDate = DateTime.Now;
            obj.TaskEndDate = DateTime.Now;
            obj.Priority = 3;
            obj.User_ID = userIdDummy;

            try
            {
                ObjBl.AddTask(obj);
                Assert.IsTrue(1 == 1);
            }
            catch
            {
                Assert.Inconclusive("Task not added");
            }
        }
        public IHttpActionResult PutParentTask(int id, ParentTask parentTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != parentTask.ParentId)
            {
                return(BadRequest());
            }

            try
            {
                parentTaskBusiness.PutParentTask(parentTask);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!parentTaskBusiness.ParentTaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 29
0
 // Token: 0x0600017A RID: 378 RVA: 0x0000CFAC File Offset: 0x0000B1AC
 private static void CheckTaskForErrors(Task task, bool projectLevelBehavior, ref List <ErrorDetails> errorDetails)
 {
     if (task.Disabled)
     {
         return;
     }
     if (task is UnknownTask || task is UnknownParentTask)
     {
         ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.UnknownTask, task, -1, null);
     }
     if (task.GetType().GetCustomAttributes(typeof(SkipErrorCheckAttribute), false).Length == 0)
     {
         FieldInfo[] allFields = TaskUtility.GetAllFields(task.GetType());
         for (int i = 0; i < allFields.Length; i++)
         {
             ErrorCheck.CheckField(task, projectLevelBehavior, ref errorDetails, allFields[i], i, allFields[i].GetValue(task));
         }
     }
     if (task is ParentTask && task.NodeData.NodeDesigner != null && !(task.NodeData.NodeDesigner as NodeDesigner).IsEntryDisplay)
     {
         ParentTask parentTask = task as ParentTask;
         if (parentTask.Children == null || parentTask.Children.Count == 0)
         {
             ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.MissingChildren, task, -1, null);
         }
         else
         {
             for (int j = 0; j < parentTask.Children.Count; j++)
             {
                 ErrorCheck.CheckTaskForErrors(parentTask.Children[j], projectLevelBehavior, ref errorDetails);
             }
         }
     }
 }
Ejemplo n.º 30
0
        public IHttpActionResult AddParentTask(ParentTask parenttask)
        {
            businessObj.AddParentTask(parenttask);
            var list = businessObj.GetAllParentTask();

            return(Ok(list));
        }
Ejemplo n.º 31
0
        public void SetUp()
        {
            parallelTask = new ParallelParentTask(0, "TASK", "Test");
            sequentialTask = new SequentialParentTask(0, "TASK", "Test");
            emptyTask = new SequentialParentTask(0, "TASK", "Test");

            leaf1 = new LeafTask(1, "LEAF1", "Awesome Task", HOURS);
            leaf2 = new LeafTask(2, "LEAF2", "More Awesome Task", HOURS);

            e = new Engineer() { ID = 0, HoursAvailable = HOURS / 2, Name = "Test" };
            e2 = new Engineer() { ID = 1, HoursAvailable = HOURS / 2, Name = "Test" };

            leaf1.AddEngineer(e);
            leaf2.AddEngineer(e2);

            parallelTask.AddTask(leaf1);
            parallelTask.AddTask(leaf2);

            sequentialTask.AddTask(leaf1);
            sequentialTask.AddTask(leaf1);
        }