public string AddDb(ParameterEntity pe) { var key = pe.Hash(); if (HasRegistered(key)) { return(key); } receiverMap.Add(key, new Subject <ResultEntity>()); if (!SearchDb(key)) { logger?.LogInformation($"{key}.sqlite not found. Ptolemy.Hydra will create"); } var db = new WriteOnlySqliteRepository(GetDbPath(pe)); db.UpdateParameter(pe); // add upsert observer receiverMap[key].Synchronize().Buffer(bufferSize).Subscribe(list => { if (token.IsCancellationRequested) { logger?.LogError("Cancel was requested. Ptolemy.Hydra give up write entity to {key}.sqlite"); } db.BulkUpsert(list); logger?.LogInformation($"{list.Count} entities upsert to {key}.sqlite"); }, token); return(key); }
/// <summary> /// update parameter information /// </summary> /// <param name="pe"></param> public void UpdateParameter(ParameterEntity pe) { pe.Id = 1; if (!context.ParameterEntities.Any()) { context.ParameterEntities.Add(pe); } context.SaveChanges(); }
public void CloseDb(ParameterEntity pe) => CloseDb(pe.Hash());
private string GetDbPath(ParameterEntity pe) => GetDbPath(pe.Hash());