public void ClearReminderScheduleForPackage( PackageId packageId ) { try { restClient.Delete(Path(packageId)); } catch (Exception e) { throw new EslException ("Failed to remove reminder schedule for package with id: " + packageId.Id + ". Exception: " + e.Message); } }
/// <summary> /// Gets the field summary for the package and returns a list of field summaries. /// </summary> /// <returns>A list of field summaries.</returns> /// <param name="packageId">The package id.</param> public List<FieldSummary> GetFieldSummary (PackageId packageId) { string path = template.UrlFor (UrlTemplate.FIELD_SUMMARY_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { string response = Converter.ToString (HttpMethods.GetHttp (apiToken, path)); return JsonConvert.DeserializeObject<List<FieldSummary>> (response); } catch (Exception e) { throw new EslException ("Could not get the field summary." + " Exception: " + e.Message); } }
/// <summary> /// Gets the package. /// </summary> /// <returns>The package.</returns> /// <param name="packageId">The package id.</param> internal Silanis.ESL.API.Package GetPackage (PackageId packageId) { string path = template.UrlFor (UrlTemplate.PACKAGE_ID_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { string response = restClient.Get(path); return JsonConvert.DeserializeObject<Silanis.ESL.API.Package> (response, settings); } catch (Exception e) { throw new EslException ("Could not get package." + " Exception: " + e.Message); } }
/// <summary> /// Updates the package's fields and roles. /// </summary> /// <param name="packageId">The package id.</param> /// <param name="package">The updated package.</param> internal void UpdatePackage (PackageId packageId, Silanis.ESL.API.Package package) { string path = template.UrlFor (UrlTemplate.PACKAGE_ID_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { string json = JsonConvert.SerializeObject (package, settings); string response = restClient.Put(path, json); } catch (Exception e) { throw new EslException ("Could not update the package." + " Exception: " + e.Message); } }
/// <summary> /// Creates a session token for a signer and returns the session token. /// </summary> /// <returns>The session token for signer.</returns> /// <param name="packageId">The package id.</param> /// <param name="signer">The signer to create a session token for.</param> public SessionToken CreateSignerSessionToken (PackageId packageId, string signerId) { string path = template.UrlFor (UrlTemplate.SESSION_PATH) .Replace ("{packageId}", packageId.Id) .Replace ("{signerId}", signerId) .Build (); try { string response = Converter.ToString (HttpMethods.PostHttp (apiToken, path, new byte[0])); return JsonConvert.DeserializeObject<SessionToken> (response); } catch (Exception e) { throw new EslException ("Could not create a session token for signer." + " Exception: " + e.Message); } }
public ReminderSchedule GetReminderScheduleForPackage( PackageId packageId ) { try { string response = restClient.Get(Path(packageId)); if (response.Length == 0) { return null; } PackageReminderSchedule apiResponse = JsonConvert.DeserializeObject<PackageReminderSchedule> (response, settings ); return new ReminderScheduleConverter( apiResponse ).ToSDKReminderSchedule(); } catch (Exception e) { throw new EslException ("Failed to retrieve reminder schedule for package with id: " + packageId.Id + ". Exception: " + e.Message); } }
/// <summary> /// Gets the audit trail for a package and returns a list of audits. /// </summary> /// <returns>A list of audits.</returns> /// <param name="packageId">The package id.</param> public List<Audit> GetAudit (PackageId packageId) { string path = template.UrlFor (UrlTemplate.AUDIT_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { string response = Converter.ToString (HttpMethods.GetHttp (apiToken, path)); Dictionary<string,object> eventList = JsonConvert.DeserializeObject <Dictionary<string,object>> (response); if (eventList.ContainsKey ("audit-events")) { return JsonConvert.DeserializeObject<List<Audit>> (eventList ["audit-events"].ToString ()); } return null; } catch (Exception e) { throw new EslException ("Could not get audit." + " Exception: " + e.Message); } }
internal PackageBuilder (Silanis.ESL.API.Package package) { this.id = new PackageId( package.Id ); this.packageName = package.Name; this.autocomplete = package.Autocomplete; this.description = package.Description; this.expiryDate = package.Due; this.status = ConvertPackageStatus(package.Status); this.emailMessage = package.EmailMessage; this.settings = new DocumentPackageSettingsBuilder(package.Settings).build(); this.senderInfo = new SenderConverter(package.Sender).ToSDKSenderInfo(); this.attributes = new DocumentPackageAttributes(package.Data); foreach ( Silanis.ESL.API.Role role in package.Roles ) { if ( role.Signers.Count == 0 ) { continue; } if (role.Signers[0].Group != null) { WithSigner(SignerBuilder.NewSignerFromGroup(new GroupId(role.Signers[0].Group.Id))); } else { WithSigner(SignerBuilder.NewSignerFromAPISigner(role).Build()); if (role.Type == Silanis.ESL.API.RoleType.SENDER) { Silanis.ESL.API.Signer senderSigner = role.Signers[0]; WithSenderInfo( SenderInfoBuilder.NewSenderInfo(senderSigner.Email) .WithName(senderSigner.FirstName, senderSigner.LastName) .WithCompany(senderSigner.Company) .WithTitle(senderSigner.Title)); } } } foreach ( Silanis.ESL.API.Document apiDocument in package.Documents ) { Document document = DocumentBuilder.NewDocumentFromAPIDocument( apiDocument, package ).Build(); WithDocument( document ); } }
public async Task <bool> CheckIfAppIsUpdated() { bool isAppUpdated = false; bool toChangelog = false; Package package = Package.Current; PackageId packageId = package.Id; PackageVersion version = packageId.Version; // First, check if there was a previous version. If not, just fill in the current version as the previous version. if (localSettings.Values[previousVersionMajor] == null) { localSettings.Values[previousVersionMajor] = version.Major; localSettings.Values[previousVersionMinor] = version.Minor; localSettings.Values[previousVersionBuild] = version.Build; localSettings.Values[previousVersionRevision] = version.Revision; } // Second, check if the app has been updated by comparing the old agains the new version if (localSettings.Values[previousVersionMajor] != null) { // Get the values for the old version ushort oldVerMajor = Convert.ToUInt16(localSettings.Values[previousVersionMajor]); ushort oldVerMinor = Convert.ToUInt16(localSettings.Values[previousVersionMinor]); ushort oldVerBuild = Convert.ToUInt16(localSettings.Values[previousVersionBuild]); ushort oldVerRevision = Convert.ToUInt16(localSettings.Values[previousVersionRevision]); if (version.Major > oldVerMajor) // Check if it's a major version-update { isAppUpdated = true; localSettings.Values[previousVersionMajor] = version.Major; localSettings.Values[previousVersionMinor] = version.Minor; localSettings.Values[previousVersionBuild] = version.Build; localSettings.Values[previousVersionRevision] = version.Revision; } else if (version.Minor > oldVerMinor) // check if it's an minor version-update { isAppUpdated = true; localSettings.Values[previousVersionMajor] = version.Major; localSettings.Values[previousVersionMinor] = version.Minor; localSettings.Values[previousVersionBuild] = version.Build; localSettings.Values[previousVersionRevision] = version.Revision; } else if (version.Build > oldVerBuild) // check if the build has been updated { isAppUpdated = true; localSettings.Values[previousVersionMajor] = version.Major; localSettings.Values[previousVersionMinor] = version.Minor; localSettings.Values[previousVersionBuild] = version.Build; localSettings.Values[previousVersionRevision] = version.Revision; } else if (version.Revision > oldVerRevision) // This probably won't be used, but is here anyway; check if the revision has been updated { isAppUpdated = true; localSettings.Values[previousVersionMajor] = version.Major; localSettings.Values[previousVersionMinor] = version.Minor; localSettings.Values[previousVersionBuild] = version.Build; localSettings.Values[previousVersionRevision] = version.Revision; } } if (isAppUpdated == true) { //toChangelog = await f**k.ShowAppUpdatedDialog("Error-AppUpdated-Text", "Error-AppUpdated-Title"); Debug.WriteLine("toChangelog = " + toChangelog); } return(toChangelog); }
public override int Execute() { var global = _options.ValueOrDefault <bool>("global"); var toolPath = _options.SingleArgumentOrDefault("tool-path"); DirectoryPath?toolDirectoryPath = null; if (!string.IsNullOrWhiteSpace(toolPath)) { if (!Directory.Exists(toolPath)) { throw new GracefulException( string.Format( LocalizableStrings.InvalidToolPathOption, toolPath)); } toolDirectoryPath = new DirectoryPath(toolPath); } if (toolDirectoryPath == null && !global) { throw new GracefulException(LocalizableStrings.UninstallToolCommandNeedGlobalOrToolPath); } if (toolDirectoryPath != null && global) { throw new GracefulException(LocalizableStrings.UninstallToolCommandInvalidGlobalAndToolPath); } IToolPackageStore toolPackageStore = _createToolPackageStore(toolDirectoryPath); IShellShimRepository shellShimRepository = _createShellShimRepository(toolDirectoryPath); var packageId = new PackageId(_options.Arguments.Single()); IToolPackage package = null; try { package = toolPackageStore.EnumeratePackageVersions(packageId).SingleOrDefault(); if (package == null) { throw new GracefulException( messages: new[] { string.Format( LocalizableStrings.ToolNotInstalled, packageId), }, isUserError: false); } } catch (InvalidOperationException) { throw new GracefulException( messages: new[] { string.Format( LocalizableStrings.ToolHasMultipleVersionsInstalled, packageId), }, isUserError: false); } try { using (var scope = new TransactionScope( TransactionScopeOption.Required, TimeSpan.Zero)) { foreach (var command in package.Commands) { shellShimRepository.RemoveShim(command.Name); } package.Uninstall(); scope.Complete(); } _reporter.WriteLine( string.Format( LocalizableStrings.UninstallSucceeded, package.Id, package.Version.ToNormalizedString()).Green()); return(0); } catch (Exception ex) when(ToolUninstallCommandLowLevelErrorConverter.ShouldConvertToUserFacingError(ex)) { throw new GracefulException( messages: ToolUninstallCommandLowLevelErrorConverter.GetUserFacingMessages(ex, packageId), verboseMessages: new[] { ex.ToString() }, isUserError: false); } }
public void NotifySigner( PackageId packageId, GroupId groupId ) { Role role = FindRoleForGroup(packageId, groupId.Id); NotifySigner(packageId, role.Id); }
public void NotifySigner (PackageId packageId, string signerEmail, string message) { string path = template.UrlFor (UrlTemplate.NOTIFICATIONS_PATH).Replace ("{packageId}", packageId.Id).Build (); StringWriter sw = new StringWriter (); using (JsonWriter json = new JsonTextWriter(sw)) { json.Formatting = Formatting.Indented; json.WriteStartObject (); json.WritePropertyName ("email"); json.WriteValue (signerEmail); json.WritePropertyName ("message"); json.WriteValue (message); json.WriteEndObject (); } try { restClient.Post(path, sw.ToString()); } catch (Exception e) { throw new EslException ("Could not send email notification to signer. Exception: " + e.Message); } }
public SigningStatus GetSigningStatus (PackageId packageId, string signerId, string documentId) { String path = template.UrlFor( UrlTemplate.SIGNING_STATUS_PATH ) .Replace( "{packageId}", packageId.Id ) .Replace( "{signerId}", !String.IsNullOrEmpty(signerId) ? signerId : "" ) .Replace( "{documentId}", !String.IsNullOrEmpty(documentId) ? documentId : "" ) .Build(); try { string response = restClient.Get(path); JsonTextReader reader = new JsonTextReader(new StringReader(response)); //Loop 'till we get to the status value while (reader.Read () && reader.TokenType != JsonToken.String) { } return SigningStatusUtility.FromString(reader.Value.ToString ()); } catch (Exception e) { throw new EslException ("Could not get signing status. Exception: " + e.Message); } }
public void DeletePackage(PackageId id) { string path = template.UrlFor (UrlTemplate.PACKAGE_ID_PATH).Replace ("{packageId}", id.Id).Build (); try { restClient.Delete(path); } catch (Exception e) { throw new EslException ("Could not delete package. Exception: " + e.Message); } }
/// <summary> /// Downloads a document from the package and returns it in a byte array. /// </summary> /// <returns>The document to download.</returns> /// <param name="packageId">The package id.</param> /// <param name="documentId">The id of the document to download.</param> public byte[] DownloadDocument (PackageId packageId, String documentId) { string path = template.UrlFor (UrlTemplate.PDF_PATH) .Replace ("{packageId}", packageId.Id) .Replace ("{documentId}", documentId) .Build (); try { return restClient.GetBytes(path); } catch (Exception e) { throw new EslException ("Could not download the pdf document." + " Exception: " + e.Message); } }
/// <summary> /// Downloads the evidence summary from the package and returns it in a byte array. /// </summary> /// <returns>The evidence summary in byte array.</returns> /// <param name="packageId">The package id.</param> public byte[] DownloadEvidenceSummary (PackageId packageId) { string path = template.UrlFor (UrlTemplate.EVIDENCE_SUMMARY_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { return restClient.GetBytes(path); } catch (Exception e) { throw new EslException ("Could not download the evidence summary." + " Exception: " + e.Message); } }
private string GetNupkgUrl(string baseUri, PackageId id, NuGetVersion version) => baseUri + id.ToString() + "/" + version.ToNormalizedString() + "/" + id.ToString() + "." + version.ToNormalizedString() + ".nupkg";
public SessionToken CreateSessionToken(PackageId packageId, string signerId) { return(CreateSignerSessionToken(packageId, signerId)); }
public override int GetHashCode() { return(PackageId.GetHashCode() * Version.GetHashCode() * (Framework != null ? Framework.GetHashCode() : 1)); }
public void Run(IBackgroundTaskInstance taskInstance) { StorageFolder localFolder = ApplicationData.Current.LocalFolder; try { // see if the configuration file is present if not copy minimal sample one from application directory if (localFolder.TryGetItemAsync(ConfigurationFilename).AsTask().Result == null) { StorageFile templateConfigurationfile = Package.Current.InstalledLocation.GetFileAsync(ConfigurationFilename).AsTask().Result; templateConfigurationfile.CopyAsync(localFolder, ConfigurationFilename).AsTask(); } // Load the settings from configuration file exit application if missing or invalid StorageFile file = localFolder.GetFileAsync(ConfigurationFilename).AsTask().Result; this.applicationSettings = JsonConvert.DeserializeObject <ApplicationSettings>(FileIO.ReadTextAsync(file).AsTask().Result); } catch (Exception ex) { this.logging.LogMessage("JSON configuration file load failed " + ex.Message, LoggingLevel.Error); return; } #if CEECH_NRF24L01P_SHIELD // Disable the onboard beeper so it doesn't whine so much GpioController gpioController = GpioController.GetDefault(); GpioPin buzzer = gpioController.OpenPin(4); buzzer.SetDriveMode(GpioPinDriveMode.Output); buzzer.Write(GpioPinValue.Low); #endif // Log the Application build, shield information etc. LoggingFields applicationBuildInformation = new LoggingFields(); #if CEECH_NRF24L01P_SHIELD applicationBuildInformation.AddString("Shield", "CeechnRF24L01P"); #endif #if BOROS_RF2_SHIELD_RADIO_0 appllcationBuildInformation.AddString("Shield", "BorosRF2Port0"); #endif #if BOROS_RF2_SHIELD_RADIO_1 applicationBuildInformation.AddString("Shield", "BorosRF2Port1"); #endif #if CLOUD_DEVICE_BOND applicationBuildInformation.AddString("Bond", "Supported"); #else applicationBuildInformation.AddString("Bond", "NotSupported"); #endif #if CLOUD_DEVICE_PUSH applicationBuildInformation.AddString("Push", "Supported"); #else applicationBuildInformation.AddString("Push", "NotSupported"); #endif #if CLOUD_DEVICE_SEND applicationBuildInformation.AddString("Send", "Supported"); #else applicationBuildInformation.AddString("Send", "NotSupported"); #endif applicationBuildInformation.AddString("Timezone", TimeZoneSettings.CurrentTimeZoneDisplayName); applicationBuildInformation.AddString("OSVersion", Environment.OSVersion.VersionString); applicationBuildInformation.AddString("MachineName", Environment.MachineName); // This is from the application manifest Package package = Package.Current; PackageId packageId = package.Id; PackageVersion version = packageId.Version; applicationBuildInformation.AddString("ApplicationVersion", string.Format($"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}")); this.logging.LogEvent("Application starting", applicationBuildInformation, LoggingLevel.Information); // Connect the IoT hub first so we are ready for any messages LoggingFields azureIoTHubSettings = new LoggingFields(); azureIoTHubSettings.AddString("DeviceConnectionString", this.applicationSettings.AzureIoTHubDeviceConnectionString); azureIoTHubSettings.AddString("TransportType", this.applicationSettings.AzureIoTHubTransportType.ToString()); azureIoTHubSettings.AddString("SensorIDIsDeviceIDSensorID", this.applicationSettings.SensorIDIsDeviceIDSensorID.ToString()); this.logging.LogEvent("AzureIoTHub configuration", azureIoTHubSettings, LoggingLevel.Information); try { this.azureIoTHubClient = DeviceClient.CreateFromConnectionString(this.applicationSettings.AzureIoTHubDeviceConnectionString, this.applicationSettings.AzureIoTHubTransportType); } catch (Exception ex) { this.logging.LogMessage("IoT Hub connection failed " + ex.Message, LoggingLevel.Error); return; } // Wire up the field gateway restart method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("Restart", this.RestartAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub client Restart method handler setup failed " + ex.Message, LoggingLevel.Error); return; } #if CLOUD_DEVICE_BOND // Wire up the bond device method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("DeviceBond", this.DeviceBondAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub Device Bond method handler setup failed " + ex.Message, LoggingLevel.Error); return; } #endif #if CLOUD_DEVICE_PUSH // Wire up the push message to device method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("DevicePush", this.DevicePushAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub client DevicePush SetMethodHandlerAsync failed " + ex.Message, LoggingLevel.Error); return; } #endif #if CLOUD_DEVICE_SEND // Wire up the send message to device method handler try { this.azureIoTHubClient.SetMethodHandlerAsync("DeviceSend", this.DeviceSendAsync, null); } catch (Exception ex) { this.logging.LogMessage("Azure IoT Hub client DeviceSend SetMethodHandlerAsync failed " + ex.Message, LoggingLevel.Error); return; } #endif // Configure the nRF24L01 module this.rf24.OnDataReceived += this.Radio_OnDataReceived; this.rf24.OnTransmitFailed += this.Radio_OnTransmitFailed; this.rf24.OnTransmitSuccess += this.Radio_OnTransmitSuccess; this.rf24.Initialize(RF24ModuleChipEnablePin, RF24ModuleChipSelectPin, RF24ModuleInterruptPin); this.rf24.Address = Encoding.UTF8.GetBytes(this.applicationSettings.RF24Address); this.rf24.Channel = this.applicationSettings.RF24Channel; // The order of setting the power level and Data rate appears to be important, most probably register masking issue in NRF24 library which needs some investigation this.rf24.PowerLevel = this.applicationSettings.RF24PowerLevel; this.rf24.DataRate = this.applicationSettings.RF24DataRate; this.rf24.IsAutoAcknowledge = this.applicationSettings.IsRF24AutoAcknowledge; this.rf24.IsDyanmicAcknowledge = this.applicationSettings.IsRF24DynamicAcknowledge; this.rf24.IsDynamicPayload = this.applicationSettings.IsRF24DynamicPayload; this.rf24.IsEnabled = true; LoggingFields rf24Settings = new LoggingFields(); rf24Settings.AddUInt8("Channel", this.applicationSettings.RF24Channel); rf24Settings.AddString("Address", this.applicationSettings.RF24Address); rf24Settings.AddString("DataRate", this.applicationSettings.RF24DataRate.ToString()); rf24Settings.AddString("PowerLevel", this.applicationSettings.RF24PowerLevel.ToString()); rf24Settings.AddBoolean("AutoAcknowledge", this.applicationSettings.IsRF24AutoAcknowledge); rf24Settings.AddBoolean("DynamicAcknowledge", this.applicationSettings.IsRF24DynamicAcknowledge); rf24Settings.AddBoolean("DynamicPayload", this.applicationSettings.IsRF24DynamicPayload); this.logging.LogEvent("nRF24L01 configuration", rf24Settings, LoggingLevel.Information); this.deferral = taskInstance.GetDeferral(); }
public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId packageId, VersionRange versionRange = null, string targetFramework = null, string verbosity = null) { var packageRootDirectory = _store.GetRootPackageDirectory(packageId); string rollbackDirectory = null; return(TransactionalAction.Run <IToolPackage>( action: () => { var stageDirectory = _store.GetRandomStagingDirectory(); _fileSystem.Directory.CreateDirectory(stageDirectory.Value); rollbackDirectory = stageDirectory.Value; var tempProject = new FilePath(Path.Combine(stageDirectory.Value, ProjectFileName)); // Write a fake project with the requested package id, version, and framework _fileSystem.File.WriteAllText( tempProject.Value, $"{packageId};{versionRange?.ToString("S", new VersionRangeFormatter()) ?? "*"};{targetFramework};{stageDirectory.Value}"); // Perform a restore on the fake project _projectRestorer.Restore( tempProject, packageLocation, verbosity); if (_installCallback != null) { _installCallback(); } var version = _store.GetStagedPackageVersion(stageDirectory, packageId); var packageDirectory = _store.GetPackageDirectory(packageId, version); if (_fileSystem.Directory.Exists(packageDirectory.Value)) { throw new ToolPackageException( string.Format( CommonLocalizableStrings.ToolPackageConflictPackageId, packageId, version.ToNormalizedString())); } _fileSystem.Directory.CreateDirectory(packageRootDirectory.Value); _fileSystem.Directory.Move(stageDirectory.Value, packageDirectory.Value); rollbackDirectory = packageDirectory.Value; IEnumerable <string> warnings = null; _warningsMap.TryGetValue(packageId, out warnings); IReadOnlyList <FilePath> packedShims = null; _packagedShimsMap.TryGetValue(packageId, out packedShims); return new ToolPackageMock(_fileSystem, packageId, version, packageDirectory, warnings: warnings, packagedShims: packedShims); }, rollback: () => { if (rollbackDirectory != null && _fileSystem.Directory.Exists(rollbackDirectory)) { _fileSystem.Directory.Delete(rollbackDirectory, true); } if (_fileSystem.Directory.Exists(packageRootDirectory.Value) && !_fileSystem.Directory.EnumerateFileSystemEntries(packageRootDirectory.Value).Any()) { _fileSystem.Directory.Delete(packageRootDirectory.Value, false); } })); }
public override int Execute() { var global = _options.ValueOrDefault <bool>("global"); var toolPath = _options.SingleArgumentOrDefault("tool-path"); if (string.IsNullOrWhiteSpace(toolPath) && !global) { throw new GracefulException(LocalizableStrings.UninstallToolCommandNeedGlobalOrToolPath); } if (!string.IsNullOrWhiteSpace(toolPath) && global) { throw new GracefulException(LocalizableStrings.UninstallToolCommandInvalidGlobalAndToolPath); } DirectoryPath?toolDirectoryPath = null; if (!string.IsNullOrWhiteSpace(toolPath)) { toolDirectoryPath = new DirectoryPath(toolPath); } IToolPackageStore toolPackageStore = _createToolPackageStoreAndInstaller(toolDirectoryPath); IShellShimRepository shellShimRepository = _createShellShimRepository(toolDirectoryPath); var packageId = new PackageId(_options.Arguments.Single()); IToolPackage package = null; try { package = toolPackageStore.EnumeratePackageVersions(packageId).SingleOrDefault(); if (package == null) { _errorReporter.WriteLine( string.Format( LocalizableStrings.ToolNotInstalled, packageId).Red()); return(1); } } catch (InvalidOperationException) { _errorReporter.WriteLine( string.Format( LocalizableStrings.ToolHasMultipleVersionsInstalled, packageId).Red()); return(1); } try { using (var scope = new TransactionScope( TransactionScopeOption.Required, TimeSpan.Zero)) { foreach (var command in package.Commands) { shellShimRepository.RemoveShim(command.Name); } package.Uninstall(); scope.Complete(); } _reporter.WriteLine( string.Format( LocalizableStrings.UninstallSucceeded, package.Id, package.Version.ToNormalizedString()).Green()); return(0); } catch (ToolPackageException ex) { if (Reporter.IsVerbose) { Reporter.Verbose.WriteLine(ex.ToString().Red()); } _errorReporter.WriteLine(ex.Message.Red()); return(1); } catch (Exception ex) when(ex is ToolConfigurationException || ex is ShellShimException) { if (Reporter.IsVerbose) { Reporter.Verbose.WriteLine(ex.ToString().Red()); } _errorReporter.WriteLine( string.Format( LocalizableStrings.FailedToUninstallTool, packageId, ex.Message).Red()); return(1); } }
public override int GetHashCode() { return(PackageId.GetHashCode() ^ PackageVersion.GetHashCode()); }
public override int GetHashCode() { return(IdentityType.GetHashCode() ^ ServerType.GetHashCode() ^ InstancingType.GetHashCode() ^ ServiceName.GetSafeHashCode() ^ ExePath.GetSafeHashCode() ^ Permissions.GetSafeHashCode() ^ Identity.GetSafeHashCode() ^ PackageId.GetSafeHashCode() ^ Source.GetHashCode()); }
private List <ToolManifestPackage> GetToolManifestPackageFromOneManifestFile( SerializableLocalToolsManifest deserializedManifest, FilePath path, DirectoryPath correspondingDirectory) { List <ToolManifestPackage> result = new List <ToolManifestPackage>(); var errors = new List <string>(); if (deserializedManifest.version == 0) { errors.Add(LocalizableStrings.ManifestVersion0); } if (deserializedManifest.version > SupportedVersion) { errors.Add( string.Format( LocalizableStrings.ManifestVersionHigherThanSupported, deserializedManifest.version, SupportedVersion)); } if (!deserializedManifest.isRoot.HasValue) { errors.Add(string.Format(LocalizableStrings.ManifestMissingIsRoot, path.Value)); } foreach (KeyValuePair <string, SerializableLocalToolSinglePackage> tools in deserializedManifest.tools) { var packageLevelErrors = new List <string>(); var packageIdString = tools.Key; var packageId = new PackageId(packageIdString); string versionString = tools.Value.version; NuGetVersion version = null; if (versionString is null) { packageLevelErrors.Add(LocalizableStrings.ToolMissingVersion); } else { if (!NuGetVersion.TryParse(versionString, out version)) { packageLevelErrors.Add(string.Format(LocalizableStrings.VersionIsInvalid, versionString)); } } if (tools.Value.commands == null || (tools.Value.commands != null && tools.Value.commands.Length == 0)) { packageLevelErrors.Add(LocalizableStrings.FieldCommandsIsMissing); } if (packageLevelErrors.Any()) { var joinedWithIndentation = string.Join(Environment.NewLine, packageLevelErrors.Select(e => "\t\t" + e)); errors.Add(string.Format(LocalizableStrings.InPackage, packageId.ToString(), joinedWithIndentation)); } else { result.Add(new ToolManifestPackage( packageId, version, ToolCommandName.Convert(tools.Value.commands), correspondingDirectory)); } } if (errors.Any()) { throw new ToolManifestException( string.Format(LocalizableStrings.InvalidManifestFilePrefix, path.Value, string.Join(Environment.NewLine, errors.Select(e => "\t" + e)))); } return(result); }
/// <summary> /// Downloads the documents from the package in a zip file and returns it in a byte array. /// </summary> /// <returns>The zipped documents in byte array.</returns> /// <param name="packageId">.</param> public byte[] DownloadZippedDocuments (PackageId packageId) { string path = template.UrlFor (UrlTemplate.ZIP_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { return restClient.GetBytes(path); } catch (Exception e) { throw new EslException ("Could not download the documents to a zip file." + " Exception: " + e.Message); } }
// Can be called independently of/simultaneously with InitializeStatics. // Does not use the results of InitializeStatics. // Does not require the use of a lock because, given that the results of all the callees of // this function are idempotent for the process lifetime, this function will always store // the same information in s_dependentPackagePath no matter how many times it is called. private static void InitializeStaticsForDependentPackages() { if (s_dependentPackageInfoList == null) { // Create an empty list. If there are no dependencies, this will be our way of knowing that we ran // through this function once. List <PackageInfo> dependentPackageInfoList = new List <PackageInfo>(); // We call Package.Current here and in InitializeStatics. This may cause a small perf hit. // In theory we could have cached it as a static variable. // However, we don't want to have to keep a reference to it alive for the lifetime of the AppDomain. // Also having InitializeStaticsForDependentPackages not depend on InitializeStatics leads to a simpler design. Package currentPackage = Package.Current; if (currentPackage != null) { IReadOnlyList <Package> dependencies = currentPackage.Dependencies; if (dependencies != null) { int dependenciesCount = dependencies.Count; if (dependenciesCount > 0) { // We have dependencies. Throw away the old empty list, and create a list with // capacity exactly equal to the number of dependencies. dependentPackageInfoList = new List <PackageInfo>(dependenciesCount); foreach (Package package in dependencies) { if (package != null) { StorageFolder dependentPackageLocation = package.InstalledLocation; PackageInfo dependentPackageInfo; dependentPackageInfo.Path = null; dependentPackageInfo.Name = null; dependentPackageInfo.FullName = null; if (dependentPackageLocation != null) { dependentPackageInfo.Path = dependentPackageLocation.Path; } PackageId id = package.Id; if (id != null) { dependentPackageInfo.Name = id.Name; dependentPackageInfo.FullName = id.FullName; } dependentPackageInfoList.Add(dependentPackageInfo); } } } } } // Assign even if the list is empty. That way we know we ran through this function once. s_dependentPackageInfoList = dependentPackageInfoList; } Debug.Assert(s_dependentPackageInfoList != null); }
/// <summary> /// Uploads the Document and file in byte[] to the package. /// </summary> /// <param name="packageId">The package id.</param> /// <param name="fileName">The name of the document.</param> /// <param name="fileBytes">The file to upload in bytes.</param> /// <param name="document">The document object that has field settings.</param> internal void UploadDocument (PackageId packageId, string fileName, byte[] fileBytes, Silanis.ESL.API.Document document) { Support.LogMethodEntry(packageId, fileName, document); string path = template.UrlFor (UrlTemplate.DOCUMENT_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { string json = JsonConvert.SerializeObject (document, settings); Support.LogDebug("document json = " + json); byte[] payloadBytes = Converter.ToBytes (json); string boundary = GenerateBoundary (); byte[] content = CreateMultipartContent (fileName, fileBytes, payloadBytes, boundary); restClient.PostMultipartFile(path, content, boundary); Support.LogMethodExit("Document uploaded without issue"); // Converter.ToString (HttpMethods.MultipartPostHttp (apiToken, path, content, boundary)); } catch (Exception e) { throw new EslException ("Could not upload document to package." + " Exception: " + e.Message); } }
public void SetAsRoutingPackage() { PackageId = PackageId.Replace(Package.ROUTING, ""); }
internal IList<Role> GetRoles( PackageId packageId ) { String path = template.UrlFor( UrlTemplate.ROLE_PATH ) .Replace( "{packageId}", packageId.Id ) .Build(); Result<Role> response = null; try { string stringResponse = restClient.Get(path); response = JsonConvert.DeserializeObject<Result<Role>> (stringResponse, settings); } catch( Exception e ) { throw new EslException("Unable to retrieve role list for package with id " + packageId.Id + ". " + e.Message); } return response.Results; }
public DirectoryPath GetRootPackageDirectory(PackageId packageId) { return(Root.WithSubDirectories(packageId.ToString())); }
private Role FindRoleForGroup( PackageId packageId, string groupId ) { IList<Role> roles = GetRoles(packageId); foreach (Role role in roles) { if (role.Signers.Count > 0) { Silanis.ESL.API.Signer signer = role.Signers[0]; if (signer.Group != null && signer.Group.Id.Equals(groupId)) { return role; } } } return null; }
/// <nodoc /> protected static void WritePackageId(PackageId packageId, BuildXLWriter writer) { writer.Write(packageId.Name); writer.Write(packageId.Version.MinVersion); writer.Write(packageId.Version.MaxVersion); }
public void NotifySigner (PackageId packageId, string roleId ) { string path = template.UrlFor(UrlTemplate.NOTIFY_ROLE_PATH) .Replace("{packageId}", packageId.Id) .Replace("{roleId}", roleId) .Build(); try { restClient.Post(path, ""); } catch (Exception e) { throw new EslException("Unable to send email notification. " + e.Message); } }
internal PackageId CreatePackageFromTemplate(PackageId templateId, Package delta) { string packageId = apiClient.CreatePackageFromTemplate(templateId.Id, delta); return new PackageId(packageId); }
public DirectoryPath GetPackageDirectory(PackageId packageId, NuGetVersion version) { return(GetRootPackageDirectory(packageId) .WithSubDirectories(version.ToNormalizedString().ToLowerInvariant())); }
private bool IsMatch(PackageId id) { return(string.Equals(this.PackageManager, id.PackageManager, StringComparison.OrdinalIgnoreCase) && string.Equals(this.Group, id.Group, StringComparison.OrdinalIgnoreCase) && string.Equals(this.Name, id.Name, StringComparison.OrdinalIgnoreCase)); }
/// <summary> /// Deletes the document from the package. /// </summary> /// <param name="packageId">The package id.</param> /// <param name="document">The document to delete.</param> public void DeleteDocument (PackageId packageId, Document document) { string path = template.UrlFor (UrlTemplate.DOCUMENT_ID_PATH) .Replace ("{packageId}", packageId.Id) .Replace ("{documentId}", "document.Id") .Build (); try { restClient.Delete(path); } catch (Exception e) { throw new EslException ("Could not delete document from package." + " Exception: " + e.Message); } }
private List <ToolManifestPackage> GetToolManifestPackageFromOneManifestFile( SerializableLocalToolsManifest deserializedManifest, FilePath path, DirectoryPath correspondingDirectory) { List <ToolManifestPackage> result = new List <ToolManifestPackage>(); var errors = new List <string>(); ValidateVersion(deserializedManifest, errors); if (!deserializedManifest.IsRoot.HasValue) { errors.Add(string.Format(LocalizableStrings.ManifestMissingIsRoot, path.Value)); } if (deserializedManifest.Tools != null && deserializedManifest.Tools.Count > 0) { var duplicateKeys = deserializedManifest.Tools.GroupBy(x => x.PackageId) .Where(group => group.Count() > 1) .Select(group => group.Key); if (duplicateKeys.Any()) { errors.Add(string.Format(LocalizableStrings.MultipleSamePackageId, string.Join(", ", duplicateKeys))); } } foreach (var tools in deserializedManifest.Tools ?? new List <SerializableLocalToolSinglePackage>()) { var packageLevelErrors = new List <string>(); var packageIdString = tools.PackageId; var packageId = new PackageId(packageIdString); string versionString = tools.Version; NuGetVersion version = null; if (versionString is null) { packageLevelErrors.Add(LocalizableStrings.ToolMissingVersion); } else { if (!NuGetVersion.TryParse(versionString, out version)) { packageLevelErrors.Add(string.Format(LocalizableStrings.VersionIsInvalid, versionString)); } } if (tools.Commands == null || (tools.Commands != null && tools.Commands.Length == 0)) { packageLevelErrors.Add(LocalizableStrings.FieldCommandsIsMissing); } if (packageLevelErrors.Any()) { var joinedWithIndentation = string.Join(Environment.NewLine, packageLevelErrors.Select(e => "\t\t" + e)); errors.Add(string.Format(LocalizableStrings.InPackage, packageId.ToString(), joinedWithIndentation)); } else { result.Add(new ToolManifestPackage( packageId, version, ToolCommandName.Convert(tools.Commands), correspondingDirectory)); } } if (errors.Any()) { throw new ToolManifestException( string.Format(LocalizableStrings.InvalidManifestFilePrefix, path.Value, string.Join(Environment.NewLine, errors.Select(e => "\t" + e)))); } return(result); }
internal PackageId CreateTemplateFromPackage(PackageId originalPackageId, Silanis.ESL.API.Package delta) { string templateId = apiClient.CreateTemplateFromPackage(originalPackageId.Id, delta); return new PackageId(templateId); }
public void DeleteDocument (PackageId templateId, string documentId) { packageService.DeleteDocument(templateId, documentId); }
/// <summary> /// Deletes the document from the template. /// </summary> /// <param name="templateId">The template id.</param> /// <param name="document">The document to delete.</param> public void DeleteDocument (PackageId templateId, Document document) { DeleteDocument(templateId, document.Id); }
/// <summary> /// Gets the field summary for the package and returns a list of field summaries. /// </summary> /// <returns>A list of field summaries.</returns> /// <param name="packageId">The package id.</param> public List<FieldSummary> GetFieldSummary (PackageId packageId) { // Usually we would convert to the sdk model objects expected here, but since their is not api model object being returned, // We decided it would be better to deserialize the json directly to our sdk object, instead of returning a raw string. return apiClient.GetFieldSummary(packageId.Id); }
public SessionToken CreateSessionToken (PackageId packageId, string signerId) { return CreateSignerSessionToken(packageId, signerId); }
public void RemoveSigner( PackageId packageId, string signerId ) { string path = template.UrlFor (UrlTemplate.REMOVE_SIGNER_PATH) .Replace ("{packageId}", packageId.Id) .Replace ("{roleId}", signerId) .Build (); try { restClient.Delete(path); return; } catch (EslServerException e) { throw new EslServerException ("Could not delete signer." + " Exception: " + e.Message, e.ServerError, e); } catch (Exception e) { throw new EslException ("Could not delete signer." + " Exception: " + e.Message, e); } }
private string Path( PackageId packageId ) { return template.UrlFor (UrlTemplate.REMINDER_PATH) .Replace( "{packageId}", packageId.Id ) .Build (); }
public void UnlockSigner(PackageId packageId, string senderId) { string path = template.UrlFor (UrlTemplate.ROLE_UNLOCK_PATH) .Replace ("{packageId}", packageId.Id) .Replace("{roleId}", senderId) .Build (); try { restClient.Post(path, null); } catch (EslServerException e) { throw new EslServerException ("Could not unlock signer." + " Exception: " + e.Message, e.ServerError, e); } catch (Exception e) { throw new EslException ("Could not unlock signer." + " Exception: " + e.Message, e); } }
/// <summary> /// Sends the package. /// </summary> /// <param name="packageId">The package id.</param> public void SendPackage (PackageId packageId) { string path = template.UrlFor (UrlTemplate.PACKAGE_ID_PATH) .Replace ("{packageId}", packageId.Id) .Build (); try { byte[] content = Converter.ToBytes ("{\"status\":\"SENT\"}"); restClient.Post(path, "{\"status\":\"SENT\"}"); } catch (Exception e) { throw new EslException ("Could not send the package." + " Exception: " + e.Message); } }
public override bool Execute() { var fileVersions = new Dictionary <string, FileVersionData>(StringComparer.OrdinalIgnoreCase); foreach (var file in Files) { var targetPath = file.GetMetadata("TargetPath"); if (!targetPath.StartsWith("runtimes/")) { continue; } if (file.GetMetadata("IsSymbolFile").Equals("true", StringComparison.OrdinalIgnoreCase)) { continue; } var fileName = Path.GetFileName(file.ItemSpec); var current = GetFileVersionData(file); FileVersionData existing; if (fileVersions.TryGetValue(fileName, out existing)) { if (current.AssemblyVersion != null) { if (existing.AssemblyVersion == null) { fileVersions[fileName] = current; continue; } else if (current.AssemblyVersion != existing.AssemblyVersion) { if (current.AssemblyVersion > existing.AssemblyVersion) { fileVersions[fileName] = current; } continue; } } if (current.FileVersion != null && existing.FileVersion != null) { if (current.FileVersion > existing.FileVersion) { fileVersions[fileName] = current; } } } else { fileVersions[fileName] = current; } } var props = ProjectRootElement.Create(); var itemGroup = props.AddItemGroup(); // set the platform manifest when the platform is not being published as part of the app itemGroup.Condition = "'$(RuntimeIdentifier)' == '' or '$(SelfContained)' != 'true'"; var manifestFileName = Path.GetFileName(PlatformManifestFile); itemGroup.AddItem(PlatformManifestsItem, $"$(MSBuildThisFileDirectory){manifestFileName}"); Directory.CreateDirectory(Path.GetDirectoryName(PlatformManifestFile)); using (var manifestWriter = File.CreateText(PlatformManifestFile)) { foreach (var fileData in fileVersions) { var name = fileData.Key; var versions = fileData.Value; var assemblyVersion = versions.AssemblyVersion?.ToString() ?? String.Empty; var fileVersion = versions.FileVersion?.ToString() ?? String.Empty; manifestWriter.WriteLine($"{name}|{PackageId}|{assemblyVersion}|{fileVersion}"); } } var propertyGroup = props.AddPropertyGroup(); propertyGroup.AddProperty(PreferredPackagesProperty, PreferredPackages); var versionPropertyName = $"_{PackageId.Replace(".", "_")}_Version"; propertyGroup.AddProperty(versionPropertyName, PackageVersion); props.Save(PropsFile); return(!Log.HasLoggedErrors); }