/// <summary> /// checkin文件 /// </summary> /// <param name="tgv"></param> /// <param name="fileType"></param> private void CheckInFile(TreeGridView tgv, DataType.FileType fileType) { int rowIndex = tgv.CurrentCell.RowIndex; if (rowIndex <= 0) { MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataGridViewRow row = tgv.Rows[rowIndex]; String Id = row.Cells["DFL_ID"].Value.ToString(); DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id); // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, ""); HYDocumentMS.IFileHelper file = new FileHelper(); Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckIn, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString()); if (bl == false) { MessageBox.Show("你没有权限检入此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (docFileEntity == null) { return; } if (docFileEntity.CHECKOUTFLG == "N") { MessageBox.Show("文件名【" + docFileEntity.DFL_FILE_NAME + "】" + "\n" + "不为检出状态,不能进行检入操作!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { HYPDM.WinUI.Document.CheckInForm form = new HYPDM.WinUI.Document.CheckInForm(); form.DocFileEntity = docFileEntity; if (form.ShowDialog() == DialogResult.OK) { if (form.FileServerAckReult1) { docFileEntity.CHECKINFLG = "Y"; docFileEntity.CHECKINDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); docFileEntity.CHECKOUTFLG = "N"; docFileEntity.DFL_VER_LATEST = "V" + DateTime.Now.ToString("yyyyMMddHHmmss"); docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID; docFileEntity.Save(); VersionSave("1", docFileEntity); MessageBox.Show("文件检入成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.DialogResult = DialogResult.No; MessageBox.Show("文件检入失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <summary> /// 版本历史记录保存 /// </summary> /// <param name="type">0:检出,1:检入</param> private void VersionSave(string type, DOC_FILE_LIST doc) { PDM_VERSION_HISTORY version = new PDM_VERSION_HISTORY(); version.ID = Guid.NewGuid().ToString(); version.VERSIONNO = doc.DFL_VER_LATEST; version.VERSIONSTATUS = type; version.OPERATORUSER = LoginInfo.LoginID; version.OPERATORDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); version.DFL_ID = doc.DFL_ID; version.FILE_NAME = doc.DFL_FILE_NAME; version.Insert(); }
//private void btnCancel_Click(object sender, EventArgs e) //{ // CheckOutCancel(this.tvFileList, DataType.FileType.ProcessFile); //} /// <summary> /// 取消检出 /// </summary> /// <param name="tgv"></param> /// <param name="fileType"></param> private void CheckOutCancel(TreeGridView tgv, DataType.FileType fileType) { int rowIndex = tgv.CurrentCell.RowIndex; if (rowIndex <= 0) { MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataGridViewRow row = tgv.Rows[rowIndex]; String Id = row.Cells["DFL_ID"].Value.ToString(); DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id); if (docFileEntity.CREATEUSER.ToString() != LoginInfo.LoginID.ToString()) { MessageBox.Show("当前不为文件的检出用户,不能进行取消动作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } if (docFileEntity == null) { return; } docFileEntity.CHECKOUTFLG = "N"; docFileEntity.CHECKINFLG = "Y"; docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID; docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); try { docFileEntity.Save(); VersionSave("qx", docFileEntity); MessageBox.Show("文件检出取消成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); return; } finally { } }
public DOC_FILE_LIST GetDocFileEntityByDCID(string dflID) { DOC_FILE_LIST doc = null; DataEntityQuery <DOC_FILE_LIST> query = DataEntityQuery <DOC_FILE_LIST> .Create(); var p = (from item in query where (item.DEL_FLAG == "N") && (item.DFL_ID == dflID) select item); IList <DOC_FILE_LIST> list = p.ToList(); if (list.Count == 0) { } else { doc = list[0]; } return(doc); }
public Boolean delDocFileByDFLID(string dflID) { Boolean result = true; DOC_FILE_LIST file = new DOC_FILE_LIST(); DataEntityQuery<DOC_FILE_LIST> query = DataEntityQuery<DOC_FILE_LIST>.Create(); var p = (from item in query where (item.DFL_ID == dflID) && (item.DEL_FLAG == "N") select item ); file = p.ToList()[0]; if (file == null) { result = false; throw new Exception("改记录不存在"); } else { file.DEL_FLAG = "Y"; file.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); file.LASTUPDATEUSER = LoginInfo.LoginID; try { file.Update(); } catch (Exception ex) { result = false; throw new Exception(ex.Message.ToString()); } finally { } } return result; }
public Boolean delDocFileByDFLID(string dflID) { Boolean result = true; DOC_FILE_LIST file = new DOC_FILE_LIST(); DataEntityQuery <DOC_FILE_LIST> query = DataEntityQuery <DOC_FILE_LIST> .Create(); var p = (from item in query where (item.DFL_ID == dflID) && (item.DEL_FLAG == "N") select item ); file = p.ToList()[0]; if (file == null) { result = false; throw new Exception("改记录不存在"); } else { file.DEL_FLAG = "Y"; file.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); file.LASTUPDATEUSER = LoginInfo.LoginID; try { file.Update(); } catch (Exception ex) { result = false; throw new Exception(ex.Message.ToString()); } finally { } } return(result); }
/// <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(); } } }
/// <summary> /// 检出文件 /// </summary> /// <param name="tgv"></param> /// <param name="fileType"></param> private void CheckOut(TreeGridView tgv, DataType.FileType fileType) { int rowIndex = tgv.CurrentCell.RowIndex; if (rowIndex <= 0) { MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataGridViewRow row = tgv.Rows[rowIndex]; HYDocumentMS.IFileHelper file = new FileHelper(); Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckOut, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString()); if (bl == false) { MessageBox.Show("你没有权限检出此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } String Id = row.Cells["DFL_ID"].Value.ToString(); DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id); // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, ""); if (docFileEntity == null) { return; } if (docFileEntity.CHECKOUTFLG == "Y") { MessageBox.Show("当前文档已被检出,不能再次检出,请等待检出人检入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } HYPDM.WinUI.Document.DetectionForm form = new HYPDM.WinUI.Document.DetectionForm(); form.DocFileEntity = docFileEntity; if (form.ShowDialog() == DialogResult.OK) { if (form.FileServerAckResult) { docFileEntity.CHECKOUTFLG = "Y"; docFileEntity.CHECKINFLG = "N"; docFileEntity.CHECKOUTDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID; docFileEntity.Save(); } else { MessageBox.Show("文件检出失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { VersionSave("0", docFileEntity); MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } finally { // MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
//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(); } } }