NTGuru705
asked on
Crystal License Count Help
I am running some rpt files to a pdf export via an ASP web page.. I am using the Server.CreateObject("Cryst alRuntime. Applicatio n.8.5") familiar way of doing this and for some reason or another I am frequently getting and out of license alert... but I thought once the pdf file was dropped to disk the license was released.. I know I dont have 5 simultaneous users doing this.. is there a way to track where these licenses are being held.. to release them I am using this.. on every page that I am generating the report from.. this is at the bottom..
Function DestroyObjects(ByRef ObjectToDestroy)
If isobject(ObjectToDestroy) then
set ObjectToDestroy = nothing
'Not supported with IIS4, so ignore an error here.
On Error Resume Next
Session.Contents.Remove(Ob jectToDest roy)
On Error Goto 0
DestroyObjects = true
'Response.Write("Killed")
Else
DestroyObjects = false
'Response.Write("Not Killed")
End if
End Function
DestroyObjects(session("oP ageEngine" ))
DestroyObjects(session("oR pt"))
DestroyObjects(session("oA pp"))
POSTED BELOW IS THE CALLING PAGE
========================== ======
<%@ Language=VBScript %>
<!--#include file="../../../../../inclu de/functio ns.asp" -->
<%
PageTitle = "FFIT Custom MB Format 01v1"%>
<title>
<%Response.Write(PageTitle )%></title >
<%
ExportDirectory = "D:\public\htdocs\working\ "
workingURL = "http://portal.firstfleetinc.com/working/"
basePath = Request.ServerVariables("P ATH_TRANSL ATED")
While (Right(basePath, 1) <> "\" And Len(basePath) <> 0)
iLen = Len(basePath) - 1
basePath = Left(basePath, iLen)
Wend
baseVirtualPath = Request.ServerVariables("P ATH_INFO")
While (Right(baseVirtualPath, 1) <> "/" And Len(baseVirtualPath) <> 0)
iLen = Len(baseVirtualPath) - 1
baseVirtualPath = Left(baseVirtualPath, iLen)
Wend
If Not IsObject(session("oApp")) Then
Set session("oApp") = Server.CreateObject("Cryst alRuntime. Applicatio n.8.5")
If Not IsObject(session("oApp")) Then
response.write "Error: Could not instantiate the Crystal Reports automation server. Please check to see that Crystal Reports or ReCrystallize has been properly installed on the web server PC. See the ReCrystallize Pro Getting Started guide for more information."
response.end
End If
End If
If IsObject(session("oRpt")) Then
set session("oRpt") = nothing
End If
Set session("oRpt") = session("oApp").OpenReport (basePath & "ffmb01v1.rpt", 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = Nothing
Set Session("oApp") = Nothing
Session.Abandon
Response.End
End If
session("oRpt").DiscardSav edData
session("oRpt").MorePrintE ngineError Messages = False
session("oRpt").EnablePara meterPromp ting = False
set crtable = session("oRpt").Database.T ables.Item (1)
crtable.SetLogonInfo cstr("Trinity"), cstr("PSLive"), cstr("sa"), cstr("MYPASSWORD")
if not crtable.TestConnectivity then
response.write "Unable to connect to data source using the following information.<BR><BR>"
response.write "Server / ODBC data source: Trinity<BR>"
response.write "Database / Table: PSLive<BR>"
response.write "User Name: " & "sa<BR>"
response.write "Please verify the database user password in this ASP file.<BR><BR>"
end if
Set session("oSubRpt") = session("oRpt").OpenSubrep ort( "MB1a.rpt" )
set crtable = session("oSubRpt").Databas e.Tables.I tem(1)
crtable.SetLogonInfo cstr("Trinity"), cstr("PSLive"), cstr("sa"), cstr("MYPASSWORD")
if not crtable.TestConnectivity then
response.write "ReCrystallize Warning: Unable to connect to data source using the following information.<BR><BR>"
response.write "Server / ODBC data source: Trinity<BR>"
response.write "Database / Table: PSLive<BR>"
response.write "User Name: " & "sa<BR>"
response.write "Please verify the database user password in this ASP file.<BR><BR>"
end if
set session("ParamCollection") = Session("oRpt").Parameterf ields
set Param1 = session("ParamCollection") .Item(1)
set Param2 = session("ParamCollection") .Item(2)
If Request.QueryString("mb") <> 0 Then
ParamValue1 = "REPRINT"
ParamValue2 = Request.QueryString("mb")
Call Param1.SetCurrentValue (CStr(ParamValue1), 12)
Call Param2.SetCurrentValue (CDbl(ParamValue2), 7)
Else
ParamValue1 = "NOTREPRINT"
ParamValue2 = Request.QueryString("mb")
Call Param1.SetCurrentValue (CStr(ParamValue1), 12)
Call Param2.SetCurrentValue (CDbl(ParamValue2), 7)
End if
set Param3 = session("ParamCollection") .Item(3)
ParamValue3 = Request.QueryString("billt o")
Call Param3.SetCurrentValue (CStr(ParamValue3), 12)
set Param4 = session("ParamCollection") .Item(4)
ParamValue4 = Request.QueryString("datet ype")
Call Param4.SetCurrentValue (CDbl(ParamValue4), 7)
set Param5 = session("ParamCollection") .Item(5)
ParamValue5 = Request.QueryString("start date")
SPosition=Instr(ParamValue 5,":")
If SPosition = "0" Then
ParamValue5 = RTrim(ParamValue5)
ParamValue5 = ParamValue5 & " 00:00:00"
End if
Call Param5.SetCurrentValue (CDate(ParamValue5), 16)
set Param6 = session("ParamCollection") .Item(6)
ParamValue6 = Request.QueryString("endda te")
EPosition=Instr(ParamValue 6,":")
If EPosition = "0" Then
ParamValue6 = RTrim(ParamValue6)
ParamValue6 = ParamValue6 & " 23:59:59"
End if
Call Param6.SetCurrentValue (CDate(ParamValue6), 16)
If IsObject (session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
%>
<% viewer = "PDF" %>
<%
if viewer = "Word" then
exporttype = "14"
fileextension = ".doc"
end if
if viewer = "Excel" then
exporttype = "21"
fileextension = ".xls"
end if
if viewer = "RTF" then
exporttype = "4"
fileextension = ".rtf"
end if
if viewer = "CSV" then
exporttype = "5"
fileextension = ".csv"
end if
if viewer = "PDF" then
exporttype = "31"
fileextension = ".pdf"
end if
if viewer = "HTML" then
exporttype = "24"
fileextension = ".htm"
end if
%>
<%
set crystalExportOptions = Session("oRpt").ExportOpti ons
ExportFileName = CStr(Session.SessionID) & fileextension
if viewer<>"HTML" then
crystalExportOptions.DiskF ileName = ExportDirectory & ExportFileName
else
crystalExportOptions.HTMLF ileName = basepath & ExportFileName
end if
crystalExportOptions.Forma tType = CInt(exporttype)
crystalExportOptions.Desti nationType = 1
Session("oRpt").Export False
Function DestroyObjects(ByRef ObjectToDestroy)
If isobject(ObjectToDestroy) then
set ObjectToDestroy = nothing
'Not supported with IIS4, so ignore an error here.
On Error Resume Next
Session.Contents.Remove(Ob jectToDest roy)
On Error Goto 0
DestroyObjects = true
'Response.Write("Killed")
Else
DestroyObjects = false
'Response.Write("Not Killed")
End if
End Function
DestroyObjects(session("oP ageEngine" ))
DestroyObjects(session("oR pt"))
DestroyObjects(session("oA pp"))
response.write "<META http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) & "0; url=" & workingURL & exportfilename & Chr(34) & ">"
'clean up files that are more than 1 day old
del = DeleteFiles(1, ExportDirectory)
set objF = Nothing
set objFC = Nothing
set objFS = Nothing
%>
Function DestroyObjects(ByRef ObjectToDestroy)
If isobject(ObjectToDestroy) then
set ObjectToDestroy = nothing
'Not supported with IIS4, so ignore an error here.
On Error Resume Next
Session.Contents.Remove(Ob
On Error Goto 0
DestroyObjects = true
'Response.Write("Killed")
Else
DestroyObjects = false
'Response.Write("Not Killed")
End if
End Function
DestroyObjects(session("oP
DestroyObjects(session("oR
DestroyObjects(session("oA
POSTED BELOW IS THE CALLING PAGE
==========================
<%@ Language=VBScript %>
<!--#include file="../../../../../inclu
<%
PageTitle = "FFIT Custom MB Format 01v1"%>
<title>
<%Response.Write(PageTitle
<%
ExportDirectory = "D:\public\htdocs\working\
workingURL = "http://portal.firstfleetinc.com/working/"
basePath = Request.ServerVariables("P
While (Right(basePath, 1) <> "\" And Len(basePath) <> 0)
iLen = Len(basePath) - 1
basePath = Left(basePath, iLen)
Wend
baseVirtualPath = Request.ServerVariables("P
While (Right(baseVirtualPath, 1) <> "/" And Len(baseVirtualPath) <> 0)
iLen = Len(baseVirtualPath) - 1
baseVirtualPath = Left(baseVirtualPath, iLen)
Wend
If Not IsObject(session("oApp")) Then
Set session("oApp") = Server.CreateObject("Cryst
If Not IsObject(session("oApp")) Then
response.write "Error: Could not instantiate the Crystal Reports automation server. Please check to see that Crystal Reports or ReCrystallize has been properly installed on the web server PC. See the ReCrystallize Pro Getting Started guide for more information."
response.end
End If
End If
If IsObject(session("oRpt")) Then
set session("oRpt") = nothing
End If
Set session("oRpt") = session("oApp").OpenReport
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = Nothing
Set Session("oApp") = Nothing
Session.Abandon
Response.End
End If
session("oRpt").DiscardSav
session("oRpt").MorePrintE
session("oRpt").EnablePara
set crtable = session("oRpt").Database.T
crtable.SetLogonInfo cstr("Trinity"), cstr("PSLive"), cstr("sa"), cstr("MYPASSWORD")
if not crtable.TestConnectivity then
response.write "Unable to connect to data source using the following information.<BR><BR>"
response.write "Server / ODBC data source: Trinity<BR>"
response.write "Database / Table: PSLive<BR>"
response.write "User Name: " & "sa<BR>"
response.write "Please verify the database user password in this ASP file.<BR><BR>"
end if
Set session("oSubRpt") = session("oRpt").OpenSubrep
set crtable = session("oSubRpt").Databas
crtable.SetLogonInfo cstr("Trinity"), cstr("PSLive"), cstr("sa"), cstr("MYPASSWORD")
if not crtable.TestConnectivity then
response.write "ReCrystallize Warning: Unable to connect to data source using the following information.<BR><BR>"
response.write "Server / ODBC data source: Trinity<BR>"
response.write "Database / Table: PSLive<BR>"
response.write "User Name: " & "sa<BR>"
response.write "Please verify the database user password in this ASP file.<BR><BR>"
end if
set session("ParamCollection")
set Param1 = session("ParamCollection")
set Param2 = session("ParamCollection")
If Request.QueryString("mb") <> 0 Then
ParamValue1 = "REPRINT"
ParamValue2 = Request.QueryString("mb")
Call Param1.SetCurrentValue (CStr(ParamValue1), 12)
Call Param2.SetCurrentValue (CDbl(ParamValue2), 7)
Else
ParamValue1 = "NOTREPRINT"
ParamValue2 = Request.QueryString("mb")
Call Param1.SetCurrentValue (CStr(ParamValue1), 12)
Call Param2.SetCurrentValue (CDbl(ParamValue2), 7)
End if
set Param3 = session("ParamCollection")
ParamValue3 = Request.QueryString("billt
Call Param3.SetCurrentValue (CStr(ParamValue3), 12)
set Param4 = session("ParamCollection")
ParamValue4 = Request.QueryString("datet
Call Param4.SetCurrentValue (CDbl(ParamValue4), 7)
set Param5 = session("ParamCollection")
ParamValue5 = Request.QueryString("start
SPosition=Instr(ParamValue
If SPosition = "0" Then
ParamValue5 = RTrim(ParamValue5)
ParamValue5 = ParamValue5 & " 00:00:00"
End if
Call Param5.SetCurrentValue (CDate(ParamValue5), 16)
set Param6 = session("ParamCollection")
ParamValue6 = Request.QueryString("endda
EPosition=Instr(ParamValue
If EPosition = "0" Then
ParamValue6 = RTrim(ParamValue6)
ParamValue6 = ParamValue6 & " 23:59:59"
End if
Call Param6.SetCurrentValue (CDate(ParamValue6), 16)
If IsObject (session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
%>
<% viewer = "PDF" %>
<%
if viewer = "Word" then
exporttype = "14"
fileextension = ".doc"
end if
if viewer = "Excel" then
exporttype = "21"
fileextension = ".xls"
end if
if viewer = "RTF" then
exporttype = "4"
fileextension = ".rtf"
end if
if viewer = "CSV" then
exporttype = "5"
fileextension = ".csv"
end if
if viewer = "PDF" then
exporttype = "31"
fileextension = ".pdf"
end if
if viewer = "HTML" then
exporttype = "24"
fileextension = ".htm"
end if
%>
<%
set crystalExportOptions = Session("oRpt").ExportOpti
ExportFileName = CStr(Session.SessionID) & fileextension
if viewer<>"HTML" then
crystalExportOptions.DiskF
else
crystalExportOptions.HTMLF
end if
crystalExportOptions.Forma
crystalExportOptions.Desti
Session("oRpt").Export False
Function DestroyObjects(ByRef ObjectToDestroy)
If isobject(ObjectToDestroy) then
set ObjectToDestroy = nothing
'Not supported with IIS4, so ignore an error here.
On Error Resume Next
Session.Contents.Remove(Ob
On Error Goto 0
DestroyObjects = true
'Response.Write("Killed")
Else
DestroyObjects = false
'Response.Write("Not Killed")
End if
End Function
DestroyObjects(session("oP
DestroyObjects(session("oR
DestroyObjects(session("oA
response.write "<META http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) & "0; url=" & workingURL & exportfilename & Chr(34) & ">"
'clean up files that are more than 1 day old
del = DeleteFiles(1, ExportDirectory)
set objF = Nothing
set objFC = Nothing
set objFS = Nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There is not much difference but I was leaving two session variables out there...
session("oSubRpt")
session("ParamCollection")
I found a link on Crystal Site that helped...
http://support.businessobjects.com/library/kbase/articles/c2009964.asp
I am going to request closure of this item.
Here is a slightly modified version that helped me....
==========================
Function DestroyObjects(ByRef ObjectToDestroy)
If isobject(ObjectToDestroy) then
set ObjectToDestroy = nothing
'Not supported with IIS4, so ignore an error here.
On Error Resume Next
Session.Contents.Remove(Ob
On Error Goto 0
DestroyObjects = true
'Response.Write("Inside")
Else
DestroyObjects = false
'Response.Write("Outside")
End if
if isobject(ObjectToDestroy) then
'Response.Write("ObjectDea
else
'Response.Write("ObjectSti
end if
End Function
DestroyObjects(session("oP
DestroyObjects(session("oR
DestroyObjects(session("oA
DestroyObjects(session("oS
DestroyObjects(session("Pa