private void SetupIndexes(ILiteRepository repo)
 {
     repo.Database.GetCollection <RecordingSessionDto>().EnsureIndex(x => x.IsRunning);
     repo.Database.GetCollection <RecordingSessionDto>().EnsureIndex(x => x.GateId);
     repo.Database.GetCollection <CheckpointDto>().EnsureIndex(x => x.GateId);
     repo.Database.GetCollection <CheckpointDto>().EnsureIndex(x => x.Aggregated);
 }
        private ILiteQueryable <T> GetQueryable <T>(ILiteRepository repository) where T : EventBase
        {
            if (typeof(T) == typeof(Register))
            {
                return(repository
                       .Query <Register>(PostcrossingTrackerConstants.EventCollectionName)
                       .IncludeAll() as ILiteQueryable <T>);
            }

            if (typeof(T) == typeof(Send))
            {
                return(repository
                       .Query <Send>(PostcrossingTrackerConstants.EventCollectionName)
                       .IncludeAll() as ILiteQueryable <T>);
            }

            if (typeof(T) == typeof(SignUp))
            {
                return(repository
                       .Query <SignUp>(PostcrossingTrackerConstants.EventCollectionName)
                       .IncludeAll() as ILiteQueryable <T>);
            }

            if (typeof(T) == typeof(Upload))
            {
                return(repository
                       .Query <Upload>(PostcrossingTrackerConstants.EventCollectionName)
                       .IncludeAll() as ILiteQueryable <T>);
            }

            return(repository
                   .Query <EventBase>(PostcrossingTrackerConstants.EventCollectionName) as ILiteQueryable <T>);
        }
Пример #3
0
        public static T Upsert2 <T>(this ILiteRepository repository, Expression <Func <T, bool> > filter, T data, UpdateOptions options = null)
        {
            // 查找是否存在
            T exist = repository.Query <T>().Where(filter).FirstOrDefault();

            // 如果不存在,新建
            if (exist == null)
            {
                repository.Insert(data);
                return(data);
            }

            // 更新数据
            Type tt         = data.GetType();
            var  properties = tt.GetProperties().Where(p => options == null || options.Validate(p.Name));

            foreach (var prop in properties)
            {
                object value = prop.GetValue(data);
                // 给exist赋值
                prop.SetValue(exist, value);
            }

            // 更新到数据库
            repository.Upsert(exist);
            return(exist);
        }
Пример #4
0
        public UpdaterService(ILiteRepository liteRepository = null)
        {
            if (liteRepository == null)
            {
#if DEBUG
                var file = @"App_Data\QBData.db";
#else
                var appDAta = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var file    = Path.Combine(appDAta, @"QBTracker\QBData.db");
#endif
                this.liteRepository = new LiteRepository(file);
            }
            else
            {
                this.liteRepository = liteRepository;
                ProcessStartFile    = Process.GetCurrentProcess().MainModule?.FileName;
                EnsureUpdateEntry();
                updateEntry.ExeFile = ProcessStartFile;
                SaveUpdateEntry();
            }

            ApplicationVersion   = Assembly.GetExecutingAssembly().GetName().Version;
            TempAssembliesFolder = AppDomain.CurrentDomain.BaseDirectory;
            ReleaseUpdateUri     = "https://github.com/iQuarc/QBTracker/releases.atom";
        }
Пример #5
0
 private void SetupIndexes(ILiteRepository repo)
 {
     repo.Database.GetCollection <ClassDto>(Name <ClassDto>()).EnsureIndex(x => x.ChampionshipId);
     repo.Database.GetCollection <EventDto>(Name <EventDto>()).EnsureIndex(x => x.ChampionshipId);
     repo.Database.GetCollection <EventDto>(Name <EventDto>()).EnsureIndex(x => x.EndOfRegistration);
     repo.Database.GetCollection <SessionDto>(Name <SessionDto>()).EnsureIndex(x => x.EventId);
     repo.Database.GetCollection <SessionDto>(Name <SessionDto>()).EnsureIndex(x => x.ClassIds);
     repo.Database.GetCollection <RiderClassRegistrationDto>(Name <RiderClassRegistrationDto>()).EnsureIndex(x => x.ClassId);
     repo.Database.GetCollection <RiderClassRegistrationDto>(Name <RiderClassRegistrationDto>()).EnsureIndex(x => x.RiderProfileId);
     repo.Database.GetCollection <RiderClassRegistrationDto>(Name <RiderClassRegistrationDto>()).EnsureIndex(x => x.ChampionshipDtoId);
     repo.Database.GetCollection <RiderEventRegistrationDto>(Name <RiderEventRegistrationDto>()).EnsureIndex(x => x.ClassId);
     repo.Database.GetCollection <RiderEventRegistrationDto>(Name <RiderEventRegistrationDto>()).EnsureIndex(x => x.EventId);
     repo.Database.GetCollection <RiderEventRegistrationDto>(Name <RiderEventRegistrationDto>()).EnsureIndex(x => x.RiderClassRegistrationId);
 }
Пример #6
0
 public LiteDataSession(ILiteRepository repository)
 => _repository = repository;
Пример #7
0
 private ILiteQueryable <Subtheme> GetQueryable(ILiteRepository repository)
 {
     return(repository
            .Query <Subtheme>()
            .IncludeAll());
 }
Пример #8
0
        // void IRepository.ValidateDatabase(ILiteRepository repo)
        // {
        //     repo.Query<Checkpoint>().OrderBy(x => x.Id).FirstOrDefault();
        //     repo.Query<Tag>().OrderBy(x => x.Id).FirstOrDefault();
        // }

        private void SetupIndexes(ILiteRepository repo)
        {
            repo.Database.GetCollection <Checkpoint>().EnsureIndex(x => x.Timestamp);
            repo.Database.GetCollection <Tag>().EnsureIndex(x => x.DiscoveryTime);
            repo.Database.GetCollection <SubscriptionDto>().EnsureIndex(x => x.SenderId);
        }
Пример #9
0
        // void IRepository.ValidateDatabase(ILiteRepository repo)
        // {
        //     repo.Query<AuthToken>().OrderBy(x => x.Token).FirstOrDefault();
        // }

        private void SetupIndexes(ILiteRepository repo)
        {
            repo.Database.GetCollection <AuthToken>().EnsureIndex(x => x.Updated);
            repo.Database.GetCollection <AuthToken>().EnsureIndex(x => x.ServiceName);
        }
 private ILiteQueryable <BricksetUser> GetQueryable(ILiteRepository repository)
 {
     return(repository
            .Query <BricksetUser>()
            .IncludeAll());
 }
Пример #11
0
 public LiteDataStore(ILiteRepository repository)
 => _repository = repository;
Пример #12
0
 private ILiteQueryable <Postcard> GetQueryable(ILiteRepository repository)
 {
     return(repository
            .Query <Postcard>(PostcrossingTrackerConstants.PostcardCollectionName)
            .IncludeAll());
 }