Esempio n. 1
0
        public void SetSmallTaskInfo()
        {
            try
            {
                List <EachTask> smallEachTaskList = EachTaskModel.GetSpecificTaskSmallTasks(SelectedEachTaskId);

                SmallTaskListData.Clear();

                smallEachTaskList?.ForEach(eachSmallTask =>
                {
                    SmallTaskInfo smallTaskInfo = new SmallTaskInfo()
                    {
                        EachTaskId       = eachSmallTask.EachTaskId,
                        ParentEachTaskId = SelectedEachTaskId,
                        Content          = eachSmallTask.Content,
                        IsComplete       = eachSmallTask.CompleteFlag
                    };

                    SmallTaskListData.Add(smallTaskInfo);
                });
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 2
0
        public void TaskPause(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsEachTaskIdEmpty())
                {
                    CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Msg1001"));
                    return;
                }

                Msg = TimeInfoModel.RegisterPause(SelectedEachTaskId);
                if (Msg != null)
                {
                    CommonViewModel.NotifySystemMessage(Msg);
                    return;
                }

                if (NotifyRestTime != null)
                {
                    NotifyRestTime.Cancel();
                }

                CommonViewModel.RecentSelectedEachTaskId = SelectedEachTaskId;

                // Update Recent status
                SetRecentInfo("Msg1011");
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 3
0
        public async Task MemoRegister(object sender, RoutedEventArgs e)
        {
            try
            {
                // Control Progress Dialog
                var progressDialog = new RegisterProgressDialog();
                var showingDialog  = progressDialog.ShowAsync();

                if (IsEachTaskIdEmpty())
                {
                    CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Msg1001"));
                    return;
                }

                if (!string.IsNullOrWhiteSpace(MemoContent))
                {
                    MemoModel.Register(SelectedEachTaskId, MemoContent);
                }

                showingDialog.Cancel();
                progressDialog.Hide();

                // Control Progress Dialog
                var completeDialog       = new RegisterCompleteDialog();
                var noticeCompleteDialog = completeDialog.ShowAsync();
                await Task.Delay(700);

                noticeCompleteDialog.Cancel();
                completeDialog.Hide();
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 4
0
        public void SetRecentInfo(string msgNo)
        {
            try
            {
                CommonViewModel.RecentSelectedEachTaskId = SelectedEachTaskId;
                CommonViewModel.RecentActionStatus       = msgNo;

                TaskChoiceLabel = $"{GetLangMessage.GetMessage("Msg1007")}       {ShowRecentInfo()}";
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 5
0
 public void Page_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         SetTaskDisplayInfo();
         SetSmallTaskInfo();
         SetSelectedEachTask();
         this.SelectedEachTaskId = CommonViewModel.RecentSelectedEachTaskId;
     }
     catch
     {
         CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
     }
 }
Esempio n. 6
0
        public async void UpdateConfig()
        {
            try
            {
                await UpdateSpecificConfigAsync(ConfigType.NotificationFlag, NotificationToggleValue.ToString());
                await UpdateSpecificConfigAsync(ConfigType.NotificationSpanMinute, NotificationSpanMinuteValue);
                await UpdateSpecificConfigAsync(ConfigType.Language, GetLanguageConfig().ToString());

                CommonViewModel.LangSetting = GetLanguageConfig().ToString();
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 7
0
        public void SetSelectedEachTask()
        {
            try
            {
                EachTask selectedTask = EachTaskModel.GetEachTask(CommonViewModel.RecentSelectedEachTaskId);

                if (selectedTask != null)
                {
                    this.SelectedEachTaskItem = new TaskDisplayInfo()
                    {
                        EachTaskId = selectedTask.EachTaskId,
                        Content    = (selectedTask.CompleteFlag ? "✔" : "").PadRight(3) + selectedTask.Content
                    };
                }
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 8
0
        public void ShorOtherDateLog()
        {
            try
            {
                TaskListData.Clear();

                List <EachTask> specificTaskList = GetSpecificDateEachTaskList(LogDate);
                specificTaskList.ForEach(eachTask => TaskListData.Add(eachTask));

                ActivityLog.Clear();
                ModelsHelpers.GetSpecificDateActivityLog(LogDate).ForEach(activity => ActivityLog.Add(activity));

                NoteList.Clear();
                ChangeMemoListToNoteList(MemoModel.GetSpecificDateMemo(LogDate)).ForEach(memo => NoteList.Add(memo));
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 9
0
        public void TaskStart(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsEachTaskIdEmpty())
                {
                    CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Msg1001"));
                    return;
                }


                Msg = TimeInfoModel.RegisterStart(SelectedEachTaskId);
                if (Msg != null)
                {
                    CommonViewModel.NotifySystemMessage(Msg);

                    if (Msg != GetLangMessage.GetMessage("Msg1016"))
                    {
                        // If the button pushing is invalid, return and not update the status.
                        return;
                    }
                }

                if (ConfigModel.GetSpecificConfigValue(ConfigModel.ConfigType.NotificationFlag) == true.ToString())
                {
                    this.NotifyRestTime = ThreadPoolTimer.CreatePeriodicTimer((source) =>
                    {
                        Notification notification = new Notification();
                        notification.NotifyRestTime();
                    }, TimeSpan.FromMinutes(float.Parse(ConfigModel.GetSpecificConfigValue(ConfigModel.ConfigType.NotificationSpanMinute))));
                }

                // Update Recent status
                SetRecentInfo("Msg1010");
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 10
0
        public void SetTaskDisplayInfo()
        {
            try
            {
                List <EachTask> specificDateEachTaskList = EachTaskModel.GetSpecificDateEachTasks(this.MainDate).ToList();

                TaskListData.Clear();

                specificDateEachTaskList?.ForEach(eachTask =>
                {
                    TaskDisplayInfo info = new TaskDisplayInfo
                    {
                        EachTaskId = eachTask.EachTaskId,
                        Content    = (eachTask.CompleteFlag ? "✔" : "").PadRight(3) + eachTask.Content
                    };
                    TaskListData.Add(info);
                });
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 11
0
        public void ShowSpecificTaskLog()
        {
            try
            {
                ActivityLog.Clear();
                List <Activity> SpecificDateActivityList = ModelsHelpers.GetSpecificDateActivityLog(LogDate);
                NoteList.Clear();
                List <Note> SpecificDateNote = ChangeMemoListToNoteList(MemoModel.GetSpecificDateMemo(LogDate));

                if (SelectedEachTaskId != null)
                {
                    SpecificDateActivityList = SpecificDateActivityList.Where(activity => activity.EachTaskId == SelectedEachTaskId).ToList();
                    SpecificDateNote         = SpecificDateNote.Where(note => note.EachTaskId == SelectedEachTaskId).ToList();
                }

                SpecificDateActivityList.ForEach(activity => ActivityLog.Add(activity));
                SpecificDateNote.ForEach(note => NoteList.Add(note));
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 12
0
        public void TaskStop(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsEachTaskIdEmpty())
                {
                    CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Msg1001"));
                    return;
                }

                Msg = TimeInfoModel.RegisterStop(SelectedEachTaskId);
                if (Msg != null)
                {
                    CommonViewModel.NotifySystemMessage(Msg);

                    if (Msg != GetLangMessage.GetMessage("Msg1020"))
                    {
                        // If the button pushing is invalid, return and not update the status.
                        return;
                    }
                }

                if (NotifyRestTime != null)
                {
                    NotifyRestTime.Cancel();
                }

                CommonViewModel.RecentSelectedEachTaskId = SelectedEachTaskId;

                // Update Recent status
                SetRecentInfo("Msg1012");
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 13
0
        async public void RegisterTaskData(object sender, RoutedEventArgs e)
        {
            try
            {
                string pattern = @"<.*?>";
                TaskData = Regex.Replace(TaskData, pattern, string.Empty);

                // Control Progress Dialog
                var progressDialog = new RegisterProgressDialog();
                var showingDialog  = progressDialog.ShowAsync();

                // Changes ValidFlag value of All tasks for this plan date to false
                // If there is a task data in TaskData, the ValidFlag value of the task will change to true after this below processing
                List <EachTask> specificDateClassificationData = GetSpecificDateEachTasks(PlanDate);
                foreach (EachTask classificationTask in specificDateClassificationData)
                {
                    EachTaskModel.ChangeValidFlag(classificationTask.EachTaskId, false);
                    List <EachTask> smallTaskList = GetSpecificTaskSmallTasks(classificationTask.EachTaskId);
                    foreach (EachTask smallTask in smallTaskList)
                    {
                        EachTaskModel.ChangeValidFlag(smallTask.EachTaskId, false);
                    }
                }

                if (!TaskData.StartsWith("#"))
                {
                    showingDialog.Cancel();
                    progressDialog.Hide();
                    CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Msg1001"));

                    return;
                }

                String TaskDataToRegister = "\r" + TaskData;

                TaskDataToRegister = TaskDataToRegister.Replace("\r\r", "\r");

                string[] largeTaskStrings   = TaskDataToRegister.Split("\r#");
                int      LargetTaskRank     = 1;
                bool     reviewRegisterFlag = false;

                foreach (string eachLargeTask in largeTaskStrings)
                {
                    if (string.IsNullOrWhiteSpace(eachLargeTask))
                    {
                        continue;
                    }

                    List <string> taskStrings = eachLargeTask.Split("\r-").ToList();
                    taskStrings = taskStrings.Select(str => str.Replace("\r", string.Empty)).ToList();

                    string classificationTask = taskStrings[0].TrimStart();

                    // If review task has been registerd already, change the flag to on to avoid registering twice
                    if (classificationTask == GetLangMessage.GetMessage("Msg2005"))
                    {
                        reviewRegisterFlag = true;
                    }


                    EachTask newClassificationTask = new EachTask()
                    {
                        PlanDate         = this.PlanDate,
                        Content          = classificationTask,
                        RegisteredDate   = DateTime.Now.ToLocalTime(),
                        ParentEachTaskId = string.Empty,
                        Rank             = LargetTaskRank,
                        ValidFlag        = true
                    };

                    // Checks if the task has been already registered by checking EachTaskId
                    string classificationId = EachTaskModel.GetEachTaskId(newClassificationTask);
                    if (string.IsNullOrWhiteSpace(classificationId))
                    {
                        classificationId = EachTaskModel.RegisterTask(newClassificationTask);
                    }
                    else
                    {
                        await EachTaskModel.UpdateTaskRankAsync(classificationId, LargetTaskRank);

                        EachTaskModel.ChangeValidFlag(classificationId, true);
                    }

                    int    smallTaskRank = 1;
                    string smallTaskId   = string.Empty;

                    foreach (string eachTaskString in taskStrings.GetRange(1, taskStrings.Count - 1))
                    {
                        EachTask newTask = new EachTask()
                        {
                            PlanDate         = this.PlanDate,
                            Content          = eachTaskString.Substring(1).TrimStart(),
                            RegisteredDate   = DateTimeOffset.Now.ToLocalTime(),
                            ParentEachTaskId = classificationId.ToString(),
                            Rank             = smallTaskRank,
                            ValidFlag        = true
                        };

                        smallTaskId = EachTaskModel.GetEachTaskId(newTask);
                        if (string.IsNullOrWhiteSpace(smallTaskId))
                        {
                            await EachTaskModel.RegisterTaskAsync(newTask);
                        }
                        else
                        {
                            await EachTaskModel.UpdateTaskRankAsync(smallTaskId, smallTaskRank);

                            EachTaskModel.ChangeValidFlag(smallTaskId, true);
                        }

                        smallTaskRank = smallTaskRank + 1;
                    }

                    LargetTaskRank = LargetTaskRank + 1;
                }

                // Add ReviewTask at last
                if (!reviewRegisterFlag)
                {
                    EachTask newClassificationTask = new EachTask()
                    {
                        PlanDate         = this.PlanDate,
                        Content          = GetLangMessage.GetMessage("Msg2005"),
                        RegisteredDate   = DateTime.Now.ToLocalTime(),
                        ParentEachTaskId = string.Empty,
                        Rank             = LargetTaskRank,
                        ValidFlag        = true
                    };

                    EachTaskModel.RegisterTask(newClassificationTask);
                }

                // Close Dialog Window
                showingDialog.Cancel();
                progressDialog.Hide();

                // Control Progress Dialog
                var completeDialog       = new RegisterCompleteDialog();
                var noticeCompleteDialog = completeDialog.ShowAsync();
                await Task.Delay(700);

                noticeCompleteDialog.Cancel();
                completeDialog.Hide();
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }
Esempio n. 14
0
        public void Search(object sender, RoutedEventArgs e)
        {
            try
            {
                CommonViewModel.RecentSearchWord = this.SearchWord;

                List <Memo> result = new List <Memo>();

                if (this.IsSearchConditionTaskName)
                {
                    result = MemoModel.SearchTaskName(SearchWord);
                    CommonViewModel.IsRecentSearchConditionTaskName    = true;
                    CommonViewModel.IsRecentSearchConditionMemoContent = false;
                }
                else
                {
                    result = MemoModel.SearchMemoContent(SearchWord);
                    CommonViewModel.IsRecentSearchConditionTaskName    = false;
                    CommonViewModel.IsRecentSearchConditionMemoContent = true;
                }

                SearchResult.Clear();

                result.ForEach(memo =>
                {
                    string targetContent = string.Empty;
                    string contentHtml   = string.Empty;
                    int index            = 0;

                    if (this.IsSearchConditionTaskName)
                    {
                        targetContent = memo.EachTask.Content.Replace("\r", "<br>");
                    }
                    else
                    {
                        targetContent = memo.Content.Replace("\r", "<br>");
                    }

                    while (true)
                    {
                        index = targetContent.IndexOf(this.SearchWord, StringComparison.OrdinalIgnoreCase);
                        if (index < 0)
                        {
                            contentHtml += targetContent;
                            break;
                        }
                        else if (index > 0)
                        {
                            contentHtml = targetContent.Substring(0, index);
                        }

                        contentHtml  += $"<strong>{targetContent.Substring(index, this.SearchWord.Length)}</strong>";
                        targetContent = targetContent.Substring(index + this.SearchWord.Length);
                    }
                    contentHtml = $"<span>{contentHtml}</span>";
                    EachSearchResult eachSearchResult = new EachSearchResult();

                    if (this.IsSearchConditionTaskName)
                    {
                        eachSearchResult.TaskName    = contentHtml;
                        eachSearchResult.Date        = $"[{memo.EachTask.PlanDate.Date.ToString().Substring(0, 10)}({memo.EachTask.PlanDate.DayOfWeek.ToString().Substring(0, 3)})]";
                        eachSearchResult.ContentHtml = memo.Content;
                    }
                    else
                    {
                        eachSearchResult.TaskName    = memo.EachTask.Content;
                        eachSearchResult.Date        = $"[{memo.EachTask.PlanDate.Date.ToString().Substring(0, 10)}({memo.EachTask.PlanDate.DayOfWeek.ToString().Substring(0, 3)})]";
                        eachSearchResult.ContentHtml = contentHtml;
                    }
                    SearchResult.Add(eachSearchResult);
                });

                CommonViewModel.RecentSearchResult = new ObservableCollection <EachSearchResult>(SearchResult);
            }
            catch
            {
                CommonViewModel.NotifySystemMessage(GetLangMessage.GetMessage("Exception"));
            }
        }