public static bool GetIsUserLogin() { bool result = false; try { string loginInOutInfos = string.Format(@"{0}\LoginInOutInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); var ui = DataParse.ReadFromXmlPath <string>(loginInOutInfos); if (ui != null && ui.ToString() != "") { try { var loginInOutInfo = JsonConvert.DeserializeObject <LoginInOutInfo>(ui.ToString()); if (loginInOutInfo != null && loginInOutInfo.Type == "LoginIn") { var proc = System.Diagnostics.Process.GetProcessesByName("WordAndImgOperationApp"); if (proc != null && proc.Length == 1) { result = true; } } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } return(result); }
public static void CallWordAndImgApp() { try { var proc = System.Diagnostics.Process.GetProcessesByName("WordAndImgOperationApp"); if (proc != null && proc.Length == 1) { CommonExchangeInfo commonExchangeInfo = new CommonExchangeInfo(); commonExchangeInfo.Code = "ShowWordAndImgOperationApp"; string jsonData = JsonConvert.SerializeObject(commonExchangeInfo); //序列化 Win32Helper.SendMessage("WordAndImgOperationApp", jsonData); } else { string appPath = ""; string loginInOutInfos = string.Format(@"{0}\WordAndImgAppInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); var ui = DataParse.ReadFromXmlPath <string>(loginInOutInfos); if (ui != null && ui.ToString() != "") { try { var wordAndImgAppInfo = JsonConvert.DeserializeObject <WordAndImgAppInfo>(ui.ToString()); if (wordAndImgAppInfo != null) { appPath = wordAndImgAppInfo.Path; } } catch { } } if (!string.IsNullOrEmpty(appPath) && File.Exists(appPath)) { var info = new System.Diagnostics.ProcessStartInfo(appPath); info.WorkingDirectory = appPath.Substring(0, appPath.LastIndexOf(System.IO.Path.DirectorySeparatorChar)); System.Diagnostics.Process.Start(info); } } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } }
/// <summary> /// 获取所有校验数据 /// </summary> /// <param name="token"></param> /// <returns></returns> public static void GetAllCheckWordByToken(string token) { List <WordModel> wordModelLists = new List <WordModel>(); try { //#region 假数据 //WordModels.Add(new WordModel { ID = "1", Name = "第一", IsCustumCi = true }); //WordModels.Add(new WordModel { ID = "2", Name = "最", IsCustumCi = false }); //WordModels.Add(new WordModel { ID = "3", Name = "冠军", IsCustumCi = false }); //WordModels.Add(new WordModel { ID = "4", Name = "防晒", IsCustumCi = true }); //#endregion string apiName = "words/word"; string resultStr = HttpHelper.HttpUrlGet(apiName, "GET", token); CommonResponse resultInfo = JsonConvert.DeserializeObject <CommonResponse>(resultStr); if (resultInfo != null && resultInfo.state) { List <DBWordModel> listDBWords = JsonConvert.DeserializeObject <List <DBWordModel> >(resultInfo.result); if (listDBWords != null) { foreach (var item in listDBWords) { WordModel word = new WordModel(); word.ID = item.id; word.Name = item.name; wordModelLists.Add(word); } } try { CommonExchangeInfo commonExchangeInfo = new CommonExchangeInfo(); commonExchangeInfo.Code = "HideNotifyMessageView"; commonExchangeInfo.Data = "4003"; string jsonData = JsonConvert.SerializeObject(commonExchangeInfo); //序列化 Win32Helper.SendMessage("WordAndImgOperationApp", jsonData); } catch { } } else { try { CommonExchangeInfo commonExchangeInfo = new CommonExchangeInfo(); commonExchangeInfo.Code = "ShowNotifyMessageView"; commonExchangeInfo.Data = "4003"; string jsonData = JsonConvert.SerializeObject(commonExchangeInfo); //序列化 Win32Helper.SendMessage("WordAndImgOperationApp", jsonData); } catch { } } } catch (Exception ex) { wordModelLists = new List <WordModel>(); WPFClientCheckWordUtil.Log.TextLog.SaveError(ex.Message); try { CommonExchangeInfo commonExchangeInfo = new CommonExchangeInfo(); commonExchangeInfo.Code = "ShowNotifyMessageView"; commonExchangeInfo.Data = "4003"; string jsonData = JsonConvert.SerializeObject(commonExchangeInfo); //序列化 Win32Helper.SendMessage("WordAndImgOperationApp", jsonData); } catch { } } WordModels = wordModelLists; new Task(() => { try { string myWordModelsInfo = string.Format(@"{0}\MyWordModelsInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); //保存用户设置信息到本地 DataParse.WriteToXmlPath(JsonConvert.SerializeObject(WordModels), myWordModelsInfo); } catch (Exception ex) { WPFClientCheckWordUtil.Log.TextLog.SaveError(ex.Message); } }).Start(); }
/// <summary> /// 获取文本中包含的违禁词集合 /// </summary> /// <param name="text"></param> /// <returns></returns> public static List <UnChekedWordInfo> GetUnChekedWordInfoList(string text, string typeInfo = "Word") { List <UnChekedWordInfo> result = new List <UnChekedWordInfo>(); try { bool isGetAllWord = true; string isGetAllWordsInfo = ""; if (typeInfo == "Word") { isGetAllWordsInfo = string.Format(@"{0}\IsWordGetAllWordsInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); } else { isGetAllWordsInfo = string.Format(@"{0}\IsExcelGetAllWordsInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); } var ui = DataParse.ReadFromXmlPath <string>(isGetAllWordsInfo); if (ui != null && ui.ToString() != "") { try { var isGetAllWords = JsonConvert.DeserializeObject <IsGetAllWordsInfo>(ui.ToString()); if (isGetAllWords != null) { isGetAllWord = isGetAllWords.IsGetAllWords; } } catch (Exception ex) { } } if (isGetAllWord || WordModels.Count == 0) { string myWordModelsInfo = string.Format(@"{0}\MyWordModelsInfo.xml", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\WordAndImgOCR\\LoginInOutInfo\\"); int countTime = 0; while (true) { var uiMyWords = CheckWordUtil.DataParse.ReadFromXmlPath <string>(myWordModelsInfo); if (uiMyWords != null && uiMyWords.ToString() != "") { try { WordModels = JsonConvert.DeserializeObject <List <WordModel> >(uiMyWords.ToString()); IsGetAllWordsInfo info = new IsGetAllWordsInfo(); info.IsGetAllWords = false; DataParse.WriteToXmlPath(JsonConvert.SerializeObject(info), isGetAllWordsInfo); if (WordModels.Count > 0) { break; } } catch { } } countTime++; System.Threading.Thread.Sleep(500); if (countTime > 10) { break; } } } foreach (var item in WordModels) { if (text.Contains(item.Name)) { 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; result.Add(unChekedWordInfo); } } } } catch (Exception ex) { CheckWordUtil.Log.TextLog.SaveError(ex.Message); } return(result); }