public async Task <ResultSingle <App> > CreateAppAsync(AppServiceTier tier, App app = null, bool doCache = false, bool throwIfError = true) { App theApp = app == null ? _editApp : app; theApp.ServiceTierId = tier.Id; ResultSingle <App> result = await ResultSingleUI <App> .WaitForObjectAsync( throwIfError, theApp, new CachedHttpRequest <App, ResultSingle <App> >( Backend.CreateAsync), doCache); if (result.Code == 0) { EditApp = result.Data.Payload; _editApp.OwnedBy = Backend.Permit.User; if (throwIfError && _editApp.Status != "assigned") { string message = "Failed to initialize the app. Please contact support."; //Helpers.ErrorHandler.Exception(message, string.Empty); throw new Exception(message); } if (app != null) { _editApp.CopyTo(app); } } return(result); }
public static async Task QueryServicesAsync(BackendService <UserT> backend) { AppService serviceSeed = new AppService(); ResultMultiple <AppService> result = await ResultMultipleUI <AppService> .WaitForObjectsAsync( true, serviceSeed, new CachedHttpRequest <AppService, ResultMultiple <AppService> >( backend.QueryAsyncListAsync), true); if (result.Code < 0) { return; } _appServices = result.Data.Payload; AppServiceTier tierSeed = new AppServiceTier(); ResultMultiple <AppServiceTier> resultTier; foreach (AppService service in _appServices) { tierSeed.OwnedBy = service; resultTier = await ResultMultipleUI <AppServiceTier> .WaitForObjectsAsync( true, tierSeed, new CachedHttpRequest <AppServiceTier, ResultMultiple <AppServiceTier> >( backend.QueryAsyncListAsync), true); if (result.Code == 0) { service.Tiers = resultTier.Data.Payload; } } }
public static string[] TranslateFeaturesIncluded(AppServiceTier tier) { List <string> values = JsonConvert.DeserializeObject <List <string> >( tier.FeaturesIncluded); return(values.ToArray <string>()); }
public async Task CreateDefaultStorageServiceAsync() { // Only one tier available at present AppServiceTier defaultTier = StorageService.Tiers.First(); await CreateSubscription(defaultTier); await QueryAppSubscriptions(); CreateServicesTables(); }
public async Task SwitchAppServiceTierAsync(AppServiceTier newTier) { AppServiceSubscription subscription = EditApp.Subscriptions.FirstOrDefault( x => (x.ServiceTier.OwnedBy as AppService).Type == "app"); if (subscription != null) { await RemoveSubscriptionAsync(subscription); } await CreateSubscription(newTier); await QueryAppSubscriptions(); ResetAppServiceTable(); }
public async Task SetAppUpgradingAsync(bool upgrading = true) { _upgradeAppServiceTier = null; if (upgrading) { await QueryAppUpgradeServiceTiersAsync(); } else { _upgradableAppTiers.Clear(); } ResetAppServiceTable(); }
public static ServiceTableItem CreateServiceTableItem(AppServiceTier tier) { ServiceTableItem item = new ServiceTableItem(); item.Tag = tier.Tag; item.Name = tier.Name; item.ProvidedBy = (tier.OwnedBy as AppService).Name; item.Period = tier.Period; item.Cost = tier.ItemCost; item.Type = tier.Type; item.FeaturesAll = TranslateFeaturesAll(tier.OwnedBy as AppService); item.FeaturesIncluded = TranslateFeaturesIncluded(tier); item.Tier = tier; return(item); }
public async Task <ResultSingle <AppServiceTier> > UpdateAppUpgradeServiceTierAsync( AppService service = null, AppServiceTier teir = null, Deployment deployment = null, bool doCache = true, bool throwIfError = true) { AppService theService = service == null ? AppService : service; Deployment theDeployment = deployment == null ? _editApp.Deployment : deployment; AppServiceTier theTier = teir == null ? _upgradeAppServiceTier : teir; theService.OwnedBy = theDeployment; _upgradeAppServiceTier.OwnedBy = theService; return(await ResultSingleUI <AppServiceTier> .WaitForObjectAsync( throwIfError, theTier, new CachedHttpRequest <AppServiceTier, ResultSingle <AppServiceTier> >( Backend.UpdateAsync), doCache)); }
public void ResetAppServiceTable() { ObservableCollection <AppServiceTier> appTiers = null; AppServiceTier selectTier = null; if (_upgradableAppTiers.Any()) { appTiers = _upgradableAppTiers; selectTier = _upgradeAppServiceTier; } else { if (_editApp.Subscriptions != null) { var subscription = _editApp.Subscriptions.FirstOrDefault( x => (x.ServiceTier.OwnedBy as AppService).Type == "app"); selectTier = subscription.ServiceTier; SelectedAppServiceTag = (selectTier.OwnedBy as AppService).Tag; } else { SelectedAppServiceTag = DefaultAppServiceTag; } appTiers = AppService.Tiers; } AppTierTable.Clear(); ServiceTableItem tableItem = null; foreach (var tier in appTiers) { tableItem = CreateServiceTableItem(tier); AppTierTable.Add(tableItem); if (selectTier != null && selectTier.Id == tableItem.Tier.Id) { SelectedAppServiceTableItem = tableItem; } } OnPropertyChanged("AppTierTable"); }
public async Task <ResultMultiple <AppServiceTier> > QueryAppUpgradeServiceTiersAsync( AppService service = null, Deployment deployment = null, bool doCache = true, bool throwIfError = true) { AppService theService = service == null ? AppService : service; Deployment theDeployment = deployment == null ? _editApp.Deployment : deployment; theService.OwnedBy = theDeployment; AppServiceTier tierSeed = new AppServiceTier(); tierSeed.OwnedBy = theService; ResultMultiple <AppServiceTier> result = await ResultMultipleUI <AppServiceTier> .WaitForObjectsAsync( true, tierSeed, new CachedHttpRequest <AppServiceTier, ResultMultiple <AppServiceTier> >( Backend.QueryAsyncListAsync), true); if (result.Code >= 0) { _upgradableAppTiers = result.Data.Payload; } return(result); }
public async Task <ResultMultiple <Forest> > QueryAppServiceTierLocationsAsync(AppServiceTier teir, bool doCache = false, bool throwIfError = true) { Forest forestSeeder = new Forest(); forestSeeder.OwnedBy = teir; return(await ResultMultipleUI <Forest> .WaitForObjectsAsync( throwIfError, forestSeeder, new CachedHttpRequest <Forest, ResultMultiple <Forest> >( Backend.QueryAsyncListAsync), doCache)); }
public void UpgradeAppServiceTier(AppServiceTier newTier) { _upgradeAppServiceTier = newTier; ResetAppServiceTable(); }
public async Task <ResultSingle <AppServiceSubscription> > CreateSubscription(AppServiceTier tier, bool doCache = true, bool throwIfError = true) { AppServiceSubscription subscription = new AppServiceSubscription(); subscription.OwnedBy = _editApp; subscription.ServiceTier = tier; subscription.AppServiceTierId = tier.Id; return(await ResultSingleUI <AppServiceSubscription> .WaitForObjectAsync( throwIfError, subscription, new CachedHttpRequest <AppServiceSubscription, ResultSingle <AppServiceSubscription> >( Backend.CreateAsync), doCache)); }