public void EditConnection(TDSettings.ConnectionRow connectionValues) { TDSettings.ConnectionRow[] rowConn = this.Connection.Select("ConnectionId=" + connectionValues.ConnectionId) as TDSettings.ConnectionRow[]; if (rowConn != null && rowConn.Length == 1) { rowConn[0].ConnectionName = connectionValues.ConnectionName; rowConn[0].URL = connectionValues.URL; rowConn[0].Type = connectionValues.Type; rowConn[0].UserName = connectionValues.UserName; rowConn[0].Password = connectionValues.Password; rowConn[0].RememberPassword = connectionValues.RememberPassword; rowConn[0].ActiveUser = connectionValues.ActiveUser; rowConn[0].Charset = connectionValues.Charset; SavingData sp = new SavingData(OperationType.EditConnection, rowConn[0]); this.SaveXML(sp); } }
public int AddConnection(string connectionName, string url, string connectionType, string userName, string password, bool rememberPass, bool activeUser) { TDSettings.ConnectionRow connectionRow = this.Connection.NewConnectionRow(); connectionRow.ConnectionName = connectionName; connectionRow.URL = url; connectionRow.Type = connectionType; connectionRow.UserName = userName; connectionRow.Password = password; connectionRow.RememberPassword = rememberPass; connectionRow.ActiveUser = activeUser; this.Connection.Rows.Add(connectionRow); SavingData sp = new SavingData(OperationType.AddConnection, connectionRow); this.SaveXML(sp); return(connectionRow.ConnectionId); }
public void EditConnection(int connectionId, string connectionName, string url, string connectionType, string userName, string password, bool rememberPass, bool activeUser) { TDSettings.ConnectionRow[] rowConn = this.Connection.Select("ConnectionId=" + connectionId.ToString()) as TDSettings.ConnectionRow[]; if (rowConn != null && rowConn.Length == 1) { rowConn[0].ConnectionName = connectionName; rowConn[0].URL = url; rowConn[0].Type = connectionType; rowConn[0].UserName = userName; rowConn[0].Password = password; rowConn[0].RememberPassword = rememberPass; rowConn[0].ActiveUser = activeUser; SavingData sp = new SavingData(OperationType.EditConnection, rowConn[0]); this.SaveXML(sp); } }
public void DeleteConnection(int connectionId) { TDSettings.ConnectionRow[] connRow = this.Connection.Select("ConnectionId=" + connectionId.ToString()) as TDSettings.ConnectionRow[]; if (connRow != null && connRow.Length == 1) { this.Connection.RemoveConnectionRow(connRow[0]); ConnectionRow delConn = new ConnectionDataTable().NewConnectionRow(); delConn.ConnectionId = connectionId; SavingData sp = new SavingData(OperationType.DeleteConnection, delConn); this.SaveXML(sp); } }
private void SaveXML(SavingData data) { this.EncryptPasswordsBeforeSaving(); this.WriteXml(_fileName); this.DecryptPasswordsAfterSaving(); this.AcceptChanges(); if (data == null) { return; } else { // fire the event if (SaveSettings != null) { this.SaveSettings(this, new MyZillaSettingsEventArgs(data)); } } }
void bkgCatalogues_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { CustomException ex = (CustomException)e.Error; string errorMessage; if (ex != null) { if (this.CatalogueEvent != null) { SavingData sp = ex.CustomData; if (sp.Operation == OperationType.LogOnFailed) { // no code here. } else { sp.Operation = OperationType.AddConnectionThrowsError; } if (this.CatalogueEvent != null) { this.CatalogueEvent(this, new MyZillaSettingsEventArgs(sp)); } } errorMessage = Messages.ErrLoadingCatalogues + Environment.NewLine + ex.InnerException.Message; } else { errorMessage = Messages.ErrLoadingCatalogues + Environment.NewLine + e.Error.Message; } if (!string.IsNullOrEmpty(errorMessage)) { MyLogger.Write(errorMessage, "bkgCatalogues_RunWorkerCompleted", LoggingCategory.Exception); } } // status OK if (!e.Cancelled && e.Error == null) { ArrayList result = e.Result as ArrayList; Catalogues cataloguesPerUser = result[0] as Catalogues; SavingData sp = result[1] as SavingData; if (result[0] != null) { // check if catalogues exist bool areLoaded = this.AreCataloguesLoaded(cataloguesPerUser.ConnectionId); if (areLoaded) { // remove if exist this.RemoveCataloguesForConnection(cataloguesPerUser.ConnectionId); } // add catalogues per user globalCataloguesCollection.Add(cataloguesPerUser); if (this.CatalogueEvent != null) { this.CatalogueEvent(this, new MyZillaSettingsEventArgs(sp)); } } else { if (this.CatalogueEvent != null) { TDSettings.ConnectionRow connectionRow = sp.ConnectionRow ; SavingData spWhenNullCatalogues = new SavingData(OperationType.AddConnectionThrowsError, connectionRow); this.CatalogueEvent(this, new MyZillaSettingsEventArgs(spWhenNullCatalogues)); } } } }
// TO DO load catalogues for connection public void LoadCataloguesForUser(int connectionId) { TDSettings.ConnectionRow connection = _appSettings.GetConnectionById (connectionId ) ; if (String.IsNullOrEmpty(connection.Charset)) { IUtilities utilities = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(connectionId); connection.Charset = utilities.GetBugzillaCharset(connection.URL); _appSettings.EditConnection(connection); } SavingData data = new SavingData( OperationType.EditConnection , connection ); this.LoadCataloguesForUser(data); }
private void LoadCataloguesForUser(SavingData data) { // check if the catalogues collection has loaded. bool isLoaded = false; for (int i = 0; i < globalCataloguesCollection.Count; i++) { if (globalCataloguesCollection[i].ConnectionId == data.ConnectionRow.ConnectionId ) { isLoaded = true; } } if (!isLoaded) { TDSettings.ConnectionRow connection = _appSettings.GetConnectionById (data.ConnectionRow.ConnectionId ); BackgroundWorker bwCatalogues = new BackgroundWorker(); bwCatalogues.DoWork += new DoWorkEventHandler(bkgCatalogues_DoWork); bwCatalogues.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bkgCatalogues_RunWorkerCompleted); bwCatalogues.ProgressChanged += new ProgressChangedEventHandler(bkgCatalogues_ProgressChanged); bwCatalogues.WorkerReportsProgress = true; bwCatalogues.WorkerSupportsCancellation = true; ArrayList al = new ArrayList(); al.Add(connection ); al.Add(data); bwCatalogues.RunWorkerAsync(al); } }
public MyZillaSettingsEventArgs(SavingData data) { _data = data; }
public MyZillaSettingsEventArgs( SavingData data) { _data = data; }
private void SaveXML( SavingData data) { this.EncryptPasswordsBeforeSaving(); this.WriteXml(_fileName); this.DecryptPasswordsAfterSaving(); this.AcceptChanges(); if (data == null) { return; } else { // fire the event if (SaveSettings != null) { this.SaveSettings(this, new MyZillaSettingsEventArgs ( data ) ); } } }
public void EditConnection(int connectionId, string connectionName, string url, string connectionType, string userName, string password, bool rememberPass, bool activeUser) { TDSettings.ConnectionRow[] rowConn = this.Connection.Select("ConnectionId=" + connectionId.ToString()) as TDSettings.ConnectionRow[]; if (rowConn != null && rowConn.Length == 1 ) { rowConn[0].ConnectionName = connectionName; rowConn[0].URL = url; rowConn[0].Type = connectionType; rowConn[0].UserName = userName; rowConn[0].Password = password; rowConn[0].RememberPassword = rememberPass; rowConn[0].ActiveUser = activeUser; SavingData sp = new SavingData( OperationType.EditConnection , rowConn[0] ); this.SaveXML( sp); } }
public void DeleteConnection(int connectionId) { TDSettings.ConnectionRow[] connRow = this.Connection.Select("ConnectionId=" + connectionId.ToString()) as TDSettings.ConnectionRow[]; if (connRow != null && connRow.Length == 1) { this.Connection.RemoveConnectionRow(connRow[0]); ConnectionRow delConn = new ConnectionDataTable ().NewConnectionRow (); delConn.ConnectionId = connectionId; SavingData sp = new SavingData (OperationType.DeleteConnection , delConn ); this.SaveXML( sp); } }
public int AddConnection(string connectionName, string url, string connectionType, string userName, string password, bool rememberPass, bool activeUser) { TDSettings.ConnectionRow connectionRow = this.Connection.NewConnectionRow(); connectionRow.ConnectionName = connectionName; connectionRow.URL = url; connectionRow.Type = connectionType; connectionRow.UserName = userName; connectionRow.Password = password; connectionRow.RememberPassword = rememberPass; connectionRow.ActiveUser = activeUser; this.Connection.Rows.Add(connectionRow); SavingData sp = new SavingData( OperationType.AddConnection , connectionRow ); this.SaveXML( sp); return connectionRow.ConnectionId ; }