Пример #1
0
    /// <summary>
    /// Save
    /// </summary>
    protected void doSave(object sender, EventArgs e)
    {
        try
        {
            CultureInfo  csvCulture = CultureResolver.ResolveCsvCulture(Request);
            CSVFormatter csvformat  = new CSVFormatter(csvCulture);

            // Create Header
            bool confidentialityAffected       = PollutantTransferTrend.IsAffectedByConfidentiality(FacilityBasic.FacilityID, PollutantCode);
            Dictionary <string, string> header = CsvHeaderBuilder.GetFacilityTrendHeader(FacilityBasic.FacilityReportId, true);

            // Create Body
            string pollutantName = LOVResources.PollutantName(PollutantCode);
            List <TimeSeriesClasses.PollutantTransfers> data = getTimeSeriesData(FacilityBasic.FacilityID, PollutantCode);

            // dump to file
            string topheader       = csvformat.CreateHeader(header);
            string pollutantHeader = csvformat.GetPollutantTransfersTrendHeader();

            Response.WriteUtf8FileHeader("EPRTR_Pollutant_Transfers_Time_Series");

            Response.Write(topheader + pollutantHeader);
            foreach (var v in data)
            {
                string row = csvformat.GetPollutantTransfersTrendRow(v, pollutantName);
                Response.Write(row);
            }
            Response.End();
        }
        catch
        {
        }
    }
Пример #2
0
    protected void showContent(string command)
    {
        hideSubControls();

        this.ucSheetLinks.HighLight(command);
        string txt = Resources.GetGlobal("Pollutant", "AllValuesAreYearlyTransfers");

        bool   conf  = PollutantTransferTrend.IsAffectedByConfidentiality(FacilityBasic.FacilityID, PollutantCode);
        string alert = conf ? Resources.GetGlobal("Common", "ConfidentialityAlertLink") : string.Empty;

        if (command.Equals(TrendTransferContent.TimeSeries.ToString()))
        {
            this.litHeadline.Text   = Resources.GetGlobal("Facility", "PollutantTransfersTimeSeries");
            ViewState[CONTENT_TYPE] = TrendTransferContent.TimeSeries;
        }
        else if (command.Equals(TrendTransferContent.Comparison.ToString()))
        {
            this.litHeadline.Text   = Resources.GetGlobal("Facility", "PollutantTransfersComparison");
            ViewState[CONTENT_TYPE] = TrendTransferContent.Comparison;
        }
        else if (command.Equals(TrendTransferContent.Confidentiality.ToString()))
        {
            this.litHeadline.Text = Resources.GetGlobal("Facility", "PollutantTransfersConfidentiality");
            this.ucContentConfidentiality.Visible = true;
            this.ucContentConfidentiality.Populate(FacilityBasic.FacilityID, PollutantCode);
            ViewState[CONTENT_TYPE] = TrendTransferContent.Confidentiality;
            alert = String.Empty;
        }

        updateHeader(txt);
        updateAlert(alert);
    }
    /// <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
        {
        }
    }
    /// <summary>
    /// Populate charts. Selected year in compare dropdown will be searchyear
    /// </summary>
    public void Populate(PollutantTransferTimeSeriesFilter filter, int?searchYear)
    {
        SearchFilter = filter;
        SearchYear   = searchYear;

        initializeContentLinks();

        //Only determine once and store in viewstate
        ConfidentialityAffected = PollutantTransferTrend.IsAffectedByConfidentiality(filter);
        // show timeseries as default
        showContent(Sheets.TimeSeries.TimeSeries.ToString());
    }
Пример #5
0
    /// <summary>
    /// getTimeSeriesData
    /// </summary>
    private List <TimeSeriesClasses.PollutantTransfers> getTimeSeriesData(int facilityid, string pollutantCode)
    {
        // look in viewstate first
        List <TimeSeriesClasses.PollutantTransfers> data = ViewState[TIMESERIES] as List <TimeSeriesClasses.PollutantTransfers>;

        // if no data in viewstate or id has changed, query db
        if ((data == null || data.Count() == 0))
        {
            data = PollutantTransferTrend.GetTimeSeries(facilityid, pollutantCode);
            ViewState[TIMESERIES] = data;
        }
        return(data);
    }
    /// <summary>
    /// updateTimeSeries
    /// </summary>
    private void updateCompareChart(PollutantTransferTimeSeriesFilter filter)
    {
        dataFound(true);

        // init year combo boxes
        int year1 = this.ucYearCompare.Year1;
        int year2 = this.ucYearCompare.Year2;

        Color[]           colors      = new Color[] { Global.ColorWasteWater, Global.ColorWasteWater };
        string[]          legendTexts = new string[] { Resources.GetGlobal("Common", "FacilitiesBothYears"), Resources.GetGlobal("Common", "AllFacilities") };
        ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { Global.HatchStyleBothYears, Global.HatchStyleTotal };

        // same unit for all data

        this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, PollutantTransferTrend.CODE_KG, colors, hatchStyles, legendTexts);

        // from and to bar
        // get compare result compare char
        TimeSeriesClasses.ComparisonPollutant result = PollutantTransferTrend.GetComparisonTimeSeries(filter, year1, year2);
        bool foundData = (result.QuantityFrom != null || result.QuantityTo != null);

        if (foundData)
        {
            TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData
            {
                Year   = result.YearFrom,
                Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityFrom), TimeSeriesUtils.RangeValue(result.QuantityFrom) - TimeSeriesUtils.RangeValue(result.BothQuantityFrom) },
            };

            TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData
            {
                Year   = result.YearTo,
                Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothQuantityTo), TimeSeriesUtils.RangeValue(result.QuantityTo) - TimeSeriesUtils.RangeValue(result.BothQuantityTo) },
            };

            // from and to bar
            this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>()
            {
                dataFrom, dataTo
            });


            // update sinle table
            updateTable(result);
        }
        else
        {
            dataFound(false);
        }
    }
Пример #7
0
    /// <summary>
    /// populate
    /// </summary>
    public void Populate(PollutantTransferTimeSeriesFilter filter)
    {
        // result from qyerylayer
        List <TimeSeriesClasses.PollutantTransfers> data = PollutantTransferTrend.GetTimeSeries(filter);

        // set data to table.
        this.lvTimeSeriesTable.DataSource = data;
        this.lvTimeSeriesTable.DataBind();

        // init time series. Must be done after table databinding, because missing years are added.
        this.ucStackColumnTime.Visible = (data != null && data.Count > 0);
        if (this.ucStackColumnTime.Visible)
        {
            Color[]           colors      = new Color[] { Global.ColorWasteWater };
            ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { ChartHatchStyle.None };
            // init time series
            this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_KG, colors, hatchStyles, null);
            //this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, PollutantTransferTrend.CODE_TNE, colors, null);
            this.ucStackColumnTime.Width = 700;

            List <TimeSeriesUtils.BarData> bars = new List <TimeSeriesUtils.BarData>();

            // loop through data and create tooltip
            foreach (var v in data)
            {
                string[] tip = new string[] { String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year),
                                              String.Format("{0}: {1}", Resources.GetGlobal("Common", "Quantity"), QuantityFormat.Format(v.Quantity, v.QuantityUnit)),
                                              String.Format("{0}: {1}", Resources.GetGlobal("Common", "Facilities"), v.Facilities) };

                TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData
                {
                    Year    = v.Year,
                    Values  = new double?[] { TimeSeriesUtils.RangeValue(v.Quantity) },
                    ToolTip = ToolTipFormatter.FormatLines(tip)
                };
                bars.Add(cd);
            }
            this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bars, false));
        }
    }
    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();
    }
 private void showContent(PollutantTransferTimeSeriesFilter filter)
 {
     this.lvConfidentiality.DataSource = PollutantTransferTrend.GetConfidentialTimeSeries(filter);
     this.lvConfidentiality.DataBind();
 }