Ejemplo n.º 1
0
        private void Initialize(TableDataFrame dataFrame)
        {
            m_dataFrame = dataFrame;
            int curhldindex = 0;
            int updindex    = -1;

            foreach (var holder in DataSqlGeneratorAddonType.Instance.CommonSpace.GetAllAddons())
            {
                var gen      = (IDataSqlGenerator)holder.CreateInstance();
                var tablegen = gen as TableDataSqlGeneratorBase;
                if (tablegen != null)
                {
                    if (dataFrame.TabularData.TableSource != null)
                    {
                        tablegen.FullTableName = dataFrame.TabularData.TableSource.FullName;
                    }
                    else
                    {
                        var ts = dataFrame.TabularData.GetStructure(null);
                        tablegen.FullTableName = ts.FullName;
                    }
                }
                if (gen is UpdateSqlGenerator)
                {
                    updindex = curhldindex;
                }
                lbxGenerator.Items.Add(gen);
                curhldindex++;
            }
            InitiDialects();

            addonSelectFrame1.Reload(false);

            foreach (var gen in dataFrame.GetSqlGens())
            {
                lbxGenerator.Items.Add(gen);
            }

            if (lbxGenerator.Items.Count > 0)
            {
                lbxGenerator.SelectedIndex       = updindex >= 0 ? updindex : 0;
                dataSqlGeneratorFrame1.Generator = (IDataSqlGenerator)lbxGenerator.SelectedItem;
            }
            //m_db = m_objs[0].FindDatabaseConnection(ConnPack);
            //Async.SafeOpen(m_db.Connection);

            lbxRows.Items.Add(new AllRowsExtractor(dataFrame));
            lbxRows.Items.Add(new FilteredRowsExtractor(dataFrame));
            lbxRows.Items.Add(new LoadedRowsExtractor(dataFrame));
            lbxRows.Items.Add(new SelectedRowsExtractor(dataFrame));
            lbxRows.SelectedIndex = 3;

            m_initialized = true;
            if (dataFrame.m_table != null)
            {
                dataSqlGeneratorFrame1.SetHintStructure(dataFrame.m_table.Structure, m_dataFrame.GetSelectedColumns());
            }
            btnSaveAsJob.Visible = false;
            RefreshPreview();
        }
Ejemplo n.º 2
0
        private void DoRefreshPreview()
        {
            var sw  = new StringWriter();
            var dmp = m_dialect.CreateDumper(sw, m_formatProps);

            if (m_sqlgen is IAppObjectSqlGenerator)
            {
                foreach (var obj in m_objs)
                {
                    if (m_db != null)
                    {
                        ((IAppObjectSqlGenerator)m_sqlgen).GenerateSql(m_db, obj.GetFullDatabaseRelatedName(), dmp, m_dialect);
                    }
                    else
                    {
                        ((IAppObjectSqlGenerator)m_sqlgen).GenerateSql(obj, dmp, m_dialect);
                    }
                }
            }
            if (m_sqlgen is IDataSqlGenerator)
            {
                if (((IDataSqlGenerator)m_sqlgen).IsRowEnumerator)
                {
                    var preview  = m_rowsExtractor.GetPreviewRows(m_previewRows);
                    int rowcount = m_rowsExtractor.GetRowCount();

                    dmp.Put("-- All row count: %s, preview row count: %s\n\n", rowcount, preview.Rows.Count);
                    foreach (var row in preview.Rows)
                    {
                        ((IDataSqlGenerator)m_sqlgen).GenerateSqlRow(row, dmp, m_dataFrame.GetSelectedColumns());
                    }
                }
                else
                {
                    ((IDataSqlGenerator)m_sqlgen).GenerateSql(dmp);
                }
            }
            m_preview = sw.ToString();
        }
Ejemplo n.º 3
0
 private void ForEachRow(IBedRecord row)
 {
     Generator.GenerateSqlRow(row, m_dmp, m_dataFrame.GetSelectedColumns());
 }