internal string ApplyPackage(CloudHostedInstance instance, DeployablePackage package) { StringBuilder log = new StringBuilder(); package.LcsEnvironmentId = instance.EnvironmentId; var validationResponse = ValidateSandboxServicing(package); if (validationResponse.Success && !string.IsNullOrEmpty(validationResponse.Data.ToString())) { string platformRelease; try { var releaseVersion = JsonConvert.DeserializeObject <ValidateSandboxServicingData>(validationResponse.Data.ToString()); platformRelease = releaseVersion.PlatformRelease; } catch { platformRelease = validationResponse.Data.ToString(); } log.AppendLine($"{instance.DisplayName}: Package deployment validation successful."); var deploymentResponse = StartSandboxServicing(package, platformRelease); log.AppendLine($"{instance.DisplayName}: {deploymentResponse.Message}"); log.AppendLine(); } else { log.AppendLine($"{instance.DisplayName}: Package deployment validation failed."); log.AppendLine($"{instance.DisplayName}: {validationResponse.Message}"); log.AppendLine(); } return(log.ToString()); }
private void DeployPackage_Click(object sender, RoutedEventArgs e) { if (PackagesGrid.SelectedItems.Count > 0) { if (PackagesGrid.SelectedItem != null) { DeployablePackage = PackagesGrid.SelectedItem as DeployablePackage; this.Close(); } } }
internal Response ValidateSandboxServicing(DeployablePackage package) { var parameters = $"package[PackageId]={package.PackageId}&package[Name]={package.Name}&package[Description]={package.Description}&package[packageType]={package.PackageType}&package[ModifiedDate]={package.ModifiedDate}&package[ModifiedBy]={package.ModifiedBy}&package[Publisher]={package.Publisher}&package[LcsEnvironmentActionId]={package.LcsEnvironmentActionId}&package[LcsEnvironmentId]={package.LcsEnvironmentId}&package[FileAssetDisplayVersion]={package.FileAssetDisplayVersion}&package[PlatformVersion]={package.PlatformVersion}&package[AppVersion]={package.AppVersion}"; using (_stringContent = new StringContent(parameters, Encoding.UTF8, "application/x-www-form-urlencoded")) { SetRequestVerificationToken($"{LcsUrl}/V2"); var result = _httpClient.PostAsync($"{LcsUrl}/Environment/ValidateSandboxServicing/{LcsProjectId}", _stringContent).Result; result.EnsureSuccessStatusCode(); var responseBody = result.Content.ReadAsStringAsync().Result; return(JsonConvert.DeserializeObject <Response>(responseBody)); } }
internal string ApplyPackage(CloudHostedInstance instance, DeployablePackage package) { StringBuilder log = new StringBuilder(); package.LcsEnvironmentId = instance.EnvironmentId; var validationResponse = ValidateSandboxServicing(package); if (validationResponse.Success && !string.IsNullOrEmpty(validationResponse.Data.ToString())) { log.AppendLine($"{instance.DisplayName}: Package deployment validation successful."); var deploymentResponse = StartSandboxServicing(package, validationResponse.Data.ToString()); log.AppendLine($"{instance.DisplayName}: {deploymentResponse.Message}"); log.AppendLine(); } else { log.AppendLine($"{instance.DisplayName}: Package deployment validation failed."); log.AppendLine($"{instance.DisplayName}: {validationResponse.Message}"); log.AppendLine(); } return(log.ToString()); }