Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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();
     }
 }
Ejemplo n.º 3
0
        private void Extract(TagArchive archive, bool recusive, params string[] files)
        {
            extractionActive = true;
            int totalFilesExtracted = 0, totalFilesToExtract = 0;

            List <TagSet> sets = archive.BuildTagLocationList(files, currentGame);

            // Setup the counts.
            foreach (TagSet set in sets)
            {
                totalFilesToExtract += set.Tags.Count;
            }

            progressPanel.TotalExtracted = 0;
            progressPanel.TagCount       = totalFilesToExtract;

            UniqueStringCollection additionalFiles = new UniqueStringCollection();

            try
            {
                foreach (TagSet set in sets)
                {
                    string filename = currentGame.Maps[set.MapIndex].Filename;

                    // UI Update
                    progressPanel.CurrentMap = Path.GetFileName(filename);

                    progressPanel.CurrentMap = filename;
                    progressPanel.OpeningMap = true;
                    IMapFile map = currentGame.CreateMapFileObject();
                    map.Load(currentGame.MapFilePath + "\\" + filename);

                    progressPanel.ExtractingTags = true;
                    // Sort alphabetically so that folders don't get extracted out of order.
                    set.Tags.Sort();

                    // Extract the tags one by one.
                    foreach (string tag in set.Tags)
                    {
                        // UI Update
                        progressPanel.CurrentTag = tag;
                        bool successful = true;
                        try
                        {
                            // Check and see if we have attempted to cancel...
                            if (!extractionActive)
                            {
                                return;
                            }

                            if (!archive.FileExists(tag))
                            {
                                byte[] data = map.GetTag(tag);
                                archive.AddFile(tag, data);
                            }
                        }
                        catch (Exception ex)
                        {
                            successful = false;
                            Output.Write(OutputTypes.Error, "Unable to extract tag '" + tag + ex.Message);
                        }
                        if (successful)
                        {
                            RemoveFromQueue(tag);
                        }
                        totalFilesExtracted++;

                        // UI Update
                        progressPanel.TotalExtracted = totalFilesExtracted;

                        if (recusive)
                        {
                            // Attempt to deserialize the tag, and get its dependencies.
                            string   tagExtension = Path.GetExtension(tag).Trim('.');
                            Type     tagType      = currentGame.TypeTable.LocateEntryByName(tagExtension).TagType;
                            TagPath  poolPath     = new TagPath(tag, currentGame.GameID, TagLocation.Archive);
                            string[] dependencies = Core.Prometheus.Instance.Pool.GetTagReferences(poolPath.ToPath(), tagType);
                            foreach (string dependency in dependencies)
                            {
                                if (!archive.FileExists(dependency))
                                {
                                    additionalFiles.Add(dependency);
                                }
                            }
                        }
                    }
                }
                if (additionalFiles.Count > 0)
                {
                    progressPanel.Title = "Extracting dependencies...";
                    // Extract the additional files.
                    Extract(archive, true, additionalFiles.ToArray());
                }
            }
            finally
            {
                UpdateExtractionButton();
            }
        }