Actuateclub.com

 

  About Actuate   |   Forums   |   Message Board  |   FAQ   |   Jobs    |   Actuate 100   |   Guest Book  |   Feedback  |   Sitemap   |   Home

Techieindex

 
Write Report details to a database

Description :
 
Writing report details into a database

Report Logic :

This report design is used for writing data to a database. The following code is in the finish report method of root section. Finish report method is executed at the end of report execution. In this method all the report Variables & report parameter will be available.

This following code below is used in a report to record the report details to a database. By analyzing the information from the database, we can get the following. The number reports run, parameters used to run the report, rox name, roi name, server name, server username, time took to run the report, etc… Even we can get the number of rows got from the sql also.

Sub FinishReport( )
  Super::FinishReport( )

  Dim stmt As AcDBStatement
  Dim queryStatement As String
  Dim DBMSFields As String
  Dim DBMSValues As String
  Dim newConnection As Con_repd
  Dim msgString As String
  Dim pageCount As Integer
  Dim intAppContent As Integer
  Dim AFCROXVersion As String
  Dim ROXVersion As String
  Dim FactoryVersion As String
  Dim ServerName As String
  Dim ServerUserName As String
  Dim OSUserName As String
  Dim totalWallTime As Integer
  Dim HLString As String 
  Dim RelationId As String
  Dim StartDate As String
  Dim EndDate As String
  Dim IntervalDays As Integer
  Dim LastweekDate As String 
  Dim LastmonthDate As String
  Dim YesterDate As String
  Dim RowNumbers As Integer 
  Dim DiskSpace As Integer 

  IF Brpt::psRelationshipID <> "" THEN
      RelationId = Brpt::psRelationshipID
  ELSE
     RelationId = " "
                  End If


If Brpt::StatisticsSwitch = "True" Then

     StartDate = BrsWithDateRange::psDate1
     EndDate = BrsWithDateRange::psDate2
     lastweekDate = BrsWithDateRange::ps0DateRangeOption2
     lastmonthDate = BrsWithDateRange::ps0DateRangeOption3 
     Yesterdate = BrsWithDateRange::ps0DateRangeOption1 

  If Startdate <> EndDate Then
      IntervalDays = DateDiff("d", StartDate, EndDate)
  Else
   IntervalDays = 1
  End IF
                            
 If lastweekDate = "y" Then
    IntervalDays = 7
 End If

 If LastmonthDate = "y" Then
    IntervalDays = 31
 End If 

  If YesterDate = "y" Then
      IntervalDays = 1
  End If 

 Rownumbers = BrsWithDateRange::RowCountInt
  ' DiskSpace = Filelen(Roifilename)

 IF HLString = "" THEN
     HLString = " No hierarchy is used"
 End IF
                            
 Dim psUserId as String

 IF Brpt::psUserId <> "" THEN
     psUserId = Brpt::psUserId
 ELSE
   psUserId = " "
 End If
   pageCount = pgcount
 

  'Set the connection since it is not available here to write the both the ActuateResults
  'and the ReportStatistics tables

  Set newConnection = New con_repd
  newConnection.connect

  If newConnection.IsOpen Then

  'Set the variables that we will use to write back to our ActuateResults table

  ' totalWallTime = Timer - reportStartTime
    ReportStopDateInfo = CVDate(Now)
    totalWallTime = DateDiff("s", ReportStartDateInfo, ReportStopDateInfo)
    intAppContent = GetAppContext
    AFCROXVersion = GetAFCROXVersion(0) & "." & GetAFCROXVersion(1)
    FactoryVersion = GetFactoryVersion(0) & "." & GetFactoryVersion(1)
    ROXVersion = GetROXVersion(0) & "." & GetROXVersion(1)
    ServerName = GetServerName
 If ServerName = "" Then
    ServerName = " "
 End If
    ServerUserName = GetServerUserName
 If ServerUserName = "" Then
    ServerUserName = " "
End If

   OSUserName = GetOSUserName
 If OSUserName ="" Then
    OSUserName = " "
                      End If

# Note  : In front of each field allows a substitution to 'take place. since offices city for example is equal to NY its value is automatically substituted for the offices city string in the DBMS values ' variable.' this method is for trimming  the rox & roi names into the table
Dim temproinames as string
Dim temproxnames as string
Dim tempholder,folderdst,rox,roi as string

folderdst = "/"
rox = "rox"
roi = "roi"
dim s1,e1 as integer
tempholder = roifilename
s1 = 1
do while s1 <> 0
     s1 = instr(tempholder,folderdst)
     e1 = instr(tempholder,roi)
     temproinames = mid(tempholder, s1+1,e1 + 2)
     tempholder = temproinames
 loop
 temproinames = tempholder
  s1 = 1
  tempholder = RoxFilename
do while s1 <> 0
      s1 = instr(tempholder,folderdst)
      e1 = instr(tempholder,rox)
      temproxnames = mid(tempholder, s1+1,e1 + 2)
      tempholder = temproxnames
loop
  temproxnames = tempholder
' some time instead of folder name rotp: may appear
' for that case the following code is applied

  folderdst = "rotp"
  s1 = instr(temproxnames,folderdst)
  IF s1 <> 0 Then
    s1 = instr(temproxnames,folderdst)
    temproxnames = mid(temproxnames, s1+3,e1 + 2)
  End If

   s1 = instr(temproinames,folderdst)
 IF s1 <> 0 Then
   s1 = instr(temproinames,folderdst)
    temproinames = mid(temproinames, s1+3,e1 + 2)
End IF

DBMSFields = " (ReportUserId"
                           +& ",GenerationType"
                           +& ",AFCROXVersion"
                           +& ",FactoryVersion"
                           +& ",ROXVersion"
                           +& ",ServerName"
                           +& ",ServerUserName"
                           +& ",OSUserName"
                           +& ",PageCount"
                           +& ",StartTime"
                           +& ",EndTime"
                           +& ",TotalWallClock"
                           +& ",RoxFileName"
                           +& ",RoiFileName"
                           +& ",NumberOfRows"
                           +& ",DateInterval"
                           +& ",Rltnshp_Id"
                           +& ",Hier_Branch"
                           +& ",DiskSize)"


      DBMSValues = " values(:psUserId"
                          +& ",:intAppContent"
                          +& ",:AFCROXVersion"
                          +& ",:FactoryVersion"
                          +& ",:ROXVersion"
                          +& ",:ServerName"
                          +& ",:ServerUserName"
                          +& ",:OSUserName"
                          +& ",:pageCount"
                          +& ",:ReportStartDateInfo"
                          +& ",:ReportStopDateInfo"
                          +& ",:totalWallTime"
                          +& ",:temproxnames"
                          +& ",:temproinames"
                          +& ",:RowNumbers"
                          +& ",:IntervalDays"
                          +& ",:RelationId"
                          +& ",:HLString"
                          +& ",:Diskspace)"      
queryStatement = "Insert into Actuate_Results " & DBMSFields & DBMSValues
Set stmt = newConnection.Prepare(queryStatement)

  If stmt Is Nothing Then
            ShowFactoryStatus("Failed to prepare the statement")
            ' MsgBox NEWconnection.GetSpecificErrorText( )
  Exit Sub
  End If

        ' bind the datarow values to the stmt : variables

         stmt.BindParameter(1,psUserId)
         stmt.BindParameter(2,intAppContent)
         stmt.BindParameter(3,AFCROXVersion)
         stmt.BindParameter(4,FactoryVersion)
         stmt.BindParameter(5,ROXVersion)
         stmt.BindParameter(6,ServerName)
         stmt.BindParameter(7,ServerUserName)
         stmt.BindParameter(8,OSUserName)
         stmt.BindParameter(9,pageCount)
         stmt.BindParameter(10,ReportStartDateInfo)
         stmt.BindParameter(11,ReportStopDateInfo)
         stmt.BindParameter(12,totalWallTime)
         stmt.BindParameter(13,temproxnames)
         stmt.BindParameter(14,temproinames)
         stmt.BindParameter(15,RowNumbers)
         stmt.BindParameter(16,IntervalDays)
         stmt.BindParameter(17,RelationId)
         stmt.BindParameter(18,HLString)
         stmt.BindParameter(19,DiskSpace)


If Not stmt.Execute Then
   ' msgbox "Unable to insert data row into the ActuateResults table"
    ShowFactoryStatus("Unable to insert data row into the        ActuateResults table")
End If

DIM queryStatement1 AS STRING
Dim stmt1 As AcDBStatement
        queryStatement1 = "COMMIT"
        SET STmt1 = newConnection.Prepare(queryStatement1)
        ShowFactoryStatus("Inserting Statistics Information")
If Not stmt1.Execute Then
        ShowFactoryStatus("Unable to insert data row into the ActuateResults table")
       ' msgbox "Unable to insert data row into the ActuateResults table"
End If
    ' STMT1.EXECUTE()
Else
   ShowFactoryStatus("Failed to perform DataBase connection")
' MsgBox "Failed to perform DataBase connection" & Chr$(10)
'+& newConnection.GetSpecificErrorText()
End If
End If
   ' Insert your code here
End Sub
 

 

 

Copyright © 2008 Techieindex