示例#1
0
        /// <summary>
        /// Fills the modified data for the response
        /// </summary>
        /// <param name="response">Response to send</param>
        /// <param name="currentUser">Current user</param>
        /// <returns>Task</returns>
        private async Task FillModifiedData(PersonalDataResponse response, GoNorthUser currentUser)
        {
            response.ModifiedData = new List <TrimmedModifiedData>();

            List <AikaQuest> quests = await _questDbAccess.GetQuestsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(quests.Select(p => new TrimmedModifiedData {
                ObjectType   = "Quest",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaChapterDetail> chapterDetail = await _chapterDetailDbAccess.GetChapterDetailsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(chapterDetail.Select(p => new TrimmedModifiedData {
                ObjectType   = "ChapterDetail",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaChapterOverview> chapterOverview = await _chapterOverviewDbAccess.GetChapterOverviewByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(chapterOverview.Select(p => new TrimmedModifiedData {
                ObjectType   = "ChapterOverview",
                Name         = "ChapterOverview",
                ModifiedDate = p.ModifiedOn
            }));

            List <EvneSkill> skills = await _skillDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(skills.Select(p => new TrimmedModifiedData {
                ObjectType   = "Skill",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KortistoNpc> npcs = await _npcDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(npcs.Select(p => new TrimmedModifiedData {
                ObjectType   = "Npc",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <StyrItem> items = await _itemDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(items.Select(p => new TrimmedModifiedData {
                ObjectType   = "Item",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <ExportTemplate> exportTemplates = await _exportTemplateDbAccess.GetExportTemplatesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(exportTemplates.Select(p => new TrimmedModifiedData {
                ObjectType   = "ExportTemplate",
                Name         = "Template " + p.TemplateType.ToString() + " " + p.Category.ToString(),
                ModifiedDate = p.ModifiedOn
            }));

            List <KartaMap> maps = await _mapDbAccess.GetMapsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(maps.Select(p => new TrimmedModifiedData {
                ObjectType   = "Map",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KirjaPage> pages = await _pageDbAccess.GetPagesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(pages.Select(p => new TrimmedModifiedData {
                ObjectType   = "WikiPage",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KirjaPageVersion> pageVersions = await _pageVersionDbAccess.GetPageVersionsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(pageVersions.Select(p => new TrimmedModifiedData {
                ObjectType   = "WikiPageVersion",
                Name         = string.Format("{0} #{1}", p.Name, p.VersionNumber),
                ModifiedDate = p.ModifiedOn
            }));

            List <TaleDialog> dialogs = await _taleDbAccess.GetDialogsByModifiedUser(currentUser.Id);

            Dictionary <string, KortistoNpc> dialogNpcs = (await _npcDbAccess.ResolveFlexFieldObjectNames(dialogs.Select(n => n.RelatedObjectId).ToList())).ToDictionary(n => n.Id);

            foreach (TaleDialog curDialog in dialogs)
            {
                string npcName = "DELETED";
                if (dialogNpcs.ContainsKey(curDialog.RelatedObjectId))
                {
                    npcName = dialogNpcs[curDialog.RelatedObjectId].Name;
                }
                response.ModifiedData.Add(new TrimmedModifiedData {
                    ObjectType   = "Dialog",
                    Name         = npcName,
                    ModifiedDate = curDialog.ModifiedOn
                });
            }

            List <TaleConfigEntry> taleConfigEntries = await _taleConfigDbAccess.GetConfigEntriesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(taleConfigEntries.Select(p => new TrimmedModifiedData {
                ObjectType   = "TaleConfig",
                Name         = p.Key,
                ModifiedDate = p.ModifiedOn
            }));

            List <TaskBoard> taskBoards = await _taskBoardDbAccess.GetTaskBoardsByModifiedUser(currentUser.Id);

            foreach (TaskBoard curBoard in taskBoards)
            {
                if (curBoard.ModifiedBy == currentUser.Id)
                {
                    response.ModifiedData.Add(new TrimmedModifiedData {
                        ObjectType   = "TaskBoard",
                        Name         = curBoard.Name,
                        ModifiedDate = curBoard.ModifiedOn
                    });
                }

                List <TaskGroup> modifiedGroups = curBoard.TaskGroups.Where(t => t.ModifiedBy == currentUser.Id).ToList();
                if (modifiedGroups.Count > 0)
                {
                    response.ModifiedData.AddRange(modifiedGroups.Select(p => new TrimmedModifiedData {
                        ObjectType   = "TaskGroup",
                        Name         = p.Name,
                        ModifiedDate = p.ModifiedOn
                    }));
                }

                List <GoNorthTask> tasks = curBoard.TaskGroups.SelectMany(p => p.Tasks.Where(t => t.ModifiedBy == currentUser.Id)).ToList();
                if (tasks.Count > 0)
                {
                    response.ModifiedData.AddRange(tasks.Select(p => new TrimmedModifiedData {
                        ObjectType   = "Task",
                        Name         = p.Name,
                        ModifiedDate = p.ModifiedOn
                    }));
                }
            }

            List <GoNorthTaskType> taskGroupTypes = await _taskGroupTypeDbAccess.GetTaskTypesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(taskGroupTypes.Select(p => new TrimmedModifiedData {
                ObjectType   = "TaskGroupType",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <GoNorthTaskType> taskTypes = await _taskTypeDbAccess.GetTaskTypesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(taskTypes.Select(p => new TrimmedModifiedData {
                ObjectType   = "TaskType",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));
        }
        /// <summary>
        /// Fills the modified data for the response
        /// </summary>
        /// <param name="response">Response to send</param>
        /// <param name="currentUser">Current user</param>
        /// <returns>Task</returns>
        private async Task FillModifiedData(PersonalDataResponse response, GoNorthUser currentUser)
        {
            response.ModifiedData = new List <TrimmedModifiedData>();

            List <AikaQuest> quests = await _questDbAccess.GetQuestsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(quests.Select(p => new TrimmedModifiedData {
                ObjectType   = "Quest",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaQuest> questRecycleBin = await _questDbAccess.GetRecycleBinQuestsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(questRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "QuestRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaQuest> questImplementationSnapshots = await _questImplementationSnapshotDbAccess.GetSnapshotsModifiedByUsers(currentUser.Id);

            response.ModifiedData.AddRange(questImplementationSnapshots.Select(p => new TrimmedModifiedData {
                ObjectType   = "QuestImplementationSnapshot",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaChapterDetail> chapterDetail = await _chapterDetailDbAccess.GetChapterDetailsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(chapterDetail.Select(p => new TrimmedModifiedData {
                ObjectType   = "ChapterDetail",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaChapterDetail> chapterDetailRecycleBin = await _chapterDetailDbAccess.GetRecycleBinChapterDetailsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(chapterDetailRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "ChapterDetailRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaChapterOverview> chapterOverview = await _chapterOverviewDbAccess.GetChapterOverviewByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(chapterOverview.Select(p => new TrimmedModifiedData {
                ObjectType   = "ChapterOverview",
                Name         = "ChapterOverview",
                ModifiedDate = p.ModifiedOn
            }));

            List <AikaChapterOverview> chapterOverviewRecycleBin = await _chapterOverviewDbAccess.GetRecycleBinChapterOverviewByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(chapterOverviewRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "ChapterOverviewRecycleBin",
                Name         = "ChapterOverview",
                ModifiedDate = p.ModifiedOn
            }));

            List <EvneSkill> skills = await _skillDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(skills.Select(p => new TrimmedModifiedData {
                ObjectType   = "Skill",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <EvneSkill> skillsRecyleBin = await _skillDbAccess.GetRecycleBinFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(skillsRecyleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "SkillRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <EvneSkill> skillsImplementationSnapshots = await _skillImplementationSnapshotDbAccess.GetSnapshotsModifiedByUsers(currentUser.Id);

            response.ModifiedData.AddRange(skillsImplementationSnapshots.Select(p => new TrimmedModifiedData {
                ObjectType   = "SkillImplementationSnapshot",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <FlexFieldImportFieldValuesResultLog> skillsFieldValuesLogs = await _skillImportFieldValuesLogDbAccess.GetImportLogsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(skillsFieldValuesLogs.Select(p => new TrimmedModifiedData {
                ObjectType   = "SkillFieldValueImportLog",
                Name         = p.FileName,
                ModifiedDate = p.ModifiedOn
            }));

            List <EvneSkill> skillTemplates = await _skillTemplateDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(skillTemplates.Select(p => new TrimmedModifiedData {
                ObjectType   = "SkillTemplate",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <EvneSkill> skillsTemplateRecyleBin = await _skillTemplateDbAccess.GetRecycleBinFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(skillsTemplateRecyleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "SkillTemplateRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KortistoNpc> npcs = await _npcDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(npcs.Select(p => new TrimmedModifiedData {
                ObjectType   = "Npc",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KortistoNpc> npcsRecycleBin = await _npcDbAccess.GetRecycleBinFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(npcsRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "NpcRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KortistoNpc> npcImplementationSnapshots = await _npcImplementationSnapshotDbAccess.GetSnapshotsModifiedByUsers(currentUser.Id);

            response.ModifiedData.AddRange(npcImplementationSnapshots.Select(p => new TrimmedModifiedData {
                ObjectType   = "NpcImplementationSnapshot",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <FlexFieldImportFieldValuesResultLog> npcsFieldValuesLogs = await _npcImportFieldValuesLogDbAccess.GetImportLogsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(npcsFieldValuesLogs.Select(p => new TrimmedModifiedData {
                ObjectType   = "NpcFieldValueImportLog",
                Name         = p.FileName,
                ModifiedDate = p.ModifiedOn
            }));

            List <KortistoNpc> npcTemplates = await _npcTemplateDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(npcTemplates.Select(p => new TrimmedModifiedData {
                ObjectType   = "NpcTemplate",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KortistoNpc> npcTemplatesRecycleBin = await _npcTemplateDbAccess.GetRecycleBinFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(npcTemplatesRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "NpcTemplateRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <StyrItem> items = await _itemDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(items.Select(p => new TrimmedModifiedData {
                ObjectType   = "Item",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <StyrItem> itemsRecyleBin = await _itemDbAccess.GetRecycleBinFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(itemsRecyleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "ItemReycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <StyrItem> itemImplementationSnapshots = await _itemImplementationSnapshotDbAccess.GetSnapshotsModifiedByUsers(currentUser.Id);

            response.ModifiedData.AddRange(itemImplementationSnapshots.Select(p => new TrimmedModifiedData {
                ObjectType   = "ItemImplementationSnapshot",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <FlexFieldImportFieldValuesResultLog> itemsFieldValuesLogs = await _itemImportFieldValuesLogDbAccess.GetImportLogsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(itemsFieldValuesLogs.Select(p => new TrimmedModifiedData {
                ObjectType   = "ItemFieldValueImportLog",
                Name         = p.FileName,
                ModifiedDate = p.ModifiedOn
            }));

            List <StyrItem> itemTemplates = await _itemTemplateDbAccess.GetFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(itemTemplates.Select(p => new TrimmedModifiedData {
                ObjectType   = "ItemTemplate",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <StyrItem> itemTemplatesRecyleBin = await _itemTemplateDbAccess.GetRecycleBinFlexFieldObjectsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(itemTemplatesRecyleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "ItemTemplateReycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <ExportTemplate> exportTemplates = await _exportTemplateDbAccess.GetExportTemplatesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(exportTemplates.Select(p => new TrimmedModifiedData {
                ObjectType   = "ExportTemplate",
                Name         = "Template " + p.TemplateType.ToString() + " " + p.Category.ToString(),
                ModifiedDate = p.ModifiedOn
            }));

            List <ExportTemplate> exportTemplatesRecycleBin = await _exportTemplateDbAccess.GetRecycleBinExportTemplatesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(exportTemplatesRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "ExportTemplateRecycleBin",
                Name         = "Template " + p.TemplateType.ToString() + " " + p.Category.ToString(),
                ModifiedDate = p.ModifiedOn
            }));


            List <IncludeExportTemplate> includeExportTemplates = await _includeExportTemplateDbAccess.GetIncludeTemplatesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(includeExportTemplates.Select(p => new TrimmedModifiedData {
                ObjectType   = "IncludeExportTemplate",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <IncludeExportTemplate> includeExportTemplatesRecycleBin = await _includeExportTemplateDbAccess.GetRecycleBinIncludeTemplatesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(includeExportTemplatesRecycleBin.Select(p => new TrimmedModifiedData {
                ObjectType   = "IncludeExportTemplateRecycleBin",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));


            List <ObjectExportSnippet> objectExportSnippets = await _objectExportSnippetDbAccess.GetExportSnippetByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(objectExportSnippets.Select(p => new TrimmedModifiedData {
                ObjectType   = "ObjectExportSnippet",
                Name         = p.SnippetName,
                ModifiedDate = p.ModifiedOn
            }));

            List <KartaMap> maps = await _mapDbAccess.GetMapsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(maps.Select(p => new TrimmedModifiedData {
                ObjectType   = "Map",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KirjaPage> pages = await _pageDbAccess.GetPagesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(pages.Select(p => new TrimmedModifiedData {
                ObjectType   = "WikiPage",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <KirjaPageVersion> pageVersions = await _pageVersionDbAccess.GetPageVersionsByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(pageVersions.Select(p => new TrimmedModifiedData {
                ObjectType   = "WikiPageVersion",
                Name         = string.Format("{0} #{1}", p.Name, p.VersionNumber),
                ModifiedDate = p.ModifiedOn
            }));

            List <TaleDialog> dialogs = await _taleDbAccess.GetDialogsByModifiedUser(currentUser.Id);

            Dictionary <string, KortistoNpc> dialogNpcs = (await _npcDbAccess.ResolveFlexFieldObjectNames(dialogs.Select(n => n.RelatedObjectId).ToList())).ToDictionary(n => n.Id);

            foreach (TaleDialog curDialog in dialogs)
            {
                string npcName = "DELETED";
                if (dialogNpcs.ContainsKey(curDialog.RelatedObjectId))
                {
                    npcName = dialogNpcs[curDialog.RelatedObjectId].Name;
                }
                response.ModifiedData.Add(new TrimmedModifiedData {
                    ObjectType   = "Dialog",
                    Name         = npcName,
                    ModifiedDate = curDialog.ModifiedOn
                });
            }

            List <TaleDialog> dialogsRecyleBin = await _taleDbAccess.GetRecycleBinDialogsByModifiedUser(currentUser.Id);

            Dictionary <string, KortistoNpc> dialogRecyleBinNpcs = (await _npcDbAccess.ResolveRecycleBinFlexFieldObjectNames(dialogsRecyleBin.Select(n => n.RelatedObjectId).ToList())).ToDictionary(n => n.Id);

            foreach (TaleDialog curDialog in dialogsRecyleBin)
            {
                string npcName = "DELETED";
                if (dialogRecyleBinNpcs.ContainsKey(curDialog.RelatedObjectId))
                {
                    npcName = dialogRecyleBinNpcs[curDialog.RelatedObjectId].Name;
                }
                response.ModifiedData.Add(new TrimmedModifiedData {
                    ObjectType   = "DialogRecyleBin",
                    Name         = npcName,
                    ModifiedDate = curDialog.ModifiedOn
                });
            }

            List <TaleDialog> dialogsSnapshots = await _taleImplementationSnapshotDbAccess.GetSnapshotsModifiedByUsers(currentUser.Id);

            Dictionary <string, KortistoNpc> dialogSnapshotNpcs = (await _npcDbAccess.ResolveFlexFieldObjectNames(dialogsSnapshots.Select(n => n.RelatedObjectId).ToList())).ToDictionary(n => n.Id);

            foreach (TaleDialog curDialogSnapshot in dialogsSnapshots)
            {
                string npcName = "DELETED";
                if (dialogNpcs.ContainsKey(curDialogSnapshot.RelatedObjectId))
                {
                    npcName = dialogNpcs[curDialogSnapshot.RelatedObjectId].Name;
                }
                response.ModifiedData.Add(new TrimmedModifiedData {
                    ObjectType   = "DialogSnapshot",
                    Name         = npcName,
                    ModifiedDate = curDialogSnapshot.ModifiedOn
                });
            }

            List <StateMachine> stateMachines = await _stateMachineDbAccess.GetStateMachinesByModifiedUser(currentUser.Id);

            Dictionary <string, KortistoNpc> stateMachineNpcs = (await _npcDbAccess.ResolveFlexFieldObjectNames(stateMachines.Select(n => n.RelatedObjectId).ToList())).ToDictionary(n => n.Id);

            foreach (StateMachine curStateMachine in stateMachines)
            {
                string npcName = "DELETED";
                if (stateMachineNpcs.ContainsKey(curStateMachine.RelatedObjectId))
                {
                    npcName = stateMachineNpcs[curStateMachine.RelatedObjectId].Name;
                }
                response.ModifiedData.Add(new TrimmedModifiedData {
                    ObjectType   = "StateMachine",
                    Name         = npcName,
                    ModifiedDate = curStateMachine.ModifiedOn
                });
            }

            List <StateMachine> stateMachineSnapshots = await _stateMachineSnapsshotDbAccess.GetSnapshotsModifiedByUsers(currentUser.Id);

            Dictionary <string, KortistoNpc> stateMachineSnapshotNpcs = (await _npcDbAccess.ResolveFlexFieldObjectNames(stateMachineSnapshots.Select(n => n.RelatedObjectId).ToList())).ToDictionary(n => n.Id);

            foreach (StateMachine curStateMachine in stateMachineSnapshots)
            {
                string npcName = "DELETED";
                if (stateMachineSnapshotNpcs.ContainsKey(curStateMachine.RelatedObjectId))
                {
                    npcName = stateMachineSnapshotNpcs[curStateMachine.RelatedObjectId].Name;
                }
                response.ModifiedData.Add(new TrimmedModifiedData {
                    ObjectType   = "StateMachineSnapshot",
                    Name         = npcName,
                    ModifiedDate = curStateMachine.ModifiedOn
                });
            }


            List <JsonConfigEntry> jsonConfigEntries = await _projectConfigDbAccess.GetJsonConfigEntriesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(jsonConfigEntries.Select(p => new TrimmedModifiedData {
                ObjectType   = "JsonConfig",
                Name         = p.Key,
                ModifiedDate = p.ModifiedOn
            }));

            List <MiscProjectConfig> miscConfigEntries = await _projectConfigDbAccess.GetMiscConfigEntriesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(miscConfigEntries.Select(p => new TrimmedModifiedData {
                ObjectType   = "MiscConfig",
                Name         = "Miscellaneous Config",
                ModifiedDate = p.ModifiedOn
            }));

            List <TaskBoard> taskBoards = await _taskBoardDbAccess.GetTaskBoardsByModifiedUser(currentUser.Id);

            foreach (TaskBoard curBoard in taskBoards)
            {
                if (curBoard.ModifiedBy == currentUser.Id)
                {
                    response.ModifiedData.Add(new TrimmedModifiedData {
                        ObjectType   = "TaskBoard",
                        Name         = curBoard.Name,
                        ModifiedDate = curBoard.ModifiedOn
                    });
                }

                List <TaskGroup> modifiedGroups = curBoard.TaskGroups.Where(t => t.ModifiedBy == currentUser.Id).ToList();
                if (modifiedGroups.Count > 0)
                {
                    response.ModifiedData.AddRange(modifiedGroups.Select(p => new TrimmedModifiedData {
                        ObjectType   = "TaskGroup",
                        Name         = p.Name,
                        ModifiedDate = p.ModifiedOn
                    }));
                }

                List <GoNorthTask> tasks = curBoard.TaskGroups.SelectMany(p => p.Tasks.Where(t => t.ModifiedBy == currentUser.Id)).ToList();
                if (tasks.Count > 0)
                {
                    response.ModifiedData.AddRange(tasks.Select(p => new TrimmedModifiedData {
                        ObjectType   = "Task",
                        Name         = p.Name,
                        ModifiedDate = p.ModifiedOn
                    }));
                }
            }

            List <GoNorthTaskType> taskGroupTypes = await _taskGroupTypeDbAccess.GetTaskTypesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(taskGroupTypes.Select(p => new TrimmedModifiedData {
                ObjectType   = "TaskGroupType",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            List <GoNorthTaskType> taskTypes = await _taskTypeDbAccess.GetTaskTypesByModifiedUser(currentUser.Id);

            response.ModifiedData.AddRange(taskTypes.Select(p => new TrimmedModifiedData {
                ObjectType   = "TaskType",
                Name         = p.Name,
                ModifiedDate = p.ModifiedOn
            }));

            response.SelectedProject = await _projectDbAccess.GetUserSelectedProject(currentUser.Id);
        }
示例#3
0
        /// <summary>
        /// Deletes the modified data for the user
        /// </summary>
        /// <param name="user">User</param>
        /// <returns>Task</returns>
        private async Task DeleteModifiedData(GoNorthUser user)
        {
            List <AikaQuest> quests = await _questDbAccess.GetQuestsByModifiedUser(user.Id);

            foreach (AikaQuest curQuest in quests)
            {
                curQuest.ModifiedBy = Guid.Empty.ToString();
                curQuest.ModifiedOn = DateTimeOffset.UtcNow;
                await _questDbAccess.UpdateQuest(curQuest);
            }

            List <AikaChapterDetail> chapterDetail = await _chapterDetailDbAccess.GetChapterDetailsByModifiedUser(user.Id);

            foreach (AikaChapterDetail curChapterDetail in chapterDetail)
            {
                curChapterDetail.ModifiedBy = Guid.Empty.ToString();
                curChapterDetail.ModifiedOn = DateTimeOffset.UtcNow;
                await _chapterDetailDbAccess.UpdateChapterDetail(curChapterDetail);
            }

            List <AikaChapterOverview> chapterOverview = await _chapterOverviewDbAccess.GetChapterOverviewByModifiedUser(user.Id);

            foreach (AikaChapterOverview curOverview in chapterOverview)
            {
                curOverview.ModifiedBy = Guid.Empty.ToString();
                curOverview.ModifiedOn = DateTimeOffset.UtcNow;
                await _chapterOverviewDbAccess.UpdateChapterOverview(curOverview);
            }

            List <EvneSkill> skills = await _skillDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (EvneSkill curSkill in skills)
            {
                curSkill.ModifiedBy = Guid.Empty.ToString();
                curSkill.ModifiedOn = DateTimeOffset.UtcNow;
                await _skillDbAccess.UpdateFlexFieldObject(curSkill);
            }

            List <KortistoNpc> npcs = await _npcDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (KortistoNpc curNpc in npcs)
            {
                curNpc.ModifiedBy = Guid.Empty.ToString();
                curNpc.ModifiedOn = DateTimeOffset.UtcNow;
                await _npcDbAccess.UpdateFlexFieldObject(curNpc);
            }

            List <StyrItem> items = await _itemDbAccess.GetFlexFieldObjectsByModifiedUser(user.Id);

            foreach (StyrItem curItem in items)
            {
                curItem.ModifiedBy = Guid.Empty.ToString();
                curItem.ModifiedOn = DateTimeOffset.UtcNow;
                await _itemDbAccess.UpdateFlexFieldObject(curItem);
            }

            List <ExportTemplate> exportTemplates = await _exportTemplateDbAccess.GetExportTemplatesByModifiedUser(user.Id);

            foreach (ExportTemplate curTemplate in exportTemplates)
            {
                curTemplate.ModifiedBy = Guid.Empty.ToString();
                curTemplate.ModifiedOn = DateTimeOffset.UtcNow;
                await _exportTemplateDbAccess.UpdateTemplate(curTemplate);
            }

            List <KartaMap> maps = await _mapDbAccess.GetMapsByModifiedUser(user.Id);

            foreach (KartaMap curMap in maps)
            {
                curMap.ModifiedBy = Guid.Empty.ToString();
                curMap.ModifiedOn = DateTimeOffset.UtcNow;
                await _mapDbAccess.UpdateMap(curMap);
            }

            List <KirjaPage> pages = await _pageDbAccess.GetPagesByModifiedUser(user.Id);

            foreach (KirjaPage curPage in pages)
            {
                curPage.ModifiedBy = Guid.Empty.ToString();
                curPage.ModifiedOn = DateTimeOffset.UtcNow;
                await _pageDbAccess.UpdatePage(curPage);
            }

            List <KirjaPageVersion> pageVersions = await _pageVersionDbAccess.GetPageVersionsByModifiedUser(user.Id);

            foreach (KirjaPageVersion curVersion in pageVersions)
            {
                curVersion.ModifiedBy = Guid.Empty.ToString();
                curVersion.ModifiedOn = DateTimeOffset.UtcNow;
                await _pageVersionDbAccess.UpdatePageVersion(curVersion);
            }

            List <TaleDialog> dialogs = await _taleDbAccess.GetDialogsByModifiedUser(user.Id);

            foreach (TaleDialog curDialog in dialogs)
            {
                curDialog.ModifiedBy = Guid.Empty.ToString();
                curDialog.ModifiedOn = DateTimeOffset.UtcNow;
                await _taleDbAccess.UpdateDialog(curDialog);
            }

            List <JsonConfigEntry> jsonConfigEntries = await _projectConfigDbAccess.GetJsonConfigEntriesByModifiedUser(user.Id);

            foreach (JsonConfigEntry curConfig in jsonConfigEntries)
            {
                curConfig.ModifiedBy = Guid.Empty.ToString();
                curConfig.ModifiedOn = DateTimeOffset.UtcNow;
                await _projectConfigDbAccess.UpdateJsonConfig(curConfig);
            }

            List <MiscProjectConfig> miscConfigEntries = await _projectConfigDbAccess.GetMiscConfigEntriesByModifiedUser(user.Id);

            foreach (MiscProjectConfig curMiscConfig in miscConfigEntries)
            {
                curMiscConfig.ModifiedBy = Guid.Empty.ToString();
                curMiscConfig.ModifiedOn = DateTimeOffset.UtcNow;
                await _projectConfigDbAccess.UpdateMiscConfig(curMiscConfig);
            }

            List <TaskBoard> taskBoards = await _taskBoardDbAccess.GetTaskBoardsByModifiedUser(user.Id);

            foreach (TaskBoard curBoard in taskBoards)
            {
                if (curBoard.ModifiedBy == user.Id)
                {
                    curBoard.ModifiedBy = Guid.Empty.ToString();
                    curBoard.ModifiedOn = DateTimeOffset.UtcNow;
                }

                List <TaskGroup> modifiedGroups = curBoard.TaskGroups.Where(t => t.ModifiedBy == user.Id).ToList();
                foreach (TaskGroup curTaskGroup in modifiedGroups)
                {
                    curTaskGroup.ModifiedBy = Guid.Empty.ToString();
                    curTaskGroup.ModifiedOn = DateTimeOffset.UtcNow;
                }

                List <GoNorthTask> tasks = curBoard.TaskGroups.SelectMany(p => p.Tasks.Where(t => t.ModifiedBy == user.Id)).ToList();
                if (tasks.Count > 0)
                {
                    foreach (GoNorthTask curTask in tasks)
                    {
                        curTask.ModifiedBy = Guid.Empty.ToString();
                        curTask.ModifiedOn = DateTimeOffset.UtcNow;
                    }
                }

                await _taskBoardDbAccess.UpdateTaskBoard(curBoard);
            }

            List <GoNorthTaskType> taskGroupTypes = await _taskGroupTypeDbAccess.GetTaskTypesByModifiedUser(user.Id);

            foreach (GoNorthTaskType curType in taskGroupTypes)
            {
                curType.ModifiedBy = Guid.Empty.ToString();
                curType.ModifiedOn = DateTimeOffset.UtcNow;
                await _taskGroupTypeDbAccess.UpdateTaskType(curType);
            }

            List <GoNorthTaskType> taskTypes = await _taskTypeDbAccess.GetTaskTypesByModifiedUser(user.Id);

            foreach (GoNorthTaskType curType in taskTypes)
            {
                curType.ModifiedBy = Guid.Empty.ToString();
                curType.ModifiedOn = DateTimeOffset.UtcNow;
                await _taskTypeDbAccess.UpdateTaskType(curType);
            }
        }