public void DeleteValue(string name) { Logger.LogVerbose("Deleting EnvironmentVariableValue for EnvironmentVariableDefinition with SchemeName {0}", name); EnvironmentVariableValue current = GetValueRecord(name); if (current != null) { Logger.LogVerbose("Deleting EnvironmentVariableValue with Id = {0}", current.Id); OrganizationService.Delete(current.LogicalName, current.Id); Logger.LogInformation("Deleted EnvironmentVariableValue with Id = {0}", current.Id); } else { Logger.LogInformation("Skipping Delete as no EnvironmentVariableValue found for EnvironmentVariableDefinition with SchemeName {0}", name); } }
public string GetValue(string name) { Logger.LogVerbose("Getting EnvironmentVariableValue for EnvironmentVariableDefinition with SchemeName {0}", name); EnvironmentVariableValue env = GetValueRecord(name); if (env != null) { Logger.LogInformation("Returning EnvironmentVariableValue record found with Id = {0}", env.Id); return(env.Value); } else { Logger.LogInformation("No EnvironmentVariableValue record found for EnvironmentVariableDefinition with SchemeName {0}", name); return(null); } }
public void SetValue(string name, string value) { Logger.LogVerbose("Setting EnvironmentVariableValue for EnvironmentVariableDefinition with SchemeName {0}", name); EnvironmentVariableValue current = GetValueRecord(name); if (current != null) { if (current.Value != value) { current.Value = value; EnvironmentVariableValue update = new EnvironmentVariableValue(); update.Id = current.Id; update.Value = value; OrganizationService.Update(update); Logger.LogInformation("Updated EnvironmentVariableValue Id ={0} for EnvironmentVariableDefinition with SchemeName {1}", current.Id, name); } else { Logger.LogInformation("Skipped Update EnvironmentVariableValue Id ={0} for EnvironmentVariableDefinition with SchemeName {1} as values are same", current.Id, name); } } else { EnvironmentVariableDefinition definition = GetDefinitionRecord(name); if (definition is null) { throw new Exception($"Definition with SchemaName = {name} was not found"); } EnvironmentVariableValue create = new EnvironmentVariableValue(); create.Value = value; create.EnvironmentVariableDefinitionId = definition.ToEntityReference(); Guid Id = OrganizationService.Create(create); Logger.LogInformation("Created EnvironmentVariableValue Id ={0} for EnvironmentVariableDefinition with SchemeName {1}", Id, name); } }