本文整理汇总了C#中Job类的典型用法代码示例。如果您正苦于以下问题:C# Job类的具体用法?C# Job怎么用?C# Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Job类属于命名空间,在下文中一共展示了Job类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartRunningJob
private void StartRunningJob(Job job)
{
Logger.Info("Starting WorkerProcess for job {0}", job.Id);
Process process = new Process
{
StartInfo =
{
FileName = ConfigurationManager.AppSettings["WorkerProcessLocation"],
Arguments = string.Format("-i {0}", job.Id),
UseShellExecute = false,
CreateNoWindow = true,
ErrorDialog = false,
RedirectStandardError = true
}
};
process.Start();
process.WaitForExit();
if (process.ExitCode != 0)
{
Logger.Error("Worker process for job ID: {0} exited with error.", job.Id);
//using (var repo = new JobRepository())
//{
// //repo.UpdateStateForJob(job, JobState.CompletedWithError, "Unspecified error");
//}
}
else
{
Logger.Info("Worker process for job ID: {0} completed.", job.Id);
}
}
示例2: CreateAndSendSignatureJob
public async Task CreateAndSendSignatureJob()
{
ClientConfiguration clientConfiguration = null; //As initialized earlier
var directClient = new DirectClient(clientConfiguration);
var documentToSign = new Document(
"Subject of Message",
"This is the content",
FileType.Pdf,
@"C:\Path\ToDocument\File.pdf");
var exitUrls = new ExitUrls(
new Uri("http://redirectUrl.no/onCompletion"),
new Uri("http://redirectUrl.no/onCancellation"),
new Uri("http://redirectUrl.no/onError")
);
var job = new Job(
documentToSign,
new Signer(new PersonalIdentificationNumber("12345678910")),
"SendersReferenceToSignatureJob",
exitUrls
);
var directJobResponse = await directClient.Create(job);
}
示例3: CreateStartBilling
/// <summary>
/// 创建步骤 2 ,开始Billing
/// </summary>
/// <param name="jb">Job 实例</param>
/// <param name="databaseName">数据库名</param>
/// <param name="strSQl">SQL命令</param>
public void CreateStartBilling(Job jb, string databaseName, string strSQl)
{
try
{
JobStep jbstp = new JobStep(jb, "开始Billing");
//数据库
jbstp.DatabaseName = databaseName;
//计划执行的SQL命令
jbstp.Command = strSQl;
//* 制定执行步骤
//成功时执行的操作
jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
//jbstp.OnSuccessAction = StepCompletionAction.GoToStep;
//jbstp.OnSuccessStep = 3;
//失败时执行的操作
jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
//创建 SQL 代理实例的作业步骤.
jbstp.Create();
}
catch (Exception)
{
throw;
}
}
示例4: Engage
/// <summary>
/// Engages autopilot execution to FinalDestination either by direct
/// approach or following a course.
/// </summary>
public void Engage(Vector3 destination) {
if (_job != null && _job.IsRunning) {
_job.Kill();
}
Destination = destination;
_job = new Job(Engage(), true);
}
示例5: RetrieveVacancy
Job RetrieveVacancy()
{
var objJobId = Request.QueryString["jobid"];
var isInvalid = false;
var j = new Job();
if (objJobId != null && objJobId.IsNumeric() && int.Parse(objJobId) > 0)
{
var jobId = int.Parse(objJobId);
//retrieve vacancy object
j = new Jobs().GetJob(jobId);
//validate
if (j == null || j.JobId <= 0)
{
isInvalid = true;
}
//******** NEED TO IMPLEMENT CHECK CLIENT USERS PERMISSIONS ******
}
else
isInvalid = true;
if (isInvalid)
//invalid request redirect
Response.Redirect("/404.aspx");
return j;
}
示例6: EndTree
Job EndTree(Job job, JobStatus endStatus)
{
// If this is the root, mutate to completed status.
if (job.ParentId == null)
return _jobMutator.Mutate<EndTransition>(job, status: JobStatus.Completed);
job = _jobMutator.Mutate<EndTransition>(job, PendingEndStatus[endStatus]);
/*
* First, load the parent, find the await record for this job and
* update its status to end status.
*/
// ReSharper disable once PossibleInvalidOperationException
var parent = _jobRepository.Load(job.ParentId.Value);
var @await = parent.Continuation.Find(job);
@await.Status = endStatus;
/*
* After we set the await's status, invoke ContinuationDispatcher to
* ensure any pending await for parent is dispatched.
* If ContinuationDispatcher returns any awaits, that means parent job is not
* ready for completion.
*/
var pendingAwaits = _continuationDispatcher.Dispatch(parent);
if (!pendingAwaits.Any())
EndTree(parent, JobStatus.Completed);
return _jobMutator.Mutate<EndTransition>(job, endStatus);
}
示例7: JobOnThing
public override Job JobOnThing( Pawn pawn, Thing t )
{
var warden = pawn;
var slave = t as Pawn;
if(
( slave == null )||
( slave.guest == null )||
( slave.guest.interactionMode != Data.PIM.FreeSlave )||
( slave.Downed )||
( !slave.Awake() )||
( !warden.CanReserveAndReach(
slave,
PathEndMode.ClosestTouch,
warden.NormalMaxDanger(),
1 )
)
)
{
return null;
}
var collar = slave.WornCollar();
if( collar == null )
{ // Slave isn't wearing a collar, wut?
return null;
}
IntVec3 result;
if( !RCellFinder.TryFindPrisonerReleaseCell( slave, warden, out result ) )
{
return null;
}
var job = new Job( Data.JobDefOf.FreeSlave, slave, collar, result );
job.maxNumToCarry = 1;
return job;
}
示例8: TestDontRunAtFirstIfCoresNotAvailable
public void TestDontRunAtFirstIfCoresNotAvailable()
{
BenchmarkSystem Bs = new BenchmarkSystem();
//jobs that needs in all 27 cpus, should execute with no problems.
Job job1 = new Job((string[] arg) => { return arg.Length.ToString(); }, new Owner("morten12"), 9, 10000);
Job job2 = new Job((string[] arg) => { return arg.Length.ToString(); }, new Owner("morten22"), 9, 10000);
Job job3 = new Job((string[] arg) => { return arg.Length.ToString(); }, new Owner("morten32"), 9, 10000);
Bs.Submit(job1);
Bs.Submit(job2);
Bs.Submit(job3);
//this job requires too many cores and should therefore not run immediately
Job job4 = new Job((string[] arg) => { return arg.Length.ToString(); }, new Owner("morten4"), 9, 10000);
Bs.Submit(job4);
Task task = Task.Factory.StartNew(() => Bs.ExecuteAll());
Thread.Sleep(1000);
Assert.AreEqual(State.Running, job1.State);
Assert.AreEqual(State.Running, job2.State);
Assert.AreEqual(State.Running, job3.State);
// this job should not be running as there aren't enough cores for it to run.
Assert.AreEqual(State.Submitted, job4.State);
//it should run after the cores become available
Thread.Sleep(12000);
Assert.AreEqual(State.Running, job4.State);
// NOTE: this test fails because the first three submitted jobs dont run simultaneusly. The factory method of Task should run them in separate threads, but somehow choses to
// run them chronological instead. Maybe you can explain why? Thank you in advance.
}
示例9: Execute
public override void Execute(string filename, bool testModus, Job job) {
Console.WriteLine(" Delete '{0}'", filename);
if (testModus) {
return;
}
File.Delete(filename);
}
示例10: Ctor_ShouldInitializeAllProperties
public void Ctor_ShouldInitializeAllProperties()
{
var job = new Job(_methodData, _arguments);
Assert.Same(_methodData, job.MethodData);
Assert.Same(_arguments, job.Arguments);
}
示例11: nextLevel
public void nextLevel()
{
contractshown = false;
if(currentJob>=jobs.Count){
Application.LoadLevel("End");
}
else{
job = jobs[currentJob];
CVGenerator cvGenerator = new CVGenerator();
cvList = new List<CV>();
int numberOfCVs = Random.Range(4, 7);
for (int num = 0; num < numberOfCVs; num++)
{
Candidate candidate = new Candidate(ref maleSprites, ref femaleSprites);
cvList.Add(cvGenerator.generateCV(candidate));
}
currentCV = 0;
renderCV();
showJob();
refreshHUD();
}
}
示例12: postprocess
private static LogItem postprocess(MainForm mainForm, Job ajob)
{
if (!(ajob is D2VIndexJob)) return null;
D2VIndexJob job = (D2VIndexJob)ajob;
if (job.PostprocessingProperties != null) return null;
StringBuilder logBuilder = new StringBuilder();
VideoUtil vUtil = new VideoUtil(mainForm);
Dictionary<int, string> audioFiles = vUtil.getAllDemuxedAudio(job.AudioTracks, job.Output, 8);
if (job.LoadSources)
{
if (job.DemuxMode != 0 && audioFiles.Count > 0)
{
string[] files = new string[audioFiles.Values.Count];
audioFiles.Values.CopyTo(files, 0);
Util.ThreadSafeRun(mainForm, new MethodInvoker(
delegate
{
mainForm.Audio.openAudioFile(files);
}));
}
// if the above needed delegation for openAudioFile this needs it for openVideoFile?
// It seems to fix the problem of ASW dissapearing as soon as it appears on a system (Vista X64)
Util.ThreadSafeRun(mainForm, new MethodInvoker(
delegate
{
AviSynthWindow asw = new AviSynthWindow(mainForm, job.Output);
asw.OpenScript += new OpenScriptCallback(mainForm.Video.openVideoFile);
asw.Show();
}));
}
return null;
}
示例13: UpdateOrder
public async Task<ReplaceOneResult> UpdateOrder(Job job, OrderModel orderModel)
{
if (job.Order.Type != orderModel.Type)
{
throw new InvalidOperationException("Updating with a different ordermodel for this job");
}
// FIXME: Finding a resolver here would help here dude
switch (orderModel.Type)
{
case OrderTypes.Delivery:
case OrderTypes.ClassifiedDelivery:
{
var orderCalculationService = new DefaultOrderCalculationService();
var serviceChargeCalculationService = new DefaultDeliveryServiceChargeCalculationService();
var orderProcessor = new DeliveryOrderProcessor(
orderCalculationService,
serviceChargeCalculationService);
orderProcessor.ProcessOrder(orderModel);
var jobUpdater = new DeliveryJobUpdater(job);
jobUpdater.UpdateJob(orderModel);
job = jobUpdater.Job;
break;
}
}
var result = await UpdateJob(job);
return result;
}
示例14: Initialize
public void Initialize()
{
scheduler = Scheduler.getInstance();
job1 = new Job((string[] args) => { foreach (string s in args) { Console.Out.WriteLine(s); } return ""; }, new Owner("owner1"), 2, 3);
job2 = new Job((string[] args) => { foreach (string s in args) { Console.Out.WriteLine(s); } return ""; }, new Owner("owner2"), 2, 45);
job3 = new Job((string[] args) => { foreach (string s in args) { Console.Out.WriteLine(s); } return ""; }, new Owner("owner3"), 2, 200);
}
示例15: Play
public void Play(float itemRadius) {
D.Assert(itemRadius > Constants.ZeroF);
float currentScale = itemRadius * _radiusToScaleNormalizeFactor;
if (currentScale != _prevScale) {
float relativeScale = currentScale / _prevScale;
ScaleParticleSystem(_primaryParticleSystem, relativeScale);
foreach (ParticleSystem pSystem in _childParticleSystems) {
ScaleParticleSystem(pSystem, relativeScale);
}
_prevScale = currentScale;
}
_primaryParticleSystem.Play(withChildren: true);
D.AssertNull(_waitForExplosionFinishedJob);
bool includeChildren = true;
string jobName = "WaitForExplosionFinishedJob";
_waitForExplosionFinishedJob = _jobMgr.WaitForParticleSystemCompletion(_primaryParticleSystem, includeChildren, jobName, isPausable: true, waitFinished: (jobWasKilled) => {
if (jobWasKilled) {
// 12.12.16 An AssertNull(_jobRef) here can fail as the reference can refer to a new Job, created
// right after the old one was killed due to the 1 frame delay in execution of jobCompleted(). My attempts at allowing
// the AssertNull to occur failed. I believe this is OK as _jobRef is nulled from KillXXXJob() and, if
// the reference is replaced by a new Job, then the old Job is no longer referenced which is the objective. Jobs Kill()ed
// centrally by JobManager won't null the reference, but this only occurs during scene transitions.
}
else {
_waitForExplosionFinishedJob = null;
HandleExplosionFinished();
}
MyPoolManager.Instance.DespawnEffect(transform);
});
}