private void moveByHours(int hours)
 {
     ClockUtil.CurrentTime = new DateTime(ClockUtil.CurrentTime.Millisecond + ((hours * 60 * 1000 * 60) + 5000));
     ESS.FW.Bpm.Engine.Impl.JobExecutor.JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;
     jobExecutor.Start();
     Thread.Sleep(1000);
     jobExecutor.Shutdown();
 }
Exemple #2
0
        public static void WaitForJobExecutorToProcessAllJobs(ProcessEngineConfigurationImpl processEngineConfiguration,
                                                              long maxMillisToWait, long intervalMillis)
        {
            ESS.FW.Bpm.Engine.Impl.JobExecutor.JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;
            jobExecutor.Start();

            //try
            //{
            //  Timer timer = new Timer();
            //  InteruptTask task = new InteruptTask(Thread.CurrentThread);
            //  timer.Schedule(task, maxMillisToWait);
            //  bool areJobsAvailable = true;
            //  try
            //  {
            //	while (areJobsAvailable && !task.TimeLimitExceeded)
            //	{
            //	  Thread.Sleep(intervalMillis);
            //	  areJobsAvailable = areJobsAvailable(processEngineConfiguration);
            //	}
            //  }
            //  //catch (InterruptedException)
            //  //{
            //  //}
            //  finally
            //  {
            //	timer.Cancel();
            //  }
            //  if (areJobsAvailable)
            //  {
            //	throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
            //  }

            //}
            //finally
            //{
            //  jobExecutor.Shutdown();
            //}
        }
Exemple #3
0
        public virtual void WaitForJobExecutorToProcessAllJobs(long maxMillisToWait)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngine.ProcessEngineConfiguration;

            ESS.FW.Bpm.Engine.Impl.JobExecutor.JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;
            jobExecutor.Start();
            int intervalMillis = 1000;

            int jobExecutorWaitTime = jobExecutor.WaitTimeInMillis * 2;

            if (maxMillisToWait < jobExecutorWaitTime)
            {
                maxMillisToWait = jobExecutorWaitTime;
            }

            try
            {
                InterruptTask          task  = new InterruptTask(Thread.CurrentThread);
                System.Threading.Timer timer = new System.Threading.Timer(task.Run, null, maxMillisToWait, 0);

                bool areJobsAvailable = true;
                try
                {
                    while (areJobsAvailable && !task.TimeLimitExceeded)
                    {
                        Thread.Sleep(intervalMillis);
                        try
                        {
                            areJobsAvailable = AreJobsAvailable();
                        }
                        catch (System.Exception ex)
                        {
                            // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
                            // isolation level doesn't allow READ of the table
                        }
                    }
                }
                catch (ThreadInterruptedException e)
                {
                }
                finally
                {
                    timer.Change(-1, 0);
                }
                if (areJobsAvailable)
                {
                    throw new AssertionException("time limit of " + maxMillisToWait + " was exceeded");
                }
            }
            finally
            {
                jobExecutor.Shutdown();
            }

            //try
            //{
            //    Timer timer = new Timer();
            //    InterruptTask task = new InterruptTask(Thread.CurrentThread);
            //    timer.Schedule(task, maxMillisToWait);
            //    bool areJobsAvailable = true;
            //    try
            //    {
            //        while (areJobsAvailable && !task.TimeLimitExceeded)
            //        {
            //            Thread.Sleep(intervalMillis);
            //            try
            //            {
            //                areJobsAvailable = areJobsAvailable();
            //            }
            //            catch (Exception)
            //            {
            //                // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
            //                // isolation level doesn't allow Permissions.Read of the table
            //            }
            //        }
            //    }
            //    //catch (InterruptedException)
            //    //{
            //    //}
            //    finally
            //    {
            //        timer.Cancel();
            //    }
            //    if (areJobsAvailable)
            //    {
            //        throw new AssertionError("time limit of " + maxMillisToWait + " was exceeded");
            //    }

            //}
            //finally
            //{
            //    jobExecutor.Shutdown();
            //}
        }