public RexProSession StartSession() { var request = new SessionRequest(this.settings); var response = this.SendRequest <SessionRequest, SessionResponse>(request, MessageType.SessionRequest); var session = new RexProSession(this, response.Session); var sessionGuid = new Guid(response.Session); SessionStreams.GetOrAdd(sessionGuid, _ => NewTcpClient().GetStream()); session.Kill += (sender, args) => { while (SessionStreams.ContainsKey(sessionGuid)) { NetworkStream stream; if (SessionStreams.TryRemove(sessionGuid, out stream)) { stream.Close(); stream.Dispose(); } else { Thread.SpinWait(10); } } }; return(session); }
public ScriptResponse <T> ExecuteScript <T>(ScriptRequest script, RexProSession session = null, bool transaction = true) { script.Meta.InSession = session != null; script.Meta.Isolate = session == null; script.Meta.Transaction = transaction; script.Session = session; if (session == null) { if (script.Meta.GraphName == null) { script.Meta.GraphName = this.settings.GraphName; } if (script.Meta.GraphObjectName == null) { script.Meta.GraphObjectName = this.settings.GraphObjectName; } } return(this.SendRequest <ScriptRequest, ScriptResponse <T> >(script, MessageType.ScriptRequest)); }
public T Query <T>(string script, Dictionary <string, object> bindings = null, RexProSession session = null, bool transaction = true) { var request = new ScriptRequest(script, bindings); return(this.ExecuteScript <T>(request, session, transaction).Result); }
public void KillSession(RexProSession session) { var request = new SessionRequest(this.settings, session, true); this.SendRequest <SessionRequest, SessionResponse>(request, MessageType.SessionRequest); }
public ScriptResponse ExecuteScript(ScriptRequest script, RexProSession session = null, bool transaction = true) { return(this.ExecuteScript <object>(script, session, transaction)); }