Hi Folks.
I have inherited some code which programmatically creates jobs and adds notifications. The code was written using VC API v6.x.x but having upgraded to VC API v7.x.x it will no longer compile. I realise that the way VC handles notifications has changed but I cannot find anywhere explaining how to do this programmatically.
The original code is shown below -
NotificationClass nc = job.NewNotification(NotificationClass.NType.SQL);
nc.Description = functionDisplay + descriptionPostfix;
nc.SQL.ConnectionId = sqlCon.Id;
nc.SQL.CommandType = System.Data.CommandType.Text;
string userId = new User(DB, Configuration.system).id;
if (type.Equals("ERROR"))
nc.SQL.Command = "spSysErrorInsert " + userId + "," + functionId.ToString() + "," + DB.WrapValue(Environment.MachineName) + "," + DB.WrapValue("VisualCron") + "," + DB.WrapValue("Execution Error") + "," + DB.WrapValue("Check VisualCron Logs") + ",null,null,null,null,null";
else
nc.SQL.Command = "spSysActivityInsert " + userId + "," + functionId.ToString() + ",null," + DB.WrapValue(type) + "," + DB.WrapValue(type.Substring(0, 1) + type.Substring(1).ToLower()) + ",null,null,null,null,null";
//Add to notification server
server.Notifications.Add(nc);
//Attach notification to event based on passed type
if (type.Equals("START"))
job.StartNotifications.Add(nc.Id);
else if (type.Equals("END"))
job.CompleteNotifications.Add(nc.Id);
else if (type.Equals("ERROR"))
job.ErrorNotifications.Add(nc.Id);
This line now fails - server.Notifications.Add(nc);
I cannot work out how to create a TaskNotificationClass which seems to have replaced the NotificationClass.
All help greatly appreciated!!
Regards.
John
Edited by moderator
2015-04-24T05:42:35Z
|
Reason: Not specified