Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Job Tracker in Net API Model
Hiral
We are trying to use CreateJobTracker, StartJobTracker and AddJobToTracker methods of session object in Net model.
We are doing everything exactly as it is mentioned in API.
It errors out in mbpNetModel.dll. It gives us following error:
------------------------------------------------------------------------------------------------------------------------------------
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mbpnetmodel.dll
Additional information: Error processing a request/reply from the client.
-------------------------------------------------------------------------------------------------------------------------------------
We must need a way to track a status of job in a multi threading way. Please get back with us on this issue.
If you are able to use the job tracker functionality with out any issue, please provide us with a working example of that.
Thank You,
Hiral Kanaiya
Find more posts tagged with
Comments
msnider
Yes, I am successfully using the Job Tracker methods. Can you send a snippet of your code?
Thanks,
Mark
Hiral
Private mbJobTracker As New System.EventHandler(AddressOf jobTracking)
Public Sub jobTracking(ByVal sender As Object, ByVal e As EventArgs)
Try
MsgBox("Job Is Finished: " & CType(e, MBPNetModel.JobEventArgs).JobID.Trim & "--" & CType(e, MBPNetModel.JobEventArgs).Filename)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim netSession As New MBPNetModel.MediaBinServer("aim-dev-svr", "32456", "VAL", "userName", "Password")
Dim a, b, c As Boolean
Dim strJobID As String
Try
a = netSession.CreateJobTracker(mbJobTracker)
c = netSession.StartJobTracker
strJobID = job guid ‘assign job guid here.
b = netSession.AddJobToTracker(strJobID)
Catch ex As Exception
MsgBox(ex.Message)
Finally
End Try
End Sub
Hiral
Could you please provide me with some example of it. I have provided my code snippet.
Thank You.
msnider
What are you passing in as strJobID? It should be a valid job id returned from either the InsertAsset or RetrieveFile methods. For example,
strJobID = netSession.RetrieveFile( strAssetId, -1, strTaskID, null, strOutputPath, false );
Hiral
Yes, I am passing valid job id
strJobID = .InsertFileExternal(strSourcePath, task)
It inserts my asset fine and returns valid job id. It performs all other functions fine in the mediabin. fails in the jobtracker thread. Please help.
If you could provide your code snippet that would be great too.
thank you.
Hiral
msnider
InsertFileExternal is not exposed thru the MBPNetModel interface. The only way to access that method is from the MBPSCRIPTMODEL2Lib.MBContainer which can be obtained thru the MBPNetModel.MediaBinSession object. Can you send me your complete code listing?
Here is some sample code using just the MBPNetModel interface:
private void Start()
{
mMediaBinServer = new MBPNetModel.MediaBinServer( mServerName, mPort, mDomain, mUsername, mPassword );
//Create a job tracker thread
System.EventHandler callback = new System.EventHandler( this.JobDone );
if( mMediaBinServer.CreateJobTracker( callback ) )
mMediaBinServer.StartJobTracker();
}
private void Stop()
{
mMediaBinServer.StopJobTracker();
}
private void RetrieveFile()
{
try
{
string jobID = mMediaBinServer.RetrieveFile( mAssetID, -1, mTaskID, null, mPath, false );
if( jobID != null && jobID != "" )
mMediaBinServer.AddJobToTracker( jobID );
}
catch(Exception e)
{
WebForm2.mMsg = e.Message;
}
}
private void JobDone( object sender, EventArgs e)
{
MBPNetModel.JobEventArgs eventArgs = (MBPNetModel.JobEventArgs) e;
string msg = "Status:\t";
string file = Path.GetFileName( eventArgs.Filename );
switch( eventArgs.JobState )
{
case MBPNetModel.MBObjects.MBJobState.JobComplete:
msg += "Success. " + file + " job completed.";
break;
case MBPNetModel.MBObjects.MBJobState.JobCanceled:
msg += "Error. " + file + " job canceled.";
break;
case MBPNetModel.MBObjects.MBJobState.JobFailed:
msg += "Error. " + file + " job failed.";
break;
default:
msg = "Error. " + file + " unknown job state.";
break;
}
if( eventArgs.JobMessage != String.Empty )
msg += eventArgs.JobMessage;
WebForm2.mMsg = msg;
}
Hiral
My file inserts fine. it creates job in active jobs. It completes job and as soon as it completes job instead of going to jobTracking sub routine it pops up the error:
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mbpnetmodel.dll
Additional information: Error processing a request/reply from the client."
and breaks out.
Private callback As New System.EventHandler(AddressOf Me.jobTracking)
Private Sub jobTracking(ByVal sender As Object, ByVal e As EventArgs)
Try
MsgBox("Job Is Finished: " & CType(e, MBPNetModel.JobEventArgs).JobID.Trim & "--" & CType(e, MBPNetModel.JobEventArgs).Filename)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Function InsertReviseExternalFiles(ByVal strSourcePath As String, ByVal ContainerID As String) As String
Dim session As New MBPSCRIPTMODEL2Lib.MBSession
Dim container As MBPSCRIPTMODEL2Lib.MBContainer
Dim Asset As MBPSCRIPTMODEL2Lib.MBAsset
Dim task As MBPSCRIPTMODEL2Lib.MBRunTaskClass
Dim strJobID As String
Try
With session
If .IsLoggedOn = False Then
.Logon("aim-dev-svr", "val", "kanaiyah", "Blessings1*")
End If
container = .GetContainer(ContainerID)
task = .GetNullInsertionTask.CreateRunTask
End With
With container
Asset = .CheckInsertFileConflicts(strSourcePath)
If Asset Is Nothing Then
strJobID = .InsertFileExternal(strSourcePath, task)
Else
'revision object use external revise file
If Not Asset.IsLocked Then
Asset.LockObject()
End If
strJobID = Asset.ReviseFileExternal(strSourcePath, task)
End If
End With
Return strJobID
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Function
Public Sub TestJobTracker()
Dim netSession As New MBPNetModel.MediaBinServer("correct configurations*")
Dim strJobID As String
Try
lblStartTime.Text = Now()
Cursor.Current = Cursors.WaitCursor
If netSession.CreateJobTracker(callback) Then 'mbJobTracker
netSession.StartJobTracker()
End If
strJobID = InsertReviseExternalFiles("FilePathFrom network", "{6B3261DF-8113-4274-9CED-5D8F824E231F}")
If strJobID <> Nothing Then
netSession.AddJobToTracker(strJobID)
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
Cursor.Current = Cursors.Default
lblEndTime.Text = Now()
End Try
End Sub
msnider
The problem is that you are trying to use two different connections to MediaBin each of which maintains its own internal cache of MediaBin objects...in this case the job objects.
The namespace MBPNetModel is essentially a wrapper around the namespace MBPSCRIPTMODEL2Lib. Anything that is available in the MBPSCRIPTMODEL2Lib namespace but is not exposed in MBPNetModel, such as InsertFileExternal, can be accessed thru MBPNetModel.MediaBinSession
Therefore to fix the problem you are having, you should not create a new MBPSCRIPTMODEL2Lib.MBSession in InsertReviseExternalFiles but instead pass netSession.MediaBinSession in as an argument. Your code will become:
Private callback As New System.EventHandler(AddressOf Me.jobTracking)
Private Sub jobTracking(ByVal sender As Object, ByVal e As EventArgs)
Try
MsgBox("Job Is Finished: " & CType(e, MBPNetModel.JobEventArgs).JobID.Trim & "--" & CType(e, MBPNetModel.JobEventArgs).Filename)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Public Function InsertReviseExternalFiles(ByVal strSourcePath As String, ByVal ContainerID As String, ByVal session As MBPSCRIPTMODEL2Lib.MBSession) As String
Dim container As MBPSCRIPTMODEL2Lib.MBContainer
Dim Asset As MBPSCRIPTMODEL2Lib.MBAsset
Dim task As MBPSCRIPTMODEL2Lib.MBRunTaskClass
Dim strJobID As String
Try
With session
container = .GetContainer(ContainerID)
task = .GetNullInsertionTask.CreateRunTask
End With
With container
Asset = .CheckInsertFileConflicts(strSourcePath)
If Asset Is Nothing Then
strJobID = .InsertFileExternal(strSourcePath, task)
Else
'revision object use external revise file
If Not Asset.IsLocked Then
Asset.LockObject()
End If
strJobID = Asset.ReviseFileExternal(strSourcePath, task)
End If
End With
Return strJobID
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Function
Public Sub TestJobTracker()
Dim netSession As New MBPNetModel.MediaBinServer("correct configurations*")
Dim strJobID As String
Try
lblStartTime.Text = Now()
Cursor.Current = Cursors.WaitCursor
If netSession.CreateJobTracker(callback) Then 'mbJobTracker
netSession.StartJobTracker()
End If
'We need to make this connection persistent and initialize the underlying
'MediaBin ScriptModel session before we use any objects from
'the MBPSCRIPTMODEL2Lib namespace.
netSession.OkToLogoff = False
netSession.GetMediaBinServerName()
strJobID = InsertReviseExternalFiles("FilePathFrom network", "{6B3261DF-8113-4274-9CED-5D8F824E231F}", netSession.MediaBinSession)
If strJobID <> Nothing Then
netSession.AddJobToTracker(strJobID)
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
Cursor.Current = Cursors.Default
lblEndTime.Text = Now()
End Try
End Sub
Also, you may want to consider making netSession a class member variable so that it doesn't go out of scope.
Mark
Hiral
It worked ! Thank You so much !