| 111 | |
| 112 | |
| 113 | bool WorkflowMachine::PostRequest(const std::string& command) |
| 114 | { |
| 115 | rapidjson::Document request(rapidjson::kObjectType); |
| 116 | rapidjson::Document::AllocatorType& allocator = request.GetAllocator(); |
| 117 | rapidjson::Value commandValue(command.c_str(), command.size(), allocator); |
| 118 | request.AddMember("command", commandValue, allocator); |
| 119 | rapidjson::StringBuffer buffer; |
| 120 | rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); |
| 121 | request.Accept(writer); |
| 122 | |
| 123 | string jsonResult; |
| 124 | if (m_function) |
| 125 | jsonResult = BNPostWorkflowRequestForFunction(m_function->GetObject(), buffer.GetString()); |
| 126 | else |
| 127 | jsonResult = BNPostWorkflowRequestForBinaryView(m_view->GetObject(), buffer.GetString()); |
| 128 | |
| 129 | rapidjson::Document response(rapidjson::kObjectType); |
| 130 | response.Parse(jsonResult.c_str()); |
| 131 | if (response.HasMember("commandStatus") && response["commandStatus"].HasMember("accepted")) |
| 132 | return response["commandStatus"]["accepted"].GetBool(); |
| 133 | |
| 134 | return false; |
| 135 | } |
| 136 | |
| 137 | |
| 138 | WorkflowMachine::WorkflowMachine(Ref<BinaryView> view): m_view(view) |