Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void GivenAnUnsupportedAttributeMetadata_WhenConverted_ThenItShouldThrowP
{
//Arrange
var field = new Field() { Name = "test", Value = "125462" };
var amd = new MemoAttributeMetadata();
var amd = new ImageAttributeMetadata();
//Act
Action act = () => converter.Convert(amd, field);
//Assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,19 @@ where Attribute.IsDefined(type, typeof(CommandVerbAttribute)) &&
throw new InvalidOperationException($"No command found for verb '{_options.CommandVerb}'");
}
var command = ActivatorUtilities.CreateInstance(scope.ServiceProvider, mathingVerbCommandType) as ICommand;
await command.Execute();
if (command == null)
{
throw new InvalidOperationException($"Command type '{mathingVerbCommandType.FullName}' could not be instantiated.");
}
try
{
await command.Execute();
}
catch
{
Environment.ExitCode = -100;
throw;
}


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public ImportCommands(ILogger<ImportCommands> logger,
_options = options.Value;
}

public async Task Execute() => await Import(_options.schema, _options.data);
public Task Execute() => Import(_options.schema, _options.data);


private async Task Import(string schemafilepath, string datafilepath)
{

var ImportQueue = new Queue<ImportDataTask>();
var schema = await _importDataProvider.ReadSchemaFromFile(schemafilepath);
var importdata = await _importDataProvider.ReadFromFile(datafilepath);

Expand All @@ -48,19 +46,19 @@ private async Task Import(string schemafilepath, string datafilepath)
throw new Exception("Provided Schema was not valid.");
}
_logger.LogInformation("Schema validation succeeded.");
var ImportQueue = CreateQueue(schema);

foreach (var schemaEntity in schema.Entity)

var taskResults = await ProcessQueue(ImportQueue, importdata);
if (taskResults.Any(r => r == TaskResult.Failed))
{
ImportQueue.Enqueue(new ImportDataTask { EntitySchema = schemaEntity });
if (schemaEntity.Relationships.Relationship.Any())
{
foreach (var relationshipSchema in schemaEntity.Relationships.Relationship)
{
ImportQueue.Enqueue(new ImportDataTask { RelationshipSchema = relationshipSchema, SouceEntityName = schemaEntity.Name });
}
}
_logger.LogError("Import process failed.");
throw new Exception("Import process failed.");
}

}
private async Task<IEnumerable<TaskResult>> ProcessQueue(Queue<ImportDataTask> ImportQueue, Entities importdata)
{
var taskResults = new List<TaskResult>();
while (ImportQueue.Count > 0)
{
Expand All @@ -78,7 +76,7 @@ private async Task Import(string schemafilepath, string datafilepath)
}
if (importTask.RelationshipSchema != null &&
ImportQueue.Any(t => t.EntitySchema != null &&
t.EntitySchema.Name == importTask.RelationshipSchema.M2mTargetEntity || t.EntitySchema.Name == importTask.SouceEntityName))
(t.EntitySchema.Name == importTask.RelationshipSchema.M2mTargetEntity || t.EntitySchema.Name == importTask.SouceEntityName)))
{
ImportQueue.Enqueue(importTask);
continue;
Expand All @@ -90,14 +88,23 @@ private async Task Import(string schemafilepath, string datafilepath)


}
if (taskResults.Any(r => r == TaskResult.Failed))
return taskResults;
}
private static Queue<ImportDataTask> CreateQueue(ImportSchema schema)
{
var ImportQueue = new Queue<ImportDataTask>();
foreach (var schemaEntity in schema.Entity)
{
_logger.LogError("Import process failed.");
throw new Exception("Import process failed.");
ImportQueue.Enqueue(new ImportDataTask { EntitySchema = schemaEntity });
if (schemaEntity.Relationships.Relationship.Any())
{
foreach (var relationshipSchema in schemaEntity.Relationships.Relationship)
{
ImportQueue.Enqueue(new ImportDataTask { RelationshipSchema = relationshipSchema, SouceEntityName = schemaEntity.Name });
}
}
}



return ImportQueue;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public object Convert(AttributeMetadata attributeMetadata, Field field)
switch (attributeMetadata.AttributeType.Value)
{
case AttributeTypeCode.String:
case AttributeTypeCode.Memo:
return _mainConverter.Convert<string>(value);
case AttributeTypeCode.Picklist:
case AttributeTypeCode.State:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information"
"Default": "Information",
"Dataverse.ConfigurationMigrationTool.Console.Services.Dataverse.SdkDataverseServiceFactory": "Warning"
}
},
"Dataverse": {
Expand Down
Loading