/// <summary> /// 物理文件注册 /// </summary> /// <param name="fileType"></param> private void RegFile(DataType.FileType fileType) { string savePath = ""; string savePathID = "";//保存的目标路径的id ListView listViewFile = null; AddFileFrm frm = new AddFileFrm(); if (frm.ShowDialog() == DialogResult.OK) { //将需要添加的文件信息返回来 //fileList //savePath listViewFile = frm.ListViewFile; savePath = frm.SaveFilepath; //从弹出窗体返回来的保存路径 savePathID = frm.SavePathID;//保存的目标路径的id // MessageBox.Show(savePath); // FileSockClient.UpLoadFileSocketClient sock = null; //DataEntityQuery<DOC_FILE_LIST> query = DataEntityQuery<DOC_FILE_LIST>.Create(); DOC_FILE_LIST file = new DOC_FILE_LIST(); String path = ""; foreach (ListViewItem item in listViewFile.Items) { // MessageBox.Show(item.Text.ToString()); //var path = ofdFile.FileName; path = item.Text.ToString(); // IDocFileListService _fileService = ServiceContainer.GetService<DocFileListService>(); try { //FileSockClient.UpLoadFileSocketClient sock = new FileSockClient.UpLoadFileSocketClient(path, @"D:\\PDM文件服务器根目录"); FileSockClient.UpLoadFileSocketClient uploadSocket = new FileSockClient.UpLoadFileSocketClient(path, savePath); if (!uploadSocket.AckStatus) { return; } // MessageBox.Show("文件添加成功==文件目录" + @"E:\\PDM文件服务器根目录"); } catch (Exception ex) { MessageBox.Show("文件添加失败==文件目录" + savePath + "===" + ex.Message.ToString()); } finally { } try { file.DFL_ID = Guid.NewGuid().ToString(); file.DFL_FILE_NAME = path.Substring(path.LastIndexOf(@"\") + 1); file.DFL_FILE_EXTEND = path.Substring(path.LastIndexOf(@".") + 1); file.DFL_FILE_CHILD_PATH = savePathID; file.DEL_FLAG = "N"; //file.DFL_VER_LATEST = "V" + DateTime.Now.ToString("yyyyMMddHHmmss"); file.DFL_VER_LATEST = new HYDocumentMS.FileHelper().getNewVer("V"); file.DOCID = Document.DOCID; //与文档表关联主键 file.CREATEDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); file.CREATEUSER = LoginInfo.LoginID; file.LASTUPDATEDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); file.LASTUPDATEUSER = LoginInfo.LoginID; file.CHECKOUTFLG = "N"; file.CHECKINFLG = "Y"; // query.Save(file); //query.Insert(file); file.FILE_TYPE = fileType.ToString(); file.Save(); MessageBox.Show("文件注册成功,文件目录" + savePath, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } catch (Exception ex) { MessageBox.Show("文件注册失败【注册到数据库失败】," + ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } this.BindTreeData(); } } }
//private DataTable dt; ///// <summary> ///// 查看文件 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //private void btnView_Click(object sender, EventArgs e) //{ // ViewFile(this.tvFileList, DataType.FileType.ProcessFile); //} ///// <summary> ///// 工艺文件注册 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //private void btnRegPhysicalFile_Click(object sender, EventArgs e) //{ // //注册工艺文件 // RegFile(DataType.FileType.ProcessFile); //} ///// <summary> ///// 删除文件 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //private void btnDel_Click(object sender, EventArgs e) //{ // delFile(this.tvFileList, DataType.FileType.ProcessFile); //} ///// <summary> ///// 检入 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //private void btnCheckIN_Click(object sender, EventArgs e) //{ // CheckInFile(this.tvFileList, DataType.FileType.ProcessFile); //} ///// <summary> ///// 检出 ///// </summary> ///// <param name="sender"></param> ///// <param name="e"></param> //private void btnCheckOut_Click(object sender, EventArgs e) //{ // CheckOut(this.tvFileList, DataType.FileType.ProcessFile); //} /// <summary> /// 物理文件注册 /// </summary> /// <param name="fileType"></param> private void RegFile(DataType.FileType fileType) { string savePath = ""; string savePathID = "";//保存的目标路径的id ListView listViewFile = null; HYPDM.WinUI.Document.AddFileFrm frm = new HYPDM.WinUI.Document.AddFileFrm(); if (frm.ShowDialog() == DialogResult.OK) { //将需要添加的文件信息返回来 //fileList //savePath listViewFile = frm.ListViewFile; savePath = frm.SaveFilepath; //从弹出窗体返回来的保存路径 savePathID = frm.SavePathID; //保存的目标路径的id // MessageBox.Show(savePath); // FileSockClient.UpLoadFileSocketClient sock = null; //DataEntityQuery<DOC_FILE_LIST> query = DataEntityQuery<DOC_FILE_LIST>.Create(); DOC_FILE_LIST file = new DOC_FILE_LIST(); String path = ""; foreach (ListViewItem item in listViewFile.Items) { // MessageBox.Show(item.Text.ToString()); //var path = ofdFile.FileName; path = item.Text.ToString(); // IDocFileListService _fileService = ServiceContainer.GetService<DocFileListService>(); try { //FileSockClient.UpLoadFileSocketClient sock = new FileSockClient.UpLoadFileSocketClient(path, @"D:\\PDM文件服务器根目录"); FileSockClient.UpLoadFileSocketClient uploadSocket = new FileSockClient.UpLoadFileSocketClient(path, savePath); if (!uploadSocket.AckStatus) { return; } // MessageBox.Show("文件添加成功==文件目录" + @"E:\\PDM文件服务器根目录"); } catch (Exception ex) { MessageBox.Show("文件添加失败==文件目录" + savePath + "===" + ex.Message.ToString()); } finally { } try { file.DFL_ID = Guid.NewGuid().ToString(); file.DFL_FILE_NAME = path.Substring(path.LastIndexOf(@"\") + 1); file.DFL_FILE_EXTEND = path.Substring(path.LastIndexOf(@".") + 1); file.DFL_FILE_CHILD_PATH = savePathID; file.DEL_FLAG = "N"; //file.DFL_VER_LATEST = "V" + DateTime.Now.ToString("yyyyMMddHHmmss"); file.DFL_VER_LATEST = new HYDocumentMS.FileHelper().getNewVer("V"); file.DOCID = Document.DOCID; //与文档表关联主键 file.CREATEDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); file.CREATEUSER = LoginInfo.LoginID; file.LASTUPDATEDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); file.LASTUPDATEUSER = LoginInfo.LoginID; file.CHECKOUTFLG = "N"; file.CHECKINFLG = "Y"; // query.Save(file); //query.Insert(file); file.FILE_TYPE = fileType.ToString(); file.Save(); MessageBox.Show("图纸注册成功,文件目录" + savePath, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } catch (Exception ex) { MessageBox.Show("图纸注册失败【注册到数据库失败】," + ex.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } this.BindTreeData(); } } }
/// <summary> /// 检入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheckIN_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; if (txtFileName.Text.Trim() == string.Empty || txtFilePath.Text.Trim() == string.Empty) { MessageBox.Show("文件名或文件路径不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //Boolean result = true; //Util.FTPHelper helper = Util.Common.FtpHepler(); //var info = ""; //var result = helper.UploadFile(txtFilePath.Text, out info); try { string filePath = this.txtFilePath.Text.ToString(); int i = filePath.LastIndexOf(@"\"); if (i == -1) { i = filePath.LastIndexOf(@"/"); } filePath = filePath.Substring(0, i) + @"\" + this.txtFileName.Text.ToString(); string tempNewFileName = this.txtFileName.Text.ToString(); tempNewFileName = tempNewFileName.Substring(0, tempNewFileName.LastIndexOf(@".")) + DocFileEntity.DFL_VER_LATEST + tempNewFileName.Substring(tempNewFileName.LastIndexOf(@".")); // MessageBox.Show(filePath); string serPathAndFileName = new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH) + this.txtFileName.Text.ToString(); FileSockClient.CopyOldVerFile hh = new FileSockClient.CopyOldVerFile(serPathAndFileName, tempNewFileName); //复制旧版本数据到Vers目录下 if (!hh.AckStatus) { FileServerAckReult = hh.AckStatus; this.DialogResult = DialogResult.OK; return; } //上传更新文件覆盖旧文件 FileSockClient.UpLoadFileSocketClient upload = new FileSockClient.UpLoadFileSocketClient(filePath, new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH), true); if (!upload.AckStatus) { FileServerAckReult = upload.AckStatus; this.DialogResult = DialogResult.OK; return; } } catch (Exception ex) { FileServerAckReult = false; this.DialogResult = DialogResult.No; MessageBox.Show(ex.Message.ToString()); } //if (result) //{ // MessageBox.Show("文件检入成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); //} //else //{ // this.DialogResult = DialogResult.No; // MessageBox.Show("文件检入失败,具体原因为:" + info, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } }
/// <summary> /// 检入 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheckIN_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; if (txtFileName.Text.Trim() == string.Empty || txtFilePath.Text.Trim() == string.Empty) { MessageBox.Show("文件名或文件路径不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //Boolean result = true; //Util.FTPHelper helper = Util.Common.FtpHepler(); //var info = ""; //var result = helper.UploadFile(txtFilePath.Text, out info); try { string filePath = this.txtFilePath.Text.ToString(); int i = filePath.LastIndexOf(@"\"); if (i == -1) { i = filePath.LastIndexOf(@"/"); } filePath = filePath.Substring(0, i) + @"\" + this.txtFileName.Text.ToString(); string tempNewFileName = this.txtFileName.Text.ToString(); tempNewFileName = tempNewFileName.Substring(0, tempNewFileName.LastIndexOf(@".")) + DocFileEntity.DFL_VER_LATEST + tempNewFileName.Substring(tempNewFileName.LastIndexOf(@".")); // MessageBox.Show(filePath); string serPathAndFileName = new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH) + this.txtFileName.Text.ToString(); FileSockClient.CopyOldVerFile hh = new FileSockClient.CopyOldVerFile(serPathAndFileName, tempNewFileName); //复制旧版本数据到Vers目录下 if (!hh.AckStatus) { FileServerAckReult = hh.AckStatus; this.DialogResult = DialogResult.OK; return; } //上传更新文件覆盖旧文件 FileSockClient.UpLoadFileSocketClient upload = new FileSockClient.UpLoadFileSocketClient(filePath, new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH), true); if (!upload.AckStatus) { FileServerAckReult = upload.AckStatus; this.DialogResult = DialogResult.OK; return; } } catch (Exception ex) { FileServerAckReult = false; this.DialogResult = DialogResult.No; MessageBox.Show(ex.Message.ToString()); } //if (result) //{ // MessageBox.Show("文件检入成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); //} //else //{ // this.DialogResult = DialogResult.No; // MessageBox.Show("文件检入失败,具体原因为:" + info, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); //} } }