public override async Task <IProviderResponse <ICollection <TEntity> > > ProcessMultipleAsync(Func <IBucket, Task <IOperationResult <TServiceEntity>[]> > operations) { IProviderResponse <ICollection <TEntity> > response; try { var results = await operations(_client); foreach (var result in results) { if (result.ShouldRetry() || !result.Success) { //Todo //Logger } } response = MapResponse(results); } catch (Exception ex) { //Todo //_logger ex response = new ProviderResponse <ICollection <TEntity> >() { Success = false, Message = ex.Message, ResponseStatus = Couchbase.IO.ResponseStatus.InternalError.ToString("f"), Exception = ex }; } return(response); }
public override async Task <IProviderResponse <TEntity> > ProcessAsync(Func <IBucket, Task <IOperationResult <TServiceEntity> > > operation) { IProviderResponse <TEntity> response; try { var result = await operation(_client); if (result.ShouldRetry()) { result = await operation(_client); } response = MapResponse(result); } catch (Exception ex) { //Todo //_logger ex response = new ProviderResponse <TEntity>() { Success = false, Message = ex.Message, ResponseStatus = Couchbase.IO.ResponseStatus.InternalError.ToString("f"), Exception = ex }; } return(response); }
public override async Task <IProviderResponse <TEntityFragment> > ProcessFragmentAsync <TEntityFragment>(Func <IBucket, Task <IDocumentFragment <TSvcFragmentEntity> > > operation, string fragmentKey) { IProviderResponse <TEntityFragment> response; try { var result = await operation(_client); if (result.ShouldRetry()) { result = await operation(_client); } response = MapResponse <TEntityFragment>(result, fragmentKey); } catch (Exception ex) { //Todo //_logger ex response = new ProviderResponse <TEntityFragment>() { Success = false, Message = ex.Message, ResponseStatus = Couchbase.IO.ResponseStatus.InternalError.ToString("f"), Exception = ex }; } return(response); }
public void CreateResponse_CreatedResponse_ThrowsNoException() { var user = _initializer.IdentityRepository.GetBy(x => x.Providers.Count > 0).First(); var order = _initializer.OrderRepository.GetBy(x => x.Creator.Id != user.Id).First(); var orderResponse = new OrderResponse { Comment = "Comment to find", Creator = user, Order = order, Provider = user.Providers.First(), Price = 300, CreatedAt = DateTime.Now }; _initializer.OrderResponseRepository.Create(orderResponse); _initializer.CommitProvider.CommitChanges(); var expectedOrder = _initializer.OrderRepository.GetBy(x => x.Id == order.Id).Single(); var expected = new ProviderResponse { Comment = "Comment", Provider = _initializer.IdentityRepository.GetBy(x => x.Id == user.Id).Single().Providers.First(), Order = expectedOrder, Creator = expectedOrder.Creator }; Assert.That(() => _initializer.ProviderService.CreateResponse(expected), Throws.Nothing); var actual = _initializer.ProviderResponseRepository.GetBy(x => x.Comment == expected.Comment).Single(); Assert.AreEqual(expected, actual); }
public override void LoadChildren() { var worker = new BackgroundWorker(); worker.DoWork += (s, e) => { dispatcher.BeginInvoke((Action)(() => Children.Clear())); var id = (ushort)instance.ID; ProviderResponse <VcapFilesResult> result = provider.GetFiles(app.Parent, app, "/", id); if (result.Response == null) { Messenger.Default.Send(new NotificationMessage <string>(result.Message, Messages.ErrorMessage)); return; } dispatcher.BeginInvoke((Action)(() => { foreach (VcapFilesResult.FilesResultData dir in result.Response.Directories) { base.Children.Add(new FolderTreeViewItemViewModel(dir.Name, dir.Name, app, id)); } foreach (VcapFilesResult.FilesResultData file in result.Response.Files) { base.Children.Add(new FileTreeViewItemViewModel(file.Name, file.Name, app, id)); } })); }; worker.RunWorkerAsync(); }
private void UpdateApp() { Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.UpdateApp, (confirmed) => { if (confirmed) { UpdateViewModel viewModel = null; Messenger.Default.Send(new NotificationMessageAction <UpdateViewModel>(Messages.GetUpdateAppData, vm => viewModel = vm)); var worker = new BackgroundWorker { WorkerReportsProgress = true }; SetProgressTitle("Update Application"); worker.ProgressChanged += WorkerProgressChanged; worker.DoWork += (s, e) => { worker.ReportProgress(10, "Updating Application: " + viewModel.SelectedApplication.Name); ProviderResponse <bool> result = provider.Update( viewModel.SelectedCloud, viewModel.SelectedApplication, viewModel.PushFromDirectory); if (!result.Response) { worker.ReportProgress(-1, result.Message); return; } worker.ReportProgress(75, "Refreshing Application: " + viewModel.SelectedApplication.Name); ProviderResponse <Application> appResult = provider.GetApplication(viewModel.SelectedApplication, viewModel.SelectedCloud); if (appResult.Response == null) { worker.ReportProgress(-1, appResult.Message); return; } e.Result = appResult.Response; }; worker.RunWorkerCompleted += (s, e) => { var result = e.Result as Application; if (result == null) { return; } Cloud cloud = provider.Clouds.SingleOrDefault((c) => c.ID == viewModel.SelectedCloud.ID); if (cloud != null) { Application application = cloud.Applications.SingleOrDefault((i) => i.Name == result.Name); if (application != null) { application.Merge(result); } } Messenger.Default.Send(new ProgressMessage(100, "Application Updated.")); }; worker.RunWorkerAsync(); Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.Progress, c => { })); } })); }
public HttpResponseMessage Put(int id, Provider provider) { //quick check to determine if the provider is a valid provider? if (id != provider.ProviderId) { throw new HttpResponseException(HttpStatusCode.NotFound); } ProviderResponse response = null; using (var db = new ClientsProvidersDbEntities()) { response = Mapper.Map <Provider, ProviderResponse>(provider); db.Providers.Add(provider); try { db.SaveChanges(); } catch (Exception ex) { var myError = ex.Message; } return(Request.CreateResponse(HttpStatusCode.OK, response)); } }
private void Refresh() { var worker = new BackgroundWorker { WorkerReportsProgress = true }; SetProgressTitle("Refresh Application"); worker.ProgressChanged += WorkerProgressChanged; worker.DoWork += (s, e) => { worker.ReportProgress(30, "Refreshing Application: " + SelectedApplication.Name); ProviderResponse <Application> appResult = provider.GetApplication(SelectedApplication, Cloud); if (appResult.Response == null) { worker.ReportProgress(-1, appResult.Message); return; } e.Result = appResult.Response; }; worker.RunWorkerCompleted += (s, e) => { var result = e.Result as Application; if (result != null) { RefreshSelectedApplication(result); } Messenger.Default.Send(new ProgressMessage(100, "Application Refreshed.")); applicationStarting = false; }; worker.RunWorkerAsync(); Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.Progress, c => { })); }
private void SelectedApplicationPropertyChanged(object sender, PropertyChangedEventArgs e) { ApplicationErrorMessage = String.Empty; var worker = new BackgroundWorker(); worker.DoWork += (s, args) => { ProviderResponse <bool> result = provider.UpdateApplication(SelectedApplication, Cloud); if (!result.Response) { dispatcher.BeginInvoke((Action)(() => ApplicationErrorMessage = result.Message)); return; } ProviderResponse <Application> appResult = provider.GetApplication(SelectedApplication, Cloud); if (appResult.Response == null) { dispatcher.BeginInvoke((Action)(() => ApplicationErrorMessage = appResult.Message)); return; } args.Result = appResult.Response; }; worker.RunWorkerCompleted += (s, args) => { var result = args.Result as Application; if (result != null) { RefreshSelectedApplication(result); } }; worker.RunWorkerAsync(); }
public void DeleteApplication() { var worker = new BackgroundWorker { WorkerReportsProgress = true }; SetProgressTitle("Delete Application"); worker.ProgressChanged += WorkerProgressChanged; worker.DoWork += (s, e) => { worker.ReportProgress(30, "Deleting Application: " + SelectedApplication.Name); ProviderResponse <bool> appResult = provider.Delete(SelectedApplication.DeepCopy(), Cloud.DeepCopy()); if (!appResult.Response) { worker.ReportProgress(-1, appResult.Message); return; } e.Result = appResult.Response; }; worker.RunWorkerCompleted += (s, e) => { Application applicationToRemove = Cloud.Applications.SingleOrDefault((i) => i.Name == SelectedApplication.Name); if (applicationToRemove != null) { int index = Cloud.Applications.IndexOf(applicationToRemove); Cloud.Applications.RemoveAt(index); } Messenger.Default.Send(new ProgressMessage(100, "Application Deleted.")); }; worker.RunWorkerAsync(); Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.Progress, c => { })); }
public virtual async Task <IProviderResponse <ICollection <TEntity> > > ProcessCollectionAsync(Func <TClient, Task <TCollectionResult> > operation) { IProviderResponse <ICollection <TEntity> > response; try { var result = await operation(_client); response = MapResponse(result); } catch (Exception ex) { //Todo //_logger ex response = new ProviderResponse <ICollection <TEntity> >() { Success = false, Message = ex.Message, ResponseStatus = HttpStatusCode.InternalServerError.ToString("f"), Exception = ex }; } return(response); }
public virtual async Task <IProviderResponse <TEntityFragment> > ProcessFragmentAsync <TEntityFragment>(Func <TClient, Task <TFragmentResult> > operation, string fragmentKey) { IProviderResponse <TEntityFragment> response; try { var result = await operation(_client); response = MapResponse <TEntityFragment>(result, fragmentKey); } catch (Exception ex) { //Todo //_logger ex response = new ProviderResponse <TEntityFragment>() { Success = false, Message = ex.Message, ResponseStatus = HttpStatusCode.InternalServerError.ToString("f"), Exception = ex }; } return(response); }
protected override IProviderResponse <ICollection <TEntity> > MapResponse(IOperationResult <ICollection <TServiceEntity> > operationResult) { if (operationResult != null) { var responseEntityCollection = new List <TEntity>(); foreach (var serviceEntity in operationResult.Value) { responseEntityCollection.Add(serviceEntity); } var response = new ProviderResponse <ICollection <TEntity> >() { Data = responseEntityCollection, Success = operationResult.Success, Message = operationResult.Message, ResponseStatus = operationResult.Status.ToString("f"), Exception = operationResult.Exception, Version = operationResult.Cas }; } return(new ProviderResponse <ICollection <TEntity> >() { Success = false, Message = string.Empty, ResponseStatus = CustomResponseErrors.CBSvcMappingError.ToString("f") }); }
public ProviderResponse<Cloud> Connect(Cloud cloud) { ProviderResponse<Cloud> response = new ProviderResponse<Cloud>(); Cloud local = cloud.DeepCopy(); IVcapClient client = new VcapClient(local); try { VcapClientResult result = client.Login(); if (!result.Success) throw new Exception(result.Message); local.AccessToken = client.CurrentToken; var applications = client.GetApplications(); var provisionedServices = client.GetProvisionedServices(); var availableServices = client.GetSystemServices(); local.Applications.Synchronize(new SafeObservableCollection<Application>(applications), new ApplicationEqualityComparer()); local.Services.Synchronize(new SafeObservableCollection<ProvisionedService>(provisionedServices), new ProvisionedServiceEqualityComparer()); local.AvailableServices.Synchronize(new SafeObservableCollection<SystemService>(availableServices), new SystemServiceEqualityComparer()); foreach (Application app in local.Applications) { var instances = GetInstances(local, app); if (instances.Response != null) app.InstanceCollection.Synchronize(new SafeObservableCollection<Instance>(instances.Response), new InstanceEqualityComparer()); } response.Response = local; } catch (Exception ex) { response.Message = ex.Message; } return response; }
private void PushApp() { Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.PushApp, (confirmed) => { if (confirmed) { PushViewModel viewModel = null; Messenger.Default.Send(new NotificationMessageAction <PushViewModel>(Messages.GetPushAppData, vm => viewModel = vm)); var worker = new BackgroundWorker { WorkerReportsProgress = true }; SetProgressTitle("Push Application"); worker.ProgressChanged += WorkerProgressChanged; worker.DoWork += (s, e) => { worker.ReportProgress(10, "Pushing Application: " + viewModel.Name); ProviderResponse <bool> result = provider.Push(viewModel.SelectedCloud, viewModel.Name, viewModel.Url, Convert.ToUInt16(viewModel.Instances), viewModel.PushFromDirectory, Convert.ToUInt32(viewModel.SelectedMemory), viewModel.ApplicationServices.Select(provisionedService => provisionedService.Name).ToArray()); if (false == result.Response) { worker.ReportProgress(-1, result.Message); return; } ProviderResponse <Application> appResult = provider.GetApplication( new Application { Name = viewModel.Name }, viewModel.SelectedCloud); if (appResult.Response == null) { worker.ReportProgress(-1, appResult.Message); return; } e.Result = appResult.Response; }; worker.RunWorkerCompleted += (s, e) => { var result = e.Result as Application; Cloud cloud = provider.Clouds.SingleOrDefault((c) => c.ID == viewModel.SelectedCloud.ID); if (result != null) { cloud.Applications.Add(result); } Messenger.Default.Send(new ProgressMessage(100, "Application Pushed.")); }; worker.RunWorkerAsync(); Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.Progress, c => { })); } })); }
private void worker_DoRegistrationWork(object sender, DoWorkEventArgs e) { ManageCloudsData selected = SelectedCloud; IsSelectedCloudAccountRegistered = selected.IsAccountRegistered = false; ProviderResponse <bool> result = provider.RegisterAccount(selected.ServerUrl, selected.Email, selected.Password); e.Result = result; }
public void Restart() { var worker = new BackgroundWorker { WorkerReportsProgress = true }; SetProgressTitle("Restarting Application"); worker.ProgressChanged += WorkerProgressChanged; worker.DoWork += (s, e) => { worker.ReportProgress(25, "Stopping Application: " + SelectedApplication.Name); ProviderResponse <bool> result = provider.Stop(SelectedApplication.DeepCopy(), Cloud.DeepCopy()); if (!result.Response) { worker.ReportProgress(-1, result.Message); return; } worker.ReportProgress(40, "Refreshing Application: " + SelectedApplication.Name); ProviderResponse <Application> appResult = provider.GetApplication(SelectedApplication, Cloud); if (appResult.Response == null) { worker.ReportProgress(-1, appResult.Message); return; } dispatcher.BeginInvoke((Action)(() => RefreshSelectedApplication(appResult.Response))); worker.ReportProgress(60, "Starting Application: " + SelectedApplication.Name); result = provider.Start(SelectedApplication.DeepCopy(), Cloud.DeepCopy()); if (!result.Response) { worker.ReportProgress(-1, result.Message); return; } worker.ReportProgress(75, "Refreshing Application: " + SelectedApplication.Name); appResult = provider.GetApplication(SelectedApplication, Cloud); if (appResult.Response == null) { worker.ReportProgress(-1, appResult.Message); return; } e.Result = appResult.Response; }; worker.RunWorkerCompleted += (s, e) => { var result = e.Result as Application; if (result != null) { RefreshSelectedApplication(result); } Messenger.Default.Send(new ProgressMessage(100, "Application Restarted.")); }; worker.RunWorkerAsync(); Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.Progress, c => { })); }
protected override void OnConfirmed(CancelEventArgs e) { ProviderResponse <bool> result = provider.CreateService(cloud, SelectedSystemService.Vendor, Name); if (!result.Response) { ErrorMessage = result.Message; e.Cancel = true; } }
private void worker_DoValidationWork(object sender, DoWorkEventArgs e) { var worker = (BackgroundWorker)sender; ManageCloudsData selected = SelectedCloud; IsSelectedCloudAccountValid = selected.IsAccountValid = false; ProviderResponse <bool> result = provider.ValidateAccount(selected.ServerUrl, selected.Email, selected.Password); e.Result = result; }
public void Create_ResponseNotValid_ThrowsException() { var response = new ProviderResponse { Comment = null }; _initializer.ProviderResponseRepository.Create(response); Assert.That(() => _initializer.CommitProvider.CommitChanges(), Throws.Exception); }
public HttpResponseMessage Get(int id) { ProviderResponse response = null; using (var db = new ClientsProvidersDbEntities()) { var provider = db.Providers.Where(x => x.ProviderId == id).FirstOrDefault(); response = Mapper.Map <Provider, ProviderResponse>(provider); } return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public ProviderResponseViewModel MapToProviderResponseViewModel(ProviderResponse providerResponse) { return(new ProviderResponseViewModel { Id = providerResponse.Id, Order = _orderMapper.MapToOrderViewModel(providerResponse.Order), Provider = _providerMapper.MapToProviderViewModel(providerResponse.Provider), Comment = providerResponse.Comment, CreatedAt = providerResponse.CreatedAt, }); }
public void CreateResponse_ResponseNotValid_ThrowsException() { var response = new ProviderResponse { Comment = null, Creator = new User(), Provider = new Provider(), Order = new Order() }; Assert.That(() => _initializer.ProviderService.CreateResponse(response), Throws.Exception); }
private void CreateService() { Messenger.Default.Register <NotificationMessageAction <Cloud> >(this, message => { if ( message.Notification.Equals( Messages.SetCreateServiceData)) { message.Execute(Cloud); } }); Messenger.Default.Send(new NotificationMessageAction <bool>(Messages.CreateService, (confirmed) => { if (confirmed) { Messenger.Default.Send( new NotificationMessageAction <CreateServiceViewModel>( Messages.GetCreateServiceData, (viewModel) => { ProviderResponse < SafeObservableCollection < ProvisionedService > > result = provider. GetProvisionedServices (Cloud); if (result.Response == null) { ApplicationErrorMessage = result.Message; } else { Cloud.Services. Synchronize( result.Response, new ProvisionedServiceEqualityComparer ()); } })); } })); }
public ProviderResponse<bool> ChangePassword(Cloud cloud, string newPassword) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); client.ChangePassword(newPassword); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public void Create_CreatedResponse_ThrowsNoExceptions() { var user = _initializer.IdentityRepository.GetBy(x => x.Orders.Count > 0).FirstOrDefault(); var provider = _initializer.ProviderRepository.GetBy(x => x.Creator.Id != user.Id).FirstOrDefault(); var response = new ProviderResponse { Comment = "Comment", Creator = user, Provider = provider, Order = user.Orders.FirstOrDefault(), CreatedAt = DateTime.Now, }; _initializer.ProviderResponseRepository.Create(response); Assert.That(() => _initializer.CommitProvider.CommitChanges(), Throws.Nothing); }
private void OpenFile() { ProviderResponse <VcapFilesResult> result = provider.GetFiles(app.Parent, app, "/" + path, id); if (result.Response == null) { Messenger.Default.Send(new NotificationMessage <string>(result.Message, Messages.ErrorMessage)); return; } string pathToFile = Path.GetTempPath() + name; using (FileStream fs = File.Create(pathToFile)) using (var bw = new BinaryWriter(fs)) bw.Write(result.Response.File); Process.Start(pathToFile); }
public ProviderResponse<bool> ChangePassword(Cloud cloud, string newPassword) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); var vcapResult = client.ChangePassword(newPassword); if (!vcapResult.Success) throw new Exception(vcapResult.Message); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public override void LoadChildren() { Children.Clear(); ProviderResponse <VcapFilesResult> result = provider.GetFiles(app.Parent, app, path, id); if (result.Response == null) { Messenger.Default.Send(new NotificationMessage <string>(result.Message, Messages.ErrorMessage)); return; } foreach (VcapFilesResult.FilesResultData dir in result.Response.Directories) { base.Children.Add(new FolderTreeViewItemViewModel(dir.Name, path + "/" + dir.Name, app, id)); } foreach (VcapFilesResult.FilesResultData file in result.Response.Files) { base.Children.Add(new FileTreeViewItemViewModel(file.Name, path + "/" + file.Name, app, id)); } }
public async Task <ProviderResponse> FindByIdAsync(int id) { try { var provider = await _providerRepository.FindByIdAsync(id); var aux = new ProviderResponse(provider); if (provider == null) { aux = new ProviderResponse(false, "No se encontro al proveedor porque no existe", provider); } return(aux); // var provider = await _providerRepository.FindByIdAsync(id); // return new ProviderResponse(provider); } catch (Exception ex) { return(new ProviderResponse($"An error ocurred while deleting the provider: {ex.Message}")); } }
public ProviderResponse<Cloud> Connect(Cloud cloud) { var response = new ProviderResponse<Cloud>(); if (cloud.IsDataComplete) { Cloud local = cloud.DeepCopy(); IVcapClient client = new VcapClient(local); try { client.Login(); local.AccessToken = client.CurrentToken; var applications = client.GetApplications(); var provisionedServices = client.GetProvisionedServices(); var availableServices = client.GetSystemServices(); local.Applications.Synchronize(new SafeObservableCollection<Application>(applications), new ApplicationEqualityComparer()); local.Services.Synchronize(new SafeObservableCollection<ProvisionedService>(provisionedServices), new ProvisionedServiceEqualityComparer()); local.AvailableServices.Synchronize(new SafeObservableCollection<SystemService>(availableServices), new SystemServiceEqualityComparer()); foreach (Application app in local.Applications) { var instances = GetInstances(local, app); if (instances.Response != null) app.InstanceCollection.Synchronize(new SafeObservableCollection<Instance>(instances.Response), new InstanceEqualityComparer()); } response.Response = local; } catch (Exception ex) { response.Response = null; response.Message = ex.Message; } } else { response.Message = Resources.CloudFoundryProvider_ConnectIncompleteData_Message; } return response; }
protected override void OnConfirmed(CancelEventArgs e) { if (String.IsNullOrEmpty(NewPassword) || String.IsNullOrEmpty(VerifyPassword)) { e.Cancel = true; ErrorMessage = "Passwords cannot be empty."; } else if (!NewPassword.Equals(VerifyPassword)) { e.Cancel = true; ErrorMessage = "Passwords must match."; } else { ProviderResponse <bool> result = provider.ChangePassword(cloud, NewPassword); if (!result.Response) { ErrorMessage = result.Message; e.Cancel = true; } } }
protected override IProviderResponse <ICollection <TEntity> > MapResponse(ICollection <IOperationResult <TServiceEntity> > cbSvcResults) { var response = new ProviderResponse <ICollection <TEntity> >() { Data = new List <TEntity>(), Success = true, Message = string.Empty, ResponseStatus = Couchbase.IO.ResponseStatus.Success.ToString("f") }; StringBuilder errorList = new StringBuilder(); foreach (var operationResult in cbSvcResults) { if (operationResult != null) { if (operationResult.Success) { response.Data.Add(operationResult.Value); } else { errorList.AppendFormat(@"Message: {0}, ResponseStatus: {1}. ", operationResult.Message, operationResult.Status.ToString("f")); } } } if (errorList.Length > 0) { response.Success = false; response.Message = errorList.ToString(); response.ResponseStatus = Couchbase.IO.ResponseStatus.InternalError.ToString("f"); } return(response); }
public ProviderResponse<bool> CreateService(Cloud cloud, string serviceName, string provisionedServiceName) { ProviderResponse<bool> response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); var vcapResult = client.CreateService(serviceName, provisionedServiceName); if (!vcapResult.Success) throw new Exception(vcapResult.Message); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<bool> RegisterAccount(Cloud cloud,string email, string password) { ProviderResponse<bool> response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); var vcapResult = client.AddUser(email,password); if (!vcapResult.Success) throw new Exception(vcapResult.Message); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<bool> Delete(Application app, Cloud cloud) { ProviderResponse<bool> response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); client.Delete(app.Name); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<bool> RegisterAccount(string serverUrl, string email, string password) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(serverUrl); var vcapResult = client.AddUser(email, password); response.Response = true; response.Message = vcapResult.Message; } catch (Exception ex) { response.Response = false; response.Message = ex.Message; } return response; }
public ProviderResponse<bool> ValidateAccount(Cloud cloud) { ProviderResponse<bool> response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); var vcapResponse = client.Login(); if (vcapResponse != null && !vcapResponse.Success && !String.IsNullOrEmpty(vcapResponse.Message)) throw new Exception(vcapResponse.Message); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<bool> UpdateApplication(Application app, Cloud cloud) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); var vcapResponse = client.UpdateApplication(app); if (vcapResponse != null && !String.IsNullOrEmpty(vcapResponse.Description)) throw new Exception(vcapResponse.Description); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<bool> ValidateAccount(string serverUrl, string email, string password) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(serverUrl); client.Login(email, password); response.Response = true; } catch (Exception ex) { response.Response = false; response.Message = ex.Message; } return response; }
public ProviderResponse<bool> Push(Cloud cloud, string name, string url, ushort instances, string directoryToPushFrom, uint memory, string[] services) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); client.Push(name, url, instances, new System.IO.DirectoryInfo(directoryToPushFrom), memory, services); response.Response = true; } catch (Exception ex) { response.Response = false; response.Message = ex.Message; } return response; }
public ProviderResponse<bool> Update(Cloud cloud, Application app, string directoryToPushFrom) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); client.Update(app.Name, new System.IO.DirectoryInfo(directoryToPushFrom)); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<IEnumerable<StatInfo>> GetStats(Application app, Cloud cloud) { var response = new ProviderResponse<IEnumerable<StatInfo>>(); try { IVcapClient client = new VcapClient(cloud); response.Response = client.GetStats(app); } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<SafeObservableCollection<StatInfo>> GetStats(Cloud cloud, Application application) { var response = new ProviderResponse<SafeObservableCollection<StatInfo>>(); try { IVcapClient client = new VcapClient(cloud); response.Response = new SafeObservableCollection<StatInfo>(client.GetStats(application)); } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<SafeObservableCollection<ProvisionedService>> GetProvisionedServices(Cloud cloud) { var response = new ProviderResponse<SafeObservableCollection<ProvisionedService>>(); try { IVcapClient client = new VcapClient(cloud); response.Response = new SafeObservableCollection<ProvisionedService>(client.GetProvisionedServices()); } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<IEnumerable<Instance>> GetInstances(Cloud cloud, Application app) { var response = new ProviderResponse<IEnumerable<Instance>>(); try { IVcapClient client = new VcapClient(cloud); var stats = client.GetStats(app); var instances = new SafeObservableCollection<Instance>(); if (stats != null) { foreach (var stat in stats) { var instance = new Instance() { ID = stat.ID, State = stat.State }; if (stat.Stats != null) { instance.Cores = stat.Stats.Cores; instance.MemoryQuota = stat.Stats.MemQuota/1048576; instance.DiskQuota = stat.Stats.DiskQuota/1048576; instance.Host = stat.Stats.Host; instance.Parent = app; instance.Uptime = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime)); if (stat.Stats.Usage != null) { instance.Cpu = stat.Stats.Usage.CpuTime/100; instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage)/1024; instance.Disk = Convert.ToInt32(stat.Stats.Usage.DiskUsage)/1048576; } } instances.Add(instance); } } response.Response = instances; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<VcapFilesResult> GetFiles(Cloud cloud, Application application, string path, ushort instanceId) { var response = new ProviderResponse<VcapFilesResult>(); try { IVcapClient client = new VcapClient(cloud); var result = client.Files(application.Name, path, instanceId); response.Response = result; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public void DeleteResponse_ResponseNotFound_ThrowsException() { var responseToDelete = new ProviderResponse(); Assert.That(() => _initializer.ProviderService.DeleteResponse(responseToDelete), Throws.Exception); }
public ProviderResponse<bool> UpdateApplication(Application app, Cloud cloud) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); client.UpdateApplication(app); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<Application> GetApplication(Application app, Cloud cloud) { var response = new ProviderResponse<Application>(); try { IVcapClient client = new VcapClient(cloud); response.Response = client.GetApplication(app.Name); var instancesResponse = this.GetInstances(cloud, app); if (instancesResponse.Response != null) response.Response.InstanceCollection.Synchronize(new SafeObservableCollection<Instance>(instancesResponse.Response),new InstanceEqualityComparer()); } catch (Exception ex) { response.Message = ex.Message; } return response; }
public ProviderResponse<bool> CreateService(Cloud cloud, string serviceName, string provisionedServiceName) { var response = new ProviderResponse<bool>(); try { IVcapClient client = new VcapClient(cloud); client.CreateService(serviceName, provisionedServiceName); response.Response = true; } catch (Exception ex) { response.Message = ex.Message; } return response; }