| 52 | // BatchCompletionState printer - prints all what we know about completed batch |
| 53 | |
| 54 | static void print_cs(ThrowStatusWrapper& status, IBatchCompletionState* cs, IUtil* utl) |
| 55 | { |
| 56 | unsigned p = 0; |
| 57 | IStatus* s2 = NULL; |
| 58 | bool pr1 = false, pr2 = false; |
| 59 | |
| 60 | // 1. Print per-message state info |
| 61 | |
| 62 | unsigned upcount = cs->getSize(&status); |
| 63 | unsigned unk = 0, succ = 0; |
| 64 | for (p = 0; p < upcount; ++p) |
| 65 | { |
| 66 | int s = cs->getState(&status, p); |
| 67 | switch (s) |
| 68 | { |
| 69 | case IBatchCompletionState::EXECUTE_FAILED: |
| 70 | if (!pr1) |
| 71 | { |
| 72 | printf("Message Status\n"); |
| 73 | pr1 = true; |
| 74 | } |
| 75 | printf("%5u Execute failed\n", p); |
| 76 | break; |
| 77 | |
| 78 | case IBatchCompletionState::SUCCESS_NO_INFO: |
| 79 | ++unk; |
| 80 | break; |
| 81 | |
| 82 | default: |
| 83 | if (!pr1) |
| 84 | { |
| 85 | printf("Message Status\n"); |
| 86 | pr1 = true; |
| 87 | } |
| 88 | printf("%5u Updated %d record(s)\n", p, s); |
| 89 | ++succ; |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | printf("Summary: total=%u success=%u success(but no update info)=%u\n", upcount, succ, unk); |
| 94 | |
| 95 | // 2. Print detailed errors (if exist) for messages |
| 96 | |
| 97 | s2 = master->getStatus(); |
| 98 | for(p = 0; (p = cs->findError(&status, p)) != IBatchCompletionState::NO_MORE_ERRORS; ++p) |
| 99 | { |
| 100 | try |
| 101 | { |
| 102 | cs->getStatus(&status, s2, p); |
| 103 | |
| 104 | char text[1024]; |
| 105 | utl->formatStatus(text, sizeof(text) - 1, s2); |
| 106 | text[sizeof(text) - 1] = 0; |
| 107 | if (!pr2) |
| 108 | { |
| 109 | printf("\nDetailed errors status:\n"); |
| 110 | pr2 = true; |
| 111 | } |