UPDATE:
After a chat with Henrik and much trial and error beforehand I have reached a solution.
Here is a link to a solved question I posted on StackOverflow about not being able to reach the string values inside each task's property:
http://stackoverflow.com...of-propertyinfo-getvalue And here is my code that covers resetting the property values. The key here after the SetValue() is called is that serverObj.Jobs.Update() and serverObj.Jobs.Tasks.Update() are called. This code is probably super-inefficient, but speed isn't key in my particular case so this works for me. Improve it if you know how.
Dim count As Integer = 0
Dim strAdd As String = ""
For Each t As VisualCronAPI.Server In vcClient.Servers.GetAll()
For Each f As VisualCron.JobClass In t.Jobs.GetAll
For Each s As VisualCron.TaskClass In f.Tasks
Dim propVal As Object
Dim propInfo As PropertyInfo() = s.GetType().GetProperties()
For i As Integer = 0 To propInfo.Length - 1
With propInfo(i)
If s.TaskType.ToString = propInfo(i).Name.ToString Then
Dim asm As Assembly = Assembly.Load("VisualCron")
Dim typeName As String = String.Format("VisualCron.{0}", propInfo(i).PropertyType.Name)
Dim tp As Type = asm.GetType(typeName)
Dim classInst As Object = Activator.CreateInstance(tp)
Dim classProps As PropertyInfo() = classInst.GetType().GetProperties()
For h As Integer = 0 To classProps.Length - 1
With classProps(h)
If .GetIndexParameters().Length = 0 Then
propVal = .GetValue(CallByName(s, propInfo(i).Name.ToString, [Get]), Nothing)
If Not propVal Is Nothing Then
If propVal.ToString.ToUpper.Contains("\\SERVER\") Then
tp.GetProperty(classProps(h).Name.ToString).SetValue(CallByName(s, propInfo(i).Name.ToString, [Get]), "\\NEW_PATH\", Nothing)
t.Jobs.Update(f)
t.Jobs.Tasks.Update(s)
End If
End If
End If
End With
Next
End If
End With
Next
Next s
Next f
Next t
Sorry about no syntax highlighting... it keeps screwing up and cutting off the top half of my code.
Edited by user
2012-12-03T16:39:45Z
|
Reason: Not specified