Skip to content

Commit

Permalink
Corrected issue in table reading in Import tool
Browse files Browse the repository at this point in the history
  • Loading branch information
crisfervil committed Sep 28, 2018
1 parent d7dede4 commit a9f15a0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/XrmCommandBox/Tools/ImportTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,28 @@ public void Run(ImportToolOptions options)

_log.Info("Running Import Tool...");

_log.Info($"Reading {options.File} file...");
var optionsMsgStr = string.IsNullOrEmpty(options.FileOptions) ? "" : $"({options.FileOptions}) ";
_log.Info($"Reading {options.File} {optionsMsgStr}file...");

var dataTable = serializer.Deserialize(options.File, options.FileOptions);
_log.Info($"{dataTable.Count} '{dataTable.Name}' records read");

if (dataTable == null) throw new Exception("Unexpected error reading data table");

dataTable.Name = !string.IsNullOrEmpty(options.EntityName) ? options.EntityName : dataTable.Name;
if (string.IsNullOrEmpty(dataTable.Name)) throw new Exception("Entity name not prvided. Set the Entity Name parameter option or set the table name in the input file");

_log.Info($"{dataTable.Count} '{dataTable.Name}' records read");

_log.Debug($"Querying metadata of entity {dataTable.Name}...");
var metadata = _crmService.GetMetadata(dataTable.Name);

// Process Lookups
if(options.Lookups != null)
if (options.Lookups != null)
{
_log.Debug("Resolving Lookups...");
ProcessLookups(dataTable, options);
}

dataTable.Name = !string.IsNullOrEmpty(options.EntityName) ? options.EntityName : dataTable.Name;
if (string.IsNullOrEmpty(dataTable.Name)) throw new Exception("Entity name not prvided. Set the Entity Name parameter option or set the table name in the input file");

_log.Debug($"Querying metadata of entity {dataTable.Name}...");
var metadata = _crmService.GetMetadata(dataTable.Name);

_log.Info("Processing records...");
var records = dataTable.AsEntityCollection(metadata);

Expand Down

0 comments on commit a9f15a0

Please sign in to comment.