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); }
/// <summary> /// returns a normal rule equivalent to the UI RULE /// /// *THIS CODE SHOULD BE AUTOMATICALLY GENERATED BY THE TEXT TEMPLATE* /// /// </summary> public NormalRule ToSingleNormalRule() { return(new NormalRule { Allow = this.Allow, LogicalModelId = this.LogicalModelId, ApplicationId = this.ApplicationId, OptionId = this.OptionId, UserLevel = this.UserLevel, Version = ComparableFields.GetNumericVersion(this.Version), UiruleId = this.Id, ProbeId = this.ProbeId, TransducerType = this.TransducerType, KitId = this.KitId, CountryId = this.CountryId, DistributorId = this.DistributorId }); }
// 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); } } } }