From 98cd7063d9b9a1570dcfbac92f5c2b35d904868b Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期一, 05 七月 2021 15:41:29 +0800 Subject: [PATCH] 修改修改 --- zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs | 83 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 82 insertions(+), 1 deletions(-) diff --git a/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs b/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs index 37f91c7..6108fcf 100644 --- a/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs +++ b/zhengcaioa/zhengcaioa/Controllers/LiaotianController.cs @@ -429,7 +429,88 @@ /// <summary> - /// 淇濆瓨 + /// 鎻愪氦骞跺鏍� + /// </summary> + /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param> + /// <returns></returns> + [HttpPost] + [CheckLogin] + public async Task<string> TijiaobingshenheAsync(LiaotianDTO data) + { + ResultEntity resultEntity = new ResultEntity(); + resultEntity.Result = false; + var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User")); + ViewData["curentuser"] = curentuser; + data.RecStatus = "A"; + data.Clientid = "A"; + if (String.IsNullOrEmpty(data.Id)) + { + data.Creater = curentuser.Id; + data.Createtime = DateTime.Now; + } + data.Modifier = curentuser.Id; + data.Modifytime = DateTime.Now; + + + + resultEntity = _liaotianService.saveLiaotian(data); + + string api_domain = _configuration.GetSection("Elasticsearchurl").Value; + string url = $"{api_domain}/liaotian/person/" + data.Id; + LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO(); + liaotianElasticsearchDTO.id = data.Id; + liaotianElasticsearchDTO.question = data.Question; + liaotianElasticsearchDTO.anwser = data.Anwser; + + + string requestJson = JsonConvert.SerializeObject(liaotianElasticsearchDTO); ; + try + { + string result = string.Empty; + Uri postUrl = new Uri(url); + + using (HttpContent httpContent = new StringContent(requestJson)) + { + httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); + + var httpClient = _clientFactory.CreateClient(); + httpClient.Timeout = new TimeSpan(0, 0, 60); + var Result = await httpClient.PutAsync(postUrl, httpContent); + result = Result.Content.ReadAsStringAsync().Result; + + + + } + + Newtonsoft.Json.Linq.JObject jobject = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(result); + + if (jobject["error"] == null && jobject["_shards"]["successful"].ToString() == "1") + { + resultEntity.Result = true; + } + else + { + resultEntity.Result = false; + } + + } + catch (Exception e) + { + resultEntity.Result = false; + throw e; + + + } + + + + + + return JsonConvert.SerializeObject(resultEntity); + } + + /// <summary> + /// 瀹℃牳 /// </summary> /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param> /// <returns></returns> -- Gitblit v1.9.1