------ #### SuperDesign V3.0.2412.2001 - *.[新增]新增程序更新日志设置和自动发布功能。 - *.[修复]修复Post数据格式不正确时双击文本框会导致软件闪退的BUG。
83 lines
2.8 KiB
C#
83 lines
2.8 KiB
C#
using ExtendUI.FTPManager;
|
|
using FTPop;
|
|
using ryCommon;
|
|
using ryCommonDb;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace SuperDesign.Manager.FTP
|
|
{
|
|
public partial class FrmUploadUpdateZipToFtp : Form
|
|
{
|
|
public FrmUploadUpdateZipToFtp()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public string LocalPath { get; set; } = "";
|
|
public string EngName { get; set; } = "";
|
|
public int FTPId { get; set; } = 0;
|
|
public string RemoteDir { get; set; } = "";
|
|
private void BtnUploadZSB_Click(object sender, EventArgs e)
|
|
{
|
|
Upload(EngName+".zip");
|
|
}
|
|
private void Upload(string filename)
|
|
{
|
|
BtnUploadZSB.Enabled = false;
|
|
BtnUploadBeta.Enabled = false;
|
|
new Thread(Start).Start();
|
|
void Start()
|
|
{
|
|
var isUpload_ok = 0;
|
|
FTPUI ftp_ui = new FTPUI(new SQLiteDataProvider(), Application.StartupPath + "\\UserDb\\Ftp.dat");
|
|
var ftp_info = ftp_ui.GetFTPInfo(FTPId);
|
|
IFTP ftp = new FTPWinSCP();
|
|
ftp.FileTransferProgress += Session_FileTransferProgress;
|
|
var opened = ftp.Open(ftp_info);
|
|
if (opened == 1)
|
|
{
|
|
if(ftp.Upload(LocalPath, RemoteDir + "/" + filename)!=1)
|
|
{
|
|
MessageBox.Show("本地目录:"+ LocalPath + "\r\n远程目录:"+ RemoteDir + "/" + filename+"\r\n"+ftp.LastError,"出错",MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
else { isUpload_ok = 1; }
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("连接FTP出错=>" + ftp.LastError, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
ftp.Close();
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
BtnUploadZSB.Enabled = true;
|
|
BtnUploadBeta.Enabled = true;
|
|
if(isUpload_ok==1)
|
|
{
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
private void Session_FileTransferProgress(object sender, FTPop.FileTransferProgressEventArgs e)
|
|
{
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
progressBar1.Value = (e.FileProgress*100).ToInt(0, 100, 100);
|
|
}));
|
|
}
|
|
|
|
private void BtnUploadBeta_Click(object sender, EventArgs e)
|
|
{
|
|
Upload(EngName + "_beta.zip");
|
|
}
|
|
}
|
|
}
|