Esempio n. 1
0
        public void TestGetJobCountByStatusServiceID1()
        {
            //Add items ta1 and ta2
            jsm.AddJob(ta1);
            jsm.AddJob(ta2);

            Assert.AreEqual(2, jsm.GetJobCountByStatusServiceID(JobStatus.Queued, 3),
                            "There must be 2 elements with status as JobStatus.Queued and serviceId as 3.");
        }
Esempio n. 2
0
File: Demo.cs Progetto: kurtrips/tc
        public void TestDemo()
        {
            //Base operations

            // create JobStatusManager
            JobStatusManager jobManager = new JobStatusManager();

            // add job
            jobManager.AddJob(job1);

            // Remove job
            jobManager.RemoveJob(job1.QueueID);

            // add a list of jobs
            jobManager.AddJobs(list);

            // Remove a list of jobs
            jobManager.RemoveJobs(list);


            //Get data for various criteria

            // get concrete job (QueueID is unique job identifier)
            ITradeActivityItem item1 = jobManager.GetJobByQueueID(2);

            // Get count of jobs with given status
            int jobsCount1 = jobManager.GetJobCountByStatus(JobStatus.Queued);

            // get jobs with given status
            ReadOnlyCollection <ITradeActivityItem> jobs2 = jobManager.GetJobsByStatus(JobStatus.Queued);

            // get jobs for given service
            ReadOnlyCollection <ITradeActivityItem> jobs3 = jobManager.GetJobsByServiceID(3);

            // Get count of jobs with given status for given service
            int jobCount2 = jobManager.GetJobCountByStatusServiceID(JobStatus.Queued, 3);

            // get jobs for given service and with given status
            ReadOnlyCollection <ITradeActivityItem> jobs4 = jobManager.GetJobsByStatusAndServiceID(JobStatus.Queued, 3);

            // get jobs for given service and with JobStatus.Queued status
            ReadOnlyCollection <ITradeActivityItem> jobs5 = jobManager.GetJobsForDispatch(3);

            // we can get exclusive access to JobStatusManager to execute not thread safe operations
            lock (jobManager.SyncRoot)
            {
                foreach (ITradeActivityItem job in jobs4)
                {
                    Console.WriteLine(job.QueueID);
                }
            }


            //Monitor jobs for given criteria
            //The application can get read only wrapper for given condition once and uses it many times.
            //The wrapper provides read only access to collection of jobs for given criteria.

            // get jobs for dispatch once
            ReadOnlyCollection <ITradeActivityItem> jobs = jobManager.GetJobsForDispatch(3);

            // call by timer for example
            foreach (ITradeActivityItem job in jobs)
            {
                // process job
            }
        }