基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
/******************************
|
||||
* 说明:附件上传下载入口类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-01-22
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Lskj.Control;
|
||||
|
||||
namespace Lskj.Attach.Client.Model
|
||||
{
|
||||
public class ClientManager
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>说明:初始化上传下载窗口</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="args">The arguments.</param>
|
||||
public static void InitForm(string[] args)
|
||||
{
|
||||
string param = args[0].Replace("^^", " ");
|
||||
|
||||
ParamFormatter.ParseParams(param);
|
||||
|
||||
if (!ParamFormatter.ParseResult)
|
||||
{
|
||||
MessageUtil.Show("无效参数,请检查." + args);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/******************************
|
||||
* 说明:Window消息
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-01-22
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.Attach.Client.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Window消息
|
||||
/// </summary>
|
||||
internal struct CustomWinMsg
|
||||
{
|
||||
private static readonly int CUSTOM_MESSAGE;
|
||||
public static readonly int SUCCESS_MESSAGE;
|
||||
public static readonly int FAIL_MESSAGE;
|
||||
public static readonly int SETPROGRESS;
|
||||
public static readonly int CLOSE_WINDOW;
|
||||
public static readonly int NOTIFY_READY;
|
||||
public static readonly int CONNECT_ERROR;
|
||||
public static readonly int DELETEFILE_MESSAGE;
|
||||
public static readonly int READYTOCLOSE;
|
||||
public static readonly int BATCHUPLOADCOMPLETED;
|
||||
|
||||
static CustomWinMsg()
|
||||
{
|
||||
CUSTOM_MESSAGE = 36864;
|
||||
SUCCESS_MESSAGE = CUSTOM_MESSAGE + 1;
|
||||
FAIL_MESSAGE = CUSTOM_MESSAGE + 2;
|
||||
SETPROGRESS = CUSTOM_MESSAGE + 3;
|
||||
CLOSE_WINDOW = CUSTOM_MESSAGE + 4;
|
||||
NOTIFY_READY = CUSTOM_MESSAGE + 5;
|
||||
CONNECT_ERROR = CUSTOM_MESSAGE + 6;
|
||||
DELETEFILE_MESSAGE = CUSTOM_MESSAGE + 7;
|
||||
READYTOCLOSE = CUSTOM_MESSAGE + 8;
|
||||
BATCHUPLOADCOMPLETED = CUSTOM_MESSAGE + 9;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Lskj.Control;
|
||||
|
||||
namespace Lskj.Attach.Client.Model
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 1)]
|
||||
internal struct GlobalVariable
|
||||
{
|
||||
public static uint UserId;
|
||||
public static bool NeedExit;
|
||||
public static object MutexObj;
|
||||
public static Timer TimerObj;
|
||||
public static Thread ThreadObj;
|
||||
public static IntPtr WndMain;
|
||||
public static BaseForm BaseFormObj;
|
||||
public static AutoResetEvent NotifyEvent;
|
||||
|
||||
static GlobalVariable()
|
||||
{
|
||||
TimerObj = null;
|
||||
ThreadObj = null;
|
||||
NeedExit = false;
|
||||
MutexObj = 1;
|
||||
UserId = 0;
|
||||
WndMain = IntPtr.Zero;
|
||||
BaseFormObj = null;
|
||||
NotifyEvent = new AutoResetEvent(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/******************************
|
||||
* 说明:参数处理类
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-01-22
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Lskj.Control.Model;
|
||||
using Lskj.Util;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.Attach.Client.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数处理类
|
||||
/// </summary>
|
||||
internal struct ParamFormatter
|
||||
{
|
||||
private static Dictionary<string, string> _dataDic = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// 参数处理结果(成功与否)
|
||||
/// </summary>
|
||||
public static bool ParseResult;
|
||||
/// <summary>
|
||||
/// 传入参数个数
|
||||
/// </summary>
|
||||
/// <value>The parameter count.</value>
|
||||
public static int ParamCount { get; private set; }
|
||||
/// <summary>
|
||||
/// 附件目录ID
|
||||
/// </summary>
|
||||
/// <value>The directory identifier.</value>
|
||||
public static int DirectoryId
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
Convert.ToInt32(_dataDic["directoryId"]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件前缀
|
||||
/// </summary>
|
||||
/// <value>The file number.</value>
|
||||
public static string FileNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataDic["fileNumber"];
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件路径
|
||||
/// </summary>
|
||||
/// <value>The file path.</value>
|
||||
public static string FilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataDic["filePath"];
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件编号
|
||||
/// </summary>
|
||||
/// <value>The species no.</value>
|
||||
public static string SpeciesNo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataDic["SpeciesNo"];
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件下载路径
|
||||
/// </summary>
|
||||
/// <value>Down load path.</value>
|
||||
public static string DownLoadPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dataDic["downloadPath"].Replace('*', ' ');
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件下载存放路径
|
||||
/// </summary>
|
||||
/// <value>The save local path.</value>
|
||||
public static string SaveLocalPath
|
||||
{
|
||||
get { return PubUtil.FileDownLoadTempPath + Path.GetFileName(DownLoadPath); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件操作类型
|
||||
/// </summary>
|
||||
/// <value>The type of the attach.</value>
|
||||
public static AttachType AttachType
|
||||
{
|
||||
get
|
||||
{
|
||||
return (AttachType)Convert.ToInt32(_dataDic["type"]);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 附件ID集合
|
||||
/// </summary>
|
||||
/// <value>The file ids.</value>
|
||||
public static int[] FileIds
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] strArray = _dataDic["fileIds"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int[] numArray = new int[strArray.Length];
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
numArray[i] = int.Parse(strArray[i]);
|
||||
}
|
||||
return numArray;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 消息句柄
|
||||
/// </summary>
|
||||
/// <value>The handler.</value>
|
||||
public static IntPtr Handler
|
||||
{
|
||||
get
|
||||
{
|
||||
return new IntPtr(int.Parse(_dataDic["mainHandle"]));
|
||||
}
|
||||
}
|
||||
|
||||
static ParamFormatter()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:处理参数</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="args">The arguments.</param>
|
||||
public static void ParseParams(string args)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] strArray = args.Split(new char[] { '|', '=' }, StringSplitOptions.None);
|
||||
if (strArray.Length <= 2) return;
|
||||
if ("paramsCount" != strArray[0]) return;
|
||||
|
||||
ParamCount = Convert.ToInt32(strArray[1]);
|
||||
|
||||
for (int i = 2; i < (strArray.Length - 1); i += 2)
|
||||
{
|
||||
_dataDic.Add(strArray[i], strArray[i + 1]);
|
||||
}
|
||||
if (_dataDic.Count != ParamCount) return;
|
||||
|
||||
ParseResult = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/******************************
|
||||
* 说明:Socket客户端
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-01-22
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
******************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Lskj.AttachStart.Service;
|
||||
using Lskj.Util;
|
||||
using System.Data;
|
||||
using Lskj.Model;
|
||||
using Lskj.Core;
|
||||
using System.Threading;
|
||||
|
||||
namespace Lskj.Attach.Client.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SocketClient.
|
||||
/// </summary>
|
||||
public class SocketClient
|
||||
{
|
||||
private LSSocket _socket;
|
||||
/// <summary>
|
||||
/// Socket对象
|
||||
/// </summary>
|
||||
/// <value>The socket object.</value>
|
||||
public LSSocket SocketObj { get { return this._socket; } }
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:检查Socket状态</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
public bool CheckSocketState()
|
||||
{
|
||||
return this._socket != null && this._socket.SocketState == 1;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:连接Socket服务器</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void ConnectServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
string port = DBConfig.Instance.Internet ? SystemInfo.Instance.InternetPort : SystemInfo.Instance.LanPort;
|
||||
string ip = DBConfig.Instance.Internet ? SystemInfo.Instance.InternetIp : SystemInfo.Instance.LanIp;
|
||||
if(string.IsNullOrEmpty(port))port ="7859";
|
||||
|
||||
LogHelper.Instance.WriteLog(string.Format("准备连接服务器:{0}", ip + ":" + port));
|
||||
|
||||
this._socket = new LSSocket();
|
||||
this._socket.Connect(ip, uint.Parse(port));
|
||||
this._socket.ParseReceiveDataEvent += new LSSocket.ParseReceiveDataEventHandle(_socket_ParseReceiveDataEvent);
|
||||
this._socket.SocketCloseEvent += new LSASyncSocket.SocketCloseEventHandle(_socket_SocketCloseEvent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:释放所有资源</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void FreeAllResources()
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
GlobalVariable.NeedExit = true;
|
||||
Thread.Sleep(1000);
|
||||
GlobalVariable.ThreadObj.Interrupt();
|
||||
LSFileManage.dispose();
|
||||
}
|
||||
public void OnHeardTimer()
|
||||
{
|
||||
S2C2S_Heart structObj = new S2C2S_Heart(true);
|
||||
this._socket.Send(structObj);
|
||||
}
|
||||
public void ProcessRevDataFromServer()
|
||||
{
|
||||
Thread.CurrentThread.IsBackground = true;
|
||||
LSSocketRev socketRev = null;
|
||||
while (!GlobalVariable.bNeedExit)
|
||||
{
|
||||
Exception exception;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
socketRev = LSQueueManage.GetSocketRevData();
|
||||
LSWriteLog.WriteTrace("------------------ProcessRevDataFromServer----已经获取到列表数据", new object[0]);
|
||||
if (GlobalVariable.bNeedExit)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception exception1)
|
||||
{
|
||||
exception = exception1;
|
||||
PubUtils.WriteLog("ProcessRevDataFromServer 前面的 error: {0}", new object[] { exception.Message.ToString() });
|
||||
throw new Exception(exception.Message.ToString());
|
||||
}
|
||||
GlobalVariable.BaseFormObj.ParseDataFromServerMsg(socketRev);
|
||||
}
|
||||
catch (ThreadAbortException exception2)
|
||||
{
|
||||
PubUtils.WriteLog("ProcessRevDataFromServer ThreadAbortException: {0}", new object[] { exception2 });
|
||||
break;
|
||||
}
|
||||
catch (ThreadInterruptedException exception3)
|
||||
{
|
||||
PubUtils.WriteLog("ProcessRevDataFromServer ThreadInterruptedException: {0}", new object[] { exception3 });
|
||||
break;
|
||||
}
|
||||
catch (Exception exception6)
|
||||
{
|
||||
exception = exception6;
|
||||
if (socketRev != null)
|
||||
{
|
||||
PubUtils.WriteLog("ProcessRevDataFromServer error: {0},ProxySocket.SocketState: {1} ,byte data is:\n{2}", new object[] { exception, socketRev.ClientSocket.SocketState, socketRev.ByteData });
|
||||
}
|
||||
else
|
||||
{
|
||||
PubUtils.WriteLog("ProcessRevDataFromServer error: {0}", new object[] { exception });
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (socketRev != null)
|
||||
{
|
||||
socketRev = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:Scoket关闭</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="AsyncSocket">The asynchronous socket.</param>
|
||||
private void _socket_SocketCloseEvent(LSASyncSocket AsyncSocket)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:Socket接收到数据触发</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-01-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="ProxySocket">The proxy socket.</param>
|
||||
/// <param name="byteData">The byte data.</param>
|
||||
private void _socket_ParseReceiveDataEvent(LSSocket ProxySocket, byte[] byteData)
|
||||
{
|
||||
LSSocketRev socketRev = new LSSocketRev
|
||||
{
|
||||
ClientSocket = ProxySocket,
|
||||
ByteData = byteData
|
||||
};
|
||||
LSQueueManage.InsertSocketRevData(socketRev);
|
||||
LogHelper.Instance.WriteLog("OnRevServerSocketData 插入列表数据执行完毕.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F87EF28F-21C1-4D2D-8045-0B3A5C8F1D8E}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Lskj.Attach</RootNamespace>
|
||||
<AssemblyName>Lskj.Attach</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Client\Model\ClientManager.cs" />
|
||||
<Compile Include="Client\Model\CustomWinMsg.cs" />
|
||||
<Compile Include="Client\Model\GlobalVariable.cs" />
|
||||
<Compile Include="Client\Model\ParamFormatter.cs" />
|
||||
<Compile Include="Client\Model\SocketClient.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Service\C2S2C_BackgroundFileData.cs" />
|
||||
<Compile Include="Service\C2S2C_FileData.cs" />
|
||||
<Compile Include="Service\C2S2C_FileTranslateComplete.cs" />
|
||||
<Compile Include="Service\C2S2C_SmartResponse.cs" />
|
||||
<Compile Include="Service\C2S_AddFile.cs" />
|
||||
<Compile Include="Service\C2S_AddFileDirectory.cs" />
|
||||
<Compile Include="Service\C2S_DeleteFile.cs" />
|
||||
<Compile Include="Service\C2S_DownloadFile.cs" />
|
||||
<Compile Include="Service\C2S_EditFileDirectory.cs" />
|
||||
<Compile Include="Service\C2S_RemoveFileDirectory.cs" />
|
||||
<Compile Include="Service\C2S_ReqBackgroundDownload.cs" />
|
||||
<Compile Include="Service\C2S_ReqestFileList.cs" />
|
||||
<Compile Include="Service\C2S_SmartClientLogin.cs" />
|
||||
<Compile Include="Service\ErrorType.cs" />
|
||||
<Compile Include="Service\LSASyncSocket.cs" />
|
||||
<Compile Include="Service\LSDBManage.cs" />
|
||||
<Compile Include="Service\LSErrorManage.cs" />
|
||||
<Compile Include="Service\LSFileData.cs" />
|
||||
<Compile Include="Service\LSFileManage.cs" />
|
||||
<Compile Include="Service\LSIniFile.cs" />
|
||||
<Compile Include="Service\LSProtocol.cs" />
|
||||
<Compile Include="Service\LSQueueManage.cs" />
|
||||
<Compile Include="Service\LSSocket.cs" />
|
||||
<Compile Include="Service\LSSocketRev.cs" />
|
||||
<Compile Include="Service\MsgHeader.cs" />
|
||||
<Compile Include="Service\PubUtils.cs" />
|
||||
<Compile Include="Service\S2C2S_Heart.cs" />
|
||||
<Compile Include="Service\S2C_AddFile.cs" />
|
||||
<Compile Include="Service\S2C_AddFileDirectory.cs" />
|
||||
<Compile Include="Service\S2C_DeleteFile.cs" />
|
||||
<Compile Include="Service\S2C_DownloadFile.cs" />
|
||||
<Compile Include="Service\S2C_EditFileDirectory.cs" />
|
||||
<Compile Include="Service\S2C_RemoveFileDirectory.cs" />
|
||||
<Compile Include="Service\S2C_ReqBackgroundDownload.cs" />
|
||||
<Compile Include="Service\S2C_ReqestFileList.cs" />
|
||||
<Compile Include="Service\S2C_ReqUpdateFile.cs" />
|
||||
<Compile Include="Service\StructDirectoryInfo.cs" />
|
||||
<Compile Include="Service\StructFileInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Lskj.Business\Lskj.Business.csproj">
|
||||
<Project>{7EAFCCC2-A18F-49E9-85C6-A984966CFD01}</Project>
|
||||
<Name>Lskj.Business</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Control\Lskj.Control.csproj">
|
||||
<Project>{447CDC40-659F-4CCA-9ED6-8E818B4CF8BF}</Project>
|
||||
<Name>Lskj.Control</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Core\Lskj.Core.csproj">
|
||||
<Project>{2A1BE6AC-1077-491B-A754-C5822FE8121E}</Project>
|
||||
<Name>Lskj.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Data\Lskj.Data.csproj">
|
||||
<Project>{308B9B18-9BE2-495C-9C64-EED81D567813}</Project>
|
||||
<Name>Lskj.Data</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Model\Lskj.Model.csproj">
|
||||
<Project>{52BC40E0-C0C6-4F78-996B-CAE028D209CA}</Project>
|
||||
<Name>Lskj.Model</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Lskj.Util\Lskj.Util.csproj">
|
||||
<Project>{A51BF642-6543-4DE3-8948-83F558B72BD4}</Project>
|
||||
<Name>Lskj.Util</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.AttachStart
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
// 特性集控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Lskj.AttachStart")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("Lskj.AttachStart")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
||||
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
|
||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("dd8ed8f4-0afc-417b-8985-31a003bcfb32")]
|
||||
|
||||
// 程序集的版本信息由下面四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 内部版本号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.18408
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Lskj.Attach.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Lskj.Attach.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.18408
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Lskj.Attach.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S2C_BackgroundFileData
|
||||
{
|
||||
public const uint ID = 65545;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwTotalCount;
|
||||
public int dwPacketOrder;
|
||||
public int dwPacketLen;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
|
||||
public byte[] FileData;
|
||||
public C2S2C_BackgroundFileData(bool autoSet)
|
||||
{
|
||||
this.FileData = new byte[1024];
|
||||
this.dwErrId = this.dwTotalCount = this.dwPacketOrder = this.dwPacketLen = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 65545;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S2C_FileData
|
||||
{
|
||||
public const uint ID = 4097;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwFileId;
|
||||
public int dwTotalBytes;
|
||||
public int dwTotalCount;
|
||||
public int dwPacketOrder;
|
||||
public int dwPacketLen;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
|
||||
public byte[] FileData;
|
||||
public C2S2C_FileData(bool autoSet)
|
||||
{
|
||||
this.FileData = new byte[1024];
|
||||
this.dwErrId = this.dwFileId = this.dwTotalCount = this.dwPacketOrder = this.dwPacketLen = this.dwTotalBytes = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 4097;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S2C_FileTranslateComplete
|
||||
{
|
||||
public const uint ID = 4098;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwFileId;
|
||||
public int dwTotalBytes;
|
||||
public int dwTotalCount;
|
||||
public int dwRevPacketCount;
|
||||
public int dwRevBytesLen;
|
||||
public C2S2C_FileTranslateComplete(bool autoSet)
|
||||
{
|
||||
this.dwErrId = this.dwFileId = this.dwTotalBytes = this.dwTotalCount = this.dwRevPacketCount = this.dwRevBytesLen = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 4098;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S2C_SmartResponse
|
||||
{
|
||||
public const uint ID = 69634;
|
||||
public MsgHeader header;
|
||||
public uint dwFieldCount;
|
||||
public uint dwDataLen;
|
||||
public C2S2C_SmartResponse(bool autoSet)
|
||||
{
|
||||
this.dwFieldCount = this.dwDataLen = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 69634;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_AddFile
|
||||
{
|
||||
public const uint ID = 17;
|
||||
public MsgHeader header;
|
||||
public StructFileInfo fi;
|
||||
public C2S_AddFile(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.fi = new StructFileInfo(true);
|
||||
this.header.dwType = 17;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_AddFileDirectory
|
||||
{
|
||||
public const uint ID = 1;
|
||||
public MsgHeader header;
|
||||
public StructFileInfo fi;
|
||||
public C2S_AddFileDirectory(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.fi = new StructFileInfo(true);
|
||||
this.header.dwType = 1;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||
public struct C2S_DeleteFile
|
||||
{
|
||||
public const uint ID = 22;
|
||||
public MsgHeader header;
|
||||
public int dwFileId;
|
||||
public C2S_DeleteFile(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.dwFileId = 0;
|
||||
this.header.dwType = 22;
|
||||
this.header.dwLen = (uint) Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_DownloadFile
|
||||
{
|
||||
public const uint ID = 19;
|
||||
public MsgHeader header;
|
||||
public int dwDirectoryId;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
|
||||
public int[] dwFileIds;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
|
||||
public int[] dwProductIds;
|
||||
public C2S_DownloadFile(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.dwDirectoryId = 0;
|
||||
this.dwFileIds = new int[50];
|
||||
this.dwProductIds = new int[50];
|
||||
this.header.dwType = 19;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
|
||||
public string strFileIds
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.getIds(this.dwFileIds);
|
||||
}
|
||||
}
|
||||
public string strProductIds
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.getIds(this.dwProductIds);
|
||||
}
|
||||
}
|
||||
private string getIds(int[] arr)
|
||||
{
|
||||
string str = "";
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
int num2 = arr[i];
|
||||
if (num2 != 0)
|
||||
{
|
||||
str = str + num2.ToString() + "|";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_EditFileDirectory
|
||||
{
|
||||
public const uint ID = 3;
|
||||
public MsgHeader header;
|
||||
public uint dwFileId;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
||||
public byte[] szDirName;
|
||||
public C2S_EditFileDirectory(bool autoSet)
|
||||
{
|
||||
this.dwFileId = 0;
|
||||
this.szDirName = new byte[512];
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 3;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_RemoveFileDirectory
|
||||
{
|
||||
public const uint ID = 5;
|
||||
public MsgHeader header;
|
||||
public uint dwFileId;
|
||||
public C2S_RemoveFileDirectory(bool autoSet)
|
||||
{
|
||||
this.dwFileId = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 5;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_ReqBackgroundDownload
|
||||
{
|
||||
public const int DownLoadModel = 1;
|
||||
public const int GetFileListModel = 2;
|
||||
public const uint ID = 65543;
|
||||
public MsgHeader header;
|
||||
public int reqType;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1024)]
|
||||
public byte[] szPath;
|
||||
public C2S_ReqBackgroundDownload(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.reqType = 1;
|
||||
this.szPath = new byte[1024];
|
||||
this.header.dwType = 65543;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
|
||||
public bool isDownloadModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.reqType == 1);
|
||||
}
|
||||
}
|
||||
public bool isGetFileListModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.reqType == 2);
|
||||
}
|
||||
}
|
||||
public string strPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return PubUtils.BytesToStr(this.szPath);
|
||||
}
|
||||
set
|
||||
{
|
||||
byte[] src = PubUtils.StrToBytes(value);
|
||||
Buffer.BlockCopy(src, 0, this.szPath, 0, src.Length);
|
||||
src = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||
public struct C2S_ReqestFileList
|
||||
{
|
||||
public const uint ID = 33;
|
||||
public MsgHeader header;
|
||||
public int dwParentId;
|
||||
public int dwReqType;
|
||||
public int dwFileId;
|
||||
public C2S_ReqestFileList(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.dwParentId = -1;
|
||||
this.dwReqType = this.dwFileId = 0;
|
||||
this.header.dwType = 33;
|
||||
this.header.dwLen = (uint) Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct C2S_SmartClientLogin
|
||||
{
|
||||
public const uint ID = 69633;
|
||||
public MsgHeader header;
|
||||
public C2S_SmartClientLogin(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 69633;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 1)]
|
||||
internal struct ErrorType
|
||||
{
|
||||
private static readonly int NONE;
|
||||
public static readonly int SUCCESS;
|
||||
public static readonly int FILE_EXIST;
|
||||
public static readonly int DIRECTORY_EXIST;
|
||||
public static readonly int FILE_NOT_EXIST;
|
||||
public static readonly int DIRECTORY_NOT_EXIST;
|
||||
public static readonly int DELETE_FILE_ERROR;
|
||||
public static readonly int DELETEFILE_FROMDB_ERROR;
|
||||
public static readonly int FILE_BEEN_LOCKED;
|
||||
public static readonly int FAIL;
|
||||
public static readonly int UNKNOWN;
|
||||
private static readonly int MAX;
|
||||
static ErrorType()
|
||||
{
|
||||
NONE = 0;
|
||||
SUCCESS = NONE++;
|
||||
FILE_EXIST = NONE++;
|
||||
DIRECTORY_EXIST = NONE++;
|
||||
FILE_NOT_EXIST = NONE++;
|
||||
DIRECTORY_NOT_EXIST = NONE++;
|
||||
DELETE_FILE_ERROR = NONE++;
|
||||
DELETEFILE_FROMDB_ERROR = NONE++;
|
||||
FILE_BEEN_LOCKED = NONE++;
|
||||
FAIL = NONE++;
|
||||
UNKNOWN = NONE++;
|
||||
MAX = NONE++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Lskj.Util;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public abstract class LSASyncSocket
|
||||
{
|
||||
private byte _HandledCloseEventCounter = 0;
|
||||
private int _LastExchangeStamp = 0;
|
||||
protected int _ReceivedLen = 0;
|
||||
private int _SendedLen = 0;
|
||||
protected Socket _socket;
|
||||
protected int _socketstate = 0;
|
||||
private object[] _source;
|
||||
private int nSendLength = 0;
|
||||
public object ObjClient2Server = 2;
|
||||
public object ObjServer2Client = 1;
|
||||
protected const uint PACKETMAXLEN = 102400;
|
||||
private AutoResetEvent RevDone_Event = new AutoResetEvent(true);
|
||||
private AutoResetEvent SendDone_Event = new AutoResetEvent(true);
|
||||
protected StateObject StateObj = new StateObject();
|
||||
|
||||
public event SocketCloseEventHandle SocketCloseEvent;
|
||||
|
||||
protected LSASyncSocket()
|
||||
{
|
||||
}
|
||||
|
||||
protected void CheckCloseState(int ErrorCode)
|
||||
{
|
||||
switch (ErrorCode)
|
||||
{
|
||||
case 10053:
|
||||
case 10054:
|
||||
case 10057:
|
||||
case 10058:
|
||||
this.CloseSocket();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseSocket()
|
||||
{
|
||||
if (this._socketstate != 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
this._socketstate = 2;
|
||||
if ((this._socket != null) && this._socket.Connected)
|
||||
{
|
||||
string str = ((IPEndPoint)this._socket.RemoteEndPoint).Port.ToString();
|
||||
this._socket.Shutdown(SocketShutdown.Receive);
|
||||
Thread.Sleep(1);
|
||||
this._socket.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
if (this.SocketCloseEvent != null)
|
||||
{
|
||||
this.SocketCloseEvent(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void ContinueReceive()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (((this._socket != null) && this._socket.Connected) && (this._socketstate != 2))
|
||||
{
|
||||
this._ReceivedLen = 0;
|
||||
if (this.StateObj.buffer.Length > this.StateObj.BufferSize)
|
||||
{
|
||||
this.StateObj.buffer = new byte[this.StateObj.BufferSize];
|
||||
}
|
||||
this.SetLastStamp();
|
||||
this._socket.BeginReceive(this.StateObj.buffer, 0, this.StateObj.BufferSize, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), this._socket);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
}
|
||||
|
||||
~LSASyncSocket()
|
||||
{
|
||||
if (this.SendDone_Event != null)
|
||||
{
|
||||
this.SendDone_Event.Close();
|
||||
this.SendDone_Event = null;
|
||||
}
|
||||
if (this.RevDone_Event != null)
|
||||
{
|
||||
this.RevDone_Event.Close();
|
||||
this.RevDone_Event = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void HandledCloseEvent()
|
||||
{
|
||||
this._HandledCloseEventCounter = (byte)(this._HandledCloseEventCounter + 1);
|
||||
}
|
||||
|
||||
protected abstract void ParseReceiveData(byte[] byteData);
|
||||
protected abstract void ReceiveCallback(IAsyncResult ar);
|
||||
protected void ReceiveReady()
|
||||
{
|
||||
this._socketstate = 1;
|
||||
this._ReceivedLen = 0;
|
||||
try
|
||||
{
|
||||
this._socket.BeginReceive(this.StateObj.buffer, 0, this.StateObj.BufferSize, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), this._socket);
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
this.CheckCloseState(exception.ErrorCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Send(object structObj)
|
||||
{
|
||||
byte[] byteData = PubUtils.StructToBytes(structObj);
|
||||
return this.Send(byteData);
|
||||
}
|
||||
|
||||
public bool Send(byte[] byteData)
|
||||
{
|
||||
return this.Send(byteData, byteData.Length);
|
||||
}
|
||||
|
||||
public bool Send(byte[] byteData, int sendLength)
|
||||
{
|
||||
int tickCount = Environment.TickCount;
|
||||
if (((this._socket == null) || !this._socket.Connected) || (this._socketstate == 2))
|
||||
{
|
||||
if (this._socket == null)
|
||||
{
|
||||
LogHelper.Instance.WriteLog(string.Format(this.ToString() + ".send 过程即将要发送数据,但是不能发出去,socket = null, _socketstate=={0}, 要发送的数据内容是:\n{1}", this._socketstate, byteData));
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Instance.WriteLog(string.Format(this.ToString() + ".send 过程即将要发送数据,但是不能发出去,socket id= {0}, socket.Connected=={1},_socketstate=={2}, 要发送的数据内容是:\n{3}", this._socket.Handle, this._socket.Connected, this._socketstate, byteData));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.SendDone_Event.WaitOne();
|
||||
if (((this._socket == null) || !this._socket.Connected) || (this._socketstate == 2))
|
||||
{
|
||||
this.SendDone_Event.Set();
|
||||
return false;
|
||||
}
|
||||
LogHelper.Instance.WriteLog(string.Format("Socket Send Data WaitOne过程等待周期 = {0}", Environment.TickCount - tickCount));
|
||||
this.SetLastStamp();
|
||||
this._SendedLen = 0;
|
||||
this.nSendLength = sendLength;
|
||||
try
|
||||
{
|
||||
this._socket.BeginSend(byteData, 0, sendLength, SocketFlags.None, new AsyncCallback(this.SendCallback), tickCount);
|
||||
return true;
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
this.SendDone_Event.Set();
|
||||
LogHelper.Instance.WriteLog(string.Format("LSASyncSocket.Sen SOCKET errorcode: {0} errormsg: {1}", exception.SocketErrorCode, exception.StackTrace));
|
||||
this.CheckCloseState(exception.ErrorCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.SendDone_Event.Set();
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SendCallback(IAsyncResult ar)
|
||||
{
|
||||
if (((this._socket == null) || !this._socket.Connected) || (this._socketstate == 2))
|
||||
{
|
||||
this.SendDone_Event.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
int asyncState = 2147483647;
|
||||
try
|
||||
{
|
||||
asyncState = (int)ar.AsyncState;
|
||||
int num2 = this._socket.EndSend(ar);
|
||||
this._SendedLen += num2;
|
||||
if (this.nSendLength != this._SendedLen)
|
||||
{
|
||||
LogHelper.Instance.WriteLog(string.Format("严重错误!!!需要发送的长度是= {0},但实际发送的长度为= {1}", this._SendedLen, this.nSendLength));
|
||||
this.CloseSocket();
|
||||
}
|
||||
}
|
||||
catch (SocketException exception)
|
||||
{
|
||||
this.CheckCloseState(exception.ErrorCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
asyncState = Environment.TickCount - asyncState;
|
||||
LogHelper.Instance.WriteLog(string.Format("Socket Send Data周期(包含WaitOne) = {0}", asyncState));
|
||||
this.SendDone_Event.Set();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLastStamp()
|
||||
{
|
||||
this._LastExchangeStamp = Environment.TickCount;
|
||||
}
|
||||
|
||||
private void SetOptBuffer(int SendBufSize, int RevBufSize)
|
||||
{
|
||||
if (SendBufSize <= 0)
|
||||
{
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, SendBufSize);
|
||||
}
|
||||
if (RevBufSize <= 0)
|
||||
{
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, RevBufSize);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetOptKeepAlive()
|
||||
{
|
||||
uint num = 10000;
|
||||
uint num2 = 2000;
|
||||
uint structure = 0;
|
||||
byte[] array = new byte[Marshal.SizeOf(structure) * 3];
|
||||
BitConverter.GetBytes((uint)1).CopyTo(array, 0);
|
||||
BitConverter.GetBytes(num).CopyTo(array, Marshal.SizeOf(structure));
|
||||
BitConverter.GetBytes(num2).CopyTo(array, (int)(Marshal.SizeOf(structure) * 2));
|
||||
this._socket.IOControl(IOControlCode.KeepAliveValues, array, null);
|
||||
}
|
||||
|
||||
private void SetOptLinger(int nMilliSecond)
|
||||
{
|
||||
LingerOption optionValue = null;
|
||||
if (nMilliSecond <= 0)
|
||||
{
|
||||
optionValue = new LingerOption(true, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
optionValue = new LingerOption(true, nMilliSecond);
|
||||
}
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, optionValue);
|
||||
}
|
||||
|
||||
private void SetOptTimeOut(int nMilliSecond)
|
||||
{
|
||||
if (nMilliSecond <= 0)
|
||||
{
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, nMilliSecond);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TimeOutCheck(int TimeOutValue)
|
||||
{
|
||||
return ((Environment.TickCount - this._LastExchangeStamp) > TimeOutValue);
|
||||
}
|
||||
|
||||
public bool HandledCloseEventCounter
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this._HandledCloseEventCounter > 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int ReceivedLen
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._ReceivedLen;
|
||||
}
|
||||
}
|
||||
|
||||
public int SendedLen
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._SendedLen;
|
||||
}
|
||||
}
|
||||
|
||||
public Socket socket
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._socket;
|
||||
}
|
||||
}
|
||||
|
||||
public int SocketState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._socketstate;
|
||||
}
|
||||
}
|
||||
|
||||
public object[] source
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._source;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._source = value;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void SocketCloseEventHandle(LSASyncSocket AsyncSocket);
|
||||
|
||||
protected class StateObject
|
||||
{
|
||||
private const int _BufferSize = 10240;
|
||||
public byte[] buffer = new byte[10240];
|
||||
|
||||
public void ExtentBuffer()
|
||||
{
|
||||
int num = this.buffer.Length * 2;
|
||||
byte[] dst = new byte[num];
|
||||
Buffer.BlockCopy(this.buffer, 0, dst, 0, this.buffer.Length);
|
||||
this.buffer = dst;
|
||||
}
|
||||
|
||||
public int BufferSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return 10240;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
internal class LSDBManage
|
||||
{
|
||||
public SqlConnection conn = null;
|
||||
public static string connectionStr = "";
|
||||
public static Dictionary<string, LSDBManage> dbmanageList = new Dictionary<string, LSDBManage>();
|
||||
|
||||
public int checkFileLockState(int fileId, int parentId, string name)
|
||||
{
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@RetParam", SqlDbType.Int), new SqlParameter("@fileId", SqlDbType.Int), new SqlParameter("@parentId", SqlDbType.Int), new SqlParameter("@name", SqlDbType.VarChar, 64) };
|
||||
parameterArray[0].Direction = ParameterDirection.ReturnValue;
|
||||
parameterArray[1].Value = fileId;
|
||||
parameterArray[2].Value = parentId;
|
||||
parameterArray[3].Value = name;
|
||||
using (SqlCommand command = new SqlCommand("pr_fm_CheckFileLockState", this.conn))
|
||||
{
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
foreach (SqlParameter parameter in parameterArray)
|
||||
{
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
command.ExecuteNonQuery();
|
||||
num = int.Parse(parameterArray[0].Value.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.createFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public int createFile(int parentId, string name, int fileSize, int creator, int productId)
|
||||
{
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@RetParam", SqlDbType.Int), new SqlParameter("@parentId", SqlDbType.Int), new SqlParameter("@name", SqlDbType.VarChar, 500), new SqlParameter("@fileSize", SqlDbType.Int), new SqlParameter("@creator", SqlDbType.Int), new SqlParameter("@productId", SqlDbType.Int) };
|
||||
parameterArray[0].Direction = ParameterDirection.ReturnValue;
|
||||
parameterArray[1].Value = parentId;
|
||||
parameterArray[2].Value = name;
|
||||
parameterArray[3].Value = fileSize;
|
||||
parameterArray[4].Value = creator;
|
||||
parameterArray[5].Value = productId;
|
||||
using (SqlCommand command = new SqlCommand("pr_fm_createFile", this.conn))
|
||||
{
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
foreach (SqlParameter parameter in parameterArray)
|
||||
{
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
command.ExecuteNonQuery();
|
||||
num = int.Parse(parameterArray[0].Value.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.createFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public bool deleteFile(int fileId)
|
||||
{
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@RetParam", SqlDbType.Int), new SqlParameter("@fileId", SqlDbType.Int) };
|
||||
parameterArray[0].Direction = ParameterDirection.ReturnValue;
|
||||
parameterArray[1].Value = fileId;
|
||||
using (SqlCommand command = new SqlCommand("pr_fm_deleteFile", this.conn))
|
||||
{
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
foreach (SqlParameter parameter in parameterArray)
|
||||
{
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
command.ExecuteNonQuery();
|
||||
flag = int.Parse(parameterArray[0].Value.ToString()) == 1;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.deleteFile fileId={0} error is : {1} ", new object[] { fileId, exception });
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public bool existFile(int parentId, string name)
|
||||
{
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
SqlCommand command = new SqlCommand(string.Format("select * from P_fm_FileTab where parentId={0} and sName='{1}'", parentId, name), this.conn)
|
||||
{
|
||||
CommandType = CommandType.Text
|
||||
};
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
command.Dispose();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.existFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public string getAbsoluteFile(int dwFileId)
|
||||
{
|
||||
if (dwFileId <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string str = "";
|
||||
try
|
||||
{
|
||||
using (SqlDataReader reader = this.querySql(string.Format("select dbo.[fun_fm_getAbsolutePath]({0}) as absolutePath", dwFileId)))
|
||||
{
|
||||
if ((reader != null) && reader.Read())
|
||||
{
|
||||
str = reader["absolutePath"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.getAbsoluteFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public SqlDataReader getDownloadFileList(int parentId, string fileIds, string strProductIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlCommand command = new SqlCommand("pr_fm_getDownloadFileInfo", this.conn)
|
||||
{
|
||||
CommandType = CommandType.StoredProcedure
|
||||
};
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@parentId", SqlDbType.Int), new SqlParameter("@fileIds", SqlDbType.VarChar, 1000), new SqlParameter("@productIds", SqlDbType.VarChar, 1000) };
|
||||
parameterArray[0].Value = parentId;
|
||||
parameterArray[1].Value = fileIds;
|
||||
parameterArray[2].Value = strProductIds;
|
||||
command.Parameters.Add(parameterArray[0]);
|
||||
command.Parameters.Add(parameterArray[1]);
|
||||
command.Parameters.Add(parameterArray[2]);
|
||||
return command.ExecuteReader();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.getDownloadFileList error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string getRelativePath(int parentId)
|
||||
{
|
||||
if (parentId <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string str = "";
|
||||
try
|
||||
{
|
||||
using (SqlDataReader reader = this.querySql(string.Format("select dbo.[fun_fm_getRelativePath]({0}) as relativePath", parentId)))
|
||||
{
|
||||
if ((reader != null) && reader.Read())
|
||||
{
|
||||
str = reader["relativePath"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.getRelativePath error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public SqlDataReader querySql(string strSql)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlCommand command = new SqlCommand(strSql, this.conn)
|
||||
{
|
||||
CommandType = CommandType.Text
|
||||
};
|
||||
return command.ExecuteReader();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.querySql error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Lskj.Util;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
internal static class LSErrorManage
|
||||
{
|
||||
private static Dictionary<int, string> m_errList = new Dictionary<int, string>();
|
||||
|
||||
public static string getDes(int dwErrId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_errList[dwErrId];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_errList.Add(ErrorType.SUCCESS, "成功");
|
||||
m_errList.Add(ErrorType.FILE_EXIST, "文件已经存在");
|
||||
m_errList.Add(ErrorType.DIRECTORY_EXIST, "文件夹已经存在");
|
||||
m_errList.Add(ErrorType.FILE_NOT_EXIST, "文件不存在");
|
||||
m_errList.Add(ErrorType.DIRECTORY_NOT_EXIST, "文件夹不存在");
|
||||
m_errList.Add(ErrorType.FAIL, "失败");
|
||||
m_errList.Add(ErrorType.UNKNOWN, "未知错误");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
internal class LSFileData
|
||||
{
|
||||
public int dwFileId;
|
||||
public int dwRevPacketCount;
|
||||
public int dwTotalBytes;
|
||||
public int dwTotalCount;
|
||||
public uint dwUserId = 0;
|
||||
public FileStream fs;
|
||||
public int lastWriteTime;
|
||||
|
||||
public LSFileData()
|
||||
{
|
||||
this.dwFileId = this.dwTotalBytes = this.dwTotalCount = this.dwRevPacketCount = 0;
|
||||
this.fs = null;
|
||||
this.lastWriteTime = Environment.TickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Lskj.Util;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
internal static class LSFileManage
|
||||
{
|
||||
private static Dictionary<int, LSFileData> m_fileList = new Dictionary<int, LSFileData>();
|
||||
private static string m_rootPath = "";
|
||||
|
||||
public static void createClientDirectory(string strPath)
|
||||
{
|
||||
if (strPath != "")
|
||||
{
|
||||
try
|
||||
{
|
||||
string str = "";
|
||||
string[] strArray = strPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
str = str + strArray[i] + "/";
|
||||
if (!Directory.Exists(m_rootPath + str))
|
||||
{
|
||||
Directory.CreateDirectory(m_rootPath + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static LSFileData createClientFile(string strName)
|
||||
{
|
||||
if (strName == "")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
LSFileData fd = new LSFileData();
|
||||
try
|
||||
{
|
||||
string path = m_rootPath + strName;
|
||||
fd.fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
eraseFile(fd);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
public static bool createDir(LSDBManage dbmanager, int parentId, string dirName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(m_rootPath + dbmanager.getRelativePath(parentId) + dirName);
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static LSFileData createFile(LSDBManage dbmanager, int parentId, string fileName, bool saveOld)
|
||||
{
|
||||
LSFileData data = new LSFileData();
|
||||
try
|
||||
{
|
||||
string str = dbmanager.getRelativePath(parentId);
|
||||
string rootPath = m_rootPath;
|
||||
string[] strArray = str.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
for (int i = 0; i < strArray.Length; i++)
|
||||
{
|
||||
rootPath = rootPath + strArray[i] + "//";
|
||||
if (!Directory.Exists(rootPath))
|
||||
{
|
||||
Directory.CreateDirectory(rootPath);
|
||||
}
|
||||
}
|
||||
string path = m_rootPath + str + fileName;
|
||||
if (saveOld && File.Exists(path))
|
||||
{
|
||||
File.Move(path, path + "#" + DateTime.Now.ToString("yyyy_MM_dd#hh_mm_ss"));
|
||||
}
|
||||
data.fs = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static bool createFileData(C2S2C_FileData data, out C2S2C_FileTranslateComplete structComplete)
|
||||
{
|
||||
structComplete = new C2S2C_FileTranslateComplete(true);
|
||||
try
|
||||
{
|
||||
LSFileData data2 = m_fileList[data.dwFileId];
|
||||
if (data2 != null)
|
||||
{
|
||||
data2.fs.Write(data.FileData, 0, data.dwPacketLen);
|
||||
data2.dwTotalBytes = data.dwTotalBytes;
|
||||
data2.dwTotalCount = data.dwTotalCount;
|
||||
data2.dwRevPacketCount++;
|
||||
data2.lastWriteTime = Environment.TickCount;
|
||||
if (data2.fs.Length >= data2.dwTotalBytes)
|
||||
{
|
||||
structComplete.dwFileId = data2.dwFileId;
|
||||
structComplete.dwTotalBytes = data2.dwTotalBytes;
|
||||
structComplete.dwTotalCount = data2.dwTotalCount;
|
||||
structComplete.dwRevPacketCount = data2.dwRevPacketCount;
|
||||
structComplete.dwRevBytesLen = (int)data2.fs.Length;
|
||||
data2.fs.Flush();
|
||||
data2.fs.Close();
|
||||
data2.fs.Dispose();
|
||||
data2.fs = null;
|
||||
lock (m_fileList)
|
||||
{
|
||||
m_fileList.Remove(data.dwFileId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool deleteFile(LSDBManage dbmanager, int fileId)
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = m_rootPath + dbmanager.getAbsoluteFile(fileId);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Move(path, path + "#" + DateTime.Now.ToString("yyyy_MM_dd#hh_mm_ss"));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (m_fileList)
|
||||
{
|
||||
foreach (KeyValuePair<int, LSFileData> pair in m_fileList)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public static void eraseFile(LSFileData fd)
|
||||
{
|
||||
if ((fd != null) && (fd.fs != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
string name = fd.fs.Name;
|
||||
fd.fs.Flush();
|
||||
fd.fs.Close();
|
||||
fd.fs.Dispose();
|
||||
fd.fs = null;
|
||||
File.Delete(name);
|
||||
if (File.Exists(name))
|
||||
{
|
||||
LogHelper.Instance.WriteLog("无法删除指定文件: {0}", name);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
lock (m_fileList)
|
||||
{
|
||||
m_fileList.Remove(fd.dwFileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void eraseFile(int dwFileId)
|
||||
{
|
||||
lock (m_fileList)
|
||||
{
|
||||
LSFileData fd = m_fileList[dwFileId];
|
||||
eraseFile(fd);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool existDir(LSDBManage dbmanager, int parentId, string dirName)
|
||||
{
|
||||
string str = dbmanager.getRelativePath(parentId);
|
||||
return Directory.Exists(m_rootPath + str + dirName);
|
||||
}
|
||||
|
||||
public static bool existFile(LSDBManage dbmanager, int parentId, string fileName)
|
||||
{
|
||||
string str = dbmanager.getRelativePath(parentId);
|
||||
return File.Exists(m_rootPath + str + fileName);
|
||||
}
|
||||
|
||||
public static bool init(string rootPath)
|
||||
{
|
||||
m_rootPath = rootPath;
|
||||
return Directory.Exists(rootPath);
|
||||
}
|
||||
|
||||
public static void insertFileData(LSFileData fd)
|
||||
{
|
||||
lock (m_fileList)
|
||||
{
|
||||
if (m_fileList.ContainsKey(fd.dwFileId))
|
||||
{
|
||||
m_fileList.Remove(fd.dwFileId);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileList.Add(fd.dwFileId, fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string joinFileName(string filename)
|
||||
{
|
||||
string path = m_rootPath + filename;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using Lskj.Util;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public static class LSIniFile
|
||||
{
|
||||
private static string _IniPath = "";
|
||||
private static XmlDocument xmlDoc = new XmlDocument();
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
|
||||
public static XmlNodeList ReadNodeList(string strNodeName)
|
||||
{
|
||||
XmlNodeList elementsByTagName;
|
||||
try
|
||||
{
|
||||
elementsByTagName = xmlDoc.GetElementsByTagName(strNodeName);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
return null;
|
||||
}
|
||||
return elementsByTagName;
|
||||
}
|
||||
|
||||
public static string ReadNodeValue(XmlNode node, string strName)
|
||||
{
|
||||
string str = null;
|
||||
if (node.HasChildNodes)
|
||||
{
|
||||
for (int i = 0; i < node.ChildNodes.Count; i++)
|
||||
{
|
||||
if (node.ChildNodes[i].LocalName == strName)
|
||||
{
|
||||
return node.ChildNodes[i].InnerXml;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static XmlNode ReadSingleNode(string strNodeName)
|
||||
{
|
||||
XmlNode node = null;
|
||||
try
|
||||
{
|
||||
node = xmlDoc.DocumentElement.SelectSingleNode(strNodeName);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
return null;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public static string ReadValue(string NodePath, string NodeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (XmlNode node = xmlDoc.DocumentElement.SelectNodes(NodePath)[0].FirstChild; node != null; node = node.NextSibling)
|
||||
{
|
||||
if (node.Name == NodeName)
|
||||
{
|
||||
return node.InnerText;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static bool ReadValue(string NodeName, int index, params string[] NodeValues)
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlNode node = ReadSingleNode(NodeName);
|
||||
if (node.ChildNodes.Count <= index)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
node = node.ChildNodes[index];
|
||||
int num = 0;
|
||||
for (XmlNode node2 = node.FirstChild; (node2 != null) && (num < NodeValues.Length); node2 = node2.NextSibling)
|
||||
{
|
||||
if (node2.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
NodeValues[num] = node2.InnerText;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
LogHelper.Instance.WriteError(exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ReadValue(string Section, string Key, string path)
|
||||
{
|
||||
StringBuilder retVal = new StringBuilder(255);
|
||||
int num = GetPrivateProfileString(Section, Key, "", retVal, 255, path);
|
||||
return retVal.ToString();
|
||||
}
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||
public static void WriteValue(string Section, string Key, string Value)
|
||||
{
|
||||
WritePrivateProfileString(Section, Key, Value, _IniPath);
|
||||
}
|
||||
|
||||
public static void WriteValue(string Section, string Key, string Value, string path)
|
||||
{
|
||||
WritePrivateProfileString(Section, Key, Value, path);
|
||||
}
|
||||
|
||||
public static string IniPath
|
||||
{
|
||||
set
|
||||
{
|
||||
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
if (!baseDirectory.EndsWith(@"\"))
|
||||
{
|
||||
baseDirectory = baseDirectory + @"\";
|
||||
}
|
||||
_IniPath = baseDirectory + value;
|
||||
xmlDoc.Load(_IniPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public static class LSProtocol
|
||||
{
|
||||
public const int LS_DOWNLOADFILE_MAXCOUNT = 50;
|
||||
public const int LS_FILEDATAPACKET_LEN = 1024;
|
||||
public const int LS_FILENAM_LEN = 512;
|
||||
public const int LS_PATH_LEN = 1024;
|
||||
public const uint PACKETMAXLEN = 102400;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
internal static class LSQueueManage
|
||||
{
|
||||
private static Queue<LSSocketRev> LSSocketRevQueue = new Queue<LSSocketRev>();
|
||||
private static AutoResetEvent Rev_Event = new AutoResetEvent(true);
|
||||
|
||||
public static LSSocketRev GetSocketRevData()
|
||||
{
|
||||
LSSocketRev socketRevData = null;
|
||||
if (LSSocketRevQueue.Count > 0)
|
||||
{
|
||||
lock (LSSocketRevQueue)
|
||||
{
|
||||
socketRevData = LSSocketRevQueue.Dequeue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Rev_Event.WaitOne();
|
||||
}
|
||||
if (socketRevData == null)
|
||||
{
|
||||
socketRevData = GetSocketRevData();
|
||||
}
|
||||
return socketRevData;
|
||||
}
|
||||
|
||||
public static void InsertSocketRevData(LSSocketRev socketRev)
|
||||
{
|
||||
lock (LSSocketRevQueue)
|
||||
{
|
||||
LSSocketRevQueue.Enqueue(socketRev);
|
||||
}
|
||||
Rev_Event.Set();
|
||||
}
|
||||
|
||||
public static int LSSocketRevQueueCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return LSSocketRevQueue.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Lskj.Util;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public class LSSocket : LSASyncSocket
|
||||
{
|
||||
private int _selDirectoryId = 0;
|
||||
private string _ServerIP = "";
|
||||
private uint _ServerPort = 0;
|
||||
private const int FIONREAD = 1074030207;
|
||||
private uint m_dwUserId = 0;
|
||||
private string m_remoteIP;
|
||||
private int m_remotePort;
|
||||
|
||||
public event ParseReceiveDataEventHandle ParseReceiveDataEvent;
|
||||
|
||||
public LSSocket()
|
||||
{
|
||||
base._socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
|
||||
public void clientAdd(Socket s)
|
||||
{
|
||||
base._socket = s;
|
||||
base.ReceiveReady();
|
||||
}
|
||||
|
||||
public void Connect(string strHost, uint nPort)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.ServerIP = strHost;
|
||||
this.ServerPort = nPort;
|
||||
IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(strHost), (int)nPort);
|
||||
LogHelper.Instance.WriteLog(string.Format("begin connect server ip={0}, port={1}.", strHost, nPort));
|
||||
base._socket.BeginConnect(remoteEP, new AsyncCallback(this.ConnectCallback), base._socket);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectCallback(IAsyncResult ar)
|
||||
{
|
||||
try
|
||||
{
|
||||
((Socket)ar.AsyncState).EndConnect(ar);
|
||||
LogHelper.Instance.WriteLog(string.Format("connected server ip={0} port={1} success.", this.ServerIP, this.ServerPort));
|
||||
base.ReceiveReady();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ParseReceiveData(byte[] byteData)
|
||||
{
|
||||
this.ParseReceiveDataEvent(this, byteData);
|
||||
}
|
||||
|
||||
protected override void ReceiveCallback(IAsyncResult ar)
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHelper.Instance.WriteLog(this.ToString() + ".ReceiveCallback is running socketid = " + base._socket.Handle);
|
||||
if (!((base._socket != null) && base._socket.Connected))
|
||||
{
|
||||
base.CloseSocket();
|
||||
return;
|
||||
}
|
||||
LogHelper.Instance.WriteLog(this.ToString() + ".ReceiveCallback socketid = " + base._socket.Handle + " bytesAvailable is " + base._socket.Available.ToString() + " _socketstate=" + this._socketstate.ToString());
|
||||
if ((base._socket.Available == 0) && (base._socketstate == 2))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int count = base._socket.EndReceive(ar);
|
||||
byte[] dst = new byte[count];
|
||||
Buffer.BlockCopy(base.StateObj.buffer, 0, dst, 0, count);
|
||||
if (count > 0)
|
||||
{
|
||||
int num3;
|
||||
base._ReceivedLen += count;
|
||||
for (int i = 0; i < base._ReceivedLen; i += num3)
|
||||
{
|
||||
bool flag = (base._ReceivedLen - i) <= 8;
|
||||
Label_0158:
|
||||
if (flag)
|
||||
{
|
||||
if ((base._ReceivedLen - i) < base.StateObj.buffer.Length)
|
||||
{
|
||||
Buffer.BlockCopy(base.StateObj.buffer, i, base.StateObj.buffer, 0, base._ReceivedLen - i);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.StateObj.ExtentBuffer();
|
||||
}
|
||||
base._ReceivedLen -= i;
|
||||
base._socket.BeginReceive(base.StateObj.buffer, base._ReceivedLen, base.StateObj.buffer.Length - base._ReceivedLen, SocketFlags.None, new AsyncCallback(this.ReceiveCallback), base._socket);
|
||||
return;
|
||||
}
|
||||
num3 = BitConverter.ToInt32(base.StateObj.buffer, 4 + i);
|
||||
if ((num3 + i) > base._ReceivedLen)
|
||||
{
|
||||
flag = true;
|
||||
goto Label_0158;
|
||||
}
|
||||
byte[] buffer2 = new byte[num3];
|
||||
Buffer.BlockCopy(base.StateObj.buffer, i, buffer2, 0, num3);
|
||||
if (num3 > 102400)
|
||||
{
|
||||
byte[] buffer3 = new byte[base._ReceivedLen];
|
||||
Buffer.BlockCopy(base.StateObj.buffer, 0, buffer3, 0, base._ReceivedLen);
|
||||
LogHelper.Instance.WriteLog(string.Format("received proxy data is unnormal! socketid= {0} and a packet data is :{1} and whole data is :{2}", base._socket.Handle, buffer2, buffer3));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ParseReceiveData(buffer2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.CloseSocket();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.WriteError(ex);
|
||||
}
|
||||
base.ContinueReceive();
|
||||
}
|
||||
|
||||
public void reConnect()
|
||||
{
|
||||
base._socketstate = 0;
|
||||
this.Connect(this.m_remoteIP, (uint)this.m_remotePort);
|
||||
}
|
||||
|
||||
public uint dwUserId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_dwUserId;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_dwUserId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string remoteIP
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_remoteIP;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_remoteIP = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int remotePort
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_remotePort;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_remotePort = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int selDirectoryId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._selDirectoryId;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._selDirectoryId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ServerIP
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._ServerIP;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._ServerIP = value;
|
||||
}
|
||||
}
|
||||
|
||||
public uint ServerPort
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._ServerPort;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._ServerPort = value;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void ParseReceiveDataEventHandle(LSSocket ProxySocket, byte[] byteData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public class LSSocketRev
|
||||
{
|
||||
private byte[] _ByteData = null;
|
||||
private LSSocket _ClientSocket = null;
|
||||
|
||||
public byte[] ByteData
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._ByteData;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._ByteData = value;
|
||||
}
|
||||
}
|
||||
|
||||
public LSSocket ClientSocket
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._ClientSocket;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._ClientSocket = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MsgHeader
|
||||
{
|
||||
public const uint sizeOf = 8;
|
||||
public uint dwType;
|
||||
public uint dwLen;
|
||||
public uint dwUserId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public class PubUtils
|
||||
{
|
||||
public static readonly PubUtils Instance = new PubUtils();
|
||||
|
||||
private PubUtils()
|
||||
{
|
||||
}
|
||||
|
||||
public static byte[] BytesAddStruct(byte[] bytesHead, object structObj)
|
||||
{
|
||||
byte[] src = StructToBytes(structObj);
|
||||
if ((bytesHead == null) || (bytesHead.Length <= 0))
|
||||
{
|
||||
return src;
|
||||
}
|
||||
int num = bytesHead.Length + src.Length;
|
||||
byte[] dst = new byte[num];
|
||||
Buffer.BlockCopy(bytesHead, 0, dst, 0, bytesHead.Length);
|
||||
Buffer.BlockCopy(src, 0, dst, bytesHead.Length, src.Length);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public static byte[] BytesAddStruct(object structObj, byte[] bytesTail)
|
||||
{
|
||||
byte[] src = StructToBytes(structObj);
|
||||
if ((bytesTail == null) || (bytesTail.Length <= 0))
|
||||
{
|
||||
return src;
|
||||
}
|
||||
int num = src.Length + bytesTail.Length;
|
||||
byte[] dst = new byte[num];
|
||||
Buffer.BlockCopy(src, 0, dst, 0, src.Length);
|
||||
Buffer.BlockCopy(bytesTail, 0, dst, src.Length, bytesTail.Length);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public static byte[] BytesIntercept(byte[] SrcBytes, uint FixedLen)
|
||||
{
|
||||
byte[] dst = new byte[FixedLen];
|
||||
int count = (SrcBytes.Length > FixedLen) ? ((int) FixedLen) : SrcBytes.Length;
|
||||
Buffer.BlockCopy(SrcBytes, 0, dst, 0, count);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public static string BytesToStr(byte[] SrcBytes)
|
||||
{
|
||||
return Encoding.Default.GetString(SrcBytes).Replace("\0", "");
|
||||
}
|
||||
|
||||
public static string BytesToStr(byte[] SrcBytes, int index, int count)
|
||||
{
|
||||
return Encoding.Default.GetString(SrcBytes, index, count).Replace("\0", "");
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, 0, 0);
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, int startIndex)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, startIndex, 0);
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, string ExceptField)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, 0, 0, new string[] { ExceptField });
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, string[] ExceptFields)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, 0, 0, ExceptFields);
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, int startIndex, int decCount)
|
||||
{
|
||||
object obj2 = null;
|
||||
int num = 1;
|
||||
int num2 = 0;
|
||||
int num3 = 0;
|
||||
while (num > 0)
|
||||
{
|
||||
int cb = Marshal.SizeOf(structType);
|
||||
IntPtr destination = Marshal.AllocHGlobal(cb);
|
||||
try
|
||||
{
|
||||
num3 = 0;
|
||||
Marshal.Copy(bytes, startIndex, destination, cb - decCount);
|
||||
num3 = 1;
|
||||
obj2 = Marshal.PtrToStructure(destination, structType);
|
||||
num3 = 2;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
num++;
|
||||
if (num2 > 2)
|
||||
{
|
||||
throw new Exception(exception.Message.ToString());
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(destination);
|
||||
}
|
||||
num--;
|
||||
}
|
||||
return obj2;
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, int startIndex, string ExceptField)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, startIndex, 0, new string[] { ExceptField });
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, int startIndex, string[] ExceptFields)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, startIndex, 0, ExceptFields);
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, int startIndex, int decCount, string ExceptField)
|
||||
{
|
||||
return BytesToStruct(bytes, structType, startIndex, decCount, new string[] { ExceptField });
|
||||
}
|
||||
|
||||
public static object BytesToStruct(byte[] bytes, Type structType, int startIndex, int decCount, string[] ExceptFields)
|
||||
{
|
||||
object obj3;
|
||||
try
|
||||
{
|
||||
string str = "|";
|
||||
for (int i = 0; i < ExceptFields.Length; i++)
|
||||
{
|
||||
str = str + ExceptFields[i] + "|";
|
||||
}
|
||||
int dstOffset = 0;
|
||||
int num3 = Marshal.SizeOf(structType) - decCount;
|
||||
byte[] buffer = new byte[num3];
|
||||
object obj2 = BytesToStruct(buffer, structType);
|
||||
FieldInfo[] fields = structType.GetFields();
|
||||
foreach (FieldInfo info in fields)
|
||||
{
|
||||
int count = 0;
|
||||
if (info.FieldType.IsArray)
|
||||
{
|
||||
Array array = (Array) info.GetValue(obj2);
|
||||
count = array.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = Marshal.SizeOf(info.FieldType);
|
||||
}
|
||||
string str2 = "|" + info.Name + "|";
|
||||
if (!str.Contains(str2))
|
||||
{
|
||||
Buffer.BlockCopy(bytes, startIndex, buffer, dstOffset, count);
|
||||
startIndex += count;
|
||||
}
|
||||
dstOffset += count;
|
||||
}
|
||||
obj3 = BytesToStruct(buffer, structType);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception(exception.Message.ToString());
|
||||
}
|
||||
return obj3;
|
||||
}
|
||||
|
||||
public static byte[] ComposeTwoBytes(byte[] bytesHead, byte[] bytesTail)
|
||||
{
|
||||
int num = bytesHead.Length + bytesTail.Length;
|
||||
byte[] dst = new byte[num];
|
||||
Buffer.BlockCopy(bytesHead, 0, dst, 0, bytesHead.Length);
|
||||
Buffer.BlockCopy(bytesTail, 0, dst, bytesHead.Length, bytesTail.Length);
|
||||
return dst;
|
||||
}
|
||||
|
||||
public static byte[] CopyArrayData(byte[] source, int startIndex, int length)
|
||||
{
|
||||
byte[] buffer = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
buffer[i] = source[startIndex + i];
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static void CopyStructToBytes(object structObj, byte[] destBytes, int dstOffset)
|
||||
{
|
||||
int cb = Marshal.SizeOf(structObj);
|
||||
IntPtr ptr = Marshal.AllocHGlobal(cb);
|
||||
try
|
||||
{
|
||||
Marshal.StructureToPtr(structObj, ptr, false);
|
||||
Marshal.Copy(ptr, destBytes, dstOffset, cb);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
public static IPAddress GetServerIP()
|
||||
{
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
|
||||
foreach (IPAddress address in hostEntry.AddressList)
|
||||
{
|
||||
if (address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
return address;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static uint IPToLong(string strIP)
|
||||
{
|
||||
return (uint) IPAddress.Parse(strIP).Address;
|
||||
}
|
||||
|
||||
public static string LongToIP(uint dwIP)
|
||||
{
|
||||
return new IPAddress((long) dwIP).ToString();
|
||||
}
|
||||
|
||||
public static string ReadXmlStr(string SrcStr)
|
||||
{
|
||||
return SrcStr.Replace("<", "<").Replace(">", ">").Replace("&", "&").Replace("'", "'").Replace(""", "\"");
|
||||
}
|
||||
|
||||
public static byte[] StrToBytes(string SrcString)
|
||||
{
|
||||
return Encoding.Default.GetBytes(SrcString);
|
||||
}
|
||||
|
||||
public static byte[] StrToBytes(string SrcString, uint FixedLen)
|
||||
{
|
||||
return StrToBytes(SrcString.ToCharArray(), FixedLen);
|
||||
}
|
||||
|
||||
public static byte[] StrToBytes(char[] SrcChar, uint FixedLen)
|
||||
{
|
||||
return BytesIntercept(Encoding.Default.GetBytes(SrcChar), FixedLen);
|
||||
}
|
||||
|
||||
public static byte[] StructToBytes(object structObj)
|
||||
{
|
||||
byte[] buffer2;
|
||||
int cb = Marshal.SizeOf(structObj);
|
||||
IntPtr ptr = Marshal.AllocHGlobal(cb);
|
||||
try
|
||||
{
|
||||
Marshal.StructureToPtr(structObj, ptr, false);
|
||||
byte[] destination = new byte[cb];
|
||||
Marshal.Copy(ptr, destination, 0, cb);
|
||||
buffer2 = destination;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
return buffer2;
|
||||
}
|
||||
|
||||
public static byte[] StructToBytes(object structObj, int decCount)
|
||||
{
|
||||
byte[] buffer2;
|
||||
int cb = Marshal.SizeOf(structObj);
|
||||
IntPtr ptr = Marshal.AllocHGlobal(cb);
|
||||
try
|
||||
{
|
||||
Marshal.StructureToPtr(structObj, ptr, false);
|
||||
byte[] destination = new byte[cb - decCount];
|
||||
Marshal.Copy(ptr, destination, 0, cb - decCount);
|
||||
buffer2 = destination;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
}
|
||||
return buffer2;
|
||||
}
|
||||
|
||||
public static string WriteXmlStr(string SrcStr)
|
||||
{
|
||||
return SrcStr.Replace("<", "<").Replace(">", ">").Replace("&", "&").Replace("'", "'").Replace("\"", """);
|
||||
}
|
||||
|
||||
public static IPAddress LocalFirstIPAddr
|
||||
{
|
||||
get
|
||||
{
|
||||
return Dns.Resolve(LocalMachineName).AddressList[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static uint LocalFirstIPLong
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint) LocalFirstIPAddr.Address;
|
||||
}
|
||||
}
|
||||
|
||||
public static string LocalFirstIPStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return LocalFirstIPAddr.Address.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static string LocalMachineName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Environment.MachineName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C2S_Heart
|
||||
{
|
||||
public static uint ID;
|
||||
public MsgHeader header;
|
||||
public S2C2S_Heart(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = ID;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
|
||||
static S2C2S_Heart()
|
||||
{
|
||||
ID = 65542;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_AddFile
|
||||
{
|
||||
public const uint ID = 18;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public StructFileInfo fi;
|
||||
public S2C_AddFile(bool autoSet)
|
||||
{
|
||||
this.dwErrId = 0;
|
||||
this.fi = new StructFileInfo(true);
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 18;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_AddFileDirectory
|
||||
{
|
||||
public const uint ID = 2;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public StructFileInfo fi;
|
||||
public S2C_AddFileDirectory(bool autoSet)
|
||||
{
|
||||
this.dwErrId = 0;
|
||||
this.fi = new StructFileInfo(true);
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 2;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_DeleteFile
|
||||
{
|
||||
public const uint ID = 23;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwFileId;
|
||||
public S2C_DeleteFile(bool autoSet)
|
||||
{
|
||||
this.dwErrId = this.dwFileId = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 23;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_DownloadFile
|
||||
{
|
||||
public const uint ID = 20;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwTotalCount;
|
||||
public int dwCurrentIndex;
|
||||
public StructFileInfo fi;
|
||||
public S2C_DownloadFile(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.dwErrId = this.dwTotalCount = this.dwCurrentIndex = 0;
|
||||
this.fi = new StructFileInfo(true);
|
||||
this.header.dwType = 20;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_EditFileDirectory
|
||||
{
|
||||
public const uint ID = 4;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwFileId;
|
||||
public S2C_EditFileDirectory(bool autoSet)
|
||||
{
|
||||
this.dwErrId = this.dwFileId = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 4;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_RemoveFileDirectory
|
||||
{
|
||||
public const uint ID = 6;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwFileId;
|
||||
public S2C_RemoveFileDirectory(bool autoSet)
|
||||
{
|
||||
this.header = new MsgHeader();
|
||||
this.dwErrId = this.dwFileId = 0;
|
||||
this.header.dwType = 6;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
public struct S2C_ReqBackgroundDownload
|
||||
{
|
||||
public const uint ID = 65544;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int reqType;
|
||||
public int dwCount;
|
||||
public S2C_ReqBackgroundDownload(bool autoSet)
|
||||
{
|
||||
this.dwErrId = this.dwCount = 0;
|
||||
this.reqType = 1;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 65544;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
|
||||
public bool isDownloadModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.reqType == 1);
|
||||
}
|
||||
}
|
||||
public bool isGetFileListModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return (this.reqType == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_ReqUpdateFile
|
||||
{
|
||||
public const uint ID = 4099;
|
||||
public MsgHeader header;
|
||||
public StructFileInfo fi;
|
||||
public S2C_ReqUpdateFile(bool autoSet)
|
||||
{
|
||||
this.fi = new StructFileInfo(true);
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 4099;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct S2C_ReqestFileList
|
||||
{
|
||||
public const uint ID = 34;
|
||||
public MsgHeader header;
|
||||
public int dwErrId;
|
||||
public int dwReqType;
|
||||
public int dwCount;
|
||||
public S2C_ReqestFileList(bool autoSet)
|
||||
{
|
||||
this.dwErrId = this.dwCount = this.dwReqType = 0;
|
||||
this.header = new MsgHeader();
|
||||
this.header.dwType = 34;
|
||||
this.header.dwLen = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct StructDirectoryInfo
|
||||
{
|
||||
public int dwParentId;
|
||||
public int dwFileId;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
|
||||
public byte[] szName;
|
||||
public int isDir;
|
||||
public StructDirectoryInfo(bool autoSet)
|
||||
{
|
||||
this.dwParentId = this.dwFileId = this.isDir = 0;
|
||||
this.szName = new byte[512];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||
public struct StructFileInfo
|
||||
{
|
||||
public int dwParentId;
|
||||
public int dwFileId;
|
||||
public int dwCreator;
|
||||
public int dwFileSize;
|
||||
public long dwCreateTime;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst=512)]
|
||||
public byte[] szName;
|
||||
public StructFileInfo(bool autoSet)
|
||||
{
|
||||
this.dwParentId = this.dwFileId = this.dwCreator = this.dwFileSize = 0;
|
||||
this.dwCreateTime = 0L;
|
||||
this.szName = new byte[512];
|
||||
}
|
||||
|
||||
public StructFileInfo clone()
|
||||
{
|
||||
StructFileInfo fi = new StructFileInfo(true);
|
||||
this.clone(fi);
|
||||
return fi;
|
||||
}
|
||||
|
||||
public void clone(StructFileInfo fi)
|
||||
{
|
||||
fi.dwParentId = this.dwParentId;
|
||||
fi.dwFileId = this.dwFileId;
|
||||
fi.dwCreator = this.dwCreator;
|
||||
fi.dwFileSize = this.dwFileSize;
|
||||
fi.dwCreateTime = this.dwCreateTime;
|
||||
Buffer.BlockCopy(this.szName, 0, fi.szName, 0, this.szName.Length);
|
||||
}
|
||||
|
||||
public string strName
|
||||
{
|
||||
get
|
||||
{
|
||||
return PubUtils.BytesToStr(this.szName);
|
||||
}
|
||||
set
|
||||
{
|
||||
byte[] src = PubUtils.StrToBytes(value);
|
||||
Buffer.BlockCopy(src, 0, this.szName, 0, src.Length);
|
||||
src = null;
|
||||
}
|
||||
}
|
||||
public string strCreateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.FromFileTime(this.dwCreateTime).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
set
|
||||
{
|
||||
this.dwCreateTime = DateTime.Parse(value).ToFileTime();
|
||||
}
|
||||
}
|
||||
public DateTime dtCreateTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.FromFileTime(this.dwCreateTime);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.dwCreateTime = value.ToFileTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user