public static void Import(DatabaseImportParameters parameters, Action <string> updateStatus) { UpdateStatus = updateStatus; // Configure database FluentConfiguration.Configure(parameters.ConnectionString, parameters.DropAndCreate); var normalRoutes = new List <NormalRoute>(); // Import normal routes if (!string.IsNullOrWhiteSpace(parameters.NormalRoutePath)) { normalRoutes = ImportNormalRoutes(parameters.NormalRoutePath); } // Import gravity vectors if (!string.IsNullOrWhiteSpace(parameters.GravityVectorPath)) { ImportGravityVectors(syncRoot, parameters.GravityVectorPath, normalRoutes); } // Import deviation map if (!string.IsNullOrWhiteSpace(parameters.DeviationMapPath)) { ImportDeviationCells(parameters.DeviationMapPath); } // Import near-miss map if (!string.IsNullOrWhiteSpace(parameters.NearMissMapPath)) { ImportNearMissMap(parameters.NearMissMapPath); } }
public static List <ValidationError> Validate(DatabaseImportParameters parameters) { var result = new List <ValidationError>(); if (!string.IsNullOrWhiteSpace(parameters.NormalRoutePath)) { if (!File.Exists(parameters.NormalRoutePath)) { result.Add(GenerateError($"The file {parameters.NormalRoutePath} does not exist")); } } if (!string.IsNullOrWhiteSpace(parameters.GravityVectorPath)) { if (string.IsNullOrWhiteSpace(parameters.NormalRoutePath)) { result.Add(GenerateError("If you specify a gravity vector path, you must also specify a normal route path")); } if (!File.Exists(parameters.GravityVectorPath)) { result.Add(GenerateError($"The file {parameters.GravityVectorPath} does not exist")); } } if (!string.IsNullOrWhiteSpace(parameters.DeviationMapPath)) { if (!File.Exists(parameters.DeviationMapPath)) { result.Add(GenerateError($"The file {parameters.DeviationMapPath} does not exist")); } } if (!string.IsNullOrWhiteSpace(parameters.NearMissMapPath)) { if (!File.Exists(parameters.NearMissMapPath)) { result.Add(GenerateError($"The file {parameters.NearMissMapPath} does not exist")); } } if (string.IsNullOrWhiteSpace(parameters.ConnectionString)) { result.Add(GenerateError("You must specify a connection string")); } else { try { FluentConfiguration.TestConfiguration(parameters.ConnectionString); } catch (ArgumentException e) { result.Add(GenerateError("Invalid connection string: " + e.Message)); } catch (Exception e) { result.Add(GenerateError(e.Message)); } } return(result); }