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

164 lines
4.7 KiB
C#

namespace LSFileClient
{
using LSServerService;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Data;
[StructLayout(LayoutKind.Sequential, Size = 1)]
internal struct LSParamsFormatter
{
private static int _paramsCount;
public static bool bParseResult;
private static Dictionary<string, string> m_dataDic;
public static bool parseParams(string strParams)
{
try
{
string[] strArray = strParams.Split(new char[] { '|', '=' }, StringSplitOptions.None);
if (strArray.Length <= 2)
{
return false;
}
if (strArray[0] != "paramsCount")
{
return false;
}
_paramsCount = int.Parse(strArray[1]);
for (int i = 2; i < (strArray.Length - 1); i += 2)
{
m_dataDic.Add(strArray[i], strArray[i + 1]);
}
if (m_dataDic.Count != _paramsCount)
{
return false;
}
return true;
}
catch (Exception exception)
{
PubUtils.WriteLog("error: {0}", new object[] { exception });
}
return false;
}
public static int paramsCount
{
get
{
return _paramsCount;
}
}
public static int userId
{
get
{
return int.Parse(m_dataDic["userId"]);
}
}
public static string fileNumber
{
get
{
return m_dataDic["fileNumber"];
}
}
public static string filePath
{
get
{
return m_dataDic["filePath"];
}
}
public static string specieNo
{
get
{
return m_dataDic["specieNo"];
}
}
public static fmTypes type
{
get
{
return (fmTypes)Enum.Parse(typeof(fmTypes), m_dataDic["type"]);
}
}
public static int[] fileIds
{
get
{
string[] strArray = m_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;
}
}
public static int directoryId
{
get
{
return int.Parse(m_dataDic["directoryId"]);
}
}
public static void setPosistion(FrmBase frm)
{
frm.Left = int.Parse(m_dataDic["left"]);
frm.Top = int.Parse(m_dataDic["top"]);
frm.Width = int.Parse(m_dataDic["width"]);
frm.Height = int.Parse(m_dataDic["height"]);
}
public static IntPtr mainHandle
{
get
{
return new IntPtr(int.Parse(m_dataDic["mainHandle"]));
}
}
public static int commonModel
{
get
{
return _paramsCount;
}
}
public static string downloadPath
{
get
{
return m_dataDic["downloadPath"].Replace('*', ' ');
}
}
public static string serverPath;
public static string savePath
{
get
{
//string url = !string.IsNullOrEmpty(downloadPath) ? downloadPath.Replace(Path.GetFileName(downloadPath), "").Replace(serverPath, "") : "";
string str = downloadPath.Replace(Path.GetFileName(downloadPath), "").Replace(serverPath, "");
string path = Environment.CurrentDirectory + "//tempfiles//" + str;
//string path = Environment.CurrentDirectory + "//tempfiles//";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string fileName = Path.GetFileName(downloadPath);
return (path + fileName);
}
}
static LSParamsFormatter()
{
_paramsCount = 0;
bParseResult = true;
m_dataDic = new Dictionary<string, string>();
}
}
}