Exemplo n.º 1
0
		public void EngineExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
		{
			bool assemblyLoaded = false;
			try 
			{
				this.Cleanup();
				this._codeSegment = segment;
				
				assemblyLoaded = this.LoadAssembly(context);
				if (assemblyLoaded && !HasErrors) 
				{
					this._currentObject = InstantiateClass( CurrentAssembly, typeof(_DotNetScriptGui), context );

					if (this._currentObject is _DotNetScriptGui)
					{
						this._interfaceObject = this._currentObject as _DotNetScriptGui;
						this._interfaceObject.Setup();
					}
				
					if (context.Gui.ShowGui || context.Gui.ForceDisplay)
					{
						OnShowGUI(context.Gui);
					}
					this._assemblyStack.Pop();
					assemblyLoaded = false;
				}
			}
			catch (Exception ex)
			{
				this.Cleanup( assemblyLoaded );

				throw ex;
			}
		}
        public void EngineExecuteCode(IZeusCodeSegment segment, IZeusContext context)
        {
            bool assemblyLoaded = false;

            try
            {
                this.Cleanup();
                this._codeSegment = segment;

                assemblyLoaded = this.LoadAssembly(context);
                if (assemblyLoaded && !HasErrors)
                {
                    this._currentObject = InstantiateClass(CurrentAssembly, typeof(_DotNetScriptTemplate), context);

                    if (this._currentObject is _DotNetScriptTemplate)
                    {
                        this._primaryObject = this._currentObject as _DotNetScriptTemplate;
                        this._primaryObject.Render();
                    }
                    this._assemblyStack.Pop();
                    assemblyLoaded = false;
                }
            }
            catch (Exception ex)
            {
                this.Cleanup(assemblyLoaded);
                log.Error(ex);
                throw ex;
            }
        }
        public void EngineExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
        {
            bool assemblyLoaded = false;

            try
            {
                this.Cleanup();
                this._codeSegment = segment;

                assemblyLoaded = this.LoadAssembly(context);
                if (assemblyLoaded && !HasErrors)
                {
                    this._currentObject = InstantiateClass(CurrentAssembly, typeof(_DotNetScriptGui), context);

                    if (this._currentObject is _DotNetScriptGui)
                    {
                        this._interfaceObject = this._currentObject as _DotNetScriptGui;
                        this._interfaceObject.Setup();
                    }

                    if (context.Gui.ShowGui || context.Gui.ForceDisplay)
                    {
                        OnShowGUI(context.Gui);
                    }
                    this._assemblyStack.Pop();
                    assemblyLoaded = false;
                }
            }
            catch (Exception ex)
            {
                this.Cleanup(assemblyLoaded);

                throw ex;
            }
        }
Exemplo n.º 4
0
        static protected bool ExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
        {
            IZeusExecutionHelper helper = segment.ZeusScriptingEngine.ExecutionHelper;

            // If the template has an interface block, execute it
            if (!segment.IsEmpty)
            {
                ArrayList reqVars = segment.ITemplate.RequiredInputVariables;

                if (!context.Input.Contains(reqVars))
                {
                    try
                    {
                        helper.EngineExecuteGuiCode(segment, context);

                        if (helper.HasErrors)
                        {
                            IZeusExecutionError[] errors = helper.Errors;
                            helper.ClearErrors();
                            throw new ZeusExecutionException(segment.ITemplate, errors, false);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new ZeusRuntimeException(segment.ITemplate, ex, false);
                    }
                }

                context.Input.AddItems(context.Gui);
            }

            return(!context.Gui.IsCanceled);
        }
Exemplo n.º 5
0
        public string ParseCustomTag(IZeusCodeSegment segment, string text)
        {
            ArrayList extraData = segment.ExtraData;
            string    data = null, path = null;
            string    returnValue = string.Empty;

            if (text.StartsWith(INCLUDE_FILE_COMPILE))
            {
                data        = text.Substring(INCLUDE_FILE_COMPILE.Length).Trim();
                path        = DotNetScriptEngine.MakeAbsolute(data, segment.ITemplate.FilePath);
                returnValue = this.IncludeFileCompile(path);
            }
            else if (text.StartsWith(INCLUDE_FILE))
            {
                data        = text.Substring(INCLUDE_FILE.Length).Trim();
                path        = DotNetScriptEngine.MakeAbsolute(data, segment.ITemplate.FilePath);
                returnValue = this.IncludeFile(path);
            }
            else if (text.StartsWith(COMPILER_VERSION))
            {
                data = text.Substring(COMPILER_VERSION.Length).Trim();
                this.SetCompilerVersion(data, extraData);
            }
            else if (text.StartsWith(COMPILER_VERSION_ALT))
            {
                data = text.Substring(COMPILER_VERSION_ALT.Length).Trim();
                this.SetCompilerVersion(data, extraData);
            }
            else if (text.StartsWith(INCLUDE_REFERENCE))
            {
                data = text.Substring(INCLUDE_REFERENCE.Length).Trim();
                this.IncludeReference(data, extraData);
            }
            else if (text.StartsWith(INCLUDE_REFERENCE_ALT))
            {
                data = text.Substring(INCLUDE_REFERENCE_ALT.Length).Trim();
                this.IncludeReference(data, extraData);
            }
            else if (text.StartsWith(INCLUDE_NAMESPACE))
            {
                data = text.Substring(INCLUDE_NAMESPACE.Length).Trim();
                this.IncludeNamespace(data, extraData);
            }
            else if (text.StartsWith(INCLUDE_NAMESPACE_ALT))
            {
                data = text.Substring(INCLUDE_NAMESPACE_ALT.Length).Trim();
                this.IncludeNamespace(data, extraData);
            }
            else if (text.StartsWith(INCLUDE_DEBUG))
            {
                extraData.Add(new string[2] {
                    DotNetScriptEngine.DEBUG, Boolean.TrueString
                });
            }

            return(returnValue);
        }
Exemplo n.º 6
0
        public string GetCustomHeaderCode(IZeusCodeSegment segment, IZeusIntrinsicObject[] iobjs)
        {
            bool      isGui   = (segment.SegmentType == ZeusConstants.CodeSegmentTypes.GUI_SEGMENT);
            ArrayList imports = new ArrayList();

            imports.Add("System");
            imports.Add("System.Collections");
            imports.Add("Zeus");
            imports.Add("Zeus.Data");
            imports.Add("Zeus.DotNetScript");
            if (isGui)
            {
                imports.Add("Zeus.UserInterface");
            }

            foreach (string tns in Zeus.Configuration.ZeusConfig.Current.TemplateNamespaces)
            {
                if (!imports.Contains(tns))
                {
                    imports.Add(tns);
                }
            }

            foreach (IZeusIntrinsicObject obj in iobjs)
            {
                if (!obj.Disabled)
                {
                    if (obj.Namespace != null)
                    {
                        if (!imports.Contains(obj.Namespace))
                        {
                            imports.Add(obj.Namespace);
                        }
                    }
                }
            }

            ArrayList tmpExtraData = segment.ExtraData;

            string[] array;
            foreach (object obj in tmpExtraData)
            {
                if (obj is String[])
                {
                    array = (string[])obj;
                    if ((array.Length == 2) && (array[0] == DotNetScriptEngine.USE_NAMESPACE))
                    {
                        if (!imports.Contains(array[1]))
                        {
                            imports.Add(array[1]);
                        }
                    }
                }
            }

            return(this._engine.BuildImportStatments(segment.Language, imports));
        }
Exemplo n.º 7
0
        public string ParseCustomTag(IZeusCodeSegment segment, string text)
        {
            string        data = null, path = null;
            string        returnValue = string.Empty;
            CustomTagType type        = CustomTagType.None;

            if (text.StartsWith(INCLUDE_SCRIPT))
            {
                data = text.Substring(INCLUDE_SCRIPT.Length).Trim();
                type = CustomTagType.IncludeScript;
            }
            else if (text.StartsWith(INCLUDE_SCRIPT_ALT))
            {
                data = text.Substring(INCLUDE_SCRIPT_ALT.Length).Trim();
                type = CustomTagType.IncludeScript;
            }
            else if (text.StartsWith(INCLUDE_TEMPLATE))
            {
                data = text.Substring(INCLUDE_TEMPLATE.Length).Trim();
                type = CustomTagType.IncludeTemplate;
            }
            else if (text.StartsWith(INCLUDE_TEMPLATE_ALT))
            {
                data = text.Substring(INCLUDE_TEMPLATE_ALT.Length).Trim();
                type = CustomTagType.IncludeTemplate;
            }
            else if (text.StartsWith(INCLUDE_FILE))
            {
                data = text.Substring(INCLUDE_FILE.Length).Trim();
                type = CustomTagType.IncludeFile;
            }
            else if (text.StartsWith(INCLUDE_FILE_ALT))
            {
                data = text.Substring(INCLUDE_FILE_ALT.Length).Trim();
                type = CustomTagType.IncludeFile;
            }

            switch (type)
            {
            case CustomTagType.IncludeFile:
                //TODO: Not yet implemented
                break;

            case CustomTagType.IncludeTemplate:
                path        = MicrosoftScriptEngine.MakeAbsolute(data, segment.ITemplate.FilePath);
                returnValue = this.IncludeTemplate(segment.ITemplate, path);
                break;

            case CustomTagType.IncludeScript:
                path        = MicrosoftScriptEngine.MakeAbsolute(data, segment.ITemplate.FilePath);
                returnValue = this.IncludeScript(path, false);
                break;
            }

            return(returnValue);
        }
		public string ParseCustomTag(IZeusCodeSegment segment, string text)
		{
			ArrayList extraData = segment.ExtraData;
			string data = null, path = null;
			string returnValue = string.Empty;

            if (text.StartsWith(INCLUDE_FILE_COMPILE))
            {
                data = text.Substring(INCLUDE_FILE_COMPILE.Length).Trim();
                path = DotNetScriptEngine.MakeAbsolute(data, segment.ITemplate.FilePath);
                returnValue = this.IncludeFileCompile(path);
            }
			else if (text.StartsWith(INCLUDE_FILE))
			{
				data = text.Substring(INCLUDE_FILE.Length).Trim();
				path = DotNetScriptEngine.MakeAbsolute(data, segment.ITemplate.FilePath);
				returnValue = this.IncludeFile(path);
            }
            else if (text.StartsWith(COMPILER_VERSION))
            {
                data = text.Substring(COMPILER_VERSION.Length).Trim();
                this.SetCompilerVersion(data, extraData);
            }
            else if (text.StartsWith(COMPILER_VERSION_ALT))
            {
                data = text.Substring(COMPILER_VERSION_ALT.Length).Trim();
                this.SetCompilerVersion(data, extraData);
            }
			else if (text.StartsWith(INCLUDE_REFERENCE))
			{
				data = text.Substring(INCLUDE_REFERENCE.Length).Trim();
				this.IncludeReference(data, extraData);
			}
			else if (text.StartsWith(INCLUDE_REFERENCE_ALT))
			{
				data = text.Substring(INCLUDE_REFERENCE_ALT.Length).Trim();
				this.IncludeReference(data, extraData);
			}
			else if (text.StartsWith(INCLUDE_NAMESPACE))
			{
				data = text.Substring(INCLUDE_NAMESPACE.Length).Trim();
				this.IncludeNamespace(data, extraData);
			}
			else if (text.StartsWith(INCLUDE_NAMESPACE_ALT))
			{
				data = text.Substring(INCLUDE_NAMESPACE_ALT.Length).Trim();
				this.IncludeNamespace(data, extraData);
			}
			else if (text.StartsWith(INCLUDE_DEBUG))
			{
				extraData.Add(new string[2] { DotNetScriptEngine.DEBUG, Boolean.TrueString });
			}
			
			return returnValue;
		}
Exemplo n.º 9
0
 public string GetCustomFooterCode(IZeusCodeSegment segment, IZeusIntrinsicObject[] iobjs)
 {
     if (segment.SegmentType == ZeusConstants.CodeSegmentTypes.GUI_SEGMENT)
     {
         return(this._engine.BuildGuiClass(segment.Language, iobjs));
     }
     else
     {
         return(this._engine.BuildBodyClass(segment.Language, iobjs));
     }
 }
Exemplo n.º 10
0
        static internal bool ExecuteCodeSegment(IZeusCodeSegment segment, IZeusContext context)
        {
            bool returnValue = true;

            if (context == null)
            {
                context = new ZeusContext();
            }
            PopulateContextObjects(context as ZeusContext);

            //Push this template onto the template stack
            if (context is ZeusContext)
            {
                ((ZeusContext)context).TemplateStack.Push(segment.ITemplate);
            }

            if (segment.SegmentType == ZeusConstants.CodeSegmentTypes.GUI_SEGMENT)
            {
                foreach (IZeusContextProcessor processor in ZeusFactory.Preprocessors)
                {
                    processor.Process(context);
                }

                returnValue = ZeusExecutioner.ExecuteGuiCode(segment, context);
            }
            else
            {
                ZeusExecutioner.ExecuteCode(segment, context);
            }

            //Pop the template from the template stack
            if (context is ZeusContext)
            {
                ((ZeusContext)context).TemplateStack.Pop();
            }
            return(returnValue);
        }
Exemplo n.º 11
0
		public void EngineExecuteCode(IZeusCodeSegment segment, IZeusContext context)
		{
			bool assemblyLoaded = false;
			try 
			{
				this.Cleanup();
				this._codeSegment = segment;
			
				assemblyLoaded = this.LoadAssembly(context);
				if (assemblyLoaded && !HasErrors) 
				{
					this._currentObject = InstantiateClass( CurrentAssembly, typeof(_DotNetScriptTemplate), context );

					if (this._currentObject is _DotNetScriptTemplate)
					{
						this._primaryObject = this._currentObject as _DotNetScriptTemplate;
						this._primaryObject.Render();
					}
					this._assemblyStack.Pop();
					assemblyLoaded = false;
				}
			}
			catch (Exception ex)
			{
				this.Cleanup( assemblyLoaded );
				throw ex;
			}
        }
Exemplo n.º 12
0
        public void EngineExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
        {
            // If the template has an interface block, execute it
            if (!segment.IsEmpty)
            {
                if (!HasErrors)
                {
                    int step = 0;
                    try
                    {
                        MicrosoftScriptControl.Timeout       = (_timeout == -1 ? MSScriptControl.ScriptControlConstants.NoTimeout : (_timeout * 1000));
                        MicrosoftScriptControl.Language      = segment.Language;
                        MicrosoftScriptControl.AllowUI       = true;
                        MicrosoftScriptControl.UseSafeSubset = false;
                        MicrosoftScriptControl.Reset();
                        MicrosoftScriptControl.AddObject("input", context.Input, true);
                        MicrosoftScriptControl.AddObject("context", context, true);

                        foreach (string key in context.Objects.Keys)
                        {
                            if (key != "input")
                            {
                                MicrosoftScriptControl.AddObject(key, context.Objects[key], true);
                            }
                        }

                        step = 1;

                        MicrosoftScriptControl.AddCode(segment.Code);

                        step = 2;

                        object[] paramList = new object[0];

                        object tmpReturn = MicrosoftScriptControl.Run(GUI_ENTRY_NAME, ref paramList);

                        if (context.Gui.ShowGui || context.Gui.ForceDisplay)
                        {
                            OnShowGUI(context.Gui);
                        }
                    }
                    catch (System.Runtime.InteropServices.COMException)
                    {
                        MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                        if (step < 2)
                        {
                            error.IsRuntime = false;
                        }
                        this.AddError(error);
                    }
                    catch (Exception ex)
                    {
                        if ((MicrosoftScriptControl.Error == null) || (MicrosoftScriptControl.Error.Description == null))
                        {
                            throw ex;
                        }
                        else
                        {
                            MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                            if (step < 2)
                            {
                                error.IsRuntime = false;
                            }
                            this.AddError(error);
                        }
                    }

                    MicrosoftScriptControl.Reset();
                }
            }
        }
Exemplo n.º 13
0
        public void EngineExecuteCode(IZeusCodeSegment segment, IZeusContext context)
        {
            // If the segment isn't empty, execute it
            if (!segment.IsEmpty)
            {
                if (!HasErrors)
                {
                    int step = 0;
                    try
                    {
                        if (context.ExecutionDepth > 1)
                        {
                            ScriptStack.Push(new MSScriptControl.ScriptControl());
                        }

                        MicrosoftScriptControl.Timeout       = (_timeout == -1 ? MSScriptControl.ScriptControlConstants.NoTimeout : (_timeout * 1000));
                        MicrosoftScriptControl.Language      = segment.Language;
                        MicrosoftScriptControl.AllowUI       = true;
                        MicrosoftScriptControl.UseSafeSubset = false;

                        MicrosoftScriptControl.AddObject("output", context.Output, true);
                        MicrosoftScriptControl.AddObject("input", context.Input, true);
                        MicrosoftScriptControl.AddObject("context", context, true);

                        foreach (string key in context.Objects.Keys)
                        {
                            if ((key != "output") && (key != "input"))
                            {
                                MicrosoftScriptControl.AddObject(key, context.Objects[key], true);
                            }
                        }

                        string entryCode = this.ScriptingEntryCall(segment.Language) as String;
                        string entryCall = BODY_ENTRY_NAME;

                        step = 1;
                        MicrosoftScriptControl.AddCode(segment.Code);
                        MicrosoftScriptControl.AddCode(entryCode);
                        step = 2;

                        object[] paramList = new object[0];

                        object tmpReturn = MicrosoftScriptControl.Run(entryCall, ref paramList);
                    }
                    catch (System.Runtime.InteropServices.COMException)
                    {
                        MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                        if (step < 2)
                        {
                            error.IsRuntime = false;
                        }
                        this.AddError(error);
                    }
                    catch (Exception ex)
                    {
                        if ((MicrosoftScriptControl.Error == null) || (MicrosoftScriptControl.Error.Description == null))
                        {
                            throw ex;
                        }
                        else
                        {
                            MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                            if (step < 2)
                            {
                                error.IsRuntime = false;
                            }
                            this.AddError(error);
                        }
                    }
                    finally
                    {
                        MicrosoftScriptControl.Reset();
                        if (context.ExecutionDepth > 1)
                        {
                            ScriptStack.Pop();
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        static internal bool ExecuteCodeSegment(IZeusCodeSegment segment, IZeusContext context)
        {
            bool returnValue = true;

            if (context == null) context = new ZeusContext();
            PopulateContextObjects(context as ZeusContext);

            //Push this template onto the template stack
            if (context is ZeusContext)
            {
                ((ZeusContext)context).TemplateStack.Push(segment.ITemplate);
            }

            if (segment.SegmentType == ZeusConstants.CodeSegmentTypes.GUI_SEGMENT)
            {
                foreach (IZeusContextProcessor processor in ZeusFactory.Preprocessors)
                {
                    processor.Process(context);
                }

                returnValue = ZeusExecutioner.ExecuteGuiCode(segment, context);
            }
            else
            {
                ZeusExecutioner.ExecuteCode(segment, context);
            }

            //Pop the template from the template stack
            if (context is ZeusContext)
            {
                ((ZeusContext)context).TemplateStack.Pop();
            }
            return returnValue;
        }
Exemplo n.º 15
0
		static protected bool ExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context) 
		{
			IZeusExecutionHelper helper = segment.ZeusScriptingEngine.ExecutionHelper;

			// If the template has an interface block, execute it
			if (!segment.IsEmpty)
			{
				ArrayList reqVars = segment.ITemplate.RequiredInputVariables;

				if (!context.Input.Contains(reqVars)) 
				{
                    try
                    {
                        helper.EngineExecuteGuiCode(segment, context);

                        if (helper.HasErrors)
                        {
                            IZeusExecutionError[] errors = helper.Errors;
                            helper.ClearErrors();
                            throw new ZeusExecutionException(segment.ITemplate, errors, false);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new ZeusRuntimeException(segment.ITemplate, ex, false);
                    }
				}

				context.Input.AddItems(context.Gui);
			}

			return !context.Gui.IsCanceled;
		}
using System;
Exemplo n.º 17
0
		public string GetCustomFooterCode(IZeusCodeSegment segment, IZeusIntrinsicObject[] iobjs) 
		{
			if (segment.SegmentType == ZeusConstants.CodeSegmentTypes.GUI_SEGMENT) 
			{
				return this._engine.BuildGuiClass(segment.Language, iobjs);
			}
			else
			{
				return this._engine.BuildBodyClass(segment.Language, iobjs);
			}
		}
Exemplo n.º 18
0
		public string GetCustomHeaderCode(IZeusCodeSegment segment, IZeusIntrinsicObject[] iobjs) 
		{
			bool isGui = (segment.SegmentType == ZeusConstants.CodeSegmentTypes.GUI_SEGMENT);
			ArrayList imports = new ArrayList();

			imports.Add("System");
			imports.Add("System.Collections");
			imports.Add("Zeus");
			imports.Add("Zeus.Data");
			imports.Add("Zeus.DotNetScript");
			if (isGui) 
			{
					imports.Add("Zeus.UserInterface");
            }

            foreach (string tns in Zeus.Configuration.ZeusConfig.Current.TemplateNamespaces)
            {
                if (!imports.Contains(tns)) imports.Add(tns);
            }

			foreach (IZeusIntrinsicObject obj in iobjs) 
			{
                if (!obj.Disabled)
                {
                    if (obj.Namespace != null)
                    {
                        if (!imports.Contains(obj.Namespace))
                            imports.Add(obj.Namespace);
                    }
                }
			}

			ArrayList tmpExtraData = segment.ExtraData;
			string[] array;
			foreach (object obj in tmpExtraData) 
			{
				if (obj is String[]) 
				{
					array = (string[])obj;
					if ((array.Length == 2) && (array[0] == DotNetScriptEngine.USE_NAMESPACE))
					{
						if (!imports.Contains(array[1]))
							imports.Add(array[1]);
					}
				}
			}

			return this._engine.BuildImportStatments(segment.Language, imports);
		}
Exemplo n.º 19
0
 public string GetCustomFooterCode(IZeusCodeSegment segment, IZeusIntrinsicObject[] iobjs)
 {
     return(string.Empty);
 }
		public void EngineExecuteCode(IZeusCodeSegment segment, IZeusContext context)
		{
			// If the segment isn't empty, execute it
			if (!segment.IsEmpty) 
			{
				if (!HasErrors)
                {
                    int step = 0;
					try 
					{
						if (context.ExecutionDepth > 1) 
						{
								ScriptStack.Push( new MSScriptControl.ScriptControl() );
						}

						MicrosoftScriptControl.Timeout = (_timeout == -1 ? MSScriptControl.ScriptControlConstants.NoTimeout : (_timeout * 1000) );
						MicrosoftScriptControl.Language = segment.Language;
						MicrosoftScriptControl.AllowUI = true;
						MicrosoftScriptControl.UseSafeSubset = false;

						MicrosoftScriptControl.AddObject("output", context.Output, true);
						MicrosoftScriptControl.AddObject("input", context.Input, true);
						MicrosoftScriptControl.AddObject("context", context, true);
			
						foreach (string key in context.Objects.Keys) 
						{
							if ((key != "output") && (key != "input"))
								MicrosoftScriptControl.AddObject(key, context.Objects[key], true);
						}

						string entryCode = this.ScriptingEntryCall(segment.Language) as String;
						string entryCall = BODY_ENTRY_NAME;

                        step = 1;
						MicrosoftScriptControl.AddCode(segment.Code);
						MicrosoftScriptControl.AddCode(entryCode);
                        step = 2;

						object[] paramList = new object[0];
			
						object tmpReturn = MicrosoftScriptControl.Run(entryCall, ref paramList);
					}
					catch (System.Runtime.InteropServices.COMException)
					{
						MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                        if (step < 2) error.IsRuntime = false;
						this.AddError(error);
					}
                    catch (Exception ex)
                    {
                        if ((MicrosoftScriptControl.Error == null) || (MicrosoftScriptControl.Error.Description == null))
                        {
                            throw ex;
                        }
                        else
                        {
                            MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                            if (step < 2) error.IsRuntime = false;
                            this.AddError(error);
                        }
                    }
					finally 
					{
						MicrosoftScriptControl.Reset();
						if (context.ExecutionDepth > 1) ScriptStack.Pop();
					}
				}
			}
		}
Exemplo n.º 21
0
		static protected void ExecuteCode(IZeusCodeSegment segment, IZeusContext context) 
		{
			IZeusExecutionHelper helper = segment.ZeusScriptingEngine.ExecutionHelper;
			ExecuteCode(helper, segment.ITemplate, context, new ArrayList());
		}
		public void EngineExecuteGuiCode(IZeusCodeSegment segment, IZeusContext context)
		{
			// If the template has an interface block, execute it
			if (!segment.IsEmpty) 
			{
				if (!HasErrors) 
				{
                    int step = 0;
                    try
                    {
                        MicrosoftScriptControl.Timeout = (_timeout == -1 ? MSScriptControl.ScriptControlConstants.NoTimeout : (_timeout * 1000));
                        MicrosoftScriptControl.Language = segment.Language;
                        MicrosoftScriptControl.AllowUI = true;
                        MicrosoftScriptControl.UseSafeSubset = false;
                        MicrosoftScriptControl.Reset();
                        MicrosoftScriptControl.AddObject("input", context.Input, true);
                        MicrosoftScriptControl.AddObject("context", context, true);

                        foreach (string key in context.Objects.Keys)
                        {
                            if (key != "input")
                                MicrosoftScriptControl.AddObject(key, context.Objects[key], true);
                        }

                        step = 1;

                        MicrosoftScriptControl.AddCode(segment.Code);
                        
                        step = 2;

                        object[] paramList = new object[0];

                        object tmpReturn = MicrosoftScriptControl.Run(GUI_ENTRY_NAME, ref paramList);

                        if (context.Gui.ShowGui || context.Gui.ForceDisplay)
                        {
                            OnShowGUI(context.Gui);
                        }
                    }
                    catch (System.Runtime.InteropServices.COMException)
                    {
                        MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                        if (step < 2) error.IsRuntime = false;
                        this.AddError(error);
                    }
                    catch (Exception ex)
                    {
                        if ((MicrosoftScriptControl.Error == null) || (MicrosoftScriptControl.Error.Description == null))
                        {
                            throw ex;
                        }
                        else
                        {
                            MicrosoftScriptError error = new MicrosoftScriptError(MicrosoftScriptControl.Error, context);
                            if (step < 2) error.IsRuntime = false;
                            this.AddError(error);
                        }
                    }

					MicrosoftScriptControl.Reset();
				}
			}
		}
Exemplo n.º 23
0
        static protected void ExecuteCode(IZeusCodeSegment segment, IZeusContext context)
        {
            IZeusExecutionHelper helper = segment.ZeusScriptingEngine.ExecutionHelper;

            ExecuteCode(helper, segment.ITemplate, context, new ArrayList());
        }