public void iniciarDatos(string _tabla) { //You always work on the active sheet Worksheet activeSheet = ((Worksheet)Globals.ThisAddIn.Application.Application.ActiveSheet); activeSheet.Change -= WorksheetChangeEventHandler; //The established connection of the properties of the sheet is obtained conexionSeleccionada = JsonConvert.DeserializeObject <conexionesOData>(fe.ReadProperty("conexionSeleccionada", activeSheet.CustomProperties)); //The OData connection is established client = new ODataClient(conexionSeleccionada.Url); //Lets create an object to store the connection of the table conexionTabla conexiontabla = new conexionTabla(); conexiontabla.Url = conexionSeleccionada.Url; conexiontabla.Tabla = _tabla; //The connection property to the table is created for the sheet and the value is assigned if (fe.ReadProperty("conexionTabla", activeSheet.CustomProperties) == null) { activeSheet.CustomProperties.Add("conexionTabla", JsonConvert.SerializeObject(conexiontabla)); } else { fe.setProperty("conexionTabla", activeSheet.CustomProperties, JsonConvert.SerializeObject(conexiontabla)); } obtenerColumnasDeTabla(activeSheet, _tabla); traerDatosDeTabla(conexionSeleccionada.Url, _tabla, true); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { /* * Every time the connection combobox changes an action is made. * If the selected option is "New" then the interface to create a new connection is opened. * If the option is one of the connections already created, it proceeds to obtain the tables it has. And they are loaded in the Tables combobox. */ if (comboBox1.Text == "New") { nuevaConexion nuevaConexion = new nuevaConexion(); nuevaConexion.Show(); this.Close(); } else { comboBox2.Text = ""; List <conexionesOData> lista = JsonConvert.DeserializeObject <List <conexionesOData> >(MrBotAddIn.Properties.Settings.Default.jsonDeConexiones); conexionSeleccionada = lista.Find(x => x.Name == comboBox1.Text); client = new ODataClient(conexionSeleccionada.Url); llamada(client); } }