Beispiel #1
0
        //creates header for Pollutant filter and adds to dictionary
        protected static void addPollutant(Dictionary <string, string> header, PollutantFilter filter)
        {
            if (filter != null)
            {
                string key   = Resources.GetGlobal("Common", "Pollutant");
                string value = string.Empty;

                PollutantFilter.Level level = filter.SearchLevel();

                if (level == PollutantFilter.Level.All)
                {
                    value = Resources.GetGlobal("Common", "AllPollutants");
                }
                else if (level == PollutantFilter.Level.PollutantGroup)
                {
                    value = LOVResources.PollutantGroupName(ListOfValues.GetPollutant(filter.PollutantGroupID).Code);
                }
                else
                {
                    value = LOVResources.PollutantName(ListOfValues.GetPollutant(filter.PollutantID).Code);
                }

                header.Add(key, value);
            }
        }
    /// <summary>
    /// Save transfers data
    /// </summary>
    protected void doSave(object sender, EventArgs e)
    {
        try
        {
            CultureInfo  csvCulture = CultureResolver.ResolveCsvCulture(Request);
            CSVFormatter csvformat  = new CSVFormatter(csvCulture);

            // Create Header
            var header = CsvHeaderBuilder.GetTsPollutantTransfersSearchHeader(SearchFilter, ConfidentialityAffected);

            var data = PollutantTransferTrend.GetTimeSeries(SearchFilter);

            var    pollutant     = ListOfValues.GetPollutant(SearchFilter.PollutantFilter.PollutantID);
            string pollutantName = LOVResources.PollutantName(pollutant.Code);

            // dump to file
            string topheader  = csvformat.CreateHeader(header);
            string rowheaders = csvformat.GetPollutantTransfersTimeSeriesHeader();

            Response.WriteUtf8FileHeader("EPRTR_Pollutant_Transfers_Time_Series");

            Response.Write(topheader + rowheaders);

            foreach (var v in data)
            {
                string row = csvformat.GetPollutantTransfersTimeSeriesRow(v, pollutantName);
                Response.Write(row);
            }
            Response.End();
        }
        catch
        {
        }
    }
Beispiel #3
0
        private static List <WasteTransfers.TransboundaryHazardousWasteData> prepareBubblechartData(IEnumerable <WasteTransfers.TransboundaryHazardousWasteData> data)
        {
            List <WasteTransfers.TransboundaryHazardousWasteData> result = new List <WasteTransfers.TransboundaryHazardousWasteData>();

            result.AddRange(data);

            //Add one dummy row for each E-PRTR country - to make sure all reporting countries are always represented in the grid
            IEnumerable <WasteTransfers.TransboundaryHazardousWasteData> dummies = ListOfValues.ReportingCountries()
                                                                                   .OrderBy(x => x.Code)
                                                                                   .Select(v => new WasteTransfers.TransboundaryHazardousWasteData()
            {
                TransferTo = v.Code,
            });

            result.AddRange(dummies);

            //Add dummy row for other countries (i.e. countries outside E-PRTR)
            WasteTransfers.TransboundaryHazardousWasteData other = new WasteTransfers.TransboundaryHazardousWasteData();
            other.TransferTo = WasteTransfers.TransboundaryHazardousWasteData.OTHER;


            result.Add(other);

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the name of a NaceActivity (incl. code) based on the LOV_Id
        /// </summary>
        public static string NaceActivityName(int lov_id)
        {
            LOV_NACEACTIVITY a    = ListOfValues.GetNaceActicvity(lov_id);
            string           code = a != null ? a.Code : String.Empty;

            return(NaceActivityName(code));
        }
    /// <summary>
    /// Search, fill data into summery
    /// </summary>
    public void Populate(int facilityReportId, int searchYear, string pollutantCode, MediumFilter.Medium medium)
    {
        FacilityBasic = Facility.GetFacilityBasic(facilityReportId);
        PollutantCode = pollutantCode;

        ViewState[FACILITY_REPORTID] = facilityReportId;
        CurrentMedium          = medium;
        ViewState[SEARCH_YEAR] = searchYear;

        // reset viewstate data
        ViewState[TIMESERIES_AIR]   = null;
        ViewState[TIMESERIES_WATER] = null;
        ViewState[TIMESERIES_SOIL]  = null;

        showContent(TrendReleaseContent.TimeSeries.ToString());

        // set the year according to search. Include EPER

        List <int> years = ListOfValues.ReportYearsSeries().ToList();

        if (medium == MediumFilter.Medium.Soil)
        {
            years = ListOfValues.ReportYears(showEPER).ToList();
        }

        this.ucYearCompareSeries.Initialize(years, searchYear);
    }
    private string groupCount(PollutantReleases.ReleasesTreeListRow row)
    {
        int total  = ListOfValues.CountLeafPollutants(row.Code);
        int number = 0;

        return(String.Format("({0}/{1})", number, total));
    }
Beispiel #7
0
        /// <summary>
        /// GetPollutantFilter
        /// </summary>
        public static PollutantFilter GetPollutantFilter(string code, int level)
        {
            PollutantFilter filter    = new PollutantFilter();
            LOV_POLLUTANT   pollutant = ListOfValues.GetPollutant(code);

            if (level == 1)
            {
                if (pollutant.ParentID != null)
                {
                    filter.PollutantID      = pollutant.LOV_PollutantID;
                    filter.PollutantGroupID = pollutant.ParentID.Value;
                }
                else
                {
                    // confidential in group, same id
                    filter.PollutantID      = pollutant.LOV_PollutantID;
                    filter.PollutantGroupID = pollutant.LOV_PollutantID;
                }
            }
            else if (level == 0)
            {
                filter.PollutantID      = PollutantFilter.AllPollutantsInGroupID;
                filter.PollutantGroupID = pollutant.LOV_PollutantID;
            }

            return(filter);
        }
Beispiel #8
0
        public ListOfValue AddLov(string value, string parentValue)
        {
            if (string.IsNullOrEmpty(value.Trim()))
            {
                return(null);
            }

            if (ActiveListOfValues.Any(val => val.Equals(value)))
            {
                var lov =
                    ListOfValues.FirstOrDefault(a => a.Active && a.Value.ToLower().Trim() == value.ToLower().Trim());

                if (lov == null)
                {
                    return(null);
                }

                if (lov.ParentValue.Trim().ToLower() != parentValue.Trim().ToLower())
                {
                    lov.ParentValue = parentValue;
                    return(lov);
                }
                return(lov);
            }
            var listOfValue = new ListOfValue {
                Value = value, ParentValue = parentValue
            };

            ListOfValues.Add(listOfValue);

            return(listOfValue);
        }
Beispiel #9
0
    public static string Resolve(HttpRequest request)
    {
        // get list of currently allowed cultures from CMS database
        IEnumerable <string> allowedCultures = ListOfValues.GetAllCultureCodes();
        // retrieve cookie
        HttpCookie cultureCookie = request.Cookies["Culture"];

        // retrieve url parameter
        string cultureUrlParameter = request.QueryString["lang"];

        string cultureDefault = "en-GB";

        // set to default
        string cultureCode = cultureDefault;

        // apply url based culture
        if (allowedCultures.Contains(cultureUrlParameter))
        {
            cultureCode = cultureUrlParameter;
        }
        // apply cookie based culture from dropdown
        else if (cultureCookie != null &&
                 !string.IsNullOrEmpty(cultureCookie.Value) &&
                 allowedCultures.Contains(cultureCookie.Value))
        {
            cultureCode = cultureCookie.Value;
        }

        return(cultureCode);
    }
Beispiel #10
0
        private string loadData()
        {
            ListOfValues lst = new ListOfValues();

            lst.listaObiektow = null;
            var client = new HttpClient();
            var task   = client.GetAsync("http://mpmmtest.azurewebsites.net/api/values")
                         .ContinueWith((taskwithresponse) =>
            {
                var response   = taskwithresponse.Result;
                var jsonString = response.Content.ReadAsStringAsync();
                jsonString.Wait();
                lst = JsonConvert.DeserializeObject <ListOfValues>(jsonString.Result);
            });

            task.Wait();
            string message = "<table style='width:70%'><tr><td>ID</td><td>Nazwa</td><td>Tresc</td></tr>";

            foreach (var value in lst.listaObiektow.OrderBy(x => x.id))
            {
                message += "<tr><td>" + value.id + "</td>";
                message += "<td>" + value.nazwa + "</td>";
                message += "<td>" + value.tresc + "</td></tr>";
            }
            message += "</table>";
            return(message);
        }
Beispiel #11
0
        /// <summary>
        /// Gets the name of a AnnexIActivity (incl. code) based on the LOV_AnnexIId
        /// </summary>
        public static string AnnexIActivityName(int lov_id)
        {
            LOV_ANNEXIACTIVITY a = ListOfValues.GetAnnexIActicvity(lov_id);

            string code = a != null ? a.Code : String.Empty;

            return(AnnexIActivityName(code));
        }
 public void UncheckOnly(params string[] values)
 {
     DoVIAction("UnheckOnly: " + values.Print(),
                () =>
     {
         Clear();
         CheckGroup(ListOfValues.Except(values).ToArray());
     });
 }
Beispiel #13
0
        //creates header for regulation (legal name) used in reporting and adds to dictionary
        protected static void addLegalRegulation(Dictionary <string, string> header, int reportingYear)
        {
            string key = Resources.GetGlobal("Common", "Regulation");

            string code  = ListOfValues.GetRegulationCode(reportingYear);
            string value = LOVResources.LegalRegulationName(code);

            header.Add(key, value);
        }
        public IExtendedProperty Clone()
        {
            var extendedProperty = new ExtendedProperty <T> {
                Name = Name, Value = Value, ReadOnly = ReadOnly, Description = Description, FullName = FullName
            };

            ListOfValues.Each(property => extendedProperty.AddToListOfValues(property));
            return(extendedProperty);
        }
Beispiel #15
0
        private void SaveGoogleMap(string googleSitemap)
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.Encoding    = Encoding.UTF8;
            settings.CloseOutput = true;

            using (XmlWriter writer = XmlWriter.Create(googleSitemap, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");

                writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
                writer.WriteAttributeString("xsi", "schemaLocation", null, "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd");

                var languageList = ListOfValues.GetAllCultureCodes();

                foreach (Url url in _urls)
                {
                    writer.WriteStartElement("url");
                    writer.WriteElementString("loc", url.Location);
                    writer.WriteEndElement();

                    //D30 START 16/05/2013 --> We don´t need languages

                    /* if (languageList.Count() > 1)
                     * {
                     *    foreach (var lang in languageList)
                     *    {
                     *        //RRP START 18-04-2013
                     *        //Original code (All cultures)
                     *        //writer.WriteStartElement("url");
                     *        //writer.WriteElementString("loc", url.Location + "?lang=" + lang);
                     *        //writer.WriteEndElement();
                     *
                     *        //Only for en-GB culture
                     *        //We don't need references from the sitemap to the same page in all languages.
                     *        //Only English is needed
                     *        if (lang == "en-GB")
                     *        {
                     *            writer.WriteStartElement("url");
                     *            writer.WriteElementString("loc", url.Location + "?lang=" + lang);
                     *            writer.WriteEndElement();
                     *        }
                     *        //RRP END 18-04-2013
                     *    }
                     * }*/

                    //D30 END 16/05/2013
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
Beispiel #16
0
        /// <summary>
        /// return map with reporting countries for a list of years
        /// [year][count]
        /// </summary>
        public static Dictionary <int, int> GetReportingYears()
        {
            Dictionary <int, int> yearContries = new Dictionary <int, int>();
            var reportingyears = ListOfValues.ReportingYears(true);

            foreach (var v in reportingyears)
            {
                yearContries.Add(v.Year, v.Countries.HasValue ? v.Countries.Value : 0);
            }
            return(yearContries);
        }
Beispiel #17
0
 public static string PollutantNameEPER(string code, string codeEPER)
 {
     if (ListOfValues.IsPollutantGroupEPER(code, codeEPER))
     {
         return(GetResource("LOV_POLLUTANT", codeEPER + ".Confidential"));
     }
     else
     {
         return(GetResource("LOV_POLLUTANT", codeEPER));
     }
 }
Beispiel #18
0
    protected void lvColHeaders_OnDataBinding(object sender, EventArgs e)
    {
        Label lbActivity = ((ListView)sender).FindControl("lbActivity") as Label;

        int           pollutantGroupID = getPollutantGroupID();
        LOV_POLLUTANT group            = ListOfValues.GetPollutant(pollutantGroupID);

        if (lbActivity != null && group != null)
        {
            lbActivity.Text = String.Format(Resources.GetGlobal("AreaOverview", "ReleasesOf"), LOVResources.PollutantGroupName(group.Code));
        }
    }
Beispiel #19
0
        public void AreaGroupsTest()
        {
            //IEnumerable<LOV_AREAGROUP> expected = null; // TODO: Initialize to an appropriate value
            IEnumerable <LOV_AREAGROUP> actual;

            actual = ListOfValues.AreaGroups();

            // Test of the numer of entries in LOV
            Assert.AreEqual(5, actual.Count());

            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #20
0
        public static AreaFilter GetAreaFilter(AreaFilter searchAreaFilter, string areaCode, string parentCode)
        {
            //for total-rows the activityfilter corresponds to the filter from the search
            if (TreeListRow.CODE_TOTAL.Equals(areaCode))
            {
                return(searchAreaFilter == null ? null : searchAreaFilter.Clone() as AreaFilter);
            }

            AreaFilter areaFilter = new AreaFilter();

            areaFilter.TypeRegion = searchAreaFilter.TypeRegion;

            // Search for country according to code
            REPORTINGCOUNTRY country = ListOfValues.GetReportingCountry(areaCode);

            if (country != null)
            {
                //country level
                areaFilter.CountryID = country.LOV_CountryID;
                areaFilter.RegionID  = AreaFilter.AllRegionsInCountryID;
            }
            else
            {
                country = ListOfValues.GetReportingCountry(parentCode);
                areaFilter.CountryID = country.LOV_CountryID;

                //NUTS or RBD level
                if (areaFilter.TypeRegion.Equals(AreaFilter.RegionType.RiverBasinDistrict))
                {
                    LOV_RIVERBASINDISTRICT rbd = ListOfValues.GetRiverBasinDistrict(areaCode);
                    if (rbd != null)
                    {
                        areaFilter.RegionID = rbd.LOV_RiverBasinDistrictID;
                    }
                }
                else if (areaFilter.TypeRegion.Equals(AreaFilter.RegionType.NUTSregion))
                {
                    LOV_NUTSREGION nuts = ListOfValues.GetNutsRegion(areaCode);

                    if (nuts != null && !TreeListRow.CODE_UNKNOWN.Equals(areaCode))
                    {
                        areaFilter.RegionID = nuts.LOV_NUTSRegionID;
                    }
                    else
                    {
                        areaFilter.RegionID = null;
                    }
                }
            }


            return(areaFilter);
        }
Beispiel #21
0
        protected static void addDatabaseDate(Dictionary <string, string> header)
        {
            string appIsReview = ConfigurationManager.AppSettings["IsReview"];

            if (!String.IsNullOrEmpty(appIsReview) && appIsReview.ToLower().Equals("true"))
            {
                header.Add(Resources.GetGlobal("Common", "DatabaseDateReview"), ListOfValues.GetLatestReviewDate().Format());
            }
            else
            {
                header.Add(Resources.GetGlobal("Common", "DatabaseDate"), ListOfValues.GetLatestPublicationDate().Format());
            }
        }
Beispiel #22
0
        /// <summary>
        /// Gets the short name of a Pollutant based on the code.
        /// If the code corresponds to a pollutant group, the name for confidnetiality within the group is returned
        /// </summary>
        public static string PollutantNameShort(string code)
        {
            string shortCode = code + ".short";

            if (ListOfValues.IsPollutantGroup(code))
            {
                return(GetResource("LOV_POLLUTANT", shortCode + ".Confidential"));
            }
            else
            {
                return(GetResource("LOV_POLLUTANT", shortCode));
            }
        }
Beispiel #23
0
    /// <summary>
    /// init list
    /// </summary>
    public void Initialize(bool includeEper, int?searchYear)
    {
        // get reporting years
        List <int> years = ListOfValues.ReportYearsSeries().ToList();

        this.Visible = years.Count > 0;

        if (years.Count > 0)
        {
            int year = searchYear.HasValue ? searchYear.Value : years[years.Count - 1];
            Initialize(years, year);
        }
    }
Beispiel #24
0
        /// <summary>
        /// GetActivityFilter
        /// </summary>
        /// <param name="searchActivityFilter">Input filter is discarded after this method is run</param>
        /// <param name="code">Note: code can be sector, activity or subactivity code</param>
        /// <param name="parentCode"></param>
        /// <returns></returns>
        public static ActivityFilter GetActivityFilter(ActivityFilter searchActivityFilter, string code, string parentCode)
        {
            //for total-rows the activityfilter corresponds to the filter from the search
            if (TreeListRow.CODE_TOTAL.Equals(code))
            {
                return(searchActivityFilter == null ? null : searchActivityFilter.Clone() as ActivityFilter);
            }

            ActivityFilter activityfilter = new ActivityFilter();

            LOV_ANNEXIACTIVITY parent   = ListOfValues.GetAnnexIActicvity(parentCode);
            LOV_ANNEXIACTIVITY selected = ListOfValues.GetAnnexIActicvity(code);

            if (parent == null)
            {
                //selected is on sectorlevel
                activityfilter.SectorIds.Add(selected.LOV_AnnexIActivityID);
                activityfilter.ActivityIds.Add(ActivityFilter.AllActivitiesInSectorID);
                activityfilter.SubActivityIds.Add(ActivityFilter.AllSubActivitiesInActivityID);
            }
            else
            {
                //selected is on sectorlevel or activity
                if (parent.ParentID == null)
                {
                    //selected is on activity level
                    activityfilter.SectorIds.Add(parent.LOV_AnnexIActivityID);
                    activityfilter.ActivityIds.Add(selected.LOV_AnnexIActivityID);
                    activityfilter.SubActivityIds.Add(ActivityFilter.AllSubActivitiesInActivityID);
                }
                else
                {
                    //selected is on subactivity level
                    LOV_ANNEXIACTIVITY sector = ListOfValues.GetAnnexIActicvity((int)parent.ParentID);
                    activityfilter.SectorIds.Add(sector.LOV_AnnexIActivityID);
                    activityfilter.ActivityIds.Add(parent.LOV_AnnexIActivityID);

                    if (TreeListRow.CODE_UNSPECIFIED.Equals(code))
                    {
                        activityfilter.SubActivityIds.Add(ActivityFilter.SubActivitiesUnspecifiedID);
                    }
                    else
                    {
                        activityfilter.SubActivityIds.Add(selected.LOV_AnnexIActivityID);
                    }
                }
            }
            return(activityfilter);
        }
    protected string GetGroupCount(object obj)
    {
        IndustrialActivity.IAReleasesTreeListRow row = (IndustrialActivity.IAReleasesTreeListRow)obj;

        if (row.HasChildren)
        {
            int total  = ListOfValues.CountLeafPollutants(row.Code);
            int number = row.CountChildPollutants;
            return(String.Format("({0}/{1})", number, total));
        }
        else
        {
            return(string.Empty);
        }
    }
Beispiel #26
0
        public ListOfValue AddLov(string value)
        {
            if (ActiveListOfValues.Any(val => val.Equals(value)))
            {
                return(null);
            }

            var listOfValue = new ListOfValue {
                Value = value
            };

            ListOfValues.Add(listOfValue);

            return(listOfValue);
        }
Beispiel #27
0
    /// <summary>
    /// Search, fill data into summery
    /// </summary>
    public void Populate(int facilityReportId, string pollutantCode, int searchYear)
    {
        FacilityBasic         = Facility.GetFacilityBasic(facilityReportId);
        PollutantCode         = pollutantCode;
        SearchYear            = searchYear;
        ViewState[TIMESERIES] = null;

        // first sheet is the time series sheet
        showContent(TrendTransferContent.TimeSeries.ToString());

        // set the year according to search. Include EPER
        List <int> years = ListOfValues.ReportYearsSeries().ToList();

        this.ucYearCompareSeries.Initialize(years, searchYear);
    }
    /// <summary>
    /// Search, fill data into summery
    /// </summary>
    public void Populate(int facilityReportId, int searchYear, WasteTypeFilter.Type waste)
    {
        FacilityBasic = Facility.GetFacilityBasic(facilityReportId);
        ViewState[FACILITY_SPECIAL] = facilityReportId;
        WasteType  = waste;
        SearchYear = searchYear;

        // reset viewstate data
        ViewState[TIMESERIES_DATA] = null;
        showContent(TrendWasteContent.TimeSeries.ToString());

        // set the year according to search. Waste does not inclucde EPER
        List <int> years = years = ListOfValues.ReportYears(false).ToList();

        this.ucYearCompareSeries.Initialize(years, searchYear);
    }
Beispiel #29
0
        //creates header for Area and adds to dictionary
        protected static void addArea(Dictionary <string, string> header, AreaFilter filter)
        {
            if (filter != null)
            {
                string key   = Resources.GetGlobal("Common", "Area");
                string value = string.Empty;

                AreaFilter.Level level = filter.SearchLevel();

                if (level == AreaFilter.Level.AreaGroup)
                {
                    string code = ListOfValues.GetAreaGroup((int)filter.AreaGroupID).Code;
                    value = LOVResources.AreaGroupName(code);
                }
                else if (level == AreaFilter.Level.Country)
                {
                    string code = ListOfValues.GetCountry((int)filter.CountryID).Code;
                    value = LOVResources.CountryName(code);
                }
                else if (level == AreaFilter.Level.Region)
                {
                    if (filter.TypeRegion == AreaFilter.RegionType.RiverBasinDistrict)
                    {
                        string code = ListOfValues.GetRiverBasinDistrict((int)filter.RegionID).Code;
                        value = LOVResources.RiverBasinDistrictName(code);
                    }
                    else if (filter.TypeRegion == AreaFilter.RegionType.NUTSregion)
                    {
                        if (filter.RegionID != null)
                        {
                            string code = ListOfValues.GetNUTSRegion((int)filter.RegionID).Code;
                            value = LOVResources.NutsRegionName(code);
                        }
                        else
                        {
                            value = LOVResources.NutsRegionName(TreeListRow.CODE_UNKNOWN);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException(string.Format("Illgegal RegionType {0}", filter.TypeRegion));
                    }
                }

                header.Add(key, value);
            }
        }
Beispiel #30
0
        public static IEnumerable <TimeSeriesUtils.BarData> InsertMissingYearsTimeSeries(IEnumerable <TimeSeriesUtils.BarData> data, bool includeEPER)
        {
            IEnumerable <REPORTINGYEAR> years = ListOfValues.ReportingYearsTimeSeries();

            IEnumerable <TimeSeriesUtils.BarData> bars = from y in years
                                                         join c in data on y.Year equals c.Year into g
                                                         from c in g.DefaultIfEmpty()
                                                         orderby y.Year
                                                         select new TimeSeriesUtils.BarData
            {
                Year    = y.Year,
                Values  = c != null ? c.Values : null,
                ToolTip = c != null ? c.ToolTip : null
            };

            return(bars);
        }