private void updateJavaScriptMap(WasteTransferTimeSeriesFilter filter) { MapFilter mapfilter = QueryLayer.WasteTransferTrend.GetMapJavascriptFilter(filter); MapJavaScriptUtils.UpdateJavaScriptMap(mapfilter, Page); }
/// <summary> /// return true if confidentiality might effect result /// </summary> public static bool IsAffectedByConfidentiality(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { Expression <Func <WASTETRANSFER_CONFIDENTIAL, bool> > lambda = getLambdaExpressionConfidential(filter, wasteType); DataClassesWasteTransferDataContext db = getDataContext(); return(db.WASTETRANSFER_CONFIDENTIALs.Any(lambda)); }
private static Expression <Func <WASTETRANSFER, bool> > getLambdaExpression(WasteTransferTimeSeriesFilter filter) { ParameterExpression param = Expression.Parameter(typeof(WASTETRANSFER), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionWasteTransfer(filter, param, false); Expression <Func <WASTETRANSFER, bool> > lambda = Expression.Lambda <Func <WASTETRANSFER, bool> >(exp, param); return(lambda); }
protected void btnSearch_Click(object sender, EventArgs e) { if (InvokeSearch != null) { WasteTransferTimeSeriesFilter filter = PopulateFilter(); // start the search InvokeSearch.Invoke(filter, e); } }
/// <summary> /// returns a dictionary with sheet headers for timeseries waste transfer search /// </summary> public static Dictionary <string, string> GetTimeSeriesWasteTransferHeader(WasteTransferTimeSeriesFilter filter) { Dictionary <string, string> header = new Dictionary <string, string>(); addArea(header, filter.AreaFilter); addActivity(header, filter.ActivityFilter); addWasteType(header, filter.WasteTypeFilter); return(header); }
/// <summary> /// Populate charts. Selected year in compare dropdown will be searchyear /// </summary> public void Populate(WasteTransferTimeSeriesFilter filter, int?searchYear) { SearchFilter = filter; SearchYear = searchYear; initializeContentLinks(); //Only determine once and store in viewstate ConfidentialityAffected = WasteTransferTrend.IsAffectedByConfidentiality(filter); // Show timeseries as default showContent(Sheets.TimeSeries.TimeSeries.ToString()); }
/// <summary> /// updateTimeSeries /// </summary> private void updateCompareChart(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { CurrentWasteType = wasteType; // view everything, user may select other years to compare dataFound(true); // init year combo boxes int year1 = this.ucYearCompare.Year1; int year2 = this.ucYearCompare.Year2; // get compare result compare char TimeSeriesClasses.ComparisonWasteTransfer result = WasteTransferTrend.GetComparisonTimeSeries(filter, year1, year2, wasteType); bool foundData = (result.TotalFrom != null || result.TotalTo != null); if (foundData) { dataFound(true); Color[] colors = new Color[] { Global.ColorWasteTotal, Global.ColorWasteTotal }; ChartHatchStyle[] hatchStyles = new ChartHatchStyle[] { Global.HatchStyleBothYears, Global.HatchStyleTotal }; string[] legendTexts = new string[] { Resources.GetGlobal("Common", "FacilitiesBothYears"), Resources.GetGlobal("Common", "AllFacilities") }; this.ucStackColumnCompare.Initialize(colors.Length, StackColumnType.Comparison, CODE_TNE, colors, hatchStyles, legendTexts); // from and to bar TimeSeriesUtils.BarData dataFrom = new TimeSeriesUtils.BarData { Year = result.YearFrom, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothTotalFrom), TimeSeriesUtils.RangeValue(result.TotalFrom) - TimeSeriesUtils.RangeValue(result.BothTotalFrom) }, }; TimeSeriesUtils.BarData dataTo = new TimeSeriesUtils.BarData { Year = result.YearTo, Values = new double?[] { TimeSeriesUtils.RangeValue(result.BothTotalTo), TimeSeriesUtils.RangeValue(result.TotalTo) - TimeSeriesUtils.RangeValue(result.BothTotalTo) }, }; // from and to bar this.ucStackColumnCompare.Add(new List <TimeSeriesUtils.BarData>() { dataFrom, dataTo }); // update sinle table updateTable(result); } else { dataFound(false); } }
/// <summary> /// /// </summary> public void Populate(WasteTransferTimeSeriesFilter filter, bool hasConfidentialInformation, WasteTypeFilter.Type wasteType) { SearchFilter = filter; //examine if there exists any confidential data independed of the wastetype this.ucWasteTypeSelector.Visible = hasConfidentialInformation; if (hasConfidentialInformation) { var counts = WasteTransferTrend.GetCountFacilities(filter); this.ucWasteTypeSelector.PopulateRadioButtonList(filter.WasteTypeFilter, wasteType, counts); } }
/// <summary> /// load completed, perserve scroll /// </summary> protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); if (!IsPostBack) { //if filter is in request, search will be invoked from the start if (LinkSearchBuilder.HasWasteTransferTimeSeriesFilter(Request)) { WasteTransferTimeSeriesFilter filter = this.ucSearchOptions.PopulateFilter(); doSearch(filter, EventArgs.Empty); } } }
private static Expression <Func <WASTETRANSFER, bool> > getLambdaExpression(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { Expression <Func <WASTETRANSFER, bool> > lambda = getLambdaExpression(filter); ParameterExpression param = lambda.Parameters[0]; //Apply waste type Expression expType = LinqExpressionBuilder.GetLinqExpressionWasteTransferType(wasteType, param, false); Expression exp = LinqExpressionBuilder.CombineAnd(lambda.Body, expType); lambda = Expression.Lambda <Func <WASTETRANSFER, bool> >(exp, param); return(lambda); }
/// <summary> /// query data to be displayed in the facility resul listview /// </summary> private void doSearch(object sender, EventArgs e) { ((MasterSearchPage)this.Master).UpdateMode(true); ((MasterSearchPage)this.Master).ShowResultArea(); WasteTransferTimeSeriesFilter filter = sender as WasteTransferTimeSeriesFilter; if (filter != null) { this.ucTsWasteTransfersSheet.Populate(filter); updateJavaScriptMap(filter); } }
/// <summary> /// returns a dictionary with sheet headers <key, value> for waste transfers time series search /// </summary> public static Dictionary <string, string> GetTsWasteTransfersSearchHeader( WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type currentWasteType, bool confidentialityAffected) { Dictionary <string, string> header = makeHeader(); addArea(header, filter.AreaFilter); addActivity(header, filter.ActivityFilter); addWasteType(header, currentWasteType); addConfidentiality(header, confidentialityAffected); return(header); }
// --------------------------------------------------------------------------------------------------- // Time series // --------------------------------------------------------------------------------------------------- #region timeseries /// <summary> /// return timeseries /// </summary> public static List <TimeSeriesClasses.WasteTransfer> GetTimeSeries(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wastetype) { DataClassesWasteTransferDataContext db = getDataContext(); // apply filter Expression <Func <WASTETRANSFER, bool> > lambda = getLambdaExpression(filter, wastetype); // get data and group by year (which get assigned to x.Key by link) IQueryable <IGrouping <int, WASTETRANSFER> > group = db.WASTETRANSFERs.Where(lambda).GroupBy(p => p.ReportingYear).OrderBy(p => p.Key); // lookup wastetype. Table has only one row per faciltiy report IEnumerable <TimeSeriesClasses.WasteTransfer> data = null; switch (wastetype) { case WasteTypeFilter.Type.HazardousCountry: data = group.Select(x => new TimeSeriesClasses.WasteTransfer(x.Key, x.Count(), WasteTypeFilter.Type.HazardousCountry, x.Sum(p => p.QuantityTotalHWIC), x.Sum(p => p.QuantityRecoveryHWIC), x.Sum(p => p.QuantityDisposalHWIC), x.Sum(p => p.QuantityUnspecHWIC))); break; case WasteTypeFilter.Type.HazardousTransboundary: data = group.Select(x => new TimeSeriesClasses.WasteTransfer(x.Key, x.Count(), WasteTypeFilter.Type.HazardousTransboundary, x.Sum(p => p.QuantityTotalHWOC), x.Sum(p => p.QuantityRecoveryHWOC), x.Sum(p => p.QuantityDisposalHWOC), x.Sum(p => p.QuantityUnspecHWOC))); break; case WasteTypeFilter.Type.NonHazardous: data = group.Select(x => new TimeSeriesClasses.WasteTransfer(x.Key, x.Count(), WasteTypeFilter.Type.NonHazardous, x.Sum(p => p.QuantityTotalNONHW), x.Sum(p => p.QuantityRecoveryNONHW), x.Sum(p => p.QuantityDisposalNONHW), x.Sum(p => p.QuantityUnspecNONHW))); break; default: throw new ArgumentOutOfRangeException("wastetype", String.Format("Illegal wastetype: {0}", wastetype.ToString())); } //add information about no. of reporting countries IEnumerable <Facility.ReportingCountries> years = Facility.GetReportingCountries(filter.AreaFilter).ToList(); IEnumerable <TimeSeriesClasses.WasteTransfer> res = from l in data.ToList() join r in years on l.Year equals r.Year select new TimeSeriesClasses.WasteTransfer( l.Year, l.Facilities, l.WasteType, l.QuantityTotal, l.QuantityRecovery, l.QuantityDisposal, l.QuantityUnspec, r.Countries); return(res.OrderBy(p => p.Year).ToList()); }
// ---------------------------------------------------------------------------------- // Map filters // ---------------------------------------------------------------------------------- #region Map /// <summary> /// returns the MapFilter (sql and sectors) corresponding to the filter. The map always uses the WASTETRANSFER table for lookup /// </summary> public static MapFilter GetMapFilter(WasteTransferTimeSeriesFilter filter) { //parameter must be "p" to match map config file ParameterExpression param = Expression.Parameter(typeof(WASTETRANSFER), "p"); Expression exp = LinqExpressionBuilder.GetLinqExpressionWasteTransfer(filter, param, false); Expression <Func <WASTETRANSFER, bool> > lambda = Expression.Lambda <Func <WASTETRANSFER, bool> >(exp, param); // create sql and sectors to map. Do not remove parameter prefix. MapFilter mapFilter = new MapFilter(); mapFilter.SqlWhere = LinqExpressionBuilder.GetSQL(lambda.Body, null); mapFilter.SetLayers(filter.ActivityFilter); return(mapFilter); }
private void showContent(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { CurrentWasteType = wasteType; //examine if there exists any confidential data for the waste type given bool hasConfidentialInformationType = WasteTransferTrend.IsAffectedByConfidentiality(filter, wasteType); this.divConfidentialityInformation.Visible = hasConfidentialInformationType; this.divNoConfidentialityInformation.Visible = !hasConfidentialInformationType; if (hasConfidentialInformationType) { this.lvConfidentiality.DataSource = WasteTransferTrend.GetCountConfidentialFacilities(filter, wasteType); this.lvConfidentiality.DataBind(); } }
/// <summary> /// /// </summary> public void Populate(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { SearchFilter = filter; var counts = WasteTransferTrend.GetCountFacilities(filter); this.ucWasteTypeSelector.PopulateRadioButtonList(filter.WasteTypeFilter, wasteType, counts); // check that any relases are selected if (!filter.WasteTypeFilter.HazardousWasteCountry && !filter.WasteTypeFilter.HazardousWasteTransboundary && !filter.WasteTypeFilter.NonHazardousWaste) { dataFound(false); return; } }
public WasteTransferTimeSeriesFilter PopulateFilter() { WasteTransferTimeSeriesFilter filter = new WasteTransferTimeSeriesFilter(); filter.AreaFilter = this.ucAreaSearchOption.PopulateFilter(); filter.PeriodFilter = new PeriodFilter(); filter.PeriodFilter.StartYear = 2007; filter.ActivityFilter = this.ucAdvancedActivitySearchOption.PopulateFilter(); filter.WasteTypeFilter = this.ucWasteTypeSearchOption.PopulateFilter(); // store settings in cookies CookieStorage.SetFilter(Response, filter.AreaFilter); return(filter); }
private void toggleTimeseries(ListViewCommandEventArgs e, int rowindex) { ucTsWasteTransfersSheet control = (ucTsWasteTransfersSheet)this.lvWasteTransferActivity.Items[rowindex].FindControl("ucTsWasteTransfersSheet"); closeAllSubSheets(); // only allow 1 sheet open control.Visible = !control.Visible; Control div = this.lvWasteTransferActivity.Items[rowindex].FindControl("subsheet"); div.Visible = !div.Visible; if (control.Visible) { // create search filter and change activity filter WasteTransferTimeSeriesFilter filter = FilterConverter.ConvertToWasteTransferTimeSeriesFilter(SearchFilter); filter.ActivityFilter = getActivityFilter(e); control.Populate(filter, SearchFilter.YearFilter.Year); } }
// -------------------------------------------------------------------------------------------------------------------- // WasteTransfer Time series Filter // -------------------------------------------------------------------------------------------------------------------- #region WasteTransferTimeSeriesFilter public static string SerializeToUrl(WasteTransferTimeSeriesFilter filter) { string result = String.Empty; if (filter != null) { // Area result += SerializeToUrl(filter.AreaFilter); // Period result += SerializeToUrl(filter.PeriodFilter); // Activity result += SerializeToUrl(filter.ActivityFilter); // Waste Type result += SerializeToUrl(filter.WasteTypeFilter); } result = result.Remove(result.Length - 1); return(result); }
/// <summary> /// updateTimeSeries /// </summary> private void updateTimeSeries(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wastetype) { CurrentWasteType = wastetype; // assume data is found dataFound(true); // result from qyerylayer List <TimeSeriesClasses.WasteTransfer> data = WasteTransferTrend.GetTimeSeries(filter, wastetype); // no data found, hide controls and leave if (data == null || data.Count == 0) { dataFound(false); return; } // set report data to table this.lvTimeSeriesTable.DataSource = data; this.lvTimeSeriesTable.DataBind(); // init stack column, 3 ranges var _colors = new List <Color>(); var _legendTexts = new List <string>(); var _hatchStyles = new List <ChartHatchStyle>(); var _tips = new List <string>(); var _values = new List <double?>(); _tips.Add(Resources.GetGlobal("Common", "Year") + ": {0}"); _tips.Add(Resources.GetGlobal("Common", "Facilities") + ": {0}"); // When called from the Time Series menu, the treatment filter will be null // Then all treatments are displayed bool showAll = (filter.WasteTreatmentFilter == null); if (showAll || filter.WasteTreatmentFilter.Recovery) { _colors.Add(Global.ColorWasteRecovery); _legendTexts.Add(Resources.GetGlobal("Common", "TreatmentRecovery")); _hatchStyles.Add(ChartHatchStyle.None); } if (showAll || filter.WasteTreatmentFilter.Disposal) { _colors.Add(Global.ColorWasteDisposal); _legendTexts.Add(Resources.GetGlobal("Common", "TreatmentDisposal")); _hatchStyles.Add(ChartHatchStyle.None); } if (showAll || filter.WasteTreatmentFilter.Unspecified) { _colors.Add(Global.ColorWasteUnspec); _legendTexts.Add(Resources.GetGlobal("Common", "TreatmentUnspecified")); _hatchStyles.Add(ChartHatchStyle.None); } Color[] colors = _colors.ToArray(); string[] legendTexts = _legendTexts.ToArray(); ChartHatchStyle[] hatchStyles = _hatchStyles.ToArray(); this.ucStackColumnTime.Initialize(colors.Length, StackColumnType.TimeSeries, WasteTransferTrend.CODE_TNE, colors, hatchStyles, legendTexts); List <TimeSeriesUtils.BarData> bardata = new List <TimeSeriesUtils.BarData>(); // loop through data and create tooltip foreach (var v in data) { _values.Clear(); _tips.Clear(); _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Year"), v.Year)); _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Facilities"), v.Facilities)); if (showAll || filter.WasteTreatmentFilter.Recovery) { _values.Add(TimeSeriesUtils.RangeValue(v.QuantityRecovery)); _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Recovery"), QuantityFormat.Format(v.QuantityRecovery, v.QuantityUnit))); } if (showAll || filter.WasteTreatmentFilter.Disposal) { _values.Add(TimeSeriesUtils.RangeValue(v.QuantityDisposal)); _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Disposal"), QuantityFormat.Format(v.QuantityDisposal, v.QuantityUnit))); } if (showAll || filter.WasteTreatmentFilter.Unspecified) { _values.Add(TimeSeriesUtils.RangeValue(v.QuantityUnspec)); _tips.Add(String.Format("{0}: {1}", Resources.GetGlobal("Common", "Unspecified"), QuantityFormat.Format(v.QuantityUnspec, v.QuantityUnit))); } TimeSeriesUtils.BarData cd = new TimeSeriesUtils.BarData { Year = v.Year, Values = _values.ToArray(), ToolTip = ToolTipFormatter.FormatLines(_tips.ToArray()) }; bardata.Add(cd); } this.ucStackColumnTime.Add(TimeSeriesUtils.InsertMissingYearsTimeSeries(bardata, false)); }
// --------------------------------------------------------------------------------------------------- // Comparison // --------------------------------------------------------------------------------------------------- #region comparison /// <summary> /// GetComparisonTimeSeries /// </summary> public static TimeSeriesClasses.ComparisonWasteTransfer GetComparisonTimeSeries(WasteTransferTimeSeriesFilter filter, int yearFrom, int yearTo, WasteTypeFilter.Type wasteType) { // Create lambda with pollutant release filter Expression <Func <WASTETRANSFER, bool> > lambda = getLambdaExpression(filter, wasteType); DataClassesWasteTransferDataContext db = new DataClassesWasteTransferDataContext(); // group by reporting year, get from and to data IQueryable <IGrouping <int, WASTETRANSFER> > groupFrom = db.WASTETRANSFERs.Where(lambda).Where(p => p.ReportingYear == yearFrom).GroupBy(p => p.ReportingYear); IQueryable <IGrouping <int, WASTETRANSFER> > groupTo = db.WASTETRANSFERs.Where(lambda).Where(p => p.ReportingYear == yearTo).GroupBy(p => p.ReportingYear); // Facility IDs when year is 'yearTo' var vTo = db.WASTETRANSFERs.Where(lambda).Where(p => p.ReportingYear == yearTo).Select(p => p.FacilityID).Distinct(); IQueryable <IGrouping <int, WASTETRANSFER> > groupDataFromBoth = db.WASTETRANSFERs.Where(lambda).Where(p => p.ReportingYear == yearFrom && vTo.Contains(p.FacilityID)).GroupBy(p => p.ReportingYear); // Facility IDs when year is 'yearFrom' var vFrom = db.WASTETRANSFERs.Where(lambda).Where(p => p.ReportingYear == yearFrom).Select(p => p.FacilityID).Distinct(); IQueryable <IGrouping <int, WASTETRANSFER> > groupDataToBoth = db.WASTETRANSFERs.Where(lambda).Where(p => p.ReportingYear == yearTo && vFrom.Contains(p.FacilityID)).GroupBy(p => p.ReportingYear); // result lists IEnumerable <TimeSeriesClasses.TsWasteCompare> dataFrom = null, dataTo = null; IEnumerable <TimeSeriesClasses.TsWasteCompare> dataFromBoth = null, dataToBoth = null; switch (wasteType) { case WasteTypeFilter.Type.HazardousCountry: dataFrom = groupFrom.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWIC), x.Sum(p => p.QuantityRecoveryHWIC), x.Sum(p => p.QuantityDisposalHWIC), x.Sum(p => p.QuantityUnspecHWIC))); dataTo = groupTo.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWIC), x.Sum(p => p.QuantityRecoveryHWIC), x.Sum(p => p.QuantityDisposalHWIC), x.Sum(p => p.QuantityUnspecHWIC))); dataFromBoth = groupDataFromBoth.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWIC), x.Sum(p => p.QuantityRecoveryHWIC), x.Sum(p => p.QuantityDisposalHWIC), x.Sum(p => p.QuantityUnspecHWIC))); dataToBoth = groupDataToBoth.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWIC), x.Sum(p => p.QuantityRecoveryHWIC), x.Sum(p => p.QuantityDisposalHWIC), x.Sum(p => p.QuantityUnspecHWIC))); break; case WasteTypeFilter.Type.HazardousTransboundary: dataFrom = groupFrom.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWOC), x.Sum(p => p.QuantityRecoveryHWOC), x.Sum(p => p.QuantityDisposalHWOC), x.Sum(p => p.QuantityUnspecHWOC))); dataTo = groupTo.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWOC), x.Sum(p => p.QuantityRecoveryHWOC), x.Sum(p => p.QuantityDisposalHWOC), x.Sum(p => p.QuantityUnspecHWOC))); dataFromBoth = groupDataFromBoth.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWOC), x.Sum(p => p.QuantityRecoveryHWOC), x.Sum(p => p.QuantityDisposalHWOC), x.Sum(p => p.QuantityUnspecHWOC))); dataToBoth = groupDataToBoth.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalHWOC), x.Sum(p => p.QuantityRecoveryHWOC), x.Sum(p => p.QuantityDisposalHWOC), x.Sum(p => p.QuantityUnspecHWOC))); break; case WasteTypeFilter.Type.NonHazardous: dataFrom = groupFrom.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalNONHW), x.Sum(p => p.QuantityRecoveryNONHW), x.Sum(p => p.QuantityDisposalNONHW), x.Sum(p => p.QuantityUnspecNONHW))); dataTo = groupTo.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalNONHW), x.Sum(p => p.QuantityRecoveryNONHW), x.Sum(p => p.QuantityDisposalNONHW), x.Sum(p => p.QuantityUnspecNONHW))); dataFromBoth = groupDataFromBoth.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalNONHW), x.Sum(p => p.QuantityRecoveryNONHW), x.Sum(p => p.QuantityDisposalNONHW), x.Sum(p => p.QuantityUnspecNONHW))); dataToBoth = groupDataToBoth.Select(x => new TimeSeriesClasses.TsWasteCompare(x.Count(), x.Sum(p => p.QuantityTotalNONHW), x.Sum(p => p.QuantityRecoveryNONHW), x.Sum(p => p.QuantityDisposalNONHW), x.Sum(p => p.QuantityUnspecNONHW))); break; default: return(null); } TimeSeriesClasses.ComparisonWasteTransfer result = new TimeSeriesClasses.ComparisonWasteTransfer(yearFrom, yearTo); var res = dataFrom.SingleOrDefault(); if (res != null) { result.SetFrom(res.Count, res.Quantity, res.Recovery, res.Disposal, res.Unspecified); } res = dataTo.SingleOrDefault(); if (res != null) { result.SetTo(res.Count, res.Quantity, res.Recovery, res.Disposal, res.Unspecified); } res = dataFromBoth.SingleOrDefault(); if (res != null) { result.SetBothFrom(res.Count, res.Quantity, res.Recovery, res.Disposal, res.Unspecified); } res = dataToBoth.SingleOrDefault(); if (res != null) { result.SetBothTo(res.Count, res.Quantity, res.Recovery, res.Disposal, res.Unspecified); } return(result); }
public static List <TimeSeriesClasses.ConfidentialityWaste> GetCountConfidentialFacilities(WasteTransferTimeSeriesFilter filter, WasteTypeFilter.Type wasteType) { DataClassesWasteTransferDataContext db = getDataContext(); Expression <Func <WASTETRANSFER_CONFIDENTIAL, bool> > lambda = getLambdaExpressionConfidential(filter, wasteType); //count all confidential claims //table has one row per facility per wastetype so distinct is needed List <TimeSeriesClasses.ConfidentialityWaste> confidential = db.WASTETRANSFER_CONFIDENTIALs.Where(lambda) .GroupBy(v => v.ReportingYear) .OrderBy(v => v.Key) .Select(v => new TimeSeriesClasses.ConfidentialityWaste { Year = v.Key, CountConfTotal = v.Select(x => x.FacilityReportID).Distinct().Count(), CountConfQuantity = v.Where(x => (bool)x.ConfidentialityOnQuantity).Select(x => x.FacilityReportID).Distinct().Count(), CountConfTreatment = v.Where(x => (bool)x.ConfidentialityOnTreatmant).Select(x => x.FacilityReportID).Distinct().Count() }).ToList(); if (confidential.Count() > 0) { List <TimeSeriesClasses.WasteTransfer> all = GetTimeSeries(filter, wasteType); foreach (TimeSeriesClasses.WasteTransfer wt in all) { TimeSeriesClasses.ConfidentialityWaste conf = confidential.SingleOrDefault(c => c.Year.Equals(wt.Year)); if (conf != null) { conf.CountTotal = wt.Facilities; } else { confidential.Add(new TimeSeriesClasses.ConfidentialityWaste { Year = wt.Year, CountTotal = wt.Facilities }); } } return(confidential.OrderBy(c => c.Year).ToList()); } return(new List <TimeSeriesClasses.ConfidentialityWaste>()); }
/// <summary> /// populate. Selected year in compare dropdown will be the last report year /// </summary> public void Populate(WasteTransferTimeSeriesFilter filter) { Populate(filter, null); }
//Table only contains confidential data private static Expression <Func <WASTETRANSFER_CONFIDENTIAL, bool> > getLambdaExpressionConfidential(WasteTransferTimeSeriesFilter filter) { ParameterExpression param = Expression.Parameter(typeof(WASTETRANSFER_CONFIDENTIAL), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionWasteTransfer(filter, param, true); Expression <Func <WASTETRANSFER_CONFIDENTIAL, bool> > lambda = Expression.Lambda <Func <WASTETRANSFER_CONFIDENTIAL, bool> >(exp, param); return(lambda); }
// --------------------------------------------------------------------------------------------------- // Count method // --------------------------------------------------------------------------------------------------- #region count /// <summary> /// Returns the number of facilities corresponding to the filter, per waste type /// Overloaded with TimeSeries filter for ease of use. /// </summary> public static QueryLayer.WasteTransfers.FacilityCountObject GetCountFacilities(WasteTransferTimeSeriesFilter tsFilter) { // conversion removes all year span information var filter = FilterConverter.ConvertToWasteTransferSearchFilter(tsFilter); ParameterExpression param = Expression.Parameter(typeof(WASTETRANSFER_TREATMENT), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionWasteTransferSearch(filter, param, true); // Exclude EPER reporting years Expression prop = Expression.Property(param, "ReportingYear"); Expression val = Expression.Constant(2007); Expression yearExp = Expression.GreaterThanOrEqual(prop, val); exp = Expression.AndAlso(yearExp, exp); Expression <Func <WASTETRANSFER_TREATMENT, bool> > lambda = Expression.Lambda <Func <WASTETRANSFER_TREATMENT, bool> >(exp, param); return(WasteTransfers.GetFacilityCounts(lambda)); }