如何在Pdm中进行文档汇出,只有一级关系的???
private void TuExport()
{
DataSet ds = TUDANG_BLL.GetDataSetBySQL("select distinct PITEM_ID from PDM_TUDANG");
lbl_TUDataCount.Text = ds.Tables[0].Rows.Count.ToString();
List<PDM.Model.PDM_TUDANG> List_TUDANG = new List<PDM.Model.PDM_TUDANG>();
List_TUDANG = TUDANG_BLL.GetModelList("");
lbl_TUFileCount.Text = List_TUDANG.Count.ToString();
int i = 0;
int j = 0;
int l = 0;
foreach (DataRow dr in ds.Tables[0].Rows)
{
try
{
i++;
if (!Directory.Exists(Application.StartupPath + "\\ATTACH\\related file\\" + dr["PITEM_ID"].ToString().Trim().Replace('*', '_')))
{
Directory.CreateDirectory(Application.StartupPath + "\\ATTACH\\related file\\" + dr["PITEM_ID"].ToString().Trim().Replace('*', '_'));
}
SafeSetText(lbl_TUcdata, i.ToString());
#region 导出档案
List<PDM.Model.PDM_TUDANG> list = List_TUDANG.FindAll((PDM.Model.PDM_TUDANG p) => { return p.PITEM_ID.Trim() == dr["PITEM_ID"].ToString().Trim(); });
foreach (PDM.Model.PDM_TUDANG _list in list)
{
j++;
try
{
//建立版本文件夹
if (!Directory.Exists(Application.StartupPath + "\\ATTACH\\related file\\" + _list.PITEM_ID.Trim().Replace('*', '_') + "\\" + _list.PITEM_REVISION_ID.Trim()))
{
Directory.CreateDirectory(Application.StartupPath + "\\ATTACH\\related file\\" + _list.PITEM_ID.Trim().Replace('*', '_') + "\\" + _list.PITEM_REVISION_ID.Trim());
}
if (!File.Exists(Application.StartupPath + "\\ATTACH\\related file\\" + _list.PITEM_ID.Trim().Replace('*', '_') + "\\" + _list.PITEM_REVISION_ID + "\\" + _list.PORIGINAL_FILE_NAME.Trim()))
{
File.Copy(String.Format("{0}\\{1}\\{2}", txt_TU_Path.Text.Trim(), _list.PSD_PATH_NAME.Trim(), _list.PFILE_NAME.Trim()), Application.StartupPath + "\\ATTACH\\related file\\" + _list.PITEM_ID.Trim().Replace('*', '_') + "\\" + _list.PITEM_REVISION_ID + "\\" + _list.PORIGINAL_FILE_NAME.Trim());
}
}
catch (Exception err)
{
l++;
WriteLog("TUDANG:" + DateTime.Now.ToString("yyyyMMddHH:mm:ss") + "," + _list.PITEM_ID + "," + _list.PITEM_REVISION_ID + "," + _list.PORIGINAL_FILE_NAME + "," + _list.PFILE_NAME + "," + _list.PSD_PATH_NAME);
WriteErrLog("TUDANG:" + DateTime.Now.ToString("yyyyMMddHH:mm:ss") + "," + err.Message.ToString());
SafeSetText(lbl_TU_Fail, l.ToString());
}
//lbl_cfile.Text = j.ToString();
SafeSetText(lbl_TUcfile, j.ToString());
}
#endregion
}
catch (Exception err)
{
WriteErrLog("TUDANG:" + DateTime.Now.ToString("yyyyMMddHH:mm:ss") + "," + dr["PITEM_ID"].ToString().Trim() + "," + err.Message.ToString());
}
}
SafeSetText(lbl_TUtotal, "汇出完成");
}