Exemple #1
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);
            var id = this.ReadId(s);

            return fs.Delete(id);
        }
Exemple #2
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);
            var id = this.ReadId(s);

            return(fs.Delete(id));
        }
Exemple #3
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs       = new LiteFileStorage(engine);
            var id       = this.ReadId(s);
            var metadata = JsonSerializer.Deserialize(s).AsDocument;

            return(fs.SetMetadata(id, metadata));
        }
Exemple #4
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);
            var id = this.ReadId(s);
            var metadata = JsonSerializer.Deserialize(s).AsDocument;

            return fs.SetMetadata(id, metadata);
        }
Exemple #5
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);
            var id = this.ReadId(s);

            var filename = Path.GetFullPath(s.Scan(@"\s*.*").Trim());

            if (!File.Exists(filename)) throw new IOException("File " + filename + " not found");

            var file = fs.Upload(id, filename);

            return file.AsDocument;
        }
Exemple #6
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);
            var id = this.ReadId(s);

            var filename = Path.GetFullPath(s.Scan(@"\s*.*").Trim());

            if (!File.Exists(filename))
            {
                throw new IOException("File " + filename + " not found");
            }

            var file = fs.Upload(id, filename);

            return(file.AsDocument);
        }
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs       = new LiteFileStorage(engine);
            var id       = ReadId(s);
            var filename = s.Scan(@"\s*.*").Trim();

            var file = fs.FindById(id);

            if (file != null)
            {
                file.SaveAs(filename, true);

                return(file.AsDocument);
            }
            return(false);
        }
Exemple #8
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs          = new LiteFileStorage(engine);
            var id          = this.ReadId(s);
            var fileHandler = LitePlatform.Platform.FileHandler;

            var filename = s.Scan(@"\s*.*").Trim();

            if (!fileHandler.FileExists(filename))
            {
                throw new IOException("File " + filename + " not found");
            }

            var file = fs.Upload(id, filename);

            return(file.AsDocument);
        }
Exemple #9
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);

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

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

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

                return(new BsonArray(files));
            }
        }
Exemple #10
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);

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

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

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

                return new BsonArray(files);
            }
        }
Exemple #11
0
        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var fs = new LiteFileStorage(engine);
            var id = this.ReadId(s);
            var filename = s.Scan(@"\s*.*").Trim();

            var file = fs.FindById(id);

            if (file != null)
            {
                file.SaveAs(filename, true);

                return file.AsDocument;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// Creates a new instance of <see cref="LiteDBStorageRepository"/> attached to the given context
        /// </summary>
        /// <remarks>Limit per file is 2 GB</remarks>
        public LiteDBStorageRepository(ILiteDBContext dbContext)
        {
            Contract.Requires(dbContext != null);

            _fileStorage = dbContext.Database.FileStorage;
        }