public async Task <IActionResult> TopicDetail(TopicModel model) { var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity)); if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId)) { return(new JsonResult(new { Code = "400", Message = "用户登录异常,请先登录。" })); } model.Introduction = string.IsNullOrEmpty(model.Introduction) ? "" : model.Introduction; var url = "http://activityservice.gooios.com/api/topic/v1"; var ourl = "http://organizationservice.gooios.com/api/organization/v1/getbyid"; var imgServiceUrl = "https://imageservice.gooios.com/api/image/v1/"; var org = await HttpRequestHelper.GetAsync <OrganizationDTO>(ourl, $"id={applicationUser.OrganizationId}", "999960bff18111e799160126c7e9f568", applicationUser.Id); if (org != null) { if (model.Address == null || string.IsNullOrEmpty(model.Address.StreetAddress)) { model.Address = org.Address; } model.OrganizationName = org.ShortName; model.CreatorName = org.ShortName; imgServiceUrl += org.LogoImageId; var logoimg = await HttpRequestHelper.GetAsync <ImageDTO>(imgServiceUrl, "", "63e960bff18111e799160126c7e9f004", applicationUser.Id); model.CreatorPortraitUrl = logoimg?.HttpPath; } if (string.IsNullOrEmpty(model.Id)) { model.OrganizationId = applicationUser.OrganizationId; var jsonObj = JsonConvert.SerializeObject(model); await HttpRequestHelper.PostNoResultAsync(url, jsonObj, "83e960bff18221e39916012cc8e9f609", applicationUser.Id); } else { model.OrganizationId = applicationUser.OrganizationId; var jsonObj = JsonConvert.SerializeObject(model); await HttpRequestHelper.PutNoResultAsync(url, jsonObj, "83e960bff18221e39916012cc8e9f609", applicationUser.Id); } return(new JsonResult(new { Code = "200", Message = "保存成功。" })); }
public async Task <IActionResult> ServiceDetail(ServiceModel model) { var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity)); if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId)) { return(new JsonResult(new { Code = "400", Message = "用户登录异常,请先登录。" })); } model.Category = string.IsNullOrEmpty(model.Category) ? "" : model.Category; model.SubCategory = (string.IsNullOrEmpty(model.SubCategory) || model.SubCategory == "请选择") ? null : model.SubCategory; var url = "http://fancyservice.gooios.com/api/service/v1"; var ourl = "http://organizationservice.gooios.com/api/organization/v1/getbyid"; if (string.IsNullOrEmpty(model.Id)) { model.OrganizationId = applicationUser.OrganizationId; var org = await HttpRequestHelper.GetAsync <OrganizationDTO>(ourl, $"id={applicationUser.OrganizationId}", "999960bff18111e799160126c7e9f568", applicationUser.Id); if (org != null) { model.Station = org.Address; } var jsonObj = JsonConvert.SerializeObject(model); await HttpRequestHelper.PostNoResultAsync(url, jsonObj, "768960bff18111e79916016898e9f885", applicationUser.Id); } else { model.OrganizationId = applicationUser.OrganizationId; var org = await HttpRequestHelper.GetAsync <OrganizationDTO>(ourl, $"id={applicationUser.OrganizationId}", "999960bff18111e799160126c7e9f568", applicationUser.Id); if (org?.Address != null) { model.Station = org.Address; } var jsonObj = JsonConvert.SerializeObject(model); await HttpRequestHelper.PutNoResultAsync(url, jsonObj, "768960bff18111e79916016898e9f885", applicationUser.Id); } return(new JsonResult(new { Code = "200", Message = "保存成功。" })); }
private static void Main(string[] args) { // Dummy query to wake the server up var result = HttpRequestHelper.GetAsync("http://127.0.0.1:4321/api/game", Token).Result; WaitFor("Initialize client"); UdpGameClient = new UdpGameClient("127.0.0.1", 5001); var udpPort = ((IPEndPoint)UdpGameClient.Client.Client.LocalEndPoint).Port; UserWebSocket = new WebSocketClient($"ws://127.0.0.1:6789/User/?auth_token={Token}&udp_port={udpPort}"); UserWebSocket.Connect(); //Create_game_with_new_map_and_join(); Create_game_with_new_map_and_join(); WaitFor("Disconnect client"); UserWebSocket.Close(); WaitFor("End"); }
/// <summary> /// Get the image for the map and return it's path /// </summary> /// <param name="mapHashId"></param> /// <param name="imagePath"></param> /// <returns></returns> public string GetMapImage(string mapHashId, string imagePath = null) { var httpResponse = HttpRequestHelper.GetAsync(Endpoint + "/image/" + mapHashId, UserToken.Token).Result; var body = HttpRequestHelper.GetContent(httpResponse).Result; var statusCode = HttpRequestHelper.GetStatusCode(httpResponse); if (statusCode != HttpStatusCode.OK) { throw new Exception(body); } var fileData = JsonConvert.DeserializeObject <byte[]>(body); var path = imagePath ?? Path.GetTempPath() + mapHashId + ".png"; using (var image = Image.FromStream(new MemoryStream(fileData))) { image.Save(path, ImageFormat.Png); } return(path); }