public async Task <IActionResult> Index() { var retry = Policy.Handle <NullReferenceException>().WaitAndRetry(new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2) }); IndexViewModel model = null; var user = await GetCurrentUserAsync(); await retry.Execute(async() => { var allBuckets = new List <Bucket>(); var taskList = new List <Task>(); foreach (var app in user.MyApps) { async Task AddApp() { var appInfo = await _ossApiService.ViewMyBucketsAsync(await _appsContainer.AccessToken(app.AppId, app.AppSecret)); allBuckets.AddRange(appInfo.Buckets); } taskList.Add(AddApp()); } await Task.WhenAll(taskList); model = new IndexViewModel(user) { AllBuckets = allBuckets.GroupBy(t => t.BelongingAppId).OrderBy(t => t.Key) }; }); return(View(model)); }
public async Task <IActionResult> Index() { var user = await GetCurrentUserAsync(); var allBuckets = new List <Bucket>(); var taskList = new List <Task>(); foreach (var app in user.MyApps) { async Task AddApp() { var appInfo = await _ossApiService.ViewMyBucketsAsync(await _appsContainer.AccessToken(app.AppId, app.AppSecret)); allBuckets.AddRange(appInfo.Buckets); } taskList.Add(AddApp()); } await Task.WhenAll(taskList); var model = new IndexViewModel(user) { AllBuckets = allBuckets.GroupBy(t => t.BelongingAppId).OrderBy(t => t.Key) }; return(View(model)); }
public async Task Recover( DeveloperUser User, App ThisApp, CoreApiService coreApiService, OSSApiService ossApiService, AppsContainer appsContainer) { base.Recover(User, 1); var token = await appsContainer.AccessToken(ThisApp.AppId, ThisApp.AppSecret); var buckets = await ossApiService.ViewMyBucketsAsync(token); Buckets = buckets.Buckets; var grants = await coreApiService.AllUserGrantedAsync(token); Grants = grants.Grants; }
public async Task <IActionResult> Index() { var cuser = await GetCurrentUserAsync(); var allBuckets = new List <Bucket>(); foreach (var app in cuser.MyApps) { var appInfo = await _ossApiService.ViewMyBucketsAsync(await _appsContainer.AccessToken(app.AppId, app.AppSecret)); allBuckets.AddRange(appInfo.Buckets); } var model = new IndexViewModel(cuser) { AllBuckets = allBuckets }; return(View(model)); }
public async Task Recover( DeveloperUser user, App thisApp, CoreApiService coreApiService, OSSApiService ossApiService, AppsContainer appsContainer, SitesService sitesService) { base.RootRecover(user, 1); var token = await appsContainer.AccessToken(thisApp.AppId, thisApp.AppSecret); var buckets = await ossApiService.ViewMyBucketsAsync(token); Buckets = buckets.Buckets; var grants = await coreApiService.AllUserGrantedAsync(token); Grants = grants.Grants; var sites = await sitesService.ViewMySitesAsync(token); Sites = sites.Sites; }