public void CopyFileList(string _projectNO, string _projectCategory) { BLL.T_FileList_BLL B1 = new T_FileList_BLL(); IList <MDL.T_FileList> fileList = (new BLL.T_FileList_BLL()).FindByProjectNO(_projectNO); if (fileList.Count <= 0) { T_FileList file = new T_FileList(); T_GdList gd = new T_GdList(); gd.ProjectNo = _projectNO; gd.ProjectCategory = _projectCategory; file.ProjectNO = _projectNO; file.ProjectCategory = _projectCategory; String stmtId = "T_FileList.CopyFileList"; MyISqlMap.QueryForObject <int>(stmtId, file); stmtId = "T_CellAndEFile.CopyCellFileList"; MyISqlMap.QueryForObject <int>(stmtId, _projectNO); stmtId = "T_GdList.CopyGdList"; MyISqlMap.QueryForObject <int>(stmtId, gd); } }
/// <summary> /// 更新案卷下的文字页数 /// </summary> /// <param name="ProjectNO"></param> /// <param name="ArchiveID"></param> /// <returns></returns> public void UpdateArchiveTextNums(T_Archive obj) { if (obj == null) { throw new ArgumentNullException("obj"); } T_FileList_BLL fileListBLL = new T_FileList_BLL(); obj.wzz = fileListBLL.GetWzCount(obj.ArchiveID, obj.ProjectNO).ToString(); String stmtId = "T_Archive.Update"; MyISqlMap.Update(stmtId, obj); }
/// <summary> /// 按案卷上报 /// </summary> /// <returns></returns> private bool?ConfirmSplitForfrmArchive() { if (txtLoc.Text == "") { TXMessageBoxExtensions.Info("请选择导出文件的存储路径!"); txtLoc.Focus(); return(null); } string destFilename = Globals.Projectname; destFolder = txtLoc.Text; string dest_temp = Path.GetDirectoryName(txtLoc.Text); if (!Directory.Exists(dest_temp)) { TXMessageBoxExtensions.Info("存储的路径不存在!"); return(null); } double projectSize = Convert.ToDouble(DirectoryInfoCommon.GetDirectorySpace(Application.StartupPath + "\\Project\\" + Globals.ProjectNO) / Convert.ToDouble(1024 * 1024 * 1024)); ReadWriteAppConfig config = new ReadWriteAppConfig(); if (config.Read("Upload_ProjectSize") == "") { config.Write("Upload_ProjectSize", "4"); } string upload_size = config.Read("Upload_ProjectSize"); if (projectSize > Convert.ToDouble(upload_size)) { DialogResult dresult = TXMessageBoxExtensions.Question("上报工程大于" + upload_size + "G,当前工程大小为:" + System.Math.Round(projectSize, 2) + "G \r\n\n 【温馨提示:工程太大,生成移交文件需要比较长得时间】 \r\n\n 是否继续生成移交?"); if (dresult != DialogResult.OK) { return(null); } } else if (MyCommon.CheckDisk(destFolder) < projectSize) { //硬盘空间不足 TXMessageBoxExtensions.Info("上报工程大小为:" + System.Math.Round(projectSize, 2) + "G 保存目录硬盘空间不足,无法生成! \r\n 【温馨提示:请选择比较空闲的盘符】"); txtLoc.Focus(); return(null); } tempFullName = dest_temp + "\\" + Guid.NewGuid().ToString(); if (System.IO.Directory.Exists(tempFullName)) { MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); } MyCommon.DeleteAndCreateEmptyDirectory(tempFullName); MyCommon.DeleteAndCreateEmptyDirectory(destFolder, false); MyCommon.DeleteAndCreateEmptyDirectory(destFolder, true); panelBottom.Visible = true; panelTop.Visible = false; Application.DoEvents(); butClose.Enabled = false; ERM.CBLL.CreateSip projectFactory = new ERM.CBLL.CreateSip(Globals.ProjectNO); //DataSet dsFinalArchive = projectFactory.GetListArchive(Globals.ProjectNO, ""); DataSet dsFinalArchive = new Archive().pb_setXmlInfo(); if (dsFinalArchive.Tables.Count < 1 || dsFinalArchive.Tables[0].Rows.Count < 1) { TXMessageBoxExtensions.Info("没有任何案卷可以移交!"); return(false); } int count_FinalArchive = dsFinalArchive.Tables[0].Rows.Count; bool checkfile_flag = true; for (int i = 0; i < count_FinalArchive; i++) { BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL(); IList <MDL.T_FileList> fileList = fileBLL.FindByArchiveID2(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO); foreach (MDL.T_FileList obj in fileList) { if (obj.selected == 1 || obj.filepath == null || obj.filepath == "") { ConvertAllEFileToPDF(obj.FileID); } else { string tFilePath = obj.filepath.Replace("MPDF\\", ""); string sourMfile = Globals.ProjectPath + obj.filepath; if (!System.IO.File.Exists(sourMfile)) { ConvertAllEFileToPDF(obj.FileID); } } IList <MDL.T_CellAndEFile> cellList = (new ERM.BLL.T_CellAndEFile_BLL()).FindByGdFileID(obj.FileID, Globals.ProjectNO); ERM.MDL.T_FileList file_model = (new ERM.BLL.T_FileList_BLL()).Find(obj.FileID, Globals.ProjectNO); if ((file_model.filepath == null || file_model.filepath == "") && cellList.Count > 0) { TXMessageBoxExtensions.Info("提示:文件【" + obj.gdwj + "】电子文件信息有误!无法移交,请审查"); checkfile_flag = false; break; } } if (!checkfile_flag) { break; } } if (!checkfile_flag) { return(false); } progressBar2.Maximum = count_FinalArchive; progressBar2.Minimum = 0; progressBar2.MarqueeAnimationSpeed = 1000; progressBar2.Step = 1; lblMsg.Text = "正在输出元数据信息..."; Application.DoEvents(); GetListArchiveXML(projectFactory, tempFullName); try { for (int i = 0; i < count_FinalArchive; i++) { if (!Directory.Exists(tempFullName)) { MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, true); } //20120530 屏蔽XML文件 GetProjectXML(projectFactory, tempFullName); if (Convert.ToBoolean(Properties.Settings.Default.SipIncludeDoc)) { //20120530 屏蔽XML文件 GetListArchiveXMLEx(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), tempFullName); GetDocumentXMLEx(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), tempFullName); BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL(); IList <MDL.T_FileList> fileList = fileBLL.FindByArchiveID2(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO); foreach (MDL.T_FileList obj in fileList) { //20120530 屏蔽XML文件 //getDocModel(obj); getDocModel_NEW(obj, tempFullName); } } lblMsg.Text = "正在对数据包进行封装..."; Application.DoEvents(); if (System.IO.File.Exists(tempFullName + "\\index.dat"))//Application.StartupPath + "\\temp\\index.dat" { System.IO.File.Move(tempFullName + "\\index.dat", destFolder + "\\index.dat"); string gcInfo = System.IO.File.ReadAllText(tempFullName + "\\a#sgwj_gc.xml", Encoding.GetEncoding("gb2312")); string docList = System.IO.File.ReadAllText(destFolder + "\\index.dat"); gcInfo = gcInfo.Replace("</项目工程信息>", "<ArchiveFileList>" + docList + "</ArchiveFileList></项目工程信息>"); System.IO.File.WriteAllText(destFolder + "\\index.dat", gcInfo, Encoding.GetEncoding("gb2312")); } SevenZip.SevenZipCompressor.SetLibraryPath(Application.StartupPath + "\\7z.dll"); SevenZip.SevenZipCompressor tmp = new SevenZip.SevenZipCompressor(); { tmp.ArchiveFormat = SevenZip.OutArchiveFormat.Zip; tmp.CompressDirectory(tempFullName, destFolder + "\\" + dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString() + ".sip"); } MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); progressBar2.Value = progressBar2.Value + 1; } } catch (Exception ex) { MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); TXMessageBoxExtensions.Info("封装数据时发生意外错误!错误002"); MyCommon.WriteLog("生成移交文件时失败!错误信息:" + ex.Message); return(false); } butClose.Text = "关闭"; butClose.Enabled = true; TXMessageBoxExtensions.Info("已经成功生成上报文件!"); return(true); }
private bool StartRemove(string saveLoc, System.ComponentModel.BackgroundWorker _bgWorker) { string destFilename = Globals.Projectname; destFolder = saveLoc; string dest_temp = Path.GetDirectoryName(saveLoc); tempFullName = dest_temp + "\\" + Guid.NewGuid().ToString(); if (System.IO.Directory.Exists(tempFullName)) { MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); } MyCommon.DeleteAndCreateEmptyDirectory(tempFullName); MyCommon.DeleteAndCreateEmptyDirectory(destFolder, false); MyCommon.DeleteAndCreateEmptyDirectory(destFolder, true); if (Index_temp > 100) { Index_temp = 0; } _bgWorker.ReportProgress(Index_temp++); ERM.CBLL.CreateSip projectFactory = new ERM.CBLL.CreateSip(Globals.ProjectNO); // DataSet dsFinalArchive = projectFactory.GetListArchive(Globals.ProjectNO, ""); DataSet dsFinalArchive = new Archive().pb_setXmlInfo(); if (dsFinalArchive.Tables.Count < 1 || dsFinalArchive.Tables[0].Rows.Count < 1) { TXMessageBoxExtensions.Info("没有任何案卷可以移交!"); return(false); } int count_FinalArchive = dsFinalArchive.Tables[0].Rows.Count; //DataSet dsFinalArchive_temp = projectFactory.GetListArchive(Globals.ProjectNO, ""); DataSet dsFinalArchive_temp = dsFinalArchive; dsFinalArchive_temp.DataSetName = "案卷信息"; dsFinalArchive_temp.Tables[0].TableName = "记录"; string _filename = tempFullName + "\\index.dat"; StreamWriter w1 = new StreamWriter(_filename, false, Encoding.Default); if (dsFinalArchive_temp != null && dsFinalArchive_temp.Tables.Count > 0 && dsFinalArchive_temp.Tables[0].Rows.Count > 0) { for (int i1 = 0; i1 < dsFinalArchive_temp.Tables[0].Rows.Count; i1++) { w1.WriteLine("<FileList><File>" + dsFinalArchive_temp.Tables[0].Rows[i1][0].ToString() + ".sip</File>"); w1.WriteLine("<Title>" + dsFinalArchive_temp.Tables[0].Rows[i1]["案卷题名"].ToString() + "</Title></FileList>"); } } w1.Flush(); w1.Close(); if (Index_temp > 100) { Index_temp = 0; } _bgWorker.ReportProgress(Index_temp++); try { for (int i = 0; i < count_FinalArchive; i++) { if (Index_temp > 100) { Index_temp = 0; } _bgWorker.ReportProgress(Index_temp++); if (!Directory.Exists(tempFullName)) { MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, true); } StreamWriter gc = new StreamWriter(tempFullName + "\\a#sgwj_gc.xml", false, Encoding.Default); gc.WriteLine("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"no\"?>"); gc.WriteLine("<项目工程信息>"); gc.WriteLine(" <项目信息>"); DataSet ds = new Item().pb_setXmlInfo(new T_Projects_BLL().Find(Globals.ProjectNO).ItemID); Hashtable _Item = new Hashtable(); if (ds.Tables.Count > 0) { for (int n = 0; n < ds.Tables[0].Rows.Count; n++) { for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { _Item.Add(ds.Tables[0].Columns[j].ColumnName, ds.Tables[0].Rows[n][j].ToString()); } } foreach (System.Collections.DictionaryEntry objDE in _Item) { if (_Item[objDE.Key] != null) { if (_Item[objDE.Key].GetType() != typeof(System.String[])) { gc.WriteLine(" <" + objDE.Key + ">" + objDE.Value + "</" + objDE.Key + ">"); } else { gc.WriteLine(" <" + objDE.Key + ">" + ((string[])_Item[objDE.Key])[0] + "</" + objDE.Key + ">"); } } else { gc.WriteLine(" <" + objDE.Key + "></" + objDE.Key + ">"); } } } gc.WriteLine(" </项目信息>"); gc.WriteLine(" <工程信息>"); Hashtable _detail = new Hashtable(); DataSet ds1 = new ERM.UI.Common.XmlMapping.Project().pb_setXmlInfo(new T_Projects_BLL().Find(Globals.ProjectNO).ProjectCategory); if (ds1.Tables.Count > 0) { for (int n = 0; n < ds1.Tables[0].Rows.Count; n++) { for (int j = 0; j < ds1.Tables[0].Columns.Count; j++) { _detail.Add(ds1.Tables[0].Columns[j].ColumnName, ds1.Tables[0].Rows[n][j].ToString()); } } foreach (System.Collections.DictionaryEntry objDE in _detail) { if (_detail[objDE.Key] != null) { if (_detail[objDE.Key].GetType() != typeof(System.String[])) { gc.WriteLine(" <" + objDE.Key + ">" + objDE.Value + "</" + objDE.Key + ">"); } else { gc.WriteLine(" <" + objDE.Key + ">" + ((string[])_detail[objDE.Key])[0] + "</" + objDE.Key + ">"); } } else { gc.WriteLine(" <" + objDE.Key + "></" + objDE.Key + ">"); } } gc.WriteLine(" </工程信息>"); gc.WriteLine("</项目工程信息>"); gc.Flush(); gc.Close(); } if (Convert.ToBoolean(Properties.Settings.Default.SipIncludeDoc)) { #region ================================== //20120530 屏蔽XML文件 //DataSet dsFinalArchive_temp1 = projectFactory.GetListArchive(Globals.ProjectNO, dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString()); DataSet dsFinalArchive_temp1 = new Archive().pb_setXmlInfo(Globals.ProjectNO, dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString()); dsFinalArchive_temp1.DataSetName = "案卷信息"; dsFinalArchive_temp1.Tables[0].TableName = "记录"; _filename = tempFullName + "\\a#sgwj_file.xml"; if (System.IO.File.Exists(_filename)) { try { System.IO.File.Delete(_filename); } catch { } } gc = new StreamWriter(_filename, true, Encoding.Default); gc.WriteLine("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"no\"?>"); gc.Flush(); gc.Close(); System.IO.FileStream stream_archive = new System.IO.FileStream(_filename, System.IO.FileMode.Append); System.Xml.XmlTextWriter xmlWriter_archive = new System.Xml.XmlTextWriter(stream_archive, System.Text.Encoding.Default); dsFinalArchive_temp1.WriteXml(xmlWriter_archive); xmlWriter_archive.Close(); #endregion #region =========================== //DataSet dsFinalFile = projectFactory.GetListFile(Globals.ProjectNO, // dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString()); DataSet dsFinalFile = new ERM.UI.Common.XmlMapping.File().pb_setXmlInfo("pb_queryByFileNo", dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO); dsFinalFile.DataSetName = "文件信息"; dsFinalFile.Tables[0].TableName = "记录"; _filename = tempFullName + "\\a#sgwj_document.xml"; if (System.IO.File.Exists(_filename)) { try { System.IO.File.Delete(_filename); } catch { } } gc = new StreamWriter(_filename, true, Encoding.Default); gc.WriteLine("<?xml version=\"1.0\" encoding=\"gb2312\" standalone=\"no\"?>"); gc.Flush(); gc.Close(); System.IO.FileStream stream_file = new System.IO.FileStream(_filename, System.IO.FileMode.Append); System.Xml.XmlTextWriter xmlWriter_file = new System.Xml.XmlTextWriter(stream_file, System.Text.Encoding.Default); dsFinalFile.WriteXml(xmlWriter_file); xmlWriter_file.Close(); #endregion BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL(); //IList<MDL.T_FileList> fileList = fileBLL.FindByArchiveID2(dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO); DataSet fileList = new ERM.UI.Common.XmlMapping.File().pb_setXmlInfo("pb_FindByArchiveID2", dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString(), Globals.ProjectNO); if (fileList.Tables.Count > 0) { for (int j = 0; j < fileList.Tables[0].Rows.Count; j++) { DataRow obj = fileList.Tables[0].Rows[j]; if (Index_temp > 100) { Index_temp = 0; } _bgWorker.ReportProgress(Index_temp++); string FileID = obj["FileID"].ToString(); if (obj["filepath"] != null) { string tFilePath = obj["filepath"].ToString().Replace("MPDF\\", ""); string decMfile = tempFullName + "\\" + tFilePath; string sourMfile = Globals.ProjectPath + obj["filepath"]; try { if (System.IO.File.Exists(sourMfile)) { System.IO.File.Copy(sourMfile, decMfile, true); } } catch (Exception ex) { MyCommon.WriteLog("生成移交文件时,拷贝文件失败!错误信息:" + ex.Message); } } BLL.T_CellAndEFile_BLL cellBLL = new ERM.BLL.T_CellAndEFile_BLL(); IList <MDL.T_CellAndEFile> cellList = cellBLL.FindByFileID(FileID, Globals.ProjectNO, 1); foreach (MDL.T_CellAndEFile obj2 in cellList) { string yswjpath = obj2.filepath.Replace("ODOC\\", ""); string dec = tempFullName + "\\" + yswjpath; string sour = Globals.ProjectPath + obj2.filepath; try { if (System.IO.File.Exists(sour)) { System.IO.File.Copy(sour, dec, true); } } catch (Exception ex) { MyCommon.WriteLog("生成移交文件时,拷贝原文件失败!错误信息:" + ex.Message); } } } } } if (System.IO.File.Exists(tempFullName + "\\index.dat")) { System.IO.File.Move(tempFullName + "\\index.dat", destFolder + "\\index.dat"); string gcInfo = System.IO.File.ReadAllText(tempFullName + "\\a#sgwj_gc.xml", Encoding.GetEncoding("gb2312")); string docList = System.IO.File.ReadAllText(destFolder + "\\index.dat"); gcInfo = gcInfo.Replace("</项目工程信息>", "<ArchiveFileList>" + docList + "</ArchiveFileList></项目工程信息>"); System.IO.File.WriteAllText(destFolder + "\\index.dat", gcInfo, Encoding.GetEncoding("gb2312")); } SevenZip.SevenZipCompressor.SetLibraryPath(Application.StartupPath + "\\7z.dll"); SevenZip.SevenZipCompressor tmp = new SevenZip.SevenZipCompressor(); tmp.ArchiveFormat = SevenZip.OutArchiveFormat.Zip; tmp.CompressDirectory(tempFullName, destFolder + "\\" + dsFinalArchive.Tables[0].Rows[i]["案卷ID"].ToString() + ".sip"); MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); } } catch (Exception ex) { MyCommon.DeleteAndCreateEmptyDirectory(tempFullName, false); TXMessageBoxExtensions.Info("封装数据时发生意外错误!错误002"); MyCommon.WriteLog("生成移交文件时失败!错误信息:" + ex.Message); return(false); } return(true); }
/// <summary> /// 重新生成PDF /// </summary> /// <param name="FileID">节点ID</param> private void ConvertAllEFileToPDF(string FileID) { BLL.T_FileList_BLL fileBLL = new ERM.BLL.T_FileList_BLL(); MDL.T_FileList fileMDL = fileBLL.Find(FileID, Globals.ProjectNO); BLL.T_CellAndEFile_BLL cellBLL = new ERM.BLL.T_CellAndEFile_BLL(); IList <MDL.T_CellAndEFile> cellList = cellBLL.FindByGdFileID(FileID, Globals.ProjectNO); System.Collections.ArrayList fileArryList = new System.Collections.ArrayList(); bool isUpdateFileSelect_flg = false; foreach (MDL.T_CellAndEFile cellMDL in cellList) { string pdfPath = ""; if (cellMDL.DocYs == null || cellMDL.DocYs == 1 || cellMDL.fileTreePath == String.Empty || cellMDL.fileTreePath == "") { if (!isUpdateFileSelect_flg) { isUpdateFileSelect_flg = true; } using (ConvertCell2PDF c1 = new ConvertCell2PDF()) { try { int iPageCount = c1.PrintCellToPDF(Globals.ProjectPath + cellMDL.filepath, Globals.ProjectPath + "PDF\\" + cellMDL.CellID + ".pdf"); if (iPageCount == 0) { cellMDL.fileTreePath = ""; } else { cellMDL.fileTreePath = "PDF\\" + cellMDL.CellID + ".pdf"; } cellMDL.DocYs = 0; cellMDL.DoStatus = 1; cellMDL.ys = iPageCount; cellBLL.Update(cellMDL); } catch (Exception e) { cellMDL.fileTreePath = ""; MyCommon.WriteLog("PDF转换失败!错误信息:" + e.Message); } pdfPath = cellMDL.fileTreePath; } } else { pdfPath = cellMDL.fileTreePath; } if (!System.IO.File.Exists(Globals.ProjectPath + pdfPath)) { continue; } fileArryList.Add(Globals.ProjectPath + pdfPath); } string[] FileList = new string[fileArryList.Count]; for (int i = 0; i < fileArryList.Count; i++) { FileList[i] = fileArryList[i].ToString(); } using (ConvertCell2PDF c1 = new ConvertCell2PDF()) { int iPageCount = 0; if (FileList.Length > 0) { try { iPageCount = c1.MergePDF(FileList, Globals.ProjectPath + "MPDF\\" + FileID + ".pdf"); if (iPageCount == 0) { fileMDL.filepath = ""; } else { fileMDL.filepath = "MPDF\\" + FileID + ".pdf"; } } catch (Exception ex) { iPageCount = 0; fileMDL.filepath = ""; MyCommon.WriteLog("合并PDF失败!错误信息:" + ex.Message); } } else { fileMDL.filepath = ""; } //1 文字数量 2声像 3照片数量 int EFileType_flg = 1; TreeFactory treeFactory = new TreeFactory(); treeFactory.GetParentNodeType(FileID, ref EFileType_flg); if (EFileType_flg == 1) { fileMDL.sl = iPageCount; } else if (EFileType_flg == 3) { int tzz = MyCommon.ToInt(fileMDL.tzz); int dtz = MyCommon.ToInt(fileMDL.dtz); int zpz = MyCommon.ToInt(fileMDL.zpz); int dpz = MyCommon.ToInt(fileMDL.dpz); fileMDL.dw = (iPageCount + dtz).ToString(); fileMDL.tzz = (iPageCount).ToString(); fileMDL.dtz = dtz.ToString(); fileMDL.wzz = (zpz + dpz).ToString(); fileMDL.zpz = zpz.ToString(); fileMDL.dpz = dpz.ToString(); } else if (EFileType_flg == 2) { int tzz = MyCommon.ToInt(fileMDL.tzz); int dtz = MyCommon.ToInt(fileMDL.dtz); int zpz = MyCommon.ToInt(fileMDL.zpz); int dpz = MyCommon.ToInt(fileMDL.dpz); fileMDL.dw = (tzz + dtz).ToString(); fileMDL.tzz = tzz.ToString(); fileMDL.dtz = dtz.ToString(); fileMDL.wzz = (iPageCount + dpz).ToString(); fileMDL.zpz = (iPageCount).ToString(); fileMDL.dpz = dpz.ToString(); } fileMDL.selected = 0; fileBLL.Update(fileMDL); } }
/// <summary> /// 复制 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Click(object sender, EventArgs e) { frm2PDFProgressMsg fmessage = new frm2PDFProgressMsg(); fmessage.Text = "工程复制中..."; try { string sourceNO = string.Empty; string sourceName = string.Empty; string targeNO = string.Empty; string targeName = string.Empty; T_Projects sourcePorj; T_Projects targePorj; (cbx_Source.SelectedItem as System.Data.DataRowView)[0].ToString(); if (cbx_Source.Items.Count == 1 || cbx_Trage.Items.Count == 1) { TXMessageBoxExtensions.Info("提示:请选择需要复制的工程!"); cbx_Source.Focus(); return; } else if ((cbx_Source.SelectedItem as System.Data.DataRowView)[0].ToString() == "--请选择") { TXMessageBoxExtensions.Info("提示:请选择复制的工程!"); cbx_Source.Focus(); return; } else if ((cbx_Trage.SelectedItem as System.Data.DataRowView)[0].ToString() == "--请选择") { TXMessageBoxExtensions.Info("提示:请选择复制的目的工程!"); cbx_Trage.Focus(); return; } else { sourceNO = (cbx_Source.SelectedItem as System.Data.DataRowView)[1].ToString(); //要编辑的主键 sourceName = (cbx_Source.SelectedItem as System.Data.DataRowView)[0].ToString(); //要编辑的主键 targeNO = (cbx_Trage.SelectedItem as System.Data.DataRowView)[1].ToString(); //要编辑的主键 targeName = (cbx_Trage.SelectedItem as System.Data.DataRowView)[0].ToString(); //要编辑的主键 //根据工程编号查询工程类别 sourcePorj = projectBLL.Find(sourceNO); targePorj = projectBLL.Find(targeNO); if (sourcePorj.ProjectCategory != targePorj.ProjectCategory) { TXMessageBoxExtensions.Info("复制的工程类别必须一致!"); return; } if (sourceNO == targeNO) { TXMessageBoxExtensions.Info("提示:同一工程不能复制!"); return; } } if (TXMessageBoxExtensions.Question("提示:确定将工程\n编号:" + sourceNO + " 名称:" + sourceName + "\n复制到工程\n编号:" + targeNO + " 名称:" + targeName + "\n【温馨提示:复制之后工程信息将无法恢复!请慎重!!!】") == DialogResult.OK) { status_flg = true; btn_Copy.Enabled = false; btn_Colse.Enabled = false; fmessage = new frm2PDFProgressMsg(); fmessage.Text = "工程复制中..."; fmessage.progressBar1.Maximum = 4; fmessage.label2.Text = "正在删除工程编号:" + targeNO + "信息..."; fmessage.progressBar1.Value = 1; fmessage.Show(); Application.DoEvents(); //删除目的工程下信息 BLL.BLLMore bllMore = new BLL.BLLMore(); bllMore.DeleteUnitByProjectNO(targeNO); bllMore.DeleteFileListByProjectNO(targeNO); bllMore.DeleteCellFileByProjectNO(targeNO); bllMore.DeleteArchiveByProjectNO(targeNO); bllMore.DeleteGdFileByProjectNO(targeNO);//删除归档类别 #region add deleteProject bllMore.DeleteTrafficByProjectNO(targeNO); bllMore.DeleteRoadLampByProjectNO(targeNO); bllMore.DeleteBrigeByProjectNO(targeNO); bllMore.DeletePointByPorjectNo(targeNO); #endregion MyCommon.DeleteAndCreateEmptyDirectory(Globals.ProjectPathParent + targeNO); //将源工程信息Copy到目的工程 fmessage.label2.Text = "正在更新工程编号:" + targeNO + "信息..."; fmessage.progressBar1.Value = 2; Application.DoEvents(); BLL.T_Projects_BLL Proj_bll = new ERM.BLL.T_Projects_BLL(); ERM.MDL.T_Projects targe_proj_MDL = Proj_bll.Find(targeNO); ERM.MDL.T_Projects source_proj_MDL = Proj_bll.Find(sourceNO); targe_proj_MDL.address = source_proj_MDL.address; targe_proj_MDL.area1 = source_proj_MDL.area1; targe_proj_MDL.area2 = source_proj_MDL.area2; targe_proj_MDL.begindate = source_proj_MDL.begindate; targe_proj_MDL.bgyfmj = source_proj_MDL.bgyfmj; targe_proj_MDL.bjdate = source_proj_MDL.bjdate; targe_proj_MDL.category = source_proj_MDL.category; targe_proj_MDL.cfmj = source_proj_MDL.cfmj; targe_proj_MDL.createdate = source_proj_MDL.createdate; targe_proj_MDL.district = source_proj_MDL.district; targe_proj_MDL.dxsmj = source_proj_MDL.dxsmj; targe_proj_MDL.enddate = source_proj_MDL.enddate; targe_proj_MDL.floors1 = source_proj_MDL.floors1; targe_proj_MDL.floors2 = source_proj_MDL.floors2; targe_proj_MDL.ghcode = source_proj_MDL.ghcode; targe_proj_MDL.high = source_proj_MDL.high; targe_proj_MDL.hjqk = source_proj_MDL.hjqk; targe_proj_MDL.jldwshr = source_proj_MDL.jldwshr; targe_proj_MDL.jsdwshr = source_proj_MDL.jsdwshr; targe_proj_MDL.passwd = source_proj_MDL.passwd; targe_proj_MDL.price1 = source_proj_MDL.price1; targe_proj_MDL.price2 = source_proj_MDL.price2; targe_proj_MDL.projecttype = source_proj_MDL.projecttype; targe_proj_MDL.qtyfmj = source_proj_MDL.qtyfmj; targe_proj_MDL.sgbzz = source_proj_MDL.sgbzz; targe_proj_MDL.sgcode = source_proj_MDL.sgcode; targe_proj_MDL.stru = source_proj_MDL.stru; targe_proj_MDL.syyfmj = source_proj_MDL.syyfmj; targe_proj_MDL.tbr = source_proj_MDL.tbr; targe_proj_MDL.tempid = source_proj_MDL.tempid; targe_proj_MDL.ts1 = source_proj_MDL.ts1; targe_proj_MDL.ts2 = source_proj_MDL.ts2; targe_proj_MDL.ts3 = source_proj_MDL.ts3; targe_proj_MDL.ts4 = source_proj_MDL.ts4; targe_proj_MDL.tstotal = source_proj_MDL.tstotal; targe_proj_MDL.ydpzcode = source_proj_MDL.ydpzcode; targe_proj_MDL.ydxkcode = source_proj_MDL.ydxkcode; targe_proj_MDL.zjy = source_proj_MDL.zjy; targe_proj_MDL.zygz = source_proj_MDL.zygz; targe_proj_MDL.zzmj = source_proj_MDL.zzmj; targe_proj_MDL.ztcw = source_proj_MDL.ztcw; targe_proj_MDL.dstcw = source_proj_MDL.dstcw; targe_proj_MDL.dxtcw = source_proj_MDL.dxtcw; targe_proj_MDL.kzsfcd = source_proj_MDL.kzsfcd; targe_proj_MDL.ts5 = source_proj_MDL.ts5; targe_proj_MDL.XMJL = source_proj_MDL.XMJL; targe_proj_MDL.yjdw = source_proj_MDL.yjdw; targe_proj_MDL.XCJL = source_proj_MDL.XCJL; Proj_bll.Update(targe_proj_MDL); //坐标信息 IList <T_Point> t_point_source = new T_Point_BLL().GetList(sourceNO); foreach (var item in t_point_source) { item.ID = Guid.NewGuid().ToString(); item.ProjectNo = targeNO; new T_Point_BLL().Insert(item); } //电子文件 bllMore.CopyFileAndEFileList(sourceNO, targeNO); BLL.T_Archive_BLL archive_bll = new ERM.BLL.T_Archive_BLL(); //案卷信息 BLL.T_FileList_BLL filelist_bll = new ERM.BLL.T_FileList_BLL(); //文件表 BLL.T_CellAndEFile_BLL cellAndEfile = new ERM.BLL.T_CellAndEFile_BLL(); //电子文件 //单位 BLL.T_Units_BLL units_bll = new ERM.BLL.T_Units_BLL(); //施工单位 IList <MDL.T_Units> IUnits = units_bll.FindByProjectNO(sourceNO); if (IUnits != null && IUnits.Count > 0) { foreach (MDL.T_Units units in IUnits) { units.UnitID = Guid.NewGuid().ToString(); units.ProjectNO = targeNO; units_bll.Add(units);//保存 } } //扩展信息 switch (sourcePorj.ProjectCategory) { case "Traffic": T_Traffic_BLL trafficBll = new T_Traffic_BLL(); T_Traffic traffic = trafficBll.QueryTraffic_ByProjID(sourceNO); if (traffic != null) { traffic.ID = Guid.NewGuid().ToString(); traffic.ProjectID = targeNO; trafficBll.Insert(traffic); } break; case "RoadLamp": T_Project_RoadLamp_BLL roadLampBll = new T_Project_RoadLamp_BLL(); T_Project_RoadLamp roadLamp = roadLampBll.QueryRoadLamp_ByProjID(sourceNO); if (roadLamp != null) { roadLamp.ProjectID = targeNO; roadLamp.ID = Guid.NewGuid().ToString(); roadLampBll.Insert(roadLamp); } break; case "Brige": T_Project_Brige_BLL brigeBll = new T_Project_Brige_BLL(); T_Project_Brige brige = brigeBll.QueryBrige_ByProjID(sourceNO); if (brige != null) { brige.ID = Guid.NewGuid().ToString(); brige.ProjectID = targeNO; brigeBll.Insert(brige); } break; } fmessage.progressBar1.Value = 3; Application.DoEvents(); //迁移文件夹 string mprojectPath = Application.StartupPath + "\\Project\\" + sourceNO; string tprojectPath = Application.StartupPath + "\\Project\\" + targeNO; string[] DirectoryList = new string[] { "MPDF", "ODOC", "PDF" }; if (System.IO.Directory.Exists(tprojectPath)) { MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath, false); MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath, true); } else { MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath, true); } string tempText = fmessage.label2.Text; char[] tempChar = tempText.ToCharArray(); int tempIndex = 0; foreach (string dic in DirectoryList) { MyCommon.DeleteAndCreateEmptyDirectory(tprojectPath + "\\" + dic, true); fmessage.label2.Text = ""; if (System.IO.Directory.Exists(mprojectPath)) { if (System.IO.Directory.Exists(mprojectPath + "\\" + dic)) { string[] files = System.IO.Directory.GetFiles(mprojectPath + "\\" + dic); foreach (string filename in files) { fmessage.label2.Text += tempChar[tempIndex]; Application.DoEvents(); tempIndex++; if (tempIndex >= tempChar.Length) { tempIndex = 0; fmessage.label2.Text = ""; } System.IO.FileInfo fileinfo = new System.IO.FileInfo(filename); if (System.IO.File.Exists(filename)) { System.IO.File.Copy(filename, tprojectPath + "\\" + dic + "\\" + fileinfo.Name, true); } } } } } fmessage.progressBar1.Value = 4; Application.DoEvents(); fmessage.Close(); btn_Copy.Enabled = true; btn_Colse.Enabled = true; TXMessageBoxExtensions.Info("提示:复制成功!"); BindGridViewData(); } } catch (Exception ex) { if (fmessage != null) { fmessage.Close(); } TXMessageBoxExtensions.Info("提示:复制失败!"); MyCommon.WriteLog("复制工程错误:" + ex.Message); btn_Copy.Enabled = true; btn_Colse.Enabled = true; } }