예제 #1
0
        public void Start(string name, string collection = null, string handler = null)
        {
            var setting = _configrationManager.GetSetting(name);

            var discoverObject = new DiscoverObject(setting);

            discoverObject.Builder = _buildIndexProvider.Get(setting.IndexBuilder);

            IMessageQueue dispatchQueue = _messageQueueProvider != null?_messageQueueProvider.Get(DispatchQueueName, true) : null;

            var task = discoverObject.ForEachAsync((item) => {
                if (dispatchQueue != null)
                {
                    var message = new DownloadContentMessageBody
                    {
                        Url = item.GetValue("uri").AsString
                    };

                    message.Context.Add("saveTo", collection);

                    message.Context.Add("handler", handler);

                    dispatchQueue.Send(message);

                    Console.WriteLine("[Dispatch]");
                }

                if (_action != null)
                {
                    try
                    {
                        _action.Invoke(item);
                    }catch (System.Exception ex)
                    {
                        // Ignore the exception caused by external invoke
                    }
                }
            });

            task.Wait();
        }
예제 #2
0
        public void Start(string collection, string handler)
        {
            IMessageQueue dispatchQueue = _messageQueueProvider != null?_messageQueueProvider.Get(DispatchQueueName, true) : null;

            foreach (var resource in _resources)
            {
                if (dispatchQueue != null)
                {
                    var message = new DownloadContentMessageBody
                    {
                        Url = resource
                    };

                    message.Context.Add("saveTo", collection);

                    message.Context.Add("handler", handler);

                    dispatchQueue.Send(message);

                    Console.WriteLine("[Dispatch]");
                }
            }
        }