public EngineConfigurationWrapper(IEngineConfigurationBuilder engineConfigurationBuilder, ExecuteOptions opts, ILogger <EngineConfigurationWrapper> logger)
 {
     if (opts == null) //means that we are in init command and not execute
     {
         _engineConfiguration = engineConfigurationBuilder.BuildDefault();
         return;
     }
     if (opts.ConfigFile == string.Empty)
     {
         opts.ConfigFile = "configuration.json";
     }
     if (!File.Exists(opts.ConfigFile))
     {
         logger.LogInformation("The config file {ConfigFile} does not exist, nor does the default 'configuration.json'. Use '{ExecutableName}.exe init' to create a configuration file first", opts.ConfigFile, System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
         throw new ArgumentException("missing configfile");
     }
     logger.LogInformation("Config Found, creating engine host");
     _engineConfiguration = engineConfigurationBuilder.BuildFromFile(opts.ConfigFile);
 }
        private EngineConfiguration CreateEmptyConfig()
        {
            EngineConfiguration ec = new EngineConfiguration();

            ec.TelemetryEnableTrace = false;
            ec.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(2);
            ec.Source  = new TeamProjectConfig()
            {
                Project = "migrationSource1",
                AllowCrossProjectLinking = false,
                Collection = new Uri("https://dev.azure.com/nkdagility-preview/"),
                ReflectedWorkItemIDFieldName = "Custom.ReflectedWorkItemId",
                PersonalAccessToken          = "",
                LanguageMaps = new LanguageMaps()
                {
                    AreaPath = "Area", IterationPath = "Iteration"
                }
            };
            ec.Target = new TeamProjectConfig()
            {
                Project = "migrationTarget1",
                AllowCrossProjectLinking = false,
                Collection = new Uri("https://dev.azure.com/nkdagility-preview/"),
                ReflectedWorkItemIDFieldName = "Custom.ReflectedWorkItemId",
                PersonalAccessToken          = "",
                LanguageMaps = new LanguageMaps()
                {
                    AreaPath = "Area", IterationPath = "Iteration"
                }
            };
            ec.FieldMaps = new List <IFieldMapConfig>();
            ec.WorkItemTypeDefinition = new Dictionary <string, string> {
                { "sourceWorkItemTypeName", "targetWorkItemTypeName" }
            };
            ec.Processors = new List <ITfsProcessingConfig>();
            return(ec);
        }
 private void AddFieldMapps(EngineConfiguration ec)
 {
     ec.FieldMaps.Add(new MultiValueConditionalMapConfig()
     {
         WorkItemTypeName      = "*",
         sourceFieldsAndValues = new Dictionary <string, string>
         {
             { "Field1", "Value1" },
             { "Field2", "Value2" }
         },
         targetFieldsAndValues = new Dictionary <string, string>
         {
             { "Field1", "Value1" },
             { "Field2", "Value2" }
         }
     });
     ec.FieldMaps.Add(new FieldBlankMapConfig()
     {
         WorkItemTypeName = "*",
         targetField      = "TfsMigrationTool.ReflectedWorkItemId"
     });
     ec.FieldMaps.Add(new FieldValueMapConfig()
     {
         WorkItemTypeName = "*",
         sourceField      = "System.State",
         targetField      = "System.State",
         defaultValue     = "New",
         valueMapping     = new Dictionary <string, string> {
             { "Approved", "New" },
             { "New", "New" },
             { "Committed", "Active" },
             { "In Progress", "Active" },
             { "To Do", "New" },
             { "Done", "Closed" },
             { "Removed", "Removed" }
         }
     });
     ec.FieldMaps.Add(new FieldtoFieldMapConfig()
     {
         WorkItemTypeName = "*",
         sourceField      = "Microsoft.VSTS.Common.BacklogPriority",
         targetField      = "Microsoft.VSTS.Common.StackRank"
     });
     ec.FieldMaps.Add(new FieldtoFieldMultiMapConfig()
     {
         WorkItemTypeName       = "*",
         SourceToTargetMappings = new Dictionary <string, string>
         {
             { "SourceField1", "TargetField1" },
             { "SourceField2", "TargetField2" }
         }
     });
     ec.FieldMaps.Add(new FieldtoTagMapConfig()
     {
         WorkItemTypeName = "*",
         sourceField      = "System.State",
         formatExpression = "ScrumState:{0}"
     });
     ec.FieldMaps.Add(new FieldMergeMapConfig()
     {
         WorkItemTypeName = "*",
         sourceField1     = "System.Description",
         sourceField2     = "Microsoft.VSTS.Common.AcceptanceCriteria",
         targetField      = "System.Description",
         formatExpression = @"{0} <br/><br/><h3>Acceptance Criteria</h3>{1}"
     });
     ec.FieldMaps.Add(new RegexFieldMapConfig()
     {
         WorkItemTypeName = "*",
         sourceField      = "COMPANY.PRODUCT.Release",
         targetField      = "COMPANY.DEVISION.MinorReleaseVersion",
         pattern          = @"PRODUCT \d{4}.(\d{1})",
         replacement      = "$1"
     });
     ec.FieldMaps.Add(new FieldValuetoTagMapConfig()
     {
         WorkItemTypeName = "*",
         sourceField      = "Microsoft.VSTS.CMMI.Blocked",
         pattern          = @"Yes",
         formatExpression = "{0}"
     });
     ec.FieldMaps.Add(new TreeToTagMapConfig()
     {
         WorkItemTypeName = "*",
         timeTravel       = 1,
         toSkip           = 3
     });
 }