基线 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 插入列表数据执行完毕.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user