コード例 #1
0
ファイル: ImageCache.cs プロジェクト: laszlo-kiss/Dataphor
 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;
         }
     }
 }
コード例 #2
0
 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;
         }
     }
 }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 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();
 }
コード例 #6
0
 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;
         }
     }
 }
コード例 #7
0
ファイル: Node.cs プロジェクト: laszlo-kiss/Dataphor
        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();
        }