private void CompressOrUncompressIfNeeded(string sourcePath, UploadProgressHandler progressHandler) { if (this.CompressPackage) { if (progressHandler != null) { progressHandler.SetStateCompressing(); } ImageStoreUtility.ArchiveApplicationPackage(sourcePath, progressHandler); } else if (this.UncompressPackage) { if (progressHandler != null) { progressHandler.SetStateUncompressing(); } ImageStoreUtility.TryExtractApplicationPackage(sourcePath, progressHandler); } }
private void GenerateChecksumsIfNeeded(string sourcePath, string imageStoreString, UploadProgressHandler progressHandler) { if (this.GenerateChecksums) { if (string.IsNullOrEmpty(imageStoreString)) { this.ThrowTerminatingError( new ArgumentException(StringResources.Error_MissingImageStoreConnectionStringArgument), Constants.CopyApplicationPackageErrorId, null); } if (progressHandler != null) { progressHandler.SetStateGeneratingChecksums(); } ImageStoreUtility.GenerateApplicationPackageChecksumFiles( sourcePath, progressHandler, ImageStoreUtility.GetImageStoreProviderType(imageStoreString) == ImageStoreProviderType.ImageStoreService); } }
protected string TryFetchImageStoreConnectionString(string connectionStringArg, StoreLocation certStoreLocation) { if (!string.IsNullOrEmpty(connectionStringArg)) { return(connectionStringArg); } var clusterConnection = this.GetClusterConnectionNoThrow(); if (clusterConnection == null) { this.ThrowTerminatingError( new ArgumentException(StringResources.Error_MissingImageStoreConnectionStringArgument), Constants.GetImageStoreConnectionStringErrorId, null); } string clusterManifest = null; try { clusterManifest = clusterConnection.GetClusterManifestAsync( this.GetTimeout(), this.GetCancellationToken()).Result; } catch (AggregateException aggregateException) { aggregateException.Handle((ae) => { this.ThrowTerminatingError( ae, Constants.GetClusterManifestErrorId, clusterConnection); return(true); }); } int searchIndex = clusterManifest.IndexOf(ImageStoreConnectionStringParameterName) + ImageStoreConnectionStringParameterName.Length; int startIndex = clusterManifest.IndexOf(ValueParameterName, searchIndex) + ValueParameterName.Length; int endIndex = clusterManifest.IndexOf("\"", startIndex); if (startIndex < 0 || endIndex < 0) { this.ThrowTerminatingError( new ArgumentException(StringResources.Error_ImageStoreConnectionStringParse), Constants.GetImageStoreConnectionStringErrorId, null); } var imageStoreString = clusterManifest.Substring(startIndex, endIndex - startIndex); if (ImageStoreUtility.GetImageStoreProviderType(imageStoreString) == ImageStoreProviderType.Invalid) { imageStoreString = this.DecryptText(imageStoreString, certStoreLocation); if (ImageStoreUtility.GetImageStoreProviderType(imageStoreString) == ImageStoreProviderType.Invalid) { this.ThrowTerminatingError( new ArgumentException(StringResources.Error_ImageStoreConnectionStringParse), Constants.GetImageStoreConnectionStringErrorId, null); } } this.WriteObject(string.Format(CultureInfo.InvariantCulture, StringResources.PowerShell_Using_ImageStoreConnectionString, imageStoreString)); return(imageStoreString); }
public static void WriteStringToFile(string fileName, string value, bool writeLine = true, Encoding encoding = null) { ImageStoreUtility.WriteStringToFile(fileName, value, writeLine, encoding); }