private void Excute(TraceItem item) { Log log = item.ToLog(); if (mqttServer == null || mqttServer.IsRuning == false) { return; } PublishData data = new PublishData() { topic = this.logNewsTopic, data = log }; if (!data.ToPayLoad()) { return; } Task task = this.mqttServer.Publish(data); try { task.Wait(5000);// 外面加上超时判断,防止一条发送失败,后面一直卡死 } catch { } //JsonConvert.DeserializeObject<PumpJZ>(); }
private void Record(TraceItem item) { Log log = item.ToLog(); string id = Guid.NewGuid().ToString(); string sql = string.Format(@"insert into {0} (类型,信息文本,插入时间,系统名称) values ('{1}',""{2}"",""{3}"",""{4}"")", this.tableName, log.type, log.text, log.dateTime, log.serverName); this.sqLite.ExecuteNonQuery(sql); }
public static void RecordDisPatchLog(TraceItem item) { if (!DisPatchRecordEnvFlag) { return; } try { SQLiteHelper sqLite = new SQLiteHelper(fileFullPath); Log log = item.ToLog(); string id = Guid.NewGuid().ToString(); string sql = string.Format(@"insert into {0} (类型,信息文本,插入时间,系统名称) values ('{1}',""{2}"",""{3}"",""{4}"")", logTableName, log.type, log.text, log.dateTime, log.serverName); sqLite.ExecuteNonQuery(sql); } catch { } }