private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid   guid             = new Guid();
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(openFileDialog1.FileName))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    guid = Guid.NewGuid();
                    m_serverFileBasic.AddFile(guid, strFtpServerPath + guid.ToString(), fileType);

                    CursorControl.SetWaitCursor(this);
                    m_serverFileBasic.FileUpLoad(openFileDialog1.FileName, strFtpServerPath, guid.ToString(), fileType);
                    this.Cursor = System.Windows.Forms.Cursors.Arrow;

                    if (GetError())
                    {
                        FM_FileList fileInfo = new FM_FileList();

                        fileInfo.DeleteFlag = false;
                        fileInfo.Department = txtDepartment.Tag.ToString();
                        fileInfo.FileName   = txtFileName.Text;
                        fileInfo.FileNo     = txtFileNo.Text;
                        fileInfo.FileUnique = guid;
                        fileInfo.SortID     = Convert.ToInt32(txtSort.Tag);
                        fileInfo.Version    = txtVersion.Text;

                        if (m_serverFileBasic.AddFileList(fileInfo, out m_strErr))
                        {
                            MessageDialog.ShowPromptMessage("上传成功");
                        }
                        else
                        {
                            throw new Exception(m_strErr);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
            }
        }
예제 #2
0
        /// <summary>
        /// 上传文件
        /// </summary>
        string UpdateFile()
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid   guid             = new Guid();
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(openFileDialog1.FileName))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    ConditionUpdateFile(llbFileDownLoad, ref guid, strFtpServerPath, fileType, CE_OperatorMode.添加);

                    CursorControl.SetWaitCursor(this);
                    m_serverFileBasic.FileUpLoad(openFileDialog1.FileName, strFtpServerPath, guid.ToString(), fileType);

                    this.Cursor = System.Windows.Forms.Cursors.Arrow;
                    if (GetError())
                    {
                        MessageDialog.ShowPromptMessage("上传成功");
                        return(guid.ToString());
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 上传文件
        /// </summary>
        string Update(string mode)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Guid   guid             = new Guid();
                    string fileType         = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."));
                    string strFtpServerPath = "/" + ServerTime.Time.Year.ToString() + "/" + ServerTime.Time.Month.ToString() + "/";

                    if (!GlobalObject.FileTypeRecognition.IsWordDocument(openFileDialog1.FileName))
                    {
                        throw new Exception("此文件非正常WORD文件,可能由于文件格式无法识别或者文件加密造成无法上传");
                    }

                    switch (mode)
                    {
                    case "Propoer":

                        if (llbProposerDownLoad.Tag == null || llbProposerDownLoad.Tag.ToString().Trim().Length == 0)
                        {
                            guid = Guid.NewGuid();
                            m_serverFileBasicInfo.AddFile(guid, strFtpServerPath + guid.ToString(), fileType);
                        }
                        else
                        {
                            guid = new Guid(llbProposerDownLoad.Tag.ToString());
                            m_serverFileBasicInfo.UpdateFile(guid, fileType);
                        }
                        break;

                    default:
                        break;
                    }

                    CursorControl.SetWaitCursor(this);

                    m_serverFileBasicInfo.FileUpLoad(openFileDialog1.FileName, strFtpServerPath, guid.ToString(), fileType);

                    this.Cursor = System.Windows.Forms.Cursors.Arrow;

                    if (GetError())
                    {
                        MessageDialog.ShowPromptMessage("上传成功");
                        return(guid.ToString());
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                MessageDialog.ShowErrorMessage(ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Arrow;
                return(null);
            }
        }