private void Process() { try { List <TbTitle> title; List <TbTitleInfo> titleInfo; mInputPath = textBox1.Text; mOutputPath = textBox2.Text; if (String.IsNullOrEmpty(mInputPath)) { throw new System.InvalidOperationException($"輸入目錄不可為空"); } if (String.IsNullOrEmpty(mOutputPath)) { throw new System.InvalidOperationException($"輸出目錄不可為空"); } mTitleInfoFileName = Path.Combine(mInputPath, "Tb_Title_Info.txt"); mTitleStringFileName = Path.Combine(mInputPath, "tb_Title_String.txt"); if (!File.Exists(mTitleInfoFileName)) { throw new System.InvalidOperationException($"{mTitleInfoFileName} 檔案不存在"); } if (!File.Exists(mTitleStringFileName)) { throw new System.InvalidOperationException($"{mTitleStringFileName} 檔案不存在"); } GetIdTable(mTitleStringFileName, out title); GetIdTable(mTitleInfoFileName, out titleInfo); List <TbTitleInfo> frontTitle = titleInfo.Where(o => (o.id.ToCharArray()[0] == '1')).ToList(); List <TbTitleInfo> backTitle = titleInfo.Where(o => (o.id.ToCharArray()[0] == '2')).ToList(); WritePackage format = (radioButton1.Checked) ? WritePackageFactory.GetInstance(WritePackageFactory.Type.TEXT) : (radioButton2.Checked) ? WritePackageFactory.GetInstance(WritePackageFactory.Type.CSV) : WritePackageFactory.GetInstance(WritePackageFactory.Type.HTML); WriteData(format, title, frontTitle, backTitle); MessageBox.Show("finish"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void WriteData(WritePackage format, List <TbTitle> title, List <TbTitleInfo> frontTitle, List <TbTitleInfo> backTitle) { ProcessByIndividual(format.method, title, frontTitle, $"前方稱號.{format.ext}"); ProcessByIndividual(format.method, title, backTitle, $"後方稱號.{format.ext}"); }