private static ChapterRecord LoadChapterFromDataRow(DataRow row) { var mangaRecordKey = new Tuple <Guid, string>((Guid)row["ScraperId"], Convert.ToString(row["MangaId"])); var mangaRecord = MangaRecordsCache[mangaRecordKey]; if (mangaRecord == null) { mangaRecord = new MangaRecord() { MangaId = Convert.ToString(row["MangaId"]), MangaName = Convert.ToString(row["MangaName"]), Scraper = (Guid)row["ScraperId"], Url = row["MangaUrl"] as string }; MangaRecordsCache[mangaRecordKey] = mangaRecord; } var chapterRecord = new ChapterRecord() { ChapterId = Convert.ToString(row["ChapterId"]), ChapterName = Convert.ToString(row["ChapterName"]), Scraper = (Guid)row["ScraperId"], Url = Convert.ToString(row["ChapterUrl"]), MangaRecord = mangaRecord }; return(chapterRecord); }
private CoursePageRecord GetCurrentCoursePageRecord(RockContext rockContext) { CourseRecordService courseRecordService = new CourseRecordService(rockContext); ChapterRecordService chapterRecordService = new ChapterRecordService(rockContext); CoursePageRecordService coursePageRecordService = new CoursePageRecordService(rockContext); CourseRecord courseRecord = GetCourseRecord(courseRecordService); if (externalRedirectDebug.IsNotNullOrWhiteSpace()) { return(null); } if (courseRecord == null) { throw new Exception("This course does not exist or you are not authorized"); } ChapterRecord chapterRecord = GetNextChapterRecord(courseRecord, chapterRecordService); while (chapterRecord != null) { CoursePageRecord coursePageRecord = GetNextCoursePageRecord(coursePageRecordService, chapterRecord); if (coursePageRecord != null) { ViewState["coursePageRecordId"] = coursePageRecord.Id; return(coursePageRecord); } else { chapterRecord.CompletionDateTime = RockDateTime.Now; chapterRecord.Passed = chapterRecord.CoursePageRecords.Where(p => p.Passed).Count() >= chapterRecord.Chapter.CoursePages.Count(); rockContext.SaveChanges(); if (chapterRecord.Passed == false) { ShowFailedChapter(); return(null); } chapterRecord = GetNextChapterRecord(courseRecord, chapterRecordService); } } //if we got to this place the course is complete courseRecord.CompletionDateTime = RockDateTime.Now; courseRecord.Passed = courseRecord.ChapterRecords.Where(c => c.Passed).Count() >= courseRecord.Course.Chapters.Count(); rockContext.SaveChanges(); CourseRequirementHelper.UpdateCourseStatuses(courseRecord.CourseId, courseRecord.PersonAliasId, courseRecord.Passed); DisplayCompletion(); return(null); }
public void StartGame(ChapterRecord record) { if (record == null) { throw new ArgumentNullException("record"); } InitializeChapter(record.ChapterId); turnId = 0; StartNewTurnPhase(); }
private ChapterRecord GetNextChapterRecord(CourseRecord courseRecord, ChapterRecordService chapterRecordService) { var chapters = courseRecord.Course.Chapters.OrderBy(c => c.Order).ToList(); foreach (var chapter in chapters) { var chapterRecords = courseRecord.ChapterRecords .Where(cr => cr.ChapterId == chapter.Id); //If no records for this chapter make a new one if (!chapterRecords.Any()) { var chapterRecord = new ChapterRecord { Chapter = chapter, CourseRecord = courseRecord }; chapterRecordService.Add(chapterRecord); chapterRecordService.Context.SaveChanges(); return(chapterRecord); } //If there is an incomplete record select that one if (chapterRecords.Where(cr => cr.CompletionDateTime == null).Any()) { return(chapterRecords.Where(cr => cr.CompletionDateTime == null).FirstOrDefault()); } //If there are no passed records make a new one if (!chapterRecords.Where(cr => cr.Passed).Any()) { var chapterRecord = new ChapterRecord { Chapter = chapter, CourseRecord = courseRecord }; chapterRecordService.Add(chapterRecord); chapterRecordService.Context.SaveChanges(); return(chapterRecord); } //Continue loop because this chapter has been passed } return(null); }
// Start is called before the first frame update void Start() { TestLocalization(); activityManager = new GameActivityManager(this); gameManager = new GameManager(this); ChapterRecord record = ChapterRecord.NewGame(); gameManager.StartGame(record); RenderFieldMap(record.ChapterId); globalVariables = Global.Instance(); fieldObjectsRoot = this.transform.Find("FieldObjects"); InitializeObjects(); cancellableObjects = new List <GameObject>(); ///PlaceMenu(MenuId.ActionMenu, FDPosition.At(3, 3)); // ShowMessageDialog(1, "This is test"); }
private static DownloadedChapterInfo LoadDownloadInfoFromDataRow(DataRow row, ChapterRecord chapter) { return(new DownloadedChapterInfo(chapter) { Path = row["Path"] as string, Downloaded = Convert.ToDateTime(row["Downloaded"]), DownloadFolder = row["DownloadFolder"] as string, DownloadFormatProviderId = (Guid)row["FormatProviderId"] }); }
private CoursePageRecord GetNextCoursePageRecord(CoursePageRecordService coursePageRecordService, ChapterRecord chapterRecord) { var pages = chapterRecord.Chapter.CoursePages.OrderBy(p => p.Order); foreach (var page in pages) { var pageRecords = chapterRecord.CoursePageRecords .Where(r => r.CoursePageId == page.Id); //If no page record exists create one if (!pageRecords.Any()) { var pageRecord = new CoursePageRecord { CoursePage = page, ChapterRecord = chapterRecord }; coursePageRecordService.Add(pageRecord); coursePageRecordService.Context.SaveChanges(); return(pageRecord); } //Return incomplete page if (pageRecords.Where(r => r.CompletionDateTime == null).Any()) { return(pageRecords.Where(r => r.CompletionDateTime == null).FirstOrDefault()); } } return(null); //There are no more page records to complete for this chapter }