public static string GetAreaName(this TreeListRow row, AreaFilter areaFilter) { switch (row.Level) { case 0: //country return(LOVResources.CountryName(row.Code)); case 1: //River absin district or NUTS { AreaFilter.RegionType type = areaFilter.TypeRegion; if (type == AreaFilter.RegionType.RiverBasinDistrict) { return(LOVResources.RiverBasinDistrictName(row.Code)); } else { return(LOVResources.NutsRegionName(row.Code)); } } default: return(string.Empty); } }
/// <summary> /// Save /// </summary> /// public void DoSaveCSV(object sender, EventArgs e) { try { CultureInfo csvCulture = CultureResolver.ResolveCsvCulture(Request); CSVFormatter csvformat = new CSVFormatter(csvCulture); // Create Header FacilitySearchFilter filter = SearchFilter; bool isConfidentialityAffected = Facility.IsAffectedByConfidentiality(filter); Dictionary <string, string> header = CsvHeaderBuilder.GetFacilitySearchHeader( filter, isConfidentialityAffected); // Create Body List <Facility.FacilityCSV> facilities = Facility.GetFacilityListCSV(filter); // dump to file string topheader = csvformat.CreateHeader(header).Replace("E-PRTR", "EPER"); string facilityHeader = csvformat.GetFacilityHeader(); string url = Request.Url.AbsoluteUri; url = url.Substring(0, url.LastIndexOf("/") + 1); Response.WriteUtf8FileHeader("EPER_Facility_List"); Response.Write(topheader + facilityHeader); foreach (var v in facilities) { // translate codes v.ActivityName = LOVResources.AnnexIActivityName(v.ActivityCode); v.CountryName = LOVResources.CountryName(v.CountryCode); v.NutsRegionName = LOVResources.NutsRegionName(v.NutsRegionCode); v.RiverBasinName = LOVResources.RiverBasinDistrictName(v.RiverBasinCode); v.FacilityName = ConfidentialFormat.Format(v.FacilityName, v.Confidential); v.PostalCode = ConfidentialFormat.Format(v.PostalCode, v.Confidential); v.Address = ConfidentialFormat.Format(v.Address, v.Confidential); v.City = ConfidentialFormat.Format(v.City, v.Confidential); v.URL = String.Format("{0}/PopupFacilityDetails.aspx?FacilityReportId={1}", url, v.FacilityReportID); string row = csvformat.GetFacilityRow(v); Response.Write(row); } Response.End(); } catch { } }
//creates header for Area and adds to dictionary protected static void addArea(Dictionary <string, string> header, AreaFilter filter) { if (filter != null) { string key = Resources.GetGlobal("Common", "Area"); string value = string.Empty; AreaFilter.Level level = filter.SearchLevel(); if (level == AreaFilter.Level.AreaGroup) { string code = ListOfValues.GetAreaGroup((int)filter.AreaGroupID).Code; value = LOVResources.AreaGroupName(code); } else if (level == AreaFilter.Level.Country) { string code = ListOfValues.GetCountry((int)filter.CountryID).Code; value = LOVResources.CountryName(code); } else if (level == AreaFilter.Level.Region) { if (filter.TypeRegion == AreaFilter.RegionType.RiverBasinDistrict) { string code = ListOfValues.GetRiverBasinDistrict((int)filter.RegionID).Code; value = LOVResources.RiverBasinDistrictName(code); } else if (filter.TypeRegion == AreaFilter.RegionType.NUTSregion) { if (filter.RegionID != null) { string code = ListOfValues.GetNUTSRegion((int)filter.RegionID).Code; value = LOVResources.NutsRegionName(code); } else { value = LOVResources.NutsRegionName(TreeListRow.CODE_UNKNOWN); } } else { throw new InvalidOperationException(string.Format("Illgegal RegionType {0}", filter.TypeRegion)); } } header.Add(key, value); } }
// Translate if specific country selected private void translateArea(AreaFilter filter, List <PollutantTransfers.AreaComparison> compareList) { //dont translate countries, only regions (NUTS or RBD) if (filter.SearchLevel() != AreaFilter.Level.AreaGroup) { foreach (PollutantTransfers.AreaComparison cl in compareList) { if (filter.TypeRegion == AreaFilter.RegionType.RiverBasinDistrict) { cl.Area = LOVResources.RiverBasinDistrictName(cl.Area); //RiverBasinDistrictCode } else if (filter.TypeRegion == AreaFilter.RegionType.NUTSregion) { cl.Area = LOVResources.NutsRegionName(cl.Area); //NUTS code } } } }
private void populateNUTSRegions(int countryId) { this.cbRegion.Items.Add(new ListItem(Resources.GetGlobal("Common", "AllNUTRegions"), AreaFilter.AllRegionsInCountryID.ToString())); if (countryId > 0) { IEnumerable <LOV_NUTSREGION> regions = ListOfValues.NUTSRegions(countryId, 2); //only level 2 is shown regions.OrderBy(p => p.Code); List <ListItem> items = new List <ListItem>(); foreach (LOV_NUTSREGION r in regions) { items.Add(new ListItem(LOVResources.NutsRegionName(r.Code), r.LOV_NUTSRegionID.ToString())); } items.Sort(new ListItemComparer()); this.cbRegion.Items.AddRange(items.ToArray()); } setSelectedRegion(); }
/// <summary> /// Manual insertion of all facility level details into List, which is in turn bound to GridView /// </summary> private void populateDetails(int facilityReportId) { FACILITYDETAIL_DETAIL fac = Facility.GetFacilityDetails(facilityReportId).First(); FACILITYDETAIL_COMPETENTAUTHORITYPARTY authority = Facility.GetFacilityCompetentAuthority(facilityReportId).First(); List <FacilityDetailElement> elements = new List <FacilityDetailElement>(); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "FacilityDetailsTitle"), String.Empty, true)); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "ParentCompanyName"), ConfidentialFormat.Format(fac.ParentCompanyName, fac.ConfidentialIndicator))); // Take "Valid" string from FACILITY_DETAIL_DETAIL elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Coords"), CoordinateFormat.Format(fac.Coordinates, "VALID"))); //NUTS is voluntary. Only add if reported. if (!string.IsNullOrEmpty(fac.NUTSRegionSourceCode)) { //Add both reported and geo-coded value - if they differ. if (fac.NUTSRegionSourceCode != fac.NUTSRegionLevel2Code) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NUTSMap"), LOVResources.NutsRegionName(fac.NUTSRegionLevel2Code))); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NUTSReported"), LOVResources.NutsRegionName(fac.NUTSRegionSourceCode))); } else { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NUTS"), LOVResources.NutsRegionName(fac.NUTSRegionLevel2Code))); } } //Add both reported and geo-coded value - if they differ. if (fac.RiverBasinDistrictSourceCode != fac.RiverBasinDistrictCode) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "RBDMap"), LOVResources.RiverBasinDistrictName(fac.RiverBasinDistrictCode))); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "RBDReported"), LOVResources.RiverBasinDistrictName(fac.RiverBasinDistrictSourceCode))); } else { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "RBD"), LOVResources.RiverBasinDistrictName(fac.RiverBasinDistrictCode))); } //NACE code reported on sub-activity level, except for EPER where some is reported on Activity level //string naceCode = !String.IsNullOrEmpty(fac.NACESubActivityCode) ? fac.NACESubActivityCode : fac.NACEActivityCode; string naceCode = !String.IsNullOrEmpty(fac.NACEActivityCode) ? fac.NACEActivityCode : fac.NACESectorCode; elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "NACE"), LOVResources.NaceActivityName(naceCode))); //Production volume is voluntary. Only add if reported. if (fac.ProductionVolumeQuantity != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "ProductionV"), String.Format("{0} {1} {2}", fac.ProductionVolumeProductName, NumberFormat.Format(fac.ProductionVolumeQuantity), LOVResources.UnitName(fac.ProductionVolumeUnitCode)))); } //No. of IPPC installations is voluntary. Only add if reported. if (fac.TotalIPPCInstallationQuantity != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "IPPC"), NumberFormat.Format(fac.TotalIPPCInstallationQuantity))); } //No. of emplyees is voluntary. Only add if reported. if (fac.TotalEmployeeQuantity != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Employ"), NumberFormat.Format(fac.TotalEmployeeQuantity))); } //Operating hours is voluntary. Only add if reported. if (fac.OperatingHours != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "OperationHours"), String.Format("{0}", fac.OperatingHours))); } //Website is voluntary. Only add if reported. if (!string.IsNullOrEmpty(fac.WebsiteCommunication)) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "WebSite"), String.Format("{0}", fac.WebsiteCommunication))); } if (fac.ConfidentialIndicatorCode != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Pollutant", "ConfidentialityReason"), LOVResources.ConfidentialityReason(fac.ConfidentialIndicatorCode))); } elements.Add(new FacilityDetailElement( Resources.GetGlobal("Common", "NationalID") + ":", FacilityDetailsFormat.FormatNationalId(fac))); // This is not the most elegant way to obtain a spacing spacing elements.Add(new FacilityDetailElement(String.Empty, String.Empty)); string updatedDateString = authority.CALastUpdate == null ? Resources.GetGlobal("Facility", "LastUpdatedUnknown") : authority.CALastUpdate.Format(); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "CompetentA"), String.Format(Resources.GetGlobal("Facility", "LastUpdated"), updatedDateString), true)); elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Name"), String.Format(authority.CAName))); if (authority.CAAddress != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Address"), AddressFormat.Format(authority.CAAddress, authority.CACity, authority.CAPostalCode, false))); } if (authority.CATelephoneCommunication != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Phone"), String.Format(authority.CATelephoneCommunication))); } if (authority.CAFaxCommunication != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Fax"), String.Format(authority.CAFaxCommunication))); } elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "Email"), String.Format(authority.CAEmailCommunication))); if (authority.CAContactPersonName != null) { elements.Add(new FacilityDetailElement( Resources.GetGlobal("Facility", "CPerson"), String.Format(authority.CAContactPersonName))); } // data binding facilityreportDetails.DataSource = elements; facilityreportDetails.DataBind(); }