public static void Register(string eachTaskId, string memoContent) { using (var db = new MemoAppContext()) { EachTask targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == eachTaskId).FirstOrDefault(); if (targetTask == null) { return; } Memo sameMemo = db.Memos.Where(memo => memo.EachTask.EachTaskId == eachTaskId).FirstOrDefault(); if (sameMemo == null) { Memo newMemo = new Memo { CreateTime = DateTimeOffset.Now.ToLocalTime(), Content = memoContent, EachTask = targetTask }; db.Memos.Add(newMemo); } else { sameMemo.Content = memoContent; sameMemo.UpdateTime = DateTimeOffset.Now.ToLocalTime(); } db.SaveChanges(); } }
public static List <Memo> SearchTaskName(string searchWord) { string[] searchWordList = searchWord.Split(new string[] { " ", " " }, StringSplitOptions.RemoveEmptyEntries); using (var db = new MemoAppContext()) { List <Memo> rtnList = db.Memos.Include(memo => memo.EachTask).ToList(); for (int i = 0; i < searchWordList.Length; i++) { if (searchWordList[i].StartsWith("-") || searchWordList[i].StartsWith("-")) { rtnList = rtnList.Where(memo => (!memo.EachTask.Content.ToLower().Contains(searchWordList[i].Substring(1).ToLower()))).ToList(); } else { rtnList = rtnList.Where(memo => memo.EachTask.Content.ToLower().Contains(searchWordList[i].ToLower())).ToList(); } } return(rtnList.GroupBy(memo => memo.EachTask.PlanDate) .SelectMany(memo => memo.OrderByDescending(m => m.EachTask.Rank)) .GroupBy(memo => memo.EachTask.PlanDate) .SelectMany(memo => memo.OrderBy(m => m.EachTask.PlanDate)) .Reverse() .ToList()); } }
public static TaskStatus CheckTaskStatus(string eachTaskId) { using (var db = new MemoAppContext()) { EachTask thisTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == eachTaskId).FirstOrDefault(); if (thisTask.CompleteFlag == true) { return(TaskStatus.AlreadyFinished); } else if (thisTask.StartedFlag == false) { return(TaskStatus.NotYetStarted); } else { TimeInfo stopTimeInfo = db.TimeInfos.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId && timeInfo.Stop == DateTimeOffset.MinValue).FirstOrDefault(); if (stopTimeInfo == null) { return(TaskStatus.AlreadyPaused); } else { return(TaskStatus.NoProblem); } } } }
public static List <Config> GetAllConfig() { using (var db = new MemoAppContext()) { return(db.Configs.ToList()); } }
public static string GetSpecificConfigValue(ConfigType configType) { using (var db = new MemoAppContext()) { return(db.Configs.Where(config => config.ConfigId == configType.ToString()).FirstOrDefault()?.Value); } }
public static string RegisterPause(string eachTaskId) { string msg = null; switch (CheckTaskStatus(eachTaskId)) { case TaskStatus.AlreadyPaused: msg = GetLangMessage.GetMessage("Msg1017"); break; case TaskStatus.AlreadyFinished: msg = GetLangMessage.GetMessage("Msg1018"); break; case TaskStatus.NoProblem: using (var db = new MemoAppContext()) { TimeInfo stopTimeInfo = db.TimeInfos.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId && timeInfo.Stop == DateTimeOffset.MinValue).FirstOrDefault(); stopTimeInfo.Stop = DateTimeOffset.Now.ToLocalTime(); db.SaveChanges(); } break; case TaskStatus.NotYetStarted: msg = GetLangMessage.GetMessage("Msg1019"); break; } return(msg); }
public static string RegisterPause(string eachTaskId) { string msg = null; switch (CheckTaskStatus(eachTaskId)) { case TaskStatus.AlreadyPaused: msg = "すでに一時停止中です。"; break; case TaskStatus.AlreadyFinished: msg = "すでに完了済みのタスクです。"; break; case TaskStatus.NoProblem: using (var db = new MemoAppContext()) { TimeInfo stopTimeInfo = db.TimeInfos.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId && timeInfo.Stop == DateTimeOffset.MinValue).FirstOrDefault(); stopTimeInfo.Stop = DateTimeOffset.Now.ToLocalTime(); db.SaveChanges(); } break; case TaskStatus.NotYetStarted: msg = "このタスクはまだ開始されていません。"; break; } return(msg); }
public static List <Activity> GetSpecificDateActivityLog(DateTimeOffset specificTime) { List <Activity> activityLog = new List <Activity>(); using (var db = new MemoAppContext()) { List <EachTask> eachTaskList = EachTaskModel.GetSpecificDateEachTasks(specificTime); foreach (var eachTask in eachTaskList) { List <TimeInfo> timeInfoList = TimeInfoModel.GetSpecificTaskTimeInfo(eachTask.EachTaskId); foreach (TimeInfo timeInfo in timeInfoList) { Activity activity = new Activity() { ExactStartTime = timeInfo.Start.LocalDateTime, StartTime = timeInfo.Start.LocalDateTime.ToString(" HH : mm "), StopTime = timeInfo.Stop == DateTimeOffset.MinValue ? " XX : XX " : timeInfo.Stop.LocalDateTime.ToString(" HH : mm "), TaskContent = eachTask.Content, EachTaskId = eachTask.EachTaskId }; activityLog.Add(activity); } } } return(activityLog.OrderBy(log => log.ExactStartTime).ToList()); }
public static string GetSpecificEachTaskMemo(string eachTaskId) { using (var db = new MemoAppContext()) { return(db.Memos.Where(memo => memo.EachTask.EachTaskId == eachTaskId).FirstOrDefault()?.Content); } }
public static List <TimeInfo> GetSpecificTaskTimeInfo(string eachTaskId) { using (var db = new MemoAppContext()) { return(db.TimeInfos.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId).Include(timeInfo => timeInfo.EachTask).ToList()); } }
async public static Task <int> RegisterTaskAsync(EachTask newTask) { using (var db = new MemoAppContext()) { db.EachTasks.Add(newTask); return(await db.SaveChangesAsync()); } }
public static void ChangeValidFlag(string targetTaskId, bool flagValue) { using (var db = new MemoAppContext()) { EachTask targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == targetTaskId).FirstOrDefault(); targetTask.ValidFlag = flagValue; db.SaveChanges(); } }
public static string RegisterTask(EachTask newTask) { using (var db = new MemoAppContext()) { db.EachTasks.Add(newTask); db.SaveChanges(); return(GetEachTaskId(newTask)); } }
async public static Task UpdateTaskRankAsync(string newTaskId, int rank) { using (var db = new MemoAppContext()) { EachTask targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == newTaskId).FirstOrDefault(); targetTask.Rank = rank; await db.SaveChangesAsync(); } }
public static List <Memo> GetSpecificDateMemo(DateTimeOffset specificDate) { using (var db = new MemoAppContext()) { List <Memo> memoList = db.Memos.Where(memo => memo.CreateTime.Date == specificDate.Date).Include(memo => memo.EachTask).ToList(); return(memoList); } }
async public static Task ChangeComplateFlag(string targetTaskId, bool flagValue) { using (var db = new MemoAppContext()) { EachTask targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == targetTaskId).FirstOrDefault(); targetTask.CompleteFlag = flagValue; await db.SaveChangesAsync(); } }
public static EachTask GetEachTask(string targetTaskId) { EachTask targetTask = new EachTask(); using (var db = new MemoAppContext()) { targetTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == targetTaskId).FirstOrDefault(); } return(targetTask); }
/// <summary> /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの ///最初の行であるため、main() または WinMain() と論理的に等価です。 /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new MemoAppContext()) { db.Database.Migrate(); } }
public static string AlreadyStartedEachTaskId(DateTimeOffset dateTime) { using (var db = new MemoAppContext()) { return(db.TimeInfos.Where(timeInfo => timeInfo.Stop == DateTimeOffset.MinValue && timeInfo.Start.Date == dateTime.Date) .Include(timeInfo => timeInfo.EachTask) .FirstOrDefault()? .EachTask?.EachTaskId); } }
public static List <EachTask> GetSpecificTaskSmallTasks(string eachTaskId) { if (string.IsNullOrWhiteSpace(eachTaskId)) { return(new List <EachTask>()); } using (var db = new MemoAppContext()) { return(db.EachTasks.Where(eachTask => eachTask.ParentEachTaskId == eachTaskId && eachTask.ValidFlag == true) .OrderBy(eachTask => eachTask.Rank).ToList()); } }
public static string GetEachTaskId(EachTask targetTask) { using (var db = new MemoAppContext()) { EachTask existEachTask = db.EachTasks.Where(eachTask => eachTask.Content == targetTask.Content && eachTask.PlanDate.Date == targetTask.PlanDate.Date && eachTask.ParentEachTaskId == targetTask.ParentEachTaskId) .FirstOrDefault(); return(existEachTask?.EachTaskId ?? string.Empty); } }
public static List <EachTask> GetSpecificDateEachTasks(DateTimeOffset specificDate) { if (specificDate == null) { return(new List <EachTask>()); } using (var db = new MemoAppContext()) { return(db.EachTasks.ToList() .FindAll(eachTask => eachTask.PlanDate.Date == specificDate.Date && string.IsNullOrWhiteSpace(eachTask.ParentEachTaskId) && eachTask.ValidFlag == true) .OrderBy(eachTask => eachTask.Rank) .ToList()); } }
public static string RegisterStart(string eachTaskId) { string msg = null; using (var db = new MemoAppContext()) { var selectedTask = db.EachTasks.FirstOrDefault(eachTask => eachTask.EachTaskId == eachTaskId); List <TimeInfo> notStoppedInfo = db.TimeInfos.Where(timeInfo => timeInfo.Stop == DateTimeOffset.MinValue).Include(timeInfo => timeInfo.EachTask).ToList(); TimeInfo doubleStartTask = notStoppedInfo.Where(timeInfo => timeInfo.EachTask.EachTaskId == eachTaskId).FirstOrDefault(); if (doubleStartTask != null) { msg = GetLangMessage.GetMessage("Msg1015"); } else { if (selectedTask.CompleteFlag == true) { EachTask completeTask = db.EachTasks.Where(eachTask => eachTask.EachTaskId == eachTaskId).FirstOrDefault(); completeTask.CompleteFlag = false; msg = GetLangMessage.GetMessage("Msg1016"); } else { TimeInfo startTimeInfo = new TimeInfo() { Start = DateTimeOffset.Now.ToLocalTime(), EachTask = db.EachTasks.FirstOrDefault(eachTask => eachTask.EachTaskId == eachTaskId) }; db.TimeInfos.Add(startTimeInfo); selectedTask.StartedFlag = true; } notStoppedInfo.ForEach(timeInfo => timeInfo.Stop = DateTimeOffset.Now.ToLocalTime()); db.SaveChanges(); } } return(msg); }
public async static Task UpdateSpecificConfigAsync(ConfigType configType, string value) { using (var db = new MemoAppContext()) { Config targetConfig = db.Configs.Where(config => config.ConfigId == configType.ToString()).FirstOrDefault(); if (targetConfig == null) { Config newConfig = new Config() { ConfigId = configType.ToString(), Value = value }; db.Configs.Add(newConfig); } else { targetConfig.Value = value; } await db.SaveChangesAsync(); } }