/****************************** * 说明:参数处理类 * 创建人:龚宇超 * 创建日期: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 { /// /// 参数处理类 /// internal struct ParamFormatter { private static Dictionary _dataDic = new Dictionary(); /// /// 参数处理结果(成功与否) /// public static bool ParseResult; /// /// 传入参数个数 /// /// The parameter count. public static int ParamCount { get; private set; } /// /// 附件目录ID /// /// The directory identifier. public static int DirectoryId { get { try { Convert.ToInt32(_dataDic["directoryId"]); } catch (Exception) { } return 0; } } /// /// 附件前缀 /// /// The file number. public static string FileNumber { get { return _dataDic["fileNumber"]; } } /// /// 附件路径 /// /// The file path. public static string FilePath { get { return _dataDic["filePath"]; } } /// /// 附件编号 /// /// The species no. public static string SpeciesNo { get { return _dataDic["SpeciesNo"]; } } /// /// 附件下载路径 /// /// Down load path. public static string DownLoadPath { get { return _dataDic["downloadPath"].Replace('*', ' '); } } /// /// 附件下载存放路径 /// /// The save local path. public static string SaveLocalPath { get { return PubUtil.FileDownLoadTempPath + Path.GetFileName(DownLoadPath); } } /// /// 附件操作类型 /// /// The type of the attach. public static AttachType AttachType { get { return (AttachType)Convert.ToInt32(_dataDic["type"]); } } /// /// 附件ID集合 /// /// The file ids. 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; } } /// /// 消息句柄 /// /// The handler. public static IntPtr Handler { get { return new IntPtr(int.Parse(_dataDic["mainHandle"])); } } static ParamFormatter() { } /// /// 说明:处理参数 /// 创建人:龚宇超 /// 创建日期:2018-01-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The arguments. 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); } } } }