Esempio n. 1
0
        /// <summary>
        /// 检入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckIN_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            if (txtFileName.Text.Trim() == string.Empty || txtFilePath.Text.Trim() == string.Empty)
            {
                MessageBox.Show("文件名或文件路径不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //Boolean result = true;
                //Util.FTPHelper helper = Util.Common.FtpHepler();
                //var info = "";
                //var result = helper.UploadFile(txtFilePath.Text, out info);

                try
                {
                    string filePath = this.txtFilePath.Text.ToString();
                    int    i        = filePath.LastIndexOf(@"\");
                    if (i == -1)
                    {
                        i = filePath.LastIndexOf(@"/");
                    }
                    filePath = filePath.Substring(0, i) + @"\" + this.txtFileName.Text.ToString();

                    string tempNewFileName = this.txtFileName.Text.ToString();

                    tempNewFileName = tempNewFileName.Substring(0, tempNewFileName.LastIndexOf(@".")) + DocFileEntity.DFL_VER_LATEST + tempNewFileName.Substring(tempNewFileName.LastIndexOf(@"."));

                    //  MessageBox.Show(filePath);
                    string serPathAndFileName        = new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH) + this.txtFileName.Text.ToString();
                    FileSockClient.CopyOldVerFile hh = new FileSockClient.CopyOldVerFile(serPathAndFileName, tempNewFileName); //复制旧版本数据到Vers目录下
                    if (!hh.AckStatus)
                    {
                        FileServerAckReult = hh.AckStatus;
                        this.DialogResult  = DialogResult.OK;
                        return;
                    }
                    //上传更新文件覆盖旧文件
                    FileSockClient.UpLoadFileSocketClient upload = new FileSockClient.UpLoadFileSocketClient(filePath, new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH), true);
                    if (!upload.AckStatus)
                    {
                        FileServerAckReult = upload.AckStatus;
                        this.DialogResult  = DialogResult.OK;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    FileServerAckReult = false;
                    this.DialogResult  = DialogResult.No;
                    MessageBox.Show(ex.Message.ToString());
                }

                //if (result)
                //{
                //    MessageBox.Show("文件检入成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
                //else
                //{
                //    this.DialogResult = DialogResult.No;
                //    MessageBox.Show("文件检入失败,具体原因为:" + info, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);

                //}
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 检入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckIN_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            if (txtFileName.Text.Trim() == string.Empty || txtFilePath.Text.Trim() == string.Empty)
            {
                MessageBox.Show("文件名或文件路径不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                //Boolean result = true;
                //Util.FTPHelper helper = Util.Common.FtpHepler();
                //var info = "";
                //var result = helper.UploadFile(txtFilePath.Text, out info);

                try
                {
                    string filePath = this.txtFilePath.Text.ToString();
                    int i = filePath.LastIndexOf(@"\");
                    if (i == -1)
                    {
                        i = filePath.LastIndexOf(@"/");
                    }
                    filePath = filePath.Substring(0, i) + @"\" + this.txtFileName.Text.ToString();

                    string tempNewFileName = this.txtFileName.Text.ToString();

                    tempNewFileName = tempNewFileName.Substring(0, tempNewFileName.LastIndexOf(@".")) + DocFileEntity.DFL_VER_LATEST + tempNewFileName.Substring(tempNewFileName.LastIndexOf(@"."));

                    //  MessageBox.Show(filePath);
                    string serPathAndFileName = new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH) + this.txtFileName.Text.ToString();
                    FileSockClient.CopyOldVerFile hh = new FileSockClient.CopyOldVerFile(serPathAndFileName, tempNewFileName); //复制旧版本数据到Vers目录下
                    if (!hh.AckStatus)
                    {
                        FileServerAckReult = hh.AckStatus;
                        this.DialogResult = DialogResult.OK;
                        return;
                    }
                    //上传更新文件覆盖旧文件
                    FileSockClient.UpLoadFileSocketClient upload = new FileSockClient.UpLoadFileSocketClient(filePath, new FileHelper().getDocumentAllPathByPathID(DocFileEntity.DFL_FILE_CHILD_PATH), true);
                    if (!upload.AckStatus)
                    {
                        FileServerAckReult = upload.AckStatus;
                        this.DialogResult = DialogResult.OK;
                        return;
                    }

                }
                catch (Exception ex)
                {
                    FileServerAckReult = false;
                    this.DialogResult = DialogResult.No;
                    MessageBox.Show(ex.Message.ToString());
                }

                //if (result)
                //{
                //    MessageBox.Show("文件检入成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
                //else
                //{
                //    this.DialogResult = DialogResult.No;
                //    MessageBox.Show("文件检入失败,具体原因为:" + info, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);

                //}

            }
        }