Example #1
0
    /// <summary>
    /// update header
    /// </summary>
    /// <param name="filter"></param>
    private void updateHeader(PollutantTransfersSearchFilter filter, bool includeFacilityCount, string text)
    {
        Dictionary <string, string> header = SheetHeaderBuilder.GetPollutantTransferSearchHeader(filter, includeFacilityCount);

        this.ucSheetSubHeader.PopulateHeader(header);
        this.ucSheetSubHeader.Text = text;
    }
Example #2
0
 /// <summary>
 /// Search, fill data into summery
 /// </summary>
 public void Populate(PollutantTransfersSearchFilter filter)
 {
     SearchFilter            = filter;
     ConfidentialityAffected = PollutantTransfers.IsAffectedByConfidentiality(filter); //Only determine once and store in viewstate
     // always show summery
     showContent(Sheets.PollutantTransfers.Summary.ToString());
 }
Example #3
0
        /// <summary>
        /// return total list confidential reasons
        /// </summary>
        public static IEnumerable <TransfersConfidentialRow> GetConfidentialReason(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();

            // apply filter for confidential, do not include the pollutant itself
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filter, param, false);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            var reason0 = db.POLLUTANTTRANSFERs.Where(lambda);
            var reason1 = from p in reason0 group p by new { p.ConfidentialCode };
            var reason2 = from p in reason1
                          select new
            {
                code  = p.Select(x => x.ConfidentialCode).First(),
                count = p.Count()
            };

            // build result
            List <TransfersConfidentialRow> result = new List <TransfersConfidentialRow>();

            foreach (var v in reason2)
            {
                result.Add(new TransfersConfidentialRow(v.code, v.count));
            }
            return(result.OrderBy(x => x.Code));
        }
Example #4
0
        /// <summary>
        /// GetAreaComparison
        /// </summary>
        public static List <AreaComparison> GetAreaComparison(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();

            // apply filter
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filter, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            AreaFilter areaFilter = filter.AreaFilter;

            IEnumerable <AreaComparison> data = db.POLLUTANTTRANSFERs.Where(lambda)
                                                .GroupBy(areaFilter)
                                                .Select(x => new AreaComparison(
                                                            x.Key.Code,
                                                            x.Sum(p => p.Quantity),
                                                            x.Count()));

            //Make sure sql is executed now and ordered by size
            List <AreaComparison> result = data.OrderBy(p => p.Quantity).ToList();

            //Calculate percentages
            double tot = result.Sum(p => p.Quantity);

            if (tot > 0)
            {
                foreach (AreaComparison ac in result)
                {
                    ac.Percent = (ac.Quantity / tot) * 100.0;
                }
            }

            return(result);
        }
Example #5
0
        /// <summary>
        /// Return all subactivities (level 2) that fullfill search criteria.
        /// If activityCodes are null, all activities will be returned. If activityCodes is empty no activities will be returned.
        /// Notice that this will include one subactivity "Not specified on this level" for each activity, even if the activity do not have any subactivities at all!
        /// </summary>
        public static IEnumerable <ActivityTreeListRow> GetSubActivities(PollutantTransfersSearchFilter filter, List <string> activityCodes)
        {
            if (activityCodes != null && activityCodes.Count() == 0)
            {
                return(new List <ActivityTreeListRow>());
            }

            DataClassesPollutantTransferDataContext      db     = getPollutantTransferDataContext();
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getActivityAreaLambda(filter);

            //add activities to expression
            if (activityCodes != null)
            {
                ParameterExpression param       = lambda.Parameters[0];
                Expression          activityExp = LinqExpressionBuilder.GetInExpr(param, "IAActivityCode", activityCodes);

                Expression exp = LinqExpressionBuilder.CombineAnd(lambda.Body, activityExp);
                lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);
            }

            //find data for sub-activity level, this level never has children.
            IEnumerable <ActivityTreeListRow> subactivities = db.POLLUTANTTRANSFERs.Where(lambda)
                                                              .GroupBy(p => new { SectorCode = p.IASectorCode, ActivityCode = p.IAActivityCode, SubActivityCode = p.IASubActivityCode, PollutantCode = p.PollutantCode })
                                                              .Select(x => new ActivityTreeListRow(
                                                                          x.Key.SectorCode,
                                                                          x.Key.ActivityCode,
                                                                          !x.Key.SubActivityCode.Equals(null) ? x.Key.SubActivityCode : ActivityTreeListRow.CODE_UNSPECIFIED,
                                                                          x.Key.PollutantCode,
                                                                          x.Count(),
                                                                          x.Sum(p => p.Quantity),
                                                                          false));

            return(subactivities);
        }
Example #6
0
        /// <summary>
        /// return all activities (level 1) that fullfill search criteria within the sectorCodes given.
        /// If sectorCodes are null, all activities will be returned. If sectorCodes is empty no activities will be returned.
        /// </summary>
        public static IEnumerable <ActivityTreeListRow> GetActivities(PollutantTransfersSearchFilter filter, List <string> sectorCodes)
        {
            if (sectorCodes != null && sectorCodes.Count() == 0)
            {
                return(new List <ActivityTreeListRow>());
            }

            DataClassesPollutantTransferDataContext      db     = getPollutantTransferDataContext();
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getActivityAreaLambda(filter);

            if (sectorCodes != null)
            {
                ParameterExpression param     = lambda.Parameters[0];
                Expression          sectorExp = LinqExpressionBuilder.GetInExpr(param, "IASectorCode", sectorCodes);

                Expression exp = LinqExpressionBuilder.CombineAnd(lambda.Body, sectorExp);
                lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);
            }

            //find data for activity level
            IEnumerable <ActivityTreeListRow> activities = db.POLLUTANTTRANSFERs.Where(lambda)
                                                           .GroupBy(p => new { SectorCode = p.IASectorCode, ActivityCode = p.IAActivityCode, PollutantCode = p.PollutantCode })
                                                           .Select(x => new ActivityTreeListRow(
                                                                       x.Key.SectorCode,
                                                                       x.Key.ActivityCode,
                                                                       null,
                                                                       x.Key.PollutantCode,
                                                                       x.Count(),
                                                                       x.Sum(p => p.Quantity),
                                                                       x.First(p => !p.IASubActivityCode.Equals(null)) != null));

            return(activities);
        }
Example #7
0
        /// <summary>
        /// return all countries that fullfill search criteria
        /// </summary>
        public static IEnumerable <AreaTreeListRow> GetCountries(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext      db     = getPollutantTransferDataContext();
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getActivityAreaLambda(filter);


            //find data for country level. Country level always has children.
            IEnumerable <AreaTreeListRow> countries = db.POLLUTANTTRANSFERs.Where(lambda)
                                                      .GroupBy(p => new { CountryCode = p.CountryCode, PollutantCode = p.PollutantCode })
                                                      .Select(x => new AreaTreeListRow(
                                                                  x.Key.CountryCode,
                                                                  null,
                                                                  filter.AreaFilter.TypeRegion,
                                                                  x.Key.PollutantCode,
                                                                  x.Count(),
                                                                  x.Sum(p => p.Quantity),
                                                                  true));


            List <AreaTreeListRow> result = countries.ToList(); //make sure sql is executed now to do it only once

            List <AreaTreeListRow> totals = result.GroupBy(p => new { PollutantCode = p.PollutantCode })
                                            .Select(x => new AreaTreeListRow(
                                                        AreaTreeListRow.CODE_TOTAL,
                                                        null,
                                                        filter.AreaFilter.TypeRegion,
                                                        x.Key.PollutantCode,
                                                        x.Sum(p => p.Facilities),
                                                        x.Sum(p => p.Quantity),
                                                        false)).ToList();


            //only add total to result if more than one sector.
            if (result.Select(r => r.CountryCode).Distinct().Count() > 1)
            {
                result.AddRange(totals);
            }

            //find facility count
            int facilityCount = 0;

            if (result.Count == 1)
            {
                facilityCount = result.Single().Facilities;
            }
            else if (totals.Count == 1)
            {
                facilityCount = totals.Single().Facilities;
            }
            else
            {
                facilityCount = GetFacilityCount(filter);
            }

            filter.Count = facilityCount;

            return(result);
        }
Example #8
0
        public static Dictionary <string, string> GetPollutantTransferSearchHeader(
            PollutantTransfersSearchFilter filter,
            bool confidentialityAffected)
        {
            var header = GetPollutantTransferSearchHeader(filter);

            addConfidentiality(header, confidentialityAffected);
            return(header);
        }
Example #9
0
        /// <summary>
        /// get lambda for confidential pollutant transfers
        /// </summary>
        private static Expression <Func <POLLUTANTTRANSFER, bool> > getPollutantTransfersConfidentialLambda(DataClassesPollutantTransferDataContext db, IndustrialActivitySearchFilter filter, bool includePollutant)
        {
            ParameterExpression            param           = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            PollutantTransfersSearchFilter filterTransfers = FilterConverter.ConvertToPollutantTransfersSearchFilter(filter);
            Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filterTransfers, param, includePollutant);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            return(lambda);
        }
Example #10
0
        /// <summary>
        /// returns a dictionary with csv headers <key, value> for pollutant transfer search
        /// </summary>
        public static Dictionary <string, string> GetPollutantTransferSearchHeader(PollutantTransfersSearchFilter filter)
        {
            Dictionary <string, string> header = makeHeader();

            addPollutant(header, filter.PollutantFilter);
            addYear(header, filter.YearFilter);
            addArea(header, filter.AreaFilter);

            return(header);
        }
Example #11
0
    /// <summary>
    /// Search
    /// </summary>
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (InvokeSearch != null)
        {
            PollutantTransfersSearchFilter filter = PopulateFilter();

            // start the search
            InvokeSearch.Invoke(filter, e);
        }
    }
Example #12
0
        /// <summary>
        /// Find all reported pollutant codes fullfilling the filter
        /// </summary>
        public static List <string> GetPollutantCodes(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext      db     = getPollutantTransferDataContext();
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getActivityAreaLambda(filter);

            //distinct pollutants
            List <string> codes = db.POLLUTANTTRANSFERs.Where(lambda)
                                  .Select(r => r.PollutantCode).Distinct().ToList();

            return(codes);
        }
    /// <summary>
    /// Fill table according to filter
    /// </summary>
    public void Populate(PollutantTransfersSearchFilter filter)
    {
        SearchFilter = filter;
        List <PollutantTransfers.AreaTreeListRow> data = QueryLayer.PollutantTransfers.GetCountries(filter).ToList();

        sortResult(data);
        ViewState[RESULT] = data;

        this.lvPollutantTransfersAreas.DataSource = data;
        this.lvPollutantTransfersAreas.DataBind();
    }
    /// <summary>
    /// invoke pollutant search search for this row
    /// </summary>
    protected void onPollutantSearchClick(object sender, CommandEventArgs e)
    {
        // create pollutant search filter
        PollutantTransfersSearchFilter filter = FilterConverter.ConvertToPollutantTransfersSearchFilter(SearchFilter);

        // create pollutant filter
        filter.PollutantFilter = getPollutantFilter(e);

        // go to pollutant release
        LinkSearchRedirecter.ToPollutantTransfers(Response, filter);
    }
Example #15
0
        /// <summary>
        /// return true if confidentiality might effect result
        /// </summary>
        public static bool IsAffectedByConfidentiality(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();

            // apply filter for confidential, do not include the pollutant itself
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfersConfidential(filter, param, false);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            return(db.POLLUTANTTRANSFERs.Any(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();

        PollutantTransfersSearchFilter filter = sender as PollutantTransfersSearchFilter;

        if (filter != null)
        {
            updateJavaScriptMap(filter);
            this.ucPollutantTransfersSheet.Populate(filter);
        }
    }
Example #17
0
        /// <summary>
        /// returns a dictionary with sheet headers <key, value> for pollutant transfer search
        /// </summary>
        public static Dictionary <string, string> GetPollutantTransferSearchHeader(PollutantTransfersSearchFilter filter, bool includeFacilityCount)
        {
            Dictionary <string, string> header = new Dictionary <string, string>();

            addPollutant(header, filter.PollutantFilter);
            addYear(header, filter.YearFilter);
            addArea(header, filter.AreaFilter);
            if (includeFacilityCount)
            {
                addCount(header, filter.Count);
            }

            return(header);
        }
Example #18
0
        // ----------------------------------------------------------------------------------
        // Map filters
        // ----------------------------------------------------------------------------------
        #region Map

        /// <summary>
        /// returns the MapFilter (sql and layers) corresponding to the filter.
        /// </summary>
        public static MapFilter GetMapFilter(PollutantTransfersSearchFilter filter)
        {
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filter, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            // create sql and sectors to map
            MapFilter mapFilter = new MapFilter();

            mapFilter.SqlWhere = LinqExpressionBuilder.GetSQL(exp, param);
            mapFilter.SetLayers(filter.ActivityFilter);

            return(mapFilter);
        }
Example #19
0
        public static MapFilter GetMapJavascriptFilter(PollutantTransfersSearchFilter filter)
        {
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filter, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            // create sql and sectors to map
            MapFilter mapFilter = new MapFilter();

            mapFilter.SqlWhere = LinqExpressionBuilder.GetSQLJavascript(exp, param);
            mapFilter.SqlWhere = "FacilityReportID IN (select FacilityReportID from dbo.POLLUTANTTRANSFER where " + mapFilter.SqlWhere + ")";

            return(mapFilter);
        }
Example #20
0
        /// <summary>
        /// Generates facility list for Pollutant Transfer search results
        /// </summary>
        /// <param name="filter">Holds the search criteria</param>
        /// <param name="sortColumn">Specifies the column used for sorting</param>
        /// <param name="descending">Indicate whether sorting is descending</param>
        /// <param name="startRowIndex">Starting index for paging</param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static object FacilityList(PollutantTransfersSearchFilter filter, string sortColumn, bool descending, int startRowIndex, int pagingSize)
        {
            // add rows (pageing)
            List <PollutantTransfers.ResultFacility> result = new List <PollutantTransfers.ResultFacility>();

            for (int i = 0; i < startRowIndex; i++)
            {
                result.Add(null);
            }

            // create expression
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filter, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            // apply lambda
            IEnumerable <POLLUTANTTRANSFER> data = db.POLLUTANTTRANSFERs.Where(lambda).orderBy(sortColumn, descending);

            // set the number of found rows for this filter
            filter.Count = data.Count();
            data         = data.Skip(startRowIndex).Take(pagingSize);

            // default unit for Pollutant Transfers
            foreach (var v in data)
            {
                QuantityUnit unit = (v.UnitCode == QuantityUnit.Tonnes.ToString()) ? QuantityUnit.Tonnes : QuantityUnit.Kilo;
                result.Add(new PollutantTransfers.ResultFacility(
                               v.IAActivityCode,
                               v.FacilityName,
                               v.Quantity,
                               v.CountryCode,
                               v.FacilityReportID,
                               unit,
                               v.ConfidentialIndicatorFacility,
                               v.ConfidentialIndicator,
                               v.FacilityID));
            }

            // add rows (pageing)
            int addcount = result.Count;

            for (int i = 0; i < filter.Count - addcount; i++)
            {
                result.Add(null);
            }

            return(result);
        }
Example #21
0
        /// <summary>
        /// return full area tree with all rows expanded
        /// </summary>
        public static IEnumerable <AreaTreeListRow> GetAreaTree(PollutantTransfersSearchFilter filter)
        {
            IEnumerable <AreaTreeListRow> countries = GetCountries(filter).ToList();

            List <string> countryCodes             = countries.Where(p => p.HasChildren).Select(p => p.CountryCode).ToList();
            IEnumerable <AreaTreeListRow> subareas = GetSubAreas(filter, countryCodes).ToList();

            IEnumerable <AreaTreeListRow> result = countries.Union(subareas)
                                                   .OrderBy(x => AreaTreeListRow.CODE_TOTAL.Equals(x.CountryCode))
                                                   .ThenBy(x => x.CountryCode)
                                                   .ThenBy(x => AreaTreeListRow.CODE_UNKNOWN.Equals(x.RegionCode))
                                                   .ThenBy(x => x.RegionCode);

            return(result);
        }
Example #22
0
    public PollutantTransfersSearchFilter PopulateFilter()
    {
        PollutantTransfersSearchFilter filter = new PollutantTransfersSearchFilter();

        filter.YearFilter      = this.ucYearSearchOption.PopulateFilter();
        filter.AreaFilter      = this.ucAreaSearchOption.PopulateFilter();
        filter.PollutantFilter = this.ucPollutantSearchOption.PopulateFilter();
        filter.ActivityFilter  = this.ucAdvancedActivitySearchOption.PopulateFilter();

        // store settings in cookies
        CookieStorage.SetFilter(Response, filter.AreaFilter);
        CookieStorage.SetFilter(Response, filter.YearFilter);

        return(filter);
    }
Example #23
0
        /// <summary>
        /// Returns the number of facilities corresponding to the filter. Always use POLLUTANTTRANSFER table, since it has the fewest records.
        /// </summary>
        public static int GetFacilityCount(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filter, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            //find total no. of facilities.
            int count = db.POLLUTANTTRANSFERs
                        .Where(lambda)
                        .Select <POLLUTANTTRANSFER, int>(d => (int)d.FacilityReportID).Distinct()
                        .Count();

            return(count);
        }
Example #24
0
    /// <summary>
    /// populate and sort
    /// </summary>
    private void populateList(PollutantTransfersSearchFilter filter, string sortColumn)
    {
        int startRowIndex = PageIndex;

        bool descending = ViewState[sortColumn] != null && (bool)ViewState[sortColumn];

        this.lvFacilityResult.DataSource = QueryLayer.PollutantTransfers.FacilityList(filter, sortColumn, descending, startRowIndex, getPageSize());
        this.lvFacilityResult.DataBind();

        // save current sort column (to be used in pageing)
        ViewState["sortcolumn"] = sortColumn;

        if (ContentChanged != null)
        {
            ContentChanged.Invoke(null, EventArgs.Empty);
        }
    }
Example #25
0
    /// <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.HasPollutantTransferSearchFilter(Request))
            {
                PollutantTransfersSearchFilter filter = this.ucSearchOptions.PopulateFilter();
                doSearch(filter, EventArgs.Empty);
            }
        }

        // When load completed, perserve scroll position
        ScriptManager.RegisterStartupScript(Page, typeof(string), this.UniqueID, "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(SetScroll);", true);
    }
Example #26
0
        /// <summary>
        /// return full activity tree with all rows expanded
        /// </summary>
        public static IEnumerable <ActivityTreeListRow> GetActivityTree(PollutantTransfersSearchFilter filter)
        {
            IEnumerable <ActivityTreeListRow> sectors = GetSectors(filter).ToList();

            List <string> sectorCodes = sectors.Where(p => p.HasChildren).Select(p => p.SectorCode).ToList();
            IEnumerable <ActivityTreeListRow> activities = GetActivities(filter, sectorCodes).ToList();

            List <string> activityCodes = activities.Where(p => p.HasChildren).Select(p => p.ActivityCode).ToList();
            IEnumerable <ActivityTreeListRow> subactivities = GetSubActivities(filter, activityCodes).ToList();

            //create result with full tree
            IEnumerable <ActivityTreeListRow> result = sectors.Union(activities).Union(subactivities)
                                                       .OrderBy(s => s.SectorCode)
                                                       .ThenBy(s => s.ActivityCode)
                                                       .ThenBy(s => s.SubactivityCode);

            return(result);
        }
Example #27
0
    public void DoSaveCSV(object sender, EventArgs e)
    {
        try
        {
            CultureInfo  csvCulture = CultureResolver.ResolveCsvCulture(Request);
            CSVFormatter csvformat  = new CSVFormatter(csvCulture);

            // Create Header
            PollutantTransfersSearchFilter filter = SearchFilter;

            bool isConfidentialityAffected = PollutantTransfers.IsAffectedByConfidentiality(filter);

            Dictionary <string, string> header = EPRTR.HeaderBuilders.CsvHeaderBuilder.GetPollutantTransferSearchHeader(
                filter,
                isConfidentialityAffected);

            // Create Body
            var facilities = PollutantTransfers.GetFacilityListCSV(filter);

            // dump to file
            string topheader      = csvformat.CreateHeader(header);
            string facilityHeader = csvformat.GetPollutantTranfersFacilityHeader();

            string url = Request.Url.AbsoluteUri;
            url = url.Substring(0, url.LastIndexOf("/") + 1);

            Response.WriteUtf8FileHeader("EPRTR_Pollutant_Transfers_Facility_List");

            Response.Write(topheader + facilityHeader);

            foreach (var item in facilities)
            {
                item.Url = String.Format("{0}/PopupFacilityDetails.aspx?FacilityReportId={1}", url, item.FacilityReportId);

                string row = csvformat.GetPollutantTransfersFacilityRow(item);
                Response.Write(row);
            }

            Response.End();
        }
        catch
        {
        }
    }
Example #28
0
        public static IEnumerable <IATransfersTreeListRow> GetPollutantTransfers(IndustrialActivitySearchFilter filter)
        {
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");

            PollutantTransfersSearchFilter filterTransfer = FilterConverter.ConvertToPollutantTransfersSearchFilter(filter);

            filterTransfer.ActivityFilter = filter.ActivityFilter;
            filterTransfer.AreaFilter     = filter.AreaFilter;
            filterTransfer.YearFilter     = filter.YearFilter;
            Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filterTransfer, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);

            int facilitiesCount = 0;
            List <IATransfersTreeListRow> pollutants = getTransfers(db, lambda, out facilitiesCount).ToList <IATransfersTreeListRow>();

            filter.Count = facilitiesCount;
            return(pollutants);
        }
Example #29
0
        // ----------------------------------------------------------------------------------
        // Summery
        // ----------------------------------------------------------------------------------
        #region summery

        /// <summary>
        /// Summery
        /// </summary>
        public static List <Summary.Quantity> Summery(PollutantTransfersSearchFilter filter)
        {
            DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext();

            // apply filter
            ParameterExpression param = Expression.Parameter(typeof(POLLUTANTTRANSFER), "s");
            Expression          exp   = LinqExpressionBuilder.GetLinqExpressionPollutantTransfers(filter, param);
            Expression <Func <POLLUTANTTRANSFER, bool> > lambda = Expression.Lambda <Func <POLLUTANTTRANSFER, bool> >(exp, param);
            var summeryFiltered = db.POLLUTANTTRANSFERs.Where(lambda);

            var summery0 = from s in summeryFiltered select new { s.IAActivityCode, s.Quantity };
            var summery1 = from s in summery0 group s by new { s.IAActivityCode };
            var summery2 = from s in summery1
                           select new
            {
                code        = s.Select(x => x.IAActivityCode).First(),
                count       = s.Count(),
                sumQuantity = s.Sum(x => x.Quantity)
            };

            double total = 0;

            filter.Count = 0;

            List <Summary.Quantity> final = new List <Summary.Quantity>();

            foreach (var v in summery2)
            {
                if (v.sumQuantity > 0)
                {
                    final.Add(new Summary.Quantity(v.code, v.sumQuantity));
                    total        += v.sumQuantity;
                    filter.Count += v.count;
                }
            }

            // Get top 10 list, sorted by quantity
            final = Summary.GetTop10(final, total);
            return(final);
        }
    public void Populate(PollutantTransfersSearchFilter filter)
    {
        List <PollutantTransfers.AreaComparison> compareList = PollutantTransfers.GetAreaComparison(filter);
        string title = string.Empty;

        // Translate area codes
        translateArea(filter.AreaFilter, compareList);

        // update flash
        int compareListCount = compareList.Count;

        if (compareListCount != 0)
        {
            string swfFile = EPRTR.Charts.ChartsUtils.PolluntantTransferAreaComparisonChart;
            EPRTR.Charts.ChartsUtils.ChartClientScript(swfFile, title, compareList, this.compareChartPanel, this.UniqueID.ToString(), EPRTR.Charts.ChartsUtils.AreaType.Air, compareListCount);
        }
        else
        {
            //show no data control
            this.NoDataReturned.Visible = true;
        }
    }