Example #1
0
        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();
            }
        }
Example #2
0
        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());
            }
        }
Example #3
0
        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);
                    }
                }
            }
        }
Example #4
0
 public static List <Config> GetAllConfig()
 {
     using (var db = new MemoAppContext())
     {
         return(db.Configs.ToList());
     }
 }
Example #5
0
 public static string GetSpecificConfigValue(ConfigType configType)
 {
     using (var db = new MemoAppContext())
     {
         return(db.Configs.Where(config => config.ConfigId == configType.ToString()).FirstOrDefault()?.Value);
     }
 }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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());
        }
Example #9
0
 public static string GetSpecificEachTaskMemo(string eachTaskId)
 {
     using (var db = new MemoAppContext())
     {
         return(db.Memos.Where(memo => memo.EachTask.EachTaskId == eachTaskId).FirstOrDefault()?.Content);
     }
 }
Example #10
0
 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());
     }
 }
Example #11
0
 async public static Task <int> RegisterTaskAsync(EachTask newTask)
 {
     using (var db = new MemoAppContext())
     {
         db.EachTasks.Add(newTask);
         return(await db.SaveChangesAsync());
     }
 }
Example #12
0
 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();
     }
 }
Example #13
0
 public static string RegisterTask(EachTask newTask)
 {
     using (var db = new MemoAppContext())
     {
         db.EachTasks.Add(newTask);
         db.SaveChanges();
         return(GetEachTaskId(newTask));
     }
 }
Example #14
0
 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();
     }
 }
Example #15
0
        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);
            }
        }
Example #16
0
 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();
     }
 }
Example #17
0
        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);
        }
Example #18
0
        /// <summary>
        /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの
        ///最初の行であるため、main() または WinMain() と論理的に等価です。
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using (var db = new MemoAppContext())
            {
                db.Database.Migrate();
            }
        }
Example #19
0
 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);
     }
 }
Example #20
0
        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());
            }
        }
Example #21
0
        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);
            }
        }
Example #22
0
        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());
            }
        }
Example #23
0
        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);
        }
Example #24
0
        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();
            }
        }