/// <summary> /// 添加一行数据 /// </summary> /// <param name="bean">对应的数据实体</param> public static void AddOne(DirIndexBean bean) { using (SQLiteCommand cmd = new SQLiteCommand()) { cmd.CommandText = "INSERT INTO [dir_index] VALUES (@path, @incident_id, @target_id);"; cmd.Parameters.Add("path", DbType.String).Value = bean.Path; cmd.Parameters.Add("incident_id", DbType.UInt32).Value = bean.IncidentId; cmd.Parameters.Add("target_id", DbType.UInt64).Value = bean.TargectId; SQLiteClient.Write(cmd); } }
/// <summary> /// 刷新一行数据 /// </summary> /// <param name="bean">对应的数据实体</param> public static void RefreshIndex(DirIndexBean bean) { int n; using (SQLiteCommand cmd = new SQLiteCommand()) { cmd.CommandText = "UPDATE [dir_index] SET [incident_id] = @incident_id, [target_id] = @target_id WHERE [path] = @path;"; cmd.Parameters.Add("path", DbType.String).Value = bean.Path; cmd.Parameters.Add("incident_id", DbType.UInt32).Value = bean.IncidentId; cmd.Parameters.Add("target_id", DbType.UInt64).Value = bean.TargectId; n = SQLiteClient.Write(cmd); } if (n == 0) { AddOne(bean); } }
//通过路径获取最新的记录节点 internal static RecordBean GetLastBean(string path) { DirIndexBean dirIndex = DirIndexMapper.GetOneByPath(path); if (dirIndex == null) { return(null); } RecordBean bean = RecordMapper.GetOneById(dirIndex.TargectId, dirIndex.IncidentId); if (bean == null) { return(null); } //告知该bean是属于哪一个事件的 bean.IncidentId = dirIndex.IncidentId; return(bean); }