/// <summary> /// 通用操作方式 /// </summary> /// <param name="guid">唯一编码</param> void ShowOrDownLoad(string guid) { FM_FilePath lnqTemp = m_serverFileBasicInfo.GetFilePathInfo(new Guid(guid)); 操作方式 frm = new 操作方式(ProcessType.发布); frm.ShowDialog(); if (frm.OperatorFlag == CE_FileOperatorType.在线阅读) { FileOperationService.File_Look(new Guid(guid), GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式])); } else if (frm.OperatorFlag == CE_FileOperatorType.载) { saveFileDialog1.Filter = "All files (*.*)|*.*"; saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-"); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName); if (GetError()) { MessageDialog.ShowPromptMessage("下载成功"); } } } }
/// <summary> /// 下载 /// </summary> void FileDownLoad() { try { saveFileDialog1.Filter = "All files (*.*)|*.*"; saveFileDialog1.FileName = ""; if (m_filePathExternal.Trim().Length == 0) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { m_filePathExternal = saveFileDialog1.FileName; } } if (m_filePathExternal.Trim().Length > 0) { BackgroundWorker worker = BackgroundWorkerTools.GetWorker("下载文件"); worker.RunWorkerAsync(); m_serverFileFtp.Download(m_filePathInternal, m_filePathExternal); worker.CancelAsync(); if (GetError()) { MessageDialog.ShowPromptMessage("下载成功"); } } } catch (Exception ex) { MessageDialog.ShowErrorMessage(ex.Message); this.Cursor = System.Windows.Forms.Cursors.Arrow; } }
private void btnDownLoad_Click(object sender, EventArgs e) { string path = dataGridView1.CurrentRow.Cells["路径"].Value.ToString(); saveFileDialog1.Filter = "All files (*.*)|*.*"; saveFileDialog1.FileName = txtFileName.Text; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { m_serverFTP.Download(path, saveFileDialog1.FileName); if (GetError()) { MessageDialog.ShowPromptMessage("下载成功"); } } }
/// <summary> /// 查看 /// </summary> /// <param name="guid"></param> /// <param name="type"></param> public static void File_Look(Guid guid, CE_CommunicationMode type) { try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.FM_FilePath where a.FileUnique == guid select a; if (varData.Count() == 1) { FM_FilePath tempPath = varData.Single(); string temp = System.Environment.GetEnvironmentVariable("TEMP"); DirectoryInfo info = new DirectoryInfo(temp); string guidFile = (Guid.NewGuid()).ToString() + "\\"; string filePath = info.FullName + "\\" + guidFile + tempPath.FileUnique + tempPath.FileType; if (type == CE_CommunicationMode.Socket) { FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverSocket.Download(varData.Single().FilePath, filePath); } else if (type == CE_CommunicationMode.FTP) { FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverFTP.Download(varData.Single().FilePath, filePath); } System.Diagnostics.Process.Start(filePath); } else { throw new Exception("文件唯一编码重复"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 通用操作方式 /// </summary> /// <param name="guid">唯一编码</param> void ShowOrDownLoad(string guid) { try { FM_FilePath lnqTemp = m_serverFileBasic.GetFilePathInfo(new Guid(guid)); 操作方式 frm = new 操作方式(ProcessType.发布); frm.ShowDialog(); if (frm.OperatorFlag == CE_FileOperatorType.在线阅读) { FileOperationService.File_Look(new Guid(guid), GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式])); } else if (frm.OperatorFlag == CE_FileOperatorType.载) { saveFileDialog1.Filter = "All files (*.*)|*.*"; saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-"); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { BackgroundWorker worker = BackgroundWorkerTools.GetWorker("下载文件"); worker.RunWorkerAsync(); m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName); worker.CancelAsync(); if (GetError()) { MessageDialog.ShowPromptMessage("下载成功"); } } } } catch (Exception ex) { MessageDialog.ShowErrorMessage(ex.Message); this.Cursor = System.Windows.Forms.Cursors.Arrow; return; } }
/// <summary> /// 文件下载 /// </summary> /// <param name="guid">文件唯一编码</param> /// <param name="systemPath">系统路径</param> /// <param name="type">操作文件访问方式</param> public static void File_DownLoad(Guid guid, string systemPath, CE_CommunicationMode type) { try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.FM_FilePath where a.FileUnique == guid select a; if (varData.Count() == 0) { throw new Exception("文件不存在"); } else if (varData.Count() == 1) { if (type == CE_CommunicationMode.Socket) { FileServiceSocket serverSocket = new FileServiceSocket(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverSocket.Download(varData.Single().FilePath, systemPath + varData.Single().FileType); } else if (type == CE_CommunicationMode.FTP) { FileServiceFTP serverFTP = new FileServiceFTP(GlobalObject.GlobalParameter.FTPServerIP, GlobalObject.GlobalParameter.FTPServerAdvancedUser, GlobalObject.GlobalParameter.FTPServerAdvancedPassword); serverFTP.Download(varData.Single().FilePath, systemPath + varData.Single().FileType); } } else { throw new Exception("文件唯一编码重复"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void btnDownLoad_Click(object sender, EventArgs e) { string path = dataGridView1.CurrentRow.Cells["路径"].Value.ToString(); saveFileDialog1.Filter = "All files (*.*)|*.*"; int index = path.LastIndexOf(".") >= 0 ? path.LastIndexOf(".") : 0; saveFileDialog1.FileName = (txtFileName.Text + path.Substring(index)).Replace("/", "-"); //saveFileDialog1.FileName = txtFileName.Text + ".doc"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { m_serverFTP.Download(path, saveFileDialog1.FileName); if (GetError()) { MessageDialog.ShowPromptMessage("下载成功"); } } }
/// <summary> /// 通用操作方式 /// </summary> /// <param name="guid">唯一编码</param> void ShowOrDownLoad(string guid) { try { FM_FilePath lnqTemp = m_serverFileBasicInfo.GetFilePathInfo(new Guid(guid)); 操作方式 frm = new 操作方式(ProcessType.审查); frm.ShowDialog(); if (frm.OperatorFlag == CE_FileOperatorType.在线阅读) { FileOperationService.File_Look(new Guid(guid), GlobalObject.GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.文件传输方式])); } else if (frm.OperatorFlag == CE_FileOperatorType.载) { saveFileDialog1.Filter = "All files (*.*)|*.*"; saveFileDialog1.FileName = (txtFileName.Text + lnqTemp.FileType).Replace("/", "-"); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { BackgroundWorker worker = BackgroundWorkerTools.GetWorker("下载文件"); worker.RunWorkerAsync(); m_serverFTP.Download(lnqTemp.FilePath, saveFileDialog1.FileName); worker.CancelAsync(); if (GetError()) { MessageDialog.ShowPromptMessage("下载成功"); } } } else if (frm.OperatorFlag == CE_FileOperatorType.在线编辑) { string filePath = "C:\\temp" + lnqTemp.FileType; m_serverFTP.Download(lnqTemp.FilePath, filePath); System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); //设置启动进程的初始目录 myProcess.StartInfo.WorkingDirectory = Application.StartupPath; //设置启动进程的应用程序或文档名 myProcess.StartInfo.FileName = filePath; //设置启动进程的参数 myProcess.StartInfo.Arguments = ""; myProcess.Start(); myProcess.WaitForExit(); bool flag = false; Guid guidTemp = new Guid(); string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/"; if (!GlobalObject.FileTypeRecognition.IsWordDocument(filePath)) { throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传"); } if (btnAdd.Visible) { ConditionUpdateFile(llbProposerDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改); flag = true; llbProposerUpLoad.Tag = guidTemp; llbProposerDownLoad.Tag = guidTemp; llbProposerDownLoad.Text = BasicInfo.LoginName + "的文件"; } else if (btnAudit.Visible) { ConditionUpdateFile(llbAuditorDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改); flag = true; llbAuditorUpLoad.Tag = guidTemp; llbAuditorDownLoad.Tag = guidTemp; llbAuditorDownLoad.Text = BasicInfo.LoginName + "的文件"; } else if (btnPointAffirm.Visible) { ConditionUpdateFile(llbPointDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改); flag = true; m_serverReviewProcess.PointUpLoadFile(guidTemp, m_strSDBNo); dataGridView1.DataSource = m_serverReviewProcess.GetListInfoTable(txtSDBNo.Text); PositioningRecord(BasicInfo.LoginID); } else if (btnJudge.Visible) { ConditionUpdateFile(llbJudgeDownLoad, ref guidTemp, strFtpServerPath, lnqTemp.FileType, CE_OperatorMode.修改); flag = true; llbJudgeUpLoad.Tag = guidTemp; llbJudgeDownLoad.Tag = guidTemp; llbJudgeDownLoad.Text = BasicInfo.LoginName + "的文件"; } if (flag) { CursorControl.SetWaitCursor(this); m_serverFileBasicInfo.FileUpLoad(filePath, strFtpServerPath, guidTemp.ToString(), lnqTemp.FileType); this.Cursor = System.Windows.Forms.Cursors.Arrow; } File.Delete(filePath); } } catch (Exception ex) { MessageDialog.ShowErrorMessage(ex.Message); this.Cursor = System.Windows.Forms.Cursors.Arrow; return; } }