/// <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));
        }
 private void DealSingleParagraph(object obj)
 {
     try
     {
         Range  item = obj as Range;
         string str  = CellGetStringValue(item);
         if (!string.IsNullOrEmpty(str))
         {
             List <UnChekedWordInfo> listUnChekedWord = new List <UnChekedWordInfo>();
             string hashWord = HashHelper.ComputeSHA1ByStr(str);
             try
             {
                 if (!CurrentWordsDictionary.ContainsKey(hashWord))
                 {
                     listUnChekedWord = CheckWordHelper.GetUnChekedWordInfoList(str).ToList();
                     if (listUnChekedWord != null)
                     {
                         try
                         {
                             CurrentWordsDictionary.Add(hashWord, listUnChekedWord);
                         }
                         catch
                         { }
                     }
                 }
                 else
                 {
                     listUnChekedWord = CurrentWordsDictionary[hashWord];
                 }
             }
             catch (Exception ex)
             {
                 CheckWordUtil.Log.TextLog.SaveError(ex.Message);
             }
             if (listUnChekedWord != null && listUnChekedWord.Count > 0)
             {
                 HasUnChenckedWordsParagraphs.Add(new UnChekedWordExcelRangeInfo {
                     Range = item, RangeText = str, UnChekedWordLists = listUnChekedWord
                 });
             }
         }
     }
     catch (Exception ex)
     {
         CheckWordUtil.Log.TextLog.SaveError(ex.Message);
     }
     try
     {
         // 以原子操作的形式递减指定变量的值并存储结果。
         if (Interlocked.Decrement(ref countDealParagraph) == 0)
         {
             // 将事件状态设置为有信号,从而允许一个或多个等待线程继续执行。
             myEvent.Set();
         }
     }
     catch
     { }
 }
示例#3
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));
        }
 /// <summary>
 /// 解析处理段落
 /// </summary>
 /// <param name="ParagraphDataList"></param>
 private void DealSingleParagraph(object obj)
 {
     try
     {
         Microsoft.Office.Interop.Word.Paragraph paragraph = obj as Microsoft.Office.Interop.Word.Paragraph;
         if (paragraph != null)
         {
             string text = paragraph.Range.Text;
             if (!string.IsNullOrEmpty(text))
             {
                 List <UnChekedWordInfo> listUnChekedWord = new List <UnChekedWordInfo>();
                 string hashWord = HashHelper.ComputeSHA1ByStr(text);
                 try
                 {
                     if (!CurrentWordsDictionary.ContainsKey(hashWord))
                     {
                         listUnChekedWord = CheckWordHelper.GetUnChekedWordInfoList(text).ToList();
                         if (listUnChekedWord != null)
                         {
                             try
                             {
                                 CurrentWordsDictionary.Add(hashWord, listUnChekedWord);
                             }
                             catch
                             { }
                         }
                     }
                     else
                     {
                         listUnChekedWord = CurrentWordsDictionary[hashWord];
                     }
                 }
                 catch (Exception ex)
                 {
                     CheckWordUtil.Log.TextLog.SaveError(ex.Message);
                 }
                 if (listUnChekedWord != null && listUnChekedWord.Count > 0)
                 {
                     HasUnChenckedWordsParagraphs.Add(new UnChekedWordParagraphInfo {
                         Paragraph = paragraph, UnChekedWordLists = listUnChekedWord
                     });
                 }
             }
         }
     }
     catch (Exception ex)
     {
         CheckWordUtil.Log.TextLog.SaveError(ex.Message);
     }
     try
     {
         // 以原子操作的形式递减指定变量的值并存储结果。
         if (Interlocked.Decrement(ref countDealParagraph) == 0)
         {
             // 将事件状态设置为有信号,从而允许一个或多个等待线程继续执行。
             myEvent.Set();
         }
     }
     catch
     { }
 }