/// <summary>
        ///  检查违禁词
        /// </summary>
        public string CheckWord(CheckWordRequestInfo info)
        {
            CheckWordResponseResult result = new CheckWordResponseResult();

            if (IsUserLogin())
            {
                try
                {
                    try
                    {
                        if (CheckWordHelper.WordModels.Count == 0 && !string.IsNullOrEmpty(SystemVar.UserToken))
                        {
                            CheckWordHelper.GetAllCheckWordByToken(SystemVar.UserToken, SystemVar.UrlStr);
                        }
                    }
                    catch (Exception ex)
                    { }
                    var listUnChekedWord = CheckWordHelper.GetUnChekedWordInfoList(info.Text).ToList();
                    result.Result            = true;
                    result.UncheckWordModels = listUnChekedWord;
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                }
            }
            else
            {
                result.Message = "LoginOut";
            }
            return(JsonConvert.SerializeObject(result));
        }
        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);
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
        /// <summary>
        ///  检查违禁词
        /// </summary>
        public string CheckWord(CheckWordRequestInfo info)
        {
            CheckWordResponseResult result = new CheckWordResponseResult();

            if (IsUserLogin())
            {
                try
                {
                    var listUnChekedWord = CheckWordHelper.GetUnChekedWordInfoList(info.Text).ToList();
                    result.Result            = true;
                    result.UncheckWordModels = listUnChekedWord;
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                }
            }
            else
            {
                result.Message = "LoginOut";
            }
            return(JsonConvert.SerializeObject(result));
        }
Beispiel #5
0
        /// <summary>
        ///  检查是否是违禁词
        /// </summary>
        public string CheckOneWord(CheckWordRequestInfo info)
        {
            CheckOnlyWordResponseResult result = new CheckOnlyWordResponseResult();

            if (IsUserLogin())
            {
                try
                {
                    var infoWord = CheckWordHelper.GetUnChekedWordInfo(info.Text);
                    result.Result   = true;
                    result.WordInfo = infoWord;
                }
                catch (Exception ex)
                {
                    WPFClientCheckWordUtil.Log.TextLog.SaveError(ex.Message);
                    result.Message = ex.Message;
                }
            }
            else
            {
                result.Message = "LoginOut";
            }
            return(JsonConvert.SerializeObject(result));
        }