Files
2026-07-10 15:25:05 +08:00

101 lines
4.5 KiB
C#

namespace LSFileClient
{
using Microsoft.Win32;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using LSServerService;
internal class ClientManager
{
public static void init(string[] args)
{
// new
string serverIP = "";
string dBName = "";
string isInternet = "0";
string IsConsumer = "0";
//MessageBox.Show("1---------------"+args[0].ToString());
//string inputString = args[0].Replace("^^", " ");
//string inputString = "paramsCount=9|userId=1|type=2|left=100|top=100|width=800|height=500|directoryId=89886|fileIds=39259|mainHandle=3280218|";
//string inputString = @"paramsCount=12|userId=1|type=0|left=100|top=100|width=800|height=500|directoryId=17248|fileIds=|mainHandle=1314908|fileNumber=001|specieNo=01|filePath=D:\LsErpNew\Cs\Debug\TempFiles/001_5e7846e905f14faf934c0c8eaea9bee6.jpg|";
string inputString = @"paramsCount=11|userId=1|type=0|left=100|top=100|width=800|height=500|directoryId=133278|fileIds=|mainHandle=17827900|fileNumber=001|specieNo=0103040202|";
System.Windows.Forms.Clipboard.SetText(inputString);
LSParamsFormatter.bParseResult = LSParamsFormatter.parseParams(inputString);
if (!LSParamsFormatter.bParseResult)
{
MessageBox.Show("参数错误\r\n" + args[0].ToString());
}
else
{
RegistryKey key2 = Registry.CurrentUser.OpenSubKey("AA_ls_Erp V2.0");
if (key2 != null)
{
RegistryKey key3 = key2.OpenSubKey("File");
if (key3 != null)
{
dBName = key3.GetValue("datastr", "").ToString();
serverIP = key3.GetValue("ServerName", "").ToString();
isInternet = key3.GetValue("Internet", "1").ToString();
IsConsumer = key3.GetValue("IsConsumer", "1").ToString();
}
}
if ((serverIP == "") || (dBName == ""))
{
MessageBox.Show("连接服务器参数无效,请联系管理员.");
}
else
{
if (((LSParamsFormatter.commonModel == 9) || (LSParamsFormatter.commonModel == 11)) || (LSParamsFormatter.commonModel == 3) || (LSParamsFormatter.commonModel == 4) || LSParamsFormatter.commonModel == 12)
{
LSGlobleVariable.userId = (uint) LSParamsFormatter.userId;
}
LSClientMain main = new LSClientMain();
main.ProgramEntry(serverIP, dBName, isInternet, IsConsumer);
int num = 0;
while (num < 6)
{
if (main.checkSocketState())
{
break;
}
num++;
Thread.Sleep(300);
}
if (num >= 6)
{
MessageBox.Show("连接服务器失败,请联系管理员.");
SendMessage(LSParamsFormatter.mainHandle, 1305, IntPtr.Zero, IntPtr.Zero);
}
else if ((LSParamsFormatter.commonModel == 9) || (LSParamsFormatter.commonModel == 11) || (LSParamsFormatter.commonModel == 12))
{
Application.Run(new FrmBatchProgress(main, serverIP, dBName, IsConsumer));
}
else if (LSParamsFormatter.commonModel == 2)
{
Application.Run(new frmSingleDownload(main, serverIP, dBName, IsConsumer));
}
else if (LSParamsFormatter.commonModel == 3)
{
Application.Run(new frmSmartClient(main, serverIP, dBName, IsConsumer));
}
else if (LSParamsFormatter.commonModel == 4)
{
Application.Run(new frmDelete(main, serverIP, dBName, IsConsumer));
}
}
}
}
[DllImport("user32.dll")]
protected static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
}
}