private void ExportTemplateInformation()
{
try
{
FolderBrowserDialog sfd = new FolderBrowserDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
EMRTemplateClient etc = Factory.getEMRTemplate();
DataTable dtindex = etc.GetDataTable_TEM_FILE_INDEX();
DataTable dttext = etc.GetDataTable_TEM_FILE_TEXT();
if (dtindex == null)
{
return;
}
string filePath = sfd.SelectedPath;
foreach (DataRow dr in dttext.Rows)
{
string code = dr[0].ToString();
EMRFileClient proxy = Factory.getEMRFileClient();
byte[] bytes = proxy.GetTem_File(code);
if (bytes != null)
{
System.IO.FileStream fs = new System.IO.FileStream(filePath + "\\" + code + ".emr", System.IO.FileMode.OpenOrCreate);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
}
using (StreamWriter sw = new StreamWriter(filePath + "\\模板信息", true, Encoding.Default))
{
string repStr = "|";
for (int i = 0; i < dtindex.Rows.Count; i++)
{
int cell = dtindex.Rows[i].ItemArray.GetLength(0) - 1;
string content = string.Empty;
for (int j = 0; j < cell; j++)
{
content += dtindex.Rows[i][j] + repStr;
}
if (content.Contains(repStr))
{
content = content.Remove(content.LastIndexOf(repStr));
}
sw.WriteLine(content);
}
}