Ejemplo n.º 1
0
        private void HandleInsertRequest(MongoInsertMessage request)
        {
            _querySynchronizer.StartBlockingAction();

            try
            {
                var changes = MongoMessageHandler.GetChanges(request);
                var hasErrors = !MongoMessageHandler.IsInsertAllowed(changes);

                if (!hasErrors)
                {
                    SendRequestToServer(request);
                }

                var checkErrorRequest = ReadClientRequest();

                if (!hasErrors)
                {
                    if (checkErrorRequest.GetType() != typeof (MongoQueryMessage) &&
                        !MessageDataExtractor.IsHasErrorRequest(checkErrorRequest))
                    {
                        //TODO: throw error. Und format
                    }

                    SendRequestToServer(checkErrorRequest);
                    var hasErrorResponse = ReadServerResponse();

                    if (!MessageDataExtractor.IsHasError(hasErrorResponse))
                    {
                        MongoMessageHandler.ApplyInsertChanges(changes);
                    }

                    SendResponseToClient(hasErrorResponse);
                }
                else
                {
                    //send error to client
                }
            }
            catch (Exception)
            {
                //TODO:
                throw;
            }
            finally
            {
                _querySynchronizer.StopBlockingAction();
            }
        }
Ejemplo n.º 2
0
 public static List<MongoReference> Parse( MongoInsertMessage message )
 {
     return message.Documents.SelectMany( Parse ).ToList();
 }
Ejemplo n.º 3
0
 public static List<ReferencePack> GetChanges(MongoInsertMessage request)
 {
     var packer = new ReferencePacker();
     packer.Add(MongoDocumentReferenceExtractor.Parse(request));
     return packer.Get();
 }