@jbm1313
User A and User B both click a link in a web app. The link is dynamically generated in the form of:
http://servername/VisioDrawingServic...e.aspx?PID=777
A java class in the web app creates a java.net.URLConnection with the url from the link. Then, it creates a BufferedInputStream object to read the response from the VB app.
The VB app creates a FileData.vb object:
-
Public Class FileData
-
Private _name As String
-
Private _mimeType As String
-
Private _data As Byte()
-
-
Public Property Name() As String
-
Get
-
Return _name
-
End Get
-
Set(ByVal Value As String)
-
_name = Value
-
End Set
-
End Property
-
-
Public Property MimeType() As String
-
Get
-
Return _mimeType
-
End Get
-
Set(ByVal Value As String)
-
_mimeType = Value
-
End Set
-
End Property
-
-
Public Property Data() As Byte()
-
Get
-
Return _data
-
End Get
-
Set(ByVal Value As Byte())
-
_data = Value
-
End Set
-
End Property
-
-
End Class
-
Then, it reads from a database prompted by the "PID" query string, and creates a Visio diagram that is assigned as an array of bytes in a FileData object named diagrams.
-
Dim diagrams() As FileData
-
-
diagrams = Diagram.Request(intPID, intLID, Not boolGetPdf, boolGetPdf, True, namesExist)
-
-
If diagrams.Length > 0 And Response.IsClientConnected Then
-
-
If boolGetPdf Then
-
Response.ContentType = "application/pdf"
-
Else
-
Response.ContentType = "application/x-visio"
-
End If
-
-
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & diagrams(0).Name & """")
-
Response.AppendHeader("Content-Length", "" & diagrams(0).Data.GetLength(0)) ' Set content length
-
-
Response.BinaryWrite(diagrams(0).Data)
-
Else
-
' Nothing To Do
-
Response.Write("No data returned from request")
-
End If
-
-
Response.Flush()
-
Response.End()
-
The VB app creates two instances of Visio.exe, 1 for A and 1 for B.
The VB app then writes this back to the java class that called the URLConnection. The java class reads the byte data from the BufferedInputStream, and writes it to the response of the web app with response.getOutputStream().write(data, 0, length), where data is an array of bytes (byte[]) and length is the return value of BufferedInputStream.read(data).
Whoever is "done" first and clicks on the "Open/Save" dialog box first gets a binary file that is twice as big as it's supposed to be that cannot be opened by Visio, and the loser gets a blank Visio document.
I have been researching, reading, and studying some way to make one of these two processes more choosy. Ideally, the java class would only accept byte data in the output stream from the "correct" source, but how does the VB app distinguish the byte data in the OutputStream? I would think that Response.BinaryWrite would be unique to a specific http response, instead of just dumping it to one static outputstream that's available to anyone listening/requesting.
Any help or insight is appreciated!