Skip to content

Commit

Permalink
enable export error message
Browse files Browse the repository at this point in the history
  • Loading branch information
studyzy committed Apr 5, 2020
1 parent e639d9a commit d0f0981
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/IME WL Converter Win/Forms/MainForm.cs
Expand Up @@ -229,7 +229,8 @@ private void btnConvert_Click(object sender, EventArgs e)
mainBody.Filters = GetFilters();
mainBody.BatchFilters = GetBatchFilters();
mainBody.ReplaceFilters = GetReplaceFilters();
mainBody.Import.ImportLineErrorNotice += WriteErrorMessage;
mainBody.Import.ImportLineErrorNotice += WriteErrorMessage;
mainBody.Export.ExportErrorNotice += WriteErrorMessage;
mainBody.ProcessNotice+=RichTextBoxShow;
timer1.Enabled = true;
backgroundWorker1.RunWorkerAsync();
Expand Down
6 changes: 6 additions & 0 deletions src/ImeWlConverterCore/IME/BaseImport.cs
Expand Up @@ -39,5 +39,11 @@ protected void SendImportLineErrorNotice(string msg)
{
ImportLineErrorNotice?.Invoke(msg);
}

public event Action<string> ExportErrorNotice;
protected void SendExportErrorNotice(string msg)
{
ExportErrorNotice?.Invoke(msg);
}
}
}
5 changes: 3 additions & 2 deletions src/ImeWlConverterCore/IME/Win10MsPinyin.cs
Expand Up @@ -170,13 +170,14 @@ public WordLibraryList ImportLine(string str)
{
throw new NotImplementedException("二进制文件不支持单个词汇的转换");
}

public event Action<string> ExportErrorNotice;

public IList<string> Export(WordLibraryList wlList)
{
//Win10拼音只支持最多32个字符的编码
wlList = Filter(wlList);

string tempPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\Win10微软拼音词库.dat";
string tempPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "\\Win10微软拼音词库.dat");
if (File.Exists(tempPath)) { File.Delete(tempPath); }
var fs = new FileStream(tempPath, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
Expand Down
7 changes: 6 additions & 1 deletion src/ImeWlConverterCore/IME/Win10MsPinyinSelfStudy.cs
Expand Up @@ -531,6 +531,11 @@ public WordLibraryList ImportLine(string str)
throw new NotImplementedException("二进制文件不支持单个词汇的转换");
}
public string ExportFilePath { get; set; }
public event Action<string> ExportErrorNotice;
protected void SendExportErrorNotice(string msg)
{
ExportErrorNotice?.Invoke(msg);
}
/// <summary>
/// 最多支持2W条一个dat文件
/// </summary>
Expand All @@ -543,7 +548,7 @@ public IList<string> Export(WordLibraryList wlList)
var list = new List<WordLibraryList>();
if(wlList.Count>20000)
{
throw new Exception("微软拼音自学习词库最多支持2万条记录的导入,当前词条数为:"+wlList.Count+"操过限制,请设置过滤条件或者更换词库源。");
SendExportErrorNotice("微软拼音自学习词库最多支持2万条记录的导入,当前词条数为:"+wlList.Count+"超过限制,请设置过滤条件或者更换词库源。");
//以后微软拼音放开2W限制了,再把这个异常取消吧。
var item20000 = new WordLibraryList();
for(var i=0;i<wlList.Count;i++)
Expand Down
4 changes: 2 additions & 2 deletions src/ImeWlConverterCore/IME/Win10MsWubi.cs
Expand Up @@ -160,12 +160,12 @@ public WordLibraryList ImportLine(string str)
{
throw new NotImplementedException("二进制文件不支持单个词汇的转换");
}

public event Action<string> ExportErrorNotice;
public IList<string> Export(WordLibraryList wlList)
{
//Win10拼音只支持最多32个字符的编码
wlList = Filter(wlList);
string tempPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + "\\Win10微软五笔词库.dat";
string tempPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "\\Win10微软五笔词库.dat");
if (File.Exists(tempPath)) { File.Delete(tempPath); }
var fs = new FileStream(tempPath, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
Expand Down
2 changes: 1 addition & 1 deletion src/ImeWlConverterCore/ImeWlConverterCore-net46.csproj
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net46</TargetFramework>
<AssemblyName>ImeWlConverterCore</AssemblyName>
<RootNamespace>ImeWlConverterCore</RootNamespace>
<Version>2.7.0</Version>
<Version>2.8.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/ImeWlConverterCore/Interface.cs
Expand Up @@ -27,6 +27,7 @@ public interface IWordLibraryTextImport : IWordLibraryImport

public interface IWordLibraryExport
{
event Action<string> ExportErrorNotice;
Encoding Encoding { get; }
CodeType CodeType { get; }
/// <summary>
Expand Down

0 comments on commit d0f0981

Please sign in to comment.