예제 #1
0
        private Models.Task[] GetTasks( string urlPath, TasksQuery query )
        {
            if( query != null )
            {
                urlPath = query.PopulateRequestQueryString( urlPath );
            }

            Models.Task[] nameAndIdOnly = ObjectConversions.ToTasks( ExecuteRequest( urlPath ) );
            if( nameAndIdOnly == null )
            {
                return null;
            }

            if( query == null || query.ReturnCompleteTaskRecords == false )
            {
                return nameAndIdOnly;
            }

            Models.Task[] ret = new Models.Task[ nameAndIdOnly.Length ];
            Parallel.For( 0, nameAndIdOnly.Length, i =>
            {
                ret[ i ] = GetTask( nameAndIdOnly[ i ].Id );
            } );
            return ret;
        }
예제 #2
0
        public async Task<ActionResult> Post([FromBody]CreateTaskRequest request)
        {
            if (!ModelState.IsValid)
            {
                return HttpBadRequest();
            }

            else
            {
                var itemExists = await _context.Tasks.AnyAsync(i => i.Title == request.TaskTitle && i.TaskListId == request.TaskListId && i.IsDeleted != true);
                if (itemExists)
                {
                    return HttpBadRequest();
                }
                Models.Task item = new Models.Task();
                item.TaskListId = request.TaskListId;
                item.TaskId = Guid.NewGuid().ToString().Replace("-", ""); ;
                item.CreatedOnUtc = DateTime.UtcNow;
                item.UpdatedOnUtc = DateTime.UtcNow;
                item.Title = request.TaskTitle;
                _context.Tasks.Add(item);
                await _context.SaveChangesAsync();

                var tasks = await _context.Tasks.Where(i => i.TaskListId == request.TaskListId && i.IsDeleted != true).Select(p=>new { Title = p.Title }).ToListAsync();
                var getTaskList = await _context.TaskLists.Where(i => i.TaskListId == request.TaskListId).SingleOrDefaultAsync();
                var user = await _context.Users.Where(u => u.UserId == getTaskList.UserId).SingleOrDefaultAsync();
                return Json(new {User=user.EmailAddress,Tasks = tasks,TaskList=getTaskList.Title });
            }
        }
예제 #3
0
        /*
         * DELETE a task for user
         */
        public void Delete(int id)
        {
            HasRequiredScopes(WritePermission);

            string owner = ClaimsPrincipal.Current.FindFirst(objectIdElement).Value;

            Models.Task task = db.Where(t => t.Owner.Equals(owner) && t.Id.Equals(id)).FirstOrDefault();
            db.Remove(task);
        }
예제 #4
0
        public TaskMainWindow(Models.Task t, User u)
        {
            InitializeComponent();

            current = t;

            lblTitle.Content    = current.Title;
            tbkDescription.Text = current.Description;
        }
예제 #5
0
        /*
         * DELETE a task for user
         */
        public void Delete(int id)
        {
            HasRequiredScopes(WritePermission);

            var owner = CheckClaimMatch(ClaimTypes.NameIdentifier);

            Models.Task task = db.Where(t => t.Owner.Equals(owner) && t.Id.Equals(id)).FirstOrDefault();
            db.Remove(task);
        }
예제 #6
0
        public Models.Task Add(Models.Task task)
        {
            task.DateCreated = DateTime.Now;
            task.Id          = 0;

            _context.Tasks.Add(task);
            _context.SaveChanges();
            return(task);
        }
예제 #7
0
        public void TestDeleteTask_NegativeProjectId()
        {
            var context = new MockProjectManagerEntities();

            ProjectManager.Models.Task task = new Models.Task();
            task.Project_ID = -234;
            var controller = new TaskController(new BC.TaskBC(context));
            var result     = controller.DeleteTaskDetails(task) as JSendResponse;
        }
예제 #8
0
 public ActionResult Result(Int32 Id)
 {
     Models.Task t = entity.Tasks.Find(Id);
     if (System.Web.Security.FormsAuthentication.Decrypt(Request.Cookies.Get(System.Web.Security.FormsAuthentication.FormsCookieName).Value).UserData != "Admin" && t.Owner.Id.ToString() != System.Web.Security.FormsAuthentication.Decrypt(Request.Cookies.Get(System.Web.Security.FormsAuthentication.FormsCookieName).Value).Name)
     {
         return(Content("<script>location.href='/401'</script>"));
     }
     return(View("Taskdetail", t));
 }
예제 #9
0
 //Add Task
 public void NewTask(Models.Task task)
 {
     if (db.Tasks == null)
     {
         db.Tasks = new List <Models.Task>();
     }
     db.Tasks.Add(task);
     SaveData(db);
 }
예제 #10
0
        public void TestUpdateTask_NegativeTaskId()
        {
            var context = new MockProjectManagerEntities();
            var task    = new Models.Task();

            task.TaskId = -234;
            var controller = new TaskController(new MockTaskBC(context));
            var result     = controller.UpdateTaskDetails(task) as JSendResponse;
        }
예제 #11
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Models.Task task = await db.Tasks.FindAsync(id);

            db.Tasks.Remove(task);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #12
0
 public static bool AddTask(Models.Task tasks)
 {
     using (var _context = new QuanLyProjectEntities())
     {
         _context.Tasks.AddOrUpdate(tasks);
         _context.SaveChanges();
         return(true);
     }
 }
        public async Task <IActionResult> UpdateTask(int taskId, Models.Task task)
        {
            if (taskId != task.ID)
            {
                return(this.BadRequest());
            }

            var oldtask = await this.context.Tasks.FindAsync(taskId);

            if (oldtask == null)
            {
                return(this.BadRequest());
            }

            if (oldtask.Priority != task.Priority)
            {
                var changetask = await this.context.Tasks.FirstAsync(t => t.Priority == task.Priority && t.TaskgroupID == task.TaskgroupID);

                changetask.Priority = oldtask.Priority;
                oldtask.Priority    = task.Priority;
                this.context.Entry(changetask).State = EntityState.Modified;
                this.context.Entry(oldtask).State    = EntityState.Modified;
            }
            else
            {
                oldtask.Name        = task.Name;
                oldtask.Description = task.Description;
                oldtask.Deadline    = task.Deadline;
                if (oldtask.TaskgroupID != task.TaskgroupID)
                {
                    (await this.context.Tasks.Where(t => t.Priority > oldtask.Priority && t.TaskgroupID == oldtask.TaskgroupID).ToListAsync()).ForEach(g => g.Priority -= 1);
                    oldtask.Priority    = ((await this.context.Tasks.Where(t => t.TaskgroupID == task.TaskgroupID).MaxAsync(t => (int?)t.Priority)) ?? 0) + 1;
                    oldtask.TaskgroupID = task.TaskgroupID;
                }

                this.context.Entry(oldtask).State = EntityState.Modified;
            }

            try
            {
                await this.context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!this.TaskExists(taskId))
                {
                    return(this.NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(this.NoContent());
        }
예제 #14
0
        public Models.Task BeginProduce(int WorkerID)
        {
            Task task = new Models.Task()
            {
                WorkerID = WorkerID
            };

            TaskCreated(this, new Task[] { task });
            return(task);
        }
예제 #15
0
        public IActionResult Create()
        {
            ViewData["ProjectId"] = new SelectList(_context.Projects, "ProjectId", "ProjectId");

            Models.Task task = new Models.Task
            {
                CreateDate = DateTime.UtcNow
            };
            return(View(task));
        }
예제 #16
0
 void IDropTarget.DragOver(IDropInfo dropInfo)
 {
     Models.Task source = dropInfo.Data as Models.Task;
     Models.Task target = dropInfo.TargetItem as Models.Task;
     if (validTarget(source, target))
     {
         dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
         dropInfo.Effects           = System.Windows.DragDropEffects.Copy;
     }
 }
예제 #17
0
        public Models.Task Get(int id)
        {
            Models.Task task = null;
            using (var db = new TodoAppDbContext())
            {
                task = db.Tasks.SingleOrDefault(t => t.TaskID == id);
            }

            return(task);
        }
예제 #18
0
 private static void readAllTasks(XmlReader reader)
 {
     reader.Read();
     while (reader.Name == "Task" && reader.IsStartElement())
     {
         Models.Task newTask = readTask(reader);
         taskFile.Tasks.Add(newTask);
         reader.Read();
     }
 }
예제 #19
0
        public Models.Task[] BeginMoveTo(int WorkerID, int FactoryID)
        {
            Task task = new Models.Task()
            {
                WorkerID = WorkerID
            };

            TaskCreated(this, new Task[] { task });
            return(new Task[] { task });
        }
예제 #20
0
        public User PutUser(String id, [FromBody] Models.Task task)
        {
            User user = _context.Users.FirstOrDefault(cus => cus.userName == id);

            user.Tasks.Add(task);
            task.taskUser = user.userName;
            _context.Users.Update(user);
            _context.SaveChanges();
            return(user);
        }
 public DialogTaskAddEditViewModel(MainViewModel parent, bool addEdit) : base(parent)
 {
     AddEdit = addEdit;
     if (AddEdit == false) //Edit
     {
         Models.Task selected = ParentVM.TaskVM.SelectedTask;
         Namee            = selected.Name;
         SelectedCategory = selected.Category;
     }
 }
예제 #22
0
 private void taskTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node.Parent == null)
     {
         Models.Task tag = (Models.Task)taskTreeView.SelectedNode.Tag;
         this.selectedTask     = tag.taskID;
         btnAddSubtask.Enabled = true;
         btnStartTimer.Enabled = true;
     }
 }
예제 #23
0
        /// <inheritdoc/>
        public async Task AddTaskAsync(Models.Task task, CancellationToken cancellationToken)
        {
            using var context = _contextFactory();

            // Add new task into DB context
            await context.AddAsync(task, cancellationToken);

            // Save new task into DataBase
            await context.SaveChangesAsync();
        }
예제 #24
0
        /// <inheritdoc/>
        public async Task RemoveTaskAsync(Models.Task task, CancellationToken cancellationToken)
        {
            using var context = _contextFactory();

            // Remove task from DB context
            context.Remove(task);

            // Save changes into DataBase
            await context.SaveChangesAsync(cancellationToken);
        }
예제 #25
0
        public ActionResult TaskDetails(int taskID)
        {
            Models.Task task = _repository.GetTask(taskID);
            if (task != null)
            {
                return(PartialView("TaskDetailsPartial", task));
            }

            return(new EmptyResult());
        }
 public int AddNewTask(Models.Task task)
 {
     if (task.JobCategory == null)
     {
         task.JobCategory = "";
     }
     return(AddNewTask(task.TaskOwnerUsername, task.CreationDate, task.Title, task.Description,
                       task.Location, task.Address, task.TaskPhotoUrl, task.IsAssignedToSomeone,
                       task.AssignedToUserWithThisUsername, task.PaymentAmount, task.IsCompleted, task.JobCategory));
 }
예제 #27
0
 public IActionResult AddTask(Models.Task newTask)
 {
     if (ModelState.IsValid)
     {
         _context.Task.Add(newTask);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
예제 #28
0
        public Task BeginTake(int WorkerID, ResourceTypeIDs ResourceTypeID)
        {
            Task task = new Models.Task()
            {
                WorkerID = WorkerID, ResourceTypeID = ResourceTypeID
            };

            TaskCreated(this, new Task[] { task });
            return(task);
        }
예제 #29
0
        public async Task <IActionResult> Create(Models.Task task)
        {
            if (ModelState.IsValid)
            {
                await _taskService.CreateTask(task, _userManager.GetUserId(User));

                return(RedirectToAction("index", "task", new { id = task.Id }));
            }
            return(View(task));
        }
예제 #30
0
 public async Task<IActionResult> Create([Bind("TID,TaskName")] Models.Task Task)
 {
     if (ModelState.IsValid)
     {
         _context.Add(Task);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(IndexTasks));
     }
     return View(Task);
 }
예제 #31
0
        public async Task <IActionResult> CreateTask(string taskTitle)
        {
            Models.Task task = new Models.Task {
                TaskTitle = taskTitle, TaskOwner = int.Parse(User.Identity.Name)
            };
            _tasksContext.Add(task);
            await _tasksContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #32
0
 public static CommentsGetModels ConvertToCommentsGetModel(Comment comment, Models.Task task)
 {
     return(new CommentsGetModels
     {
         Id = comment.Id,
         Text = comment.Text,
         Important = comment.Important,
         IdTask = task.Id
     });
 }
예제 #33
0
 public bool Create(FormCollection newTask)
 {
     var newTaskModel = new Models.Task
     {
         DueDate = Convert.ToDateTime(newTask["DueDate"]),
         Name = newTask["Name"],
         Priority1 = dc.Priorities
             .Where(a => a.Name == newTask["Priority"])
             .First(),
         StartDate = Convert.ToDateTime(newTask["StartDate"]),
         HoursRemaining = Convert.ToDecimal(newTask["HoursRemaining"]),
         HoursSpent = Convert.ToDecimal(newTask["HoursSpent"])
     };
     dc.Tasks.InsertOnSubmit(newTaskModel);
     dc.SubmitChanges();
     return true;
 }
        public void RecordTaskActionHandler(RecordTaskAction message)
        {
            var workflowId = message.WorkflowInstanceId;
            var tenantId = message.TenantId;
            var auditContext = message.AuditContext;
            var objId = message.TargetObjectId;
            var objType = message.TargetObjectType;
            var taskEvent = message.Event;
            var task = message.State + "|" + message.Task;
            var state = message.State;
            var workflowName = message.WorkflowTemplateName;
            var stateNameForLock = (string.IsNullOrEmpty(state) ? message.StateId.ToString() : state);
            var stateLock = new StateLock()
            {
                WorkflowInstanceId = workflowId,
                WorkflowInstanceTenantId = tenantId,
                StateName = stateNameForLock,
            };
            while (lockedStates.Exists(x => x.WorkflowInstanceId == workflowId && x.StateName == stateNameForLock && x.WorkflowInstanceTenantId == tenantId))
            {
                System.Threading.Thread.Sleep(100);
            }
            lockedStates.Add(stateLock);
            try
            {
                //System.Console.WriteLine("Event Received : " + taskEvent);
                WorkflowInstance data = null;
                using (var dataContext = new DataContext(message.TenantId, auditContext))
                {

                    try
                    {
                        data = Utils.GetWorkflowInstance(dataContext, workflowId, objId, objType);
                        if (data == null)
                        {
                            return;
                        }
                        var stateData = data.States.Where(x => (x.Id == message.StateId)).FirstOrDefault();
                        if (stateData == null)
                        {
                            stateData = data.States.Where(x => (x.StateTemplate.StateName == message.State)).OrderByDescending(x => x.Id).FirstOrDefault();
                            if (stateData == null)
                            {
                                return;
                            }
                        }
                        var taskData = stateData.Tasks.Where(x => (x.Id == message.TaskId)).FirstOrDefault();
                        if (taskData == null)
                        {
                            taskData = stateData.Tasks.Where(x => (x.TaskTemplate.TaskName == task)).OrderByDescending(x => x.Id).FirstOrDefault();
                            if (taskData == null)
                            {
                                return;
                            }
                        }
                        var eventData = data.WorkflowTemplate.EventsTypes.FirstOrDefault(x => x.ParentName == taskData.TaskTemplate.TaskName && x.Event == taskEvent && x.Type == EventType.EventLevel.TASK);
                        if (eventData == null)
                        {
                            return;
                        }
                        var workflowEvent = new WorkflowEvent()
                        {
                            EventDate = DateTime.UtcNow,
                            EventMetaData = null,
                            EventType = eventData,
                            ExecutedBy = auditContext,
                            TaskParent = taskData,
                            WorkflowInstance = data,
                        };
                        data.Events.Add(workflowEvent);

                        if (data.CurrentState.Id == stateData.Id && taskData.IsCurrentTask == true)
                        {
                            TaskTemplate nextTaskTemplate = stateData.StateTemplate.Tasks.FirstOrDefault(x => x.TaskName == eventData.MoveTo);
                            if (nextTaskTemplate == null)
                            {
                                return;
                            }
                            taskData.IsCurrentTask = false;
                            PocketBoss.Models.Task newTask = new Models.Task()
                            {
                                TaskTemplate = nextTaskTemplate,
                                IsCurrentTask = true,
                                LastTask = nextTaskTemplate.LastTask,
                                State = stateData,
                                WorkflowInstance = data,
                                TransitionDate = DateTime.UtcNow,
                                TransitionedBy = auditContext,
                                TransitionEvent = workflowEvent,
                            };
                            stateData.Tasks.Add(newTask);
                            dataContext.SaveChanges();
                            publishNewTasks(data, newTask, message.AuditContext, message.TenantId, _bus);
                        }
                    }
                    catch (Exception exc)
                    {
                    }

                }
                using (var dataContext = new DataContext(message.TenantId, auditContext))
                {
                    if (dataContext.Tasks.Count(x => x.LastTask == false && x.IsCurrentTask == true && x.State.IsCurrent == true && x.WorkflowInstanceId == data.Id) == 0)
                    {
                        updateStateAsComplete(data, message.AuditContext, message.TenantId, _bus);
                    }
                }
            }
            catch (Exception exc)
            {
            }
            finally
            {
                lockedStates.Remove(stateLock);
            }
        }