예제 #1
0
        static void Main(string[] args)
        {
            // configure the system
            var store = @"C:\LokadData\dp-store";
            // scan "default" event container
            var reader = PlatformClient.ConnectToEventStoreAsReadOnly(store, storeId: "default");
            var views  = PlatformClient.ConnectToViewStorage(store, "sample2-views");

            // Load view, in case this console continues previous work
            var data = views.ReadAsJsonOrGetNew <Sample2Data>(ViewName);

            // print it for debug purposes
            PrintDataToConsole(data, true);

            // this process runs incrementally until stopped
            while (true)
            {
                try
                {
                    ProcessNextIncrementOfEventsOrSleep(data, reader, views);
                }
                catch (Exception ex)
                {
                    // print and sleep on error
                    Console.WriteLine(ex);
                    Thread.Sleep(1000);
                }
            }
        }
예제 #2
0
        public Client(ClientOptions options)
        {
            Options = options;
            // TODO : pass server options
            ClientHttpBase = string.Format("http://{0}:{1}", options.Ip, options.HttpPort);
            Views          = PlatformClient.ConnectToViewStorage(options.StoreLocation, options.ViewsFolder);

            UseEventStore("default");

            RegisterCommands();
        }
예제 #3
0
        static void Main()
        {
            StorePath = ConfigurationManager.AppSettings["StorePath"];

            if (string.IsNullOrWhiteSpace(StorePath))
            {
                StorePath = @"C:\LokadData\dp-store";
            }

            StoreConnection = ConfigurationManager.AppSettings["StoreConnection"];
            if (string.IsNullOrWhiteSpace(StoreConnection))
            {
                StoreConnection = "http://localhost:8080";
            }

            // Use "default" container for reading/writing events
            _client = PlatformClient.ConnectToEventStore(StorePath, storeId: "default", platformServerEndpoint: StoreConnection);
            _view   = PlatformClient.ConnectToViewStorage(StorePath, "sample1-views");


            Console.WriteLine("You name:");
            _userName = Console.ReadLine();
            Console.WriteLine("Chat starting...");

            _client.WriteEvent("", Encoding.UTF8.GetBytes("|join a new user " + _userName));
            Task.Factory.StartNew(ScanChat,
                                  TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness);

            WriteColorText(_userName + ">", ConsoleColor.Green);

            _userMessage = "";

            while (true)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey();

                if (keyInfo.KeyChar != '\r')
                {
                    _userMessage += keyInfo.KeyChar;
                }
                else
                {
                    _client.WriteEvent("", Encoding.UTF8.GetBytes(string.Format("{0}|{1}", _userName, _userMessage)));
                    Console.WriteLine();
                    WriteColorText(_userName + ">", ConsoleColor.Green);
                    _userMessage = "";
                }
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            var store = PlatformClient.ConnectToEventStoreAsReadOnly(PlatformPath, "sample3");
            var views = PlatformClient.ConnectToViewStorage(PlatformPath, Conventions.ViewContainer);

            var threads = new List <Task>
            {
                Task.Factory.StartNew(() => TagProjection(store, views),
                                      TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness),
                Task.Factory.StartNew(() => CommentProjection(store, views),
                                      TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness),
                Task.Factory.StartNew(() => UserCommentsPerDayDistributionProjection(store, views),
                                      TaskCreationOptions.LongRunning | TaskCreationOptions.PreferFairness)
            };

            Task.WaitAll(threads.ToArray());
        }