private static void UpdateSingleDocument(BSonDoc document, IObjectStore store) { var obj = store.GetById((string)document[DocumentMetadata.IdPropertyName]); BSonDoc val = GetValue(document); foreach (var p in GetRealProperties(val)) // remove properties starting with if (document.HasProperty(p)) obj[p] = val[p]; store.Set(obj); }
public override void OnHandle(IStore store, string collection, BSonDoc command, BSonDoc document) { if (document == null || string.IsNullOrEmpty(collection)) return; IObjectStore st = store.GetCollection(collection); if (document.HasProperty(DocumentMetadata.IdPropertyName)) { UpdateSingleDocument(document, st); return; } if (document.HasProperty(CommandKeyword.Filter)) { UpdateCollection(document, st); return; } st.Set(document); }
public override void OnHandle(IStore store, string collection, BSonDoc command, BSonDoc document) { IObjectStore st = store.GetCollection(collection); if (command.HasProperty(CommandKeyword.Id)) { var ent = st.GetById((string)command[CommandKeyword.Id]); if (ent != null) st.Remove(ent); } if (document != null && document.HasProperty(DocumentMetadata.IdPropertyName)) { var ent = st.GetById((string)document[DocumentMetadata.IdPropertyName]); if (ent != null) st.Remove(ent); } }
private static ICommandHandler[] ChechHandlers(BSonDoc command) { string actionname = string.Empty; if (command.HasProperty(CommandKeyword.Action)) actionname = (command[CommandKeyword.Action] ?? string.Empty).ToString(); LogWriter.LogInformation(string.Format("Executing action {0}", string.Empty), LogEntryType.Information); if (_commandHandlers.ContainsKey(actionname)) return _commandHandlers[actionname].ToArray(); return null; }
private string GetEntityUI(BSonDoc entity) { if (entity.HasProperty(DocumentMetadata.IdPropertyName) && entity[DocumentMetadata.IdPropertyName] != null) return (string)entity[DocumentMetadata.IdPropertyName]; entity[DocumentMetadata.IdPropertyName] = newIdFunction(); return (string)entity[DocumentMetadata.IdPropertyName]; }
protected static BSonDoc GetValue(BSonDoc document) { if (document.HasProperty(CommandKeyword.Value)) return document[CommandKeyword.Value] as BSonDoc; return document; }