基线 SVN r240

SVN-Revision: r240
This commit is contained in:
cyf
2025-02-06 06:46:06 +00:00
commit ab56a9bcf7
5317 changed files with 902274 additions and 0 deletions
@@ -0,0 +1,100 @@
/******************************
* 说明:下载Scoket通讯
* 创建人:龚宇超
* 创建日期:2018-01-23
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lskj.SocketService;
namespace Lskj.SocketClient
{
public class ClientDownLoadSocket : ClientBaseSocket
{
public ClientDownLoadSocket()
: base()
{
_protocolFlag = ProtocolFlag.Download;
}
public bool DoDownLoad(string dirName, string fileName, ref long fileSize)
{
bool bConnect = ReConnectAndLogin(); //检测连接是否还在,如果断开则重连并登录
if (!bConnect)
return bConnect;
try
{
_outgoingDataAssembler.Clear();
_outgoingDataAssembler.AddRequest();
_outgoingDataAssembler.AddCommand(ProtocolKey.Download);
_outgoingDataAssembler.AddValue(ProtocolKey.DirName, dirName);
_outgoingDataAssembler.AddValue(ProtocolKey.FileName, fileName);
SendCommand();
bool bSuccess = RecvCommand();
if (bSuccess)
{
bSuccess = CheckErrorCode();
if (bSuccess)
{
bSuccess = _incomingDataParser.GetValue(ProtocolKey.FileSize, ref fileSize);
}
return bSuccess;
}
else
return false;
}
catch (Exception E)
{
//记录日志
_errorString = E.Message;
return false;
}
}
public bool DoData(byte[] buffer, int offset, int count)
{
try
{
_outgoingDataAssembler.Clear();
_outgoingDataAssembler.AddRequest();
_outgoingDataAssembler.AddCommand(ProtocolKey.Data);
SendCommand(buffer, offset, count);
return true;
}
catch (Exception E)
{
//记录日志
_errorString = E.Message;
return false;
}
}
public bool DoEof(Int64 fileSize)
{
try
{
_outgoingDataAssembler.Clear();
_outgoingDataAssembler.AddRequest();
_outgoingDataAssembler.AddCommand(ProtocolKey.Eof);
SendCommand();
bool bSuccess = RecvCommand();
if (bSuccess)
return CheckErrorCode();
else
return false;
}
catch (Exception E)
{
//记录日志
_errorString = E.Message;
return false;
}
}
}
}