发布:2019/12/30 14:16:46作者:管理员 来源:本站 浏览次数:1307
---------------------查询----------------------------
ResultsPage<List<SolrDTO>> results = new ResultsPage<List<SolrDTO>> { Code = -1, Msg = "异常错误", Success = false, Value = null };
//定义solr}
-----------------添加-------------------------------
var title = txt_Title.Value;
var AskContentb = txtnewstextSub.Value;
var _ImgUrl = Maticsoft.Common.Tool.GetImgUrl(AskContentb);
var json = string.Empty;
var Keyword = string.Empty;
int usertype = 0;
var userid = GetCurrentUserId(out usertype);
using (var client = new HttpClient())
{
try
{
var url = string.Format("http://webapi.zybw.com/api/GetAnalysis?keyword={0}&count=2&type=index",
HttpUtility.UrlEncode(title, Encoding.UTF8));
client.DefaultRequestHeaders.Add("Token", "iojkljfds6fdsa546fdsaf8556fdsa656a64");
var responseString = client.GetStringAsync(url);
json = responseString.Result;
JObject jo = JObject.Parse(json);
JArray jsonColleagues = (JArray)jo["Value"];
Keyword = jsonColleagues.ToString();
}
catch { }
}
EHS_AskQuestion model = new EHS_AskQuestion
{
Title = title,
AskContent = AskContentb,
CoverImage = _ImgUrl,
AskState = 1,
ClickCount = 0,
CreateTime = DateTime.Now,
Display = 1,
IsHot = 0,
IsRed = 0,
IsShow = 1,
IsTop = 0,
Keyword = Keyword,
Priority = 1,
Solutions = 0,
UserID = userid,
VideoUrl = "",
UserType = usertype
};
long aid = _bll_EHS_AskQuestion.Add(model);
if (aid > 0)
{
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<SolrDTO>>();
solr.Add(new SolrDTO()
{
id = int.Parse(aid.ToString()),
Aid = int.Parse(aid.ToString()),
Title = title,
AskContent = AskContentb,
CoverImage = _ImgUrl,
AskState = 1,
ClickCount = 0,
CreateTime = DateTime.Now,
Display = 1,
IsHot = 0,
IsRed = 0,
IsShow = 1,
IsTop = 0,
Keyword = Keyword,
Priority = 1,
Solutions = 0,
UserID = userid,
VideoUrl = "",
UserType = usertype
});
solr.Commit();
Response.Redirect("index.html");
}
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4