public override async Task <UpdateServiceInstanceResult> UpdateServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken ct) { await context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, Resources.LogMessage_UpdatingConnectedService); SalesforceConnectedServiceInstance salesforceInstance = (SalesforceConnectedServiceInstance)context.ServiceInstance; try { Project project = ProjectHelper.GetProjectFromHierarchy(context.ProjectHierarchy); await TaskScheduler.Default; // Switch to a worker thread to avoid blocking the UI thread (e.g. the progress dialog). // Update currently only supports adding additional scaffolded objects. Before they are added, ensure the correct NuGets are // installed. Additionally, ensure the required assemblies exist as not all are added initially if no objects are scaffolded. await this.AddNuGetPackagesAsync(context, project); await SalesforceConnectedServiceHandler.AddAssemblyReferencesAsync(context, salesforceInstance); try { await SalesforceConnectedServiceHandler.AddGeneratedCodeAsync(context, project, salesforceInstance); } catch (COMException comException) { if (comException.HResult == -2147467259) { // Provide a better exception message for when an invalid path ModelsHintPath was specified. throw new InvalidOperationException( Resources.LogMessage_InvalidModelsHintPath.FormatCurrentCulture(salesforceInstance.DesignerData.ModelsHintPath), comException); } } salesforceInstance.DesignerData.StoreExtendedDesignerData(context); salesforceInstance.TelemetryHelper.TrackUpdateServiceSucceededEvent(salesforceInstance); await context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, Resources.LogMessage_UpdatedConnectedService); return(new UpdateServiceInstanceResult()); } catch (Exception e) { salesforceInstance.TelemetryHelper.TrackUpdateServiceFailedEvent(salesforceInstance, e); throw; } }
public override async Task <AddServiceInstanceResult> AddServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken ct) { await context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, Resources.LogMessage_AddingConnectedService); SalesforceConnectedServiceInstance salesforceInstance = (SalesforceConnectedServiceInstance)context.ServiceInstance; try { Project project = ProjectHelper.GetProjectFromHierarchy(context.ProjectHierarchy); string generatedArtifactSuffix = SalesforceConnectedServiceHandler.GetGeneratedArtifactSuffix( context, project, salesforceInstance.RuntimeAuthentication.AuthStrategy); salesforceInstance.DesignerData.ServiceName = SalesforceConnectedServiceHandler.GetServiceInstanceName(generatedArtifactSuffix); await TaskScheduler.Default; // Switch to a worker thread to avoid blocking the UI thread (e.g. the progress dialog). await SalesforceConnectedServiceHandler.CreateConnectedAppAsync(context, project, salesforceInstance); await SalesforceConnectedServiceHandler.UpdateConfigFileAsync(context, project, salesforceInstance); await this.AddNuGetPackagesAsync(context, project); await SalesforceConnectedServiceHandler.AddAssemblyReferencesAsync(context, salesforceInstance); await SalesforceConnectedServiceHandler.AddGeneratedCodeAsync(context, project, salesforceInstance); salesforceInstance.DesignerData.StoreExtendedDesignerData(context); salesforceInstance.TelemetryHelper.TrackAddServiceSucceededEvent(salesforceInstance); await context.Logger.WriteMessageAsync(LoggerMessageCategory.Information, Resources.LogMessage_AddedConnectedService); return(new AddServiceInstanceResult( salesforceInstance.DesignerData.ServiceName, new Uri(Constants.NextStepsUrl))); } catch (Exception e) { salesforceInstance.TelemetryHelper.TrackAddServiceFailedEvent(salesforceInstance, e); throw; } }