private void button3_Click(object sender, EventArgs e)
        {
            connections connections = new connections();

            connections.Show();
            this.Close();
        }
 private void button7_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         Worksheet     activeSheet   = ((Worksheet)Globals.ThisAddIn.Application.Application.ActiveSheet);
         conexionTabla conexiontabla = JsonConvert.DeserializeObject <conexionTabla>(fe.ReadProperty("conexionTabla", activeSheet.CustomProperties));
         connections   ri            = new connections();
         ri.iniciarDatos(conexiontabla.Tabla);
     }catch
     {
         MessageBox.Show("Problem loading the data.");
     }
 }
Exemple #3
0
        public void Application_WorkbookOpen(Workbook Doc)
        {
            Sheets sheets = Doc.Worksheets;

            connections         con = new connections();
            funcionesEspeciales fe  = new funcionesEspeciales();

            foreach (Worksheet sheet in sheets)
            {
                if (fe.ReadProperty("conexionSeleccionada", sheet.CustomProperties) != null)
                {
                    DocEvents_ChangeEventHandler EventDel_CellsChange = new DocEvents_ChangeEventHandler(con.WorksheetChangeEventHandler);
                    sheet.Change += EventDel_CellsChange;
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (datosDeConexion.Name != "")
                {
                    /*
                     *  In the properties of the complement we are storing the connections,
                     *  then we obtain the existing connections to add the new one.
                     *  If we do not have a connection we establish that we will create a list of connections.
                     *  We validate that there is no connection with a duplicate name and
                     *  add it to the list of connections, write it in the properties of the project and save the information.
                     */
                    List <conexionesOData> lista = JsonConvert.DeserializeObject <List <conexionesOData> >(MrBotAddIn.Properties.Settings.Default.jsonDeConexiones);
                    if (lista == null)
                    {
                        lista = new List <conexionesOData>();
                    }
                    if (lista.Where(x => x.Name == datosDeConexion.Name).Count() == 0)
                    {
                        lista.Add(datosDeConexion);
                        MrBotAddIn.Properties.Settings.Default.jsonDeConexiones = JsonConvert.SerializeObject(lista);
                        MrBotAddIn.Properties.Settings.Default.Save();

                        connections connections = new connections();
                        connections.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("You already have a connection with this name.");
                    }
                }
                else
                {
                    MessageBox.Show("Enter a new name for the connection.");
                }
            }catch
            {
                MessageBox.Show("The connection could not be created, check the provided URL.");
            }
        }
        public void revisarInformacion(List <List <string> > listaDeDatosActualizados, List <List <string> > listaDeDatosCrudos)
        {
            formResultados.Show();
            formResultados.progressBar1.Maximum = listaDeDatosActualizados.Count;
            Worksheet     activeSheet   = ((Worksheet)Globals.ThisAddIn.Application.Application.ActiveSheet);
            conexionTabla conexiontabla = JsonConvert.DeserializeObject <conexionTabla>(fe.ReadProperty("conexionTabla", activeSheet.CustomProperties));
            ODataClient   client        = new ODataClient(conexiontabla.Url);
            int           index         = Convert.ToInt32(fe.ReadProperty("idLlavePrimaria", activeSheet.CustomProperties));
            int           contador      = 2;

            foreach (List <string> dato_actualizado in listaDeDatosActualizados)
            {
                List <List <string> > listaExistentes = listaDeDatosCrudos.FindAll(x => x.ElementAt(index) == dato_actualizado[index]);
                if (listaExistentes.Count > 0)
                {
                    foreach (List <string> trabajando in listaExistentes)
                    {
                        if (trabajando.SequenceEqual(dato_actualizado))
                        {
                            //MessageBox.Show("No cambio: " + dato_actualizado[1]);
                        }
                        else
                        {
                            //MessageBox.Show("Cambio: " + dato_actualizado[1]);
                            IDictionary <string, object> dictionary = crearDiccionarioUpdate(dato_actualizado, trabajando);
                            var ship = client.For(conexiontabla.Tabla).Key(dictionary).Set(dictionary).UpdateEntryAsync();

                            try
                            {
                                ship.Wait();
                                formResultados.richTextBox1.SelectionColor = Color.Green;
                                formResultados.richTextBox1.AppendText("Línea " + contador.ToString() + " - UPDATE - Correcto.\n");
                                //MessageBox.Show("Bien actualizado.\n");
                            }
                            catch
                            {
                                formResultados.richTextBox1.SelectionColor = Color.Red;
                                formResultados.richTextBox1.AppendText("Línea " + contador.ToString() + " - UPDATE - Error.\n");
                                //MessageBox.Show(ship.Exception.Message);
                                //MessageBox.Show(ship.Status.ToString());
                            }
                        }
                        listaDeDatosCrudos.Remove(trabajando);
                    }
                }
                else
                {
                    //MessageBox.Show("Insertar: " + dato_actualizado[1]);
                    IDictionary <string, object> dictionary = crearDiccionario(dato_actualizado);
                    var ship = client.For(conexiontabla.Tabla).Set(dictionary).InsertEntryAsync();
                    try
                    {
                        ship.Wait();
                        //MessageBox.Show("Dato agregado correctamente.");
                        formResultados.richTextBox1.SelectionColor = Color.Green;
                        formResultados.richTextBox1.AppendText("Línea " + contador.ToString() + " - INSERT - Correcto.\n");
                    }
                    catch
                    {
                        //MessageBox.Show(ship.Exception.Message);
                        //MessageBox.Show(ship.Status.ToString());
                        formResultados.richTextBox1.SelectionColor = Color.Red;
                        formResultados.richTextBox1.AppendText("Línea " + contador.ToString() + " - INSERT - Error.\n");
                    }
                }
                contador = contador + 1;
                formResultados.progressBar1.Value = formResultados.progressBar1.Value + 1;
            }

            foreach (List <string> eliminar in listaDeDatosCrudos)
            {
                //MessageBox.Show("Eliminar: " + eliminar[1]);
                IDictionary <string, object> dictionary = crearDiccionario(eliminar);
                var ship = client.For(conexiontabla.Tabla).Key(dictionary).DeleteEntriesAsync();
                try
                {
                    ship.Wait();
                    //MessageBox.Show("Dato eliminado");
                    formResultados.richTextBox1.SelectionColor = Color.Green;
                    formResultados.richTextBox1.AppendText("Línea - DELETE - Correcto.\n");
                }
                catch
                {
                    //MessageBox.Show(ship.Exception.Message);
                    //MessageBox.Show(ship.Status.ToString());
                    formResultados.richTextBox1.SelectionColor = Color.Red;
                    formResultados.richTextBox1.AppendText("Línea - DELETE - Error.\n");
                }
            }
            formResultados = new Resultados();
            connections ri = new connections();

            ri.traerDatosDeTabla(conexiontabla.Url, conexiontabla.Tabla, false);
        }
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            connections connections = new connections();

            connections.Show();
        }