public static RES OK(object data, 数据类型 dataType, string msg = "成功") { var res = new RES(); res.SUCCESS = true; if (null != data && dataType == 数据类型.ByteArray) { var dataStr = string.Empty; if (typeof(string) == data.GetType()) { res.DATA = Encoding.UTF8.GetBytes(data.ToString()); } else { res.DATA = Encoding.UTF8.GetBytes(JSON.ToJson(data)); } } else if (null == data && dataType == 数据类型.ByteArray) { res.DATA = new byte[1]; } res.MESSAGE = msg; res.DataType = (int)dataType; return(res); }
public static RES FAIL(Exception ex, 数据类型 dataType) { var res = new RES(); res.SUCCESS = false; res.DATA = $"{ex.Message}\t{((null == ex.InnerException) ? string.Empty : ex.InnerException.Message)}"; var msg = $"{ex.Message}\t{((null == ex.InnerException) ? string.Empty : ex.InnerException.Message)}"; if (dataType == 数据类型.ByteArray) { res.DATA = Encoding.UTF8.GetBytes(msg); } else { } res.MESSAGE = "发生异常"; res.DataType = (int)dataType; return(res); }
public 网络数据标识 发送(数据类型 类型) { return(new 网络数据标识(网络ID, 类型, 编号)); }
public 网络数据标识(int 网络ID, 数据类型 类型, int 编号) { this.网络ID = 网络ID; this.类型 = (int)类型; this.编号 = 编号; }