Ejemplo n.º 1
0
        public List <CTask> GetTemplateTasks(IWebHostEnvironment hstEnv, CStat.Models.CStatContext context, CTask tmpl, List <Event> events, DateRange lim)
        {
            List <CTask> taskList = new List <CTask>();

            if (tmpl.GetDueDates(events, out List <DateTimeEv> dueDateEvs, lim))
            {
                foreach (var dueDateEv in dueDateEvs)
                {
                    // Create new task and add it to the list
                    CTask task = new CTask();
                    task.ParentTaskId      = tmpl.Id;
                    task.Type              = 0;
                    task.Description       = tmpl.Description;
                    task.PlanLink          = tmpl.PlanLink;
                    task.EstimatedManHours = tmpl.EstimatedManHours;
                    task.Id                = 0;
                    task.PersonId          = tmpl.PersonId;
                    task.TotalCost         = tmpl.TotalCost;
                    task.EstimatedDoneDate = new DateTime(1900, 1, 1);
                    task.CommittedCost     = 0;
                    task.DueDate           = dueDateEv.dt;
                    task.EventId           = dueDateEv.eventID;
                    task.SetTaskStatus(CTask.eTaskStatus.Not_Started, CTask.eTaskStatus.Unknown, 0);
                    task.Priority       = (int)tmpl.Priority;
                    task.RequiredSkills = tmpl.RequiredSkills;
                    taskList.Add(task);
                }
            }

            return(taskList);
        }
Ejemplo n.º 2
0
        public ActionResult OnPostMarkComplete()
        {
            int taskId = int.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskId").Value);

            if (taskId > 0)
            {
                var   taskData = TaskData.ReadTaskData(hostEnv, taskId, -1);
                CTask task     = _context.Task.First(t => (t.Id == taskId));
                if ((task != null) && (taskData != null))
                {
                    taskData.PercentComplete = 100;
                    taskData.Write(hostEnv);
                    task.GetTaskStatus(out CTask.eTaskStatus status, out CTask.eTaskStatus reason, out int pctComp);
                    pctComp = 100;
                    status  = CTask.eTaskStatus.Completed;
                    reason  = CTask.eTaskStatus.Job_Done;
                    task.SetTaskStatus((CTask.eTaskStatus)status, (CTask.eTaskStatus)reason, (int)pctComp);
                    try
                    {
                        taskData.Write(hostEnv);
                        _context.Attach(task).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        _context.SaveChanges();
                        return(this.Content("Success"));
                    }
                    catch { }
                }
            }
            return(this.Content("Failed"));
        }
Ejemplo n.º 3
0
        //private TaskData CreateTestTaskData ()
        //{
        //    TaskData tData = new TaskData(task.Id)
        //    {
        //        state = (int)CTask.eTaskStatus.Paused,
        //        reason = (int)CTask.eTaskStatus.Need_Funds,
        //        Desc = "The same came to Jesus by night, and said unto him, Rabbi, we know that thou art a teacher come from God: for no man can do these miracles that thou doest, except God be with him.             Jesus answered and said unto him, Verily, verily, I say unto thee, Except a man be born again, he cannot see the kingdom of God. Nicodemus saith unto him, How can a man be born when he is old ? can he enter the second time into his mother's womb, and be born? Jesus answered, Verily, verily, I say unto thee, Except a man be born of water and of the Spirit, he cannot enter into the kingdom of God. That which is born of the flesh is flesh; and that which is born of the Spirit is spirit. Marvel not that I said unto thee, Ye must be born again. The wind bloweth where it listeth, and thou hearest the sound thereof, but canst not tell whence it cometh, and whither it goeth: so is every one that is born of the Spirit."
        //    };

        //    Pic pic = new Pic(126, 1, "This is the title description for Pic 1", "Images/Img_126_1.jpg");
        //    tData.pics.Add(pic);
        //    pic = new Pic(126, 2, "This is the title description for Pic 22", "Images/Img_126_2.jpg");
        //    tData.pics.Add(pic);
        //    pic = new Pic(126, 3, "This is the title description for Pic 333", "Images/Img_126_3.jpg");
        //    tData.pics.Add(pic);
        //    return tData;
        //}

        private void InitializeTask(int tid = 0)
        {
            task     = new CTask();
            taskData = new TaskData();
            if (tid == -1)
            {
                // Initialize Template
                task.Type            |= (int)CTask.eTaskType.Template;
                IsTemplate            = true;
                taskData.FixedDueDate = true;
                tid = 0;
            }
            else
            {
                task.Type = 0;
            }

            task.Description       = "";
            task.EstimatedManHours = 0;
            task.Id                = tid;
            task.PersonId          = null;
            task.TotalCost         = 0;
            task.EstimatedDoneDate = new DateTime(1900, 1, 1);
            task.CommittedCost     = 0;
            task.SetTaskStatus(CTask.eTaskStatus.Not_Started, CTask.eTaskStatus.Unknown, 0);
            task.Priority       = (int)CTask.ePriority.High;
            task.RequiredSkills = "";
        }