From d124cb9b8e7d60fcbb2e56880b6892e2078746d4 Mon Sep 17 00:00:00 2001 From: christianwade Date: Wed, 22 Feb 2017 18:12:23 -0800 Subject: [PATCH] ModelConfigurationIDs command-line parameter --- .../ArgumentOptions.cs | 3 +++ .../Program.cs | 11 ++++++-- .../ConfigDatabaseHelper.cs | 27 +++++++++++-------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/AsPartitionProcessing/AsPartitionProcessing.SampleClient/ArgumentOptions.cs b/AsPartitionProcessing/AsPartitionProcessing.SampleClient/ArgumentOptions.cs index cff15b7..8718998 100644 --- a/AsPartitionProcessing/AsPartitionProcessing.SampleClient/ArgumentOptions.cs +++ b/AsPartitionProcessing/AsPartitionProcessing.SampleClient/ArgumentOptions.cs @@ -18,6 +18,9 @@ namespace AsPartitionProcessing.SampleClient [Option('k', "MergePartitionKey", HelpText = "When ExecutionMode=MergePartitions, target partition key. If year, follow yyyy; if month follow yyyymm.")] public string MergePartitionKey { get; set; } + [Option('i', "ModelConfigurationIDs", HelpText = "When connect to config database, only process models with ModelConfigurationID in a comma-delimited list.")] + public string ModelConfigurationIDs { get; set; } + [ParserState] public IParserState LastParserState { get; set; } diff --git a/AsPartitionProcessing/AsPartitionProcessing.SampleClient/Program.cs b/AsPartitionProcessing/AsPartitionProcessing.SampleClient/Program.cs index e387788..18be712 100644 --- a/AsPartitionProcessing/AsPartitionProcessing.SampleClient/Program.cs +++ b/AsPartitionProcessing/AsPartitionProcessing.SampleClient/Program.cs @@ -38,7 +38,8 @@ namespace AsPartitionProcessing.SampleClient class Program { //Set sample execution mode here: - private static ExecutionMode _executionMode = ExecutionMode.InitializeInline; + private static ExecutionMode _executionMode = ExecutionMode.InitializeFromDatabase; + private static string _modelConfigurationIDs; static int Main(string[] args) { @@ -214,7 +215,7 @@ namespace AsPartitionProcessing.SampleClient connectionInfo.Password = ReadPassword(); } - return ConfigDatabaseHelper.ReadConfig(connectionInfo); + return ConfigDatabaseHelper.ReadConfig(connectionInfo, _modelConfigurationIDs); } private static void ParseArgs(string[] args, ref string mergeTable, ref Granularity mergeTargetGranuarity, ref string mergePartitionKey, out bool help) @@ -225,6 +226,12 @@ namespace AsPartitionProcessing.SampleClient ArgumentOptions options = new ArgumentOptions(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { + if (!String.IsNullOrEmpty(options.ModelConfigurationIDs)) + { + Console.WriteLine($"ModelConfigurationIDs: {options.ModelConfigurationIDs}"); + _modelConfigurationIDs = options.ModelConfigurationIDs; + } + Console.WriteLine($"Argument ExecutionMode: {options.ExecutionMode}"); switch (options.ExecutionMode) { diff --git a/AsPartitionProcessing/AsPartitionProcessing/ConfigDatabaseHelper.cs b/AsPartitionProcessing/AsPartitionProcessing/ConfigDatabaseHelper.cs index 995d71a..fe94104 100644 --- a/AsPartitionProcessing/AsPartitionProcessing/ConfigDatabaseHelper.cs +++ b/AsPartitionProcessing/AsPartitionProcessing/ConfigDatabaseHelper.cs @@ -14,17 +14,11 @@ namespace AsPartitionProcessing /// Read configuration information from the database. /// /// Information required to connect to the configuration and logging database. + /// Comma delimited list of ModelConfigurationIDs to filter on when getting worklist from workspace database. /// Collection of partitioned models with configuration information. - public static List ReadConfig(ConfigDatabaseConnectionInfo connectionInfo) + public static List ReadConfig(ConfigDatabaseConnectionInfo connectionInfo, string modelConfigurationIDs) { - using (SqlConnection connection = new SqlConnection(GetConnectionString(connectionInfo))) - { - connection.Open(); - using (SqlCommand command = new SqlCommand()) - { - command.Connection = connection; - command.CommandType = CommandType.Text; - command.CommandText = @" + string commandText = String.Format(@" SELECT [ModelConfigurationID] ,[AnalysisServicesServer] ,[AnalysisServicesDatabase] @@ -43,13 +37,24 @@ namespace AsPartitionProcessing ,[MaxDateIsNow] ,[MaxDate] ,[IntegerDateKey] + ,[TemplateSourceQuery] FROM [dbo].[vPartitioningConfiguration] - WHERE [DoNotProcess] = 0 + WHERE [DoNotProcess] = 0 {0} ORDER BY [ModelConfigurationID], [TableConfigurationID], - [PartitioningConfigurationID];"; + [PartitioningConfigurationID];", + (String.IsNullOrEmpty(modelConfigurationIDs) ? "" : $" AND [ModelConfigurationID] IN ({modelConfigurationIDs}) ")); + + using (SqlConnection connection = new SqlConnection(GetConnectionString(connectionInfo))) + { + connection.Open(); + using (SqlCommand command = new SqlCommand()) + { + command.Connection = connection; + command.CommandType = CommandType.Text; + command.CommandText = commandText; List modelConfigs = new List(); ModelConfiguration modelConfig = null;