Example #1
0
        public async static Task <KitabDB> InstanceDBAsync()
        {
            var path = WebConfigurationManager.AppSettings["app_data"];
            //var path = HostingEnvironment.MapPath("~/App_Data/Bijbel");

            var kitab = await KitabDB.LoadFromDiskAsync(path);

            return(kitab);
        }
Example #2
0
        public async Task MustLoadFromDisk()
        {
            var baseF = @"c:\temp\bijbel";

            Trace.TraceInformation("Starting...");
            var kitabDb = await KitabDB.LoadFromDiskAsync(baseF, false);

            var words = kitabDb.Contents.Words;
        }
Example #3
0
        public void Start()
        {
            var start = Environment.TickCount;

            kitabDb = KitabDB.LoadFromDiskAsync(baseF, false).Result;
            Debug.WriteLine("Loading KitabDB took {0} ms", Environment.TickCount - start);

            start   = Environment.TickCount;
            kitabDb = KitabDB.LoadFromDiskAsync(baseF, false).Result;
            Debug.WriteLine("Loading KitabDB including the cache took {0} ms", Environment.TickCount - start);
        }
Example #4
0
        public void Init()
        {
            var connectionString     = ConfigurationManager.ConnectionStrings["bijbel2"].ConnectionString;
            var connectionStringLite = ConfigurationManager.ConnectionStrings["bijbel"].ConnectionString;
            //var _options = new DbContextOptionsBuilder<DbSqlContext>()
            //    .UseSqlite(connectionString)
            //    .Options;
            var _options = new DbContextOptionsBuilder <DbSqlContext>()
                           .UseSqlServer(connectionString)
                           .Options;

            dbSqlContext = new DbSqlContext(_options);
            var optionsLite = new DbContextOptionsBuilder <DbSqlContext>().UseSqlite(connectionStringLite).Options;

            dbSqliteContext = new DbSqlContext(optionsLite);

            _repo = new BijbelRepository(dbSqliteContext);
            try
            {
                //dbSqliteContext.Database.EnsureDeleted();
                //dbSqliteContext.Database.EnsureCreated();
            }
            catch (InvalidOperationException inv)
            {
                throw inv;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            try
            {
                dbSqlContext.Database.EnsureDeleted();
                dbSqlContext.Database.EnsureCreated();
            }
            catch (InvalidOperationException inv)
            {
                throw inv;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            var mapConfig = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Peshitta.Infrastructure.Models.Book, Peshitta.Infrastructure.Sqlite.Model.Book>()
                .ForMember(m => m.abbrevation, opt => opt.MapFrom(m => m.abbreviation ?? m.Title.Substring(0, 2)));
                cfg.CreateMap <Peshitta.Infrastructure.Models.BookEdition, Peshitta.Infrastructure.Sqlite.Model.bookedition>().
                ForMember(m => m.keywords, opt => opt.MapFrom(map => map.keywords != null ? string.Join(",", map.keywords): null));
                cfg.CreateMap <Peshitta.Infrastructure.Models.Text, Peshitta.Infrastructure.Sqlite.Model.Text>();
                cfg.CreateMap <Peshitta.Infrastructure.Models.words, Peshitta.Infrastructure.Sqlite.Model.words>();
                cfg.CreateMap <Peshitta.Infrastructure.Models.BookChapter, Peshitta.Infrastructure.Sqlite.Model.BookChapter>();
                cfg.CreateMap <Peshitta.Infrastructure.Models.BookChapterAlinea, Peshitta.Infrastructure.Sqlite.Model.BookChapterAlinea>();
                cfg.CreateMap <Peshitta.Infrastructure.Models.TextWords, Peshitta.Infrastructure.Sqlite.Model.TextWords>();
                cfg.CreateMap <Peshitta.Infrastructure.Models.TextWordsHistory, Peshitta.Infrastructure.Sqlite.Model.TextWordsHistory>();
            });

            mapper = mapConfig.CreateMapper();
            var start = Environment.TickCount;

            kitabDb = KitabDB.LoadFromDiskAsync(baseF, false).Result;
            Debug.WriteLine("Loading KitabDB took {0} ms", Environment.TickCount - start);

            start   = Environment.TickCount;
            kitabDb = KitabDB.LoadFromDiskAsync(baseF, false).Result;
            Debug.WriteLine("Loading KitabDB including the cache took {0} ms", Environment.TickCount - start);
        }