示例#1
0
        /// <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>
        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;
            }
        }