2 Replies Latest reply on Sep 24, 2008 9:15 AM by MMFranklin

    onSessionEnd

    MMFranklin
      I am calling the following adminapi method from within onSessionEnd in my application to clean the user's Datasource connection as shown in the code below...

      ****************************************************************************************** ******************************
      <!--- Login CF API--->
      <cfinvoke component="CFIDE.adminapi.administrator" method="login">
      <cfinvokeargument name="adminPassword" value="#Arguments.ApplicationScope.AppInt.CFSERVERPW#"/>
      </cfinvoke>

      <!--- DELETE DataSource --->
      <cfinvoke component="CFIDE.adminapi.datasource" method="deleteDatasource">
      <cfinvokeargument name="dsnname" value="#Arguments.SessionScope.auth.Temp_DSN#"/>
      </cfinvoke>

      <!--- Logout CF API--->
      <cfinvoke component="CFIDE.adminapi.administrator" method="logout">
      </cfinvoke>
      ****************************************************************************************** ******************************

      The code works as expected and does cleanup of the temporarily assigned datasource, however my onError method writes the following: "Error in Method [onSessionEnd] Event handler exception" to my application log shortly after firing. Does anyone have any insight on this problem.

      Below is a complete snippet of entire onSessionEnd method. As you will see I am also invoking a com object to delete the DNS on my PSQL server, but I don't believe this is problem.

      ****************************************************************************************** ******************************
      <!--- Cleanup of Temp DSN and TEMP DS on Session End --->
      <cffunction access="public" name="onSessionEnd" output="no" returnType="void">
      <cfargument name="sessionScope" required="yes">
      <cfargument name="applicationScope" required="yes">

      <!--- Remove User from List of Active Sessions --->
      <cfif StructKeyExists(arguments.sessionScope.auth, "WEB_USER_NAME")>
      <cfset structDelete(arguments.applicationScope.sessionTracker,arguments.sessionScope.auth.sessio nTracker)>
      </cfif>

      <!--- Delete DSN from CF Admin --->
      <!--- Login CF API--->
      <cfinvoke component="CFIDE.adminapi.administrator" method="login">
      <cfinvokeargument name="adminPassword" value="#Arguments.ApplicationScope.AppInt.CFSERVERPW#"/>
      </cfinvoke>

      <!--- DELETE DataSource --->
      <cfinvoke component="CFIDE.adminapi.datasource" method="deleteDatasource">
      <cfinvokeargument name="dsnname" value="#Arguments.SessionScope.auth.Temp_DSN#"/>
      </cfinvoke>

      <!--- Loginout CF API--->
      <cfinvoke component="CFIDE.adminapi.administrator" method="logout">
      </cfinvoke>


      <!--- Create PSQL the Session object --->
      <cfobject class="dto.dtoSession.1" name="dtoSession" action="create" context="inproc" type="com">

      <!--- Connect to Session --->
      <cfset session_return = dtoSession.Connect(Arguments.ApplicationScope.AppInt.PSQLServerName,Arguments.Application Scope.AppInt.PSQLServerUID,Arguments.ApplicationScope.AppInt.PSQLServerPW)>

      <cfif session_return NEQ 0>
      <cflog text="PSQL v8 Error Status:#session_return#" type="Warning" log="Application">
      </cfif>

      <!--- Delete DSN --->
      <cfobject class="dto.dtoDSN" name="del_dtoDSN" action="create" context="inproc" type="com">
      <cfset delDSN_result = dtoSession.DSNs.Remove(Arguments.SessionScope.auth.Temp_DSN)>
      <cfset retVal = dtoSession.disconnect()>

      <cfif delDSN_result neq 0>
      <cflog text="PSQL v8 DSN Removal error Status:#delDSN_result#" type="Warning" log="Application">
      </cfif>

      </cffunction>
      ****************************************************************************************** ******************************

        • 1. Re: onSessionEnd
          Daverms Level 3
          Hi,

          Can you post your "OnError" method's code here?.
          • 2. Re: onSessionEnd
            MMFranklin Level 1
            <cffunction name="onError" output="no" returnType="void">
            <cfargument name="exception" required="yes">
            <cfargument name="eventName" type="string" required="yes">

            <!--- Use the cflog tag to record info on the error --->
            <cfif arguments.eventName is "">
            <cflog type="Error" log="Application" text="#arguments.exception.message#">
            <cfelse>
            <cflog type="Error" log="Application" text="Error in Method [#arguments.eventName#] #arguments.exception.message#">
            </cfif>

            <!--- Let the <cferror> tags do their job. --->
            <cfthrow object="#arguments.exception#">

            </cffunction>

            Thanks Dave