/// <summary> /// 修改属性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { try { FileBll fileBll = new FileBll(); Model.FileModel fileModel = fileBll.GetModel(this.file.ID); if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name)) { MessageBoxEx.Show("该文件的信息异常!"); return; } FileVersionBll verBll = new FileVersionBll(); var fileVer = new BLL.FileVersionBll().GetModel(this.fileLog.FileVerID); var content = verBll.GetContent(fileVer.ID); // 获取文件信息 this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);; this.saveFileDialog1.ShowDialog(); string fileSavePath = this.saveFileDialog1.FileName; if (string.IsNullOrEmpty(fileSavePath)) { return; } //文件存放路径 string newPath = fileSavePath.EndsWith(fileModel.File_Ext) ? fileSavePath : fileSavePath + fileModel.File_Ext; FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time); MessageBoxEx.Show("保存成功!"); } catch (Exception ee) { this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("存储失败!" + ee.Message); } }
/// <summary> /// 版本历史记录单元格事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void skinDataGridView_history_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 80) { try { #region 文件下载和同步处理 int fileID = int.Parse(this.skinDataGridView_history.Rows[e.RowIndex].Cells[10].Value.ToString()); int verID = int.Parse(this.skinDataGridView_history.Rows[e.RowIndex].Cells[0].Value.ToString()); FileBll fileBll = new FileBll(); Model.FileModel fileModel = fileBll.GetModel(fileID); if (fileModel == null || string.IsNullOrEmpty(fileModel.File_Name)) { MessageBoxEx.Show("该文件的信息异常!"); return; } FileVersionBll verBll = new FileVersionBll(); var content = verBll.GetContent(verID); var fileVer = verBll.GetModel(verID); //同步 if (e.ColumnIndex == 8) { if (string.IsNullOrEmpty(fileModel.ClientPath)) { MessageBoxEx.Show("该文件的客户端路径不正确!"); return; } FileWinexploer.CreateFile(content, fileModel.ClientPath, fileVer.File_Modify_Time); MessageBoxEx.Show("同步到客户端成功!"); return; } //另存为 if (e.ColumnIndex == 9) { //获取文件信息 this.saveFileDialog1.Filter = string.Format("*{0}|*.*", fileModel.File_Ext);; this.saveFileDialog1.ShowDialog(); string fileSavePath = this.saveFileDialog1.FileName; if (string.IsNullOrEmpty(fileSavePath)) { return; } //文件存放路径 string newPath = fileSavePath.EndsWith(fileModel.File_Ext)?fileSavePath: fileSavePath + fileModel.File_Ext; FileWinexploer.CreateFile(content, newPath, fileVer.File_Modify_Time); } #endregion } catch (Exception ex) { MessageBoxEx.Show(ex.Message); } } }