/// <summary> /// 呼叫js脚本 /// </summary> /// <param name="scriptstr"></param> /// <param name="input"></param> /// <param name="outputkey"></param> /// <param name="others"></param> /// <returns></returns> public object Call(string scriptstr, FrameDLRObject input, string outputkey, params KeyValuePair <string, object>[] others) { try { var jse = _logic.CallContext_ResourceManage.CreateInstance <HostJs>(); input = input == null?FrameDLRObject.CreateInstance() : input; var lp = others.ToList(); lp.Add(new KeyValuePair <string, object>("input", input.ToDictionary())); jse.Evaluate(scriptstr, lp.ToArray()); var obj = jse.GetOutObject(outputkey); if (obj is Dictionary <string, object> ) { return(FrameDLRObject.CreateInstance((Dictionary <string, object>)obj)); } else { return(obj); } } catch (JavascriptException jex) { var strmsg = new StringBuilder(); strmsg.AppendLine(jex.V8SourceLine); strmsg.AppendLine(jex.V8StackTrace); throw new Exception(strmsg.ToString(), jex); } }
/// <summary> /// 执行一段指令 /// </summary> /// <param name="jsoncmd"></param> /// <param name="outobj"></param> /// <returns></returns> public bool Excute(string jsoncmd, ref FrameDLRObject outobj) { if (server.State == MongoServerState.Disconnected) { server.Reconnect(); } FrameDLRObject cmd = FrameDLRObject.CreateInstance(jsoncmd); var cd = new CommandDocument(cmd.ToDictionary()); var result = database.RunCommand(cd); if (result.Ok) { var value = result.Response.GetValue("value").ToBsonDocument(); value.Remove("_id"); outobj = FrameDLRObject.CreateInstance(value.ToJson()); } return(result.Ok); }
public bool Delete(string collectionname, FrameDLRObject queryjson) { return(Delete(collectionname, queryjson.ToDictionary())); }
public bool Update(string collectionname, string queryjson, FrameDLRObject updatejson) { return(Update(collectionname, ((FrameDLRObject)FrameDLRObject.CreateInstance(queryjson)).ToDictionary(), updatejson.ToDictionary())); }
public bool Update(string collectionname, FrameDLRObject queryjson, FrameDLRObject updatejson) { return(Update(collectionname, queryjson.ToDictionary(), updatejson.ToDictionary())); }
/// <summary> /// select count /// </summary> /// <param name="collectionname"></param> /// <param name="json"></param> /// <returns></returns> public long Count(string collectionname, FrameDLRObject json) { return(Count(collectionname, json.ToDictionary())); }
public List <FrameDLRObject> Query(string collectionname, FrameDLRObject json) { return(Query(collectionname, json.ToDictionary())); }