123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using DotNettyFrom.config;
-
- namespace DotNettyFrom.common
- {
- [Serializable]
- public class UIInfoModel
- {
- public int action = int.MinValue;
- public string time = DateTime.Now.ToLongTimeString();
- public string info = "";
-
- public string cmd = "";
-
- public int cmdId = int.MinValue;
-
-
- //1 发送的. 0:接收的, -1.日常信息
- public int SendType = SystemConfig.RecType;
-
-
- public UIInfoModel(string info, string cmd)
- {
- this.info = info;
- this.cmd = cmd;
- cmdId = CalcCmdId(cmd);
- }
-
-
- public UIInfoModel(string info)
- {
- this.info = info;
- }
-
- public UIInfoModel setAction(int action)
- {
- this.action = action;
- return this;
- }
-
- public UIInfoModel setSendType(int SendType)
- {
- this.SendType = SendType;
- return this;
- }
-
- public UIInfoModel setCmd(string cmd)
- {
- this.cmd = cmd;
- cmdId = CalcCmdId(cmd);
- return this;
- }
-
-
- public UIInfoModel setInfo(string info)
- {
- this.info = info;
- return this;
- }
-
-
- public override string ToString()
- {
- string res = time + " - ";
- if (!info.Trim().Equals(""))
- {
- res += this.info;
- }
-
- if (!cmd.Trim().Equals(""))
- {
- try
- {
- string cmdIdString = cmd.Substring(SystemConfig.FunctionCodeStartPos, SystemConfig.FunctionCodeLength);
- res += ". cmdId=" + cmdIdString;
- cmdId = CalcCmdId(cmd);
- }
- catch (Exception)
- {
- }
- res += ". cmd=[" + cmd + "]";
- }
- return res + ".";
- }
-
- public int CalcCmdId(string cmd)
- {
- try
- {
- string cmdId = cmd.Substring(SystemConfig.FunctionCodeStartPos, SystemConfig.FunctionCodeLength);
- return int.Parse(cmdId);
- }
- catch (Exception)
- {
- }
- return int.MinValue;
- }
- }
- }
|