Browse Source

c11 mdlconvert

gc-server3 1 năm trước cách đây
mục cha
commit
42f76e52f3
5 tập tin đã thay đổi với 46 bổ sung2 xóa
  1. 13 0
      c11.py
  2. 4 0
      cognos11/c11_api.py
  3. 27 0
      cognos7/VBS/save-as_mdl.mac
  4. 2 2
      cognos7/mdl_convert.py
  5. BIN
      dist/c11.exe

+ 13 - 0
c11.py

@@ -1,6 +1,9 @@
+import os
+from pathlib import Path
 import config
 import cognos11
 from pdf import pdf_merge, pdf_test
+import cognos7.mdl_convert
 import typer
 from enum import Enum
 
@@ -61,5 +64,15 @@ def mailtemplate():
     return template()
 
 
+@app.command()
+def mdlconvert(mdl_file):
+    cognos7.mdl_convert.convert_file(mdl_file)
+    source = mdl_file[:-4] + ".json"
+    target = cfg.cognos11.specs_dir + "/../DataModel/" + Path(source).name
+    os.makedirs(os.path.dirname(target), exist_ok=True)
+    Path(target).unlink(missing_ok=True)
+    os.rename(source, target)
+
+
 if __name__ == "__main__":
     app()

+ 4 - 0
cognos11/c11_api.py

@@ -381,6 +381,10 @@ class c11_api:
         r = self.session.post(
             self.webservice + "v1/reports/unstubreport", data=payload, headers=headers
         )
+        if r.status_code != 200:
+            logging.error(f"{report['path']}/{report['name']}")
+            logging.error(r.text)
+            return
         unstubbed = json.loads(r.text)["reportspec_full"]
         unstubbed = re.sub(r' iid="[^"]*"', "", unstubbed)
 

+ 27 - 0
cognos7/VBS/save-as_mdl.mac

@@ -0,0 +1,27 @@
+Dim objApp As Object
+Dim objModel As Object
+Dim objCube As Object
+
+Dim filename as String
+Dim folder as String
+Dim publish As String
+
+
+Sub Main ()
+   Rem On Error Resume Next
+
+   rem folder = "C:\GAPS\Portal\System\Models"
+   rem filename = "belege.mdc"
+   rem publish = "C:\GAPS\Portal\System\Cube_out\temp"
+   
+   folder = GetField(Command, 1, ",")
+   filename = GetField(Command, 2, ",")
+   
+   Set objApp = CreateObject("IBMCognosTransformer.ApplicationCtrl.1")
+   Set objModel = objApp.OpenModel(folder + "\" + filename + ".pyj")
+
+   objModel.SaveAs(folder + "\mdl\" + filename + ".mdl")
+   
+   objModel.Close
+   objApp.Quit
+End Sub

+ 2 - 2
cognos7/mdl_convert.py

@@ -307,11 +307,11 @@ def convert_file(filename):
 
 def convert_folder(base_dir):
     files = sorted([(f.stat().st_mtime, f) for f in Path(base_dir).rglob("*.mdl")])
-    for timestamp, filename in files:
+    for _, filename in files:
         convert_file(str(filename))
 
 
 if __name__ == "__main__":
     # convert_file("data/S_Offene_Auftraege.mdl")
     # convert_file("data/F_Belege_SKR_SKR_Boettche.mdl")
-    convert_folder("data/")
+    convert_folder("data/mdl/")

BIN
dist/c11.exe