Ejemplo n.º 1
0
        public static List <Uirule> ImportProbeAppRules(FeaturesContext _db, DBBuffer _buffer, Paths Paths, string LogXml2DB)
        {
            Provider.WriteImportLogFormat(LogXml2DB, "Read Probe-Applications relations");
            string settingsName = "", ProbeName = "";

            try
            {
                // ANTO DB
                _buffer.p_probe_SettingsFamily = _db.ProbeSettingsFamily.ToList();
                var num_sf         = _buffer.p_settingsFamilies.Count;
                var resultProbeApp = new List <ProbePreset> [num_sf];
                Parallel.For(0, num_sf, sfindex =>
                {
                    settingsName      = _buffer.p_settingsFamilies[sfindex].Name;
                    String swPackName = _buffer.p_swPacks.Single(s => s.Id == _buffer.p_settingsFamilies[sfindex].SwpackId).Name;
                    // select current probeList and join it with probeBind and probe Id already inserted in the DB
                    List <ProbeBind> currentProbeList = _buffer.p_probe_SettingsFamily.Where(x => x.SettingsFamilyId == _buffer.p_settingsFamilies[sfindex].Id).
                                                        Join(_buffer.p_probes, ps => ps.ProbeId, p => p.Id, (ps, p) => p).ToList().
                                                        Join(_buffer.probeBindLst, p => p.SaleName, x => x.probe.SaleName, (p, x) => new ProbeBind(p, x.probeInfoLst)).ToList();
                    resultProbeApp[sfindex] = new List <ProbePreset>();
                    foreach (ProbeBind probeBind in currentProbeList)                       // loop probes in probelist to complete probe and add probeApplication association
                    {
                        var currentProbeSetting = _buffer.p_probe_SettingsFamily.Single(x => x.ProbeId == probeBind.probe.Id &&
                                                                                        x.SettingsFamilyId == _buffer.p_settingsFamilies[sfindex].Id);
                        var probeDescEquip = (Provider.readProbeDescr(swPackName, currentProbeSetting, Paths)).Descendants("equipment").First();
                        ProbeName          = probeBind.probe.SaleName;

                        probeBind.probe.Biplane = Convert.ToBoolean(probeDescEquip.Element("fBiplane").Value);                               // complete probe field
                        currentProbeSetting.ProbeDataFileNameFrontal = probeDescEquip.Element("sProbeDataFileNameFrontal").Value.ToString();
                        currentProbeSetting.ProbeDataFileNameLateral = probeDescEquip.Element("sProbeDataFileNameLateral").Value.ToString() == "NULLFILE" ? null :
                                                                       probeDescEquip.Element("sProbeDataFileNameLateral").Value.ToString();

                        // fill appNode for the current settings family in the current probe
                        var currentProbeInfo      = probeBind.getProbeInfo(_buffer.p_settingsFamilies[sfindex]);
                        currentProbeInfo.appNodes = probeDescEquip.Element("sApplicationDesc").Elements("element")
                                                    .Where(a => a.Element("eApplication").Value.ToString() != "APPL_INVALID_PD").ToList();

                        resultProbeApp[sfindex].AddRange(createProbeApps(probeBind, currentProbeInfo, _buffer));
                    }
                });

                return(finalizeImport(resultProbeApp.SelectMany(rp => rp).ToList(), _db, _buffer));
            }
            catch (Exception ex)
            {
                throw new ParsingException("Probe-Applications relations for settings family " + settingsName + " probe " + ProbeName, ex);
            }
        }
Ejemplo n.º 2
0
        private static List <Uirule> finalizeImport(List <ProbePreset> resultProbeApp, FeaturesContext _db, DBBuffer _buffer)
        {
            // ANTO DB

            // for the changes in the probe table
            //_db.SubmitChanges();
            _db.SaveChanges();

            // insert probe_applications and create UIRules for them
            //			_db.BulkInsert(resultProbeApp);
            //			_db.ProbePreset.AddRange(resultProbeApp);
            _db.BulkInsert(resultProbeApp);

            var result = _db.createProbeAppRules(resultProbeApp, _buffer);

            _buffer.p_probe_Apps = resultProbeApp.Join(_buffer.p_applications, x => x.ApplicationId, a => a.Id, (x, a) =>
                                                       new ProbeApp(x.ProbeId, x.SettingsFamilyId, a)).ToList();
            return(result);
        }