public static void ImportRecordsFromQuery(string commandText, string sourceConnectionString, string destConnectionString, string tempPath, BeforeImportDelegate beforeImport = null, AfterImportDelegate afterImport = null) { var tempFileName = Path.ChangeExtension(Path.GetRandomFileName(), "xml"); var fileName = $"{commandText.GetStrongHash()}.xml"; try { var workXmlPath = Path.Combine(tempPath, tempFileName); var xmlPath = Path.Combine(tempPath, fileName); if (!File.Exists(xmlPath)) { ExportResultsToFile(commandText, sourceConnectionString, xmlPath, true); } if (File.Exists(workXmlPath)) { File.Delete(workXmlPath); } File.Copy(xmlPath, workXmlPath); beforeImport?.Invoke(workXmlPath, destConnectionString); ImportFiles(tempPath, Path.GetFileNameWithoutExtension(tempFileName), destConnectionString); afterImport?.Invoke(destConnectionString); } finally { if (File.Exists(tempFileName)) { try{ File.Delete(tempFileName); }catch {} } } }
public static void ImportQueryResultsFromUa(string sql, string connectionString, string tempPath, BeforeImportDelegate beforeImport = null, AfterImportDelegate afterImport = null) { ImportRecordsFromQuery( sql, connectionString.Replace("daes_", "saes_"), connectionString, tempPath, beforeImport, afterImport); }
public static void ImportQueryResultsFromProduction(string sql, string connectionString, string tempPath, BeforeImportDelegate beforeImport = null, AfterImportDelegate afterImport = null) { ImportRecordsFromQuery( sql, connectionString .Replace("daes_", "paes_") .Replace("SGISUSEUAV01.aesua.local", "SGISUSEPRV01.aesprod.local"), connectionString, tempPath, beforeImport, afterImport); }