public void UpdateBookVersion(string filePath)
        {
            _serverBookList = FileSettingsHelper <BaobaoBookList> .LoadSetting(filePath);

            if (_serverBookList == null)
            {
                return;
            }

            bool gotNewBook = false;

            foreach (var book in _serverBookList.Books)
            {
                var existingBook = GetExistingBook(book.Name);
                if (existingBook == null || existingBook.Version < book.Version)
                {
                    gotNewBook = true;
                    AWSHelper.Instance.DownloadFile(Path.Combine(ResourceBase, book.Name),
                                                    Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DownloadPath, book.Name)).Forget();
                }
            }

            if (!gotNewBook)
            {
                UpdateBookList();
            }
        }
        public void LoadExamPaper(BaobaoBook book)
        {
            ExamPaper paper = null;

            AnswerList.Clear();
            QuestionList.Clear();
            if (book != null)
            {
                if (!_books.ContainsKey(book) || _books[book] == null)
                {
                    string examPaper = book.Name;
                    paper = FileSettingsHelper <ExamPaper> .LoadSetting(Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, examPaper));

                    _books[book] = paper;
                }
                else
                {
                    paper = _books[book];
                }
            }
            if (paper != null)
            {
                foreach (var question in paper.Questions)
                {
                    QuestionList.Add(question);
                }

                if (QuestionList.Count > 0)
                {
                    _currentQuestionIndex = -1;
                    CurrentQuestionIndex  = 0;
                }
            }
        }
        public BaobaoModel(string indexFileName)
        {
            X1LogHelper.LogLevel = (int)X1EventLogEntryType.Verbose;
            _localBookList       = FileSettingsHelper <BaobaoBookList> .LoadSetting() ?? new BaobaoBookList();

            IndexFileName = indexFileName;
            UpdateBookList(false);
            AWSHelper.Instance.OnFileAvailable += Download_OnFileAvailable;
            AWSHelper.Instance.DownloadFile(Path.Combine(ResourceBase, IndexFileName),
                                            Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DownloadPath, IndexFileName)).Forget();
            BaobaoSpellingModel = new BaobaoSpellingModel();
        }
Beispiel #4
0
 public static ExamPaper LoadQuestion(string name)
 {
     return(FileSettingsHelper <ExamPaper> .LoadSetting(Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, name)));
 }