From 1aa53fde5eb18a39c53daf910d69cb857913b08d Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期三, 06 七月 2022 15:23:02 +0800
Subject: [PATCH] 提交

---
 zhengcaioa/zhengcaioa/Controllers/ExpertTest/ExpertTestTopicController.cs |  120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 116 insertions(+), 4 deletions(-)

diff --git a/zhengcaioa/zhengcaioa/Controllers/ExpertTest/ExpertTestTopicController.cs b/zhengcaioa/zhengcaioa/Controllers/ExpertTest/ExpertTestTopicController.cs
index cf5f8ef..69ca945 100644
--- a/zhengcaioa/zhengcaioa/Controllers/ExpertTest/ExpertTestTopicController.cs
+++ b/zhengcaioa/zhengcaioa/Controllers/ExpertTest/ExpertTestTopicController.cs
@@ -82,6 +82,15 @@
             actionlist.Add(actionEntity2);
 
 
+            ActionEntity actionEntity3 = new ActionEntity();
+            actionEntity3.OpenType = 0;
+            actionEntity3.ActionUrl = "";
+            actionEntity3.ActionFun = "Zhuanyi";
+            actionEntity3.PageIco = "fa fa-plus";
+            actionEntity3.ActionName = "鏁版嵁杞Щ";
+            actionlist.Add(actionEntity3);
+
+
             ViewData["ActionInfo"] = actionlist;
 
 
@@ -316,7 +325,7 @@
             {
 
                 string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
-                string url = $"{api_domain}/liaotian/person/" + data.Id;
+                string url = $"{api_domain}/liaotian/_doc/" + data.Id;
                 //string requestJson = "{\"id\": \"" + Id + "\",\"question\": \"" + data.Question + "\",\"anwser\": \"" + data.Anwser + "\"}";
                 try
                 {
@@ -417,7 +426,7 @@
             resultEntity = _expertTestTopicService.shenpi(data);
 
             string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
-            string url = $"{api_domain}/liaotian/person/" + data.Id;
+            string url = $"{api_domain}/liaotian/_doc/" + data.Id;
             LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
             liaotianElasticsearchDTO.id = data.Id;
             liaotianElasticsearchDTO.question = data.Topic;
@@ -533,7 +542,7 @@
               data = _expertTestTopicService.Get(data.Id);
             var datadtls = _expertTestTopicService.GetListanwser(data.Id);
             string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
-            string url = $"{api_domain}/liaotian/person/" + data.Id;
+            string url = $"{api_domain}/liaotian/_doc/" + data.Id;
             LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
             liaotianElasticsearchDTO.id = data.Id;
             liaotianElasticsearchDTO.question = data.Topic;
@@ -616,7 +625,7 @@
             ResultEntity resultEntity = _expertTestTopicService.ModifyStatus(Id, curentuser.Id);
 
             string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
-            string url = $"{api_domain}/liaotian/person/" + Id;
+            string url = $"{api_domain}/liaotian/_doc/" + Id;
             //string requestJson = "{\"id\": \"" + Id + "\",\"question\": \"" + data.Question + "\",\"anwser\": \"" + data.Anwser + "\"}";
             try
             {
@@ -1093,5 +1102,108 @@
             return View();
 
         }
+
+
+
+        /// <summary>
+        /// 杞Щ鏁版嵁
+        /// </summary>
+        /// <param name="data">宀椾綅瀹炰綋绫诲璞�</param>
+        /// <returns></returns>
+
+        [CheckLogin]
+        public async Task<string> ZhuanyiAsync()
+        {
+            var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
+            ViewData["curentuser"] = curentuser;
+            ResultEntity resultEntity = new ResultEntity();
+            resultEntity.Result = false;
+
+            var expertTestTopicDTOs = _expertTestTopicService.GetList().Where(x => x.ShenpiStatus == "A").ToList();
+
+
+            try
+            {
+                foreach (var data in expertTestTopicDTOs)
+                {
+
+
+                    string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
+                    string url = $"{api_domain}/liaotian/_doc/" + data.Id;
+
+                    var datadtls = _expertTestTopicService.GetListanwser(data.Id);
+                    LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
+                    liaotianElasticsearchDTO.id = data.Id;
+                    liaotianElasticsearchDTO.question = data.Topic;
+                    liaotianElasticsearchDTO.anwser = data.Topic + "  </br> ";
+                    foreach (var datadtl in datadtls)
+                    {
+                        if (datadtl.Shifouzhengqu == "A")
+                        {
+                            liaotianElasticsearchDTO.anwser += "<font color=\"#FF0000\">" + datadtl.Anwserno + " " + datadtl.Anwser + "</font>   </br>";
+                        }
+                        else
+                        {
+                            liaotianElasticsearchDTO.anwser += datadtl.Anwserno + " " + datadtl.Anwser + "  </br> ";
+                        }
+
+                    }
+
+
+
+                    string requestJson = JsonConvert.SerializeObject(liaotianElasticsearchDTO);
+
+
+
+
+
+                
+                    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;
+                        return JsonConvert.SerializeObject(resultEntity);
+                    }
+                }
+
+
+
+            }
+            catch (Exception e)
+            {
+                resultEntity.Result = false;
+                throw e;
+
+
+            }
+
+
+
+
+
+            return JsonConvert.SerializeObject(resultEntity);
+        }
+
     }
 }

--
Gitblit v1.9.1