/// <summary> /// return true if confidentiality might effect pollutant transfer result /// </summary> public static bool IsPollutantTransferAffectedByConfidentiality(IndustrialActivitySearchFilter filter) { DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext(); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getPollutantTransfersConfidentialLambda(db, filter, false); return(db.POLLUTANTTRANSFERs.Any(lambda)); }
/// <summary> /// return true if confidentiality might effect pollutant release result /// </summary> public static bool IsPollutantReleaseAffectedByConfidentiality(IndustrialActivitySearchFilter filter) { DataClassesPollutantReleaseDataContext db = getPollutantReleaseDataContext(); Expression <Func <POLLUTANTRELEASE, bool> > lambda = getPollutantReleasesConfidentialLambda(db, filter, false); return(db.POLLUTANTRELEASEs.Any(lambda)); }
public double IndustrialActivityTestA() { DateTime testStartTime; DateTime testEndTime; TimeSpan testDelta; IndustrialActivitySearchFilter filter = new IndustrialActivitySearchFilter(); filter.ActivityFilter = new ActivityFilter(); filter.ActivityFilter.SectorIds.Add(-1); filter.ActivityFilter.ActivityIds.Add(-1); filter.ActivityFilter.SubActivityIds.Add(-1); filter.AreaFilter = new AreaFilter(); filter.AreaFilter.AreaGroupID = 1; filter.AreaFilter.CountryID = -1; filter.AreaFilter.RegionID = -1; filter.MapFilter = new MapFilter(); filter.MapFilter.SqlWhere = "(((ReportingYear) = 2007) And ((((((((((((((((((((((((((((((((LOV_CountryID) = 15) Or ((LOV_CountryID) = 22)) Or ((LOV_CountryID) = 34)) Or ((LOV_CountryID) = 57)) Or ((LOV_CountryID) = 58)) Or ((LOV_CountryID) = 59)) Or ((LOV_CountryID) = 68)) Or ((LOV_CountryID) = 73)) Or ((LOV_CountryID) = 74)) Or ((LOV_CountryID) = 81)) Or ((LOV_CountryID) = 85)) Or ((LOV_CountryID) = 100)) Or ((LOV_CountryID) = 101)) Or ((LOV_CountryID) = 106)) Or ((LOV_CountryID) = 109)) Or ((LOV_CountryID) = 122)) Or ((LOV_CountryID) = 127)) Or ((LOV_CountryID) = 128)) Or ((LOV_CountryID) = 129)) Or ((LOV_CountryID) = 137)) Or ((LOV_CountryID) = 156)) Or ((LOV_CountryID) = 166)) Or ((LOV_CountryID) = 177)) Or ((LOV_CountryID) = 178)) Or ((LOV_CountryID) = 182)) Or ((LOV_CountryID) = 201)) Or ((LOV_CountryID) = 202)) Or ((LOV_CountryID) = 207)) Or ((LOV_CountryID) = 213)) Or ((LOV_CountryID) = 214)) Or ((LOV_CountryID) = 234)))"; filter.YearFilter = new YearFilter(); filter.YearFilter.Year = 2007; testStartTime = DateTime.Now; IEnumerable <PollutantReleases.ReleasesActivityAreaRow> actual = IndustrialActivity.GetPollutantReleases(filter); testEndTime = DateTime.Now; testDelta = testEndTime - testStartTime; return(testDelta.TotalSeconds); }
/// <summary> /// Populate the listview with confidential data /// </summary> public void Populate(IndustrialActivitySearchFilter filter, bool hasConfidentialInformation) { if (hasConfidentialInformation) { this.lbReleasesConfDesc.Text = CMSTextCache.CMSText("Pollutant", "ConfReleaseDesc"); this.lbTransferConfDesc.Text = CMSTextCache.CMSText("Pollutant", "ConfTransfersDesc"); this.lbWasteConfDesc.Text = CMSTextCache.CMSText("WasteTransfers", "ConfWasteDesc"); // Check one radio button this.rbReleaseGroup.Items.Clear(); this.rbReleaseGroup.Items.Add(new ListItem(Resources.GetGlobal("Common", "ContentPollutantReleases"), "releases")); this.rbReleaseGroup.Items.Add(new ListItem(Resources.GetGlobal("Common", "ContentPollutantTransfers"), "transfers")); this.rbReleaseGroup.Items.Add(new ListItem(Resources.GetGlobal("Common", "ContentWastetransfers"), "waste")); // Select first element this.rbReleaseGroup.Items[0].Selected = true; string value = this.rbReleaseGroup.SelectedValue; ViewState[RELEASES_FACILITIES] = null; ViewState[TRANSFER_FACILITIES] = null; SearchFilter = filter; updateSheet(value); } else { hideAllControls(); } rbReleaseGroup.Visible = hasConfidentialInformation; divNoConfidentialityInformation.Visible = !hasConfidentialInformation; }
public double IndustrialActivityTestE() { DateTime testStartTime; DateTime testEndTime; TimeSpan testDelta; IndustrialActivitySearchFilter filter = new IndustrialActivitySearchFilter(); filter.ActivityFilter = new ActivityFilter(); filter.ActivityFilter.SectorIds.Add(3); filter.ActivityFilter.ActivityIds.Add(26); filter.ActivityFilter.SubActivityIds.Add(-1); filter.AreaFilter = new AreaFilter(); filter.AreaFilter.AreaGroupID = 1; filter.AreaFilter.CountryID = 74; filter.AreaFilter.RegionID = -1; filter.MapFilter = new MapFilter(); filter.MapFilter.SqlWhere = "((((ReportingYear) = 2007) And (LOV_CountryID = 74)) And ((LOV_IAActivityID) = 26))"; filter.YearFilter = new YearFilter(); filter.YearFilter.Year = 2007; testStartTime = DateTime.Now; IEnumerable <PollutantReleases.ReleasesActivityAreaRow> actual = IndustrialActivity.GetPollutantReleases(filter); testEndTime = DateTime.Now; testDelta = testEndTime - testStartTime; return(testDelta.TotalSeconds); }
/// <summary> /// create header /// </summary> /// <param name="countTotal">The total number of facilities fullfilling the search critieria</param> /// <param name="countSheet">The number of facilites fullfilling the search criteria for the selected sheet (e.g. Pollutant releases)</param> private void updateHeader(IndustrialActivitySearchFilter filter, int countTotal, int countSheet, bool includeFacilityCount, string text) { Dictionary <string, string> header = SheetHeaderBuilder.GetIndustrialActivitySearchHeader(filter, countTotal, countSheet); this.ucSheetSubHeader.PopulateHeader(header); this.ucSheetSubHeader.Text = text; }
public void DoSaveCSV(object sender, EventArgs e) { CultureInfo csvCulture = CultureResolver.ResolveCsvCulture(Request); CSVFormatter csvformat = new CSVFormatter(csvCulture); // Create Header IndustrialActivitySearchFilter filter = SearchFilter; bool isConfidentialityAffected = IndustrialActivity.IsWasteAffectedByConfidentiality(filter); Dictionary <string, string> header = EPRTR.HeaderBuilders.CsvHeaderBuilder.GetIndustrialActivitySearchHeader( filter, isConfidentialityAffected); // Create Body var rows = IndustrialActivity.GetWasteTransfers(filter); // dump to file string topheader = csvformat.CreateHeader(header); string rowHeader = csvformat.GetIndustrialActivityWasteTransfersHeader(); Response.WriteUtf8FileHeader("EPRTR_Industrial_Activity_Waste_Transfer_List"); Response.Write(topheader + rowHeader); foreach (var item in rows) { string row = csvformat.GetIndustrialActivityWasteTransfersRow(item); Response.Write(row); } Response.End(); }
/// <summary> /// returns a dictionary with sheet headers <key, value> for Industrial activity search. Will include the number of facilites /// </summary> /// <param name="countTotal">The total number of facilities fullfilling the search critieria</param> /// <param name="countSheet">The number of facilites fullfilling the search criteria for the selected sheet (e.g. Pollutant releases)</param> public static Dictionary <string, string> GetIndustrialActivitySearchHeader(IndustrialActivitySearchFilter filter, int countTotal, int countSheet) { Dictionary <string, string> header = GetIndustrialActivitySearchHeader(filter); addCount(header, countTotal, countSheet); return(header); }
/// <summary> /// returns a dictionary with sheet headers <key, value> for Industrial activity search /// </summary> public static Dictionary <string, string> GetIndustrialActivitySearchHeader( IndustrialActivitySearchFilter filter, bool confidentialityAffected) { var header = GetIndustrialActivitySearchHeader(filter); addConfidentiality(header, confidentialityAffected); return(header); }
/// <summary> /// invoke activity search /// </summary> protected void onActivitySearchClick(object sender, CommandEventArgs e) { // create activity filter IndustrialActivitySearchFilter filter = FilterConverter.ConvertToIndustrialActivitySearchFilter(SearchFilter); // Change activity filter filter.ActivityFilter = getActivityFilter(e); LinkSearchRedirecter.ToIndustrialActivity(Response, filter, Sheets.IndustrialActivity.PollutantTransfers); }
/// <summary> /// returns a dictionary with sheet headers <key, value> for Industrial activity search. Will not include the number of facilities. /// </summary> public static Dictionary <string, string> GetIndustrialActivitySearchHeader(IndustrialActivitySearchFilter filter) { Dictionary <string, string> header = new Dictionary <string, string>(); addYear(header, filter.YearFilter); addArea(header, filter.AreaFilter); addActivity(header, filter.ActivityFilter); return(header); }
/// <summary> /// Search /// </summary> protected void btnSearch_Click(object sender, EventArgs e) { if (InvokeSearch != null) { IndustrialActivitySearchFilter filter = PopulateFilter(); // start the search InvokeSearch.Invoke(filter, e); } }
public static MapFilter GetMapJavascriptFilter(IndustrialActivitySearchFilter filter) { ParameterExpression param = Expression.Parameter(typeof(FACILITYSEARCH_MAINACTIVITY), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionIndustrialActivitySearch(filter, param); Expression <Func <FACILITYSEARCH_MAINACTIVITY, bool> > lambda = Expression.Lambda <Func <FACILITYSEARCH_MAINACTIVITY, bool> >(exp, param); // create sql and sectors to map MapFilter mapFilter = new MapFilter(); mapFilter.SqlWhere = LinqExpressionBuilder.GetSQL(exp, param); return(mapFilter); }
/// <summary> /// Search, fill data into summery /// </summary> public void Populate(IndustrialActivitySearchFilter filter) { SearchFilter = filter; // clear confidentiality viewstate flags PollutantReleaseConfidentialityAffected = null; PollutantTransferConfidentialityAffected = null; WasteTransferConfidentialityAffected = null; TotalCount = null; // default show pollutant releases showContent(getDefaultContent()); }
/// <summary> /// method to populate the listview /// </summary> /// <param name="filter">The filter.</param> public void Populate(IndustrialActivitySearchFilter filter) { SearchFilter = filter; this.lvIndustrialWasteTransfers.Items.Clear(); IEnumerable <Summary.WasteSummaryTreeListRow> data = IndustrialActivity.GetWasteTransfers(filter); this.lvIndustrialWasteTransfers.DataSource = data; this.lvIndustrialWasteTransfers.DataBind(); ChartsUtils.ShowWastePieCharts(data, this.upindustrialWasteSummeryPanel, this.UniqueID.ToString()); }
public IndustrialActivitySearchFilter PopulateFilter() { IndustrialActivitySearchFilter filter = new IndustrialActivitySearchFilter(); filter.AreaFilter = this.ucAreaSearchOption.PopulateFilter(); filter.YearFilter = this.ucYearSearchOption.PopulateFilter(); filter.ActivityFilter = this.ucActivitySearchOption.PopulateFilter(); // store settings in cookies CookieStorage.SetFilter(Response, filter.AreaFilter); CookieStorage.SetFilter(Response, filter.YearFilter); return(filter); }
/// <summary> /// Returns the number of facilities corresponding to the filter. Always use FACILITY_MAIN table, since it has the fewest records. /// </summary> public static int GetFacilityCount(IndustrialActivitySearchFilter filter) { DataClassesFacilityDataContext db = getFacilityDataContext(); ParameterExpression param = Expression.Parameter(typeof(FACILITYSEARCH_MAINACTIVITY), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionIndustrialActivitySearch(filter, param); Expression <Func <FACILITYSEARCH_MAINACTIVITY, bool> > lambda = Expression.Lambda <Func <FACILITYSEARCH_MAINACTIVITY, bool> >(exp, param); //find total no. of facilities. Table only have one record per facility, so distinct is not needed. int count = db.FACILITYSEARCH_MAINACTIVITies .Where(lambda) .Count(); return(count); }
/// <summary> /// returns the MapFilter (sql and layers) corresponding to the filter. /// </summary> public static MapFilter GetMapFilter(IndustrialActivitySearchFilter filter) { DataClassesFacilityDataContext db = getFacilityDataContext(); ParameterExpression param = Expression.Parameter(typeof(FACILITYSEARCH_MAINACTIVITY), "s"); Expression exp = LinqExpressionBuilder.GetLinqExpressionIndustrialActivitySearch(filter, param); Expression <Func <FACILITYSEARCH_MAINACTIVITY, bool> > lambda = Expression.Lambda <Func <FACILITYSEARCH_MAINACTIVITY, 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); }
/// <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(); IndustrialActivitySearchFilter filter = sender as IndustrialActivitySearchFilter; if (filter != null) { // call javascript map_small updateJavaScriptMap(filter); this.ucIndustrialActivitySheet.Populate(filter); //updateFlashMap(filter); } }
/// <summary> /// return total list of areas /// </summary> public static IEnumerable <IAReleasesTreeListRow> GetPollutantReleases(IndustrialActivitySearchFilter filter) { DataClassesPollutantReleaseDataContext db = getPollutantReleaseDataContext(); ParameterExpression param = Expression.Parameter(typeof(POLLUTANTRELEASE), "s"); PollutantReleaseSearchFilter filterRelease = FilterConverter.ConvertToPollutantReleaseSearchFilter(filter); Expression exp = LinqExpressionBuilder.GetLinqExpressionPollutantReleases(filterRelease, param); Expression <Func <POLLUTANTRELEASE, bool> > lambda = Expression.Lambda <Func <POLLUTANTRELEASE, bool> >(exp, param); int facilitiesCount = 0; List <IAReleasesTreeListRow> pollutants = getReleases(db, lambda, out facilitiesCount).ToList <IAReleasesTreeListRow>(); filter.Count = facilitiesCount; return(pollutants); }
/// <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.HasIndustrialActivitySearchFilter(Request)) { IndustrialActivitySearchFilter 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); }
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); }
// -------------------------------------------------------------------------------------------------------------------- // Industrial Activity Filter // -------------------------------------------------------------------------------------------------------------------- #region IndustrialActivitySearchFilter public static string SerializeToUrl(IndustrialActivitySearchFilter filter) { string result = String.Empty; if (filter != null) { // Area result += SerializeToUrl(filter.AreaFilter); // Year result += SerializeToUrl(filter.YearFilter); // Activity result += SerializeToUrl(filter.ActivityFilter); } result = result.Remove(result.Length - 1); return(result); }
private void showContent(string command) { hideSubControls(); this.ucSheetLinks.HighLight(command); string txt = string.Empty; bool includeFacilityCount = true; IndustrialActivitySearchFilter filter = SearchFilter; string alert = string.Empty; int countTotal = getTotalCount(); // activate print this.ucDownloadPrint.Visible = true; this.ucDownloadPrint.SetPrintControl(this); if (command.Equals(Sheets.IndustrialActivity.PollutantReleases.ToString())) { this.litHeadline.Text = Resources.GetGlobal("IndustrialActivity", "IndustrialActivityPollutantReleases"); this.ucIndustrialActivityPollutantReleases.Visible = true; this.ucIndustrialActivityPollutantReleases.Populate(filter); txt = Resources.GetGlobal("Pollutant", "AllValuesAreYearlyReleases"); bool prConf = getPollutantReleaseConfidentialityAffected(); alert = prConf ? Resources.GetGlobal("Common", "ConfidentialityAlertLink") : string.Empty; this.ucDownloadPrint.Show(true, true); Sheet = Sheets.IndustrialActivity.PollutantReleases; } else if (command.Equals(Sheets.IndustrialActivity.PollutantTransfers.ToString())) { this.litHeadline.Text = Resources.GetGlobal("IndustrialActivity", "IndustrialActivityPollutantTransfers"); this.ucIndustrialActivityPollutantTransfers.Visible = true; this.ucIndustrialActivityPollutantTransfers.Populate(filter); txt = Resources.GetGlobal("Pollutant", "AllValuesAreYearlyTransfers"); bool ptConf = getPollutantTransferConfidentialityAffected(); alert = ptConf ? Resources.GetGlobal("Common", "ConfidentialityAlertLink") : string.Empty; this.ucDownloadPrint.Show(true, true); Sheet = Sheets.IndustrialActivity.PollutantTransfers; } else if (command.Equals(Sheets.IndustrialActivity.WasteTransfers.ToString())) { this.litHeadline.Text = Resources.GetGlobal("IndustrialActivity", "IndustrialActivityWasteTransfers"); this.ucIndustrialActivityWasteTransfer.Visible = true; this.ucIndustrialActivityWasteTransfer.Populate(filter); txt = Resources.GetGlobal("WasteTransfers", "AllValuesAreYearlyTransfers"); bool wtConf = getWasteTransferConfidentialityAffected(); alert = wtConf ? Resources.GetGlobal("Common", "ConfidentialityAlertLink") : string.Empty; this.ucDownloadPrint.Show(true, true); Sheet = Sheets.IndustrialActivity.WasteTransfers; } else if (command.Equals(Sheets.IndustrialActivity.Confidentiality.ToString())) { this.litHeadline.Text = Resources.GetGlobal("IndustrialActivity", "IndustrialActivityConfidential"); this.ucIndustrialActivityConfidentiality.Visible = true; includeFacilityCount = false; bool conf = getAnyConfidentialityAffected(); alert = conf ? Resources.GetGlobal("Common", "ConfidentialityAlert") : string.Empty; this.ucIndustrialActivityConfidentiality.Populate(filter, conf); this.ucDownloadPrint.Show(false, true); Sheet = Sheets.IndustrialActivity.Confidentiality; } updateHeader(filter, countTotal, filter.Count, includeFacilityCount, txt); updateAlert(alert); }
/// <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); }
/// <summary> /// Get list for confidential transfers /// </summary> public static IEnumerable <ConfidentialTransfersRow> GetConfidentialTransfersFacility(IndustrialActivitySearchFilter filter) { DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext(); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getPollutantTransfersLambda(db, filter); var pollutantAll = db.POLLUTANTTRANSFERs.Where(lambda); var pollutantConfidential = from c in pollutantAll where (c.ConfidentialIndicator != null && c.ConfidentialIndicator == true) select c; // get list of confidential var conf1 = from p in pollutantConfidential group p by new { p.PollutantGroupCode }; var conf2 = from p in conf1 select new { pollutantGroup = p.Select(x => x.PollutantGroupCode).First(), facilities = p.Count(x => x.Quantity != null && x.Quantity >= 0), }; // get list of not confidential (all) var all1 = from p in pollutantAll group p by new { p.PollutantGroupCode }; var all2 = from p in all1 select new { pollutantGroup = p.Select(x => x.PollutantGroupCode).First(), facilities = p.Count(x => x.Quantity != null && x.Quantity >= 0), }; // merge results List <ConfidentialTransfersRow> final = new List <ConfidentialTransfersRow>(); foreach (var v1 in conf2) { foreach (var v2 in all2) { if (v1.pollutantGroup.Equals(v2.pollutantGroup)) { ConfidentialTransfersRow cr = new ConfidentialTransfersRow(v1.pollutantGroup); cr.FacilitiesConfidential = v1.facilities; // set confidential cr.Facilities = v2.facilities; // set not confidential (all) final.Add(cr); break; } } } return(final); //var pollutantConfOn = from c in pollutantConfAll where (c.ConfidentialIndicator != null && c.ConfidentialIndicator == true) select c; //var pollutantConfOff = from c in pollutantConfAll where c.ConfidentialIndicator == false select c; // select distinct list of pollutnat codes /*IEnumerable<string> pollutantcodes = (from p in pollutantConfAll select p.PollutantGroupCode).Distinct(); * * // loop through all pollutants * List<ConfidentialTransfersRow> final = new List<ConfidentialTransfersRow>(); * foreach (string s in pollutantcodes) * { * ConfidentialTransfersRow ct = new ConfidentialTransfersRow(s); * ct.FacilitiesConfidential = (from c in pollutantConfOn where c.PollutantGroupCode == s && c.Quantity != null select c).Count(); * ct.Facilities = (from c in pollutantConfOff where c.PollutantGroupCode == s && c.Quantity != null select c).Count(); * // add confidential to the total count of facilities * ct.Facilities += ct.FacilitiesConfidential; * final.Add(ct); * } * * return final; */ }
/// <summary> /// Waste reason facilities wrapper /// </summary> public static IEnumerable <WasteTransfers.WasteConfidentialReason> GetWasteConfidentialReason(IndustrialActivitySearchFilter filter) { WasteTransferSearchFilter filterWaste = FilterConverter.ConvertToWasteTransferSearchFilter(filter); return(WasteTransfers.GetWasteConfidentialReason(filterWaste)); }
/// <summary> /// Waste confidential facilities wrapper /// </summary> public static List <WasteTransfers.FacilityCountObject> GetWasteConfidentialFacilities(IndustrialActivitySearchFilter filter) { WasteTransferSearchFilter filterWaste = FilterConverter.ConvertToWasteTransferSearchFilter(filter); return(WasteTransfers.GetCountConfidentialFacilities(filterWaste)); }
/// <summary> /// Gets Confidential Transfers Reason /// </summary> /// <param name="filter"></param> /// <returns>IEnumerable<ConfidentialTransfersRow></returns> public static IEnumerable <ConfidentialTransfersRow> GetConfidentialTransfersReason(IndustrialActivitySearchFilter filter) { DataClassesPollutantTransferDataContext db = getPollutantTransferDataContext(); Expression <Func <POLLUTANTTRANSFER, bool> > lambda = getPollutantTransfersLambda(db, filter); //reason = ConfidentialityID var pollutantBase = db.POLLUTANTTRANSFERs.Where(lambda); var pollutantConf = from c in pollutantBase where (c.ConfidentialIndicator != null && c.ConfidentialIndicator == true) select c; // select distinct list of pollutnat codes IEnumerable <string> pollutantGroupCodes = (from p in pollutantConf select p.PollutantGroupCode).Distinct(); // final result List <ConfidentialTransfersRow> finaltmp = new List <ConfidentialTransfersRow>(); // Air count facilities var air1 = from p in pollutantConf where (p.ConfidentialCode != null) group p by new { p.PollutantGroupCode, p.ConfidentialCode }; var air2 = from p in air1 select new { pollutantGroupCode = p.Select(x => x.PollutantGroupCode).First(), reason = p.Select(x => x.ConfidentialCode).First(), facilities = p.Count(x => x.Quantity != null && x.Quantity >= 0) }; foreach (var v in air2) { finaltmp.Add(new ConfidentialTransfersRow(v.pollutantGroupCode, v.reason, v.facilities)); } List <ConfidentialTransfersRow> final = new List <ConfidentialTransfersRow>(); var finalOrdered = finaltmp.OrderBy(x => x.PollutantCode); string headCode = String.Empty; foreach (var v in finalOrdered) { if (v.PollutantCode != headCode) { headCode = v.PollutantCode; } else { v.PollutantCode = String.Empty; } final.Add(v); } return(final); }
/// <summary> /// return true if confidentiality might effect waste result /// </summary> public static bool IsWasteAffectedByConfidentiality(IndustrialActivitySearchFilter filter) { WasteTransferSearchFilter filterWaste = FilterConverter.ConvertToWasteTransferSearchFilter(filter); return(WasteTransfers.IsAffectedByConfidentiality(filterWaste)); }