Exemplo n.º 1
0
Arquivo: Logic.cs Projeto: wHo2/1000H
 static void RTPInsert(DateTime date, Routine routine, Project project, List<Project> projectList)
 {
     if (date.Date != DateTime.Today && project.StartLine == null)
     {
         project.StartLine = date.Date;
     }
     project.Id = ++Project.IDmax;
     projectList.Add(project);
     planManager.RoutineHasPlanThenAdd(routine, project);
 }
Exemplo n.º 2
0
Arquivo: Logic.cs Projeto: wHo2/1000H
        /// <summary>
        /// 判定重复执行的项目今天是否应加入,如果已有同名的项目则不加入
        /// 是则创建一个Project并加入ProjectList列表
        /// 在新建一个Routine和初始化时执行
        /// </summary>
        public static bool RoutineToProject(Routine routine, DateTime date, List<Project> projectList)
        {
            Project project = routine.Copy();
            project.SetRoutineThisDay(date);
            project.RoutineID = routine.Id;
            project.UsedTime = project.AssumeTime;
            switch (routine.RepeatType)//每天 = 1, 工作日 = 2, 周末 = 3, 间隔 = 4, 常用 = 5, 星期一 =6, 星期二 =7, 星期三 =8, 星期四 =9, 星期五=10, 星期六=11, 星期日=12
            {
                case RepeatTYPE.每天:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    RTPInsert(date, routine, project, projectList);
                    break;
                case RepeatTYPE.工作日:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek != DayOfWeek.Sunday && date.DayOfWeek != DayOfWeek.Saturday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.周末:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.间隔: return true; //未完成
                case RepeatTYPE.常用: return true;
                case RepeatTYPE.星期一:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Monday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.星期二:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Tuesday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.星期三:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Wednesday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.星期四:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Thursday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.星期五:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Friday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
                case RepeatTYPE.星期六:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        RTPInsert(date, routine, project, projectList);

                    }
                    else return true;
                    break;
                case RepeatTYPE.星期日:
                    if (projectList.Any(item => item.RoutineID == routine.Id))
                    {
                        return true;
                    }
                    if (date.DayOfWeek == DayOfWeek.Sunday)
                    {
                        RTPInsert(date, routine, project, projectList);
                    }
                    else return true;
                    break;
            }
            return true;
        }
Exemplo n.º 3
0
        private void btnSetFinished_Click(object sender, EventArgs e)
        {
            #region 新建或更改的出错提醒

            if (txtProjectName.Text == "")
            {
                MessageBox.Show("请填写项目名");
                return;
            }
            if (dtpAssumeTime.Checked == false && dtpLatestFinishTime.Checked == false)//估计时间和最迟结束时间都未填写
            {
                MessageBox.Show("估计时间和最迟结束时间必须填写一个");
                return;
            }
            #endregion

            if (btnSetFinished.Text == @"完成" || btnSetFinished.Text == @"间隔的修改")
            {
                #region 新建的逻辑
                if (cmbRepeat.SelectedIndex == 0)
                {
                    Project project = new Project();
                    ProjectGetValue(project, DateTime.Today);
                    Logic.ProjectList.Add(project);

                    Logic.Schedule();//重新计算日程表
                    project.UsedTime = (TimeSpan)(project.FinishedTime - project.StartTime);
                    project.Id = ++Project.IDmax;
                    Form1.BindProject();
                    Logic.CheckRoutineAndInsert(project);
                    //如果是计划的项目
                    if (plan != null)
                    {
                        project.Name = plan.Name + "-" + project.Name;
                        Logic.InsertPlansProject(plan, project);
                        plan.AddSubproject(project);
                        Logic.planManager.SetDirty(plan);
                    }
                    if (btnSetFinished.Text == @"间隔的修改")
                    {
                        project.Remark += ProgressRecorder.GetRecordString(project);
                        Logic.CaculateRoutine_AvgAccuTimes(project);
                    }
                }
                else//新建routine
                {
                    Routine routine = new Routine();
                    ProjectGetValue(routine, DateTime.Today);
                    Logic.RoutineList.Add(routine);
                    routine.Id = ++Routine.RIDmax;
                    Logic.RoutineToProject(routine, DateTime.Now, Logic.ProjectList);
                    Form1.BindRoutine();
                }
                Close();
                #endregion
            }
            else if (btnSetFinished.Text == @"修改完成")//修改project
            {

                #region 修改的逻辑

                stat oldStat = OldProject.Status;
                //如果是计划
                if (plan != null)
                {
                    Logic.planManager.SetDirty(plan);
                }
                ProjectGetValue(OldProject, DateTime.Today);

                if (oldStat != OldProject.Status && OldProject.Status == stat.完成)
                {
                    OldProject.Remark += ProgressRecorder.GetRecordString(OldProject);
                    if (OldProject.RoutineID != Routine.IDnull)
                    {
                        Logic.CaculateRoutine_AvgAccuTimes(OldProject);
                    }
                }
                if (OldProject.Status != stat.完成)
                {
                    OldProject.UsedTime = OldProject.AssumeTime;
                }
                Logic.Schedule();//重新计算日程表
                Close();
                #endregion
            }
            else if (btnSetFinished.Text == @"修改")//修改routine
            {
                ProjectGetValue(OldRoutine, DateTime.Today);
                Logic.Schedule();//重新计算日程表

                Close();
            }
            else if (btnSetFinished.Text == @"保存")
            #region 查看时的逻辑
            {
                if (plan != null)
                {
                    Logic.planManager.SetDirty(plan);
                }
                ProjectGetValue(OldProject, OldProject.StartTime.Value.Date);//!!!ProjectGetValue(OldProject, Form1.GetDtpSeekerValue())

                if (Logic.ProjectList.Any(item => item.Id == OldProject.Id))
                {
                    Close();
                    return;
                }
                Logic.ProjectList.Add(OldProject);
                Logic.Schedule();//重新计算日程表
                Close();
                return;
            }
            #endregion
        }
Exemplo n.º 4
0
Arquivo: Logic.cs Projeto: wHo2/1000H
 public static List<Project> GetRoutinesProjects(Routine routine)
 {
     List<Project> list = new List<Project>();
     list.AddRange(AllProjectList().FindAll(p => p.RoutineID == routine.Id));
     return list;
 }
Exemplo n.º 5
0
 public void RoutineHasPlanThenAdd(Routine routine, Project project)
 {
     if (routine.Plan != null)
     {
         var plan = GetPlanByID(routine.Plan.ToString());
         plan.AddSubproject(project);
     }
 }