/// <summary> /// The get credentials. /// </summary> private void GetCredentials() { var cm = new Credential { Target = "VSSonarQubeExtension", }; if (!cm.Exists()) { return; } cm.Load(); try { string address = this.configurationHelper.ReadSetting(Context.GlobalPropsId, OwnersId.ApplicationOwnerId, "ServerAddress").Value; string bootatstart = this.configurationHelper.ReadSetting(Context.GlobalPropsId, OwnersId.ApplicationOwnerId, GlobalIds.IsConnectAtStartOn).Value; if (address != null && bootatstart.Equals("true")) { if (AuthtenticationHelper.EstablishAConnection(this.restService, address, cm.Username, ConnectionConfiguration.ConvertToUnsecureString(cm.SecurePassword))) { this.UserName = cm.Username; this.ServerAddress = address; this.Password = ConnectionConfiguration.ConvertToUnsecureString(cm.SecurePassword); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
/// <summary> /// The get credentials. /// </summary> private void GetCredentials() { using (var cm = new Credential { Target = "VSSonarQubeExtension" }) { if (!cm.Exists()) { return; } cm.Load(); string address = "http://localhost:9000"; try { address = this.configurationHelper.ReadSetting(Context.GlobalPropsId, OwnersId.ApplicationOwnerId, "ServerAddress").Value; } catch (Exception ex) { this.notificationManager.ReportMessage(new Message { Id = "GeneralConfigurationViewModel", Data = "Failed To Connect To Server: " + ex.Message }); this.notificationManager.ReportException(ex); } string bootatstart = "false"; try { bootatstart = this.configurationHelper.ReadSetting(Context.GlobalPropsId, OwnersId.ApplicationOwnerId, GlobalIds.IsConnectAtStartOn).Value; } catch (Exception ex) { this.notificationManager.ReportMessage(new Message { Id = "GeneralConfigurationViewModel", Data = "Failed To Get Connect at Start: " + ex.Message }); } this.UserName = cm.Username; this.Password = ConnectionConfiguration.ConvertToUnsecureString(cm.SecurePassword); this.ServerAddress = address; if (address != null) { AuthtenticationHelper.EstablishAConnection(this.restService, address, cm.Username, ConnectionConfiguration.ConvertToUnsecureString(cm.SecurePassword)); } } }