public IHttpActionResult GetServiceApiResult(RequestJson obj) { string ret = String.Empty; #region 发送Request请求 DateTime reqeustdt = DateTime.Now; HttpWebRequest proxyRequest = HttpWebRequest.Create("http://" + Url.Request.Headers.Host + "/api/" + obj.code) as HttpWebRequest; proxyRequest.Method = "POST"; proxyRequest.KeepAlive = false; proxyRequest.ContentType = "application/json"; proxyRequest.Timeout = 200000; byte[] aryBuf = Encoding.GetEncoding("utf-8").GetBytes(obj.ToString()); proxyRequest.ContentLength = aryBuf.Length; using (Stream writer = proxyRequest.GetRequestStream()) { writer.Write(aryBuf, 0, aryBuf.Length); writer.Close(); writer.Dispose(); } #endregion #region 返回Response using (WebResponse response = proxyRequest.GetResponse()) { StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")); ret = reader.ReadToEnd(); reader.Close(); reader.Dispose(); } #endregion return(new TextResult(ret, Request)); }
public Mensagem VerificarLocalizacaoEmpreendimento(string easting, string northing, int estadoID, int municipioID) { RequestJson requestJson = new RequestJson(); ResponseJsonData <dynamic> resposta = new ResponseJsonData <dynamic>(); Municipio municipioCoordenada = new Municipio(); resposta = requestJson.Executar <dynamic>(_configCoordenada.Obter <String>(ConfiguracaoCoordenada.KeyUrlObterMunicipioCoordenada) + "?easting=" + easting + "&northing=" + northing); if (estadoID != 8 && !Convert.ToBoolean(resposta.Data["EstaNoEstado"])) { return(new Mensagem()); } if (Convert.ToBoolean(resposta.Data["EstaNoEstado"])) { municipioCoordenada = new ListaValoresDa().ObterMunicipio(Convert.ToInt32(resposta.Data["Municipio"]["IBGE"])); } if (municipioCoordenada.Id != municipioID) { return(Msg.MunicipioEmpreendimentoDiferenteResponsavel); } if (estadoID != 8 && Convert.ToBoolean(resposta.Data["EstaNoEstado"])) { return(Msg.MunicipioEmpreendimentoDiferenteResponsavel); } if (estadoID == 8 && !Convert.ToBoolean(resposta.Data["EstaNoEstado"])) { return(Msg.MunicipioEmpreendimentoDiferenteResponsavel); } return(new Mensagem()); }
public string ObterUrlDemonstrativo(int solicitacaoId, int schemaSolicitacao, bool isTitulo) { var urlGerar = _da.ObterUrlGeracaoDemonstrativo(solicitacaoId, schemaSolicitacao, isTitulo) ?? ""; if (String.IsNullOrWhiteSpace(urlGerar)) { return(null); } RequestJson requestJson = new RequestJson(); urlGerar = "http://www.car.gov.br/pdf/demonstrativo/" + urlGerar + "/gerar"; //urlGerar = "http://homolog-car.mma.gov.br/pdf/demonstrativo/" + urlGerar + "/gerar"; var strResposta = requestJson.Executar(urlGerar); var resposta = requestJson.Deserializar <dynamic>(strResposta); if (resposta["status"] != "s") { return(string.Empty); } return(UrlSICAR + resposta["dados"]); // PRODUCAO //return "http://homolog-car.mma.gov.br" + resposta["dados"]; // HOMOLOG }
public static void parseStreamToRequestJsonByExcel(PdfStream stream, RequestJson json) { json.id = stream.id; json.isSuccess = stream.excel_flag.ToString(); json.programName = stream.program_name; json.errorCode = stream.excel_flag.ToString(); }
public ResponseJsonData <dynamic> ObterEstadosMunicipiosPorCoordenada(String easting, String northing) { //CrossDomain case RequestJson requestJson = new RequestJson(); ResponseJsonData <dynamic> resposta = new ResponseJsonData <dynamic>(); try { resposta = requestJson.Executar <dynamic>(_configCoordenada.Obter <String>(ConfiguracaoCoordenada.KeyUrlObterMunicipioCoordenada) + "?easting=" + easting + "&northing=" + northing); if (resposta.Erros != null && resposta.Erros.Count > 0) { Validacao.Erros.AddRange(resposta.Erros); } var objJson = resposta.Data; if (objJson["EstaNoEstado"] && (objJson["Municipio"] == null || Convert.ToInt32(objJson["Municipio"]["IBGE"] ?? 0) == 0)) { Validacao.Add(Mensagem.Mapas.MunicipioSemRetorno); } } catch (Exception exc) { Validacao.AddErro(exc); } return(resposta); }
public static void buyCity(string CurrentUserGame, string CurrentUserId) { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); MakeRequestResponse command = new MakeRequestResponse(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; command.intersection = 20; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buyCity", command).Then(Response => { Debug.Log(Response.code); Debug.Log(Response.status); if (Response.code == 202) { JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); json_message.AddField("username", LoginScript.CurrentUser); json_message.AddField("intersection", command.intersection); socket.Emit("buyCity", json_message); } }).Catch(err => { Debug.Log(err); }); }
public static IEnumerable <string> CafdCalculatedInSCB(RequestJson jsonContentObj) { if (jsonContentObj != null && jsonContentObj.ecuData != null) { return(jsonContentObj.ecuData.SelectMany((EcuData a) => a.CafdId)); } return(new string[0]); }
public ResponseJson GetServiceLogic(RequestJson requestJson) { var res = new ResponseJson(); res.Name = requestJson.Name?.ToUpper(); res.Message = requestJson.Message?.ToUpper(); res.ServiceMessage = this.serviceMessage; return(res); }
public static async Task <T> Post <T>(string controller, string action, object param) where T : class { var requestUrl = Url + controller + "/" + action; var parameters = new Dictionary <string, string> { { "parameter", JsonConvert.SerializeObject(param) } }; return(await RequestJson.Post <T>(requestUrl, parameters)); }
void OnMouseDown() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); Text txt = FindTextFiel.find(); MakeRequestResponse command = new MakeRequestResponse(); command.gameId = LoginScript.CurrentUserGameId; command.playerId = LoginScript.CurrentUserGEId; command.intersection = int.Parse(piece.name); RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buyCity", command).Then(Response => { req.code = Response.code; req.status = Response.status; if (req.code == 200) { JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); json_message.AddField("username", LoginScript.CurrentUser); json_message.AddField("intersection", command.intersection); socket.Emit("buyCity", json_message); allPieces.SetActive(false); if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser) { AfiseazaDrum.afiseaza(newPieceO1, piece); } else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser) { AfiseazaDrum.afiseaza(newPieceO2, piece); } else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser) { AfiseazaDrum.afiseaza(newPieceO3, piece); } else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser) { AfiseazaDrum.afiseaza(newPieceO4, piece); } } Debug.Log(req.code); Debug.Log(req.status); txt.text = req.status; }).Catch(err => { Debug.Log(err); }); allPieces.SetActive(false); }
public void TestGetServiceLogic() { var exampleService = new ExampleService("test message"); var req = new RequestJson(); req.Name = "sample"; req.Message = "hello world"; var res = exampleService.GetServiceLogic(req); Assert.Equal("SAMPLE", res.Name); Assert.Equal("HELLO WORLD", res.Message); Assert.Equal("test message", res.ServiceMessage); }
public List <ArquivoProjeto> ObterArquivosOrtofotoWebService(ProjetoGeografico projeto) { List <ArquivoProjeto> arquivosOrtofotos = new List <ArquivoProjeto>(); try { RequestJson requestJson = new RequestJson(); GerenciadorConfiguracao <ConfiguracaoSistema> _config = new GerenciadorConfiguracao <ConfiguracaoSistema>(new ConfiguracaoSistema()); string urlGeoBasesWebService = _config.Obter <string>(ConfiguracaoSistema.KeyUrlGeoBasesWebServices); string geoBasesChave = _config.Obter <string>(ConfiguracaoSistema.KeyGeoBasesWebServicesAutencicacaoChave); ResponseJsonData <dynamic> resp = requestJson.Executar <dynamic>(urlGeoBasesWebService + "/Autenticacao/LogOn", RequestJson.GET, new { chaveAutenticacao = geoBasesChave }); if (resp.Erros != null && resp.Erros.Count > 0) { Validacao.Erros.AddRange(resp.Erros); return(null); } string mbrWkt = String.Format("POLYGON (({0} {1}, {2} {1}, {2} {3}, {0} {3}, {0} {1}))", projeto.MenorX.ToString(NumberFormatInfo.InvariantInfo), projeto.MenorY.ToString(NumberFormatInfo.InvariantInfo), projeto.MaiorX.ToString(NumberFormatInfo.InvariantInfo), projeto.MaiorY.ToString(NumberFormatInfo.InvariantInfo)); resp = requestJson.Executar <dynamic>(urlGeoBasesWebService + "/Ortofoto/ObterOrtofoto", RequestJson.POST, new { wkt = mbrWkt }); if (resp.Erros != null && resp.Erros.Count > 0) { Validacao.Erros.AddRange(resp.Erros); return(null); } foreach (var item in resp.Data) { arquivosOrtofotos.Add(new ArquivoProjeto() { Nome = Path.GetFileName(item["ArquivoNome"]), Caminho = item["ArquivoNome"], Chave = item["ArquivoChave"], ChaveData = Convert.ToDateTime(item["ArquivoChaveData"]) }); } } catch (Exception exc) { Validacao.AddErro(exc); } return(arquivosOrtofotos); }
public static Boolean updatePdfStreamDataPipeLineByExcel(List <PdfStream> pdfdata) { try { RequestJson request = new RequestJson(); if (pdfdata != null && pdfdata.Count > 0) { parseStreamToRequestJsonByExcel(pdfdata[0], request); } else { return(false); } string data = JsonConvert.SerializeObject(request); Console.WriteLine("updateexcel:" + data); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(PathUtil.updateUrl); req.Timeout = 1 * 60 * 1000; req.Method = "POST"; req.ContentType = "application/json"; Stream reqstream = req.GetRequestStream(); byte[] b = Encoding.ASCII.GetBytes(data); reqstream.Write(b, 0, b.Length); StreamReader responseReader = new StreamReader(req.GetResponse().GetResponseStream(), System.Text.Encoding.Default); string result = responseReader.ReadToEnd(); //url返回的值 responseReader.Close(); reqstream.Close(); Console.WriteLine(result); if (result != null && result.Length > 0) { Response re = JsonConvert.DeserializeObject <Response>(result); if (re.code == 0) { return(true); } return(false); } else { return(false); } } catch (Exception ex) { throw ex; } }
public void pressed() { Text txt = FindTextFiel.find(); MakeRequestResponse command2 = new MakeRequestResponse(); command2.gameId = LoginScript.CurrentUserGameId; command2.playerId = LoginScript.CurrentUserGEId; command2.answer = "yes"; command2.player = tex1.text; GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); RestClient.Post <MoveRobberRequest>("https://catan-connectivity.herokuapp.com/game/stealResource", command2).Then(Response2 => { Debug.Log("Stolen"); txt.text = Response2.status; JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); socket.Emit("Stolen", json_message); MakeRequestResponse command1 = new MakeRequestResponse(); command1.gameId = LoginScript.CurrentUserGameId; command1.playerId = LoginScript.CurrentUserGEId; RequestJson req1 = new RequestJson(); RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 => { Debug.Log("Update code " + Response1.code); Debug.Log("Update status " + Response1.status); Debug.Log("Update arguments lumber " + Response1.arguments.lumber); print("end turn info"); print(Response1.arguments.lumber.ToString()); print(Response1.arguments.ore.ToString()); print(Response1.arguments.grain.ToString()); print(Response1.arguments.brick.ToString()); print(Response1.arguments.wool.ToString()); ilumber.text = Response1.arguments.lumber.ToString(); iore.text = Response1.arguments.ore.ToString(); igrain.text = Response1.arguments.grain.ToString(); ibirck.text = Response1.arguments.brick.ToString(); iwool.text = Response1.arguments.wool.ToString(); }).Catch(err => { Debug.Log(err); }); }).Catch(err => { Debug.Log(err); }); }
public Maybe <Request> Receive() { var textMessage = (ITextMessage)messageConsumer.Receive(TimeSpan.FromMilliseconds(timeout)); if (textMessage == null) { return(Maybe <Request> .None); } var requestJson = RequestJson.Deserialize(textMessage.Text); var request = requestJson.To(); request.TextMessage = textMessage; return(Maybe <Request> .Some(request)); }
public static void rollDice(string CurrentUserGame, string CurrentUserId) { MakeRequestResponse command = new MakeRequestResponse(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/rollDice", command).Then(Response => { req.code = Response.code; req.status = Response.status; Debug.Log("Raspunsul este: " + CurrentUserGame); Debug.Log("Raspunsul2 este: " + CurrentUserId); }).Catch(err => { Debug.Log(err); }); }
public static void bankTrade(string CurrentUserGame, string CurrentUserId) { MakeRequestResponse command = new MakeRequestResponse(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; command.port = -1; command.offer = "wool"; command.request = "lumber"; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/noPlayerTrade", command).Then(Response => { Debug.Log(Response.code); Debug.Log(Response.status); }).Catch(err => { Debug.Log(err); }); }
public string ObterUrlRecibo(int solicitacaoId, int schemaSolicitacao) { var urlGerar = _da.ObterUrlGeracaoRecibo(solicitacaoId, schemaSolicitacao); RequestJson requestJson = new RequestJson(); var strResposta = requestJson.Executar(urlGerar); var resposta = requestJson.Deserializar <dynamic>(strResposta); if (resposta["status"] != "s") { return(string.Empty); } return(UrlSICAR + resposta["dados"]); }
public static void buildSettlement(string CurrentUserGame, string CurrentUserId) { MakeRequestResponse command = new MakeRequestResponse(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; command.intersection = 25; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buildSettlement", command).Then(Response => { req.code = Response.code; req.status = Response.status; Debug.Log(req.code); Debug.Log(req.status); }).Catch(err => { Debug.Log(err); }); }
public string ObterUrlRecibo(int solicitacaoId, int schemaSolicitacao) { var urlGerar = _da.ObterUrlGeracaoRecibo(solicitacaoId, schemaSolicitacao); RequestJson requestJson = new RequestJson(); var strResposta = requestJson.Executar(urlGerar); var resposta = requestJson.Deserializar <dynamic>(strResposta); if (resposta["status"] != "s") { return(string.Empty); } return(UrlSICAR + resposta["dados"]); // PRODUCAO //return "http://homolog-car.mma.gov.br" + resposta["dados"]; // HOMOLOG }
public String GetGeoInfo(Coordenada coordenada) { RequestJson requestJson = new RequestJson(); ResponseJsonData <dynamic> resposta = new ResponseJsonData <dynamic>(); String webServiceHost = _configCoord.Obter <String>(ConfiguracaoCoordenada.KeyUrlObterMunicipioCoordenada); String webServiceUri = new StringBuilder() .Append(webServiceHost) .Append("?easting=") .Append(coordenada.EastingUtm) .Append("&northing=") .Append(coordenada.NorthingUtm) .ToString(); resposta = requestJson.Executar <dynamic>(webServiceUri); return(resposta.Data); }
public static void playerTrade(string CurrentUserGame, string CurrentUserId) { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); TradePlayerJson command = new TradePlayerJson(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; command.lumber_o = 1; command.wool_o = 2; command.grain_o = 3; command.brick_o = 4; command.ore_o = 5; command.lumber_r = 6; command.wool_r = 7; command.grain_r = 8; command.brick_r = 9; command.ore_r = 10; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/playerTrade", command).Then(Response => { Debug.Log(Response.code); Debug.Log(Response.status); JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); json_message.AddField("username", LoginScript.CurrentUser); json_message.AddField("lumber_o", command.lumber_o); json_message.AddField("wool_o", command.wool_o); json_message.AddField("grain_o", command.grain_o); json_message.AddField("brick_o", command.brick_o); json_message.AddField("ore_o", command.ore_o); json_message.AddField("lumber_r", command.lumber_r); json_message.AddField("wool_r", command.wool_r); json_message.AddField("grain_r", command.grain_r); json_message.AddField("brick_r", command.brick_r); json_message.AddField("ore_r", command.ore_r); socket.Emit("playerTrade", json_message); }).Catch(err => { Debug.Log(err); }); }
public static bool CheckIfThereAreAnyNcdInTheRequest(RequestJson jsonContentObj) { bool?flag; if (jsonContentObj == null) { flag = null; } else { EcuData[] ecuData2 = jsonContentObj.ecuData; flag = ((ecuData2 != null) ? new bool?(ecuData2.Any <EcuData>()) : null); } if (flag.HasValue) { return(flag.Value); } return(false); }
public void TestFunction() { Environment.SetEnvironmentVariable("MESSAGE_TO_RETURN", "test message"); // Invoke the lambda function and confirm the string was upper cased. var function = new Function(); var context = new TestLambdaContext(); var req = new RequestJson(); req.Name = "sample"; req.Message = "hello world"; var res = function.FunctionHandler(req, context); Assert.Equal("SAMPLE", res.Name); Assert.Equal("HELLO WORLD", res.Message); Assert.Equal("test message", res.ServiceMessage); Environment.SetEnvironmentVariable("MESSAGE_TO_RETURN", ""); }
void CobaInsert() { int iduser = 50; int iditem = 60; int itemtotal = 110; AmqpControllerScript.amqpControl.exchangeSubscription.Handler = ProcessCoba; RequestJson request = new RequestJson(); request.id = id; request.type = "insertdata"; request.iduser = iduser; request.iditem = iditem; request.itemtotal = itemtotal; string requestJson = JsonUtility.ToJson(request); Debug.Log(requestJson); AmqpClient.Publish(AmqpControllerScript.amqpControl.requestExchange, AmqpControllerScript.amqpControl.requestRoutingKey, requestJson); }
public static void acceptTrade(string CurrentUserGame, string CurrentUserId) { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); TradePlayerJson command = new TradePlayerJson(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/wantToTrade", command).Then(Response => { Debug.Log("Accept Trade " + Response.code); Debug.Log("Accdept Trade " + Response.status); JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); json_message.AddField("username", LoginScript.CurrentUser); json_message.AddField("gameEngineId", LoginScript.CurrentUserGEId); json_message.AddField("wantToTrade", "true"); socket.Emit("wantToTrade", json_message); }).Catch(err => { Debug.Log(err); }); }
public static void endTurn(string CurrentUserGame, string CurrentUserId) { MakeRequestResponse command = new MakeRequestResponse(); command.gameId = CurrentUserGame; command.playerId = CurrentUserId; command.intersection = 0; command.start = 0; command.end = 0; //Debug.Log(CurrentUserGame); //Debug.Log(CurrentUserId); RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/endTurn", command).Then(Response => { req.code = Response.code; req.status = Response.status; req.arguments = Response.arguments; Debug.Log(req.code); Debug.Log(req.arguments); Debug.Log(req.status); }).Catch(err => { Debug.Log(err); }); }
public void updateResource() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); MakeRequestResponse command1 = new MakeRequestResponse(); command1.gameId = LoginScript.CurrentUserGameId; command1.playerId = LoginScript.CurrentUserGEId; RequestJson req1 = new RequestJson(); RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 => { Debug.Log("Update code " + Response1.code); Debug.Log("Update status " + Response1.status); Debug.Log("Update arguments lumber " + Response1.arguments.lumber); lumber.text = Response1.arguments.lumber.ToString(); ore.text = Response1.arguments.ore.ToString(); grain.text = Response1.arguments.grain.ToString(); brick.text = Response1.arguments.brick.ToString(); wool.text = Response1.arguments.wool.ToString(); }).Catch(err => { Debug.Log(err); }); }
public Sobreposicoes ObterGeoSobreposiacao(int id, eCaracterizacao tipo) { Sobreposicoes sobreposicoes = new Sobreposicoes(); try { sobreposicoes.DataVerificacao = DateTime.Now.ToString("dd/MM/yyyy - HH:mm", CultureInfo.CurrentCulture.DateTimeFormat); #region Empreendimento Sobreposicao sobreposicaoEmp = _da.ObterGeoSobreposicaoIdaf(id, tipo); if (sobreposicaoEmp == null) { sobreposicaoEmp = CriarObjSobreposicao(string.Empty); sobreposicaoEmp.Identificacao = " - "; } else { sobreposicaoEmp.TipoTexto = SobreposicaoTipo.Single(y => y.Id == (int)sobreposicaoEmp.Tipo).Texto; } sobreposicoes.Itens.Add(sobreposicaoEmp); #endregion #region Feicoes Geobases string ATPWkt = _da.ObterWktATP(id, tipo); string urlGeoBasesWebService = _config.Obter <string>(ConfiguracaoSistema.KeyUrlGeoBasesWebServices); urlGeoBasesWebService = urlGeoBasesWebService + "/Topologia/Relacao"; if (String.IsNullOrEmpty(ATPWkt)) { Validacao.Add(Mensagem.ProjetoGeografico.ATPNaoEncontrada); return(null); } //teste //urlGeoBasesWebService = "http://localhost:33716/Topologia/Relacao"; List <string> feicoes = new List <string>() { "HID_BACIA_HIDROGRAFICA", "LIM_TERRA_INDIGENA", "LIM_UNIDADE_PROTECAO_INTEGRAL", "LIM_UNIDADE_CONSERV_NAO_SNUC", "LIM_OUTRAS_UNID_PROTEGIDAS", "LIM_UNIDADE_USO_SUSTENTAVEL" }; RequestJson request = new RequestJson(); ResponseJsonData <List <FeicaoJson> > responseData = request.Executar <List <FeicaoJson> >(urlGeoBasesWebService, RequestJson.POST, new { feicoes = feicoes, wkt = ATPWkt }); if (responseData.Erros != null && responseData.Erros.Count > 0) { responseData.Erros.Insert(0, new Mensagem() { Tipo = eTipoMensagem.Erro, Texto = "Erro no WebService GeoBases" }); Validacao.Erros.AddRange(responseData.Erros); return(null); } Sobreposicao sobreposicao = null; foreach (var key in feicoes) { sobreposicao = CriarObjSobreposicao(key); if (!responseData.Data.Exists(x => x.Nome == key)) { sobreposicao.Identificacao = " - "; sobreposicoes.Itens.Add(sobreposicao); continue; } FeicaoJson feicaoJson = responseData.Data.First(x => x.Nome == key); List <string> lst = null; if (!feicaoJson.Geometrias.SelectMany(x => x.Atributos).Any(x => x.Nome == "ADMINISTRACAO")) { sobreposicao.Identificacao = String.Join("; ", feicaoJson.Geometrias.SelectMany(x => x.Atributos).Select(x => x.Valor).ToArray()); } else { lst = feicaoJson.Geometrias .Select(x => String.Format("{0} - {1}", x.Atributos.Single(y => y.Nome == "Nome").Valor, x.Atributos.Single(y => y.Nome == "ADMINISTRACAO").Valor)).ToList(); sobreposicao.Identificacao = String.Join("; ", lst.ToArray()); } sobreposicoes.Itens.Add(sobreposicao); } #endregion } catch (Exception exc) { Validacao.AddErro(exc); } return(sobreposicoes); }
public void Show() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); int j, i; Text txt = FindTextFiel.find(); MakeRequestResponse command = new MakeRequestResponse(); command.gameId = LoginScript.CurrentUserGameId; command.playerId = LoginScript.CurrentUserGEId; RequestJson req = new RequestJson(); RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/rollDice", command).Then(Response => { req.code = Response.code; req.status = Response.status; if (req.code == 200) { Debug.Log(Response.code); Debug.Log(Response.status); JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); json_message.AddField("username", LoginScript.CurrentUser); json_message.AddField("dice_1", Response.arguments.dice_1); json_message.AddField("dice_2", Response.arguments.dice_2); json_message.AddField("player_0", Response.arguments.player_0); json_message.AddField("lumber_0", Response.arguments.lumber_0); json_message.AddField("wool_0", Response.arguments.wool_0); json_message.AddField("grain_0", Response.arguments.grain_0); json_message.AddField("brick_0", Response.arguments.brick_0); json_message.AddField("ore_0", Response.arguments.ore_0); json_message.AddField("player_1", Response.arguments.player_1); json_message.AddField("lumber_1", Response.arguments.lumber_1); json_message.AddField("wool_1", Response.arguments.wool_1); json_message.AddField("grain_1", Response.arguments.grain_1); json_message.AddField("brick_1", Response.arguments.brick_1); json_message.AddField("ore_1", Response.arguments.ore_1); json_message.AddField("player_2", Response.arguments.player_2); json_message.AddField("lumber_2", Response.arguments.lumber_2); json_message.AddField("wool_2", Response.arguments.wool_2); json_message.AddField("grain_2", Response.arguments.grain_2); json_message.AddField("brick_2", Response.arguments.brick_2); json_message.AddField("ore_2", Response.arguments.ore_2); json_message.AddField("player_3", Response.arguments.player_3); json_message.AddField("lumber_3", Response.arguments.lumber_3); json_message.AddField("wool_3", Response.arguments.wool_3); json_message.AddField("grain_3", Response.arguments.grain_3); json_message.AddField("brick_3", Response.arguments.brick_3); json_message.AddField("ore_3", Response.arguments.ore_3); socket.Emit("RollDice", json_message); j = Response.arguments.dice_1; i = Response.arguments.dice_2; if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser) { lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_3).ToString(); ore.text = (int.Parse(ore.text) + Response.arguments.ore_3).ToString(); grain.text = (int.Parse(grain.text) + Response.arguments.grain_3).ToString(); brick.text = (int.Parse(brick.text) + Response.arguments.brick_3).ToString(); wool.text = (int.Parse(wool.text) + Response.arguments.wool_3).ToString(); } else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser) { lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_2).ToString(); ore.text = (int.Parse(ore.text) + Response.arguments.ore_2).ToString(); grain.text = (int.Parse(grain.text) + Response.arguments.grain_2).ToString(); brick.text = (int.Parse(brick.text) + Response.arguments.brick_2).ToString(); wool.text = (int.Parse(wool.text) + Response.arguments.wool_2).ToString(); } else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser) { lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_1).ToString(); ore.text = (int.Parse(ore.text) + Response.arguments.ore_1).ToString(); grain.text = (int.Parse(grain.text) + Response.arguments.grain_1).ToString(); brick.text = (int.Parse(brick.text) + Response.arguments.brick_1).ToString(); wool.text = (int.Parse(wool.text) + Response.arguments.wool_1).ToString(); } else if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser) { lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_0).ToString(); ore.text = (int.Parse(ore.text) + Response.arguments.ore_0).ToString(); grain.text = (int.Parse(grain.text) + Response.arguments.grain_0).ToString(); brick.text = (int.Parse(brick.text) + Response.arguments.brick_0).ToString(); wool.text = (int.Parse(wool.text) + Response.arguments.wool_0).ToString(); } switch (j) { case 1: side1.SetActive(true); side2.SetActive(false); side3.SetActive(false); side4.SetActive(false); side5.SetActive(false); side6.SetActive(false); break; case 2: side1.SetActive(false); side2.SetActive(true); side3.SetActive(false); side4.SetActive(false); side5.SetActive(false); side6.SetActive(false); break; case 3: side1.SetActive(false); side2.SetActive(false); side3.SetActive(true); side4.SetActive(false); side5.SetActive(false); side6.SetActive(false); break; case 4: side1.SetActive(false); side2.SetActive(false); side3.SetActive(false); side4.SetActive(true); side5.SetActive(false); side6.SetActive(false); break; case 5: side1.SetActive(false); side2.SetActive(false); side3.SetActive(false); side4.SetActive(false); side5.SetActive(true); side6.SetActive(false); break; case 6: side1.SetActive(false); side2.SetActive(false); side3.SetActive(false); side4.SetActive(false); side5.SetActive(false); side6.SetActive(true); break; } switch (i) { case 1: sside1.SetActive(true); sside2.SetActive(false); sside3.SetActive(false); sside4.SetActive(false); sside5.SetActive(false); sside6.SetActive(false); break; case 2: sside1.SetActive(false); sside2.SetActive(true); sside3.SetActive(false); sside4.SetActive(false); sside5.SetActive(false); sside6.SetActive(false); break; case 3: sside1.SetActive(false); sside2.SetActive(false); sside3.SetActive(true); sside4.SetActive(false); sside5.SetActive(false); sside6.SetActive(false); break; case 4: sside1.SetActive(false); sside2.SetActive(false); sside3.SetActive(false); sside4.SetActive(true); sside5.SetActive(false); sside6.SetActive(false); break; case 5: sside1.SetActive(false); sside2.SetActive(false); sside3.SetActive(false); sside4.SetActive(false); sside5.SetActive(true); sside6.SetActive(false); break; case 6: sside1.SetActive(false); sside2.SetActive(false); sside3.SetActive(false); sside4.SetActive(false); sside5.SetActive(false); sside6.SetActive(true); break; } if (i + j == 7) { tataHot.SetActive(true); int player_0_sum = int.Parse(lumber.text) + int.Parse(brick.text) + int.Parse(ore.text) + int.Parse(wool.text) + int.Parse(grain.text); if (player_0_sum > 7) { tataPanel.SetActive(true); player_0_sum = player_0_sum / 2; DiscarAmount.text = "You have to discard " + player_0_sum.ToString() + " of your cards"; ibirck.text = ""; iore.text = ""; ilumber.text = ""; igrain.text = ""; iwool.text = ""; } } } txt.text = req.status; }).Catch(err => { Debug.Log(err); }); }