Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     // Initialize Language with this as the IHost
     ScriptingLanguage.SetHost(this);
     // Create and initialize BasicNoUIObj object
     basicNoUIObj                = new WinWrap.Basic.BasicNoUIObj();
     basicNoUIObj.Begin         += basicNoUIObj_Begin;
     basicNoUIObj.Disconnecting += basicNoUIObj_Disconnecting;
     basicNoUIObj.DoEvents      += basicNoUIObj_DoEvents;
     basicNoUIObj.ErrorAlert    += basicNoUIObj_ErrorAlert;
     basicNoUIObj.Pause_        += basicNoUIObj_Pause_;
     basicNoUIObj.Secret         = new System.Guid("00000000-0000-0000-0000-000000000000");
     basicNoUIObj.Initialize();
     // automatically disconnect BasicNoUIObj when form closes
     basicNoUIObj.AttachToForm(this, WinWrap.Basic.ManageConstants.All);
     // Extend WinWrap Basic scripts with Examples.Extensions assembly
     // Add "Imports Examples.Extensions" to all WinWrap Basic scripts
     // Add "Imports Examples.Extensions.ScriptingLanguage" all WinWrap Basic scripts
     basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));
     if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
     {
         LogError(basicNoUIObj.Error);
         buttonRunScript.Enabled = false;
     }
 }
Пример #2
0
        private void ExecuteWinWrapBasic()
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin      += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents   += basicNoUIObj_DoEvents;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_     += basicNoUIObj_Pause_;
                basicNoUIObj.Secret      = new System.Guid("00000000-0000-0000-0000-000000000000");
                basicNoUIObj.Initialize();
                // Extend WinWrap Basic scripts with Examples.Extensions assembly
                // Add "Imports Examples.Extensions" to all WinWrap Basic scripts
                // Add "Imports Examples.Extensions.ScriptingLanguage" all WinWrap Basic scripts
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                    {
                        throw basicNoUIObj.Error.Exception;
                    }

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null) // script parsing error
                        {
                            throw basicNoUIObj.Error.Exception;
                        }

                        using (var instance = basicNoUIObj.CreateInstance(ScriptPath(Script) + "<IncidentAction"))
                        {
                            // Execute script code via an interface
                            IIncidentAction action = instance.Cast <IIncidentAction>();
                            TheIncident.Start(action, this.Text);
                        }
                    }
                }
                catch (WinWrap.Basic.TerminatedException)
                {
                    // script execution terminated, ignore error
                }
                catch (Exception ex)
                {
                    // script caused an exception
                    basicNoUIObj.ReportError(ex);
                }
            }
            TheIncident = null;
        }
Пример #3
0
        private void buttonRunScript_Click(object sender, EventArgs e)
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin      += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents   += basicNoUIObj_DoEvents;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_     += basicNoUIObj_Pause_;
                basicNoUIObj.Secret      = new System.Guid("00000000-0000-0000-0000-000000000000");
                basicNoUIObj.Initialize();
                /// Extend WinWrap Basic scripts with Examples.Extensions assembly
                /// Add "Imports Examples.Extensions" to all WinWrap Basic scripts
                /// Add "Imports Examples.Extensions.ScriptingLanguage" all WinWrap Basic scripts
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                basicNoUIObj.Sandboxed = true;
                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                    {
                        throw basicNoUIObj.Error.Exception;
                    }

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null)
                        {
                            throw basicNoUIObj.Error.Exception;
                        }

                        // Execute script code via an event
                        ScriptingLanguage.TheIncident.Start(this.Text);
                    }
                }
                catch (Exception ex)
                {
                    basicNoUIObj.ReportError(ex);
                }
            }

            TheIncident = null;
        }
Пример #4
0
        static private string VerifyWinWrapBasic()
        {
            try
            {
                using (WinWrap.Basic.BasicNoUIObj basic = new WinWrap.Basic.BasicNoUIObj())
                {
                    basic.Secret = new Guid(Secret.MySecret);
                    basic.Initialize();
                    if (basic.IsInitialized())
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(null);
        }
Пример #5
0
        private void WinWrapExecute()
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin      += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents   += basicNoUIObj_DoEvents;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_     += basicNoUIObj_Pause_;
                basicNoUIObj.Secret      = new Guid(GetPatternString("Guid[(]\"(.*)\"[)]"));
                basicNoUIObj.Initialize();
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                    {
                        throw basicNoUIObj.Error.Exception;
                    }

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null)
                        {
                            throw basicNoUIObj.Error.Exception;
                        }

                        // Execute script code via an event
                        ScriptingLanguage.TheIncident.Start("Default.aspx");
                    }
                }
                catch (Exception ex)
                {
                    basicNoUIObj.ReportError(ex);
                }
            }
            TheIncident = null;
        }
Пример #6
0
        private void WinWrapExecute(bool debug)
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin         += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents      += basicNoUIObj_DoEvents;
                basicNoUIObj.End           += basicNoUIObj_End;
                basicNoUIObj.ErrorAlert    += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_        += basicNoUIObj_Pause_;
                basicNoUIObj.Resume        += basicNoUIObj_Resume;
                basicNoUIObj.Synchronizing += basicNoUIObj_Synchronizing;
                basicNoUIObj.Secret         = new Guid(AzureOnlyStrings.GetNamedString("Guid", "00000000-0000-0000-0000-000000000000"));
                basicNoUIObj.Initialize();
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                if (debug)
                {
                    // prepare for debugging
                    basicNoUIObj.Synchronized = true;
                    Log("Debugging...");
                }

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                    {
                        throw basicNoUIObj.Error.Exception;
                    }

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null)
                        {
                            throw basicNoUIObj.Error.Exception;
                        }

                        if (debug)
                        {
                            // step into the script event handler
                            module.StepInto = true;
                            timelimit_      = DateTime.Now + new TimeSpan(0, 0, 30); // timeout in 30 seconds
                        }

                        // Execute script code via an event
                        ScriptingLanguage.TheIncident.Start("Default.aspx");
                    }
                }
                catch (Exception ex)
                {
                    if (debug)
                    {
                        // report error and allow remote to catch up
                        basicNoUIObj.ReportError(ex);
                        basicNoUIObj.Wait(3);
                    }

                    basicNoUIObj.ReportError(ex);
                }

                if (debug)
                {
                    basicNoUIObj.Wait(3);
                    Log("Debugging complete.");
                }
            }
            TheIncident = null;
        }
Пример #7
0
        private void buttonRunScript_Click(object sender, EventArgs e)
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
                basicNoUIObj.Synchronizing += basicNoUIObj_Synchronizing;
                basicNoUIObj.Secret = new System.Guid("00000000-0000-0000-0000-000000000000");
                basicNoUIObj.Initialize();

                basicNoUIObj.AttachToForm(this, WinWrap.Basic.ManageConstants.All);

                if (conns_.Any)
                {
                    basicNoUIObj.Synchronized = true;
                    basicNoUIObj.Wait(3);
                }

                /// Extend WinWrap Basic scripts with Examples.Extensions assembly
                /// Add "Imports Examples.Extensions" to all WinWrap Basic scripts
                /// Add "Imports Examples.Extensions.ScriptingLanguage" all WinWrap Basic scripts
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                        throw basicNoUIObj.Error.Exception;

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null)
                            throw basicNoUIObj.Error.Exception;

                        if (basicNoUIObj.Synchronized)
                            module.StepInto = true;

                        // Execute script code via an event
                        ScriptingLanguage.TheIncident.Start(this.Text);
                    }
                }
                catch (Exception ex)
                {
                    if (basicNoUIObj.Synchronized)
                    {
                        basicNoUIObj.ReportError(ex);
                        basicNoUIObj.Wait(3);
                    }

                    basicNoUIObj.ReportError(ex);

                    if (basicNoUIObj.Synchronized)
                        basicNoUIObj.Wait(1);
                }
            }

            TheIncident = null;
        }
Пример #8
0
        private void ExecuteWinWrapBasic()
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
                basicNoUIObj.Secret = new System.Guid("00000000-0000-0000-0000-000000000000");
                basicNoUIObj.Initialize();
                // Extend WinWrap Basic scripts with Examples.Extensions assembly
                // Add "Imports Examples.Extensions" to all WinWrap Basic scripts
                // Add "Imports Examples.Extensions.ScriptingLanguage" all WinWrap Basic scripts
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                        throw basicNoUIObj.Error.Exception;

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null) // script parsing error
                            throw basicNoUIObj.Error.Exception;

                        using (var instance = basicNoUIObj.CreateInstance(ScriptPath(Script) + "<IncidentAction"))
                        {
                            // Execute script code via an interface
                            IIncidentAction action = instance.Cast<IIncidentAction>();
                            TheIncident.Start(action, this.Text);
                        }
                    }
                }
                catch (WinWrap.Basic.TerminatedException)
                {
                    // script execution terminated, ignore error
                }
                catch (Exception ex)
                {
                    // script caused an exception
                    basicNoUIObj.ReportError(ex);
                }
            }
            TheIncident = null;
        }
Пример #9
0
        private void WinWrapExecute()
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
                basicNoUIObj.Secret = new Guid(GetPatternString("Guid[(]\"(.*)\"[)]"));
                basicNoUIObj.Initialize();
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                        throw basicNoUIObj.Error.Exception;

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null)
                            throw basicNoUIObj.Error.Exception;

                        // Execute script code via an event
                        ScriptingLanguage.TheIncident.Start("Default.aspx");
                    }
                }
                catch (Exception ex)
                {
                    basicNoUIObj.ReportError(ex);
                }
            }
            TheIncident = null;
        }
Пример #10
0
 private void RunWinWrap()
 {
     try
     {
         using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
         {
             basicNoUIObj.Begin += basicNoUIObj_Begin;
             basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
             basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
             basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
             //#if DEBUG
             // Debug.Print in a script shown on webpage when running locally
             basicNoUIObj.DebugPrint += basicNoUIObj_DebugPrint;
             //#endif
             basicNoUIObj.Secret = new Guid(Utils.GetPatternString("wwhowto01", "Guid[(]\"(.*)\"[)]"));
             basicNoUIObj.Initialize();
             basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));
             //basicNoUIObj.AddReference(typeof(String).Assembly);
             //Button1.Text = basicNoUIObj.Evaluate("2+3");
             basicNoUIObj.VirtualFileSystem = new VirtualFileSystem();
             basicNoUIObj.RunFile("local/Macro1.bas");
             //DrawTriangle();
             //basicNoUIObj.RunFile("local/Macro2.bas");
             string macroName = String.Format(@"{0}/{1}", Session["Code"].ToString(), "Macro2.bas");
             basicNoUIObj.RunFile(macroName);
             ImageUser.ImageUrl = clientImage_.ImageUrl();
         }
     }
     catch (Exception e)
     {
         AppendToTextBox1(e.Message);
     }
 }
Пример #11
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            TextBox2.Text = DateTime.Now.ToString();
            try
            {
                using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
                {
                    basicNoUIObj.Begin += basicNoUIObj_Begin;
                    basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
                    basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                    basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
                    //#if DEBUG
                    // Debug.Print in a script shown on webpage when running locally
                    basicNoUIObj.DebugPrint += basicNoUIObj_DebugPrint;
                    //#endif
                    basicNoUIObj.Secret = new Guid(Utils.GetPatternString("wwhowto01", "Guid[(]\"(.*)\"[)]"));
                    basicNoUIObj.Initialize();
                    basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));
                    //basicNoUIObj.AddReference(typeof(String).Assembly);
                    //Button1.Text = basicNoUIObj.Evaluate("2+3");
                    basicNoUIObj.VirtualFileSystem = new VirtualFileSystem();
                    /*basicNoUIObj.RunFile("local/Macro1.bas");
                    //DrawTriangle();
                    //basicNoUIObj.RunFile("local/Macro2.bas");
                    string macroName = String.Format(@"{0}/{1}", Session["Code"].ToString(), "Macro2.bas");
                    basicNoUIObj.RunFile(macroName);*/
                    using (var module = basicNoUIObj.ModuleInstance("local/Good.bas", false))
                    {
                        if (module == null)
                        {
                            string serror = Utils.FormatError(basicNoUIObj.Error, basicNoUIObj.VirtualFileSystem);
                            TextBox1.Text = serror;
                            TextBox1.Visible = true;
                        }
                        else
                        {

                            ScriptingLanguage.TriangleImage.Start();
                            ImageUser.ImageUrl = clientImage_.ImageUrl();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppendToTextBox1(ex.Message);
            }
        }
Пример #12
0
        private void WinWrapExecute(bool debug)
        {
            TheIncident = new Incident();
            using (var basicNoUIObj = new WinWrap.Basic.BasicNoUIObj())
            {
                basicNoUIObj.Begin += basicNoUIObj_Begin;
                basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
                basicNoUIObj.End += basicNoUIObj_End;
                basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
                basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
                basicNoUIObj.Resume += basicNoUIObj_Resume;
                basicNoUIObj.Synchronizing += basicNoUIObj_Synchronizing;
                basicNoUIObj.Secret = new Guid(AzureOnlyStrings.GetNamedString("Guid", "00000000-0000-0000-0000-000000000000"));
                basicNoUIObj.Initialize();
                basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));

                if (debug)
                {
                    // prepare for debugging
                    basicNoUIObj.Synchronized = true;
                    Log("Debugging...");
                }

                try
                {
                    if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
                        throw basicNoUIObj.Error.Exception;

                    using (var module = basicNoUIObj.ModuleInstance(ScriptPath(Script), false))
                    {
                        if (module == null)
                            throw basicNoUIObj.Error.Exception;

                        if (debug)
                        {
                            // step into the script event handler
                            module.StepInto = true;
                            timelimit_ = DateTime.Now + new TimeSpan(0, 0, 30); // timeout in 30 seconds
                        }

                        // Execute script code via an event
                        ScriptingLanguage.TheIncident.Start("Default.aspx");
                    }
                }
                catch (Exception ex)
                {
                    if (debug)
                    {
                        // report error and allow remote to catch up
                        basicNoUIObj.ReportError(ex);
                        basicNoUIObj.Wait(3);
                    }

                    basicNoUIObj.ReportError(ex);
                }

                if (debug)
                {
                    basicNoUIObj.Wait(3);
                    Log("Debugging complete.");
                }
            }
            TheIncident = null;
        }
Пример #13
0
 private void Form1_Load(object sender, EventArgs e)
 {
     // Initialize Language with this as the IHost
     ScriptingLanguage.SetHost(this);
     // Create and initialize BasicNoUIObj object
     basicNoUIObj = new WinWrap.Basic.BasicNoUIObj();
     basicNoUIObj.Begin += basicNoUIObj_Begin;
     basicNoUIObj.Disconnecting += basicNoUIObj_Disconnecting;
     basicNoUIObj.DoEvents += basicNoUIObj_DoEvents;
     basicNoUIObj.ErrorAlert += basicNoUIObj_ErrorAlert;
     basicNoUIObj.Pause_ += basicNoUIObj_Pause_;
     basicNoUIObj.Secret = new System.Guid("00000000-0000-0000-0000-000000000000");
     basicNoUIObj.Initialize();
     // automatically disconnect BasicNoUIObj when form closes
     basicNoUIObj.AttachToForm(this, WinWrap.Basic.ManageConstants.All);
     // Extend WinWrap Basic scripts with Examples.Extensions assembly
     // Add "Imports Examples.Extensions" to all WinWrap Basic scripts
     // Add "Imports Examples.Extensions.ScriptingLanguage" all WinWrap Basic scripts
     basicNoUIObj.AddScriptableObjectModel(typeof(ScriptingLanguage));
     if (!basicNoUIObj.LoadModule(ScriptPath("Globals.bas")))
     {
         LogError(basicNoUIObj.Error);
         buttonRunScript.Enabled = false;
     }
 }