//private static List<UIRule> GetRegulatoryRules(List<UIRule> BaseRules, string RegulatoryFeatureName, DBBuffer _buffer) //{ // var result = new List<UIRule>(); // var ChildFeatureIDs = _buffer.p_RegualtoryFeatures.Where(rf => rf.Name == RegulatoryFeatureName).Select(x => x.FeatureId).ToList(); // foreach (var BaseRule in BaseRules) // { // foreach (var ChildFeatureID in ChildFeatureIDs) // { // var tmpRule = new UIRule(BaseRule); // _buffer.SetRuleFeatureField(tmpRule, ChildFeatureID); // result.Add(tmpRule); // } // } // return result; //} private static void FillRuleFromFile(Uirule tmpRule, int StartingIndex, List <string> riga, DBBuffer _buffer) { if (!string.IsNullOrEmpty(riga[StartingIndex])) { tmpRule.OptionId = _buffer.p_option.Single(p => p.Name == riga[StartingIndex]).Id; } if (!string.IsNullOrEmpty(riga[StartingIndex + 1])) { tmpRule.ApplicationId = _buffer.p_applications.Single(p => p.Name == riga[StartingIndex + 1]).Id; } if (!string.IsNullOrEmpty(riga[StartingIndex + 2])) { tmpRule.ProbeId = _buffer.p_probes.Single(p => p.SaleName == riga[StartingIndex + 2]).Id; } if (!string.IsNullOrEmpty(riga[StartingIndex + 3])) { tmpRule.KitId = _buffer.p_biospyKits.Single(p => p.Name == riga[StartingIndex + 3]).Id; } if (!string.IsNullOrEmpty(riga[StartingIndex + 4])) { tmpRule.LogicalModelId = _buffer.p_logicalModels.Single(p => p.Name == riga[StartingIndex + 4]).Id; } if (!string.IsNullOrEmpty(riga[StartingIndex + 5])) { tmpRule.PhysicalModelId = _buffer.p_physicalModels.Single(p => p.Description == riga[StartingIndex + 5]).Id; } }
public static List <Uirule> ImportVersionRules(DBBuffer _buffer, Paths Paths, string log) { List <Uirule> result = new List <Uirule>(); var filename = "REQUIREMENTS.txt"; Provider.WriteImportLogFormat(log, filename); try { var file = Provider.CreateFile(Paths.importFilePath + "\\" + filename); // first line contains column names foreach (List <string> riga in file.Skip(1)) { var tmpRule = new Uirule(); tmpRule.Allow = AllowModes.No; tmpRule.RuleOrigin = ruleOrigins.Requirements; if (!string.IsNullOrEmpty(riga[0])) { tmpRule.Version = ComparableFields.GetStringVersion(ComparableFields.GetNumericVersionFromMajor(Convert.ToDouble(riga[0]))); } FillRuleFromFile(tmpRule, 1, riga, _buffer); IsOkToAddRule(tmpRule, _buffer); result.Add(tmpRule); } } catch (Exception ex) { throw new ParsingException(filename, ex); } return(result); }
// check if the rules are equivalent excluding the country public Boolean IsEquivalentNoCountry(Uirule f2) { if (this.Allow != f2.Allow) { return(false); } if (this.ApplicationId != f2.ApplicationId) { return(false); } if (this.LogicalModelId != f2.LogicalModelId) { return(false); } if (this.OptionId != f2.OptionId) { return(false); } if (this.UserLevel != f2.UserLevel) { return(false); } if (this.Version != f2.Version) { return(false); } if (this.ProbeId != f2.ProbeId) { return(false); } if (this.TransducerType != f2.TransducerType) { return(false); } if (this.KitId != f2.KitId) { return(false); } if (this.PhysicalModelId != f2.PhysicalModelId) { return(false); } return(true); }
// copy constructor public Uirule(Uirule copy) { Allow = copy.Allow; RuleName = copy.RuleName; PhysicalModelId = copy.PhysicalModelId; CertifierId = copy.CertifierId; LogicalModelId = copy.LogicalModelId; ApplicationId = copy.ApplicationId; OptionId = copy.OptionId; UserLevel = copy.UserLevel; Version = copy.Version; CountryId = copy.CountryId; DistributorId = copy.DistributorId; ProbeId = copy.ProbeId; TransducerType = copy.TransducerType; KitId = copy.KitId; RuleOrigin = copy.RuleOrigin; }
// Gibiino [RTC 12169] private static void IsOkToAddRule(Uirule uirule, DBBuffer buffer) { // Make sure the AlwaysPresent features are not blocked by the version FeatureRegister.FeatureType FeatureType; var feature = uirule.GetFeature(buffer, out FeatureType); if (feature.AlwaysPresent == true) { var tmpNormalRules = uirule.ToNormalRule(buffer); var dummyRule = new NormalRule(); dummyRule.SetFieldFromType(FeatureType, uirule); dummyRule.Version = 0; // Checks if the only specified fields are feature and version foreach (var trule in tmpNormalRules) { if (ComparableFields.isContained(dummyRule, trule)) { throw new Exception(buffer.p_features.Single(o => o.Id == feature.Id).Name + " feature cannot be blocked unti version " + uirule.Version); } } } }
// this file is tipically used to block some features in countries where a patent is protecting them public static List <Uirule> ImportRDBlockingRules(DBBuffer _buffer, Paths Paths, string log) { var result = new List <Uirule>(); var fileName = "BLOCKED_FEATURES-COUNTRIES_RD.txt"; Provider.WriteImportLogFormat(log, fileName); List <string> CurrentRow = null; try { var file = Provider.CreateFile(Paths.importFilePath + "\\" + fileName); // first line contains column names foreach (List <string> riga in file.Skip(1)) { CurrentRow = riga; var tmpRule = new Uirule(); tmpRule.Allow = AllowModes.No; tmpRule.RuleOrigin = ruleOrigins.RDCountryBlock; FillRuleFromFile(tmpRule, 0, riga, _buffer); var l_Country = riga[6]; var l_Distributor = riga[7]; var l_Certifier = riga[8]; var IsCountryPresent = !string.IsNullOrEmpty(riga[6]); var IsCertifierPresent = !string.IsNullOrEmpty(riga[8]); var IsUserPresent = !string.IsNullOrEmpty(riga[9]); if (IsCountryPresent && IsCertifierPresent) { throw new Exception("Cannot specify both cerifier and country: " + l_Country + ", " + l_Certifier); } if (IsCountryPresent) { tmpRule.CountryId = _buffer.p_countries.Single(c => c.Code == l_Country).Id; } if (!string.IsNullOrEmpty(l_Distributor)) { tmpRule.DistributorId = _buffer.p_Distributors.Single(c => c.Code == l_Distributor).Id; } if (IsCertifierPresent) { tmpRule.CertifierId = _buffer.p_certifiers.Single(c => c.Code == l_Certifier).Id; } if (IsUserPresent) { tmpRule.UserLevel = Provider.FromStringToEnum <UserLevel>(riga[9], Xml2DbMapper.Core.Porting.Contract.Enums.UserLevel.Unknown); } result.Add(tmpRule); } } catch (Exception ex) { throw new ParsingException(fileName, ex, CurrentRow); } return(result); }
public static List <Uirule> ImportRegulatoryRules(DBBuffer _buffer, Paths Paths, string log) { var result = new List <Uirule>(); var fileName = "RegulatoryExceptionsMatrix.txt"; Provider.WriteImportLogFormat(log, fileName); try { var file = Provider.CreateFile(Paths.importFilePath + "\\" + fileName); // first line contains column names foreach (List <string> riga in file.Skip(2)) { var tmpRule = new Uirule(); tmpRule.Allow = AllowModes.No; tmpRule.RuleOrigin = ruleOrigins.Regulatory; // parse rule only for recognized model (avoid MRI models) var stringmodel = riga[1].Trim(); var model = _buffer.p_logicalModels.SingleOrDefault(l => l.Name == stringmodel); if (model != null) { tmpRule.LogicalModelId = model.Id; } else { continue; } var countrycode = riga[0].Trim(); var country = _buffer.p_countries.SingleOrDefault(x => x.Code == countrycode); if (country != null) { tmpRule.CountryId = country.Id; } var stringfeature = riga[3].Trim(); var feature = _buffer.p_features.SingleOrDefault(f => f.Name == stringfeature); if (feature != null) { var application = _buffer.p_applications.SingleOrDefault(x => x.FeatureId == feature.Id); var option = _buffer.p_option.SingleOrDefault(x => x.FeatureId == feature.Id); var kit = _buffer.p_biospyKits.SingleOrDefault(x => x.FeatureId == feature.Id); if (application != null) { tmpRule.ApplicationId = application.Id; } if (option != null) { tmpRule.OptionId = option.Id; } if (kit != null) { tmpRule.KitId = kit.Id; } } var probename = riga[4].Trim(); var probe = _buffer.p_probes.SingleOrDefault(p => p.SaleName == probename); if (probe != null) { tmpRule.ProbeId = probe.Id; } result.Add(tmpRule); } } catch (Exception ex) { throw new ParsingException(fileName, ex); } return(result); }