Exemplo n.º 1
0
        static async Task Test0Async()
        {
            StorageFactory factory = new FileStorageFactory(new Uri("https://tempuri.org/test"), @"c:\\data\\test");

            Console.WriteLine(factory);

            Storage storage = factory.Create();

            StorageContent content = new StringStorageContent("TEST");
            await storage.Save(new Uri(storage.BaseAddress, "doc1.txt"), content);
        }
Exemplo n.º 2
0
        public async Task UploadAndDelete()
        {
            var storage = FileStorageFactory.Create();

            foreach (var file in GetFiles())
            {
                var result = await storage.UploadAsync(file);

                Assert.True(result.Success);
                Assert.Equal(1, result.Data.Length);
                var delete = await storage.TryDeleteAsync(result.Data[0]);

                Assert.True(delete);
            }
        }
Exemplo n.º 3
0
        public async Task UploadPakcageAndDelete()
        {
            var storage = FileStorageFactory.Create();

            foreach (var file in Directory.GetFiles("zip"))
            {
                var result = await storage.UploadPackageAsync(file);

                Assert.True(result.Success);
                Assert.Equal(2, result.Data.Length); //压缩包内有两个文件
                foreach (var uploadOutput in result.Data)
                {
                    var delete = await storage.TryDeleteAsync(uploadOutput.FileUrl);

                    Assert.True(delete);
                }
            }
        }
Exemplo n.º 4
0
        protected override void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot)
        {
            services.Configure <PackageHashConfiguration>(configurationRoot.GetSection(PackageHashConfigurationSectionName));

            services.AddTransient <IEntityRepository <Package>, EntityRepository <Package> >();
            services.AddTransient <IPackageHashCalculator, PackageHashCalculator>();
            services.AddTransient <IBatchProcessor, BatchProcessor>();
            services.AddTransient <IResultRecorder, ResultRecorder>();
            services.AddTransient <IPackageHashProcessor, PackageHashProcessor>();
            services.AddTransient(s =>
            {
                var address            = new Uri("http://localhost");
                var fileStorageFactory = new FileStorageFactory(
                    address,
                    Directory.GetCurrentDirectory(),
                    s.GetRequiredService <ILogger <FileStorage> >());
                return(new DurableCursor(
                           new Uri(address, $"cursor_{_bucketNumber}_of_{_bucketCount}.json"),
                           fileStorageFactory.Create(),
                           DateTimeOffset.MinValue));
            });
        }
        public async Task ExecuteAsync(bool restart)
        {
            var fileSystemStorage = new FileStorageFactory(
                new Uri("http://localhost/"),
                Directory.GetCurrentDirectory(),
                verbose: false);

            var front = new DurableCursor(
                new Uri("http://localhost/cursor.json"),
                fileSystemStorage.Create(),
                DateTime.MinValue);

            if (restart)
            {
                await front.LoadAsync(CancellationToken.None);

                front.Value = DateTime.MinValue;
                await front.SaveAsync(CancellationToken.None);
            }

            var back = MemoryCursor.CreateMax();

            await _collector.RunAsync(front, back, CancellationToken.None);
        }