コード例 #1
0
    /// <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
        {
        }
    }