private void PasswordBox_PasswordChanged_1(object sender, RoutedEventArgs e) { if (this.DataContext != null) { ((dynamic)this.DataContext).SecurePassword = ((PasswordBox)sender).SecurePassword; } SapConfigModule.Current.Hpass = ((PasswordBox)sender).SecurePassword; var oo = e.Source; ConnectionItem sss = dgConnections.CurrentItem as ConnectionItem; SapConfigModule.Current.ConnectionItems[dgConnections.SelectedIndex].pass = ((PasswordBox)sender).SecurePassword; foreach (ConnectionItem item in SapConfigModule.Current.ConnectionItems) { ConnectionItem ss = (ConnectionItem)dgConnections.CurrentItem; if (item.name == ss.name) { item.pass = ((PasswordBox)sender).SecurePassword; } } Project.Current.SetDirty(true); }
public async Task AddToMapCallback2(CancelableProgressorSource cpd) { try { await QueuedTask.Run(() => { if (MapView.Active == null) { _strMessage.SelectString = "No active map view."; cpd.Message = "There is no active map view. Please select a map and try again."; return; } //create table name for the toc layer Random r = new Random(); int n = r.Next(); string s = n.ToString(); s = s.Substring(s.Length - 4); string lyrname = _currentTable + "_" + s; //open an Esri database connection type to sap ComboBoxItem item2 = (ComboBoxItem)cboEnv.cboBox.SelectedItem; ConnectionItem connitem = item2.Icon as ConnectionItem; string tst2 = new System.Net.NetworkCredential(string.Empty, connitem.pass).Password; string serverport = connitem.server.ToString(); DatabaseConnectionProperties connectionProperties; if (Globals.RdbmsType == "Hana") { string inst = serverport.Substring(0, serverport.IndexOf(":")); connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.Hana) { AuthenticationMode = AuthenticationMode.DBMS, Instance = inst, //cboEnv.cboBox.Text, //@"sapqe2hana", User = connitem.userid, Password = tst2, Version = "dbo.DEFAULT" }; } else if (Globals.RdbmsType == "Oracle") { connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle) { AuthenticationMode = AuthenticationMode.DBMS, Instance = serverport, //cboEnv.cboBox.Text, //@"sapqe2hana", User = connitem.userid, Password = tst2, Version = "sde.DEFAULT" }; } //=====================add to map QueryText.SelectString = "SELECT * FROM \"" + _currentSchema + "\".\"" + _currentTable + "\""; using (Database db = new Database(connectionProperties)) { QueryDescription qds = db.GetQueryDescription(_querytext.SelectString, lyrname); Table pTab2 = db.OpenTable(qds); if (_spatialCol.SelectString != "" && _objidCol.SelectString != "none") { _strMessage.SelectString = "Adding Layer"; // Add a new layer to the map FeatureLayer pFL = (FeatureLayer)LayerFactory.Instance.CreateLayer(pTab2.GetDataConnection(), MapView.Active.Map, layerName: lyrname); pFL.Select(null, SelectionCombinationMethod.New); MapView.Active.ZoomToSelected(); pFL.ClearSelection(); FeatureClass featureClass = pFL.GetFeatureClass(); _strMessage.SelectString = "Layer added."; cpd.Message = "Layer added."; MessageBox.Show("Layer added successsful to map."); } else { StandaloneTable pFL = (StandaloneTable)StandaloneTableFactory.Instance.CreateStandaloneTable(pTab2.GetDataConnection(), MapView.Active.Map, tableName: lyrname); _strMessage.SelectString = "Table added."; cpd.Message = "Standalone table added successsfuly to map."; MessageBox.Show("Standalone table added successsfuly to map."); } } cpd.Dispose(); }); } catch (Exception ex) { lock (_aLock) { BtnMapVis = false; } MessageBox.Show("The table could not be added to ArcGIS Pro. " + ex.Message.ToString()); if (Globals.DBConn.State != ConnectionState.Closed) { Globals.DBConn.Close(); } cpd.Message = "Table not added."; cpd.Dispose(); } }