/// <summary> Executes a D4 script. </summary> public static void ExecuteScript(string script, IServer server, SessionInfo sessionInfo) { IServerSession session = server.Connect(sessionInfo); try { IServerProcess process = session.StartProcess(new ProcessInfo(sessionInfo)); try { IServerScript localScript = process.PrepareScript(script); try { localScript.Execute(null); } finally { process.UnprepareScript(localScript); } } finally { session.StopProcess(process); } } finally { server.Disconnect(session); } }
private void CatalogLookupFailed(Schema.Catalog catalog, string name) { #if LOGCACHEEVENTS FSession.FServer.FInternalServer.LogMessage(String.Format("Retrieving catalog for '{0}'.", AName)); #endif // A cache miss forces the retrieval of the datatype and its dependencies from the remote server process long cacheTimeStamp; long clientCacheTimeStamp; bool cacheChanged; string stringValue = _process.GetCatalog(name, out cacheTimeStamp, out clientCacheTimeStamp, out cacheChanged); // Ensure that the local cache is consistent before adding to the cache if (cacheChanged) { try { _session._server.WaitForCacheTimeStamp(this, clientCacheTimeStamp - 1); _session._server.AcquireCacheLock(this, LockMode.Exclusive); try { _session._server.EnsureCacheConsistent(cacheTimeStamp); if (stringValue != String.Empty) { IServerScript script = ((IServerProcess)_internalProcess).PrepareScript(stringValue); try { script.Execute(null); } finally { ((IServerProcess)_internalProcess).UnprepareScript(script); } } } finally { _session._server.ReleaseCacheLock(this, LockMode.Exclusive); } } catch (Exception E) { // Notify the server that the client cache is out of sync Execute(".System.UpdateTimeStamps();", null); E = new ServerException(ServerException.Codes.CacheDeserializationError, E, clientCacheTimeStamp); _session._server._internalServer.LogError(E); throw E; } finally { _session._server.SetCacheTimeStamp(this, clientCacheTimeStamp); } } }
public void RunScript(ServerProcess process, string script, string libraryName, DAE.Debug.DebugLocator locator) { if (libraryName != String.Empty) { process.ServerSession.CurrentLibrary = process.CatalogDeviceSession.ResolveLoadedLibrary(libraryName); } IServerScript localScript = ((IServerProcess)process).PrepareScript(script, locator); try { localScript.Execute(null); } finally { ((IServerProcess)process).UnprepareScript(localScript); } }
/// <summary>Executes the given script using the given process.</summary> public void ExecuteScript(IServerProcess process, string script, DAE.Runtime.DataParams paramsValue) { if (script != String.Empty) { CheckActive(); if (process == null) { process = UtilityProcess; } IServerScript localScript = process.PrepareScript(script); try { localScript.Execute(paramsValue); } finally { process.UnprepareScript(localScript); } } }
private Schema.IDataType GetDataType() { bool timeStampSet = false; try { LocalServer.WaitForCacheTimeStamp(_process, _descriptor.CacheChanged ? _descriptor.ClientCacheTimeStamp - 1 : _descriptor.ClientCacheTimeStamp); LocalServer.AcquireCacheLock(_process, _descriptor.CacheChanged ? LockMode.Exclusive : LockMode.Shared); try { if (_descriptor.CacheChanged) { LocalServer.EnsureCacheConsistent(_descriptor.CacheTimeStamp); try { if (_descriptor.Catalog != String.Empty) { IServerScript script = ((IServerProcess)_process._internalProcess).PrepareScript(_descriptor.Catalog); try { script.Execute(_params); } finally { ((IServerProcess)_process._internalProcess).UnprepareScript(script); } } } finally { LocalServer.SetCacheTimeStamp(_process, _descriptor.ClientCacheTimeStamp); timeStampSet = true; } } if (LocalServer.Catalog.ContainsName(_descriptor.ObjectName)) { Schema.Object objectValue = LocalServer.Catalog[_descriptor.ObjectName]; if (objectValue is Schema.TableVar) { _tableVar = (Schema.TableVar)objectValue; Plan plan = new Plan(_process._internalProcess); try { if (_params != null) { foreach (DataParam param in _params) { plan.Symbols.Push(new Symbol(param.Name, param.DataType)); } } foreach (DataParam param in _process._internalProcess.ProcessLocals) { plan.Symbols.Push(new Symbol(param.Name, param.DataType)); } _tableNode = (TableNode)Compiler.EmitTableVarNode(plan, _tableVar); } finally { plan.Dispose(); } _dataType = _tableVar.DataType; } else { _dataType = (Schema.IDataType)objectValue; } } else { try { Plan plan = new Plan(_process._internalProcess); try { _dataType = Compiler.CompileTypeSpecifier(plan, new DAE.Language.D4.Parser().ParseTypeSpecifier(_descriptor.ObjectName)); } finally { plan.Dispose(); } } catch { // Notify the server that the client cache is out of sync Process.Execute(".System.UpdateTimeStamps();", null); throw; } } return(_dataType); } finally { LocalServer.ReleaseCacheLock(_process, _descriptor.CacheChanged ? LockMode.Exclusive : LockMode.Shared); } } catch (Exception E) { // Notify the server that the client cache is out of sync Process.Execute(".System.UpdateTimeStamps();", null); E = new ServerException(ServerException.Codes.CacheDeserializationError, E, _descriptor.ClientCacheTimeStamp); LocalServer._internalServer.LogError(E); throw E; } finally { if (!timeStampSet) { LocalServer.SetCacheTimeStamp(_process, _descriptor.ClientCacheTimeStamp); } } }