Edit C:\Windows\install\galaxie_p01_01-10\marketing\population\person_mailing.jsp
<%@page import="com.edeal.frontline.navigation.FlRequest"%><% /****************************************************************************** * Copyright (c) 2000-2004 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. * * ******************************************************************************/ %><%@page session="true" import="com.edeal.frontline.*,java.util.*,java.sql.*"%><%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><% long beginTime = System.currentTimeMillis(); final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); DataDictionary dico = context.getDataDictionary(); String lineSep = (String)System.getProperty("line.separator"); String lineSepRN = String.valueOf((char)13) + String.valueOf((char)10); String lineSepNR = String.valueOf((char)10) + String.valueOf((char)13); String lineSepN = String.valueOf((char)10); String id = Utils.getRequestParameter(context, request, "id"); String defEncoding = context.getContextParameter("DefaultOutputEncoding"); if (defEncoding == null) { defEncoding = ""; } if(id == null) { id = (String)request.getAttribute("justSavedID"); } response.setHeader("Content-Disposition", "attachment;filename=ciblage.csv"); response.setHeader("Content-Type", "text/plain; charset=" + defEncoding); response.setHeader("Content-Encoding", defEncoding); String paramDelim = Utils.getRequestParameter(context, request, "delim"); String paramSeparator = Utils.getRequestParameter(context, request, "separator"); if (paramSeparator == null ) paramSeparator = flRequest.getRequestParameterOrAttribute("separator"); String modelID = Utils.getRequestParameter(context, request, "model"); boolean useTemplate = true; DocumentBean doc = new DocumentBean(modelID, context); Vector fields = new Vector(); Vector lib = new Vector(); try { String attID = doc.getDocAttID(); try { AttachmentBean att = new AttachmentBean(attID, context); byte[] file = att.getAttFile(); String fileStr = new String(file); // Test with all different possible line seps (win & linux) Vector template = Utils.explodeList(fileStr, lineSepRN); if (template.size() == 1) { template = Utils.explodeList(fileStr, lineSepNR); } if (template.size() == 1) { // We do this replace for the case where there really is only one item // If we didn't do this, the exploded list would return two Strings. // One proper, the other one with just '\n' or '\r' fileStr.replace('\r',' '); template = Utils.explodeList(fileStr, lineSepN); } if (template != null && !template.isEmpty()) { for (int i= 0; i < template.size(); i++) { String row = (String) template.elementAt(i); int index = row.indexOf("\t"); if (index > -1) { fields.addElement(row.substring(0, index)); if ((index + 1) < row.length()) { lib.addElement(row.substring(index + 1, row.length())); } else { lib.addElement(""); } } else { fields.addElement(row); lib.addElement(""); } } } } catch (FrontlineException e) { useTemplate = false; } catch (AccessDeniedException e) { useTemplate = false; } } catch (FieldNotInitializedException e) { useTemplate = false; } if (fields == null || fields.isEmpty()) { useTemplate = false; } if (useTemplate) { Hashtable forcedType = new Hashtable(); for(int i = 0 ; i<fields.size();i++){ if (((String) fields.elementAt(i)).contains(":")){ String fldname = (String)Utils.explodeList((String)fields.elementAt(i),":").firstElement(); FieldBean field1 = dico.getFieldByName(fldname); String currKey = (String)fields.elementAt(i); SqlField sqlF = new SqlField(session, context, currKey); FieldBean currField = dico.getFieldByName(sqlF.getField()); ObjectsBean currObject = dico.getTable("id", currField.getFldObjID()); if (fldname.startsWith("PpeFob")) { field1.setFldFobID(currObject.getObjID()); forcedType.put(fldname,field1); } } } String[] pFields = new String[fields.size()]; pFields = (String[])fields.toArray(pFields); String[][] pQuery = {{"PpePopID = " + Utils.formatToSQL(context, id)}, {"PpeRemoved = null", "PpeRemoved <> 1"}}; String[] pOrderBy = null; if (fields.contains("PpeEntID:EntZip")) { pOrderBy = new String[]{"PpeEntID:EntZip"}; } else if (fields.contains("PpePerID:PerEntID:EntZip")) { pOrderBy = new String[]{"PpePerID:PerEntID:EntZip"}; } else if (fields.contains("PpePerID:PerPerZip_")) { pOrderBy = new String[]{"PpePerID:PerPerZip_"}; } //SqlQuery sqlQuery = new SqlQuery(forcedType,context, "PopulationEntry", pFields, pQuery, pOrderBy, true); //String strQuery = sqlQuery.getSQL(); //Connection con = null; //Statement stmt = null; if (!lib.isEmpty()) { for (int i = 0; i < lib.size(); i++) { String data = (String)lib.elementAt(i); out.write(paramDelim + (data == null ? "" : Utils.replace(data, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); } out.write(lineSep); } try { //con = context.getConnection(); //stmt = con.createStatement(); //ResultSet rs = stmt.executeQuery(strQuery); //while (rs.next()) { // for (int i = 0; i < fields.size(); i++) { // String data = rs.getString(i + 1); // out.write(paramDelim + (data == null ? "" : Utils.replace(data, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); // } // out.write(lineSep); //} Vector vPpeEntries=PopulationEntryBean.listSummary(forcedType, session, context, "PopulationEntry", pFields,pQuery,pOrderBy, 0, 0, false); Enumeration enPpeEntries=vPpeEntries.elements(); while (enPpeEntries.hasMoreElements()) { Hashtable htPpeEntry=(Hashtable)enPpeEntries.nextElement(); for (int i = 0; i < pFields.length; i++) { String data = (String)htPpeEntry.get(pFields[i]); out.write(paramDelim + (data == null ? "" : Utils.replace(data, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); } out.write(lineSep); } } catch (Exception e) { } //finally { // try { stmt.close();} catch (Exception e) {} // try { con.close();} catch (Exception e) {} //} } else { String[] pFields = {"PpeID", "PpePerID", "PpePerID:PerCivID:Val", "PpePerID:PerFstName", "PpePerID:PerName", "PpePerID:PerPhone", "PpePerID:PerFax", "PpePerID:PerMail", "PpeSilID", "PpeSilID:SilCivID:Val", "PpeSilID:SilFstName", "PpeSilID:SilName", "PpeSilID:SilPhone", "PpeSilID:SilMail", "PpePopID:PopSelID:SelDefault", "PpeEntID", "PpeEntID:EntCorpName", "PpeEntID:EntAd1", "PpeEntID:EntAd2", "PpeEntID:EntAd3", "PpeEntID:EntZip", "PpeEntID:EntCity", "PpeEntID:EntCtrID:Val"}; String[] orderBy = {"PpeEntID:EntCorpName", "PpePerID:PerName", "PpeSilID:SilName"}; String[][] query = {{"PpePopID = " + Utils.formatToSQL(context, id), "PpeRemoved = 0"}}; long beforeList = System.currentTimeMillis(); Vector objs = PopulationEntryBean.listSummary(session, pFields, query, orderBy); logger.debug("Temps pour recuperer les infos : " + (System.currentTimeMillis() - beforeList)); boolean hasEntries = objs.size() > 0; // affichage des noms de colonnes String[] columnNames = {"Civilite", "Prenom", "Nom", "Tel", "Fax", "Email", "RaisonSociale", "Adresse1", "Adresse2", "Adresse3", "CodePostal", "Ville", "Pays"}; for(int i = 0; i < columnNames.length; i++) { out.write((i == 0 ? "" : paramSeparator) + columnNames[i]); } out.write((String)System.getProperty("line.separator")); for(int i = 0; i < objs.size(); i++) { Hashtable obj = (Hashtable)objs.elementAt(i); String intID = (String)obj.get("PpePerID"); String intCiv = null; String intFstName = null; String intName = null; String intPhone = null; String intFax = null; String intMail = null; if(intID != null) { intCiv = (String)obj.get("PpePerID:PerCivID:Val"); intFstName = (String)obj.get("PpePerID:PerFstName"); intName = (String)obj.get("PpePerID:PerName"); intPhone = (String)obj.get("PpePerID:PerPhone"); intFax = (String)obj.get("PpePerID:PerFax"); intMail = (String)obj.get("PpePerID:PerMail"); } else { intID = (String)obj.get("PpeSilID"); if(intID != null) { intCiv = (String)obj.get("PpeSilID:SilCivID:Val"); intFstName = (String)obj.get("PpeSilID:SilFstName"); intName = (String)obj.get("PpeSilID:SilName"); intPhone = (String)obj.get("PpeSilID:SilPhone"); intMail = (String)obj.get("PpeSilID:SilMail"); } else { intCiv = (String)obj.get("PpePopID:PopSelID:SelDefault"); } } out.write(paramDelim + (intCiv == null ? "" : Utils.replace(intCiv, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (intFstName == null ? "" : Utils.replace(intFstName, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (intName == null ? "" : Utils.replace(intName, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (intPhone == null ? "" : Utils.replace(intPhone, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (intFax == null ? "" : Utils.replace(intFax, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (intMail == null ? "" : Utils.replace(intMail, paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntCorpName") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntCorpName"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntAd1") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntAd1"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntAd2") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntAd2"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntAd3") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntAd3"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntZip") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntZip"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntCity") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntCity"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write(paramDelim + (obj.get("PpeEntID:EntCtrID:Val") == null ? "" : Utils.replace((String)obj.get("PpeEntID:EntCtrID:Val"), paramDelim, paramDelim + paramDelim)) + paramDelim + paramSeparator); out.write((String)System.getProperty("line.separator")); } } %>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de