示例#1
0
        public void AddBook(string bookPath)
        {
            lock (_updateBookLock)
            {
                var bookName = Path.GetFileName(bookPath);
                if (String.IsNullOrEmpty(bookName))
                {
                    return;
                }
                var storage = ZibaobaoLibContext.Instance.PersistentStorage;
                var dbPath  = Path.Combine(storage.DataPath, bookName);
                storage.CopyFile(bookPath, dbPath);
                var newBook = _serverBookList.Books.FirstOrDefault(o => o.Name == bookName);
                if (newBook == null)
                {
                    return;
                }

                var book = GetExistingBook(bookName);
                if (book != null)
                {
                    _localBookList.Books.Remove(book);
                }

                _localBookList.Books.Add(newBook);
                FileSettingsHelper <BaobaoBookList> .SaveSetting(_localBookList);
            }

            UpdateBookList();
        }
示例#2
0
        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();
            }
        }
示例#3
0
        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;
                }
            }
        }
示例#4
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();
        }
示例#5
0
 public static ExamPaper LoadQuestion(string name)
 {
     return(FileSettingsHelper <ExamPaper> .LoadSetting(Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, name)));
 }
示例#6
0
 public static void SaveQuestion(ExamPaper examPaper, string name)
 {
     FileSettingsHelper <ExamPaper> .SaveSetting(examPaper, Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, name));
 }