/// <summary> /// This virtual method resets the base properties for the JobWrapper. /// </summary> public override void Reset() { mBaseJob = null; mRSCallback = null; mProgressCallback = null; timeoutCallback = null; ObjectPool = null; }
public SessionJob JobGet(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobSignature? signature, JobPriority priority) { if (delSessionJobReturn == null) throw new SecurityException("Not authenticated"); return delGetSessionJob(ID, jobID, data, RSCallback, ProgressCallback, signature, priority); }
/// <summary> /// This method initializes the SessionJob. /// </summary> /// <param name="sessionid">The session id.</param> /// <param name="id">The job id.</param> /// <param name="data">The envelope data to process.</param> /// <param name="RSCallback">The response call back delegate. This will /// be used to respond after the job is complete.</param> /// <param name="ProgressCallback">The progress call back delegate. /// This should be null if callbacks are not required.</param> /// <param name="signature">The job signature.</param> /// <param name="priority">The job priority.</param> public void Initialize( Guid sessionid, Guid id, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobSignature signature, JobPriority priority) { Job newJob = null; try { newJob = delJobGet(sessionid, id, data, null,null, signature, priority); mBaseJob=newJob as JobBase; mRSCallback = RSCallback; mProgressCallback = ProgressCallback; if (SynchRQ) signalComplete = new ManualResetEvent(false); } catch (Exception ex) { Reset(); if (newJob!=null) delJobReturn(newJob); throw ex; } }
/// <summary> /// Process a synchronous request. /// </summary> /// <param name="Data">The data.</param> /// <param name="priority">The request priority.</param> /// <param name="ProgressCallback">The progress calback delegate. /// This can be used to report progress during long running processes.</param> public void ProcessRequest(IXimuraRQRSEnvelope Data, JobPriority priority, CommandProgressCallback ProgressCallback) { RQRSFolder rq = Data.Request; if (rq != null && rq.Culture == null && this.SessionCulture != null) rq.Culture = this.SessionCulture; SessionJob job = ProcessRQAsyncInternal(Guid.NewGuid(), Data, null, ProgressCallback, priority); job.WaitForCompletion(); }
/// <summary> /// Process a synchronous request. /// </summary> /// <param name="data">The data.</param> /// <param name="priority">The request priority.</param> /// <param name="ProgressCallback">The progress calback delegate. /// This can be used to report progress during long running processes.</param> public void ProcessRequest(IXimuraRQRSEnvelope data, JobPriority priority, CommandProgressCallback ProgressCallback) { SecurityManagerJob scmJob = PrepareChildJob(Guid.NewGuid(), data, null, ProgressCallback, priority); IncrementChildJobCount(); token.JobProcess(scmJob as JobBase, false); }
/// <summary> /// This protected method is used to add a job to the collection. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <returns>The guid of the job queued.</returns> protected virtual Guid AddJob(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { //Create a new job holder. JobHolder jh = new JobHolder(jobID, data, RSCallback, ProgessCallback, priority); //We add the job to the queue as it will only be executed when the Execute() //command is called. lock (this) { WorkTable.Add(jh); Interlocked.Increment(ref jobRequests); #if (DEBUG) //System.Diagnostics.Debug.WriteLine("Inc: " + jobID.ToString() + " -> " + jobRequests.ToString()); #endif } return jobID; }
/// <summary> /// This overriden method adds a job to the collection. Jobs with a dependency ID will be /// queued behind earlier jobs with the same ID. /// </summary> /// <param name="newJobID">The job identifier.</param> /// <param name="data">The data.</param> /// <param name="RSCallback">The callback.</param> /// <param name="ProgressCallback">The progress callback.</param> /// <param name="priority">The job priority.</param> /// <param name="dependencyID">The dependency identifier.</param> /// <param name="ValidateRSCallBack"></param> /// <returns>The job ID.</returns> protected virtual Guid AddJob(Guid newJobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, string dependencyID, DependencyValidateRSCallback ValidateRSCallBack) { bool jobNotLinked = true; lock (this) { //Create the job holder object. JobHolder newJob = new JobHolder(newJobID, data, RSCallback, ProgressCallback, priority, null, null, ValidateRSCallBack); //OK, let's continue as normal. //Add the job. WorkTable.Add(newJob); if (dependencyID != null) { //Register the dependency job in the dependency tree. jobNotLinked = RegisterLinkedJob(dependencyID, newJobID); newJob.DependencyID = dependencyID; } Interlocked.Increment(ref jobRequests); if (JobShouldTrace) { string dependencyInfo = ""; if (dependencyID != null) { dependencyInfo = " Dependency: " + dependencyID + " " + (string)(jobNotLinked ? "Not Linked" : "Linked"); } JobTrace("-->" + jobRequests.ToString() + " CJ=" + CompletionJobID.ToString() + " Job=" + newJobID.ToString() + dependencyInfo); } } if (autoExecute && jobNotLinked) SubmitJob(newJobID); return newJobID; }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgressCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <param name="dependencyKey">The dependency key, if this is set to null the key is ignored.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsyncWithDependency(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, string dependencyKey) { return ProcessRequestAsyncWithDependency(jobID, data, RSCallback, ProgressCallback, JobPriority.Normal, dependencyKey, null); }
/// <summary> /// This is the internal constructor for the job. /// </summary> /// <param name="jobID">The job ID.</param> /// <param name="data">The data.</param> /// <param name="RSCallback">The request progress callback.</param> /// <param name="ProgressCallback">The request progress callback.</param> /// <param name="priority">The job priority.</param> /// <param name="NextJob">The next job for linked jobs.</param> /// <param name="LastJob">The last job for linked jobs.</param> public JobHolder(Guid? jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, Guid? NextJob, Guid? LastJob, DependencyValidateRSCallback ValidateRSCallBack) { mjobID = jobID; mPriority = priority; mData = data; mRSCallback = RSCallback; mProgressCallback = ProgressCallback; mNextJob = NextJob; mLastJob = LastJob; }
/// <summary> /// This method should be overriden to provide specific clean up code. /// Specifically, any delegates references in the object should be set to null; /// </summary> /// <param name="disposing">This parameter is true if the call is from the disposable interface.</param> public override void Reset() { mData = null; mRSCallback = null; mProgressCallback = null; }
/// <summary> /// This is the internal constructor for the job. /// </summary> /// <param name="jobID">The job ID.</param> /// <param name="data">The data.</param> /// <param name="RSCallback">The request progress callback.</param> /// <param name="ProgressCallback">The request progress callback.</param> /// <param name="priority">The job priority.</param> public JobHolder(Guid? jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority): this(jobID,data,RSCallback,ProgressCallback,priority,null,null, null){}
/// <summary> /// This protected method is used to add a job to the collection. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <returns></returns> protected override Guid AddJob(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { Guid id = base.AddJob(jobID, data, RSCallback, ProgessCallback, priority); IncrementChildJobCount(); return id; }
private SecurityManagerJob PrepareChildJob(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { Job childJob = delJobGet(SessionID.Value, jobID, data, null, null, JobSignature.Empty, priority); SecurityManagerJob newJob = delSecurityManagerJobGet( childJob as JobBase, this.token, this, RSCallback, ProgessCallback); AddJob(jobID, data, RSCallback, ProgessCallback, priority); return newJob; }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <returns>The job guid.</returns> public override Guid ProcessRequestAsync(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { SecurityManagerJob scmJob = PrepareChildJob(jobID, data, RSCallback, ProgessCallback, priority); token.JobProcess(scmJob as JobBase, true); return jobID; }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgressCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <returns>The job guid.</returns> public override Guid ProcessRequestAsync(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority) { return ProcessRequestAsyncWithDependency(jobID, data, RSCallback, ProgressCallback, priority, null); }
/// <summary> /// This is the root initialization for the JobWrapper. /// </summary> /// <param name="baseJob"></param> /// <param name="RSCallback"></param> /// <param name="ProgressCallback"></param> protected virtual void Inititialize(JobBase baseJob, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback) { mBaseJob = baseJob; mRSCallback = RSCallback; mProgressCallback = null; }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgressCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <param name="dependencyKey">The dependency key, if this is set to null the key is ignored.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsyncWithDependency(IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, string dependencyKey) { return ProcessRequestAsyncWithDependency(Guid.NewGuid(), data, RSCallback, ProgressCallback, priority, dependencyKey); }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate.</param> /// <param name="priority">The request priority.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsync(IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { Guid jobID = Guid.NewGuid(); ProcessRQAsyncInternal(jobID, data, RSCallback, ProgessCallback, priority); return jobID; }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgressCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <param name="dependencyKey">The dependency key, if this is set to null the key is ignored.</param> /// <param name="ValidateRSCallBack">The delegate should contain the code to validate the callback.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsyncWithDependency(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority, string dependencyKey, DependencyValidateRSCallback ValidateRSCallBack) { if (mStatus != CompletionJobStatus.Unset && mStatus != CompletionJobStatus.Submitting) throw new JobException("The CompletionJob has already started executing. Call Reset()."); return AddJob(jobID, data, RSCallback, ProgressCallback, priority, dependencyKey, ValidateRSCallBack); }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobid">The job id.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate.</param> /// <param name="priority">The request priority.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsync(Guid jobid, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { ProcessRQAsyncInternal(jobid, data, RSCallback, ProgessCallback, priority); return jobid; }
/// <summary> /// This method redirects any job requests without a dependency ID to this code with this callback. /// </summary> /// <param name="jobID">The job identifier.</param> /// <param name="data">The data.</param> /// <param name="RSCallback">The callback.</param> /// <param name="ProgessCallback">The progress callback.</param> /// <param name="priority">The job priority.</param> /// <returns>The job ID.</returns> protected override Guid AddJob(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { return AddJob(jobID, data, RSCallback, ProgessCallback, priority, null, null); }
/// <summary> /// This private method is used to process an asynchronous request. /// </summary> /// <param name="jobid">The job ID</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgressCallback">The request progress delegate.</param> /// <returns>The Session job object.</returns> /// <exception cref="Ximura.Server.SCMBaseException"> /// This method will throw a security exception on the calling thread /// you should be prepared to catch such an exception.</exception> private SessionJob ProcessRQAsyncInternal(Guid jobid, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback, JobPriority priority) { RQRSFolder rq = data.Request; //Set the culture if the session culture is set. if (rq != null && rq.Culture == null && this.SessionCulture != null) rq.Culture = this.SessionCulture; //TODO: Place the temporary user details here data.JobUserID = Guid.Empty; data.JobUserReferenceID = this.UserID; data.JobSecurityIdentifier = null; //Create a new session job. SessionJob newJob = delSessionJobGet(SessionID, jobid, data, RSCallback, ProgressCallback, CalcSig(jobid, data), priority); //We lock this critical section to ensure that the response //does not get processed before we have added the job to the job list. //If an exception is thrown we do not add the job to the collection. lock (sessionSyncObject) { try { //Add the job to the session list. JobAdd(newJob); //SessionJobList.Add(jobid, newJob); //Get the Security Manager to process the request. delSessionJobProcess(newJob as JobBase, true); } catch (SCMBaseException aex) { JobRemove(jobid); if (newJob != null) delSessionJobReturn(newJob); throw aex; } catch (Exception ex) { JobRemove(jobid); if (newJob != null) delSessionJobReturn(newJob); throw new SCMServerErrorException("Unexpected Security Verification Exception.", ex); } } return newJob; }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="jobID">The job ID. This should be set to a new Guid.</param> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <returns>The job guid.</returns> public abstract Guid ProcessRequestAsync(Guid jobID, IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority);
/// <summary> /// Process a synchronous request. /// </summary> /// <param name="Data">The data.</param> /// <param name="ProgressCallback">The progress calback delegate. /// This can be used to report progress during long running processes.</param> public void ProcessRequest(IXimuraRQRSEnvelope Data, CommandProgressCallback ProgressCallback) { ProcessRequest(Data, JobPriority.Normal, ProgressCallback); }
/// <summary> /// Process an asychronous request. /// </summary> /// <param name="data">The data</param> /// <param name="RSCallback">The call back completion delegate.</param> /// <param name="ProgessCallback">The request progress delegate. Set this to null if not needed.</param> /// <param name="priority">The request priority.</param> /// <returns>The job guid.</returns> public Guid ProcessRequestAsync(IXimuraRQRSEnvelope data, CommandRSCallback RSCallback, CommandProgressCallback ProgessCallback, JobPriority priority) { return ProcessRequestAsync(Guid.NewGuid(),data,RSCallback,ProgessCallback, priority); }
/// <summary> /// This method initializes the session. /// </summary> /// <param name="secMan">The security manager.</param> /// <param name="jobRQ">The job request.</param> /// <param name="token">The session token.</param> /// <param name="parentJob">The parent job. This should be left null if this is not a child job.</param> public void Initialize(JobBase jobRQ, SessionToken token, SecurityManagerJob parentJob, CommandRSCallback RSCallback, CommandProgressCallback ProgressCallback) { try { //mSecMan = secMan; mParentJob=parentJob; if (parentJob!=null) mChildJobDepth = parentJob.ChildJobDepth+1; mRSCallback=RSCallback; mProgressCallback=ProgressCallback; mBaseJob = jobRQ; this.token=token; } catch(Exception ex) { Reset(); throw ex; } }