/// <summary>
        /// 按条件上传文件
        /// </summary>
        /// <param name="linklb">LinkLabel空间</param>
        /// <param name="guid">序号</param>
        /// <param name="ftpServerPath">文件路径</param>
        /// <param name="fileType">文件类型</param>
        /// <param name="mode">操作模式</param>
        void ConditionUpdateFile(LinkLabel linklb, ref Guid guid, string ftpServerPath, string fileType, CE_OperatorMode mode)
        {
            if (linklb.Tag == null || linklb.Tag.ToString().Trim().Length == 0)
            {
                guid = Guid.NewGuid();
                m_serverFileBasicInfo.AddFile(guid, ftpServerPath + guid.ToString(), fileType);
            }
            else
            {
                guid = new Guid(linklb.Tag.ToString());

                if (mode == CE_OperatorMode.添加)
                {
                    m_serverFileBasicInfo.UpdateFile(guid, fileType);
                }
            }
        }
예제 #2
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);
            }
        }