/// <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> /// 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> /// 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)); } }