示例#1
0
        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);
        }
示例#2
0
        private static void WriteMain(FeatureRegister register, List <NormalRule> AllRules, string ModelName, string OutXmlPath)
        {
            FeatureMain main = new FeatureMain(register);

            main.FillFromDB(AllRules, ModelName);
            WriteFile(main, OutXmlPath, ModelName);
        }
示例#3
0
        public static FeatureMain LoadFromFile(string path, string modelName, FeatureRegister _register)
        {
            var main = LoadWitoutRegister(path, modelName);

            main.DBRegister = _register;                  // assign the preloade register of the DB tables
            return(main);
        }
示例#4
0
			public FeatureRegisterSubset(FeatureRegister register)
			{
				Features = register.Features;
				LicenseRelations = register.LicenseRelations;
				FeatureLicenses = register.FeatureLicenses;
				Applications = register.Applications;
				Options = register.Options;
			}
示例#5
0
		// ANTO DB
		public static FeatureRegister CreateDBFiles(FeaturesContext db, string OutXmlPath)
		{
			var FullFileName = BuildXmlFileName(OutXmlPath);
			var FullKeyFileName = BuildXmlKeyFileName(OutXmlPath);

			FeatureRegister register = new FeatureRegister();
			register.FillFromDB(db);
			Provider.WriteFile<FeatureRegister>(register, FullFileName, FullKeyFileName);
			return register;
		}
示例#6
0
        public static FeatureMain LoadAllRules(string path, FeatureRegister _register)
        {
            var main = new FeatureMain(_register);

            var ModelNames = _register.ModelLicenses.Select(m => m.License.Name).ToList();

            foreach (var ModelName in ModelNames)
            {
                main.AddModelRules(path, ModelName);
            }
            main.RemoveDoubles();
            return(main);
        }
示例#7
0
 private static Boolean CheckFiles(string extractPath)
 {
     try
     {
         var FRegister = FeatureRegister.LoadFromFile(extractPath);
         var FMain     = FeatureMain.LoadAllRules(extractPath, FRegister);
     }
     catch (Exception ex)
     {
         var message = "Input Database cannote be porperly loaded: " + ex.Message;
         Catcher(message, extractPath);
         return(false);
     }
     return(true);
 }
示例#8
0
        public static FeatureMain LoadswPackRules(string path, string swpack, FeatureRegister _register)
        {
            var main = new FeatureMain(_register);
            var selectedSettingsFamiliesIds = _register.SettingsFamilies.Where(sf => sf.SwpackId == Int32.Parse(swpack)).Select(x => x.Id).ToList();

            _register.ModelLicenses = _register.ModelLicenses.Where(m => m.Model.SettingsFamilyId != null &&
                                                                    selectedSettingsFamiliesIds.Contains((int)m.Model.SettingsFamilyId)).ToList();

            var ModelNames = _register.ModelLicenses.Select(m => m.License.Name).ToList();

            foreach (var ModelName in ModelNames)
            {
                main.AddModelRules(path, ModelName);
            }
            main.RemoveDoubles();
            return(main);
        }
示例#9
0
        public static int?GetVersion(IVersionAssociationInput VersionAssociation, FeatureRegister DBRegister)
        {
            bool isnull;
            // filter country/certifier
            var ValidCountryVersions = VersionAssociation.GetVersionList(DBRegister).Where(x => x.GeographyId == VersionAssociation.GeographyId).ToList();

            // filter logical model
            var CountryModelVersionList = MatchValuesOrNull(ValidCountryVersions, VersionAssociation, (y) => y.LogicalModelId, out isnull);

            // filter distributor
            var CountryDistrModelVersionList = MatchValuesOrNull(CountryModelVersionList, VersionAssociation, (y) => y.DistributorId, out isnull);

            var ValidCV = CountryDistrModelVersionList.FirstOrDefault();

            if (ValidCV != null)
            {
                return(ComparableFields.GetNumericVersionFromMajor(ValidCV.MajorVersion));
            }
            return(null);
        }
示例#10
0
        public static FeatureMain LoadPhysicalModelRules(string path, string pmtoload, FeatureRegister _register)
        {
            var main = new FeatureMain(_register);

            _register.ModelLicenses = _register.ModelLicenses.Where(m => m.Model.PhModId == Int32.Parse(pmtoload)).ToList();

            var ModelNames = _register.ModelLicenses.Select(m => m.License.Name).ToList();

            foreach (var ModelName in ModelNames)
            {
                main.AddModelRules(path, ModelName);
            }
            main.RemoveDoubles();
            return(main);
        }
示例#11
0
        public static FeatureMain FullLoadFromFile(string path, string modelName)
        {
            var register = FeatureRegister.LoadFromFile(path);

            return(LoadFromFile(path, modelName, register));
        }
示例#12
0
        public static void FillVersion(InputParams input, int countryId, int?DistributorId, int ModelId, FeatureRegister DBRegister)
        {
            var versionAssociation = VersionAssociationCreator.CreateVersionAssociation(countryId, DistributorId, ModelId, DBRegister);

            input.Version = GetVersion(versionAssociation, DBRegister);
        }
        public static IVersionAssociationInput CreateVersionAssociation(int countryId, int?DistributorId, int?ModelId, FeatureRegister DBRegister)
        {
            var CertifierId = DBRegister.Countries.Single(x => x.Id == countryId).CertifierId;

            if (CertifierId != null)
            {
                return(new CertifierVersionInput((int)CertifierId, DistributorId, ModelId));
            }
            else
            {
                return(new CountryVersionInput(countryId, DistributorId, ModelId));
            }
        }
示例#14
0
		private static void InitRegister(FeatureRegister register)
		{
			register.DeprecateNames = register.Deprecates.Join(register.Features, d => d.DeprecatedFeatureId, f => f.Id, (d, f) => f.NameInCode).ToList();
		}
 public override List <IVersionAssociation> GetVersionList(FeatureRegister _register)
 {
     return(_register.CountryVersions.Select(x => x as IVersionAssociation).ToList());
 }
示例#16
0
		public static void SortLicenses(FeatureRegister FullRegister, out List<License> LicenseList, out List<License> AppLicenses, out List<License> VetAppLicenses,
										out List<License> OptionLicenses, Dictionary<String, FeatureInfo> FeatureAvailabilities = null)
		{
			var register = new FeatureRegisterSubset(FullRegister);

			// consider only license relations where features are of the same type
			register.LicenseRelations = register.LicenseRelations.Join(register.Features, lr => lr.FeatureId, f => f.Id, (lr, f) => new
			{
				lr, f
			})
			.Join(register.Features, x => x.lr.ParentFeatureId, f => f.Id, (x, f) => new
			{
				x.lr, child = x.f, parent = f
			})
			.Where(x => FullRegister.GetFeatureType(x.child.NameInCode) == FullRegister.GetFeatureType(x.parent.NameInCode)).Select(x => x.lr).ToList();


			// filter out the unavailale features in order not o mix the dependencie relative to features associated with the same license.
			if (FeatureAvailabilities != null && FeatureAvailabilities.Count > 0)
			{
				register.Features = register.Features.Where(f => FeatureAvailabilities.Select(x => x.Key).Contains(f.NameInCode)
									&& FeatureAvailabilities[f.NameInCode].IsAvailable).ToList();
				var selectedFeaturesIds = register.Features.Select(f => f.Id).ToList();

				register.FeatureLicenses = register.FeatureLicenses.Where(x => selectedFeaturesIds.Contains(x.Feature.Id)).ToList();
				register.Applications = register.Applications.Where(a => selectedFeaturesIds.Contains(a.FeatureId)).ToList();
				register.Options = register.Options.Where(x => selectedFeaturesIds.Contains(x.FeatureId)).ToList();
				register.LicenseRelations = register.LicenseRelations.Where(lr => selectedFeaturesIds.Contains(lr.FeatureId)
											&& selectedFeaturesIds.Contains(lr.ParentFeatureId)).ToList();
			}

			// do not consider collapsers for license ordering
			var ParentFeatureIds = register.LicenseRelations.Where(lr => lr.HiderType != HiderTypes.Collapser).Select(x => x.ParentFeatureId).Join(register.Features,
								   k => k, f => f.Id, (k, f) => f.Id).Distinct().ToList();
			var UndistinctChildFeatureIds = register.LicenseRelations.Where(lr => lr.HiderType != HiderTypes.Collapser).Select(x => x.FeatureId).Join(register.Features,
											k => k, f => f.Id, (k, f) => f.Id).ToList();
			var ChildFeatureIds = UndistinctChildFeatureIds.Distinct().ToList();
			var _MultipleParentLicenses = UndistinctChildFeatureIds.GroupBy(l => l).Where(g => g.Count() > 1).Select(g => g.First())
										  .Join(register.FeatureLicenses, k => k, f => f.Feature.Id, (k, fl) => fl).ToList();


			// Human applications
			var MultipleParent_HumanAppFeatLicenses = _MultipleParentLicenses.Join(register.Applications.Where(a => a.AppType ==
					SystemEnvironment.Human), fl => fl.Feature.Id, a => a.FeatureId, (fl, a) => fl).ToList();

			var _HumanFeatNoChildren = register.Applications.Where(a => a.AppType == SystemEnvironment.Human)
									   .Join(register.FeatureLicenses, a => a.FeatureId, fl => fl.Feature.Id, (a, fl) => fl.Feature).Where(x => !ChildFeatureIds.Contains(x.Id)).ToList();
			var HumanAppLicenses = FillChildren(_HumanFeatNoChildren, ParentFeatureIds, MultipleParent_HumanAppFeatLicenses, register);

			// Vet applications
			var MultipleParent_VetAppFeatLicenses = _MultipleParentLicenses.Join(register.Applications.Where(a => a.AppType ==
													SystemEnvironment.Veterinary), fl => fl.Feature.Id, a => a.FeatureId, (fl, a) => fl).ToList();
			var _VetFeatNoChildren = register.Applications.Where(a => a.AppType == SystemEnvironment.Veterinary)
									 .Join(register.FeatureLicenses, a => a.FeatureId, fl => fl.Feature.Id, (a, fl) => fl.Feature).Where(x => !ChildFeatureIds.Contains(x.Id)).ToList();
			VetAppLicenses = FillChildren(_VetFeatNoChildren, ParentFeatureIds, MultipleParent_VetAppFeatLicenses, register);

			// Options
			var MultipleParent_OptFeatLicenses = _MultipleParentLicenses.Join(register.Options, fl => fl.Feature.Id, o => o.FeatureId, (fl, o) => fl).ToList();
			var _OptionFeatNoChildren = register.Options
										.Join(register.FeatureLicenses, o => o.FeatureId, fl => fl.Feature.Id, (o,
												fl) => fl.Feature).Where(x => !ChildFeatureIds.Contains(x.Id)).OrderBy(fl => fl.LicenseId).ToList();
			OptionLicenses = FillChildren(_OptionFeatNoChildren, ParentFeatureIds, MultipleParent_OptFeatLicenses, register);

			AppLicenses = HumanAppLicenses.Union(VetAppLicenses).ToList();
			LicenseList = AppLicenses.Union(OptionLicenses).ToList();
		}
示例#17
0
 public static int GetMinVersion(FeatureRegister register)
 {
     return(register.MinorVersionAssociations.Min(x => x.Major));
 }
示例#18
0
        public static FeatureMain LoadFromFileAndFilter(string path, string modelName, FeatureRegister _register)
        {
            var main = LoadFromFile(path, modelName, _register);

            _register.ModelLicenses = _register.ModelLicenses.Where(m => m.License.Name == modelName).ToList();
            return(main);
        }
示例#19
0
 public FeatureMain(FeatureRegister register)
 {
     DBRegister = register;
 }
示例#20
0
 public abstract List <IVersionAssociation> GetVersionList(FeatureRegister _register);
示例#21
0
 public CountryItem(Country _country, Distributor _distributor, License _license)
 {
     MagicNumber = _license.Code;
     ComboLabel  = FeatureRegister.GetCountryComboDisplay(_country, _distributor);
     LicenseCode = _license.Name;
 }