private static void InsertLogicalModels(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictPhysMod, Dictionary <string, int> dictLicenses, Paths Paths, string log) { db.BulkInsert(LogicalModel.Import(dictPhysMod, dictLicenses, buffer, Paths, log)); buffer.p_logicalModels = db.LogicalModel.ToList(); buffer.ModelLicenses = buffer.p_logicalModels.Join(buffer.p_licenses, m => m.LicenseId, l => l.Id, (m, l) => new ModelLicense(m, l)).ToList(); }
public Feature GetFeature(DBBuffer buffer, out FeatureRegister.FeatureType type) { type = FeatureRegister.FeatureType.Nothing; if (OptionId != null) { type = FeatureRegister.FeatureType.Option; return(buffer.p_features.Single(f => f.Id == (buffer.p_option.Single(o => o.Id == OptionId).FeatureId))); } if (ApplicationId != null) { type = FeatureRegister.FeatureType.Application; return(buffer.p_features.Single(f => f.Id == (buffer.p_applications.Single(o => o.Id == ApplicationId).FeatureId))); } if (ProbeId != null) { type = FeatureRegister.FeatureType.Probe; return(buffer.p_features.Single(f => f.Id == (buffer.p_probes.Single(o => o.Id == ProbeId).FeatureId))); } if (KitId != null) { type = FeatureRegister.FeatureType.Kit; return(buffer.p_features.Single(f => f.Id == (buffer.p_biospyKits.Single(o => o.Id == KitId).FeatureId))); } return(null); }
public Dictionaries(FeaturesContext _db) { p_buffer = new DBBuffer(); p_buffer.p_probes = _db.Probe.ToList(); p_buffer.p_applications = _db.Application.ToList(); p_buffer.p_bundles = _db.Bundle.ToList(); p_buffer.p_option = _db.Option.ToList(); p_buffer.p_logicalModels = _db.LogicalModel.ToList(); p_buffer.p_biospyKits = _db.BiopsyKits.ToList(); p_buffer.p_countries = _db.Country.ToList(); }
private static void ImportRules(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictLicenses, Paths Paths, string LogXml2DB) { db.readLogModLicRules(buffer, dictLicenses, Paths, LogXml2DB); // Rules from license manager db.ImportProbesWithRules(buffer, Paths, LogXml2DB); // import Probes and probe rules db.BulkInsert(Uirule.ImportOptionProbes(buffer, Paths, LogXml2DB)); // probe option associations db.BulkInsert(Uirule.ImportVersionRules(buffer, Paths, LogXml2DB)); // versions Rules ImportRegulatoryFeatures(db, buffer, Paths, LogXml2DB); db.BulkInsert(Uirule.ImportRegulatoryRules(buffer, Paths, LogXml2DB)); // Regulatory blocks for country db.BulkInsert(Uirule.ImportRDBlockingRules(buffer, Paths, LogXml2DB)); // R&D blocks for country }
private static Dictionary <string, int> InsertFeatures(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictLicenses, Paths Paths, string log) { db.BulkInsert(Feature.Import(dictLicenses, Paths, log)); buffer.p_features = db.Feature.ToList(); var dictFeat = buffer.p_features.Select(pm => new { pm.Name, pm.Id }).ToDictionary(m => m.Name, m => m.Id); return(dictFeat); }
private static Dictionary <string, int> InsertOptions(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictFeat, Paths Paths, string log) { db.BulkInsert(Option.Import(dictFeat, Paths, log)); buffer.p_option = db.Option.ToList(); var dictOptions = buffer.p_option.Select(pm => new { pm.Name, pm.Id }).ToDictionary(m => m.Name, m => m.Id); return(dictOptions); }
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); } }
private string GetDistributorString(int?DistributorId, DBBuffer _buffer) { var distributorString = ""; if (DistributorId != null) { var distributor = _buffer.p_Distributors.SingleOrDefault(d => d.Id == DistributorId); if (distributor != null) { distributorString = " with " + distributor.Name; } } return(distributorString); }
public static CountryVersionInput CreateCountryVersionAssociation(string CountryCode, int logicalmodelId, DBBuffer _buffer) { var Country = _buffer.p_countries.SingleOrDefault(x => x.Code == CountryCode); return(new CountryVersionInput(Country.Id, null, logicalmodelId)); }
private static Dictionary <string, int> InsertPhysicalModels(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(Models.PhysicalModel.Import(Paths, log)); buffer.p_physicalModels = db.PhysicalModel.ToList(); var dictPhysMod = buffer.p_physicalModels.Select(pm => new { pm.Description, pm.Id }).ToDictionary(m => m.Description, m => m.Id); return(dictPhysMod); }
private static void InsertDistributors(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(Distributor.Import(Paths, log)); buffer.p_Distributors = db.Distributor.ToList(); }
private static void InsertDeprecated(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictFeat, Paths Paths, string log) { db.BulkInsert(Deprecated.Import(dictFeat, Paths, log)); buffer.p_Deprecated = db.Deprecated.ToList(); }
private static void InsertFeatureRelations(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictFeat, Paths Paths, string log) { db.BulkInsert(FeatureRelation.Import(dictFeat, Paths, log, buffer)); }
private static void ImportRegulatoryFeatures(FeaturesContext db, DBBuffer buffer, Paths Paths, string LogXml2DB) { db.BulkInsert(RegulatoryFeature.Import(buffer, Paths, LogXml2DB)); buffer.p_RegualtoryFeatures = db.RegulatoryFeature.ToList(); }
private static void InsertCountryLicenses(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(CountryLicense.Import(buffer, Paths, log)); buffer.p_CountryLicenses = db.CountryLicense.ToList(); }
private static void ImportVersions(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.ReadVersion(buffer, Paths, log); }
private static void InsertPartNumbers(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(PartNumbersAssociations.Import(Paths, buffer, log)); buffer.p_PartNumbersAssociations = db.PartNumbersAssociations.ToList(); }
private static void InsertMinorVersions(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(MinorVersionAssociation.Import(Paths, log)); buffer.p_MinorVersionAssociation = db.MinorVersionAssociation.ToList(); }
private static void InsertApplications(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictFeat, Paths Paths, string log) { db.BulkInsert(Application.Import(dictFeat, Paths, log)); buffer.p_applications = db.Application.ToList(); }
private static void InsertBundles(FeaturesContext db, DBBuffer buffer, Dictionary <string, int> dictFeat, Paths Paths, string log) { db.BulkInsert(Bundle.Import(dictFeat, Paths, log)); buffer.p_bundles = db.Bundle.ToList(); }
// explode all records in country and certifier version and check consistency // for models we handle the default model version, which can be overwritten by specifying the model. Therefore records will not replicated for model public void CheckConsistency(DBBuffer _buffer, string logFileXml2DB) { var VirtualAssociations = new List <CountryVersion>(); VirtualAssociations.AddRange(CountryVersions); // replicate certifier records foreach (var CertifierVersion in CertifierVersions) { var ChildrenCounttries = _buffer.p_countries.Where(c => c.CertifierId == CertifierVersion.CertifierId).ToList(); foreach (var ChildrenCountry in ChildrenCounttries) { VirtualAssociations.Add(new CountryVersion { CountryId = ChildrenCountry.Id, MajorVersion = CertifierVersion.MajorVersion, DistributorId = CertifierVersion.DistributorId, LogicalModelId = CertifierVersion.LogicalModelId }); } } // replicate Distributor records var GroupedCountryWithDistributors = _buffer.p_Country_Distributors.GroupBy(x => x.CountryId).ToList(); foreach (var CountryDistributorGroup in GroupedCountryWithDistributors) { var Vas2Replicate4Distributor = VirtualAssociations.Where(va => va.CountryId == CountryDistributorGroup.Key && va.DistributorId == null).ToList(); foreach (var Va2Replicate4Distributor in Vas2Replicate4Distributor) { foreach (var DistributorId in CountryDistributorGroup.ToList().Select(g => g.DistributorId)) { VirtualAssociations.Add(new CountryVersion { CountryId = CountryDistributorGroup.Key, MajorVersion = Va2Replicate4Distributor.MajorVersion, DistributorId = DistributorId, LogicalModelId = Va2Replicate4Distributor.LogicalModelId, }); } } } // check if there is any double record in the Virtual Associations: Do not check Version in distinguishing records var DoubleRecords = VirtualAssociations.GroupBy(va => new { va.CountryId, va.DistributorId, va.LogicalModelId }).Where(g => g.Count() > 1).ToList(); if (DoubleRecords.Count > 0) { var message = "Versions for " + string.Join(", ", DoubleRecords.Select(dr => dr.First().CountryId).Join(_buffer.p_countries, x => x, c => c.Id, (x, c) => c.Name)) + " are specified more than once. Please check the countries specified in the certifiers."; } // database index makes sure {country, distributor, logical model} are unique // check if all country items (i.e. each country license) is correctly associated with a version for all models with part number foreach (var CountryLicense in _buffer.p_CountryLicenses) { foreach (var model in _buffer.p_logicalModels) { if (!VirtualAssociations.Any(cl => cl.CountryId == CountryLicense.CountryId && cl.DistributorId == CountryLicense.DistributorId && cl.LogicalModelId == model.Id)) { var country = _buffer.p_countries.Single(c => c.Id == CountryLicense.CountryId); if (country.IsObsolete) { Provider.WriteImportLogFormat(logFileXml2DB, "Warning: " + country.Name + " (obsolete country), not associated with any major in " + model.Name); } else { throw new Exception(country.Name + " " + GetDistributorString(CountryLicense.DistributorId, _buffer) + " Has no specified version for model " + model.Name); } } } } }
private static void InsertLicenseRelationsExceptions(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(LicenseRelationException.Import(buffer, Paths, log)); buffer.p_LicenseRelationExceptions = db.LicenseRelationException.ToList(); }
public static IVersionAssociationInput CreateVersionAssociationFromNames(string CountryCode, string CountryName, string DistributorCode, string ModelName, DBBuffer _buffer) { int?DistributorId = null; var Distributor = _buffer.p_Distributors.SingleOrDefault(x => x.Code == DistributorCode); if (Distributor != null) { DistributorId = Distributor.Id; } int?ModelId = null; var Model = _buffer.p_logicalModels.SingleOrDefault(x => x.Name == ModelName); if (Model != null) { ModelId = Model.Id; } var Country = _buffer.p_countries.SingleOrDefault(x => x.Code == CountryCode && x.Name == CountryName); if (Country == null) { var Certifier = _buffer.p_certifiers.Single(x => x.Code == CountryCode && x.Name == CountryName); return(new CertifierVersionInput(Certifier.Id, DistributorId, ModelId)); } else { return(new CountryVersionInput(Country.Id, DistributorId, ModelId)); } }
private static void InsertCertifiers(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(Certifier.Import(Paths, log)); buffer.p_certifiers = db.Certifier.ToList(); }
private static void InsertSettingsFamilies(FeaturesContext db, DBBuffer buffer, Paths Paths, string log) { db.BulkInsert(SettingFamily.Import(buffer.p_swPacks, Paths, log)); buffer.p_settingsFamilies = db.SettingFamily.ToList(); }
public Dictionaries(DBBuffer _buffer) { p_buffer = _buffer; }
private static void InsertSWPacks(FeaturesContext db, DBBuffer buffer, Paths Paths, string logFileXml2DB) { db.BulkInsert(Swpack.Import(Paths, logFileXml2DB)); buffer.p_swPacks = db.Swpack.ToList(); }