*
* Imports
import sys
import importlib
sys.path.append(“C:\PPConfig\Scripts”)
u = importlib.import_module(“util”)
*
* Register job in db
util = u.Util(Watch, Script)
dbConnection = util.dbConnection
dbCursor = util.dbCursor
try:
# register job
dbCursor.execute(
“”“INSERT INTO [dbo].[job] ([j_is_finished_ok],[j_created_at],[j_updated_at],[j_input_channel],[j_input_file_url],[j_input_file_owner]) OUTPUT INSERTED.[j_id] VALUES (0,sysdatetime(),sysdatetime(),?,?,?)”“”,
(“none”, “none”, “PP Workflow”),
)
# get uid from db (autoincrement PK)
dbCursor.execute(“SELECT @@IDENTITY AS ID;”)
id = dbCursor.fetchone()[0]
dbConnection.commit()
# create job step
dbCursor.execute(
“”“INSERT INTO [dbo].[job_processed_step] ([jps_j_id],[jps_created_at],[jps_is_finished_ok],[jps_step_name],[jps_remarks]) VALUES (?,sysdatetime(),1,?,?)”“”,
(id, “createGuid”, “none”),
)
dbConnection.commit()
mailingId = str(id)
Script.ReturnValue = 1
except Exception as ex:
Watch.Log("DB dbConnection issue: " + ex.args[1], 2)
Script.ReturnValue = 0
Watch.Log(“TEST1”,2)
Watch.SetVariable(“mailingId”, mailingId)
Watch.SetJobInfo(1, mailingId)
Watch.SetJobInfo(2, “Error 12345”)
Watch.Log(“TEST2”,2)
raise Exception(“Helaas”)
Watch.Log(“TEST3”,2)