예제 #1
0
        private int GetDBVersion()
        {
            if (!Repo.TableExists(DBVersionTableName))
            {
                Repo.CreateTable(typeof(DBVersion));
                InsertDBVersion(0);
                return(0);
            }

            DBVersion dbversion = Repo.Select <DBVersion>().FirstOrDefault();

            if (dbversion == null)
            {
                return(-1);
            }

            int version;

            try
            {
                version = int.Parse(dbversion.Version);
            }
            catch
            {
                version = -1;
            }

            return(version);
        }
예제 #2
0
        public void Create(IDBService repo)
        {
            repo.CreateTable(typeof(Volume));

            // Book
            // CREATE TABLE "Book" ( `Id` TEXT NOT NULL, `Title` TEXT NOT NULL, `Author` TEXT, `PublishDate` TEXT, `Edition` TEXT, `Editors` TEXT, `EditionPublishDate` TEXT, `ISBN` TEXT, `Comment` TEXT, PRIMARY KEY(`BookId`) )
            repo.CreateTable(typeof(Book));
            repo.CreateTable(typeof(Chapter));
            repo.CreateTable(typeof(PageRef));

            repo.CreateTable(typeof(Author));
            repo.CreateTable(typeof(BookAuthor));

            // Citation
            // CREATE TABLE `Citation` ( `Id` TEXT NOT NULL, `Citation1` TEXT NOT NULL, `Citation2` TEXT NOT NULL, `CreatedDate` TEXT NOT NULL, `EditedDate` TEXT NOT NULL, PRIMARY KEY(`CitationId`) )
            repo.CreateTable(typeof(Citation));
            repo.CreateTable(typeof(RawCitation));

            //if (CreateTable(TableRawCitationName,
            //    "`Id` TEXT, " +
            //    "`Fragment` TEXT NOT NULL, " +
            //    "`PageStart` INT NOT NULL, " +
            //    "`PageStop` INT NOT NULL, " +
            //    "`GlyphStart` INT NOT NULL, " +
            //    "`GlyphStop` INT NOT NULL, " +
            //    "`Rectangles` TEXT NOT NULL, " +
            //    "`Date` TEXT NOT NULL ",
            //    "`Id`"))
            //{
            //    CreateIndex(TableCitationName, "Code");
            //}



            // Categories
            //

            repo.CreateTable(typeof(Category));

            // Storage
            //CREATE TABLE "Storage"( `Id` TEXT NOT NULL, `Hash` TEXT NOT NULL, `SourceFileName` TEXT NOT NULL, `SourceFilePath` TEXT NOT NULL, `StorageFileName` TEXT NOT NULL UNIQUE, `Author` TEXT, `Date` TEXT, `Comment` TEXT, PRIMARY KEY(`Id`))
            repo.CreateTable(typeof(Storage));

            // CitationCategory

            repo.CreateTable(typeof(CitationCategory));

            repo.CreateTable(typeof(History));
        }
예제 #3
0
        public void Create(IDBService repo)
        {
            repo.CreateTable(typeof(Volume));
            repo.CreateTable(typeof(Series));
            repo.CreateTable(typeof(VolumeSeries));

            // References
            repo.CreateTable(typeof(Book));
            repo.CreateTable(typeof(Chapter));
            repo.CreateTable(typeof(SubChapter));
            repo.CreateTable(typeof(Paragraph));
            repo.CreateTable(typeof(Page));

            repo.CreateTable(typeof(Author));
            repo.CreateTable(typeof(BookAuthor));
            repo.CreateTable(typeof(SeriesAuthor));
            repo.CreateTable(typeof(VolumeAuthor));


            // Citation
            // CREATE TABLE `Citation` ( `Id` TEXT NOT NULL, `Citation1` TEXT NOT NULL, `Citation2` TEXT NOT NULL, `CreatedDate` TEXT NOT NULL, `EditedDate` TEXT NOT NULL, PRIMARY KEY(`CitationId`) )
            repo.CreateTable(typeof(Citation));
            repo.CreateTable(typeof(RawCitation));

            //if (CreateTable(TableRawCitationName,
            //    "`Id` TEXT, " +
            //    "`Fragment` TEXT NOT NULL, " +
            //    "`PageStart` INT NOT NULL, " +
            //    "`PageStop` INT NOT NULL, " +
            //    "`GlyphStart` INT NOT NULL, " +
            //    "`GlyphStop` INT NOT NULL, " +
            //    "`Rectangles` TEXT NOT NULL, " +
            //    "`Date` TEXT NOT NULL ",
            //    "`Id`"))
            //{
            //    CreateIndex(TableCitationName, "Code");
            //}



            // Categories
            //

            if (repo.CreateTable(typeof(Category)))
            {
                // Uncategorized
                repo.InsertOrUpdate(new Category
                {
                    Id          = Id.Empty,
                    Code        = "None",
                    Name        = "Uncategorized",
                    Description = "No category selected"
                });
                repo.InsertOrUpdate(new Category
                {
                    Id          = Id.NewId(),
                    Code        = "CT1",
                    Name        = "Category one",
                    Description = "First category"
                });
                repo.InsertOrUpdate(new Category
                {
                    Id          = Id.NewId(),
                    Code        = "CT2",
                    Name        = "Category two",
                    Description = "Second category"
                });
                repo.InsertOrUpdate(new Category
                {
                    Id          = Id.NewId(),
                    Code        = "CT3",
                    Name        = "Category three",
                    Description = "Third category"
                });
            }

            repo.CreateTable(typeof(CitationCategory));


            // Storage
            //CREATE TABLE "Storage"( `Id` TEXT NOT NULL, `Hash` TEXT NOT NULL, `SourceFileName` TEXT NOT NULL, `SourceFilePath` TEXT NOT NULL, `StorageFileName` TEXT NOT NULL UNIQUE, `Author` TEXT, `Date` TEXT, `Comment` TEXT, PRIMARY KEY(`Id`))
            repo.CreateTable(typeof(Storage));

            repo.CreateTable(typeof(History));
        }