private async void SureToCustumCiTiaoBtn_Click(object sender, RoutedEventArgs e)
        {
            string message = "";
            //调用接口添加自建词库
            Task <bool> task = new Task <bool>(() => {
                EventAggregatorRepository.EventAggregator.GetEvent <SettingWindowBusyIndicatorEvent>().Publish(new AppBusyIndicator {
                    IsBusy = true
                });
                bool b = false;
                try
                {
                    APIService service = new APIService();
                    b = service.AddCustumCiTiaoByToken(UtilSystemVar.UserToken, viewModel.SearchText, viewModel.DiscriptionSearchText, ref message);
                    System.Threading.Thread.Sleep(1000);
                }
                catch (Exception ex)
                { }
                if (b)
                {
                    EventAggregatorRepository.EventAggregator.GetEvent <GetWordsEvent>().Publish(true);
                }
                EventAggregatorRepository.EventAggregator.GetEvent <SettingWindowBusyIndicatorEvent>().Publish(new AppBusyIndicator {
                    IsBusy = false
                });
                return(b);
            });

            task.Start();
            await task;

            if (task.Result)
            {
                ShowTipsInfo("添加自建词条成功");
            }
            else
            {
                ShowTipsInfo(message);
            }
        }
 private async void ImportCustumCiBtn_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
     ofd.Filter          = "Excel文件(*.xlsx)|*.xlsx";
     ofd.ValidateNames   = true;
     ofd.CheckPathExists = true;
     ofd.CheckFileExists = true;
     if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         string strFileName = ofd.FileName;
         EventAggregatorRepository.EventAggregator.GetEvent <SettingWindowBusyIndicatorEvent>().Publish(new AppBusyIndicator {
             IsBusy = true
         });
         Task <bool> taskCheckFile = new Task <bool>(() => {
             bool b = CheckFile(strFileName);
             return(b);
         });
         taskCheckFile.Start();
         await taskCheckFile;
         //检验加载文件格式
         if (taskCheckFile.Result)
         {
             int totalCount     = 0;
             int errorCount     = 0;
             int errorSameCount = 0;
             //调用接口添加自建词库
             Task <bool> task = new Task <bool>(() => {
                 ShowTipsInfo("正在批量上传,请稍后再上传");
                 EventAggregatorRepository.EventAggregator.GetEvent <SettingWindowBusyIndicatorEvent>().Publish(new AppBusyIndicator {
                     IsBusy = true
                 });
                 try
                 {
                     Aspose.Cells.Workbook workbookName = new Aspose.Cells.Workbook(strFileName);
                     string sheetName             = workbookName.Worksheets[0].Name;
                     Aspose.Cells.Cells cellsName = workbookName.Worksheets[0].Cells;
                     int minDataColumn            = cellsName.MinDataColumn;
                     int maxDataColumn            = cellsName.MaxDataColumn;
                     int minDataRow = cellsName.MinDataRow;
                     int maxDataRow = cellsName.MaxDataRow;
                     //导入数据
                     for (int i = minDataRow + 1; i < maxDataRow + 1; i++)
                     {
                         try
                         {
                             string name    = cellsName[i, minDataColumn].StringValue.Trim();
                             string comment = cellsName[i, maxDataColumn].StringValue.Trim();
                             if (!string.IsNullOrEmpty(name))
                             {
                                 totalCount++;
                                 string message     = "";
                                 APIService service = new APIService();
                                 bool b             = service.AddCustumCiTiaoByToken(UtilSystemVar.UserToken, name, comment, ref message);
                                 if (!b)
                                 {
                                     errorCount++;
                                     if (message == "该自建词条已存在")
                                     {
                                         errorSameCount++;
                                     }
                                 }
                             }
                         }
                         catch (Exception ex)
                         { }
                     }
                 }
                 catch (Exception ex)
                 { }
                 bool bResult = false;
                 if (totalCount != 0 && errorCount == 0)
                 {
                     bResult = true;
                     EventAggregatorRepository.EventAggregator.GetEvent <GetWordsEvent>().Publish(true);
                 }
                 EventAggregatorRepository.EventAggregator.GetEvent <SettingWindowBusyIndicatorEvent>().Publish(new AppBusyIndicator {
                     IsBusy = false
                 });
                 return(bResult);
             });
             task.Start();
             await task;
             if (task.Result)
             {
                 ShowTipsInfo("批量导入词条成功");
             }
             else
             {
                 if (totalCount == 0)
                 {
                     ShowTipsInfo("批量导入词条失败,数据为空");
                 }
                 else
                 {
                     if (totalCount == errorCount)
                     {
                         if (errorSameCount == 0)
                         {
                             ShowTipsInfo("批量导入词条失败");
                         }
                         else
                         {
                             ShowTipsInfo("批量导入词条失败,自建词条已存在");
                         }
                     }
                     else
                     {
                         if (errorSameCount == 0)
                         {
                             ShowTipsInfo("批量导入词条" + (totalCount - errorCount) + "条成功," + errorCount + "条失败");
                         }
                         else
                         {
                             ShowTipsInfo("批量导入词条" + (totalCount - errorCount) + "条成功," + errorSameCount + "条自建词条已存在");
                         }
                     }
                 }
             }
         }
         else
         {
             ShowTipsInfo("选择导入的文件与模板不匹配");
         }
         EventAggregatorRepository.EventAggregator.GetEvent <SettingWindowBusyIndicatorEvent>().Publish(new AppBusyIndicator {
             IsBusy = false
         });
     }
 }