private async Task Run()
        {
            var keywords = SearchGroups.Contains("|") ? string.Join(",", SearchGroups.Split('|')) : SearchGroups;
            var config   = new EventHubConfig();

            config.ConnectionString = EventHubConnectionString;
            config.EventHubName     = EventHubName;

            Tweet             = new Tweet();
            Tweet.keepRunning = true;
            var myEventHubObserver = new EventHubObserverWPF(config);

            var sendingPayload = Tweet.StreamStatuses(new TwitterConfig(OAuthToken, OAuthTokenSecret, OAuthCustomerKey, OAuthConsumerSecret,
                                                                        keywords, SearchGroups)).Select(tweet => Sentiment.ComputeScore(tweet, SearchGroups, RequireAll ? "all" : "any")).Select(tweet => new Payload {
                CreatedAt = tweet.CreatedAt, Topic = tweet.Topic, SentimentScore = tweet.SentimentScore, Author = tweet.UserName, Text = tweet.Text, SendExtended = SendExtendedInformation
            });

            if (ClearUnfoundSentiment)
            {
                sendingPayload = sendingPayload.Where(e => e.SentimentScore > -1);
            }
            sendingPayload = sendingPayload.Where(e => e.Topic != "No Match");
            SendingPayload = await Task <IDisposable> .Run(() =>
            {
                return(SendingPayload = sendingPayload.ToObservable().Subscribe(myEventHubObserver));
            });
        }
Exemple #2
0
        static void Main(string[] args)
        {
            _loadedConfig = _configHelper.LoadedEventHubConfig;
            switch (args.Length)
            {
            case 0:
                RunTestSeq(_loadedConfig, _loadedConfig.TestMessageBase, _loadedConfig.Iterations);
                break;

            case 1:
                RunTestSeq(_loadedConfig, args[0], _loadedConfig.Iterations);
                break;

            case 2:
                int.TryParse(args[1], out var tempIter);
                RunTestSeq(_loadedConfig, args[0], tempIter);
                break;

            default:
                SendHelp();
                break;
            }

            Console.ReadLine();
        }
Exemple #3
0
        private static void RunTestSeq(EventHubConfig config, string messageBody, int iterations)
        {
            var _eventHubListener = new EventHubListener(config);
            var _eventHubSender   = new EventHubSender(config, messageBody, iterations);

            _eventHubListener.StartListening().GetAwaiter().GetResult();
            _eventHubSender.SendMessages().GetAwaiter().GetResult();
        }
Exemple #4
0
 static void InitConfig()
 {
     _config = new ConfigurationBuilder()
               .AddJsonFile("Config\\appsettings.json", true, true)
               .Build();
     _eventHubConfig       = _config.GetSection("EventHub").Get <EventHubConfig>();
     _storageAccountConfig = _config.GetSection("StorageAccount").Get <StorageAccountConfig>();
 }
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="serviceId"></param>
 /// <param name="configuration"></param>
 public Config(string serviceId, IConfigurationRoot configuration) :
     base(configuration)
 {
     _swagger = new SwaggerConfig(configuration, serviceId);
     _auth    = new AuthConfig(configuration, serviceId);
     _hub     = new IoTHubConfig(configuration, serviceId);
     _cors    = new CorsConfig(configuration);
     _eh      = new EventHubConfig(configuration, serviceId);
 }
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="serviceId"></param>
 /// <param name="configuration"></param>
 public Config(string serviceId, IConfigurationRoot configuration) :
     base(configuration)
 {
     _auth     = new AuthConfig(configuration, serviceId);
     _hub      = new IoTHubConfig(configuration, serviceId);
     _cors     = new CorsConfig(configuration);
     _eh       = new EventHubConfig(configuration, serviceId);
     _sessions = new SessionServicesConfig(configuration);
 }
Exemple #7
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfigurationRoot configuration) :
     base(configuration)
 {
     _swagger = new SwaggerConfig(configuration);
     _auth    = new AuthConfig(configuration);
     _hub     = new IoTHubConfig(configuration);
     _cors    = new CorsConfig(configuration);
     _eh      = new EventHubConfig(configuration);
     _ai      = new ApplicationInsightsConfig(configuration);
 }
Exemple #8
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfigurationRoot configuration) :
     base(configuration)
 {
     _auth     = new AuthConfig(configuration);
     _hub      = new IoTHubConfig(configuration);
     _cors     = new CorsConfig(configuration);
     _eh       = new EventHubConfig(configuration);
     _sessions = new SessionServicesConfig(configuration);
     _api      = new ApiConfig(configuration);
     _ai       = new ApplicationInsightsConfig(configuration);
 }
Exemple #9
0
        private void LoadConfig()
        {
            if (!File.Exists(Config))
            {
                throw new Exception("Config file not found!");
            }

            using (var fileStream = new FileStream(Config, FileMode.Open))
            {
                var xmlSerializer = new XmlSerializer(typeof(EventHubConfig));
                _eventHubConfig = (EventHubConfig)xmlSerializer.Deserialize(fileStream);
            }
        }
            private static Dictionary <string, string> BuildProviderSettings()
            {
                var settings = new Dictionary <string, string>();

                // get initial settings from configs
                ProviderConfig.WriteProperties(settings);
                EventHubConfig.WriteProperties(settings);
                CheckpointerSettings.WriteProperties(settings);

                // add queue balancer setting
                settings.Add(PersistentStreamProviderConfig.QUEUE_BALANCER_TYPE, StreamQueueBalancerType.StaticClusterConfigDeploymentBalancer.ToString());

                return(settings);
            }
            private static void AdjustClusterConfiguration(ClusterConfiguration config)
            {
                var settings = new Dictionary <string, string>();

                // get initial settings from configs
                ProviderConfig.WriteProperties(settings);
                EventHubConfig.WriteProperties(settings);
                CheckpointerSettings.WriteProperties(settings);

                // add queue balancer setting
                settings.Add(PersistentStreamProviderConfig.QUEUE_BALANCER_TYPE, StreamQueueBalancerType.DynamicClusterConfigDeploymentBalancer.ToString());

                // register stream provider
                config.Globals.RegisterStreamProvider <EventHubStreamProvider>(StreamProviderName, settings);
                config.Globals.RegisterStorageProvider <MemoryStorage>("PubSubStore");
            }
        public void AnalyzeData(string UserId)
        {
            if (!string.IsNullOrWhiteSpace(UserId))
            {
                userId = UserId;
                try
                {
                    //Configure Twitter OAuth
                    var oauthToken          = ConfigurationManager.AppSettings["oauth_token"];
                    var oauthTokenSecret    = ConfigurationManager.AppSettings["oauth_token_secret"];
                    var oauthCustomerKey    = ConfigurationManager.AppSettings["oauth_consumer_key"];
                    var oauthConsumerSecret = ConfigurationManager.AppSettings["oauth_consumer_secret"];

                    //Configure EventHub
                    var config = new EventHubConfig();
                    config.ConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"];
                    config.EventHubName     = ConfigurationManager.AppSettings["EventHubName"];
                    var myEventHubObserver = new EventHubObserver(config);


                    var datum = Tweet.StreamStatuses(new TwitterConfig(oauthToken, oauthTokenSecret, oauthCustomerKey, oauthConsumerSecret,
                                                                       keywords)).Select(tweet => Sentiment.ComputeScore(tweet, keywords)).
                                Where(tweet => tweet.Topic != "Unknown" &&
                                      (tweetTimeZone.ToUpper().Contains(tweet.TimeZone.ToUpper()) || string.Compare(tweetTimeZone, "All") == 0) &&
                                      DateTime.Compare(DateTime.Now, tweetEndTime) <= 0).
                                Select(tweet => new Payload
                    {
                        CreatedAt      = tweet.CreatedAt,
                        UserId         = UserId,
                        Topic          = tweet.Topic,
                        SentimentScore = tweet.SentimentScore,
                        PlaceTimeZone  = tweet.TimeZone,
                        TweetText      = tweet.Text,
                        Retweeted      = tweet.Retweeted,
                        RetweetCount   = tweet.RetweetCount
                    });

                    datum.ToObservable().Subscribe(myEventHubObserver);
                }
                catch (Exception ex)
                {
                    logger.Log(ex.StackTrace, LOGLEVELS.ERROR);
                }
            }
        }
        static void Main(string[] args)
        {
            var config = new EventHubConfig();

            // Uncomment for picking from Configuration
            config.ConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"];
            config.EventHubName = ConfigurationManager.AppSettings["EventHubName"];

            //To push 1 event per second
            //var eventHubevents = Observable.Interval(TimeSpan.FromSeconds(.1)).Select(i => Sensor.Generate());
            var eventHubevents = Observable.Interval(TimeSpan.FromSeconds(.1)).Select(i => Sensor.Generate());

            //To send Data to EventHub as JSON
            var eventHubDis = eventHubevents.Subscribe(new EventHubObserver(config));

            Console.ReadLine();
            eventHubDis.Dispose();
        }
            private static void AdjustClusterConfiguration(ClusterConfiguration config)
            {
                var settings = new Dictionary <string, string>();

                // get initial settings from configs
                ProviderConfig.WriteProperties(settings);
                EventHubConfig.WriteProperties(settings);
                CheckpointSettings.WriteProperties(settings);

                // add queue balancer setting
                settings.Add(PersistentStreamProviderConfig.QUEUE_BALANCER_TYPE, StreamQueueBalancerType.DynamicClusterConfigDeploymentBalancer.ToString());

                // register stream provider
                config.Globals.RegisterStreamProvider <EventHubStreamProvider>(StreamProviderName, settings);
                config.Globals.RegisterStorageProvider <MemoryStorage>("PubSubStore");

                // Make sure a node config exist for each silo in the cluster.
                // This is required for the DynamicClusterConfigDeploymentBalancer to properly balance queues.
                config.GetOrCreateNodeConfigurationForSilo("Primary");
                config.GetOrCreateNodeConfigurationForSilo("Secondary_1");
            }
        static void Main(string[] args)
        {
            //Configure Twitter OAuth
            var oauthToken          = ConfigurationManager.AppSettings["oauth_token"];
            var oauthTokenSecret    = ConfigurationManager.AppSettings["oauth_token_secret"];
            var oauthCustomerKey    = ConfigurationManager.AppSettings["oauth_consumer_key"];
            var oauthConsumerSecret = ConfigurationManager.AppSettings["oauth_consumer_secret"];
            var keywords            = ConfigurationManager.AppSettings["twitter_keywords"];

            //Configure EventHub
            var config = new EventHubConfig();

            config.ConnectionString = ConfigurationManager.AppSettings["EventHubConnectionString"];
            config.EventHubName     = ConfigurationManager.AppSettings["EventHubName"];
            var myEventHubDataSender = new EventHubDataSender(config);

            var tweeterData = Tweet.StreamStatuses(new TwitterConfig(oauthToken, oauthTokenSecret, oauthCustomerKey, oauthConsumerSecret,
                                                                     keywords)).Select(tweet => Sentiment.ComputeScore(tweet, keywords)).Select(tweet => new Payload {
                CreatedAt = tweet.CreatedAt, Text = tweet.Text, Topic = tweet.Topic, SentimentScore = tweet.SentimentScore
            });

            tweeterData.ToObservable().Subscribe(myEventHubDataSender);
        }
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="serviceId"></param>
 /// <param name="configuration"></param>
 public Config(string serviceId, IConfigurationRoot configuration) :
     base(configuration)
 {
     _eh  = new EventHubConfig(configuration, serviceId);
     _hub = new IoTHubConfig(configuration, serviceId);
 }
 public EventHubSender(Config.EventHubConfig config, string messageBody, int iterations)
 {
     this._messageBody    = messageBody;
     this._iterations     = iterations;
     this._eventHubConfig = config;
 }
Exemple #18
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfigurationRoot configuration) :
     base(configuration)
 {
     _eh  = new EventHubConfig(configuration);
     _hub = new IoTHubConfig(configuration);
 }
        public EventHubListener(EventHubConfig config)
        {
            var eventHubConfig = config;

            _eventProcessorHost = new EventProcessorHost(eventHubConfig.EventHubName, PartitionReceiver.DefaultConsumerGroupName, eventHubConfig.EventHubConnectionString, eventHubConfig.StorageConnectionString, eventHubConfig.StorageContainerName);
        }