using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Net.Http;
|
using System.Net.Http.Headers;
|
using System.Threading.Tasks;
|
using zhengcaioa.IService;
|
using zhengcaioa.Models;
|
|
namespace zhengcaioa.Controllers
|
{
|
public class LiaotianController : Controller
|
{
|
private readonly ILogger<LiaotianController> _logger;
|
private readonly ILiaotianService _liaotianService;
|
private readonly IUserService _userService;
|
private readonly IHttpClientFactory _clientFactory;
|
private readonly IConfiguration _configuration;
|
private readonly IPltPageService _pltPageService;
|
|
|
public LiaotianController(ILogger<LiaotianController> logger, ILiaotianService liaotianService, IUserService userService, IHttpClientFactory clientFactory, IConfiguration configuration, IPltPageService pltPageService)
|
{
|
_logger = logger;
|
_liaotianService = liaotianService;
|
_userService = userService;
|
_clientFactory = clientFactory;
|
_configuration = configuration;
|
_pltPageService = pltPageService;
|
}
|
public IActionResult Index()
|
{
|
|
return View();
|
}
|
public async Task<JsonResult> FIndAsync(string key,string info)
|
{
|
//var key1 = key;
|
//var info1 = info;
|
// LiaotianDTOSearch search = new LiaotianDTOSearch();
|
// search.page = 1;
|
// search.rows = 20;
|
// search.Info = info;
|
// return new JsonResult(_liaotianService.SearchByPaging(search));
|
ResultDataEntity<LiaotianElasticsearchDTO> data = new ResultDataEntity<LiaotianElasticsearchDTO>();
|
List<LiaotianElasticsearchDTO> liaotianElasticsearchDTOs = new List<LiaotianElasticsearchDTO>();
|
|
string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
|
string url = $"{api_domain}/liaotian/_doc/_search";
|
|
string question = info;
|
|
JObject questions = new JObject();
|
questions.Add("question", question);
|
JObject match = new JObject();
|
match.Add("match", questions);
|
JObject query = new JObject();
|
query.Add("query", match);
|
|
string requestJson = query.ToString();
|
|
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.PostAsync(postUrl, httpContent);
|
result = Result.Content.ReadAsStringAsync().Result;
|
|
|
|
}
|
|
JObject jobject = (JObject)JsonConvert.DeserializeObject(result);
|
|
if (jobject["error"] == null && jobject["_shards"]["successful"].ToString() == "1")
|
{
|
JArray hits = (JArray)jobject["hits"]["hits"];
|
foreach(var hit in hits)
|
{
|
LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
|
liaotianElasticsearchDTO.id = hit["_source"]["id"].ToString();
|
liaotianElasticsearchDTO.question = hit["_source"]["question"].ToString();
|
liaotianElasticsearchDTO.anwser = hit["_source"]["anwser"].ToString();
|
liaotianElasticsearchDTOs.Add(liaotianElasticsearchDTO);
|
}
|
|
|
}
|
else
|
{
|
new JsonResult("[]");
|
|
|
}
|
data.LoadData(new LiaotianDTOSearch(), liaotianElasticsearchDTOs);
|
return new JsonResult(data);
|
}
|
|
[CheckLogin]
|
public IActionResult Indexcheck()
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
//ActionEntity actionEntity1 = new ActionEntity();
|
//actionEntity1.OpenType = 0;
|
//actionEntity1.ActionUrl = "";
|
//actionEntity1.ActionFun = "Add";
|
//actionEntity1.PageIco = "fa fa-plus";
|
//actionEntity1.ActionName = "新增";
|
//actionlist.Add(actionEntity1);
|
|
//ActionEntity actionEntity2 = new ActionEntity();
|
//actionEntity2.OpenType = 0;
|
//actionEntity2.ActionUrl = "";
|
//actionEntity2.ActionFun = "Print";
|
//actionEntity2.PageIco = "fa fa-print";
|
//actionEntity2.ActionName = "打印";
|
//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);
|
var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/Liaotian/Indexcheck");
|
var pageEntities1 = pageEntities.Where(x => x.PageMethod == "01").ToList();
|
foreach (var pageEntity in pageEntities1)
|
{
|
ActionEntity actionEntity1 = new ActionEntity();
|
actionEntity1.OpenType = pageEntity.OpenType;
|
actionEntity1.ActionUrl = "";
|
actionEntity1.ActionFun = pageEntity.PageShortcut;
|
actionEntity1.PageIco = pageEntity.PageIco;
|
actionEntity1.ActionName = pageEntity.PageName;
|
actionlist.Add(actionEntity1);
|
}
|
|
ViewData["ActionInfo"] = actionlist;
|
ViewBag.problemtype = _liaotianService.GetSYScode("Liaotian", "problemtype").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.questiontype = _liaotianService.GetSYScode("Liaotian", "questiontype").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.shifou = _liaotianService.GetSYScode("system", "shifou").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList();
|
ViewBag.Creater = _userService.GetList().Select(x => new { code = x.Id, label = x.UserName }).ToList();
|
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;
|
|
List <LiaotianDTO> liaotianDTOs =_liaotianService.SearchForPrint(new LiaotianDTOSearch()).ToList();//.Where(x=>x.Clientid =="A")
|
|
|
try
|
{
|
int i = 0;
|
foreach (var liaotianDTO in liaotianDTOs)
|
{
|
i = i + 1;
|
string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
|
string url = $"{api_domain}/liaotian/_doc/" + liaotianDTO.Id;
|
|
LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
|
liaotianElasticsearchDTO.id = liaotianDTO.Id;
|
liaotianElasticsearchDTO.question = liaotianDTO.Question;
|
liaotianElasticsearchDTO.anwser = liaotianDTO.Anwser;
|
|
|
|
string requestJson = JsonConvert.SerializeObject(liaotianElasticsearchDTO); ;// "{\"id\": \"" + liaotianDTO.Id + "\",\"question\": \"" + liaotianDTO.Question.Replace("\n", "")+ "\",\"anwser\": \"" + liaotianDTO.Anwser.Replace("\n", "") + "\"}";
|
|
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);
|
}
|
|
|
/// <summary>
|
/// 获取题目类别
|
/// </summary>
|
/// <param name="wentileibie">问题类别</param>
|
/// <returns></returns>
|
///
|
[CheckLogin]
|
public string gettimu(string wentileibie = "")
|
{
|
|
var shi = _liaotianService.GetSYScode("Liaotian", "problemtype").Where(x => x.Contents == wentileibie).ToList();
|
|
|
|
|
return JsonConvert.SerializeObject(shi);
|
|
}
|
|
[CheckLogin]
|
public string GetLiaotianList(LiaotianDTOSearch search)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
search.ShouCangCreater = curentuser.Id;
|
//JsonResult jsonResult = new JsonResult(_liaotianService.SearchByPaging(search), new Newtonsoft.Json.Serialization.DefaultContractResolver());
|
return JsonConvert.SerializeObject(_liaotianService.SearchByPaging(search));
|
}
|
|
#region 编辑
|
[CheckLogin]
|
public ActionResult Edit(string id = null, string Questiontype = null, string Problemtype = null)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
var pageEntities = _pltPageService.GetUserPage(curentuser.Id, "/Liaotian/Indexcheck");
|
var pageEntities2 = pageEntities.Where(x => x.PageMethod == "02").ToList();
|
ViewData["ActionInfo2"] = pageEntities2;
|
LiaotianDTO liaotianDTO = new LiaotianDTO();
|
if (!String.IsNullOrEmpty(id))
|
{
|
liaotianDTO = _liaotianService.GetLiaotianEntity(id);
|
var liaotianShoucangDTOs = _liaotianService.getListLiaotianShoucang(curentuser.Id, id);
|
if(liaotianShoucangDTOs!=null&& liaotianShoucangDTOs.Count > 0)
|
{
|
liaotianDTO.ShouCangStatus = "A";
|
}
|
else
|
{
|
liaotianDTO.ShouCangStatus = "D";
|
|
}
|
}
|
else
|
{
|
if (!string.IsNullOrEmpty(Questiontype))
|
{
|
liaotianDTO.Questiontype = Questiontype;
|
}
|
|
if (!string.IsNullOrEmpty(Problemtype))
|
{
|
liaotianDTO.Problemtype = Problemtype;
|
}
|
}
|
ViewData.Model = liaotianDTO;
|
|
|
ViewData["pageEntities"] = pageEntities;
|
|
ViewData["questiontype"] = _liaotianService.GetSYScode("Liaotian", "questiontype");
|
|
ViewData["problemtype"] = _liaotianService.GetSYScode("Liaotian", "problemtype").Where(x=>x.Contents == liaotianDTO.Questiontype).ToList();
|
|
|
//ViewData["Questiontypesel"] = Questiontype;
|
|
|
//ViewData["Problemtypesel"] = Problemtype;
|
|
|
return View();
|
}
|
|
[CheckLogin]
|
public string EditLiaotian(string id = null)
|
{
|
LiaotianDTO liaotianDTO = new LiaotianDTO();
|
if (!String.IsNullOrEmpty(id))
|
{
|
liaotianDTO = _liaotianService.GetLiaotianEntity(id);
|
}
|
|
// ViewData.Model = liaotianDTO;
|
return JsonConvert.SerializeObject(liaotianDTO);
|
}
|
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data">岗位实体类对象</param>
|
/// <returns></returns>
|
[HttpPost]
|
[CheckLogin]
|
public async Task<string> SaveAsync(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 = "D";
|
data.Shenheer = null;
|
data.Shenhetime = null;
|
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);
|
|
if (!string.IsNullOrEmpty(data.Id))
|
{
|
|
string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
|
string url = $"{api_domain}/liaotian/_doc/" + data.Id;
|
//string requestJson = "{\"id\": \"" + Id + "\",\"question\": \"" + data.Question + "\",\"anwser\": \"" + data.Anwser + "\"}";
|
try
|
{
|
string result = string.Empty;
|
Uri postUrl = new Uri(url);
|
|
|
|
|
var httpClient = _clientFactory.CreateClient();
|
httpClient.Timeout = new TimeSpan(0, 0, 60);
|
var Result = await httpClient.DeleteAsync(postUrl);
|
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;
|
|
|
}
|
}
|
|
|
|
|
//string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
|
//string url = $"{api_domain}/liaotian/_doc/"+ data.Id;
|
//LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
|
//liaotianElasticsearchDTO.id = data.Id;
|
//liaotianElasticsearchDTO.question = data.Question;
|
//liaotianElasticsearchDTO.anwser = data.Anwser;
|
|
|
|
//string requestJson = JsonConvert.SerializeObject(liaotianElasticsearchDTO); ;// "{\"id\": \"" + liaotianDTO.Id + "\",\"question\": \"" + liaotianDTO.Question.Replace("\n", "")+ "\",\"anwser\": \"" + liaotianDTO.Anwser.Replace("\n", "") + "\"}";
|
|
//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>
|
[HttpPost]
|
[CheckLogin]
|
public IActionResult ShouCang(LiaotianDTO data)
|
{
|
ResultEntity resultEntity = new ResultEntity();
|
resultEntity.Result = false;
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
var liaotianShoucangDTOs = _liaotianService.getListLiaotianShoucang(curentuser.Id, data.Id);
|
if (data.ShouCangStatus == "A")
|
{
|
if (liaotianShoucangDTOs == null || liaotianShoucangDTOs.Count == 0)
|
{
|
LiaotianShoucangDTO liaotianShoucangDTO = new LiaotianShoucangDTO();
|
liaotianShoucangDTO.LiaotianId = data.Id;
|
liaotianShoucangDTO.RecStatus = "A";
|
liaotianShoucangDTO.Creater = curentuser.Id;
|
liaotianShoucangDTO.Createtime = DateTime.Now;
|
liaotianShoucangDTO.Modifier = curentuser.Id;
|
liaotianShoucangDTO.Modifytime = DateTime.Now;
|
resultEntity = _liaotianService.saveLiaotianShoucang(liaotianShoucangDTO);
|
}
|
}
|
else
|
{
|
if (liaotianShoucangDTOs != null || liaotianShoucangDTOs.Count > 0)
|
{
|
foreach (var liaotianShoucangDTO in liaotianShoucangDTOs)
|
{
|
resultEntity = _liaotianService.ModifyStatusLiaotianShoucang(liaotianShoucangDTO.Id, curentuser.Id);
|
}
|
}
|
}
|
|
return new JsonResult(resultEntity); ;
|
}
|
|
|
/// <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";
|
data.Shenheer = curentuser.Id;
|
data.Shenhetime = DateTime.Now;
|
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/_doc/" + 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>
|
[HttpPost]
|
[CheckLogin]
|
public async Task<string> ShenheAsync(String Id)
|
{
|
ResultEntity resultEntity = new ResultEntity();
|
resultEntity.Result = false;
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
|
|
|
LiaotianDTO data = _liaotianService.GetLiaotianEntity(Id);
|
|
data.Shenheer = curentuser.Id;
|
data.Shenhetime = DateTime.Now;
|
data.Clientid = "A";
|
data.Modifier = curentuser.Id;
|
data.Modifytime = DateTime.Now;
|
resultEntity = _liaotianService.saveLiaotian(data);
|
|
string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
|
string url = $"{api_domain}/liaotian/_doc/" + data.Id;
|
LiaotianElasticsearchDTO liaotianElasticsearchDTO = new LiaotianElasticsearchDTO();
|
liaotianElasticsearchDTO.id = data.Id;
|
liaotianElasticsearchDTO.question = data.Question;
|
liaotianElasticsearchDTO.anwser = data.Anwser;
|
|
|
|
string requestJson = JsonConvert.SerializeObject(liaotianElasticsearchDTO); ;// "{\"id\": \"" + liaotianDTO.Id + "\",\"question\": \"" + liaotianDTO.Question.Replace("\n", "")+ "\",\"anwser\": \"" + liaotianDTO.Anwser.Replace("\n", "") + "\"}";
|
|
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);
|
}
|
|
#endregion
|
|
/// <summary>
|
/// 删除主信息
|
/// </summary>
|
/// <param name="info">实体</param>
|
/// <returns></returns>
|
///
|
[CheckLogin]
|
public async Task<string> NullifyAsync(string Id = "")
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ViewData["curentuser"] = curentuser;
|
|
ResultEntity resultEntity = _liaotianService.ModifyStatus(Id, curentuser.Id);
|
|
string api_domain = _configuration.GetSection("Elasticsearchurl").Value;
|
string url = $"{api_domain}/liaotian/_doc/" + Id;
|
//string requestJson = "{\"id\": \"" + Id + "\",\"question\": \"" + data.Question + "\",\"anwser\": \"" + data.Anwser + "\"}";
|
try
|
{
|
string result = string.Empty;
|
Uri postUrl = new Uri(url);
|
|
|
|
|
var httpClient = _clientFactory.CreateClient();
|
httpClient.Timeout = new TimeSpan(0, 0, 60);
|
var Result = await httpClient.DeleteAsync(postUrl);
|
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);
|
}
|
|
|
|
[CheckLogin]
|
public IActionResult print(LiaotianDTOSearch search)
|
{
|
|
|
ViewBag.listLiaotianDTO = _liaotianService.SearchForPrint(search);
|
|
return View();
|
}
|
|
|
}
|
}
|