Ejemplo n.º 1
0
        public EngineConfiguration BuildFromFile(string configFile = "configuration.json")
        {
            EngineConfiguration ec = null;

            try
            {
                string configurationjson = File.ReadAllText(configFile);
                ec = JsonConvert.DeserializeObject <EngineConfiguration>(configurationjson,
                                                                         new FieldMapConfigJsonConverter(),
                                                                         new ProcessorConfigJsonConverter(),
                                                                         new JsonConverterForEndpointOptions(),
                                                                         new JsonConverterForEnricherOptions(),
                                                                         new MigrationClientConfigJsonConverter());
            }
            catch (JsonSerializationException ex)
            {
                _logger.LogTrace(ex, "Configuration Error");
                _logger.LogCritical("Your configuration file is malformed and cant be loaded!");
                _logger.LogError(ex.Message);
                _logger.LogError("How to Solve: Malformed Json is usually a result of editing errors. Validate that your {configFile} is valid Json!", configFile);
                Environment.Exit(-1);
                return(null);
            }
            catch (JsonReaderException ex)
            {
                _logger.LogTrace(ex, "Configuration Error");
                _logger.LogCritical("Your configuration file was loaded but was unable to be mapped to ");
                _logger.LogError(ex.Message);
                _logger.LogError("How to Solve: Malformed configurations are usually a result of changes between versions. The best way to understand the change is to run 'migration.exe init' to create a new wel formed config and determin where the problem is!");
                Environment.Exit(-1);
                return(null);
            }

            //var builder = new ConfigurationBuilder();
            //builder.SetBasePath(Directory.GetCurrentDirectory());
            //builder.AddJsonFile(configFile, optional: false, reloadOnChange: true);
            //IConfigurationRoot configuration = builder.Build();
            //var settings = new EngineConfiguration();
            //configuration.Bind(settings);
            //#if !DEBUG
            string appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(2);

            if (ec?.Version != appVersion)
            {
                _logger.LogError("The config version {Version} does not match the current app version {appVersion}. There may be compatability issues and we recommend that you generate a new default config and then tranfer the settings accross.", ec.Version, appVersion);
                throw new Exception("Version in Config does not match X.X in Application. Please check and revert.");
            }
            //#endif
            return(ec);
        }
Ejemplo n.º 2
0
        public EngineConfiguration CreateEmptyConfig()
        {
            EngineConfiguration ec = new EngineConfiguration
            {
                Version   = Assembly.GetExecutingAssembly().GetName().Version.ToString(2),
                FieldMaps = new List <IFieldMapConfig>(),
                WorkItemTypeDefinition = new Dictionary <string, string> {
                    { "sourceWorkItemTypeName", "targetWorkItemTypeName" }
                },
                Processors = new List <IProcessorConfig>(),
            };

            ec.Source = GetMigrationConfigDefault();
            ec.Target = GetMigrationConfigDefault();
            return(ec);
        }
Ejemplo n.º 3
0
 private void AddExampleFieldMapps(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
     });
 }