static void Main(string[] args) { var instanceName = !string.IsNullOrEmpty(InstanceName) ? InstanceName : StreamInsightSetupInfo.EnumerateInstances()[0]; Server server; try { server = Server.Create(instanceName); } catch { Console.WriteLine("Could not create StreamInsight instance. Please open Program.cs and check InstanceName."); return; } var application = server.CreateApplication("StockInsight"); // Determine path for historical data var dataPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + "\\HistoricalData\\"; var ericUSDEnumerable = StockData.GetStockEnumerable(dataPath + "eric_b_usd_2009.csv", "ERIC-USD", new string[] { "Open", "High", "Low", "Close", "Volume", "Adj Close" } ); var ericSEKEnumerable = StockData.GetStockEnumerable(dataPath + "eric_b_sek_2009.csv", "ERIC-SEK", new string[] { "Open", "High", "Low", "Close", "Volume", "Adj Close" } ); var nokiaUSDEnumerable = StockData.GetStockEnumerable(dataPath + "nokia_2009.csv", "NOKIA-USD", new string[] { "Open", "High", "Low", "Close", "Volume", "Adj Close" } ); var USDSEKEnumerable = StockData.GetStockEnumerable(dataPath + "USD_SEK_ExchangeRate_2009.csv", "USD-SEK", new string[] { "Value" } ); // Run examples filterExample(ericUSDEnumerable, application); crossJoinProjectionExample(ericSEKEnumerable, ericUSDEnumerable, USDSEKEnumerable, application); avgExample(ericUSDEnumerable, application); groupApplyExample(ericUSDEnumerable, application); bigLooserExample(ericUSDEnumerable, application); userFilterExample(ericUSDEnumerable, application); standardDeviationExample(ericUSDEnumerable, application); application.Delete(); server.Dispose(); }
/// <summary> /// Starting point. /// </summary> public static void Main() { // Create the server and application var instanceName = !string.IsNullOrEmpty(InstanceName) ? InstanceName : StreamInsightSetupInfo.EnumerateInstances()[0]; Server server; try { server = Server.Create(instanceName); } catch { Console.WriteLine("Could not create StreamInsight instance. Please open Program.cs and check InstanceName."); return; } var application = server.CreateApplication("StockInsight"); // Determine path for historical data var dataPath = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + "\\HistoricalData\\"; // Configuration for input var ericSEKConfig = new StockQuoteInputConfig { ID = "ERIC-SEK", Filename = dataPath + "eric_b_sek_2009.csv", ColumnNames = new string[] { "Open", "High", "Low", "Close", "Volume", "Adj Close" }, StartDate = new DateTime(2009, 01, 01), Interval = 0 }; // Configuration for input var ericUSDConfig = new StockQuoteInputConfig { ID = "ERIC-USD", Filename = dataPath + "eric_b_usd_2009.csv", ColumnNames = new string[] { "Open", "High", "Low", "Close", "Volume", "Adj Close" }, StartDate = new DateTime(2009, 01, 01), Interval = 0 }; // Configuration for input var nokiaUSDConfig = new StockQuoteInputConfig { ID = "NOKIA-USD", Filename = dataPath + "nokia_2009.csv", ColumnNames = new string[] { "Open", "High", "Low", "Close", "Volume", "Adj Close" }, StartDate = new DateTime(2009, 01, 01), Interval = 0 }; // Configuration for input var USDSEKConfig = new StockQuoteInputConfig { ID = "USD-SEK", Filename = dataPath + "USD_SEK_ExchangeRate_2009.csv", ColumnNames = new string[] { "Value" }, StartDate = new DateTime(2009, 01, 01), Interval = 0 }; // Configure output adapter var outputConfig = new StockQuoteOutputConfig(); // Instantiate semaphor for stop signal var adapterStopSignal = new EventWaitHandle(false, EventResetMode.AutoReset, outputConfig.AdapterStopSignal); // Add input and output adapter factories to the server var inputAdapter = application.CreateInputAdapter <StockQuoteInputFactory>("StockQuoteInput", "Description..."); var outputAdapter = application.CreateOutputAdapter <StockQuoteOutputFactory>("StockQuoteOutput", "Description..."); // Create queries createFilterExampleQuery(application, ericUSDConfig, outputConfig, inputAdapter, outputAdapter); createCrossJoinExampleQuery(application, ericUSDConfig, ericSEKConfig, USDSEKConfig, outputConfig, inputAdapter, outputAdapter); createAvgExampleQuery(application, ericUSDConfig, outputConfig, inputAdapter, outputAdapter); createGroupApplyExampleQuery(application, ericUSDConfig, outputConfig, inputAdapter, outputAdapter); createBigLooserExampleQuery(application, ericUSDConfig, outputConfig, inputAdapter, outputAdapter); createUserFilterExampleQuery(application, ericUSDConfig, outputConfig, inputAdapter, outputAdapter); createStandardDeviationExampleQuery(application, ericUSDConfig, outputConfig, inputAdapter, outputAdapter); // Execute the queries (one at a time) // It would also be possible to execute them in parallell foreach (var query in application.Queries.Values) { Console.WriteLine("\r\nQuery: " + query.Name); // Start query.Start(); // Wait until output adapter signals that it is finished DiagnosticView diagnosticView; do { Thread.Sleep(100); diagnosticView = query.Application.Server.GetDiagnosticView(query.Name); } while ((string)diagnosticView["QueryState"] == "Running"); // Stop query.Stop(); } // Release resources application.Delete(); server.Dispose(); //application.Dispose(); }