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);
            }
        }
Exemplo n.º 2
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);
                    }
                }
            }
        }