Пример #1
0
        protected override void GetInitializedQuery_Graywulf(QueryBase query, string queryString, string outputTable)
        {
            var ef = new EntityFactory(Context);

            var federation = ef.LoadEntity <Federation>(Registry.AppSettings.FederationName);
            var jd         = ef.LoadEntity <JobDefinition>(Registry.AppSettings.FederationName, typeof(SqlQueryJob).Name);

            var settings = new SqlQueryJobSettings(jd.Settings);

            var user = new User(Context);

            user.Guid = Context.UserGuid;
            user.Load();

            query.ExecutionMode            = ExecutionMode.Graywulf;
            query.FederationReference.Name = Registry.AppSettings.FederationName;
            query.QueryString = queryString;

            query.SourceDatabaseVersionName = settings.HotDatabaseVersionName;
            query.StatDatabaseVersionName   = settings.StatDatabaseVersionName;

            query.QueryTimeout = settings.QueryTimeout;

            // Add MyDB as custom source
            var mydbds = new GraywulfDataset();

            mydbds.Name = settings.DefaultDatasetName;
            mydbds.DefaultSchemaName      = settings.DefaultSchemaName;
            mydbds.DatabaseInstance.Value = federation.MyDBDatabaseVersion.GetUserDatabaseInstance(user);
            mydbds.CacheSchemaConnectionString();
            mydbds.IsMutable = true;
            query.CustomDatasets.Add(mydbds);

            query.DefaultDataset = mydbds;

            // Set up MYDB for destination
            // ****** TODO add output table name to settings */
            query.Destination = new DestinationTable(
                mydbds,
                mydbds.DatabaseName,
                settings.DefaultSchemaName,
                String.IsNullOrWhiteSpace(outputTable) ? "outputtable" : outputTable,
                TableInitializationOptions.Drop | TableInitializationOptions.Create);

            // Set up temporary database
            var tempds = new GraywulfDataset();

            tempds.Name                  = Registry.Constants.TempDbName;
            tempds.IsOnLinkedServer      = false;
            tempds.DatabaseVersion.Value = federation.TempDatabaseVersion;
            query.TemporaryDataset       = tempds;

            // Set up code database
            var codeds = new GraywulfDataset();

            codeds.Name                  = Registry.Constants.CodeDbName;
            codeds.IsOnLinkedServer      = false;
            codeds.DatabaseVersion.Value = federation.CodeDatabaseVersion;
            query.CodeDataset            = codeds;
        }
Пример #2
0
        protected override void GetInitializedQuery_Graywulf(QueryBase query, string queryString, string outputTable)
        {
            var ef = new EntityFactory(Context);

            var federation = ef.LoadEntity<Federation>(Registry.AppSettings.FederationName);
            var jd = ef.LoadEntity<JobDefinition>(Registry.AppSettings.FederationName, typeof(SqlQueryJob).Name);

            var settings = new SqlQueryJobSettings(jd.Settings);

            var user = new User(Context);
            user.Guid = Context.UserGuid;
            user.Load();

            query.ExecutionMode = ExecutionMode.Graywulf;
            query.FederationReference.Name = Registry.AppSettings.FederationName;
            query.QueryString = queryString;

            query.SourceDatabaseVersionName = settings.HotDatabaseVersionName;
            query.StatDatabaseVersionName = settings.StatDatabaseVersionName;

            query.QueryTimeout = settings.QueryTimeout;

            // Add MyDB as custom source
            var mydbds = new GraywulfDataset();
            mydbds.Name = settings.DefaultDatasetName;
            mydbds.DefaultSchemaName = settings.DefaultSchemaName;
            mydbds.DatabaseInstance.Value = federation.MyDBDatabaseVersion.GetUserDatabaseInstance(user);
            mydbds.CacheSchemaConnectionString();
            mydbds.IsMutable = true;
            query.CustomDatasets.Add(mydbds);

            query.DefaultDataset = mydbds;

            // Set up MYDB for destination
            // ****** TODO add output table name to settings */
            query.Destination = new DestinationTable(
                mydbds,
                mydbds.DatabaseName,
                settings.DefaultSchemaName,
                String.IsNullOrWhiteSpace(outputTable) ? "outputtable" : outputTable,
                TableInitializationOptions.Drop | TableInitializationOptions.Create);

            // Set up temporary database
            var tempds = new GraywulfDataset();
            tempds.Name = Registry.Constants.TempDbName;
            tempds.IsOnLinkedServer = false;
            tempds.DatabaseVersion.Value = federation.TempDatabaseVersion;
            query.TemporaryDataset = tempds;

            // Set up code database
            var codeds = new GraywulfDataset();
            codeds.Name = Registry.Constants.CodeDbName;
            codeds.IsOnLinkedServer = false;
            codeds.DatabaseVersion.Value = federation.CodeDatabaseVersion;
            query.CodeDataset = codeds;
        }