Exemplo n.º 1
0
        public void ExtractAndWriteData()
        {
            for (int i = 0; i < tableList.Length; i++)
            {
                if (this.ProcessingTableData != null)
                {
                    this.ProcessingTableData(null, new ProcessingTableDataEventArgs(tableList[i], "Getting Column and Key Information", false));
                }

                ColumnInfo[] columnNamesWithTypes = InfoHelper.GetColumnNamesWithTypes(tableList[i], connData);
                int          originalCols         = columnNamesWithTypes.Length;
                string[]     pkName = InfoHelper.GetPrimaryKeyColumns(tableList[i], connData);
                SqlCommand   cmd    = BuildCommand(tableList[i], pkName, ref columnNamesWithTypes);

                string command = cmd.CommandText;
                if (originalCols != columnNamesWithTypes.Length)
                {
                    command += "\r\n--NOTE: Binary column types excluded";
                }

                string header = String.Format(PopulateHelper.scriptHeader,
                                              DateTime.Now.ToString(),
                                              tableList[i],
                                              command,
                                              this.connData.SQLServerName,
                                              this.connData.DatabaseName,
                                              String.Join(",", pkName),
                                              System.Environment.UserName);

                WriteData(tableList[i], cmd, columnNamesWithTypes, header);
            }
            if (this.ProcessingTableData != null)
            {
                this.ProcessingTableData(null, new ProcessingTableDataEventArgs("", "", true));
            }
        }