public static UnChekedDetailWordInfo GetOneWordInfo(string text) { UnChekedDetailWordInfo result = new UnChekedDetailWordInfo() { Name = text }; try { CheckWordRequestInfo info = new CheckWordRequestInfo() { Text = text }; string json = JsonConvert.SerializeObject(info); string resultStr = PostSend("http://localhost:8888/WPFClientCheckWordService/CheckOneWord", json); CheckOnlyWordResponseResult resultInfo = JsonConvert.DeserializeObject <CheckOnlyWordResponseResult>(resultStr); if (resultInfo != null && resultInfo.Result && resultInfo.WordInfo != null) { result.IsUnCheckWord = true; result.SourceDB = resultInfo.WordInfo.SourceDB; result.NameType = resultInfo.WordInfo.NameType; } } catch (Exception ex) { } return(result); }
/// <summary> /// 获取文本中包含的违禁词集合 /// </summary> /// <param name="text"></param> /// <returns></returns> public static List <UnChekedWordInfo> GetUnChekedWordInfoList(string text) { List <UnChekedWordInfo> result = new List <UnChekedWordInfo>(); try { CheckWordRequestInfo info = new CheckWordRequestInfo() { Text = text }; string json = JsonConvert.SerializeObject(info); string resultStr = PostSend("http://localhost:8888/WPFClientCheckWordService/CheckWord", json); CheckWordResponseResult resultInfo = JsonConvert.DeserializeObject <CheckWordResponseResult>(resultStr); if (resultInfo != null && resultInfo.Result && resultInfo.UncheckWordModels != null) { foreach (var item in resultInfo.UncheckWordModels) { var defaultObj = result.FirstOrDefault(x => x.Name == item.Name); if (text.Contains(item.Name) && defaultObj == null) { UnChekedWordInfo unChekedWordInfo = new UnChekedWordInfo(); unChekedWordInfo.ID = item.ID; unChekedWordInfo.Name = item.Name; foreach (var dbInfo in item.SourceDBs) { foreach (var typeInfo in item.NameTypes) { UnChekedDetailWordInfo unChekedDetailWordInfo = new UnChekedDetailWordInfo(); unChekedDetailWordInfo.Name = item.Name; unChekedDetailWordInfo.SourceDB = dbInfo.name; unChekedDetailWordInfo.NameType = typeInfo.name; unChekedDetailWordInfo.SourceDBID = dbInfo.code; unChekedDetailWordInfo.SourceDBPublishtime = dbInfo.publishtime; unChekedWordInfo.UnChekedWordDetailInfos.Add(unChekedDetailWordInfo); } } result.Add(unChekedWordInfo); } } } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } return(result); }
public List <UnChekedDetailWordInfo> GetWordDiscribeLists(string token, string id) { List <UnChekedDetailWordInfo> result = new List <UnChekedDetailWordInfo>(); try { //result.Add(new UnChekedDetailWordInfo() { Discription = "违反广告法第3条违反广告法第3条违反广告法第3条违反广告法第3条违反广告法第3条违反广告法第3条违反广告法第3条", SourceName = "词牛", CategoryName = ",母婴类", DateTime = "," + DateTime.Now.ToString("yyyy-MM-dd") }); //result.Add(new UnChekedDetailWordInfo() { Discription = "违反广告法第2条违反广告法第2条违反广告法第2条违反广告法第2条", SourceName = "自建词条", CategoryName = "", DateTime = "," + DateTime.Now.ToString("yyyy-MM-dd") }); string apiName = "words/word/" + id; string resultStr = HttpHelper.HttpUrlGet(apiName, "GET", token); CommonResponse resultInfo = JsonConvert.DeserializeObject <CommonResponse>(resultStr); if (resultInfo != null && resultInfo.state) { List <LawWordInfoModel> listLawWordInfos = JsonConvert.DeserializeObject <List <LawWordInfoModel> >(resultInfo.result); if (listLawWordInfos != null) { foreach (var item in listLawWordInfos) { UnChekedDetailWordInfo detailInfo = new UnChekedDetailWordInfo(); if (string.IsNullOrEmpty(item.data)) { detailInfo.Discription = "暂无解读"; } else { detailInfo.Discription = item.data; } detailInfo.CategoryName = string.IsNullOrEmpty(item.typeName) ? "" : "," + item.typeName; detailInfo.SourceName = item.official ? "词牛" : "自建词条"; if (item.uTime != null) { detailInfo.DateTime = "," + item.uTime.ToString("yyyy/MM/dd"); } result.Add(detailInfo); } } } } catch (Exception ex) { } return(result); }
public List <UnChekedDetailWordInfo> GetWordDiscribeLists(string id) { List <UnChekedDetailWordInfo> result = new List <UnChekedDetailWordInfo>(); try { string token = ""; string urlStr = ""; try { string loginInOutInfos = string.Format(@"{0}\LoginInOutInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); var ui = CheckWordUtil.DataParse.ReadFromXmlPath <string>(loginInOutInfos); if (ui != null && ui.ToString() != "") { try { var loginInOutInfo = JsonConvert.DeserializeObject <LoginInOutInfo>(ui.ToString()); if (loginInOutInfo != null && loginInOutInfo.Type == "LoginIn") { token = loginInOutInfo.Token; urlStr = loginInOutInfo.UrlStr; } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } string url = urlStr + "words/word/" + id; string resultStr = HttpHelper.HttpUrlGet(url, "GET", token); CommonResponse resultInfo = JsonConvert.DeserializeObject <CommonResponse>(resultStr); if (resultInfo != null && resultInfo.state) { List <LawWordInfoModel> listLawWordInfos = JsonConvert.DeserializeObject <List <LawWordInfoModel> >(resultInfo.result); if (listLawWordInfos != null) { foreach (var item in listLawWordInfos) { UnChekedDetailWordInfo detailInfo = new UnChekedDetailWordInfo(); if (string.IsNullOrEmpty(item.data)) { detailInfo.Discription = "暂无解读"; } else { detailInfo.Discription = item.data; } detailInfo.CategoryName = string.IsNullOrEmpty(item.typeName) ? "" : "," + item.typeName; detailInfo.SourceName = item.official ? "词牛" : "自建词条"; if (item.uTime != null) { detailInfo.DateTime = "," + item.uTime.ToString("yyyy/MM/dd"); } result.Add(detailInfo); } } } } catch (Exception ex) { } return(result); }