Ejemplo n.º 1
0
		public WorkQueueProcessor(int numberThreads, ManualResetEvent terminateEvent, string name)
        {
            _terminateEvent = terminateEvent;
            _threadStop = new ManualResetEvent(false);

			using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
			{
				IWorkQueueTypePropertiesEntityBroker broker = ctx.GetBroker<IWorkQueueTypePropertiesEntityBroker>();
				WorkQueueTypePropertiesSelectCriteria criteria = new WorkQueueTypePropertiesSelectCriteria();

				IList<WorkQueueTypeProperties> propertiesList = broker.Find(criteria);
				foreach (WorkQueueTypeProperties prop in propertiesList)
					_propertiesDictionary.Add(prop.WorkQueueTypeEnum, prop);
			}


			_threadPool =
				new WorkQueueThreadPool(numberThreads,
				                        WorkQueueSettings.Instance.PriorityWorkQueueThreadCount,
				                        WorkQueueSettings.Instance.MemoryLimitedWorkQueueThreadCount,
				                        _propertiesDictionary) {ThreadPoolName = name + " Pool"};


			WorkQueueFactoryExtensionPoint ep = new WorkQueueFactoryExtensionPoint();
            object[] factories = ep.CreateExtensions();

            if (factories == null || factories.Length == 0)
            {
                // No extension for the workqueue processor. 
                Platform.Log(LogLevel.Warn, "No WorkQueueFactory Extension found.");
            }
            else
            {
                foreach (object obj in factories)
                {
                    IWorkQueueProcessorFactory factory = obj as IWorkQueueProcessorFactory;
                    if (factory != null)
                    {
                        WorkQueueTypeEnum type = factory.GetWorkQueueType();
                        _extensions.Add(type, factory);
                    }
                    else
                        Platform.Log(LogLevel.Error, "Unexpected incorrect type loaded for extension: {0}",
                                     obj.GetType());
                }
            }
	    }
 public WorkQueueTypePropertiesSelectCriteria(WorkQueueTypePropertiesSelectCriteria other)
 : base(other)
 {}
Ejemplo n.º 3
0
        /// <summary>
        /// Insert an EditStudy request.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="studyStorageKey"></param>
        /// <param name="serverPartitionKey"></param>
        /// <param name="type"></param>
        /// <param name="updateItems"></param>
        /// <param name="reason"></param>
        /// <param name="user"></param>
        /// <param name="editType"></param>
        /// <returns></returns>
        private static WorkQueue InsertExternalEditStudyRequest(IUpdateContext context, ServerEntityKey studyStorageKey, ServerEntityKey serverPartitionKey, WorkQueueTypeEnum type, List<UpdateItem> updateItems, string reason, string user, EditType editType)
        {
            var propertiesBroker = context.GetBroker<IWorkQueueTypePropertiesEntityBroker>();
            var criteria = new WorkQueueTypePropertiesSelectCriteria();
            criteria.WorkQueueTypeEnum.EqualTo(type);
            WorkQueueTypeProperties properties = propertiesBroker.FindOne(criteria);

            var broker = context.GetBroker<IWorkQueueEntityBroker>();
            var insert = new WorkQueueUpdateColumns();
            DateTime now = Platform.Time;
            var data = new EditStudyWorkQueueData
            {
                EditRequest =
                {
                    TimeStamp = now,
                    UserId = user,
                    UpdateEntries = updateItems,
                    Reason = reason,
                    EditType = editType
                }
            };
            insert.WorkQueueTypeEnum = type;
            insert.StudyStorageKey = studyStorageKey;
            insert.ServerPartitionKey = serverPartitionKey;
            insert.ScheduledTime = now;
            insert.ExpirationTime = now.AddSeconds(properties.ExpireDelaySeconds);
            insert.WorkQueueStatusEnum = WorkQueueStatusEnum.Pending;
            insert.WorkQueuePriorityEnum = properties.WorkQueuePriorityEnum;
            insert.Data = XmlUtils.SerializeAsXmlDoc(data); 
            WorkQueue editEntry = broker.Insert(insert);
            if (editEntry == null)
            {
                throw new ApplicationException(string.Format("Unable to insert an Edit request of type {0} for study for user {1}", type.Description, user));
            }
            return editEntry;
        }
 public WorkQueueTypePropertiesSelectCriteria(WorkQueueTypePropertiesSelectCriteria other)
     : base(other)
 {
 }