示例#1
0
        public void AddRequest(IRequest request)
        {
            ISyncRequest syncRequest = (ISyncRequest)request;

            if (ContainsRequest(syncRequest))
            {
                return;
            }


            syncRequests.Add(syncRequest);

            /*
             * Fire Sync Queued Event
             */
            ISyncEvents syncEventHandler = resourceManager.GetSyncEventHandler();

            if (syncEventHandler != null)
            {
                syncEventHandler.OnQueue(syncRequest);
            }


            if (!IsWorkerRunning())
            {
                StartWorker();
            }
        }
示例#2
0
        /// <summary>
        /// Private EventHandler Constructor
        /// </summary>
	    private EventHandler() 
        {
		
		    IEnumerator<String> events = coreResourceManager.GetApplicationDescriptor().GetEvents();
		    while(events.MoveNext()) 
            {
			    String eventName = events.Current;
			
			    Object objectInstance = ClassUtils.CreateClassInstance(eventName);
			    if(objectInstance is INotificationEvents) 
                {
				    notificationEventsHandler = (INotificationEvents) objectInstance;
			    } 
                else if(objectInstance is ISyncEvents) 
                {
                    syncEvents = (ISyncEvents) objectInstance;
			    }
		    }
	    }
示例#3
0
        /// <summary>
        /// Private EventHandler Constructor
        /// </summary>
        private EventHandler()
        {
            IEnumerator <String> events = coreResourceManager.GetApplicationDescriptor().GetEvents();

            while (events.MoveNext())
            {
                String eventName = events.Current;

                Object objectInstance = ClassUtils.CreateClassInstance(eventName);
                if (objectInstance is INotificationEvents)
                {
                    notificationEventsHandler = (INotificationEvents)objectInstance;
                }
                else if (objectInstance is ISyncEvents)
                {
                    syncEvents = (ISyncEvents)objectInstance;
                }
            }
        }
示例#4
0
        public void HandleRequests()
        {
            IEnumerator <ISyncRequest> requests       = syncRequests.GetEnumerator();
            ICollection <ISyncRequest> removeRequests = new List <ISyncRequest>();

            while (requests.MoveNext())
            {
                ISyncRequest syncRequest = requests.Current;

                /*
                 * Fire Sync Started Event
                 */
                ISyncEvents syncEventHandler = resourceManager.GetSyncEventHandler();
                if (syncEventHandler != null)
                {
                    syncEventHandler.OnStart(syncRequest);
                }


                /*
                 * Process Request
                 */
                SyncDescriptor refreshDescriptor = resourceManager.GetSyncDescriptor(syncRequest.GetName());

                IEnumerator <String> services = refreshDescriptor.GetServiceDescriptorNames();
                while (services.MoveNext())
                {
                    String service = services.Current;

                    String serviceName = service.Substring(0, service.IndexOf(Constants.SYNC_DESCRIPTOR_SERVICE_SEPARATOR));
                    String requestName = service.Substring(service.IndexOf(Constants.SYNC_DESCRIPTOR_SERVICE_SEPARATOR) + 1, service.Length - (service.IndexOf(Constants.SYNC_DESCRIPTOR_SERVICE_SEPARATOR) + 1));


                    ServiceDescriptor         serviceDescriptor = resourceManager.RequiredServiceDescriptorBasedOnName(serviceName);
                    ServiceDescriptor.Request api = serviceDescriptor.GetRequest(requestName);

                    String apiHandler = api.GetHandler();

                    IService serviceHandler = (IService)ClassUtils.CreateClassInstance(apiHandler);
                    serviceHandler.SetServiceDescriptor(serviceDescriptor);

                    IEnumerator <String> resources = syncRequest.GetResources();
                    while (resources.MoveNext())
                    {
                        String resourceName  = resources.Current;
                        Object resourceValue = syncRequest.GetResource(resourceName);

                        serviceHandler.AddResource(resourceName, resourceValue);
                    }


                    serviceHandler.Invoke();
                }


                /*
                 * Fire Sync Started Event
                 */
                if (syncEventHandler != null)
                {
                    syncEventHandler.OnFinish(syncRequest);
                }


                removeRequests.Add(syncRequest);
            }

            foreach (ISyncRequest removeRequest in removeRequests)
            {
                syncRequests.Remove(removeRequest);
            }

            syncWorkerThread = null;
        }