Ejemplo n.º 1
0
        /// <summary>
        /// Select the correct ConfidentialIndicatordependend on the waste type
        /// </summary>
        public static Func <WASTETRANSFER, bool> ConfidentialityIndicatorQuantity(WasteTypeFilter.Type wasteType)
        {
            Expression <Func <WASTETRANSFER, bool> > func;

            switch (wasteType)
            {
            case WasteTypeFilter.Type.NonHazardous:
                func = s => (bool)s.ConfidentialIndicatorNONHW && s.QuantityTotalNONHW.Equals(null);
                break;

            case WasteTypeFilter.Type.HazardousCountry:
                func = s => (bool)s.ConfidentialIndicatorHWIC && s.QuantityTotalHWIC.Equals(null);
                break;

            case WasteTypeFilter.Type.HazardousTransboundary:
                func = s => (bool)s.ConfidentialIndicatorHWOC && s.QuantityTotalHWOC.Equals(null);
                break;

            default:
                throw new ArgumentOutOfRangeException("wasteType", String.Format("Illegal waste type:{0}", wasteType.ToString()));
            }
            return(func.Compile());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Select the correct recovery quantity dependend on the waste type
        /// </summary>
        public static Func <WASTETRANSFER, double?> QuantityRecovery(WasteTypeFilter.Type wasteType)
        {
            Expression <Func <WASTETRANSFER, double?> > func;

            switch (wasteType)
            {
            case WasteTypeFilter.Type.NonHazardous:
                func = s => s.QuantityRecoveryNONHW;
                break;

            case WasteTypeFilter.Type.HazardousCountry:
                func = s => s.QuantityRecoveryHWIC;
                break;

            case WasteTypeFilter.Type.HazardousTransboundary:
                func = s => s.QuantityRecoveryHWOC;
                break;

            default:
                throw new ArgumentOutOfRangeException("wasteType", String.Format("Illegal waste type:{0}", wasteType.ToString()));
            }
            return(func.Compile());
        }
Ejemplo n.º 3
0
        // ---------------------------------------------------------------------------------------------------
        // 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());
        }