public IEnumerator GetModel(MonoBehaviour owner) { yield return(GetNumModels(owner)); var keccak = new Sha3Keccak(); var d = keccak.CalculateHash("getModel(uint256)"); d = d.Substring(0, 8); // get latest model var value = EthereumAbiUtil.EncodeInt32(numModels - 1); string data = EncodeData("0x" + d + value); Request req = new Request(owner, Get <Call>("eth_call", data)); yield return(req.Coroutine); Call response = req.result as Call; modelResponse = new GetModelResponse(response.result); Debug.LogFormat("Model {0}, {1}. {2}, {3}, {4}", modelResponse.address, modelResponse.bounty, modelResponse.initialError, modelResponse.targetError, modelResponse.configAddress); }
public static GetModelResponse Unmarshall(UnmarshallerContext _ctx) { GetModelResponse getModelResponse = new GetModelResponse(); getModelResponse.HttpResponse = _ctx.HttpResponse; getModelResponse.RequestId = _ctx.StringValue("GetModel.RequestId"); getModelResponse.Data = _ctx.StringValue("GetModel.Data"); getModelResponse.Code = _ctx.IntegerValue("GetModel.Code"); getModelResponse.Message = _ctx.StringValue("GetModel.Message"); getModelResponse.Success = _ctx.BooleanValue("GetModel.Success"); return(getModelResponse); }
// Get the information about the mesh. public void GetModelInfo(System.Action<BackendRequestResult, GetModelResponse> resultFunction) { StartCoroutine(GetRequest(_modelURL,(BackendRequestResult result)=> { GetModelResponse responseObject = new GetModelResponse(); if (result.Success) { responseObject = JsonUtility.FromJson<GetModelResponse>(result.ResponseString); } if (resultFunction != null) { resultFunction(result, responseObject); } })); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { GetModelResponse response = new GetModelResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("contentType", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ContentType = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("schema", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Schema = unmarshaller.Unmarshall(context); continue; } } return(response); }
public IEnumerator GetModel(MonoBehaviour owner) { yield return(GetNumModels(owner)); var keccak = new Sha3Keccak(); var d = keccak.CalculateHash("getModel(uint256)"); d = d.Substring(0, 8); // get latest model var value = EthereumAbiUtil.EncodeInt32(numModels - 1); string data = EncodeData("0x" + d + value); Request req = new Request(owner, Get <Call>("eth_call", data)); yield return(req.Coroutine); Call response = req.result as Call; modelResponse = new GetModelResponse(response.result); }
private async void GetModels() { Models = new ObservableCollection <DeviceModel>(); var service = ServicesManager.SelfService; try { GetModelResponse modelResponse = await service.GetModels(Token); if (modelResponse == null || modelResponse.Error != ErrorCode.OK) { MainWindow.Instance.AddNotification(modelResponse ?? new BaseResponse() { Error = ErrorCode.InternalError, Message = "Failed to receive response from host." }); } else { foreach (var mdl in modelResponse.Models) { Models.Add(mdl); } if (Models.Count > 0) { CurrentModel = Models[0]; } } } catch (ServiceException ex) { //TODO: HIGH Add logging MainWindow.Instance.AddNotification(ex); } }
public static ModelDataViewModel GetModel(int modelId) { var viewModel = new ModelDataViewModel { ModelID = modelId }; try { using (_certonaService = new CertonaServiceClient()) { try { var request = new GetModelRequest { ModelID = modelId, User = FormsAuthenticationWrapper.User }; GetModelResponse response = _certonaService.GetModel(request); var columnGroupHeaders = new List <string>(); if (response.Errors != null && response.Errors.Count != 0) { viewModel.Errors = response.Errors.ToList(); } if (response.Model != null) { ModelDTO mDTO = response.Model; GetModelData(mDTO, ref viewModel.GridData, ref columnGroupHeaders); } viewModel.ColumnGroupHeaders = new string[columnGroupHeaders.Count]; viewModel.ColumnGroupHeaders = columnGroupHeaders.ToArray(); if (response.Model != null) { viewModel.CatalogName = response.Model.CatalogName; viewModel.ModelName = response.Model.Name; } } catch (TimeoutException exception) { _certonaService.Abort(); throw; } catch (CommunicationException exception) { _certonaService.Abort(); throw; } } } catch (Exception ex) { viewModel.Errors.Add(new ErrorResult { Description = ex.Message }); } return(viewModel); }