Exemplo n.º 1
0
        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 {}
                }
            }
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
 }