//---------------------------------------------------------------- bool TModuleServerLogic::WorkInherit() { InputFromSynchroPoint(); bool res = WorkServer(); CalcAndWaitRestTime(); EndWork(); res &= !NeedExit(); mStartTime = ht_GetMSCount(); return res; }
/** * \brief Function to solve the service solveAddWork * \param pb is a structure which corresponds to the descriptor of a profile * \return raises an exception on error */ int solveAddWork(diet_profile_t* pb) { std::string authKey; std::string workSerialized; std::string opSerialized; //IN Parameters diet_string_get(pb,0, authKey); diet_string_get(pb,1, workSerialized); diet_string_get(pb,2, opSerialized); // reset profile to handle result diet_profile_reset(pb, 2); //FIXME: SessionServer sessionServer = SessionServer(authKey); TMS_Data::AddWorkOptions_ptr workop = NULL; TMS_Data::Work_ptr work = NULL; try { std::string msgComp = ""; //MAPPER CREATION Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME); int mapperkey = mapper->code("vishnu_add_work"); mapper->code(opSerialized, mapperkey); std::string cmd = mapper->finalize(mapperkey); //To parse the object serialized if (! vishnu::parseEmfObject(workSerialized, work)) { throw TMSVishnuException(ERRCODE_INVALID_PARAM, msgComp); } //To parse the object serialized if (! vishnu::parseEmfObject(opSerialized, workop)) { throw TMSVishnuException(ERRCODE_INVALID_PARAM, msgComp); } WorkServer workServer = WorkServer(authKey, workop->getMachineId(), work); workServer.add(workop); //To serialize the user object ::ecorecpp::serializer::serializer _ser; std::string workSerializedUpdate = _ser.serialize_str(work); // set result diet_string_set(pb,0, "success"); diet_string_set(pb,1, workSerializedUpdate); FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDFAILED, work->getWorkId()); } catch (VishnuException& e) { try { FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, ""); } catch (VishnuException& fe) { e.appendMsgComp(fe.what()); } // set result diet_string_set(pb,0, "error"); diet_string_set(pb,1, e.what()); } delete work; return 0; }