public OpenJobOnRemoteData( AgentJob NewJob, RemoteConnection NewRemote ) { Job = NewJob; Remote = NewRemote; }
/// <summary> /// Remove a job from the collection.</summary> public void Remove(AgentJob job) { List.Remove(job); }
/////////////////////////////////////////////////////////////////////////// private Int32 OpenJob_1_0( Int32 ConnectionHandle, Hashtable InParameters, ref Hashtable OutParameters ) { StartTiming( "OpenJob_1_0-Internal", true ); Int32 ErrorCode = Constants.INVALID; Connection JobOwner; if( Connections.TryGetValue( ConnectionHandle, out JobOwner ) ) { Debug.Assert( ( JobOwner.Job == null ) || ( JobOwner.Job.CurrentState == AgentJob.JobState.AGENT_JOB_CLOSED ) ); // Unpack the input parameters AgentGuid JobGuid = InParameters["JobGuid"] as AgentGuid; // Check for any other Jobs running if( ActiveJobs.Count > 0 ) { foreach( AgentJob Job in ActiveJobs.Values ) { // If any remote jobs are running, we'll kill them if( Job.Owner is RemoteConnection ) { // We need to close this connection, which should quit the job and release all associated resources Log( EVerbosityLevel.Verbose, ELogColour.Green, "[OpenJob] Interrupting remote job in favor of local one" ); Hashtable OwnerInParameters = null; Hashtable OwnerOutParameters = null; CloseConnection( Job.Owner.Handle, OwnerInParameters, ref OwnerOutParameters ); } else { Debug.Assert( Job.Owner is LocalConnection ); // TODO: By allowing multiple local jobs to run, we expose // limitations in the visualizer that cause it to do some odd // things like assuming that all messages are referring to the // same job (and thus easily confused) } } } // Ensure that the folders we need are there string JobsFolder = Path.Combine( AgentApplication.Options.CacheFolder, "Jobs" ); ErrorCode = EnsureFolderExists( JobsFolder ); if( ErrorCode >= 0 ) { // For the Job-specific folder, if it's already there, clean it out; // we need to be sure to start every Job with an empty Job folder string JobSpecificFolder = Path.Combine( JobsFolder, "Job-" + JobGuid.ToString() ); ErrorCode = DirectoryRecreate( JobSpecificFolder ); if( ErrorCode >= 0 ) { // Create the new Job object and initialize it via the OpenJob method AgentJob NewJob = new AgentJob( this ); NewJob.OpenJob( JobOwner, JobGuid ); Log( EVerbosityLevel.Informative, ELogColour.Green, "[Job] Accepted Job " + JobGuid.ToString() ); ErrorCode = Constants.SUCCESS; } } // Check for errors from above if( ErrorCode < 0 ) { Log( EVerbosityLevel.Critical, ELogColour.Red, "[Job] OpenJob: Rejected, unable to create necessary directories" ); ErrorCode = Constants.ERROR_JOB; } } else { Log( EVerbosityLevel.Critical, ELogColour.Red, "[Job] OpenJob: Rejected, unrecognized connection" ); ErrorCode = Constants.ERROR_CONNECTION_NOT_FOUND; } StopTiming(); return ErrorCode; }
/// <summary> /// Add a job to the collection.</summary> public void Add(AgentJob job) { List.Add(job); }