示例#1
0
        protected String checkTable(CollectorConfig cfg, CollectionItemConfig itm)
        {
            String sqlCheck = @"
                SELECT QUOTENAME(SCHEMA_NAME(schema_id)) + '.' + QUOTENAME(name)  AS targetTable
                FROM [{0}].sys.tables 
                WHERE name = '{1}' 
                    AND schema_id IN (SCHEMA_ID('custom_snapshots'), SCHEMA_ID('snapshots'))
                ORDER BY CASE SCHEMA_NAME(schema_id) 
                        WHEN 'custome_snapshots' THEN 1
                        WHEN 'snapshots' THEN 2 
                    END ";

            sqlCheck = String.Format(sqlCheck, cfg.MDWDatabase, itm.OutputTable);

            DataTable data = CollectorUtils.GetDataTable(cfg.MDWInstance, cfg.MDWDatabase, sqlCheck);

            // table is not missing
            if (data.Rows.Count > 0)
            {
                return(data.Rows[0]["targetTable"].ToString());
            }
            else
            {
                if (verbose)
                {
                    logger.logMessage("Creating target table " + itm.OutputTable);
                }
                return(null);
            }
        }
示例#2
0
        protected String createTargetTable(
            CollectorConfig cfg,
            CollectionItemConfig itm,
            DataTable data
            )
        {
            int    ConnectionTimeout = 15;
            String ConnectionString  = String.Format("Server={0};Database={1};Integrated Security=True;Connect Timeout={2}", cfg.MDWInstance, cfg.MDWDatabase, ConnectionTimeout);

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConnectionString;
                conn.Open();

                DataTableTSQLAdapter adapter = new DataTableTSQLAdapter(conn);
                adapter.DestinationTableName = "[custom_snapshots].[" + itm.OutputTable + "]";
                adapter.CreateFromDataTable(data);
            }
            return("[custom_snapshots].[" + itm.OutputTable + "]");
        }
示例#3
0
 /*
  * Creates the target table from the
  * output definition of the query
  */
 protected abstract String createTargetTable(
     CollectorConfig cfg,
     CollectionItemConfig itm
     );