/// <summary> 获取在线客户端 /// </summary> /// <param name="dr">数据行</param> /// <param name="dbName">帐套</param> /// <returns></returns> private static ClientProtocol GetProtocol(DataRow dr,string dbName) { if (!htTable.ContainsValue(dr.Table.TableName)) { return null; } ClientProtocol cp = new ClientProtocol(); cp.StationId = GlobalStaticObj_Server.Instance.StationID; //根据表名得到子消息ID cp.SubMessageId = htTable[dr.Table.TableName].ToString(); cp.TimeSpan = TimeHelper.GetTimeInMillis(); //Json对象 string json = JsonHelper.DataTableToJson(dr, cp.StationId, dbName,true); json = BaseCodeHelper.EnCode(json); cp.Json = json; return cp; }
/// <summary> 获取在线客户端 /// </summary> /// <param name="dr">数据行</param> /// <param name="dbName">帐套</param> /// <returns></returns> private static ClientProtocol GetProtocol(DataRow dr, string dbName) { if (!htTable.ContainsKey(dr.Table.TableName)) { return null; } ClientProtocol cp = new ClientProtocol(); cp.StationId = GlobalStaticObj_Server.Instance.StationID; //根据表名得到子消息ID if (htTable[dr.Table.TableName] is ProtocolValue) { cp.SubMessageId = (htTable[dr.Table.TableName] as ProtocolValue).MessageId; } else { cp.SubMessageId = htTable[dr.Table.TableName].ToString(); } cp.TimeSpan = TimeHelper.GetTimeInMillis(); var sb = new StringBuilder(); foreach (var item in dr.ItemArray) { sb.Append(item); } LogAssistant.LogService.WriteLog(sb); //Json对象 string json = JsonHelper.DataTableToJson(dr, cp.StationId, dbName, false); json = BaseCodeHelper.EnCode(json); cp.Json = json; return cp; }
/// <summary> 写入错误日志 /// </summary> /// <param name="protocol">上传数据协议</param> public static void WriteErrorLog(ClientProtocol protocol) { string msg = string.Empty; if (htTable.ContainsKey(protocol.SubMessageId)) { string tableName = string.Empty; //表名: foreach (DictionaryEntry de in htTable) { if (de.Value.ToString() == protocol.SubMessageId) { tableName = de.Key.ToString(); break; } } msg += "表名:" + tableName + "\r\n"; } msg += "标识:" + protocol.StationId + protocol.SerialNumber + protocol.TimeSpan + "\r\n"; msg += "时间:" + TimeHelper.MillisToTime(protocol.TimeSpan) + "\r\n"; msg += "服务站ID:" + protocol.StationId + "\r\n"; msg += "内容:" + ProtocolTranslator.SerilizeMessage(protocol); //写错误日志 Log.writeCloudLog(msg); }