/// <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
        {
        }
    }
示例#2
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);
        }
示例#3
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);
            }
        }
示例#4
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));
        }
    }
示例#5
0
    private List <LOV_POLLUTANT> getOrderedPollutants(AreaOverviewSearchFilter filter, MediumFilter.Medium medium, int pollutantGroupID)
    {
        List <string> pollutantCodes = AreaOverview.GetPollutantReleasePollutantCodes(filter, medium, pollutantGroupID);

        IEnumerable <LOV_POLLUTANT> pollutants = ListOfValues.Pollutants(pollutantGroupID).Where(p => pollutantCodes.Contains(p.Code));

        //sort by short name
        List <LOV_POLLUTANT> orderedPollutants = pollutants.OrderBy(p => LOVResources.PollutantNameShort(p.Code)).ToList();

        //Add confidential in group to the end of the list.
        LOV_POLLUTANT confPollutant = ListOfValues.GetPollutant(pollutantGroupID);

        if (pollutantCodes.Contains(confPollutant.Code))
        {
            orderedPollutants.Add(confPollutant);
        }

        return(orderedPollutants);
    }
示例#6
0
    /// <summary>
    /// Save release data
    /// </summary>
    protected void doSave(object sender, EventArgs e)
    {
        try
        {
            CultureInfo  csvCulture = CultureResolver.ResolveCsvCulture(Request);
            CSVFormatter csvformat  = new CSVFormatter(csvCulture);

            // Check if current medium is affected confidentiality claims
            bool confidentialityAffected = PollutantReleaseTrend.IsAffectedByConfidentiality(
                SearchFilter,
                CurrentMedium);

            // Create Header
            var header = CsvHeaderBuilder.GetTsPollutantReleasesSearchHeader(SearchFilter,
                                                                             CurrentMedium,
                                                                             confidentialityAffected);

            var data = PollutantReleaseTrend.GetTimeSeries(SearchFilter, CurrentMedium);

            string mediumName    = LOVResources.MediumName(EnumUtil.GetStringValue(CurrentMedium));
            var    pollutant     = ListOfValues.GetPollutant(SearchFilter.PollutantFilter.PollutantID);
            string pollutantName = LOVResources.PollutantName(pollutant.Code);

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

            Response.WriteUtf8FileHeader("EPRTR_Pollutant_Releases_Time_Series");

            Response.Write(topheader + rowheaders);

            foreach (var v in data)
            {
                string row = csvformat.GetPollutantReleasesTimeSeriesRow(v, pollutantName, mediumName);
                Response.Write(row);
            }
            Response.End();
        }
        catch
        {
        }
    }
    public void Populate(PollutantTransferTimeSeriesFilter filter, bool hasConfidentialInformation)
    {
        SearchFilter = filter;

        LOV_POLLUTANT pollutant = ListOfValues.GetPollutant(filter.PollutantFilter.PollutantID);

        PollutantCode = pollutant != null ? pollutant.Code : null;

        //set parentcode
        ParentCode = null;
        if (pollutant != null && pollutant.ParentID != null)
        {
            LOV_POLLUTANT pollutantGroup = ListOfValues.GetPollutant(pollutant.ParentID.Value);
            ParentCode = pollutantGroup != null ? pollutantGroup.Code : null;
        }

        this.divConfidentialityInformation.Visible   = hasConfidentialInformation;
        this.divNoConfidentialityInformation.Visible = !hasConfidentialInformation;

        showContent(filter);
    }
    public void Populate(int facilityId, string pollutantCode)
    {
        PollutantCode = pollutantCode;
        //set parentcode
        LOV_POLLUTANT pollutant = ListOfValues.GetPollutant(pollutantCode);

        ParentCode = null;
        if (pollutant != null && pollutant.ParentID != null)
        {
            LOV_POLLUTANT pollutantGroup = ListOfValues.GetPollutant(pollutant.ParentID.Value);
            ParentCode = pollutantGroup != null ? pollutantGroup.Code : null;
        }

        List <TimeSeriesClasses.ConfidentialityPollutant> data = PollutantTransferTrend.GetConfidentialTimeSeries(facilityId, pollutantCode);
        bool hasConfidentialInformation = data.Any();

        this.divConfidentialityInformation.Visible   = hasConfidentialInformation;
        this.divNoConfidentialityInformation.Visible = !hasConfidentialInformation;

        this.lvConfidentiality.Visible    = true;
        this.lvConfidentiality.DataSource = data;
        this.lvConfidentiality.DataBind();
    }
    public void Populate(PollutantReleasesTimeSeriesFilter filter, bool hasConfidentialInformation, MediumFilter.Medium medium)
    {
        SearchFilter = filter;

        LOV_POLLUTANT pollutant = ListOfValues.GetPollutant(filter.PollutantFilter.PollutantID);

        PollutantCode = pollutant != null ? pollutant.Code : null;

        //set parentcode
        ParentCode = null;
        if (pollutant != null && pollutant.ParentID != null)
        {
            LOV_POLLUTANT pollutantGroup = ListOfValues.GetPollutant(pollutant.ParentID.Value);
            ParentCode = pollutantGroup != null ? pollutantGroup.Code : null;
        }

        this.ucMediumSelector.Visible = hasConfidentialInformation;

        if (hasConfidentialInformation)
        {
            var count = PollutantReleaseTrend.GetFacilityCounts(filter);
            this.ucMediumSelector.PopulateMediumRadioButtonList(filter.MediumFilter, medium, count);
        }
    }
示例#10
0
        /// <summary>
        /// Gets the name of a Pollutant group based on the id
        /// </summary>
        public static string PollutantGroupName(int id)
        {
            LOV_POLLUTANT group = ListOfValues.GetPollutant(id);

            return(PollutantGroupName(group.Code));
        }
示例#11
0
                    public Map(string layerId, string cmsLayerId, MediumFilter.Medium medium, string pollutantCode, List <string> activityCodes, int year)
                    {
                        this.LayerId    = layerId;
                        this.CmsLayerId = cmsLayerId;
                        this.Medium     = medium;

                        //year
                        filter.YearFilter = new YearFilter {
                            Year = year
                        };

                        //set pollutant filter
                        LOV_POLLUTANT pollutant = ListOfValues.GetPollutant(pollutantCode);

                        filter.PollutantFilter                  = new PollutantFilter();
                        filter.PollutantFilter.PollutantID      = pollutant.LOV_PollutantID;
                        filter.PollutantFilter.PollutantGroupID = (int)pollutant.ParentID;

                        //set medium filter
                        filter.MediumFilter = new MediumFilter();
                        switch (medium)
                        {
                        case MediumFilter.Medium.Air:
                            filter.MediumFilter.ReleasesToAir = true;
                            break;

                        case MediumFilter.Medium.Soil:
                            filter.MediumFilter.ReleasesToSoil = true;
                            break;

                        case MediumFilter.Medium.Water:
                            filter.MediumFilter.ReleasesToWater = true;
                            break;

                        default:
                            filter.MediumFilter = null;
                            break;
                        }

                        //set activity filter
                        if (activityCodes.Count > 0)
                        {
                            IEnumerable <LOV_ANNEXIACTIVITY> activities = ListOfValues.GetAnnexIActivities(activityCodes);
                            filter.ActivityFilter = new ActivityFilter();
                            filter.ActivityFilter.ActivityType   = ActivityFilter.Type.AnnexI;
                            filter.ActivityFilter.SectorIds      = activities.Select(a => (int)a.ParentID).ToList <int>();
                            filter.ActivityFilter.ActivityIds    = activities.Select(a => a.LOV_AnnexIActivityID).ToList <int>();
                            filter.ActivityFilter.SubActivityIds = new List <int>()
                            {
                                ActivityFilter.AllSubActivitiesInActivityID
                            };
                        }

                        //create mapfilter for expanded map
                        this.MapFilterExpanded = QueryLayer.PollutantReleases.GetMapFilter(filter);

                        if (activityCodes.Count > 0)
                        {
                            this.MapFilterExpanded.Layers = String.Format("facilities,{0}", LayerId); //Don't show any layers as default
                        }
                        else
                        {
                            this.MapFilterExpanded.Layers = LayerId;
                        }

                        this.MapFilterExpanded.VisibleLayers = LayerId; //only turn on diffuse layer

                        //create mapfilter for small map (does not show facilities)
                        this.MapFilterSmall        = new MapFilter();
                        this.MapFilterSmall.Layers = LayerId;
                    }