Exemplo n.º 1
0
        private void LoadComboTables()
        {
            try
            {
                // Obtenemos la configuracion del origen
                SettingsModel model = SettingsManager.GetXml();
                if (model == null)
                    return;

                // Obtenemos la configuracion del destino
                SettingsModel modelDest = SettingsManager.GetXml(true);

                // Inicializamos el manager de origen
                DatabaseManage manager = new DatabaseManage(model);

                // Inicializamos el manager de destino
                DatabaseManage managerDest = new DatabaseManage(modelDest);

                // Obtenemos las tablas
                List<string> tables = manager.GetTables().ToList();

                int tableCount = tables.Count();
                int tableIndex = 0;

                foreach (string table in tables)
                {
                    tableIndex++;

                    progressBarResult.BeginInvoke(new Action(() =>
                    {
                        int newValue = (int) (((float) tableIndex/tableCount)*100);
                        if (newValue > 100)
                        {
                            newValue = 100;
                        }
                        progressBarResult.Value1 = newValue;
                    }));

                    // Buscamos la tabla en la base de datos de destino,
                    // si no existe, no la mostramos
                    if (!managerDest.GetTableWithName(table)) continue;

                    // Buscamos el numero de filas
                    string numRows = manager.GetCurrentRowsForTable(table);

                    // Agregamos la tabla al combo
                    srcTableDropdown.Items.Add(new RadListDataItem
                    {
                        Value = table,
                        Text = string.Format("{0} ({1})", table, numRows)
                    });
                }
            }
            catch (Exception ex)
            {
                DisplayMessage(ex.Message);
            }
        }
        private BindingSource LoadGridTable()
        {
            try
            {
                // Obtenemos la configuracion del destino
                SettingsModel modelDest = SettingsManager.GetXml(true);
                if (modelDest == null)
                    return null;

                // Inicializamos el manager de destino
                DatabaseManage managerDest = new DatabaseManage(modelDest);

                // Obtenemos las secuencias
                IEnumerable<string> sequences = managerDest.GetAllSequences().ToList();

                // Obtenemos las tablas
                List<string> tables = managerDest.GetTables().ToList();

                List<TableSequence> sequenceList = new List<TableSequence>();

                // Comparamos cada secuencia
                foreach (string seq in sequences)
                {
                    int cutIndex = seq.IndexOf("_id_seq", StringComparison.Ordinal);

                    if (cutIndex <= 0)
                    {
                        continue;
                    }

                    string tablename = seq.Substring(0, cutIndex);

                    if (!tables.Contains(tablename))
                    {
                        continue;
                    }

                    sequenceList.Add(new TableSequence
                    {
                        Active = true,
                        Sequence = seq,
                        Table = tablename,
                        MaxId = managerDest.GetMaxIdForTable(tablename)
                    });
                }

                // Asignamos los datos al grid
                var bindingList = new BindingList<TableSequence>(sequenceList);
                var source = new BindingSource(bindingList, null);
                return source;
            }
            catch (Exception ex)
            {
                DisplayMessage(ex.Message);
            }

            return null;
        }
Exemplo n.º 3
0
        private void LoadTable(bool isDestination)
        {
            try
            {
                // Obtenemos la configuracion
                SettingsModel model = SettingsManager.GetXml(isDestination);
                if (model == null)
                    return;

                // Limpiamos el arbol
                if (isDestination)
                {
                    treeDest.Nodes.Clear();
                }
                else
                {
                    treeOrig.Nodes.Clear();
                }

                // Inicializamos el manager
                DatabaseManage manager = new DatabaseManage(model);

                // Obtenemos las tablas
                IEnumerable<string> tables = manager.GetTables();
                foreach (string table in tables)
                {
                    // Buscamos el numero de filas
                    string numRows = manager.GetRowsForTable(table);

                    // Agregamos la tabla al arbol
                    RadTreeNode tableNode = isDestination ?
                        treeDest.Nodes.Add(table, string.Format("{0} ({1})", table, numRows), "") :
                        treeOrig.Nodes.Add(table, string.Format("{0} ({1})", table, numRows), "");

                    // Obtenemos las columnas de la tabla
                    IEnumerable<string> columns = manager.GetColumnsForTable(table);
                    foreach (string column in columns)
                    {
                        // Agregamos la columna al nodo de la tabla
                        tableNode.Nodes.Add(column);
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayMessage(ex.Message);
            }
        }