public Stream Read(string imageID) { string fileName = BuildFileName(imageID); if (File.Exists(fileName)) return File.OpenRead(fileName); else { FileStream fileStream = new FileStream(fileName, FileMode.CreateNew, FileAccess.ReadWrite); try { object tempValue = _identifiers[imageID]; if (tempValue is String) { using (DAE.Runtime.Data.Scalar scalar = (DAE.Runtime.Data.Scalar)_session.Pipe.RequestDocument((string)tempValue)) StreamUtility.CopyStream(scalar.OpenStream(), fileStream); } else ((GetImageHandler)tempValue)(imageID, fileStream); fileStream.Position = 0; return fileStream; } catch { fileStream.Close(); if (File.Exists(fileName)) File.Delete(fileName); throw; } } }
public void SetImageAccepted(IFormInterface AForm) { FImageSource = (IImageSource)AForm; if (FImageSource.Stream == null) { DataField.ClearValue(); } else { using (DAE.Runtime.Data.Scalar LNewValue = new DAE.Runtime.Data.Scalar(Source.DataView.Process.ValueManager, Source.DataView.Process.DataTypes.SystemGraphic)) { Stream LStream = LNewValue.OpenStream(); try { FImageSource.Stream.Position = 0; StreamUtility.CopyStream(FImageSource.Stream, LStream); } finally { LStream.Close(); } DataField.Value = LNewValue; } } }
public void SetFormDesigner() { using (DAE.Runtime.Data.Scalar nodeTable = DataSession.Evaluate(FormDesignerNodeTypesExpression)) { NodeTypeTable.Clear(); NodeTypeTable.LoadFromString(nodeTable.AsString); } // Load the files required to register any nodes, if necessary if (DataSession.Server is DAE.Server.LocalServer) { IServerCursor cursor = DataSession.OpenCursor(GetFormDesignerLibraryFilesExpression); try { using (DAE.Runtime.Data.IRow row = cursor.Plan.RequestRow()) { bool shouldLoad; List <string> filesToLoad = new List <string>(); while (cursor.Next()) { cursor.Select(row); string fullFileName = ((DAE.Server.LocalServer)DataSession.Server).GetFile ( (DAE.Server.LocalProcess)cursor.Plan.Process, (string)row["Library_Name"], (string)row["Name"], (DateTime)row["TimeStamp"], (bool)row["IsDotNetAssembly"], out shouldLoad ); if (shouldLoad) { filesToLoad.Add(fullFileName); } } // Load each file to ensure they can be reached by the assembly resolver hack (see AssemblyUtility) foreach (string fullFileName in filesToLoad) { Assembly.LoadFrom(fullFileName); } } } finally { DataSession.CloseCursor(cursor); } } }
private IScalar LoadWithCache(string document, IServerProcess process) { IScalar result = null; lock (Cache) { uint cRC32 = Cache.GetCRC32(document); if (cRC32 > 0) { try { result = LoadFromCache(document, process); } catch { result = null; cRC32 = 0; } } using ( DAE.Runtime.Data.Row row = (DAE.Runtime.Data.Row)process.Evaluate ( String.Format ( "LoadIfNecessary('{0}', {1})", document.Replace("'", "''"), ((int)cRC32).ToString() ), null ) ) if (!(bool)row["CRCMatches"]) { using (DAE.Runtime.Data.Scalar value = row.GetValue("Value") as DAE.Runtime.Data.Scalar) { SaveToCache(document, process, value, (uint)(int)row["ActualCRC32"]); result = (DAE.Runtime.Data.Scalar)value.Copy(); } } } return(result); }
public void SetLibrary(string libraryName) { DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams(); paramsValue.Add(DAE.Runtime.DataParam.Create(Pipe.Process, "ALibraryName", libraryName)); using ( DAE.Runtime.Data.Scalar nodeTable = DataSession.Evaluate ( LibraryNodeTypesExpression, paramsValue ) ) { NodeTypeTable.Clear(); NodeTypeTable.LoadFromString(nodeTable.AsString); } ValidateNodeTypeTable(); }
private void InternalLoadFromFile() { if (String.IsNullOrEmpty(_fileName)) { _fileName = PromptForLoadName(); } using (FileStream fileStream = new FileStream(_fileName, FileMode.Open, FileAccess.Read)) { if (fileStream.Length > _maximumContentLength) { throw new ControlsException(ControlsException.Codes.MaximumContentLengthExceeded, fileStream.Length, _maximumContentLength); } using (DAE.Runtime.Data.Scalar newValue = new DAE.Runtime.Data.Scalar(DataSet.Process.ValueManager, DataSet.Process.DataTypes.SystemBinary)) { using (Stream stream = newValue.OpenStream()) StreamUtility.CopyStream(fileStream, stream); DataField.Value = newValue; } } }
protected virtual void Drop() { // Confirm the deletion Frontend.Client.Windows.IWindowsFormInterface form = Dataphoria.FrontendSession.LoadForm ( null, ".Frontend.Form('Frontend', 'DropDependents')" ); try { Frontend.Client.ISource source = (Frontend.Client.ISource)form.FindNode("Dependents"); source.Expression = String.Format ( @" DependentObjects('{0}') over {{ Level, Sequence, Object_Description }} rename {{ Object_Description Description }} order by {{ Level desc, Sequence }} " , ObjectName ); source.Enabled = true; if (form.ShowModal(Frontend.Client.FormMode.Query) != DialogResult.OK) { throw new AbortException(); } } finally { form.HostNode.Dispose(); } // Emit and execute the drop script using (DAE.Runtime.Data.Scalar script = (DAE.Runtime.Data.Scalar)Dataphoria.EvaluateQuery(GetScriptDropExpression())) Dataphoria.ExecuteScript(script.AsString); ParentList.Refresh(); }