public void RunConversion() { LfProjectConfig config = _factory.Create(_project).Config; FieldLists fieldConfigs = FieldListsForEntryAndSensesAndExamples(config); var fixedComments = new List <LfComment>(_conn.GetComments(_project)); string allCommentsJson = JsonConvert.SerializeObject(fixedComments); // _logger.Debug("Doing Lcm->Mongo direction. The json for ALL comments from Mongo would be: {0}", allCommentsJson); // _logger.Debug("Doing Lcm->Mongo direction. About to call LfMergeBridge with that JSON..."); string bridgeOutput; if (CallLfMergeBridge(allCommentsJson, out bridgeOutput)) { string newCommentsStr = ConvertMongoToLcmComments.GetPrefixedStringFromLfMergeBridgeOutput(bridgeOutput, "New comments not yet in LF: "); string newRepliesStr = ConvertMongoToLcmComments.GetPrefixedStringFromLfMergeBridgeOutput(bridgeOutput, "New replies on comments already in LF: "); string newStatusChangesStr = ConvertMongoToLcmComments.GetPrefixedStringFromLfMergeBridgeOutput(bridgeOutput, "New status changes on comments already in LF: "); List <LfComment> comments = JsonConvert.DeserializeObject <List <LfComment> >(newCommentsStr); List <Tuple <string, List <LfCommentReply> > > replies = JsonConvert.DeserializeObject <List <Tuple <string, List <LfCommentReply> > > >(newRepliesStr); List <KeyValuePair <string, Tuple <string, string> > > statusChanges = JsonConvert.DeserializeObject <List <KeyValuePair <string, Tuple <string, string> > > >(newStatusChangesStr); foreach (LfComment comment in comments) { // LfMergeBridge only sets the Guid in comment.Regarding, and leaves it to the LfMerge side to set the rest of the fields meaningfully if (comment.Regarding != null) { Guid guid; if (Guid.TryParse(comment.Regarding.TargetGuid ?? "", out guid)) { // The GUID in Chorus notes MIGHT be an entry, or it might be a sense or an example sentence. // We want to handle these three cases differently -- see FromTargetGuid below. comment.Regarding = FromTargetGuid(guid, fieldConfigs); } } // _logger.Debug("Comment by {6} regarding field {0} (containing {1}) of word {2} (GUID {7}, meaning {3}) has content {4}{5} and status {8} (GUID {9})", // comment.Regarding.FieldNameForDisplay, // comment.Regarding.FieldValue, // comment.Regarding.Word, // comment.Regarding.Meaning, // comment.Content, // comment.Replies.Count <= 0 ? "" : " and replies [" + String.Join(", ", comment.Replies.Select(reply => "\"" + reply.Content + "\"")) + "]", // comment.AuthorNameAlternate ?? "<null>", // comment.Regarding.TargetGuid, // comment.Status, // comment.StatusGuid // ); } _conn.UpdateComments(_project, comments); _conn.UpdateReplies(_project, replies); _conn.UpdateCommentStatuses(_project, statusChanges); } else { // Failure, which has already been logged so we don't need to log it again } }