Exemplo n.º 1
0
 private void AssessExtensionContent(CountryConfigFacade ccf, DataConfigFacade dcf,
                                     Dictionary <string, string> idOrderInfo, ref Dictionary <string, List <string> > extensionContent)
 {
     extensionContent.Clear();
     foreach (string extId in (from s in dcf.GetDataConfig().PolicySwitch select s.SwitchablePolicyID).Distinct())
     {
         List <string> content = new List <string>();
         foreach (CountryConfig.Extension_PolicyRow extPolRow in from e in ccf.GetCountryConfig().Extension_Policy where e.ExtensionID == extId select e)
         {
             if (extPolRow.PolicyRow.SystemRow != ccf.GetSystemRows().First())
             {
                 continue;
             }
             string order       = idOrderInfo.ContainsKey(extPolRow.PolicyID) ? idOrderInfo[extPolRow.PolicyID] : string.Empty;
             string name        = string.IsNullOrEmpty(extPolRow.PolicyRow.ReferencePolID) ? extPolRow.PolicyRow.Name : ccf.GetPolicyRowByID(extPolRow.PolicyRow.ReferencePolID).Name;
             string description = $"{order} {name}: {(extPolRow.BaseOff ? DefPar.Value.OFF : DefPar.Value.ON)}";
             if (extPolRow.PolicyRow.Private == DefPar.Value.YES)
             {
                 description += " (private)";
             }
             content.Add(description);
         }
         foreach (CountryConfig.Extension_FunctionRow extFunRow in from e in ccf.GetCountryConfig().Extension_Function where e.ExtensionID == extId select e)
         {
             if (extFunRow.FunctionRow.PolicyRow.SystemRow != ccf.GetSystemRows().First())
             {
                 continue;
             }
             string order       = idOrderInfo.ContainsKey(extFunRow.FunctionID) ? idOrderInfo[extFunRow.FunctionID] : string.Empty;
             string description = $"{order} {extFunRow.FunctionRow.Name}: {(extFunRow.BaseOff ? DefPar.Value.OFF : DefPar.Value.ON)}";
             if (extFunRow.FunctionRow.Private == DefPar.Value.YES)
             {
                 description += " (private)";
             }
             content.Add(description);
         }
         foreach (CountryConfig.Extension_ParameterRow extParRow in from e in ccf.GetCountryConfig().Extension_Parameter where e.ExtensionID == extId select e)
         {
             if (extParRow.ParameterRow.FunctionRow.PolicyRow.SystemRow != ccf.GetSystemRows().First())
             {
                 continue;
             }
             string order       = idOrderInfo.ContainsKey(extParRow.ParameterID) ? idOrderInfo[extParRow.ParameterID] : string.Empty;
             string description = $"{order} {extParRow.ParameterRow.Name}: {(extParRow.BaseOff ? DefPar.Value.OFF : DefPar.Value.ON)}";
             if (extParRow.ParameterRow.Private == DefPar.Value.YES)
             {
                 description += " (private)";
             }
             content.Add(description);
         }
         if (content.Any())
         {
             extensionContent.Add(extId, content);
         }
     }
 }
Exemplo n.º 2
0
        private static void AssessExtensionInfo(CountryConfigFacade ccf, DataConfigFacade dcf,
                                                string extensionId, string offOn, ref Dictionary <string, List <string> > switchInfo)
        {
            Dictionary <string, List <string> > dataSwitches = new Dictionary <string, List <string> >();

            foreach (DataConfig.PolicySwitchRow polSwitch in from e in dcf.GetDataConfig().PolicySwitch where e.SwitchablePolicyID == extensionId select e)
            {
                if (polSwitch.Value != offOn)
                {
                    continue;
                }
                if (!dataSwitches.ContainsKey(polSwitch.DataBaseID))
                {
                    dataSwitches.Add(polSwitch.DataBaseID, new List <string>());
                }
                dataSwitches[polSwitch.DataBaseID].Add(polSwitch.SystemID);
            }
            foreach (var dataSwitch in dataSwitches)
            {
                DataConfig.DataBaseRow dataRow = dcf.GetDataBaseRow(dataSwitch.Key); if (dataRow == null)
                {
                    continue;
                }
                string sumDataSwitches = dataRow.Name + ":";
                foreach (string sysId in dataSwitch.Value)
                {
                    CountryConfig.SystemRow sysRow = ccf.GetSystemRowByID(sysId); if (sysRow == null)
                    {
                        continue;
                    }
                    sumDataSwitches += sysRow.Name + ",";
                }
                if (!switchInfo.ContainsKey(extensionId))
                {
                    switchInfo.Add(extensionId, new List <string>());
                }
                switchInfo[extensionId].Add(RVItem_Base.TrimEnd(sumDataSwitches));
            }
        }
 internal static List <DataConfig.ExtensionRow> GetLocalExtensions(DataConfigFacade dataConfigFacade)
 {
     return((from e in dataConfigFacade.GetDataConfig().Extension select e).ToList());
 }
Exemplo n.º 4
0
        void AssessCountryInfo()
        {
            rvCountryInfo = new List <RVCountryInfo>();
            systemYears   = new List <int>(); systemYearsPublic = new List <int>();

            CountryConfigFacade ccfMTR = CountryAdministrator.GetCountryConfigFacade("MTR");
            CountryConfigFacade ccfLMA = CountryAdministrator.GetCountryConfigFacade("LMA");
            CountryConfigFacade ccfNRR = CountryAdministrator.GetCountryConfigFacade("NRR");

            foreach (string country in countries)
            {
                CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country);
                DataConfigFacade    dcf = CountryAdministrator.GetDataConfigFacade(country);

                RVCountryInfo ccInfo = new RVCountryInfo(country);
                List <int>    ccSystemYearsPublic = new List <int>();

                foreach (CountryConfig.SystemRow system in CountryAdministrator.GetCountryConfigFacade(country).GetSystemRows())
                {
                    int year = RVItem_SystemConfiguration.GetSystemYear(system); if (year == -1)
                    {
                        continue;
                    }
                    bool isPrivate = system.Private == DefPar.Value.YES;
                    if (!ccInfo.systemYearInfo.ContainsKey(year))
                    {
                        ccInfo.systemYearInfo.Add(year, isPrivate);
                    }
                    else if (ccInfo.systemYearInfo[year] == true)
                    {
                        ccInfo.systemYearInfo[year] = isPrivate;                                           // if there is a public and a private system for the year, let the public dominate
                    }
                    if (!systemYears.Contains(year))
                    {
                        systemYears.Add(year);
                    }
                    if (!isPrivate)
                    {
                        ccSystemYearsPublic.Add(year); if (!systemYearsPublic.Contains(year))
                        {
                            systemYearsPublic.Add(year);
                        }
                    }

                    List <DataConfig.DBSystemConfigRow> bm = (from d in dcf.GetDataConfig().DBSystemConfig
                                                              where d.SystemID == system.ID & d.BestMatch == DefPar.Value.YES
                                                              select d).ToList();
                    if (bm.Count > 0 && !ccInfo.bestMatchInfo.ContainsKey(year))
                    {
                        ccInfo.bestMatchInfo.Add(year, bm.First().DataBaseRow.Name);
                    }
                }

                //ccInfo.privateComponents = (from p in ccf.GetPolicyRowsOrderedAndDistinct()
                //                          where p.Private == DefPar.Value.YES select p.Name).ToList();
                int oPol = 0;
                foreach (CountryConfig.PolicyRow pol in ccf.GetPolicyRowsOrderedAndDistinct())
                {
                    ++oPol; int oFun = 0; string privFun = string.Empty;
                    ccInfo.idOrderInfo.Add(pol.ID, $"{oPol}");
                    if (pol.Private == DefPar.Value.YES)
                    {
                        ccInfo.privatePolicies.Add(string.Format("{0} {1}", oPol, pol.Name)); continue;
                    }
                    foreach (CountryConfig.FunctionRow fun in (from f in pol.GetFunctionRows() select f).OrderBy(f => long.Parse(f.Order)))
                    {
                        ++oFun; int oPar = 0; string privPar = string.Empty;
                        ccInfo.idOrderInfo.Add(fun.ID, $"{oPol}.{oFun}");
                        if (fun.Private == DefPar.Value.YES)
                        {
                            privFun += string.Format("{0} {1} ", oFun, fun.Name); continue;
                        }

                        foreach (CountryConfig.ParameterRow par in (from p in fun.GetParameterRows() select p).OrderBy(p => long.Parse(p.Order)))
                        {
                            ++oPar;
                            ccInfo.idOrderInfo.Add(par.ID, $"{oPol}.{oFun}.{oPar}");
                            if (par.Private == DefPar.Value.YES)
                            {
                                privPar += string.Format("{0} {1} ", oPar, par.Name); continue;
                            }
                        }
                        if (privPar != string.Empty)
                        {
                            ccInfo.privateParameters.Add(string.Format("{0}.{1} {2}/{3}/...: {4}",
                                                                       oPol.ToString(), oFun.ToString(), pol.Name, fun.Name, privPar));
                        }
                    }
                    if (privFun != string.Empty)
                    {
                        ccInfo.privateFunctions.Add(string.Format("{0} {1}/...: {2}",
                                                                  oPol, pol.Name, privFun));
                    }
                }

                foreach (DataConfig.DataBaseRow data in dcf.GetDataBaseRows())
                {
                    if (ccInfo.dataInfo.ContainsKey(data.Name))
                    {
                        continue;
                    }
                    bool isPrivate = data.Private == DefPar.Value.YES;
                    ccInfo.dataInfo.Add(data.Name, isPrivate);
                    if (data.Name.ToLower().StartsWith("training"))
                    {
                        ccInfo.hasTrainingData = true; ccInfo.isTrainingPublic = !isPrivate;
                    }
                    if (data.Name.ToLower().StartsWith("hypo"))
                    {
                        ccInfo.hasHypoData = true;
                    }

                    if (isPrivate)
                    {
                        continue;
                    }
                    ccInfo.dataNA.Add(data.Name, new List <string>());

                    if (!data.Name.ToLower().Contains("hhot"))
                    {
                        foreach (int systemYearPublic in ccSystemYearsPublic)
                        {
                            bool isAvailable = false;
                            foreach (DataConfig.DBSystemConfigRow dbs in dcf.GetDBSystemConfigRows(data.ID))
                            {
                                CountryConfig.SystemRow systemRow = CountryAdministrator.GetCountryConfigFacade(country).GetSystemRowByName(dbs.SystemName);
                                if (RVItem_SystemConfiguration.GetSystemYear(systemRow) == systemYearPublic)
                                {
                                    isAvailable = true; break;
                                }
                            }
                            if (!isAvailable)
                            {
                                ccInfo.dataNA[data.Name].Add(systemYearPublic.ToString());
                            }
                        }
                    }
                }

                foreach (string extId in (from s in dcf.GetDataConfig().PolicySwitch select s.SwitchablePolicyID).Distinct())
                {
                    AssessExtensionInfo(ccf, dcf, extId, DefPar.Value.ON, ref ccInfo.switchInfoOn);
                    AssessExtensionInfo(ccf, dcf, extId, DefPar.Value.OFF, ref ccInfo.switchInfoOff);
                }

                AssessExtensionContent(ccf, dcf, ccInfo.idOrderInfo, ref ccInfo.extensionContent);

                foreach (DataConfig.ExtensionRow er in dcf.GetDataConfig().Extension)
                {
                    ;
                }
                foreach (GlobLocExtensionRow er in ExtensionAndGroupManager.GetLocalExtensions(ccInfo.country))
                {
                    countriesExtensionInfo.Add(new Tuple <string, string, bool>(er.ID, er.Name, IsWholeContentPrivate(ccf.GetCountryConfig(), er.ID)));
                }

                ccInfo.mtrImplemented = AddOnImplemented(ccfMTR, country, "mtr");
                ccInfo.lmaImplemented = AddOnImplemented(ccfLMA, country, "lma");
                ccInfo.nrrImplemented = AddOnImplemented(ccfNRR, country, "nrr");

                rvCountryInfo.Add(ccInfo);
            }
            systemYears.Sort(); systemYearsPublic.Sort();
        }