public void Add(ConnectionInfo connection) { string key = GetKey(connection); connections.Add(key, connection); var provider = new SwisMetaDataProvider(connection); metadataProviders[connection] = provider; var e = new ConnectionsEventArgs(connection); ConnectionAdded?.Invoke(this, e); }
private void AddNewQueryTab() { using (NewConnection nc = new NewConnection()) { if (nc.ShowDialog(this) != DialogResult.OK) { return; } string msg = null; try { ConnectionInfo info; bool alreadyExists = false; alreadyExists = serverList.TryGet(nc.ConnectionInfo.ServerType, nc.ConnectionInfo.Server, nc.ConnectionInfo.UserName, out info); if (!alreadyExists) { info = nc.ConnectionInfo; info.Connect(); serverList.Add(info); info.ConnectionClosed += (sender, args) => serverList.Remove(info); } if (!alreadyExists) { var provider = new SwisMetaDataProvider(info); objectExplorer.AddServer(provider, info); _metadataProviders[info] = provider; } CreateQueryTab(info.Title, info, _metadataProviders[info]); } catch (FaultException <InfoServiceFaultContract> ex) { log.Error("Failed to connect", ex); msg = ex.Detail.Message; } catch (SecurityNegotiationException ex) { log.Error("Failed to connect", ex); msg = ex.Message; } catch (FaultException ex) { log.Error("Failed to connect", ex); msg = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message; } catch (MessageSecurityException ex) { log.Error("Failed to connect", ex); if (ex.InnerException != null && ex.InnerException is FaultException) { msg = (ex.InnerException as FaultException).Message; } else { msg = ex.Message; } } catch (Exception ex) { log.Error("Failed to connect", ex); msg = ex.Message; } if (msg != null) { msg = string.Format("Unable to connect to Information Service. {0}", msg); MessageBox.Show(this, msg, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }