Exemple #1
0
 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();
        }