public static ShowWeeklyPlan CreateShowWeeklyPlan(WeekSummary weekSummary, WeekTarget weekTarget, Department department) { var showWeeklyPlan = new ShowWeeklyPlan(); if (!weekSummary.Null()) { showWeeklyPlan.ID = weekSummary.ID; showWeeklyPlan.Description = weekSummary.Description; showWeeklyPlan.CreateTime = weekSummary.CreateTime.ToString("yy-MM-dd HH:mm"); showWeeklyPlan.TargetTime = weekSummary.WeekNum; } if (!weekTarget.Null()) { showWeeklyPlan.Target = weekTarget.Target ?? " "; showWeeklyPlan.Progress = weekTarget.Progress; showWeeklyPlan.TargetTime = weekTarget.WeekNum; } if (!department.Null()) { showWeeklyPlan.DepartmentName = department.Name; } DateTime beginTime; DateTime endTime; DateTimeUtility.GetWeekDays(showWeeklyPlan.TargetTime, out beginTime, out endTime); showWeeklyPlan.BeginTime = beginTime.ToString("yy-MM-dd"); showWeeklyPlan.EndTime = endTime.ToString("yy-MM-dd"); return showWeeklyPlan; }
public WeekSummary CreateSummary(int weekNum) { var weekSummary = new WeekSummary(); weekSummary.ID = Guid.NewGuid(); weekSummary.CreateTime = DateTime.Now; weekSummary.DepartmentId = DepartmentId; weekSummary.Description = Description; weekSummary.WeekNum = weekNum; return weekSummary; }
public static UpdateWeekSummary CreateSummary(Guid? weekId, WeekSummary weekSummary) { var updateWeekSummary = new UpdateWeekSummary(); updateWeekSummary.ID = weekId.GetValueOrDefault(); if (!weekSummary.Null()) { updateWeekSummary.Description = weekSummary.Description; updateWeekSummary.DepartmentId = weekSummary.DepartmentId; } return updateWeekSummary; }
//private void AddTarget(UpdateWeeklyTarget updateWeeklyTarget) //{ // var weekNum = DateTimeUtility.GetWeekOfYear(DateTime.Today); // using (var workContext = new DefaultContext()) // { // var weekTarget = workContext.WeekTargets.FirstOrDefault(x => x.WeekNum == weekNum && x.DepartmentId == updateWeeklyTarget.DepartmentId); // if (!weekTarget.Null()) // { // Message = "本周已经有日志"; // return; // } // weekTarget = updateWeeklyTarget.CreateWeekTarget(weekNum); // workContext.WeekTargets.Add(weekTarget); // Flag = true; // } //} //private void EditTarget(UpdateWeeklyTarget updateWeeklyTarget) //{ // var weekNum = DateTimeUtility.GetWeekOfYear(DateTime.Today); // using (var workContext = new DefaultContext()) // { // } //} public void UpdateSummary(UpdateWeekSummary updateWeekSummary) { using (var workContext = new DefaultContext()) { var weekTarget = workContext.WeekTargets.FirstOrDefault(x => x.ID == updateWeekSummary.ID); if (weekTarget.Null()) { Message = "总结周记不存在"; return; } var weekNum = DateTimeUtility.GetWeekOfYear(DateTime.Now); if (weekNum > weekTarget.WeekNum + 1) { if (DateTime.Now.Hour > 2 || DateTime.Today.DayOfWeek > DayOfWeek.Monday) { Message = "周记已经被锁定无法总结!"; return; } } var weekSummary = workContext.WeekSummaries.FirstOrDefault(x => x.ID == updateWeekSummary.ID); if (weekSummary.Null()) { weekSummary = new WeekSummary(); weekSummary.ID = updateWeekSummary.ID; weekSummary.CreateTime = DateTime.Now; weekSummary.DepartmentId = updateWeekSummary.DepartmentId; weekSummary.WeekNum = weekTarget.WeekNum; weekSummary.DepartmentId = weekTarget.DepartmentId; workContext.WeekSummaries.Add(weekSummary); } else { workContext.ModifiedModel(weekSummary); } weekSummary.Description = updateWeekSummary.Description; workContext.SaveChanges(); Flag = true; } }