/// <summary> /// Read a list of variables value from the DB cache given their names. /// Note: this function is not async, since liteDB do not support it yet. /// </summary> /// <param name="names">List of names of the variables</param> /// <param name="status">Status of the transaction, "Ok" if good, else see <see cref="ReadStatusCode"/> </param> /// <returns>Returns a list of dbVariable</returns> public dbVariableValue[] readValue(string[] names, out ReadStatusCode status) { BsonArray bson_arr = new BsonArray(); foreach (string name in names) { bson_arr.Add(name); } dbVariableValue[] read_var = latestValues.Find(Query.In("name", bson_arr)).ToArray(); if (read_var.Count() != names.Length) { status = ReadStatusCode.VariableNotFoundInDB; string l = ""; List <dbVariableValue> values = read_var.ToList(); foreach (var v in names) { if (values.Find(x => x.name == v) == null) { l += v + ", "; } } logger.Warn("Some of the varibles requested to read were not found: " + l); } else { status = ReadStatusCode.Ok; } return(read_var); }
/// <summary> /// Read a list of variables value from the DB cache given their names. /// Note: this function is not async, since liteDB do not support it yet. /// </summary> /// <param name="names">List of names of the variables</param> /// <param name="status">Status of the transaction, "Ok" if good, else see <see cref="ReadStatusCode"/> </param> /// <returns>Returns a list of dbVariable</returns> public dbVariableValue[] readValueFromCache(string[] names, out ReadStatusCode status) { return(db.readValue(names, out status)); }