Pārlūkot izejas kodu

Neue Idee für Portal-Aktualisierung.

- Bei Reisacher getestet und leider weiterhin Problem mit Anmeldung
Global Cube 2 gadi atpakaļ
vecāks
revīzija
c45996ad8c

+ 93 - 61
gctools/VBS/publish-reports.mac

@@ -1,71 +1,103 @@
-Dim objApp As Object
 Dim objRep As Object
 Dim objRep As Object
-Dim folder as String
+Dim objPDF as Object
+
+Dim configFile as String
 Dim publish As String
 Dim publish As String
+
+Dim Debug As Integer
+
+Dim reportFile As String
 Dim exportFormat As String
 Dim exportFormat As String
+Dim layers As String
+
+Declare Sub ReportExport   
+
 
 
 Sub Main ()
 Sub Main ()
+   Debug = 1
    Rem On Error Resume Next
    Rem On Error Resume Next
-   Set objApp = CreateObject("CognosPowerPlay.Application")
+   If Debug = 1 Then
-   rem folder = "C:\GAPS\Portal\System\Report"
+      configFile = "C:\Projekte\Python\gctools\config\Reports.csv"
-   rem exportFormat = "pdf"
+      publish = "C:\GAPS\Portal\daten"
-   rem publish = "C:\GAPS\Portal\daten"
+   Else
+      configFile = GetField(Command, 1, ",")
+      publish = GetField(Command, 2, ",")
+   End If
+
    
    
-   folder = GetField(Command, 1, ",")
+   Dim lineStr As String
-   exportFormat = GetField(Command, 2, ",")
+   Dim reportFile As String
-   publish = GetField(Command, 3, ",")
+   Dim exportFormat As String
+   Dim layers As String
+      
+   Open configFile For Input As #1
+      Do While Not EOF(1)
+         Line Input #1, lineStr 
+         reportFile = GetField(lineStr, 1, ";")
+         exportFormat = GetField(lineStr, 2, ";")
+         layers = GetField(lineStr, 3, ";")
+         Print reportFile, exportFormat
+         Call ReportExport
+
+      Loop
+   Close #1
+End Sub
 
 
-   Dim filename as String
+
+Sub ReportExport   
+   ' reportFile, exportFormat, layers as Parameters
    Dim exportFile as String
    Dim exportFile as String
-   Dim objPDF as Object
+   Dim layer as String
-   
+   Dim layerInt as Integer
-   filename = Dir(folder + "\")
+
-
+   Set objRep = CreateObject("CognosPowerPlay.Report")
-   Do While filename <> ""
+   objRep.Open(folder + "\" + reportFile)
-      If LCase(Right(filename, 4)) = ".ppr" Or LCase(Right(filename, 4)) = ".ppx" Then
+   exportFile = publish + "\" + Left(reportFile, Len(reportFile) -4)
-         Set objRep = CreateObject("CognosPowerPlay.Report")
+   Select Case exportFormat
-         objRep.Open(folder + "\" + filename)
+      Case "pdf"         
-         exportFile = publish + "\" + Left(filename, Len(filename) -4)
+         Set objPDF = objRep.PDFFile(exportFile + "_0.pdf", True)
-         Select Case exportFormat
+         With objPDF
-            Case "pdf"
+            .SaveEntireReport = True
-               
+            .AxisOnAllPages = True
-               Set objPDF = objRep.PDFFile(exportFile + "_0.pdf", True)
+            .ChartTitleOnAllPages = False
-               With objPDF
+            .IncludeLegend = False
-                  .SaveEntireReport = True
+         End With
-                  .AxisOnAllPages = True
+         objPDF.Save
-                  .ChartTitleOnAllPages = False
+
-                  .IncludeLegend = False
+         For i = 1 To 255
-               End With
+            layer = GetField(layers, i, ",")
-               objPDF.Save
+            If layer = "" Then
-
+               Exit For
-               For i = 1 to objRep.Layers.Count
+            End If
-                  Set objPDF = objRep.PDFFile(exportFile + "_" + i + ".pdf", True)
+            layerInt = Val(layer)
-                  With objPDF
+            If layerInt > objRep.Layers.Count Then
-                     .SetListOfLayersToSave objRep.Layers.Subset(i, i)
+               Exit For
-                     .SetListOfRowsToSave objRep.Rows
+            End If
-                     .SaveEntireReport = False
+
-                     .SaveAllCharts = False           
+            Set objPDF = objRep.PDFFile(exportFile + "_" + layer + ".pdf", True)
-                     .AxisOnAllPages = True
+            With objPDF
-                     .ChartTitleOnAllPages = True
+               .SetListOfLayersToSave objRep.Layers.Subset(layerInt, layerInt)
-                     .IncludeLegend = True
+               .SetListOfRowsToSave objRep.Rows
-                  End With
+               .SaveEntireReport = False
-                  objPDF.Save
+               .SaveAllCharts = False           
-               Next
+               .AxisOnAllPages = True
-
+               .ChartTitleOnAllPages = True
-            Case "asc"
+               .IncludeLegend = True
-               objRep.SaveAs exportFile, 3
+            End With
-            Case "xls"
+            objPDF.Save
-               objRep.SaveAs exportFile, 4
+         Next
-            Case "ppx"
+
-               objRep.SaveAs exportFile, 5
+      Case "asc"
-            Case Else
+         objRep.SaveAs exportFile, 3
-               objRep.Publish publish, False, True, True    
+      Case "xls"
-         End Select
+         objRep.SaveAs exportFile, 4
-         objRep.Close
+      Case "ppx"
-      End if
+         objRep.SaveAs exportFile, 5
-
+      Case Else
-
+         objRep.Publish publish, False, True, True    
-      filename = Dir
+   End Select
-   Loop
+   objRep.Close
-   objApp.Quit
+   Set objRep = Nothing
+
 End Sub
 End Sub
+

BIN
gctools/VBS/publish-reports.mcx


+ 2 - 0
gctools/config/Reports.csv

@@ -0,0 +1,2 @@
+Test;pdf;1,2,3,4
+Test2;xls;2,3,4