public static FeatureRegister CreateDBFiles(string DBorigin, string OutXmlPath, string LogXml2DB) { Provider.WriteLogFormat(LogXml2DB, "Write DB xml Files"); var db = FeaturesContext.Open(DBorigin); var AllRules = db.NormalRule.ToList(); Provider.WriteLogFormat(LogXml2DB, "Create Country Items and Register"); var register = FeatureRegister.CreateDBFiles(db, OutXmlPath); Provider.WriteFile <Dbconfiguration>(db.Dbconfiguration.First(), OutXmlPath + "\\" + FeatureManagerCompatibility.ConfigurationFileName); Provider.WriteFile <CountryItems>(register.CountryItems, OutXmlPath + "\\CountryItems.xml"); // File used in WPF only CreatePartNumbersFile(db, OutXmlPath); CreateProbePresetFile(db, OutXmlPath); Provider.WriteLogFormat(LogXml2DB, "Create Feature Main for all logical models"); var ModelNames = register.ModelLicenses.Select(m => m.License.Name).ToList(); foreach (var ModelName in ModelNames) { WriteMain(register, AllRules, ModelName, OutXmlPath); } return(register); }
public static void CreateDatabase(Paths Paths, string logFileXml2DB, int BuildNumber, DatabaseType databaseType, string connectionString) { try { FeaturesContext.Create(Paths.DBfile, databaseType, connectionString); var db = FeaturesContext.Open(Paths.DBfile); // ANTO DB LOG //db.EnableLog(); var buffer = new DBBuffer(); /* data insertion in the DB */ Provider.WriteLogFormat(logFileXml2DB, "Filling up Tables"); InsertSWPacks(db, buffer, Paths, logFileXml2DB); InsertSettingsFamilies(db, buffer, Paths, logFileXml2DB); var dictLicenses = InsertLicenses(db, buffer, Paths, logFileXml2DB); var dictPhysMod = InsertPhysicalModels(db, buffer, Paths, logFileXml2DB); InsertLogicalModels(db, buffer, dictPhysMod, dictLicenses, Paths, logFileXml2DB); InsertTwinLicenses(db, dictLicenses, Paths, logFileXml2DB); var dictFeat = InsertFeatures(db, buffer, dictLicenses, Paths, logFileXml2DB); var dictOptions = InsertOptions(db, buffer, dictFeat, Paths, logFileXml2DB); InsertApplications(db, buffer, dictFeat, Paths, logFileXml2DB); InsertBundles(db, buffer, dictFeat, Paths, logFileXml2DB); InsertFeatureRelations(db, buffer, dictFeat, Paths, logFileXml2DB); InsertLicenseRelations(db, buffer, Paths, logFileXml2DB); InsertLicenseRelationsExceptions(db, buffer, Paths, logFileXml2DB); InsertDeprecated(db, buffer, dictFeat, Paths, logFileXml2DB); InsertCertifiers(db, buffer, Paths, logFileXml2DB); InsertCountries(db, buffer, Paths, logFileXml2DB); InsertDistributors(db, buffer, Paths, logFileXml2DB); InsertCountryDistributors(db, buffer, Paths, logFileXml2DB); InsertCountryLicenses(db, buffer, Paths, logFileXml2DB); InsertMinorVersions(db, buffer, Paths, logFileXml2DB); ImportRules(db, buffer, dictLicenses, Paths, logFileXml2DB); InsertPartNumbers(db, buffer, Paths, logFileXml2DB); ImportVersions(db, buffer, Paths, logFileXml2DB); buffer.p_UIRules = db.Uirule.ToList(); Provider.WriteLogFormat(logFileXml2DB, "Convert UIRules to NormalRules"); db.BulkInsert(FeaturesContext.createNormalRules(buffer)); SetDBConfigurations(db, BuildNumber); Provider.WriteLogFormat(logFileXml2DB, "Database Created"); } catch (Exception ex) { var errormessage = Provider.WriteErrorLogFormat("Error while creating the Database: " + ex.Message); throw new ApplicationException(errormessage, ex); } }