private string DoConversion() { Logger.Info("Doing conversion"); List <string> scriptNames = new List <string>(); Dictionary <string, string> bcpExportCommands = new Dictionary <string, string>(); Dictionary <string, string> bcpImportCommands = new Dictionary <string, string>(); _destinationDatabase.Tables.ForEach(t => { DestinationTable destinationTable = t; SourceTable sourceTable = null; try { Logger.Info("Processing " + destinationTable.Name); TableMappingConfiguration mappingConfig = GetTableMappingConfig(destinationTable.Name); sourceTable = GetSourceTable(destinationTable.Name, mappingConfig); var mappingDefinition = CreateTableMappingDefinition(sourceTable, destinationTable, mappingConfig); SqlGenerator sqlGenerator = new SqlGenerator(mappingDefinition, _options.CheckExistData); BcpGenerator bcpGenerator = new BcpGenerator(_options.ServerName, _options.InstanceName, mappingDefinition, _options.BcpMode); HandleBcp(sqlGenerator, bcpGenerator, mappingDefinition, bcpExportCommands, bcpImportCommands); HandleMaxTextUpdate(sqlGenerator, mappingDefinition, scriptNames); if (_options.BlobHandling) { HandleBlobUpdate(sqlGenerator, mappingDefinition, scriptNames); } } catch (AppException ex) { if (ex.ErrorCode == AppExceptionCodes.DATABASE_ERROR_TABLE_NOT_FOUND) { Logger.Warn(destinationTable.Name + " not mapped"); } } }); // Generate bat file string exportScript = BatGenerator.GenerateBcpExecuteBat(bcpExportCommands); SaveToFile(_packageOutputPath, "BCP_Export.bat", exportScript); Logger.Info("BCP Exporting data"); Process.Start(new ProcessStartInfo { WorkingDirectory = _packageOutputPath, FileName = "BCP_Export.bat" }); string importScript = BatGenerator.GenerateBcpExecuteBat(bcpImportCommands); //SaveToFile(_packageOutputPath, "BCP_Import.bat", importScript); List <string> scriptPaths = scriptNames.Select(s => Path.Combine(CONVERSION_PACKAGE_FOLDER, s)).ToList(); string updateScript = BatGenerator.GenerateSqlExecuteBat(scriptPaths, _options.ServerName, _options.InstanceName, _options.Username, _options.Password); //SaveToFile(_packageOutputPath, "Update_Blob_Text.bat", updateScript); string batScript = importScript + Environment.NewLine + updateScript; return(batScript); }
private void Start() { gameControl = Instantiate(gameControlPrefab).GetComponent <GameControl> (); generator = Instantiate(generatorPrefab).GetComponent <BatGenerator> (); player = Instantiate(playerPrefab).GetComponent <Player> (); gameControl.EnemyGenerator = generator; gameControl.PlayerInstance = player; gameControl.MainCamera = mainCamera; gameControl.redScreenEffect = mainCamera.gameObject.AddComponent <RedScreenEffect>(); }
private string DoPostConversion() { Logger.Info("Doing post-conversion job"); foreach (string filePath in _listPostConversionScript) { string destPath = Path.Combine(_packageOutputPath, POST_CONVERSION_PACKAGE_FOLDER, Path.GetFileName(filePath)); File.Copy(filePath, destPath); } List <string> scriptPaths = _listPostConversionScript.Select(s => Path.Combine(POST_CONVERSION_PACKAGE_FOLDER, Path.GetFileName(s))).ToList(); string updateScript = BatGenerator.GenerateSqlExecuteBat(scriptPaths, _options.ServerName, _options.InstanceName, _options.Username, _options.Password); //SaveToFile(_packageOutputPath, "Run_Post_Conversion.bat", updateScript); return(updateScript); }
public void GenerateMigrationScripts() { int count = 0; string outputPath = ConfigurationManager.AppSettings["SQLOutputFolder"]; outputPath = Path.Combine(outputPath, DateTime.Now.ToString("ddMMyyyy")); List <string> scriptNames = new List <string>(); var temp = new List <string>(); while (count < _destinationDatabase.Tables.Count) { DestinationTable destinationTable = null; SourceTable sourceTable = null; try { // Get next table to migrate destinationTable = GetNextTableCanMap(); if (destinationTable == null) { break; } Console.WriteLine("Processing " + destinationTable.Name); // Check explicit mapping for source table - destination table TableMappingDefinition mappingDefinition; TableMappingConfiguration mappingConfig = GetTableMappingConfig(destinationTable.Name); sourceTable = GetSourceTable(destinationTable.Name, mappingConfig); if (mappingConfig != null) { mappingDefinition = new TableMappingDefinition(sourceTable, destinationTable, mappingConfig.FieldMappings); mappingDefinition.IsIdentityInsert = mappingConfig.IsIdentityInsert; } else { mappingDefinition = new TableMappingDefinition(sourceTable, destinationTable); } // Retain mapping definition for later use _tableMappingDefinitions.Add(mappingDefinition); // Check circle references needed to update CheckCircleReferences(destinationTable, mappingDefinition); // Generate script var scriptGenerator = new TableScriptGenerator(_sourceDatabase, mappingDefinition); var script = scriptGenerator.GenerateScript(); var fileName = string.Format("{0}.{1}-{2}.sql", count++, sourceTable.Name, destinationTable.Name); Utils.SaveToFile(outputPath, fileName, script); scriptNames.Add(fileName); temp.Add(destinationTable.Name); destinationTable.IsMapped = true; } catch (MigrationException ex) { if (ex.ErrorCode == MigrationExceptionCodes.DATABASE_ERROR_TABLE_NOT_FOUND) { destinationTable.IsMapped = true; // TODO: write log Console.WriteLine(destinationTable.Name + " not mapped"); } } } // Generate script clear temp database var clearScript = string.Format(SqlScriptTemplates.TRUNCATE_TABLE, "[TempDatabase].dbo.[TrackingRecords]"); var clearFileName = string.Format("{0}.Clear.sql", count); Utils.SaveToFile(outputPath, clearFileName, clearScript); scriptNames.Add(clearFileName); // Generate bat file string batScript = BatGenerator.GenerateSqlExecuteScript(scriptNames, _options.ServerName, _options.InstanceName, outputPath); Utils.SaveToFile(outputPath, "RunMigration.bat", batScript); }