Ejemplo n.º 1
0
        public void Maitenance(TimeSpan expiredTime, int maxCount)
        {
            DateTime expiredDateTime = DateTime.Now - expiredTime;

            foreach (var fileInfo in _fileStorage.FindAll().Where(x => x.Metadata.TryGetValue("updateAt", out var val) && (DateTime)val < expiredDateTime).ToArray())
            {
                _fileStorage.Delete(fileInfo.Id);
            }

            foreach (var fileInfo in _fileStorage.FindAll().OrderByDescending(x => x.UploadDate).Skip(maxCount).ToArray())
            {
                _fileStorage.Delete(fileInfo.Id);
            }
        }
Ejemplo n.º 2
0
 public IEnumerable <TFile> GetAll(OptionsFilter options = null)
 {
     foreach (LiteFileInfo fileInfo in _fileStorage.FindAll())
     {
         yield return(fileInfo.ToStorageFile <TFile>());
     }
 }
Ejemplo n.º 3
0
        public ThumbnailCacheManager(
            LiteDatabase liteDatabase
            )
        {
            _fileStorage = liteDatabase.FileStorage;
#if DEBUG && true
            foreach (var file in _fileStorage.FindAll().ToArray())
            {
                _fileStorage.Delete(file.Id);
            }
#endif
            _httpClient = new HttpClient();
        }
Ejemplo n.º 4
0
Archivo: Find.cs Proyecto: apkd/LiteDB
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);

            if (s.HasTerminated)
            {
                var files = fs.FindAll().Select(x => x.AsDocument);

                display.WriteResult(new BsonArray(files));
            }
            else
            {
                var id = this.ReadId(s);

                var files = fs.Find(id).Select(x => x.AsDocument);

                display.WriteResult(new BsonArray(files));
            }
        }
Ejemplo n.º 5
0
        public void Execute(LiteEngine engine, StringScanner s, Display display, InputCommand input, Env env)
        {
            var fs = new LiteStorage(engine);

            if (s.HasTerminated)
            {
                var files = fs.FindAll().Select(x => x.AsDocument);

                display.WriteResult(new BsonArray(files));
            }
            else
            {
                var id = this.ReadId(s);

                var files = fs.Find(id).Select(x => x.AsDocument);

                display.WriteResult(new BsonArray(files));
            }
        }
Ejemplo n.º 6
0
        public IEnumerable <BsonValue> Execute(StringScanner s, LiteEngine engine)
        {
            var fs = new LiteStorage(engine);
            IEnumerable <LiteFileInfo> files;

            if (s.HasTerminated)
            {
                files = fs.FindAll();
            }
            else
            {
                var id = ReadId(s);

                s.ThrowIfNotFinish();

                files = fs.Find(id);
            }

            foreach (var file in files.Select(x => x.AsDocument))
            {
                yield return(file);
            }
        }