Exemple #1
0
        /// <summary>
        /// Handles the execution exception.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="context">The message context.</param>
        /// <returns></returns>
        public async Task <MessagingContext> HandleExecutionException(Exception exception, MessagingContext context)
        {
            Logger.Error($"Exception occured while executing Steps: {exception.Message}");
            Logger.Trace(exception.StackTrace);

            if (exception.InnerException != null)
            {
                Logger.Error(exception.InnerException.Message);
                Logger.Trace(exception.InnerException.StackTrace);
            }

            string ebmsMessageId = await GetEbmsMessageId(context);

            using (DatastoreContext db = _createContext())
            {
                await db.TransactionalAsync(async ctx =>
                {
                    var repository = new DatastoreRepository(ctx);
                    var service    = new ExceptionService(_configuration, repository, _bodyStore);

                    OutException entity =
                        context.SubmitMessage != null
                            ? await service.InsertOutgoingSubmitExceptionAsync(exception, context.SubmitMessage, context.SendingPMode)
                            : await service.InsertOutgoingAS4MessageExceptionAsync(exception, ebmsMessageId, context.MessageEntityId, context.SendingPMode);

                    await ctx.SaveChangesAsync();

                    service.InsertRelatedRetryReliability(entity, context.SendingPMode?.ExceptionHandling?.Reliability);
                    await ctx.SaveChangesAsync();
                });
            }

            return(new MessagingContext(exception));
        }
        private async Task UpdateRetryStatusForMessageAsync(MessagingContext ctx, SendResult result)
        {
            if (ctx.MessageEntityId.HasValue)
            {
                using (DatastoreContext db = _createDatastore())
                {
                    var repository = new DatastoreRepository(db);
                    var service    = new MarkForRetryService(repository);
                    service.UpdateAS4MessageForSendResult(
                        messageId: ctx.MessageEntityId.Value,
                        status: result);

                    await db.SaveChangesAsync()
                    .ConfigureAwait(false);
                }
            }

            if (ctx.AS4Message?.IsPullRequest == true)
            {
                using (DatastoreContext db = _createDatastore())
                {
                    var service = new PiggyBackingService(db);
                    service.ResetSignalMessagesToBePiggyBacked(ctx.AS4Message.SignalMessages, result);

                    await db.SaveChangesAsync()
                    .ConfigureAwait(false);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Execute the step for a given <paramref name="messagingContext"/>.
        /// </summary>
        /// <param name="messagingContext">The Message used during the step execution.</param>
        /// <returns></returns>
        public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext)
        {
            if (messagingContext?.AS4Message == null)
            {
                throw new InvalidOperationException(
                          $"{nameof(StoreAS4MessageStep)} requires an AS4Message to save but no AS4Message is present in the MessagingContext");
            }

            Logger.Trace("Storing the AS4Message with Operation=ToBeProcessed...");
            using (DatastoreContext context = _createContext())
            {
                var repository = new DatastoreRepository(context);
                var service    = new OutMessageService(_config, repository, _messageBodyStore);
                service.InsertAS4Message(
                    messagingContext.AS4Message,
                    messagingContext.SendingPMode,
                    messagingContext.ReceivingPMode);

                try
                {
                    await context.SaveChangesAsync().ConfigureAwait(false);
                }
                catch
                {
                    messagingContext.ErrorResult = new ErrorResult(
                        "Unable to store the received message due to an exception occured during the saving operation",
                        ErrorAlias.Other);

                    throw;
                }
            }

            Logger.Trace("Stored the AS4Message with Operation=ToBeProcesed");
            return(await StepResult.SuccessAsync(messagingContext));
        }
        private async Task InsertRespondSignalToDatastore(MessagingContext messagingContext)
        {
            using (DatastoreContext dataContext = _createDatastoreContext())
            {
                var repository    = new DatastoreRepository(dataContext);
                var outMsgService = new OutMessageService(_config, repository, _messageBodyStore);

                IEnumerable <OutMessage> insertedMessageUnits =
                    outMsgService.InsertAS4Message(
                        messagingContext.AS4Message,
                        messagingContext.SendingPMode,
                        messagingContext.ReceivingPMode);

                await dataContext.SaveChangesAsync()
                .ConfigureAwait(false);

                ReplyHandling replyHandling = messagingContext.ReceivingPMode?.ReplyHandling;
                ReplyPattern? replyPattern  = replyHandling?.ReplyPattern;
                if (replyPattern == ReplyPattern.PiggyBack &&
                    replyHandling?.PiggyBackReliability?.IsEnabled == true)
                {
                    var piggyBackService = new PiggyBackingService(dataContext);
                    piggyBackService.InsertRetryForPiggyBackedSignalMessages(
                        insertedMessageUnits,
                        messagingContext.ReceivingPMode?.ReplyHandling?.PiggyBackReliability);

                    await dataContext.SaveChangesAsync()
                    .ConfigureAwait(false);
                }
            }
        }
        private static void TestQueryAsync()
        {
            try
            {
                using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
                {
                    //var results = repo.Query.Results();
                    //using (var pinger = repo.Query.Where(x=>x.Field1 == "V-2").ResultsAsync())
                    using (var pinger = repo.Query.ResultsAsync())
                    {
                        var startTime = DateTime.Now;
                        pinger.WaitUntilReady();
                        Console.WriteLine($"Time: {DateTime.Now.Subtract(startTime).TotalMilliseconds}");
                        var file = pinger.OutputFile;

                        List <MyItem> rr = null;
                        do
                        {
                            rr = pinger.GetItems(99);
                            Console.WriteLine($"Count={rr.Count}");
                        } while (rr.Any());
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// Handles the execution exception.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public async Task <MessagingContext> HandleExecutionException(Exception exception, MessagingContext context)
        {
            Logger.Error(exception.Message);

            using (DatastoreContext db = _createContext())
            {
                await db.TransactionalAsync(async ctx =>
                {
                    var repository = new DatastoreRepository(ctx);
                    var service    = new ExceptionService(_configuration, repository, _bodyStore);

                    InException entity =
                        context.SubmitMessage != null
                            ? await service.InsertIncomingSubmitExceptionAsync(exception, context.SubmitMessage, context.ReceivingPMode)
                            : await service.InsertIncomingAS4MessageExceptionAsync(exception, context.EbmsMessageId, context.ReceivingPMode);

                    await ctx.SaveChangesAsync();

                    service.InsertRelatedRetryReliability(entity, context.ReceivingPMode?.ExceptionHandling?.Reliability);
                    await ctx.SaveChangesAsync();
                });
            }

            return(new MessagingContext(exception)
            {
                ErrorResult = context.ErrorResult
            });
        }
        private static void Test44()
        {
            try
            {
                var ticks = DateTime.Now.Ticks;
                using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
                {
                    for (var ii = 0; ii < 1000; ii++)
                    {
                        var r6 = repo.Query
                                 .WhereUrl($"?q={ii}")
                                 .Results();
                        Console.WriteLine($"Index={ii}");

                        //foreach (var ritem in r6.AllDimensions.SelectMany(x => x.RefinementList))
                        //{
                        //    var r7 = repo.Query
                        //        .WhereUrl("?q=" + ticks++)
                        //        .WhereDimensionValue(ritem.DVIdx)
                        //        .Results();
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #8
0
        private void cmdRun_Click(object sender, EventArgs e)
        {
            txtResults.Text = "(Processing...)";
            try
            {
                if (Guid.TryParse(txtID.Text, out Guid g))
                {
                    using (var repository = new DatastoreRepository <MyItem>(g))
                    {
                        var result = repository.Query
                                     .WhereUrl(txtQuery.Text)
                                     .Results();

                        var sb = new StringBuilder();
                        sb.AppendLine($"ComputeTime={DateTime.Now.ToString("HH:mm:ss")}");
                        sb.AppendLine($"ComputeTime={result.Diagnostics.ComputeTime}");
                        sb.AppendLine($"Records={result.TotalRecordCount}");
                        sb.AppendLine($"DimensionCount={result.AllDimensions.Count}");
                        sb.AppendLine($"CacheHit={result.Diagnostics.CacheHit}");
                        txtResults.Text = sb.ToString();
                    }
                }
                else
                {
                    txtResults.Text = "(Error)";
                }
            }
            catch (Exception ex)
            {
                txtResults.Text = ex.ToString();
            }
        }
        /// <summary>
        /// Execute the step for a given <paramref name="messagingContext"/>.
        /// </summary>
        /// <param name="messagingContext">Message used during the step execution.</param>
        /// <returns></returns>
        public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext)
        {
            if (messagingContext?.AS4Message == null)
            {
                throw new InvalidOperationException(
                          $"{nameof(SetMessageToBeSentStep)} requires an AS4Message to mark for sending but no AS4Message is present in the MessagingContext");
            }

            Logger.Trace($"{messagingContext.LogTag} Set the message's Operation=ToBeSent");
            if (messagingContext.MessageEntityId == null)
            {
                throw new InvalidOperationException(
                          $"{messagingContext.LogTag} MessagingContext does not contain the ID of the OutMessage that must be set to ToBeSent");
            }

            using (DatastoreContext context = _createContext())
            {
                var repository = new DatastoreRepository(context);
                var service    = new OutMessageService(repository, _messageStore);

                service.UpdateAS4MessageToBeSent(
                    messagingContext.MessageEntityId.Value,
                    messagingContext.AS4Message,
                    messagingContext.SendingPMode?.Reliability?.ReceptionAwareness);

                await context.SaveChangesAsync().ConfigureAwait(false);
            }

            return(StepResult.Success(messagingContext));
        }
        private async Task InsertInMessageAsync(InMessage createInMessageFrom)
        {
            var context    = new DatastoreContext(_as4Msh.GetConfiguration());
            var repository = new DatastoreRepository(context);

            repository.InsertInMessage(createInMessageFrom);

            await context.SaveChangesAsync();
        }
            private TResult ExerciseRepository <TResult>(Func <DatastoreRepository, TResult> act)
            {
                using (DatastoreContext context = GetDataStoreContext())
                {
                    var sut = new DatastoreRepository(context);

                    // Act
                    return(act(sut));
                }
            }
 private static void DuplicateFilters()
 {
     using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
     {
         var q = repo.Query
                 .Where(x => x.Project == "v")
                 .Where(x => x.Project == "b")
                 .Results();
     }
 }
        private async Task UpdateDeliverMessageAccordinglyToUploadResult(string messageId, SendResult status)
        {
            using (DatastoreContext context = _createDbContext())
            {
                var repository = new DatastoreRepository(context);
                var service    = new MarkForRetryService(repository);

                service.UpdateDeliverMessageForUploadResult(messageId, status);
                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }
        /// <summary>
        /// Execute the step for a given <paramref name="messagingContext"/>.
        /// </summary>
        /// <param name="messagingContext">Message used during the step execution.</param>
        /// <returns></returns>
        public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext)
        {
            var entityMessage = messagingContext?.ReceivedMessage as ReceivedEntityMessage;

            if (!(entityMessage?.Entity is InMessage receivedInMessage))
            {
                throw new InvalidOperationException(
                          "The MessagingContext must contain a ReceivedMessage that represents an InMessage." + Environment.NewLine +
                          "Other types of ReceivedMessage models are not supported in this Step.");
            }

            // Forward message by creating an OutMessage and set operation to 'ToBeProcessed'.
            Logger.Info($"{messagingContext.LogTag} Create a message that will be forwarded to the next MSH");
            using (Stream originalInMessage =
                       await _messageStore.LoadMessageBodyAsync(receivedInMessage.MessageLocation))
            {
                string outLocation = await _messageStore.SaveAS4MessageStreamAsync(
                    _configuration.OutMessageStoreLocation,
                    originalInMessage);

                originalInMessage.Position = 0;

                AS4Message msg =
                    await SerializerProvider.Default
                    .Get(receivedInMessage.ContentType)
                    .DeserializeAsync(originalInMessage, receivedInMessage.ContentType);

                using (DatastoreContext dbContext = _createDataStoreContext())
                {
                    var repository = new DatastoreRepository(dbContext);

                    // Only create an OutMessage for the primary message-unit.
                    OutMessage outMessage = OutMessageBuilder
                                            .ForMessageUnit(
                        msg.PrimaryMessageUnit,
                        receivedInMessage.ContentType,
                        messagingContext.SendingPMode)
                                            .BuildForForwarding(outLocation, receivedInMessage);

                    Logger.Debug("Insert OutMessage {{Intermediary=true, Operation=ToBeProcesed}}");
                    repository.InsertOutMessage(outMessage);

                    // Set the InMessage to Forwarded.
                    // We do this for all InMessages that are present in this AS4 Message
                    repository.UpdateInMessages(
                        m => msg.MessageIds.Contains(m.EbmsMessageId),
                        r => r.Operation = Operation.Forwarded);

                    await dbContext.SaveChangesAsync();
                }
            }

            return(StepResult.Success(messagingContext));
        }
        private async Task InsertOutException(Exception exception, Stream body)
        {
            using (DatastoreContext context = _createContext())
            {
                var repository = new DatastoreRepository(context);
                var service    = new ExceptionService(_configuration, repository, _bodyStore);

                await service.InsertOutgoingExceptionAsync(exception, body);

                await context.SaveChangesAsync();
            }
        }
Exemple #16
0
        private async Task UpdateDeliverMessageAsync(MessagingContext messagingContext, SendResult result)
        {
            using (DatastoreContext context = _createDbContext())
            {
                var repository   = new DatastoreRepository(context);
                var retryService = new MarkForRetryService(repository);
                retryService.UpdateDeliverMessageForDeliverResult(
                    messagingContext.DeliverMessage.Message.MessageInfo.MessageId, result);

                await context.SaveChangesAsync().ConfigureAwait(false);
            }
        }
        private static void TestNonParsedField()
        {
            using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
            {
                var q = repo.Query
                        .AddNonParsedField("foo", "bar");

                //var dq = q.ToQuery();
                //Console.WriteLine(dq.NonParsedFieldList.Count);

                var r = q.Results();
                Console.WriteLine(r.Query.NonParsedFieldList.Count);
            }
        }
 private static void CreateRepo()
 {
     using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
     {
         if (repo.RepositoryExists())
         {
             repo.DeleteRepository();
         }
         if (!repo.RepositoryExists())
         {
             repo.CreateRepository();
         }
     }
 }
        private static void TestManyConnections()
        {
            try
            {
                //using (var repo = new DatastoreRepository<MyItem>(repoID, SERVER, PORT))
                //{
                //    var r6 = repo.Query.WhereUrl($"?q={0}").Results();
                //}


                var ticks = DateTime.Now.Ticks;
                //for (var ii = 0; ii < 1000000; ii++)
                Parallel.For(0, 1000, new ParallelOptions {
                    MaxDegreeOfParallelism = 12
                }, (ii) =>
                {
                    var timer = Stopwatch.StartNew();
                    using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
                    {
                        try
                        {
                            //var v = ii;
                            var v = ii % 100;
                            //var v = 2;
                            var timer5 = Stopwatch.StartNew();
                            var r6     = repo.Query.WhereUrl($"?q={v}").Results();
                            timer5.Stop();
                            Console.WriteLine($"Index={ii}, Elapsed={r6.Diagnostics.ComputeTime}, Elapsed={timer5.ElapsedMilliseconds}");
                        }
                        catch (Exception ex)
                        {
                            timer.Stop();
                            if (ex.InnerException != null)
                            {
                                Console.WriteLine($"Index={ii}, Elapsed={timer.ElapsedMilliseconds}, Error={ex.InnerException.Message}");
                            }
                            else
                            {
                                Console.WriteLine($"Index={ii}, Elapsed={timer.ElapsedMilliseconds}, Error={ex.Message}");
                            }
                        }
                    }
                }
                             );
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        private static void TestFailover()
        {
            var ii = 0;

            //FailoverConfiguration.Servers.Add(new ServerConfig { Server = "localhost", Port = 1973 });
            //FailoverConfiguration.Servers.Add(new ServerConfig { Server = "127.0.0.1", Port = 1974 });
            FailoverConfiguration.Servers.Add(new ServerConfig {
                Server = "10.13.31.13", Port = 1973
            });
            FailoverConfiguration.Servers.Add(new ServerConfig {
                Server = "127.0.0.1", Port = 1973
            });

            FailoverConfiguration.RetryOnFailCount = 0;
            var index = 0;

            do
            {
                var timer = Stopwatch.StartNew();
                try
                {
                    Parallel.For(0, 10000, new ParallelOptions {
                        MaxDegreeOfParallelism = 30
                    }, (kk) =>
                    {
                        var timer2 = Stopwatch.StartNew();
                        using (var repo = new DatastoreRepository <MyItem>(repoID, "@config", PORT))
                        {
                            Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} Started");
                            var r6 = repo.Query.WhereDimensionValue(_rnd.Next(1, 20)).Results();
                            //var r6 = repo.Query.Results();
                            timer2.Stop();
                            Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} Query Success, Count={index}, Elapsed={timer2.ElapsedMilliseconds}");
                            index++;
                        }
                    });
                }
                catch (Common.Exceptions.FailoverException ex)
                {
                    //Do Nothing - so it will try again
                    timer.Stop();
                    Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} Failed, Elapsed={timer.ElapsedMilliseconds}");
                }
                catch (Exception ex)
                {
                    timer.Stop();
                    Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}, Elapsed={timer.ElapsedMilliseconds}, Error={ex.Message}");
                }
            } while (ii == 0);
        }
        private static void InsertRandom()
        {
            var rnd = new Random();

            var dimValues = new List <string>();

            for (var ii = 1; ii <= 50; ii++)
            {
                dimValues.Add("Value " + ii);
            }

            var timer = Stopwatch.StartNew();

            using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
            {
                var list = new List <MyItem>();
                for (var ii = 0; ii < 50; ii++)
                {
                    var ID      = rnd.Next() % 9999999;
                    var newItem = new MyItem
                    {
                        Project     = "Hello" + ID,
                        Field1      = "V-" + (rnd.Next() % 5),
                        ID          = ID,
                        MyList      = new string[] { "aa", "bb" },
                        CreatedDate = DateTime.Now.AddMinutes(-_rnd.Next(0, 10000)),
                        Dim2        = "Dim2-" + (rnd.Next() % 10),
                        MyBool      = (rnd.Next(100) % 2 == 0) ? true : false,
                        MyFloat     = rnd.Next(1, 10000),
                        MyGeo       = new GeoCode {
                            Latitude = rnd.Next(-90, 90), Longitude = rnd.Next(-90, 90)
                        },
                        MyBool2    = (rnd.Next(100) % 2 == 0) ? true : false,
                        MyFloat2   = 2,
                        MyFloat3   = 4,
                        SomeInt2   = 5,
                        MyByte     = 40,
                        MyShort    = 99,
                        MyDecimal  = 66,
                        MyDecimal2 = 33,
                        MyLong     = 17626,
                    };
                    newItem.Dim2 = dimValues[rnd.Next(0, dimValues.Count)];
                    list.Add(newItem);
                }
                repo.InsertOrUpdate(list);
                timer.Stop();
                Console.WriteLine($"Added Items: Elapsed={timer.ElapsedMilliseconds}");
            }
        }
        private async Task <MessagingContext> HandleNotifyException(Exception exception, MessagingContext context)
        {
            Logger.Error(exception.Message);

            using (var dbContext = _createContext())
            {
                var repository = new DatastoreRepository(dbContext);

                if (context.NotifyMessage.EntityType == typeof(InMessage) ||
                    context.NotifyMessage.EntityType == typeof(InException))
                {
                    var inException = InException.ForEbmsMessageId(context.EbmsMessageId, exception);
                    repository.InsertInException(inException);

                    if (context.NotifyMessage.EntityType == typeof(InMessage))
                    {
                        Logger.Debug("Fatal fail in notification, set InMessage(s).Status=Exception");
                        repository.UpdateInMessage(context.EbmsMessageId, i => i.SetStatus(InStatus.Exception));
                    }
                }
                else if (context.NotifyMessage.EntityType != typeof(OutMessage) ||
                         context.NotifyMessage.EntityType == typeof(OutException))
                {
                    var outException = OutException.ForEbmsMessageId(context.EbmsMessageId, exception);
                    repository.InsertOutException(outException);

                    if (context.NotifyMessage.EntityType == typeof(OutMessage) &&
                        context.MessageEntityId != null)
                    {
                        Logger.Debug("Fatal fail in notification, set OutMessage.Status=Exception");
                        repository.UpdateOutMessage(
                            context.MessageEntityId.Value,
                            o => o.SetStatus(OutStatus.Exception));
                    }
                }

                if (context.MessageEntityId != null)
                {
                    Logger.Debug("Abort retry operation due to fatal notification exception, set Status=Completed");
                    repository.UpdateRetryReliability(
                        context.MessageEntityId.Value,
                        r => r.Status = RetryStatus.Completed);
                }

                await dbContext.SaveChangesAsync();
            }

            return(new MessagingContext(exception));
        }
        private async Task InsertReferencedInException(
            MessagingContext messagingContext,
            CancellationToken cancellation)
        {
            using (DatastoreContext context = _createContext())
            {
                var repository = new DatastoreRepository(context);
                var exception  = InException.ForEbmsMessageId(
                    messagingContext.AS4Message?.FirstSignalMessage?.RefToMessageId,
                    new Exception(messagingContext.ErrorResult.Description));

                repository.InsertInException(exception);
                await context.SaveChangesAsync(cancellation).ConfigureAwait(false);
            }
        }
        private static void TestAlive()
        {
            var timer = Stopwatch.StartNew();

            Parallel.For(0, 1000, new ParallelOptions {
                MaxDegreeOfParallelism = 20
            }, (ii) =>
            {
                using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
                {
                    repo.IsServerAlive();
                }
            });
            timer.Stop();
            Console.WriteLine($"Elapsed={timer.ElapsedMilliseconds}");
        }
Exemple #25
0
        /// <summary>
        /// Handles the transformation exception.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="messageToTransform">The <see cref="ReceivedMessage"/> that must be transformed by the transformer.</param>
        /// <returns></returns>
        public async Task <MessagingContext> HandleTransformationException(Exception exception, ReceivedMessage messageToTransform)
        {
            Logger.Error($"Exception occured during transformation: {exception.Message}");

            using (DatastoreContext db = _createContext())
            {
                var repository = new DatastoreRepository(db);
                var service    = new ExceptionService(_configuration, repository, _bodyStore);

                await service.InsertOutgoingExceptionAsync(exception, messageToTransform.UnderlyingStream);

                await db.SaveChangesAsync();
            }

            return(new MessagingContext(exception));
        }
            public void ThenInMessageExistsSucceeded(string sharedId)
            {
                // Arrange
                InsertInMessageWithOperation(sharedId);

                using (DatastoreContext context = GetDataStoreContext())
                {
                    var repository = new DatastoreRepository(context);

                    // Act
                    bool result = repository.InMessageExists(m => m.EbmsMessageId == sharedId);

                    // Assert
                    Assert.True(result);
                }
            }
 protected void InsertOutMessageWithLocation(
     string messageId,
     string contentType,
     bool intermediary)
 {
     using (DatastoreContext context = GetDataStoreContext())
     {
         var repo = new DatastoreRepository(context);
         repo.InsertOutMessage(new OutMessage(messageId)
         {
             MessageLocation = messageId,
             ContentType     = contentType,
             Intermediary    = intermediary
         });
         context.SaveChanges();
     }
 }
        private static void PerfTest()
        {
            try
            {
                var tList = new List <Task>();

                for (var ii = 0; ii < 10; ii++)
                {
                    tList.Add(new Task(() =>
                    {
                        long index = 0;
                        while (true)
                        {
                            using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
                            {
                                index++;
                                var id = _rnd.Next(1, 99999999);
                                //LoggerCQ.LogInfo("HitHard: ID=" + id + ", Index=" + index);
                                var results = repo.Query
                                              .Where(x => x.ID == id)
                                              .Results();
                            }
                        }
                    }));
                }

                for (var ii = 0; ii <= 10; ii++)
                {
                    tList.Add(new Task(() =>
                    {
                        while (true)
                        {
                            InsertRandom();
                        }
                    }));
                }

                tList.ForEach(x => x.Start());

                Task.WaitAll(tList.ToArray());
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 private static void Test12()
 {
     try
     {
         using (var repo = new DatastoreRepository <MyItem>(repoID, SERVER, PORT))
         {
             var query   = repo.Query.RecordsPerPage(20);
             var results = query.Results();
             var dlist   = query.DimensionsOnly();
             var url     = query.ToUrl();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
 private static void TestAllDimensions()
 {
     try
     {
         FailoverConfiguration.Servers.Add(new ServerConfig {
             Server = SERVER
         });
         using (var repo = new DatastoreRepository <MyItem>(repoID, "@config"))
         {
             var q = repo.Query.AllDimensions();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }