272 lines
8.2 KiB
C#
272 lines
8.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace CommonLib
|
|
{
|
|
/// <summary>
|
|
/// 依据父目录最后一层id上传批量文件 ,依据父目录id批量下载,依据多个文件id下载
|
|
/// </summary>
|
|
public enum fmUpdateDownloadType
|
|
{
|
|
upByParentId=0,
|
|
downByParentId=1,
|
|
downByFileIds=2
|
|
}
|
|
|
|
//自定义windows消息号
|
|
public struct LSCustomWinMsg
|
|
{
|
|
|
|
private const int CUSTOM_MESSAGE = 0X9000;
|
|
|
|
/// <summary>
|
|
/// 客户端连接被关闭,正准备关闭窗体
|
|
/// </summary>
|
|
public const int REV_CLIENT_SOCKET_CLOSED = CUSTOM_MESSAGE + 8;
|
|
|
|
/// <summary>
|
|
/// 批量上传关闭窗体之前的通知消息
|
|
/// </summary>
|
|
public const int BATCH_UPLOAD_COMPLETED = CUSTOM_MESSAGE + 9;
|
|
/// <summary>
|
|
/// 下载完成
|
|
/// </summary>
|
|
public const int DOWNLOADCOMPLETED = CUSTOM_MESSAGE + 10;
|
|
/// <summary>
|
|
/// 下载失败
|
|
/// </summary>
|
|
public const int DOWNLOADERROR = CUSTOM_MESSAGE + 11;
|
|
/// <summary>
|
|
/// 下载文件完成后通知消息
|
|
/// </summary>
|
|
public const int SUCCESS_MESSAGE = CUSTOM_MESSAGE + 1;
|
|
|
|
/// <summary>
|
|
/// 接收到客户端发来的窗体句柄
|
|
/// </summary>
|
|
public const int REV_CLIENT_WINDOW_HANDLE = PubUtil.WM_USER + 0x112;
|
|
|
|
/// <summary>
|
|
/// 接收到客户端处理错误消息
|
|
/// </summary>
|
|
public const int REV_CLIENT_DEAL_ERROR = PubUtil.WM_USER + 0x119;
|
|
|
|
/// <summary>
|
|
/// 接收到客户端处理ok消息
|
|
/// </summary>
|
|
public const int REV_CLIENT_DEAL_OK = PubUtil.WM_USER + 0x120;
|
|
}
|
|
|
|
public class TParamsData
|
|
{
|
|
private int _mainHandle;
|
|
private int _userId;
|
|
private fmUpdateDownloadType _type;
|
|
private int _left;
|
|
private int _top;
|
|
private int _width;
|
|
private int _height;
|
|
private int _directoryId;
|
|
private string _filePath;
|
|
private string _fileNumber;
|
|
private string _specieNo;
|
|
private List<int> _fileIds;
|
|
|
|
public TParamsData(IntPtr mainHandle)
|
|
: this(fmUpdateDownloadType.upByParentId, mainHandle)
|
|
{
|
|
|
|
}
|
|
|
|
//用户id,操作类型
|
|
public TParamsData(fmUpdateDownloadType fmType, IntPtr mainHandle)
|
|
{
|
|
_mainHandle = (int)mainHandle;
|
|
_userId = ERPInfo.Instance.EmployeeId;
|
|
_type =fmType;
|
|
|
|
//初始化一些值
|
|
_left = -1;
|
|
_top = -1;
|
|
_width = -1;
|
|
_height = -1;
|
|
_directoryId = -1;
|
|
_fileIds = new List<int>();
|
|
}
|
|
|
|
//设置位置
|
|
public void setLocation(int left, int top)
|
|
{
|
|
_left = left;
|
|
_top = top;
|
|
}
|
|
|
|
//设置宽度高度
|
|
public void setSize(int width, int height)
|
|
{
|
|
_width = width;
|
|
_height = height;
|
|
}
|
|
|
|
//设置父目录
|
|
public void setParent(int directoryId)
|
|
{
|
|
_directoryId = directoryId;
|
|
}
|
|
|
|
// 设置上传文件路径
|
|
public void setFilePath(string filepath)
|
|
{
|
|
_filePath = filepath;
|
|
}
|
|
|
|
//设置文件编码
|
|
public void SetfileNumber(String fileNumber)
|
|
{
|
|
_fileNumber= fileNumber;
|
|
}
|
|
|
|
//设置物料类别编号
|
|
public void SetspecieNo(String specieNo)
|
|
{
|
|
_specieNo=specieNo;
|
|
}
|
|
|
|
//添加文件id
|
|
public void addFileId(int fileId)
|
|
{
|
|
_fileIds.Add(fileId);
|
|
}
|
|
|
|
|
|
///
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string CallUpdateUI()
|
|
{
|
|
String exeFiles = PubUtil.LSTestFileName;
|
|
|
|
string fms = "paramsCount=9|userId={0}|type={1}|left={2}|top={3}|width={4}|height={5}|directoryId={6}|fileIds={7}|mainHandle={8}|";
|
|
|
|
String fileIds ="";
|
|
|
|
for(int i=0;i< _fileIds.Count;i++)
|
|
fileIds += _fileIds[i].ToString()+",";
|
|
|
|
|
|
string strParams = string.Format(fms, _userId, (int)_type, _left, _top, _width, _height, _directoryId, fileIds, _mainHandle) ;
|
|
|
|
PubUtil.WinExec(exeFiles + " " + strParams, 9);
|
|
return strParams;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用外部程序(上传管理增删除,额外指定了文件号和类别号)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public String CallUpdateUIEx()
|
|
{
|
|
String exeFiles = PubUtil.LSTestFileName;
|
|
|
|
string fms = "paramsCount=11|userId={0}|type={1}|left={2}|top={3}|width={4}|height={5}|directoryId={6}|fileIds={7}|mainHandle={8}|fileNumber={9}|specieNo={10}|";
|
|
|
|
String fileIds = "";
|
|
|
|
for (int i = 0; i < _fileIds.Count; i++)
|
|
fileIds += _fileIds[i].ToString() + ",";
|
|
|
|
|
|
string strParams = string.Format(fms, _userId, (int)_type, _left, _top, _width, _height, _directoryId, fileIds, _mainHandle,_fileNumber,_specieNo);
|
|
|
|
PubUtil.WinExec(exeFiles + " " + strParams, 9);
|
|
return strParams;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用外部程序(上传),无窗口
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string CallUploadUIEx()
|
|
{
|
|
string exeFiles = PubUtil.LSTestFileName;
|
|
|
|
// args = new string[] { "paramsCount=5|userId=1|directoryId=1953|mainHandle=676782|specieNo=01|filePath=E:\\工作项目\\朗速源代码(CS)\\publish_crm\\tempfiles\\aaa.jpg" };
|
|
string fms = "paramsCount=12|userId={0}|type={1}|left={2}|top={3}|width={4}|height={5}|directoryId={6}|fileIds={7}|mainHandle={8}|fileNumber={9}|specieNo={10}|filePath={11}";
|
|
|
|
|
|
string strParams = string.Format(fms, _userId, (int)_type, _left, _top, _width, _height, _directoryId, string.Empty, _mainHandle, _fileNumber, _specieNo, _filePath);
|
|
|
|
PubUtil.WinExec(exeFiles + " " + strParams, 12);
|
|
return strParams;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下载
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public String CallDownload(string downloadFileName)
|
|
{
|
|
String exeFiles = PubUtil.LSTestFileName;
|
|
//paramsCount=2|downloadPath=C:\a.txt|mainHandle=123|
|
|
string fms = "paramsCount=2|downloadPath={0}|mainHandle={1}|";
|
|
String fileIds = "";
|
|
for (int i = 0; i < _fileIds.Count; i++)
|
|
fileIds += _fileIds[i].ToString() + ",";
|
|
string strParams = string.Format(fms, downloadFileName.Replace(' ','*'), _mainHandle);
|
|
|
|
PubUtil.WinExec(exeFiles + " " + strParams, 2);
|
|
return strParams;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 启用通讯客户端
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public String CallSmartClient()
|
|
{
|
|
String exeFiles = PubUtil.LSTestFileName;
|
|
//paramsCount=3|classType=frmSmartClient|userId=1|mainHandle=123|
|
|
string fms = "paramsCount=3|classType=frmSmartClient|userId={0}|mainHandle={1}";
|
|
|
|
String fileIds = "";
|
|
|
|
for (int i = 0; i < _fileIds.Count; i++)
|
|
fileIds += _fileIds[i].ToString() + ",";
|
|
|
|
|
|
string strParams = string.Format(fms, _userId, _mainHandle);
|
|
|
|
PubUtil.WinExec(exeFiles + " " + strParams, 9);
|
|
|
|
return strParams;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除附件
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public String CallDeleteFile()
|
|
{
|
|
String exeFiles = PubUtil.LSTestFileName;
|
|
//paramsCount=4|classType=deleteFile|userId=1|mainHandle={1}|fileIds={0}
|
|
string fms = "paramsCount=4|classType=deleteFile|userId={0}|mainHandle={1}|fileIds={2}";
|
|
|
|
String fileIds = "";
|
|
|
|
for (int i = 0; i < _fileIds.Count; i++)
|
|
fileIds += _fileIds[i].ToString() + ",";
|
|
|
|
|
|
string strParams = string.Format(fms, _userId, _mainHandle, fileIds);
|
|
|
|
PubUtil.WinExec(exeFiles + " " + strParams, 9);
|
|
return strParams;
|
|
}
|
|
}
|
|
}
|