Exemplo n.º 1
0
 private void ValidateExecutionProgress()
 {
     lock (this._locker)
     {
         if ((this._executionProgress == LINQPad.ExecutionModel.ExecutionProgress.Executing) || (this._executionProgress == LINQPad.ExecutionModel.ExecutionProgress.Async))
         {
             if (this._server == null)
             {
                 this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
             }
             else
             {
                 try
                 {
                     if (this._server.Finished)
                     {
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                     }
                 }
                 catch (AppDomainUnloadedException)
                 {
                     this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public void Dispose()
 {
     lock (this._locker)
     {
         if (!this._isDisposed)
         {
             this._isDisposed         = true;
             this.ReadLineRequested   = null;
             this.QueryCompiled       = null;
             this.QueryCompleted      = null;
             this.PluginsReady        = null;
             this.CustomClickComplete = null;
             this._executionProgress  = LINQPad.ExecutionModel.ExecutionProgress.Finished;
             this._cancelRequest      = true;
             this.ClearServer();
             this._query  = null;
             this._source = null;
             try
             {
                 RemotingServices.Disconnect(this);
             }
             catch
             {
             }
         }
     }
 }
Exemplo n.º 3
0
 internal void OnQueryStatusChanged(QueryStatusEventArgs args)
 {
     lock (this._locker)
     {
         if (this._cancelRequest)
         {
             return;
         }
         if (args.ExecutionComplete)
         {
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
         }
     }
     this.OnQueryCompleted(args);
 }
Exemplo n.º 4
0
        protected virtual void OnQueryCompleted(QueryStatusEventArgs e)
        {
            lock (this._locker)
            {
                if (e.ExecutionComplete)
                {
                    this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                }
                else if (e.Async && (this._executionProgress < LINQPad.ExecutionModel.ExecutionProgress.Finished))
                {
                    this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Async;
                }
            }
            EventHandler <QueryStatusEventArgs> queryCompleted = this.QueryCompleted;

            if (queryCompleted != null)
            {
                queryCompleted(this, e);
            }
            this.QueryCompiled = null;
        }
Exemplo n.º 5
0
 public void Cancel(bool onlyIfRunning, bool killAppDomain)
 {
     Server server;
     lock (this._locker)
     {
         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
         if (!(killAppDomain || !this._cancelRequest))
         {
             return;
         }
         this._cancelRequest = true;
         server = this._server;
     }
     if (server != null)
     {
         server.Cancel(onlyIfRunning, killAppDomain);
     }
     if (killAppDomain)
     {
         this.ClearServer();
     }
 }
Exemplo n.º 6
0
        public void Cancel(bool onlyIfRunning, bool killAppDomain)
        {
            Server server;

            lock (this._locker)
            {
                this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                if (!(killAppDomain || !this._cancelRequest))
                {
                    return;
                }
                this._cancelRequest = true;
                server = this._server;
            }
            if (server != null)
            {
                server.Cancel(onlyIfRunning, killAppDomain);
            }
            if (killAppDomain)
            {
                this.ClearServer();
            }
        }
Exemplo n.º 7
0
 private void CompileAndRun(DataContextInfo dcInfo)
 {
     try
     {
         object obj2;
         QueryCore core;
         lock ((obj2 = this._locker))
         {
             core = this._query;
             if ((core == null) || this._cancelRequest)
             {
                 return;
             }
         }
         if ((dcInfo != null) && (dcInfo.Error != null))
         {
             this.OnQueryCompleted("Connection error", dcInfo.Error);
         }
         else
         {
             DataContextDriver driver = core.GetDriver(true);
             if ((driver != null) && (driver.AssembliesToAddError != null))
             {
                 this.OnQueryCompleted("Error loading custom driver assemblies", driver.AssembliesToAddError.Message);
             }
             else
             {
                 QueryCompiler c = null;
                 if (((this._lastCompilation != null) && (this._lastCompilation.AssemblyDLL != null)) && File.Exists(this._lastCompilation.AssemblyDLL.FullPath))
                 {
                     c = this._lastCompilation.Compiler;
                     if (!((((dcInfo != null) || (this._lastCompilation.DataContextDLL == null)) && ((dcInfo == null) || (this._lastCompilation.DataContextDLL != null))) ? (((dcInfo == null) || (this._lastCompilation.DataContextDLL == null)) || (dcInfo.AssemblyPath == this._lastCompilation.DataContextDLL)) : false))
                     {
                         c = null;
                     }
                 }
                 bool flag2 = false;
                 if (c == null)
                 {
                     this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Compiling;
                     c = QueryCompiler.Create(core, true);
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                     }
                     c.Compile(this._source, core, (dcInfo == null) ? null : dcInfo.AssemblyPath);
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                         if (c.Errors.HasErrors)
                         {
                             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                             this.QueryCompleted = null;
                             this.PluginsReady = null;
                             this.CustomClickComplete = null;
                         }
                     }
                     this.OnQueryCompiled(new QueryCompilationEventArgs(c, (dcInfo == null) ? null : dcInfo.AssemblyPath, this._partialSource));
                     flag2 = true;
                 }
                 lock ((obj2 = this._locker))
                 {
                     if ((this._cancelRequest || c.Errors.HasErrors) || this._compileOnly)
                     {
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                         return;
                     }
                 }
                 Server server = this._serverGenerator(this);
                 if (server != null)
                 {
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                         if (this._server != server)
                         {
                             this.ClearServer();
                         }
                         this._server = server;
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
                     }
                     bool flag7 = c.References.Any<string>(r => r.EndsWith(".winmd", StringComparison.InvariantCultureIgnoreCase));
                     server.WriteResultsToGrids = core.ToDataGrids;
                     server.ExecuteClrQuery(this, core.Repository, c.OutputFile.FullPath, c.LineOffset, c.References.ToArray<string>(), Program.MTAMode || flag7, flag2 && c.Errors.HasWarnings, core.FilePath, core.Name, this._pluginWinManager, !UserOptionsLive.Instance.ExecutionTrackingDisabled);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         try
         {
             this.OnQueryCompleted("Unable to execute query", "");
         }
         catch
         {
         }
         Program.ProcessException(exception);
     }
 }
Exemplo n.º 8
0
 private void ValidateExecutionProgress()
 {
     lock (this._locker)
     {
         if ((this._executionProgress == LINQPad.ExecutionModel.ExecutionProgress.Executing) || (this._executionProgress == LINQPad.ExecutionModel.ExecutionProgress.Async))
         {
             if (this._server == null)
             {
                 this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
             }
             else
             {
                 try
                 {
                     if (this._server.Finished)
                     {
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                     }
                 }
                 catch (AppDomainUnloadedException)
                 {
                     this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
 public void Start()
 {
     ThreadStart start = null;
     object obj2;
     QueryCore core;
     lock ((obj2 = this._locker))
     {
         core = this._query;
         if ((core == null) || this._cancelRequest)
         {
             return;
         }
         if (this._executionProgress != LINQPad.ExecutionModel.ExecutionProgress.Starting)
         {
             throw new InvalidOperationException("Cannot call Start twice on Client");
         }
     }
     if ((core.QueryKind == QueryLanguage.SQL) || (core.QueryKind == QueryLanguage.ESQL))
     {
         if (this._compileOnly)
         {
             this.OnQueryCompleted("", "");
         }
         else
         {
             lock ((obj2 = this._locker))
             {
                 this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
             }
             Server server = this._serverGenerator(this);
             lock ((obj2 = this._locker))
             {
                 if (this._cancelRequest || (server == null))
                 {
                     return;
                 }
                 if (this._server != server)
                 {
                     this.ClearServer();
                 }
                 this._server = server;
             }
             server.WriteResultsToGrids = core.ToDataGrids && (core.QueryKind == QueryLanguage.SQL);
             UniqueStringCollection source = new UniqueStringCollection(new FileNameComparer());
             if (core.GetDriver(true) != null)
             {
                 try
                 {
                     source.AddRange(core.Repository.GetDriverAssemblies());
                     if (!((core.QueryKind != QueryLanguage.ESQL) || string.IsNullOrEmpty(core.Repository.CustomAssemblyPath)))
                     {
                         source.Add(core.Repository.CustomAssemblyPath);
                     }
                 }
                 catch
                 {
                 }
             }
             server.ExecuteSqlQuery(core.QueryKind, core.Repository, this._source, source.ToArray<string>(), this, this._pluginWinManager);
         }
     }
     else if ((core.Repository != null) && core.Repository.DynamicSchema)
     {
         lock ((obj2 = this._locker))
         {
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.AwaitingDataContext;
         }
         DataContextManager.GetDataContextInfo(core.Repository, new DataContextCallback(this.GotDataContext), SchemaChangeTestMode.None);
     }
     else
     {
         if (start == null)
         {
             start = () => this.CompileAndRun(null);
         }
         new Thread(start) { Name = "Query Compiler", IsBackground = true }.Start();
     }
 }
Exemplo n.º 10
0
 internal void OnQueryStatusChanged(QueryStatusEventArgs args)
 {
     lock (this._locker)
     {
         if (this._cancelRequest)
         {
             return;
         }
         if (args.ExecutionComplete)
         {
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
         }
     }
     this.OnQueryCompleted(args);
 }
Exemplo n.º 11
0
 protected virtual void OnQueryCompleted(QueryStatusEventArgs e)
 {
     lock (this._locker)
     {
         if (e.ExecutionComplete)
         {
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
         }
         else if (e.Async && (this._executionProgress < LINQPad.ExecutionModel.ExecutionProgress.Finished))
         {
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Async;
         }
     }
     EventHandler<QueryStatusEventArgs> queryCompleted = this.QueryCompleted;
     if (queryCompleted != null)
     {
         queryCompleted(this, e);
     }
     this.QueryCompiled = null;
 }
Exemplo n.º 12
0
 public void Dispose()
 {
     lock (this._locker)
     {
         if (!this._isDisposed)
         {
             this._isDisposed = true;
             this.ReadLineRequested = null;
             this.QueryCompiled = null;
             this.QueryCompleted = null;
             this.PluginsReady = null;
             this.CustomClickComplete = null;
             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
             this._cancelRequest = true;
             this.ClearServer();
             this._query = null;
             this._source = null;
             try
             {
                 RemotingServices.Disconnect(this);
             }
             catch
             {
             }
         }
     }
 }
Exemplo n.º 13
0
        public void Start()
        {
            ThreadStart start = null;
            object      obj2;
            QueryCore   core;

            lock ((obj2 = this._locker))
            {
                core = this._query;
                if ((core == null) || this._cancelRequest)
                {
                    return;
                }
                if (this._executionProgress != LINQPad.ExecutionModel.ExecutionProgress.Starting)
                {
                    throw new InvalidOperationException("Cannot call Start twice on Client");
                }
            }
            if ((core.QueryKind == QueryLanguage.SQL) || (core.QueryKind == QueryLanguage.ESQL))
            {
                if (this._compileOnly)
                {
                    this.OnQueryCompleted("", "");
                }
                else
                {
                    lock ((obj2 = this._locker))
                    {
                        this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
                    }
                    Server server = this._serverGenerator(this);
                    lock ((obj2 = this._locker))
                    {
                        if (this._cancelRequest || (server == null))
                        {
                            return;
                        }
                        if (this._server != server)
                        {
                            this.ClearServer();
                        }
                        this._server = server;
                    }
                    server.WriteResultsToGrids = core.ToDataGrids && (core.QueryKind == QueryLanguage.SQL);
                    UniqueStringCollection source = new UniqueStringCollection(new FileNameComparer());
                    if (core.GetDriver(true) != null)
                    {
                        try
                        {
                            source.AddRange(core.Repository.GetDriverAssemblies());
                            if (!((core.QueryKind != QueryLanguage.ESQL) || string.IsNullOrEmpty(core.Repository.CustomAssemblyPath)))
                            {
                                source.Add(core.Repository.CustomAssemblyPath);
                            }
                        }
                        catch
                        {
                        }
                    }
                    server.ExecuteSqlQuery(core.QueryKind, core.Repository, this._source, source.ToArray <string>(), this, this._pluginWinManager);
                }
            }
            else if ((core.Repository != null) && core.Repository.DynamicSchema)
            {
                lock ((obj2 = this._locker))
                {
                    this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.AwaitingDataContext;
                }
                DataContextManager.GetDataContextInfo(core.Repository, new DataContextCallback(this.GotDataContext), SchemaChangeTestMode.None);
            }
            else
            {
                if (start == null)
                {
                    start = () => this.CompileAndRun(null);
                }
                new Thread(start)
                {
                    Name = "Query Compiler", IsBackground = true
                }.Start();
            }
        }
Exemplo n.º 14
0
 private void CompileAndRun(DataContextInfo dcInfo)
 {
     try
     {
         object    obj2;
         QueryCore core;
         lock ((obj2 = this._locker))
         {
             core = this._query;
             if ((core == null) || this._cancelRequest)
             {
                 return;
             }
         }
         if ((dcInfo != null) && (dcInfo.Error != null))
         {
             this.OnQueryCompleted("Connection error", dcInfo.Error);
         }
         else
         {
             DataContextDriver driver = core.GetDriver(true);
             if ((driver != null) && (driver.AssembliesToAddError != null))
             {
                 this.OnQueryCompleted("Error loading custom driver assemblies", driver.AssembliesToAddError.Message);
             }
             else
             {
                 QueryCompiler c = null;
                 if (((this._lastCompilation != null) && (this._lastCompilation.AssemblyDLL != null)) && File.Exists(this._lastCompilation.AssemblyDLL.FullPath))
                 {
                     c = this._lastCompilation.Compiler;
                     if (!((((dcInfo != null) || (this._lastCompilation.DataContextDLL == null)) && ((dcInfo == null) || (this._lastCompilation.DataContextDLL != null))) ? (((dcInfo == null) || (this._lastCompilation.DataContextDLL == null)) || (dcInfo.AssemblyPath == this._lastCompilation.DataContextDLL)) : false))
                     {
                         c = null;
                     }
                 }
                 bool flag2 = false;
                 if (c == null)
                 {
                     this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Compiling;
                     c = QueryCompiler.Create(core, true);
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                     }
                     c.Compile(this._source, core, (dcInfo == null) ? null : dcInfo.AssemblyPath);
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                         if (c.Errors.HasErrors)
                         {
                             this._executionProgress  = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                             this.QueryCompleted      = null;
                             this.PluginsReady        = null;
                             this.CustomClickComplete = null;
                         }
                     }
                     this.OnQueryCompiled(new QueryCompilationEventArgs(c, (dcInfo == null) ? null : dcInfo.AssemblyPath, this._partialSource));
                     flag2 = true;
                 }
                 lock ((obj2 = this._locker))
                 {
                     if ((this._cancelRequest || c.Errors.HasErrors) || this._compileOnly)
                     {
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                         return;
                     }
                 }
                 Server server = this._serverGenerator(this);
                 if (server != null)
                 {
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                         if (this._server != server)
                         {
                             this.ClearServer();
                         }
                         this._server            = server;
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
                     }
                     bool flag7 = c.References.Any <string>(r => r.EndsWith(".winmd", StringComparison.InvariantCultureIgnoreCase));
                     server.WriteResultsToGrids = core.ToDataGrids;
                     server.ExecuteClrQuery(this, core.Repository, c.OutputFile.FullPath, c.LineOffset, c.References.ToArray <string>(), Program.MTAMode || flag7, flag2 && c.Errors.HasWarnings, core.FilePath, core.Name, this._pluginWinManager, !UserOptionsLive.Instance.ExecutionTrackingDisabled);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         try
         {
             this.OnQueryCompleted("Unable to execute query", "");
         }
         catch
         {
         }
         Program.ProcessException(exception);
     }
 }