public void TestFacebook()
        {
            var streamInsightInstanceName = Properties.Settings.Default.InstanceName;
            var server = Server.Create(streamInsightInstanceName);
            var application = server.CreateApplication("facebooktest");

            var inputConfig = new FacebookConfig
            {
                AccessToken = AccessTokenTbx.Text,
                UsernameOrUniqueId = UsernameOrUniqueIdTbx.Text,
                RefreshPeriod = int.Parse(RefreshIntervalTbx.Text) * 1000
            };

            var input = CepStream<FacebookItem>.Create("facebook", typeof(FacebookFactory), inputConfig, EventShape.Point);

            // Configure output adapter
            var outputConfig = new StackerConfig
            {
                StackerCtlPipeName = stackerCtl1.PipeName,
                StackerCtlHostName = "localhost"
            };

            // Create query and bind to the output adapter
            var expr = from e in input
                       select new {e.Id, e.FromName, Message = !string.IsNullOrEmpty(e.Message) ? e.Message : e.Description };

            query = expr.ToQuery(application, "query", "...", typeof(StackerFactory), outputConfig, EventShape.Point, StreamEventOrder.FullyOrdered);

            // Start query
            query.Start();

            // Wait until query change state
            DiagnosticView diagnosticView;
            stopFlag = false;
            do
            {
                Thread.Sleep(100);
                diagnosticView = query.Application.Server.GetDiagnosticView(query.Name);
            } while (!stopFlag && (string)diagnosticView["QueryState"] == "Running");

            // Stop query
            query.Stop();

            application.Delete();
            server.Dispose();
        }
Exemple #2
0
 public FacebookInput(FacebookConfig config)
 {
     _config = config;
 }