Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    generazione file doppi da pagina asp

    Ciao a tutti,
    ho un piccolo problema: ho un sito che acquisisce alcune info da una pagina e passa le informazioni ad una pagina asp la quale ha il compito di creare un file xml contenente le stesse. In alcune occasioni mi capita che trovo dei file doppi con data/ora creazione che differenziano di qualche centesimo di secondo (ragion per cui escluderei il fatto che l'utente clicchi 2 volte su registra o simili, anche perchè la pagina fa un reindirizzamento e quindi l'utente dovrebbe anche tornare indietro...).
    Qualcuno ha già avuto problemi simili? Magari riconducibili ad alcuni browser o ad aggiornamenti degli stessi? Io ho provato a cercare su forum in internet ma non ci sono post sul problema....
    Se serve posto anche il codice.

    grz a tutti.
    Ciao by Davide

  2. #2
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Non è che crei il file poi lo apri ci scrivi e lo risalvi in base all'orario?

    Roby

  3. #3
    Io creo il file con il Server.CreateObject, faccio tutti gli appendChild e poi salvo con xml.save(nomefile).
    Di seguito ti posto l'intero codice:

    <%@Language=JavaScript%>


    <%
    try {
    // calcolo shipper info in base al cliente
    var Newdog_conn = Server.CreateObject("ADODB.Connection");
    Newdog_conn.Open(ConnessioneNewdog);
    var a = new SessionPar();
    a.setSessionID(Session.Contents("idSession"));
    a.getSessionContents();
    cliente = a.getSessionVar("CLIENTE_GESTITO");
    cli_alias = getCliAlias(cliente);
    riga = "select ragsoc,indiri,codcap,locali,nazion from client where codice = "+cliente;
    rs = Server.CreateObject("ADODB.Recordset");
    rs.Open(riga,Newdog_conn);
    if (!rs.EOF) {
    ragsoc = getstringa(rs("Ragsoc").Value);
    indiri = getstringa(rs("Indiri").Value);
    locali = getstringa(rs("Locali").Value);
    nazion = getstringa(rs("Nazion").Value);
    codcap = getstringa(rs("Codcap").Value);
    } else {
    ragsoc = "";
    indiri = "";
    locali = "";
    nazion = "";
    codcap = "";
    }
    rs.Close();
    riga = "Select Numero from Cliete Where Codice = "+cliente+" and Tiponr = 'M' Order By Codice,Progre";
    rs.Open(riga,Newdog_conn);
    mailad = "";
    while (!rs.EOF) {
    mailad += getstringa(rs("Numero").Value)+";";
    rs.MoveNext;
    }
    if (mailad.length > 0) {mailad = mailad.substr(0,mailad.length-1);}
    rs.Close();

    riga = "Select Numero from Cliete Where Codice = "+cliente+" and Tiponr = 'T' Order By Codice,Progre";
    rs.Open(riga,Newdog_conn);
    if (!rs.EOF) {
    phShipper = "PH:"+getTelFormatOK(getstringa(rs("Numero").Value ));
    } else {
    phShipper = "";
    }
    rs.Close();
    riga = "Select Numero from Cliete Where Codice = "+cliente+" and Tiponr = 'F' Order By Codice,Progre";
    rs.Open(riga,Newdog_conn);
    if (!rs.EOF) {
    fxShipper = "FX:"+getstringa(rs("Numero").Value);
    } else {
    fxShipper = "";
    }
    rs.Close();
    xmlStp = Server.CreateObject("Microsoft.XMLDOM");
    rootEl = xmlStp.createElement("Manifest");
    xmlStp.appendChild(rootEl);
    nd = xmlStp.createElement("BillOfLading");
    rootEl.appendChild(nd);
    apnd = xmlStp.createElement("CustomerCode");
    nd.appendChild(apnd);
    apnd.text = cli_alias;
    if (ragsoc.length > 0) {
    vnd = xmlStp.createElement("ShipperInfo");
    nd.appendChild(vnd);
    apnd = xmlStp.createElement("ShipperCode");
    vnd.appendChild(apnd);
    apnd.text = cli_alias;
    apnd = xmlStp.createElement("Name");
    vnd.appendChild(apnd);
    apnd.text = ragsoc;
    apnd = xmlStp.createElement("Address1");
    vnd.appendChild(apnd);
    apnd.text = indiri;
    paeIso = getIsoPaese(nazion.text);
    apnd = xmlStp.createElement("Address2");
    vnd.appendChild(apnd);
    apnd.text = codcap+"-"+locali+"-"+paeIso;
    apnd = xmlStp.createElement("Address3");
    apnd.text = phShipper;
    if ((phShipper != "") && (fxShipper != "")) {apnd.text=apnd.text+" - ";}
    if (fxShipper != "") {apnd.text = apnd.text + fxShipper;}
    vnd.appendChild(apnd);
    apnd = xmlStp.createElement("Mail");
    vnd.appendChild(apnd);
    apnd.text = mailad;
    }
    // Imposto il tipo di spedizione a T
    vnd = xmlStp.createElement("ShipmentType");
    nd.appendChild(vnd);
    vnd.text = "T";
    // Imposto sul numero documento il Marks
    vnd = xmlStp.createElement("ShipmentDocnum");
    nd.appendChild(vnd);
    vnd.text = a.getSessionVar("marks");
    vnd = xmlStp.createElement("ConsigneeInfo");
    nd.appendChild(vnd);
    apnd = xmlStp.createElement("Name");
    vnd.appendChild(apnd);
    apnd.text = a.getSessionVar("ragsodest");
    apnd = xmlStp.createElement("Address1");
    vnd.appendChild(apnd);
    apnd.text = a.getSessionVar("indidest");
    paeIso = getIsoPaese(a.getSessionVar("paedes"));
    apnd = xmlStp.createElement("Address2");
    vnd.appendChild(apnd);
    apnd.text = getCapFormatOK(a.getSessionVar("codcapdest"))+"-"+a.getSessionVar("localdest")+"-"+paeIso;
    if (a.getSessionVar("phonedest") != "") {
    apnd = xmlStp.createElement("Address3");
    vnd.appendChild(apnd);
    apnd.text = "PH:"+getTelFormatOK(a.getSessionVar("phonedest")) ;
    }
    apnd = xmlStp.createElement("Mail");
    vnd.appendChild(apnd);
    apnd.text = a.getSessionVar("maildest");
    apnd = xmlStp.createElement("InvoiceCurrency");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("valutamer");
    apnd = xmlStp.createElement("InvoiceValue");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("valoremer");
    apnd = xmlStp.createElement("InsuranceValue");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("valoreass");
    apnd = xmlStp.createElement("CodCurrency");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("valutacod");
    apnd = xmlStp.createElement("CodValue");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("valorecod");
    apnd = xmlStp.createElement("ArrivalCountry");
    nd.appendChild(apnd);
    apnd.text = paeIso;
    apnd = xmlStp.createElement("ShipInstruction1");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("istruz1");
    apnd = xmlStp.createElement("ShipInstruction2");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("istruz2");
    apnd = xmlStp.createElement("ShipInstruction3");
    nd.appendChild(apnd);
    apnd.text = a.getSessionVar("istruz3");

    vnd = xmlStp.createElement("PlaceOfRecipt");
    nd.appendChild(vnd);
    vxnd = xmlStp.createElement("PortName");
    vnd.appendChild(vxnd);
    vxnd.text = "1";
    vxnd = xmlStp.createElement("Nation");
    vnd.appendChild(vxnd);
    vxnd.text = "IT";

    vnd = xmlStp.createElement("PlaceOfDelivery");
    nd.appendChild(vnd);
    vxnd = xmlStp.createElement("PortName");
    vnd.appendChild(vxnd);
    vxnd.text = a.getSessionVar("localdest");
    vxnd = xmlStp.createElement("Nation");
    vnd.appendChild(vxnd);
    vxnd.text = paeIso;

    vnd = xmlStp.createElement("GoodsInfos");
    nd.appendChild(vnd);
    vxnd = xmlStp.createElement("GoodsInfo");
    vnd.appendChild(vxnd);
    apnd = xmlStp.createElement("MarksandNumber");
    vxnd.appendChild(apnd);
    apnd.text = a.getSessionVar("marks");
    apnd = xmlStp.createElement("Quantity");
    vxnd.appendChild(apnd);
    apnd.text = a.getSessionVar("packs");
    apnd = xmlStp.createElement("DescriptionOfGoods");
    vxnd.appendChild(apnd);
    apnd.text = a.getSessionVar("goods");
    apnd = xmlStp.createElement("UnitOfMeasure");
    vxnd.appendChild(apnd);
    apnd.text = a.getSessionVar("imball");
    // a vxnd bisogna aggiungere anche il nodo del peso lordo e netto totali;
    apnd = xmlStp.createElement("DetailOfMeasures");
    vxnd.appendChild(apnd);
    nrcolli = a.getSessionVar("packs");
    gwt = 0;
    nwt = 0;
    arr = new Array();
    for (i=1;i<=nrcolli;i++) {
    arr[0] = a.getSessionVar("larg"+i);
    arr[1] = a.getSessionVar("alt"+i);
    arr[2] = a.getSessionVar("prof"+i);
    arr = arr.sort(sortNumber);
    bpnd = xmlStp.createElement("DetailOfMeasure");
    cpnd = xmlStp.createElement("Width");
    bpnd.appendChild(cpnd);
    cpnd.text = arr[2];
    // cpnd.text = sortAr[0];
    apnd.appendChild(bpnd);
    cpnd = xmlStp.createElement("Height");
    bpnd.appendChild(cpnd);
    cpnd.text = arr[1];
    // cpnd.text = sortAr[1];

    cpnd = xmlStp.createElement("Deepth");
    bpnd.appendChild(cpnd);
    cpnd.text = arr[0];
    // cpnd.text = sortAr[2];
    cpnd = xmlStp.createElement("GrossW");
    bpnd.appendChild(cpnd);
    cpnd.text = a.getSessionVar("grossw"+i);
    cpnd = xmlStp.createElement("NetW");
    bpnd.appendChild(cpnd);
    cpnd.text = a.getSessionVar("netw"+i);
    }
    if (a.getSessionVar("PRIMA") == "S") {
    a.addValori("PRIMA","N");
    pathxml = s_pathxmlfile;
    nomeXml = s_pathxmlfile+"\\"+getDataFormattata()+".xml";
    xmlStp.save(nomeXml);
    }
    path = Server.MapPath("./");
    pathstampe = s_pathstampe;

    d1 = Server.CreateObject("aObjTracing.objtrc");
    filestp = d1.stampabdx(xmlStp.xml,path,pathstampe,s_aliasnam e);
    Response.Redirect("download.asp?FILETODOWNLOAD="+f ilestp+"&FILENAME="+filestp);
    xmlStp = null;
    d1 = null;

    nrcolli = a.getSessionVar("packs");
    %>

    <%
    }
    catch (err) {
    trace_operazioni(err.description);
    }
    a.freeSessionPar();
    a = null;
    rs.Close();
    rs = null;
    Newdog_conn.Close();
    Newdog_conn = null;

    // Response.Redirect("default.asp?idPage=20&idAct=1") ;
    %>

    Grazie e ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.