コード例 #1
0
        public async Task MoveToMain()
        {
            var count = await _configService.GetInt("StandbyToMainWorkerNum");

            var url = await this._configService.Get("MainServiceUrl");//this._sitePlatformDomainService.Get(file.SiteId).MainFileServiceUrl;

            var sharedSecret = await this._configService.Get("SharedSecret");

            var spec = new FileFilterSpecification(StorageType.Db);

            spec.ApplyPaging(1, count);
            spec.AddContentInclude();
            var files = this._fileDomainService.GetList(spec);

            if (files.Count > 0)
            {
                var tasks = files.Select(async(f) =>
                                         await Task.Run(async() =>
                {
                    LogHelper.Debug($"{DateTime.UtcNow} Begin Move: {f.FileKey}");
                    await MoveFile(f, url, sharedSecret);
                    LogHelper.Debug($"{DateTime.UtcNow} End Move: {f.FileKey}");
                })).ToArray();
                // wait until all finish
                await Task.WhenAll(tasks);
            }
        }
コード例 #2
0
ファイル: FileAppService.cs プロジェクト: DonyGu/FileService
        public async Task <List <FileDto> > Monitor(AuthJwt authJwt, int count)
        {
            var jwtResult = await this._fileAuthService.VerifyJwt(authJwt);

            List <FileDto> result = new List <FileDto>();
            var            spec   = new FileFilterSpecification(StorageType.Db);

            spec.ApplyPaging(1, count);
            var list = this._fileDomainService.GetList(spec);

            foreach (var item in list)
            {
                result.Add(new FileDto {
                    FileKey = item.FileKey, SiteId = item.SiteId, CreationTime = item.CreationTime, ExpireTime = item.ExpireTime
                });
            }
            return(result);
        }
コード例 #3
0
        public async Task DeleteAnExpiredFile()
        {
            var spec = new FileFilterSpecification(DateTime.UtcNow);

            spec.ApplyPaging(1, 1);
            spec.AddContentInclude();
            var files = this._fileDomainService.GetList(spec);

            if (files.Count > 0)
            {
                foreach (var item in files)
                {
                    try
                    {
                        await this._fileDomainService.Delete(item.FileKey);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error(ex, ex.Message);
                    }
                }
            }
        }
コード例 #4
0
 public IReadOnlyList <File> GetList(FileFilterSpecification spec)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
 public IReadOnlyList <File> GetList(FileFilterSpecification spec)
 {
     return(_repository.List(spec));
 }