代码细节优化,网络组件文件下载支持下载到stream,v1.5.4
This commit is contained in:
@@ -19,6 +19,8 @@ namespace ClientsLibrary.FileSupport
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class FileOperateControl : UserControl
|
public partial class FileOperateControl : UserControl
|
||||||
{
|
{
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传的实例化方法
|
/// 上传的实例化方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,6 +40,7 @@ namespace ClientsLibrary.FileSupport
|
|||||||
AdvancedFileClient = advancedFile;
|
AdvancedFileClient = advancedFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载的实例化方法
|
/// 下载的实例化方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -61,6 +64,10 @@ namespace ClientsLibrary.FileSupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Load Close
|
||||||
|
|
||||||
private void FileOperateControl_Load(object sender, EventArgs e)
|
private void FileOperateControl_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
label_filename.Text = FilePath;
|
label_filename.Text = FilePath;
|
||||||
@@ -78,36 +85,22 @@ namespace ClientsLibrary.FileSupport
|
|||||||
button1.Text = "重新上传文件";
|
button1.Text = "重新上传文件";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Property
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指示本次上传或是下载是否结束
|
/// 指示本次上传或是下载是否结束
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsOperateFinished { get; set; } = false;
|
public bool IsOperateFinished { get; set; } = false;
|
||||||
|
|
||||||
|
|
||||||
private bool Is_down_file { get; set; } = true;
|
#endregion
|
||||||
/// <summary>
|
|
||||||
/// 文件的原始路径
|
|
||||||
/// </summary>
|
|
||||||
private string FilePath { get; set; } = "";
|
|
||||||
/// <summary>
|
|
||||||
/// 文件所属的工厂分类
|
|
||||||
/// </summary>
|
|
||||||
private string Factory { get; set; } = "";
|
|
||||||
/// <summary>
|
|
||||||
/// 文件所属的类别
|
|
||||||
/// </summary>
|
|
||||||
private string Group { get; set; } = "";
|
|
||||||
/// <summary>
|
|
||||||
/// 文件所属的特殊ID
|
|
||||||
/// </summary>
|
|
||||||
private string Id { get; set; } = "";
|
|
||||||
/// <summary>
|
|
||||||
/// 文件保存的路径,文件下载的时候所需的
|
|
||||||
/// </summary>
|
|
||||||
private string SavaPathDirectory { get; set; } = "";
|
|
||||||
|
|
||||||
|
|
||||||
|
#region Upload Support
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始上传文件
|
/// 开始上传文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -133,27 +126,6 @@ namespace ClientsLibrary.FileSupport
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WrongTextShow(string text)
|
|
||||||
{
|
|
||||||
if (IsHandleCreated && InvokeRequired)
|
|
||||||
{
|
|
||||||
Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
WrongTextShow(text);
|
|
||||||
}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
label_now_info.Text = text;
|
|
||||||
button1.Visible = true;
|
|
||||||
IsOperateFinished = true;
|
|
||||||
progressBar1.Value = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
IntegrationFileClient AdvancedFileClient = null;
|
|
||||||
|
|
||||||
private void ThreadUploadFile()
|
private void ThreadUploadFile()
|
||||||
{
|
{
|
||||||
FileInfo finfo = new FileInfo(FilePath);
|
FileInfo finfo = new FileInfo(FilePath);
|
||||||
@@ -175,7 +147,7 @@ namespace ClientsLibrary.FileSupport
|
|||||||
UserClient.UserAccount.UserName,
|
UserClient.UserAccount.UserName,
|
||||||
ReportProgress);
|
ReportProgress);
|
||||||
|
|
||||||
if(result.IsSuccess)
|
if (result.IsSuccess)
|
||||||
{
|
{
|
||||||
Invoke(new Action(() =>
|
Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
@@ -189,6 +161,33 @@ namespace ClientsLibrary.FileSupport
|
|||||||
|
|
||||||
IsOperateFinished = true;
|
IsOperateFinished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Foundation Methon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void WrongTextShow(string text)
|
||||||
|
{
|
||||||
|
if (IsHandleCreated && InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
WrongTextShow(text);
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
label_now_info.Text = text;
|
||||||
|
button1.Visible = true;
|
||||||
|
IsOperateFinished = true;
|
||||||
|
progressBar1.Value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(object sender, EventArgs e)
|
||||||
@@ -225,6 +224,9 @@ namespace ClientsLibrary.FileSupport
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Download Support
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -279,10 +281,29 @@ namespace ClientsLibrary.FileSupport
|
|||||||
IsOperateFinished = true;
|
IsOperateFinished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Paint Support
|
||||||
|
|
||||||
|
|
||||||
private void FileOperateControl_Paint(object sender, PaintEventArgs e)
|
private void FileOperateControl_Paint(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
// 绘制外观
|
// 绘制外观
|
||||||
e.Graphics.DrawRectangle(Pens.DodgerBlue, new Rectangle(0, 0, Width - 1, Height - 1));
|
e.Graphics.DrawRectangle(Pens.DodgerBlue, new Rectangle(0, 0, Width - 1, Height - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Member
|
||||||
|
private IntegrationFileClient AdvancedFileClient; // 支持文件操作的
|
||||||
|
private bool Is_down_file = true; // 文件是否在下载
|
||||||
|
private string FilePath = ""; // 文件路径
|
||||||
|
private string Factory = ""; // 文件所属的工厂分类
|
||||||
|
private string Group = ""; // 文件所属的类别
|
||||||
|
private string Id = ""; // 文件所属的特殊ID
|
||||||
|
private string SavaPathDirectory = ""; // 文件保存的路径,文件下载的时候所需的
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace CommonLibrary
|
|||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
SoftBasic.FrameworkVersion = new SystemVersion("1.5.3");
|
SoftBasic.FrameworkVersion = new SystemVersion("1.5.4");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2181,6 +2181,18 @@
|
|||||||
<param name="fileSaveName">准备本地保存的名称</param>
|
<param name="fileSaveName">准备本地保存的名称</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:HslCommunication.Enthernet.IntegrationFileClient.DownloadFile(System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64},System.IO.Stream)">
|
||||||
|
<summary>
|
||||||
|
下载服务器的文件到本地的数据流中
|
||||||
|
</summary>
|
||||||
|
<param name="fileName">文件名称,带后缀</param>
|
||||||
|
<param name="factory">第一大类</param>
|
||||||
|
<param name="group">第二大类</param>
|
||||||
|
<param name="id">第三大类</param>
|
||||||
|
<param name="processReport">下载的进度报告</param>
|
||||||
|
<param name="stream">流数据</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})">
|
<member name="M:HslCommunication.Enthernet.IntegrationFileClient.UploadFile(System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Action{System.Int64,System.Int64})">
|
||||||
<summary>
|
<summary>
|
||||||
上传本地的文件到服务器操作
|
上传本地的文件到服务器操作
|
||||||
@@ -3583,7 +3595,7 @@
|
|||||||
<exception cref="T:System.ObjectDisposedException"></exception>
|
<exception cref="T:System.ObjectDisposedException"></exception>
|
||||||
<exception cref="T:System.Security.SecurityException"></exception>
|
<exception cref="T:System.Security.SecurityException"></exception>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:HslCommunication.NetSupport.WriteStreamFromSocket(System.Net.Sockets.Socket,System.IO.FileStream,System.Int64,System.Action{System.Int64,System.Int64},System.Boolean)">
|
<member name="M:HslCommunication.NetSupport.WriteStreamFromSocket(System.Net.Sockets.Socket,System.IO.Stream,System.Int64,System.Action{System.Int64,System.Int64},System.Boolean)">
|
||||||
<summary>
|
<summary>
|
||||||
从socket套接字读取数据并写入流中,必然报告进度
|
从socket套接字读取数据并写入流中,必然报告进度
|
||||||
</summary>
|
</summary>
|
||||||
@@ -3953,6 +3965,19 @@
|
|||||||
<param name="failedString">失败时记录日志的字符串</param>
|
<param name="failedString">失败时记录日志的字符串</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:HslCommunication.NetShareBase.ReceiveFileHeadFromSocket(System.Net.Sockets.Socket,System.String@,System.Int64@,System.String@,System.String@,HslCommunication.OperateResult,System.String)">
|
||||||
|
<summary>
|
||||||
|
[自校验] 从套接字中接收文件头信息
|
||||||
|
</summary>
|
||||||
|
<param name="socket"></param>
|
||||||
|
<param name="filename"></param>
|
||||||
|
<param name="size"></param>
|
||||||
|
<param name="filetag"></param>
|
||||||
|
<param name="fileupload"></param>
|
||||||
|
<param name="result"></param>
|
||||||
|
<param name="failedString"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:HslCommunication.NetShareBase.ReceiveFileFromSocket(System.Net.Sockets.Socket,System.String,System.String@,System.Int64@,System.String@,System.String@,HslCommunication.OperateResult,System.Action{System.Int64,System.Int64},System.String)">
|
<member name="M:HslCommunication.NetShareBase.ReceiveFileFromSocket(System.Net.Sockets.Socket,System.String,System.String@,System.Int64@,System.String@,System.String@,HslCommunication.OperateResult,System.Action{System.Int64,System.Int64},System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
[自校验] 从网络中接收一个文件,如果结果异常,则结束通讯
|
[自校验] 从网络中接收一个文件,如果结果异常,则结束通讯
|
||||||
@@ -3968,6 +3993,21 @@
|
|||||||
<param name="failedString">失败时的记录日志字符串</param>
|
<param name="failedString">失败时的记录日志字符串</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:HslCommunication.NetShareBase.ReceiveFileFromSocket(System.Net.Sockets.Socket,System.IO.Stream,System.String@,System.Int64@,System.String@,System.String@,HslCommunication.OperateResult,System.Action{System.Int64,System.Int64},System.String)">
|
||||||
|
<summary>
|
||||||
|
[自校验] 从网络中接收一个文件,写入数据流,如果结果异常,则结束通讯
|
||||||
|
</summary>
|
||||||
|
<param name="socket">网络套接字</param>
|
||||||
|
<param name="stream">等待写入的数据流</param>
|
||||||
|
<param name="filename">文件在对方电脑上的文件名</param>
|
||||||
|
<param name="size">文件大小</param>
|
||||||
|
<param name="filetag">文件的标识</param>
|
||||||
|
<param name="fileupload">文件的上传人</param>
|
||||||
|
<param name="result">结果信息对象</param>
|
||||||
|
<param name="receiveReport">接收进度报告</param>
|
||||||
|
<param name="failedString">失败时的记录日志字符串</param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:HslCommunication.NetShareBase.DeleteFileByName(System.String)">
|
<member name="M:HslCommunication.NetShareBase.DeleteFileByName(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
删除文件的操作
|
删除文件的操作
|
||||||
|
|||||||
Reference in New Issue
Block a user