<% /*
    $Revision$
    $Id$

    File:           Slnk2IMG.inc
    Description:
    Parameters:
    Context:
    Note:
*/
%>
<!-- #INCLUDE FILE="./SLNKDWF.inc" -->
<!-- #INCLUDE FILE="./json2.js" -->
<%
//
// Parameters: sizeX, sizeY            size of requested picture in pixels
//             offsetX, offsetY        displacement in pixels. 0=no panning
//             scale (x1000)           scaling of picture (around center)
//                                     Scaling is applied before panning
//                        OF
//             paperWidth, paperHeight size of requested picture in mm
//             DWGscale, DWGminX..viewmaxY
//             sDWGscale               gewenste DWG-schaal van het symbol
//             AsFND=1                 Genereer een find
//             AsWMF=1                 Genereer een WMF ipv PNG
//             AsDWF=1                 Genereer een DWF ipv PNG. Let op: geen layer filtering!
//             AsMAP=1                 Genereer een MAP die je in parent.SystemMap prompt
//             forPrint=1              Als het voor printen is (wit papier geforceerd)
// Layers, RegExp

// Dat doen ASP bestanden maar: Response.Expires = -1;

/* {
     dwfFile     : Mandatory, String, de te processen DWF
     forcePage   : Number, forceer een paginanummer
     keepTemp    : Logical, bewaar tempfile
     maximize    : Logical, Maximalizeer het plaatje binnen afmeting (voor symbolen)
     forceGray   : Logical, forceer grijstinten
     scale       : Number, forceer een schaal (symbolen draggen)
     rotation    : Number (0-359), forceer een rotatie (symbool draggen)
     asGIF       : Logical, Maak er een transparante GIF van (symbool draggen)
     tempFolder  : String, "C:\\Temp"
     dwfProcessor: callback functie
     imgProcessor: callback functie
     fndProcessor: callback functie
   }
 */
function SLNKDWF (myProps)
{
    this.myProps = myProps;
    this.myProps.timerStart = new ActiveXObject("SLNKDWF.About").usTimer;

    var pPage       = _getParam("page", 0);         // Bij multi-dwf
    var forPrint    = _getParam("forPrint", 0);
    var psdwgScale  = _getParam("sdwgScale", null); // Forced dwgScale (versus pixel) for symbols
    var pHintScale  = _getParam("hintScale", null); // Suggested dwgScale (versus pixel), only for manipulate DWF

    var sizeX, sizeY;
    // Het formaat van het plaatje kan op twee manieren opgegeven worden
    // in millimeter (paperWidth en paperHeight)
    // of in pixels sizeX en sizeY
    var paperWidth = _getParam("paperWidth",-1);
    var paperHeight = _getParam("paperHeight",-1);
    var dwgScale = parseFloat(_getParam("dwgScale", -1)); // Eenheid: DWGUnits per Pixel
    if (paperWidth!=-1 && paperHeight!=-1)
    {
        sizeX = paperWidth  / 25.4 * 96 * 2; // IE 6.0 doet 96 dpi lijkt/schijnt het
        sizeY = paperHeight / 25.4 * 96 * 2; // Factor 2 voor extra resolutie
        if (dwgScale < 0) // het is 'paperScale' vanuit default.asp voor PrintFG
        {
            dwgScale = paperWidth * (-dwgScale) / sizeX;
        }
        else
            dwgScale /= 2; // (onze factor 2)
    }
    else
    {
        sizeX = parseInt(_getParam("sizeX",800), 10);
        sizeY = parseInt(_getParam("sizeY",sizeX), 10);
    }

    // Offset en schaal kunnen op twee manieren opgegeven worden
    // A) in pixels (offsetX, offsetY en scale)
    // B) of in DWG coordinaten en center (DWGscale, centerX..centerY)
    // De DLL kent alleen (nog) versie A dus rekenen we B terug naar A
    //    om dat te kunnen omrekenen hebben we DWGminX..DWGmaxY nodig
    //    maar die krijgen we dan gelukkig aangereikt door de aanroeper
    if (_getParam("maximize","0")=="1" || _getParam("DWGminX","")=="")
    {
        var ox = _getParam("offsetX",0);
        var oy = _getParam("offsetY",0);
        var sc = _getParam("scale", 1000.0); // 1000 is FIT
    }
    else
    {   // Dan moet aanroeper deze meegegeven hebben
        var DWGminX  = parseInt(_getParam("DWGminX"),10);
        var DWGminY  = parseInt(_getParam("DWGminY"),10);
        var DWGmaxX  = parseInt(_getParam("DWGmaxX"),10);
        var DWGmaxY  = parseInt(_getParam("DWGmaxY"),10);
        // Dit gaan we tonen
        var centerX = parseFloat(_getParam("centerX", (DWGminX + DWGmaxX)/2));
        var centerY = parseFloat(_getParam("centerY", (DWGminY + DWGmaxY)/2));

        var paperRot  = parseInt(_getParam("rotation",0),10);

        // Bepaal schaal
        //
        var units = Math.max((DWGmaxX - DWGminX) / sizeX, (DWGmaxY - DWGminY) / sizeY) ; // DWG units per pixel bij schaal 1
        if (dwgScale == 0 || dwgScale == -1)
            dSc = 1;
        else
            dSc = units / dwgScale;

        //
        // Bepaal offset
        //
        var cX = ((DWGminX + DWGmaxX)/2 - centerX) / units;
        var cY = (centerY - (DWGminY + DWGmaxY)/2) / units;

        //
        // Stap 2: nu met dSc inzoomen op het midden
        //
        cX = sizeX/2 + (cX - sizeX/2)*dSc;
        cY = sizeY/2 + (cY - sizeY/2)*dSc;

        //
        // Prepareer resultaat
        //
        var ox = Math.round(cX);
        var oy = Math.round(cY);
        var sc = Math.round(1000*dSc);
    }

    var paperColor = _getParam("paperColor", -1);
    if (forPrint)
        paperColor = 0xFFFFFF; // Altijd met wit papier

    var forceBW   = _getParam("forceBW",false);
    var labelPos  = _getParam("labelPos", 1);

    var AsFND     = _getParam("AsFND",false);
    var AsWMF     = _getParam("AsWMF",false);
    var AsMAP     = _getParam("AsMAP",false);
    var AsDWF     = _getParam("AsDWF",false);

    var TemporaryFolder = 2;
    var fso = Server.CreateObject("Scripting.FileSystemObject");
    var _tfolder = fso.GetSpecialFolder(TemporaryFolder);

    if (Request.Querystring("txtAsPNG").count>0)
    {
        _TextAsPNG(""+Request.Querystring("txtAsPNG"));
    }

    /************************************************************\
     *
     * Maak een W2D file. Bij zoomen en pannen hoeft de W2D file niet aangepast te worden
     * en zouden we dus als optimalisatie de gecache-te versie kunnen gebruiken.
     * (maar dit doen we niet)
     * We bewaren hem wel voor de AsMAP als we die nog verwachten
     *
     * Returns pointer to extracted W2D file
    \************************************************************/
    function _ProcessDWF(myProps)
    {
       // Converteer een DWF-package en haal de W2D file er uit
       // Vervolgens wordt de W2D file aangepast (label, kleuren etc)

        if (!myProps.dwfProcessor && !myProps.contourLayers && !myProps.labelLayers)
            return myProps.dwfFile; // Geen contour te processen. Direct klaar?

        // We hebben te parsen cont file
        var oWhipFile, oDWFFilePlan;
        try
        {
            oWhipFile = _openContourDWF(myProps.dwfFile, myProps.contourLayers, myProps.labelLayers, myProps.minArea)
        }
        catch( ee )
        {
            throw "SLNKDWF/_openContourDWF Error: " + ee.description;
        }
        oWhipFile.setLabelPosition(labelPos);
        if (pHintScale && !isNaN(pHintScale) && !AsDWF)
            oWhipFile.hintScale = pHintScale; // For performance: symbols might get rasterized

        if (myProps.dwfProcessor)
            try
            {
                myProps.dwfProcessor(oWhipFile); // Ook voor AsMap: Er kunnen interessante tooltips gezet worden
            }
            catch( ee )
            {
                var fn = myProps.dwfProcessor.toString().match(/function (\w*)/)[1];
                var txt = (typeof ee=="string")?ee:(typeof ee=="object" && typeof ee.description=="string")?ee.description:ee;
                throw "SLNKDWF Error in custom contour processor " + fn + "~" + txt;
            }

        try
        {
            var TempW2D=(myProps.tempFolder?myProps.tempFolder:_tfolder) + "\\" + fso.GetTempName();
            oWhipFile.SaveAs(TempW2D);
            return TempW2D;
        }
        catch( ee )
        {
            throw "_ProcessDWF/SaveAs Error: " + ee.description + "\nUserContext: " + new ActiveXObject("SLNKDWF.About").UserContext;
        }
    }

    function _Error(msg)
    {
        new SLNKDWF({maximize : false}).Warning("Fatal error occurred. \nTechnical details for support personnel:\n" + msg);
    }

    // Werkt nog niet echt goed?
    function _ErrorAsDWF(msg)
    {
        Response.clear;
        Response.contenttype = "drawing/x-dwf";
        Response.AddHeader("content-disposition","inline; filename=Facilitor.dwf");
        Response.Write("(DWF V00.42)")
        Response.Write("\nC 0")
        Response.Write("\n(Viewport ''")
        Response.Write("\n   (Contour 1 4 0,0 10000,0 10000,10000 0,10000))")
        Response.Write("\n   (Font (Height 500))")
        Response.Write("\n   (Text 0,5000 '"+"Fatal error occurred. \nTechnical details for support personnel:\n" + msg+"')")
        Response.Write("\n(EndOfDWF)")

        Response.End();
    }

    function _TextAsPNG(msg)
    {
        var oWhip2png;
        if (msg==null) msg="(null)";
        try
        {
            oWhip2png = Server.CreateObject("SLNKDWF.Whip2PNG"); // Hopen dat dit wel lukt
            oWhip2png.SetDimensions(sizeX || 800, sizeY || 600, 0, 0, 1);
            if (myProps.maximize)
                oWhip2png.Maximize = true;
            Response.clear;
            Response.contenttype = "image/png";
            Response.BinaryWrite(oWhip2png.TextAsPNG(msg));
            Response.End();
        }
        catch( ee )
        {
            Response.contenttype = "text/plain";
            Response.Write("Kan tekst '" + msg + "' niet als PNG aanmaken: " + ee.description);
            Response.End();
        }
    }

    function _StreamFile(IMGPath, mime, extraHeader)
    {
        var oStream = Server.CreateObject("ADODB.Stream");
        oStream.Open;
        oStream.Type = 1;

        oStream.LoadFromFile(IMGPath);

        Response.clear;
        Response.contenttype = mime;
        Response.AddHeader("content-disposition","inline; filename=Facilitor.dwf");
        if (extraHeader)
            Response.AddHeader("SLNKDWF",extraHeader);
        Response.BinaryWrite(oStream.read(oStream.Size));
    }

    // Maak een Whip2PNG object aan met zo veel mogelijk settings gedaan
    function _Whip2Object(W2DPath, myProps)
    {
        var oWhip2png = Server.CreateObject("SLNKDWF.Whip2png");
        var oDWFFile = Server.CreateObject("SLNKDWF.DWFFile");

        try
        {
            oDWFFile.Open(W2DPath);
        }
        catch (e)
        {
            var message = "Error opening " + W2DPath + "<br>" + e.description;
            __DoLog(message + "<br>" + "\nUserContext: " + new ActiveXObject("SLNKDWF.About").UserContext, "#ffff00");
            // throw message; nog iets te veel info
        }

        if (oDWFFile.EplotSections.Count == 0)
            oWhip2png.Load(W2DPath);
        else
        {
            var eps = oDWFFile.EplotSections.Item(myProps.forcePage?myProps.forcePage:pPage);
            oWhip2png.LoadStream(eps);
        }

        if (forceBW)
            oWhip2png.forceBW = true;
        else
            if (paperColor>=0) oWhip2png.PaperColor = paperColor;

        if (typeof paperRot != "undefined")
            myProps.rotation = paperRot;
        oWhip2png.SetDimensions(sizeX,sizeY,ox,oy, sc/1000, myProps.rotation?myProps.rotation:0);

        oWhip2png.Maximize = myProps.maximize;
        oWhip2png.forceGray = myProps.forceGray;

        if (psdwgScale && psdwgScale  > 0)
            oWhip2png.dwgScale = psdwgScale/(myProps.scale?myProps.scale:1.0); // Geforceerde symbool schaal. Altijd 'Fit' trouwens

        try
        {
            if (myProps.imgProcessor)
                myProps.imgProcessor(oWhip2png); // Zet bijvoorbeeld kleurvertalingen
        }
        catch( ee )
        {
            var fn = myProps.imgProcessor.toString().match(/function (\w*)/)[1];
            throw "SLNKDWF Error in custom IMG processor " + fn + "~" + ee.description;
        }

        return oWhip2png;
    }

    function SlnkSetText(txt)
    {
        _TextAsPNG(txt);
    }

    // Transformeer de DLL-event naar een JScript object
    function _SlnkEvent(myProps, SLNKEvent)
    {
        var res =
            {   success     : true,
                viewminX    : SLNKEvent.viewExtents.min.DwgX, viewminY : SLNKEvent.viewExtents.min.DwgY,
                viewmaxX    : SLNKEvent.viewExtents.max.DwgX, viewmaxY : SLNKEvent.viewExtents.max.DwgY,
                DWGminX     : SLNKEvent.DWGExtents.min.DwgX,  DWGminY  : SLNKEvent.DWGExtents.min.DwgY,
                DWGmaxX     : SLNKEvent.DWGExtents.max.DwgX,  DWGmaxY  : SLNKEvent.DWGExtents.max.DwgY,
                dwgX        : SLNKEvent.dwgX,
                dwgY        : SLNKEvent.dwgY,
                EdgeAngle   : SLNKEvent.EdgeAngle,
                EdgeDistance: SLNKEvent.EdgeDistance,
                ContourLabel: SLNKEvent.ContourKey, // deprecated 2.80
                ContourKey  : SLNKEvent.ContourKey,
                TextLabel   : SLNKEvent.TextLabel,
                ContourLayer: SLNKEvent.ContourLayer,
                TextLayer   : SLNKEvent.TextLayer,
                sizeX       : sizeX,
                sizeY       : sizeY,
                dScale      : _jsNum(sc/1000)
            };
            if (Session("logging") > 0)
                res.lastDWFfile = String(myProps.dwfFile);

            // Gebeurt bij VectorWork dwf's
            if (res.DWGminX > res.DWGmaxX)
            {
                var tmp = res.DWGmaxX;
                res.DWGmaxX = res.DWGminX;
                res.DWGminX = tmp;
            }
            if (res.DWGminY > res.DWGmaxY)
            {
                var tmp = res.DWGmaxY;
                res.DWGmaxY = res.DWGminY;
                res.DWGminY = tmp;
            }
            res.scaleX = (res.DWGmaxX - res.DWGminX) / sizeX;
            res.scaleY = (res.DWGmaxY - res.DWGminY) / sizeY;

        return res;
    }

    function _SlnkGenerateIMG(myProps, TempW2D)
    {
        try
        {
            var oWhip2png = _Whip2Object(TempW2D, myProps);
            if (_getParam("forPrint", 0) == 1)
                oWhip2png.setAntialias(1); // Geeft anders vage lijntjes

            Response.clear;
            Response.contenttype = (AsWMF?"image/x-wmf":(myProps.asGIF)?"image/gif":"image/png");
            Response.BinaryWrite((myProps.asGIF)?oWhip2png.GetAsTransGIF():oWhip2png.GetAsPNG());
        }
        catch( ee )
        {
            // Wel vorige opruimen
            var TempW2D = Session("lastTempW2D");
            if (fso.FileExists(TempW2D) && myProps.dwfProcessor && (typeof myProps.keepTemp == "undefined" || !myProps.keepTemp))
            {
                try {fso.DeleteFile(TempW2D)} catch (e) {};
            }

            if (typeof(ee) == "string")
                _Error(ee);
            else
                _Error("SLNKDWF.DWFFile SlnkGenerateIMG Error: " + ee.description);
        }
    }

    function _SlnkGenerateFind(myProps, TempW2D)
    {
        var SlnkEvent = _SlnkFind(myProps, TempW2D);
        Response.Write(JSON.stringify(SlnkEvent));
    }

    // Resultaat: SlnkEvent met allerlei info
    function _SlnkFind(myProps, TempW2D)
    {
        var allOk=true;
        try
        {
            var oWhip2png = _Whip2Object(TempW2D, myProps);
            fx=parseInt(_getParam("findX", 800));
            fy=parseInt(_getParam("findY", sizeX));
            // eventuele moveFrom params
            fromX=_getParam("fromX", null);
            fromY=_getParam("fromY", null);

            areaName=oWhip2png.Find(fx, fy);
            if (fromX)
            {
                mDwgX = oWhip2png.SLNKEvent.viewExtents.min.DwgX
                            +fromX/sizeX*(oWhip2png.SLNKEvent.viewExtents.max.DwgX-oWhip2png.SLNKEvent.viewExtents.min.DwgX)
                mDwgY = oWhip2png.SLNKEvent.viewExtents.min.DwgY
                            +(sizeY-fromY)/sizeY*(oWhip2png.SLNKEvent.viewExtents.max.DwgY-oWhip2png.SLNKEvent.viewExtents.min.DwgY)
            }
        } catch( ee ) {
            if (typeof(ee) == "string")
                SLNKDWFError(ee)
            else
                SLNKDWFError("Ernstig probleem _Whip2Object:" + ee.description)
        }
        if (allOk)
        { // Copy serverside SLNKEvent properties to clientside
            SlnkEvent = _SlnkEvent(myProps, oWhip2png.SLNKEvent);
            SlnkEvent.findXY = { X : fx, Y : fy };
            SlnkEvent.fromXY = { X : fromX, Y : fromY };
            SlnkEvent.Param  = _getParam("prm", null);
            SlnkEvent.paperColor = oWhip2png.paperColor
            if (fromX) {
                SlnkEvent.fromDwgX = mDwgX;
                SlnkEvent.fromDwgY = mDwgY;
                SlnkEvent.fromKey  = String(_getParam("SymbolKey", -1));
            }
            if (myProps.fndProcessor)
                myProps.fndProcessor(SlnkEvent)

            return SlnkEvent;
        }
    }

    function _SlnkGenerateDWF(myProps, TempW2D)
    {
        try
        {
            var xp = Server.CreateObject("SLNKDWF.DWFFile");
            xp.Open(TempW2D);
            var xpSource = Server.CreateObject("SLNKDWF.DWFFile");
            xpSource.Open(myProps.dwfFile);
            if (xp.EplotSections.Count > 0 || xpSource.EplotSections.Count == 0) // TempW2D is nog een DWF package
            {                                                                    // of de bron was het niet
                _StreamFile(TempW2D, "drawing/x-dwf");
            }
            else
            {   // 'Echt' inpakken in DWF zodat paper info bewaard blijft
                var TempDWF=(myProps.tempFolder?myProps.tempFolder:_tfolder) + "\\" + fso.GetTempName();
                var xnew = Server.CreateObject("SLNKDWF.DWFFile");
                xnew.Create(TempDWF);
                // TempW2D wordt 'ingelezen', xpSource.EplotSections levert de paperinfo
                var nummer = xnew.CreateEPlotSection(TempW2D, xpSource.EplotSections.Item(0));
                var epl = xnew.EplotSections.Item(nummer)
                //epl.AddProperty("Facilitor", "Building", "123")

                xnew.Save();
                _StreamFile(TempDWF, "drawing/x-dwf", TempDWF);
            }
        }
        catch( ee )
        {
             _Error("SLNKDWF.DWFFile _SlnkGenerateDWF Error: " + ee.description);
        }
    }

    function SlnkGenerateIMG(myProps)
    {
        if (myProps == null || typeof myProps.dwfFile != "string")
            _Error("SlnkGenerateIMG: no dwfFile specfied");

        var fso = Server.CreateObject("Scripting.FileSystemObject");
        if( !fso.FileExists( myProps.dwfFile ))
        {   // Veel voorkomende fout niet helemaal laten cascaderen naar de DLL
            _Error("File not found at webserver:\n" + myProps.dwfFile)
            return;
        }

        // Simpel 1-niveau caching voor de MAP
        var TempW2D = Session("lastTempW2D");
        var lastURL = Session("lastURL");
        var currURL = String(Request.ServerVariables("QUERY_STRING"));
        var cached = (AsMAP && currURL == lastURL + "&AsMap=1");
        if (!cached)
        {   // Wel vorige opruimen
            if (fso.FileExists(TempW2D) && myProps.dwfProcessor && (typeof myProps.keepTemp == "undefined" || !myProps.keepTemp))
            {
                try {fso.DeleteFile(TempW2D)} catch (e) {};
            }

            try
            {
               var TempW2D = _ProcessDWF(myProps);
            }
            catch( ee )
            {
                 if (typeof(ee) == "string")
                    _Error(ee);
                 else
                    _Error("_SlnkGenerateIMG/_ProcessDWF Error: " + ee.description);
            }
        }
        myProps.tmBuild = ((new ActiveXObject("SLNKDWF.About").usTimer - myProps.timerStart)/1000).toFixed(0);
        var mustEnd = false;
        if (1)
        {
            var oCrypto = new ActiveXObject("SLNKDWF.Crypto");
            // TODO: user_key, session_id, customer_id, refreshcounter erin? Of
            // of: var lastCache = new Date(Application("SET_TM_" + customerId)); er gewoon in?
            var eTag = '"' + oCrypto.hex_sha1_file(TempW2D) + '"';

            Response.AddHeader("ETag", eTag);
            if (Request.ServerVariables("HTTP_IF_NONE_MATCH") == eTag)
            {   // We hebben een match!
                Response.Clear();
                Response.Status = "304 Not modified";
                mustEnd = true; // Response.End;
            }
        }

        if (!mustEnd)
        {
            if (AsFND)
                _SlnkGenerateFind(myProps, TempW2D)
            else if (AsMAP)
                _SlnkGenerateMap(myProps, TempW2D)
            else if (AsDWF)
                _SlnkGenerateDWF(myProps, TempW2D)
            else // AsIMG
                _SlnkGenerateIMG(myProps, TempW2D)
        }

        if (AsFND || AsDWF || AsMAP || myProps.asGIF || forPrint)
        {
            Session.Contents.Remove("lastURL");
            Session.Contents.Remove("lastTempW2D");
            if (myProps.dwfProcessor && (typeof myProps.keepTemp == "undefined" || !myProps.keepTemp))
            {
                try
                {
                    fso.DeleteFile(TempW2D);
                }
                catch (e)
                {
                    __DoLog("Error deleting " + TempW2D + "<br>" + e.description + "<br>" + "\nUserContext: " + new ActiveXObject("SLNKDWF.About").UserContext, "#ffff00");
                }
            }
        }
        else // We gokken dat de AsMAP nog komt en bewaren de W2D daarvoor
        {
            Session("lastURL") = String(Request.ServerVariables("QUERY_STRING"));
            Session("lastTempW2D") = TempW2D;
        }
        myProps.tmRender = ((new ActiveXObject("SLNKDWF.About").usTimer - myProps.timerStart)/1000 - myProps.tmBuild).toFixed(0);
        Response.AddHeader("SlnkDWF","B="+myProps.tmBuild+";R="+myProps.tmRender + (cached?";C=1":"") + (mustEnd?";E=1":""));
        if (mustEnd)
            Response.End; // We doen alles via 304

    }

    function _jsNum(f)
    {
        return String(f).replace(",",".");
    }


    function _SlnkGenerateMap(myProps, TempW2D)
    {
        try
        {
            var oWhip2png = _Whip2Object(TempW2D, myProps);

            var theMap  = oWhip2png.GetAsMap();

            SlnkEvent = _SlnkEvent(myProps, oWhip2png.SLNKEvent);
            SlnkEvent.Map  = theMap;
            SlnkEvent.paperColor = oWhip2png.paperColor; // Handig om later de achtergrond te zetten

        } catch( ee ) {
            if (typeof(ee) == "string")
                SLNKDWFError(ee)
            else
                SLNKDWFError("_ProcessDWF:" + ee.description)
        }
        Response.ContentType = "application/json";
        Response.Write(JSON.stringify(SlnkEvent));
    }

    this.Warning = function (txt)
    {
        if (AsMAP||AsFND)
        {
            Response.Write(JSON.stringify({success:false, message:txt}));
            Response.End();
        }
        else
            _TextAsPNG(txt);
    }

    this.Process = function ()
    {
        if (0)
        {
            var oCrypto = new ActiveXObject("SLNKDWF.Crypto");
            // TODO: user_key, customer_id, refreshcounter erin
            var eTag = '"' + oCrypto.hex_sha1(Request.QueryString) + '"';
            Response.AddHeader("ETag", eTag);
            if (Request.ServerVariables("HTTP_IF_NONE_MATCH") == eTag)
            {   // We hebben een match!
                Response.Clear();
                Response.Status = "304 Not modified";
                Response.End;
            }
        }

        SlnkGenerateIMG(this.myProps);
    }

    this.Find = function()
    {
        try
        {
           var TempW2D = _ProcessDWF(myProps);
        }
        catch( ee )
        {
             if (typeof(ee) == "string")
                _Error(ee);
             else
                _Error("_SlnkGenerateIMG/_ProcessDWF Error: " + ee.description);
        }

        var SlnkEvent = _SlnkFind(myProps, TempW2D);

        if (myProps.dwfProcessor && (typeof myProps.keepTemp == "undefined" || !myProps.keepTemp))
        {
            fso.DeleteFile(TempW2D);
        }

        return SlnkEvent;
    }
}
%>
