Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                // Setup Http Client
                client.BaseAddress = new Uri("https://god-feet.myshopify.com/admin/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                var byteArray = Encoding.ASCII.GetBytes("b44e2b63faf1a5a8fd4159f51ddb4e18:0d500f6b7fd4a0abd9370a64d1b5c7ef");
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

                // Connect to Event Store
                esClient.Connect();

                // Get all Orders (as events)
                GetAllOrders();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }
        public async Task <IList <ResolvedEvent> > ConvertAsync(EventStoreStreamsAttribute config, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(config?.ConnectionStringSetting))
            {
                var esException = new EventStoreStreamsBindingException("ConnectionString cant be empty");
                _logger.LogError(esException, esException.Message);
                throw esException;
            }
            using (var client = new EventStoreClient(config.ConnectionStringSetting, _logger))
            {
                try
                {
                    await client.Connect();

                    IList <ResolvedEvent> result = null;
                    if (config.StreamReadDirection == StreamReadDirection.Forward)
                    {
                        result = await client.ReadFromStreamForward(config.StreamName, config.StreamOffset, config.ReadSize, config.ResolveLinkTos);
                    }
                    else
                    {
                        result = await client.ReadFromStreamBackward(config.StreamName, config.StreamOffset, config.ReadSize, config.ResolveLinkTos);
                    }
                    return(result);
                }
                catch (Exception esException)
                {
                    _logger.LogError(esException, esException.Message);
                    throw;
                }
            }
        }