ModelConfigurationIDs command-line parameter

This commit is contained in:
christianwade 2017-02-22 18:12:23 -08:00
Родитель 54ab47536f
Коммит d124cb9b8e
3 изменённых файлов: 28 добавлений и 13 удалений

Просмотреть файл

@ -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; }

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -14,17 +14,11 @@ namespace AsPartitionProcessing
/// Read configuration information from the database.
/// </summary>
/// <param name="connectionInfo">Information required to connect to the configuration and logging database.</param>
/// <param name="modelConfigurationIDs">Comma delimited list of ModelConfigurationIDs to filter on when getting worklist from workspace database.</param>
/// <returns>Collection of partitioned models with configuration information.</returns>
public static List<ModelConfiguration> ReadConfig(ConfigDatabaseConnectionInfo connectionInfo)
public static List<ModelConfiguration> 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<ModelConfiguration> modelConfigs = new List<ModelConfiguration>();
ModelConfiguration modelConfig = null;