public EnvironmentConfiguration Verify(string environment) { if (string.IsNullOrWhiteSpace(environment)) { throw new ConfigurationException(ExceptionMessages.MissingEnvironment); } var sb = new StringBuilder(); var environmentConfig = Environments.FirstOrDefault(e => e.Name.ToUpper().Equals(environment.ToUpper())); if (null == environmentConfig) { throw new ConfigurationException($"The environment {environment} does not exist in config.json"); } if (string.IsNullOrEmpty(environmentConfig.ConnectionString)) { sb.AppendLine(ExceptionMessages.MissingConnectionString); } if (environmentConfig.ResetDatabase && string.IsNullOrWhiteSpace(environmentConfig.ResetConnectionString)) { sb.AppendLine(ExceptionMessages.MissingResetConnectionString); } // if we have any errors throw an exception if (sb.Length > 0) { throw new ConfigurationException(sb.ToString()); } return(environmentConfig); }
public async void RefreshEnvironment(Guid environmentId) { var environmentViewModel = Environments.FirstOrDefault(model => model.Server.EnvironmentID == environmentId); if (environmentViewModel != null) { await RefreshEnvironment(environmentViewModel, true); } }
void ValidateEnvironments(IShellViewModel shellViewModel) { foreach (var env in shellViewModel?.ExplorerViewModel?.Environments) { var exists = Environments.FirstOrDefault(model => model.ResourceId == env.ResourceId); if (env.IsConnected && exists == null) { Environments.Add(env); } } }
public FeatureToggle AddNewFeatureToggleForDefaultEnv(string key, string description, bool enabled) { var defaultEnv = Environments.FirstOrDefault(x => x.IsDefault); Guard.IsNotNull(defaultEnv, "Invalid default environment for this application"); var featureToggle = AddNewFeatureToggle(key, description); var appVal = defaultEnv.AddOrEditFeatureToggleValue(featureToggle.Id, enabled); return(featureToggle); }
protected virtual void AfterLoad(Guid environmentId) { if (ConnectControlViewModel != null) { ConnectControlViewModel.IsLoading = false; } var env = Environments.FirstOrDefault(a => a.ResourceId == environmentId); if (env != null && env.IsConnected) { var perm = new WindowsGroupPermission(); perm.Permissions = env.Server.GetPermissions(Guid.Empty); env.SetPropertiesForDialogFromPermissions(perm); } }
public void RemoveItem(IExplorerItemViewModel item) { if (Environments != null) { var env = Environments.FirstOrDefault(a => Equals(a.Server, item.Server)); if (env != null) { if (env.Children.Contains(item)) { env.RemoveChild(item); } else { env.RemoveItem(item); } } OnPropertyChanged(() => Environments); } }
internal virtual bool IsWordValid(Morpher morpher, Word word) { AllomorphEnvironment env = Environments.FirstOrDefault(e => !e.IsWordValid(word)); if (env != null) { if (morpher.TraceManager.IsTracing) { morpher.TraceManager.Failed(morpher.Language, word, FailureReason.Environments, this, env); } return(false); } AllomorphCoOccurrenceRule alloRule = AllomorphCoOccurrenceRules.FirstOrDefault(r => !r.IsWordValid(word)); if (alloRule != null) { if (morpher.TraceManager.IsTracing) { morpher.TraceManager.Failed(morpher.Language, word, FailureReason.AllomorphCoOccurrenceRules, this, alloRule); } return(false); } MorphemeCoOccurrenceRule morphemeRule = Morpheme.MorphemeCoOccurrenceRules.FirstOrDefault(r => !r.IsWordValid(word)); if (morphemeRule != null) { if (morpher.TraceManager.IsTracing) { morpher.TraceManager.Failed(morpher.Language, word, FailureReason.MorphemeCoOccurrenceRules, this, morphemeRule); } return(false); } return(true); }
public bool SetEnvironment(string hostname, bool keepDefaults = true) { // get ip address var ip = Environments.FirstOrDefault(s => s.Hostname == hostname)?.IpAddress; if (ip == null) { return(false); } // generate 'hostconfig' file data var hostEntries = new List <string>(); foreach (var item in Domains) { hostEntries.Add($"{ip} {item.DomainName}"); } var header = $"# hosts configuration autogenerated for environment '{hostname}' {Environment.NewLine}# at '{DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}' by '{Environment.UserName}'"; try { // identify OS var osPlatform = this.GetOSPlatform(); switch (osPlatform.ToString().ToLower()) { case "windows": { // create backup copy var hostconfigPath = @"c:\Windows\System32\Drivers\etc\hosts"; File.Copy(hostconfigPath, hostconfigPath + ".bak", true); // copy accordingly using (var sr = new StreamWriter(hostconfigPath)) { if (keepDefaults) { sr.WriteLine(this.LoadDefault()); } sr.WriteLine(header); sr.WriteLine(); foreach (var line in hostEntries) { sr.WriteLine(line); } sr.Close(); } // update current environment CurrentEnvironment = Environments.FirstOrDefault(s => s.Hostname == hostname); } break; case "osx": { // create backup copy var hostconfigPath = @"/etc/hosts"; File.Copy(hostconfigPath, hostconfigPath + ".bak", true); // copy accordingly using (var sr = new StreamWriter(hostconfigPath)) { if (keepDefaults) { sr.WriteLine(this.LoadDefault()); } sr.WriteLine(header); sr.WriteLine(); foreach (var line in hostEntries) { sr.WriteLine(line); } sr.Close(); } // update current environment CurrentEnvironment = Environments.FirstOrDefault(s => s.Hostname == hostname); break; } default: throw new Exception($"Unsupported OS: {osPlatform.ToString()}"); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } return(true); }
public AzureEnvironment GetEnvironment(string name) { return(Environments.FirstOrDefault(e => e.Name.Equals(name, System.StringComparison.OrdinalIgnoreCase))); }