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(); } }
public static List<MongoReference> Parse( MongoInsertMessage message ) { return message.Documents.SelectMany( Parse ).ToList(); }
public static List<ReferencePack> GetChanges(MongoInsertMessage request) { var packer = new ReferencePacker(); packer.Add(MongoDocumentReferenceExtractor.Parse(request)); return packer.Get(); }