/// <summary> /// 初期化処理 /// </summary> /// <returns>実行結果</returns> public bool Initialize() { this.taskInfoRoot = new TaskInfoRoot(); KeyInfo.Initialize(); var path = Utils.GetFullPath(TaskListSavePath); if (File.Exists(path)) { var text = File.ReadAllText(path); var jsonObj = JsonConvert.DeserializeObject <TaskInfoRoot>(text); instance.taskInfoRoot = jsonObj; var rootGroupKey = TaskGroupInfo.GetRootGroup().Key; if (instance.taskInfoRoot.TaskGroupListJsonObj.Any(x => x.Key.Equals(rootGroupKey))) { var item = instance.taskInfoRoot.TaskGroupListJsonObj.First(x => x.Key.Equals(rootGroupKey)); TaskGroupInfo.OverriteRootGroup(item); } var defaultGroupKey = TaskGroupInfo.GetDefaultGroup().Key; if (instance.taskInfoRoot.TaskGroupListJsonObj.Any(x => x.Key.Equals(defaultGroupKey))) { var item = instance.taskInfoRoot.TaskGroupListJsonObj.First(x => x.Key.Equals(defaultGroupKey)); TaskGroupInfo.OverriteDefaultGroup(item); } // 全グループに対してキーの再生成 foreach (var taskGroupInfo in instance.taskInfoRoot.TaskGroupListJsonObj) { if (!KeyInfo.IsCreatedKeyGroup(taskGroupInfo.Key)) { var keyGroup = KeyInfo.CreateKeyInfoGroup(); taskGroupInfo.ChildGroups.Clear(); var filetered = instance.taskInfoRoot.TaskGroupListJsonObj.Where(x => x.ParentGroup != null && x.ParentGroup.Equals(taskGroupInfo.Key)).ToList(); if (filetered.Any()) { foreach (var groupInfo in filetered) { if (!KeyInfo.IsCreatedKeyGroup(groupInfo.Key)) { var keyGroupChildGroup = KeyInfo.CreateKeyInfoGroup(); groupInfo.Key = keyGroupChildGroup; } groupInfo.ParentGroup = keyGroup; taskGroupInfo.ChildGroups.Add(groupInfo.Key); } } taskGroupInfo.Key = keyGroup; } foreach (var childTaskItem in taskGroupInfo.ChildTaskItems) { if (!KeyInfo.IsCreatedKeyTask(taskGroupInfo.Key, childTaskItem.Key)) { var keyGroup = KeyInfo.CreateKeyInfoTask(taskGroupInfo.Key); childTaskItem.Key = keyGroup; } childTaskItem.Group = taskGroupInfo.Key; } if (!instance.taskInfoRoot.TaskGroupList.ContainsKey(taskGroupInfo.Key)) { instance.taskInfoRoot.TaskGroupList.Add(taskGroupInfo.Key, taskGroupInfo); } } } else { instance.taskInfoRoot.AddTaskGroup(TaskGroupInfo.GetRootGroup(), null); instance.taskInfoRoot.AddTaskGroup(TaskGroupInfo.GetDefaultGroup(), TaskGroupInfo.GetRootGroup()); } return(true); }