public void ProcessSingleOrderTest()
        {
            // Arrange
            int  orderId   = 1;
            bool IsExecute = false;

            Order o = new Order();

            o = GetOrders().orders.FirstOrDefault(x => x.OrderId == orderId);

            Product p = new Product();

            p = GetProducts().products.FirstOrDefault(x => x.ProductId == o.ProductId);

            Executables   exq = new Executables();
            BusinessLogic b   = new BusinessLogic();

            // Act
            b.MapExecutables(p, orderId, IsExecute, ref exq);


            // Assert
            Assert.IsTrue(exq.IsPacking);
            Assert.IsNotNull(exq.Products);
            Assert.AreEqual(exq.Products.Count, 1);
            Assert.IsTrue(exq.IsPackingSlipRequired);
            Assert.IsNotNull(exq.PackingSlips);
            Assert.AreEqual(exq.PackingSlips.Count, 2);
            Assert.IsTrue(exq.IsPhysicalProduct);
            Assert.IsTrue(exq.AgentCommission > 0);
            Assert.IsFalse(exq.IsMembership);
            Assert.IsNull(exq.MembershipType);
        }
示例#2
0
        public ExecutableNodeFactory(Executable executable,Executables collection)
        {
            _collection = collection;
            _executable = (DtsContainer)executable;
            _host = _executable as TaskHost;
            _seq = _executable as Sequence;
            _foreachloop = _executable as ForEachLoop;
            _forloop = _executable as ForLoop;
            _psExecutable = PSObject.AsPSObject(_executable);

            if (null != _host)
            {
                _psExecutable.Properties.Add( new PSNoteProperty( "IsTaskHost", true ));
                _mainPipe = _host.InnerObject as MainPipe;
            }
            if (null != _mainPipe)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsDataFlow", true));
            }
            if (null != _seq)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsSequence", true));
            }
            if (null != _foreachloop)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsForEachLoop", true));
            }
            if (null != _forloop)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsForLoop", true));
            }
        }
示例#3
0
        public ExecutableNodeFactory(Executable executable, Executables collection)
        {
            _collection   = collection;
            _executable   = (DtsContainer)executable;
            _host         = _executable as TaskHost;
            _seq          = _executable as Sequence;
            _foreachloop  = _executable as ForEachLoop;
            _forloop      = _executable as ForLoop;
            _psExecutable = PSObject.AsPSObject(_executable);

            if (null != _host)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsTaskHost", true));
                _mainPipe = _host.InnerObject as MainPipe;
            }
            if (null != _mainPipe)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsDataFlow", true));
            }
            if (null != _seq)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsSequence", true));
            }
            if (null != _foreachloop)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsForEachLoop", true));
            }
            if (null != _forloop)
            {
                _psExecutable.Properties.Add(new PSNoteProperty("IsForLoop", true));
            }
        }
示例#4
0
        public void EnsurePuttyBinaryInResources()
        {
            const string RESOURCES_PUTTY_EXE = @"Resources\" + Executables.PUTTY_BINARY;
            string       resolvedPath        = Executables.GetPuttyBinaryPath();

            Assert.IsTrue(resolvedPath.EndsWith(RESOURCES_PUTTY_EXE));
        }
示例#5
0
        public bool LoadFromDisk()
        {
            if (!File.Exists(saveFile))
            {
                return(false);
            }

            System.IO.StreamReader file = null;
            try
            {
                file = new System.IO.StreamReader(saveFile);

                string line;

                while ((line = file.ReadLine()) != null)
                {
                    Executables.Add(new Executable(line));
                }
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }

            return(Executables.Count > 0);
        }
        public static X86Disassembler CreateDisassemblerFromRVA(this Executables exe, long rva)
        {
            var asm    = exe.Assembly;
            var reader = asm.ReadingContext.Reader.CreateSubReader(asm.RvaToFileOffset(rva));
            var sec    = asm.GetSectionHeaderByRva(rva);
            var dis    = new AsmResolver.X86.X86Disassembler(reader, exe.BaseAddress + sec.VirtualAddress - sec.PointerToRawData);

            return(dis);
        }
示例#7
0
 public void AddCapturedExecutable()
 {
     if (LastCapturedExecutable != null)
     {
         Executables.Add(LastCapturedExecutable);
     }
     LastCapturedExecutable = null;
     //go back to normal mode ...
     SetNormalMode();
 }
示例#8
0
 protected internal BasicActiveState(Scheduler scheduler)
 {
     this.scheduler     = scheduler;
     executables        = new Executables <TBActSt>();
     failed             = new AtomicBoolean(false);
     failedOutcomeValue = Optional.Empty <TBActSt>();
     exception          = new AtomicReference <Exception>(null);
     outcome            = new AtomicReference <object>(null);
     outcomeKnown       = new ManualResetEventSlim(false);
     timedOut           = new AtomicBoolean(false);
 }
示例#9
0
        public Executable AddExecutable(string path = null)
        {
            Executable new_executable = new Executable()
            {
                Settings      = this,
                Name          = L.NewExecutableName,
                Path          = path,
                AllowCommands = false
            };

            Executables.Add(new_executable);
            return(new_executable);
        }
        private void LoopExecutablesToSaveTaskScript(Executables executables, string packagePath)
        {
            foreach (Executable executable in executables)
            {
                if (executable is TaskHost)
                {
                    TaskHost task = (TaskHost)executable;
                    if (IsScriptTask(task))
                    {
                        string sqlStatementSource = GetSqlStatementSource(task);

                        string fileName;
                        if (SaveAllFilesToNearCheckBox.Checked)
                        {
                            fileName = System.IO.Path.Combine(packagePath, package.Name + " - " + task.Name + ".sql");

                            if (System.IO.File.Exists(fileName))
                            {
                                fileName = System.IO.Path.Combine(packagePath, package.Name + " - " + task.Name + "_" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString() + ".sql");
                            }
                        }
                        else
                        {
                            fileName = System.IO.Path.Combine(txtDestFolder.Text, package.Name + " - " + task.Name + ".sql");

                            if (System.IO.File.Exists(fileName))
                            {
                                fileName = System.IO.Path.Combine(txtDestFolder.Text, package.Name + " - " + task.Name + "_" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString() + ".sql");
                            }
                        }

                        try
                        {
                            System.IO.File.WriteAllText(fileName, sqlStatementSource);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(fileName + Environment.NewLine + Environment.NewLine + ex.ToString());
                        }
                    }
                }

                if (executable is Sequence)
                {
                    LoopExecutablesToSaveTaskScript(((Sequence)executable).Executables, packagePath);
                }
            }
        }
示例#11
0
        public string ProcessSingleOrder(int OrderId, bool IsExecute = false)
        {
            BusinessLogic b = new BusinessLogic();

            Order o = new Order();

            o = b.GetOrders().orders.FirstOrDefault(x => x.OrderId == OrderId);

            Product p = new Product();

            p = b.GetProducts().products.FirstOrDefault(x => x.ProductId == o.ProductId);

            Executables exq = new Executables();

            b.MapExecutables(p, OrderId, IsExecute, ref exq);

            return("Order Processed Sucessfully");
        }
        private void FillScriptComponentList(Executables executables)
        {
            foreach (Executable executable in executables)
            {
                if (executable is TaskHost)
                {
                    if (ShowOnlyScriptTasksCheckBox.Checked && !IsScriptTask((TaskHost)executable))
                    {
                        continue;
                    }

                    listView1.Items.Add(new TaskHostListItem(executable));
                }


                if (executable is Sequence)
                {
                    FillScriptComponentList(((Sequence)executable).Executables);
                }
            }
        }
        private async Task <Executable> CreateExecutableAsync(
            byte[] contents, string ext, bool cmp)
        {
            var execName = $"p{Problem.ProblemId}{(cmp ? "cmp" : "run")}";
            var testlib  = StaticFiles.GetFileInfo("static/testlib.h");

            if (!testlib.Exists)
            {
                throw new InvalidOperationException("testlib.h not found");
            }

            var stream = new MemoryStream();

            using (var newzip = new ZipArchive(stream, ZipArchiveMode.Create, true))
            {
                var f = newzip.CreateEntryFromByteArray(contents, "main" + ext);
                f.ExternalAttributes = LINUX644;
                var f2 = newzip.CreateEntryFromFile(testlib.PhysicalPath, "testlib.h");
                f2.ExternalAttributes = LINUX644;
            }

            stream.Position = 0;
            var content = new byte[stream.Length];
            int pos     = 0;

            while (pos < stream.Length)
            {
                pos += await stream.ReadAsync(content, pos, (int)stream.Length - pos);
            }

            return(await Executables.CreateAsync(new Executable
            {
                Description = $"output validator for p{Problem.ProblemId}",
                ZipFile = content,
                Md5sum = content.ToMD5().ToHexDigest(true),
                ZipSize = pos,
                ExecId = execName,
                Type = cmp ? "compare" : "run",
            }));
        }
示例#14
0
        /// <summary>
        /// Parses all games for a given system.
        /// </summary>
        ///
        /// <remarks>
        /// "Parsing" means reading and unmarshalling the given XML file in the
        /// system's database folder.
        /// </remarks>
        ///
        /// <param name="databaseFile">XML file to parse</param>
        /// <returns>Parsed games</returns>
        private List <PinballXGame> ParseGames([NotNull] string databaseFile)
        {
            var xmlPath = Path.Combine(DatabasePath, databaseFile);
            var games   = new List <PinballXGame>();

            if (_dir.Exists(DatabasePath))
            {
                var menu = _marshallManager.UnmarshallXml(xmlPath);
                var remainingExecutables = Executables.ToList();
                menu.Games.ForEach(game => {
                    // update links
                    game.System       = this;
                    game.DatabaseFile = databaseFile;

                    // update executables
                    var executable = game.AlternateExe != null && game.AlternateExe.Trim() != "" ? game.AlternateExe : DefaultExecutableLabel;
                    if (!Executables.Contains(executable))
                    {
                        _logger.Debug("Adding new alternate executable \"{0}\" to system \"{1}\"", executable, Name);
                        _threadManager.MainDispatcher.Invoke(() => Executables.Add(executable));
                    }
                    else
                    {
                        if (remainingExecutables.Contains(executable))
                        {
                            remainingExecutables.Remove(executable);
                        }
                    }
                });
                _logger.Debug("Removing alternate executables [ \"{0}\" ] from system \"{1}\"", string.Join("\", \"", remainingExecutables), Name);
                _threadManager.MainDispatcher.Invoke(() => Executables.RemoveAll(remainingExecutables));
                _threadManager.MainDispatcher.Invoke(() => Executables.Sort(string.Compare));

                games.AddRange(menu.Games);
            }
            _logger.Debug("Parsed {0} games from {1}.", games.Count, xmlPath);
            return(games);
        }
示例#15
0
        private void Btn_AddExecutable_Click(object sender, EventArgs e)
        {
            bool execPathTaken = false;
            bool shortcutTaken = false;

            // If changing an executable
            if (ChangingExecutables)
            {
                // Executable path taken
                {
                    List <ExecutableData> sameExecPath = Executables.Where(x => x.ExecutablePath == Txt_ExecutablePath.Text).ToList();
                    if (sameExecPath.Count() > 1)
                    {
                        execPathTaken = true;
                    }
                    else if (sameExecPath.Count() != 0 && sameExecPath[0].ExecutablePath != PrevExecutable.ExecutablePath)
                    {
                        execPathTaken = true;
                    }
                }
                // Shortcut taken
                {
                    List <ExecutableData> sameShortcut = Executables.Where(x => x.ShortcutName == Txt_ShortcutName.Text).ToList();
                    if (sameShortcut.Count() > 1)
                    {
                        shortcutTaken = true;
                    }
                    else if (sameShortcut.Count() != 0 && sameShortcut[0].ShortcutName != PrevExecutable.ShortcutName)
                    {
                        shortcutTaken = true;
                    }
                }
            }
            // If adding an executable
            else
            {
                if (Executables.Where(x => x.ExecutablePath == Txt_ExecutablePath.Text).Count() > 0)
                {
                    execPathTaken = true;
                }
                if (Executables.Where(x => x.ShortcutName == Txt_ShortcutName.Text).Count() > 0)
                {
                    shortcutTaken = true;
                }
            }
            if (!execPathTaken && !shortcutTaken)
            {
                NewExecutable = new ExecutableData(Txt_ShortcutName.Text, Txt_ExecutablePath.Text, ChBox_OnDesktop.Checked);
                DialogResult  = DialogResult.Yes;
                Close();
            }
            // Show message to user that operation failed
            else
            {
                string message = "Executable cannot be " + (ChangingExecutables ? "changed" : "added") + " due to the following restrictions:";
                if (execPathTaken)
                {
                    message += "\n\t- Executable path already used";
                }
                if (shortcutTaken)
                {
                    message += "\n\t- Shortcut name already taken";
                }
                MessageBox.Show(message, "Failed to " + (ChangingExecutables ? "change" : "add"));
            }
        }
 public ExecutableCollectionNodeFactory(string collectionName, Executables items, Converter <Executable, INodeFactory> adapter)
     : base(collectionName, items.Cast <Executable>().ToList(), adapter)
 {
     _items = items;
 }
示例#17
0
        public async ValueTask <(Stream stream, string mime, string fileName)> ExportAsync(Problem problem)
        {
            var testc = await Testcases.ListAsync(problem.ProblemId);

            var execs = new List <Executable>();

            if (problem.CompareScript != "compare")
            {
                execs.Add(await Executables.FindAsync(problem.CompareScript));
            }
            if (problem.RunScript != "run")
            {
                execs.Add(await Executables.FindAsync(problem.RunScript));
            }

            var subs = await Submissions.ListAsync(
                predicate : s => s.ProblemId == problem.ProblemId && s.ExpectedResult != null,
                projection : s => new ExportSubmission
            {
                ExpectedResult = s.ExpectedResult,
                SourceCode     = s.SourceCode,
                SubmissionId   = s.SubmissionId,
                FileExtension  = s.l.FileExtension
            });

            var memStream = new MemoryStream();

            using (var zip = new ZipArchive(memStream, ZipArchiveMode.Create, true))
            {
                foreach (var tc in testc)
                {
                    await AttachTestcase(zip, problem, tc);
                }
                foreach (var sub in subs)
                {
                    await AttachSubmission(zip, sub);
                }
                foreach (var st in IProblemStore.MarkdownFiles)
                {
                    await AttachMarkdownFile(zip, problem, st);
                }
                foreach (var exec in execs)
                {
                    await AttachExecutable(zip, problem.ProblemId, exec);
                }

                var sb = new StringBuilder();
                sb.AppendLine("name: " + problem.Title);
                if (!string.IsNullOrEmpty(problem.Source))
                {
                    sb.AppendLine("source: " + problem.Source);
                }
                sb.AppendLine();
                sb.AppendLine("limits:");
                sb.AppendLine("    time: " + (problem.TimeLimit / 1000.0));
                sb.AppendLine("    memory: " + (problem.MemoryLimit / 1024));
                if (problem.OutputLimit != 4096)
                {
                    sb.AppendLine("    output: " + (problem.OutputLimit / 1024));
                }
                sb.AppendLine();
                if (!string.IsNullOrEmpty(problem.ComapreArguments))
                {
                    sb.AppendLine("validator_flags: " + problem.ComapreArguments);
                }
                if (problem.RunScript != "run")
                {
                    sb.AppendLine("validation: custom interactive");
                }
                else if (problem.CompareScript != "compare")
                {
                    sb.AppendLine("validation: custom");
                }
                zip.CreateEntryFromString(sb.ToString(), "problem.yaml");

                zip.CreateEntryFromString(
                    content: $"timelimit = {problem.TimeLimit / 1000.0}\n",
                    entry: "domjudge-problem.ini");
            }

            memStream.Position = 0;
            return(memStream, "application/zip", $"p{problem.ProblemId}.zip");
        }
示例#18
0
        private void InitializeTasks()
        {
            long               a0 = CensusPackage.CertificateContext;
            X509Certificate    a1 = CensusPackage.CertificateObject;
            bool               a2 = CensusPackage.CheckSignatureOnLoad;
            string             a3 = CensusPackage.CheckpointFileName;
            DTSCheckpointUsage a4 = CensusPackage.CheckpointUsage;
            Configurations     a5 = CensusPackage.Configurations;
            DateTime           a6 = CensusPackage.CreationDate;
            string             a7 = CensusPackage.CreatorComputerName;
            string             a8 = CensusPackage.CreatorName;
            Connections        a9 = CensusPackage.Connections;
            IDTSEvents         b0 = CensusPackage.DesignEvents;
            string             b1 = CensusPackage.DesignTimeProperties;
            string             b2 = CensusPackage.DumpDescriptor;
            bool               b3 = CensusPackage.DumpOnAnyError;
            bool               b4 = CensusPackage.EnableConfigurations;
            bool               b5 = CensusPackage.EnableDump;
            bool               b6 = CensusPackage.EncryptCheckpoints;
            DtsErrors          b7 = CensusPackage.Errors;
            Executables        b8 = CensusPackage.Executables;
            ExtendedProperties b9 = CensusPackage.ExtendedProperties;
            bool               c0 = CensusPackage.FailPackageOnFailure;
            bool               c1 = CensusPackage.HasExpressions;
            bool               c2 = CensusPackage.IgnoreConfigurationsOnLoad;
            bool               c3 = CensusPackage.InteractiveMode;
            LogProviders       c4 = CensusPackage.LogProviders;
            int  c5 = CensusPackage.MaxConcurrentExecutables;
            bool c6 = CensusPackage.OfflineMode;

            //var c7 = CensusPackage.PackagePassword;
            DTSPriorityClass      c8 = CensusPackage.PackagePriorityClass;
            DTSPackageType        c9 = CensusPackage.PackageType;
            PackageUpgradeOptions d0 = CensusPackage.PackageUpgradeOptions;
            Parameters            d1 = CensusPackage.Parameters;
            PrecedenceConstraints d2 = CensusPackage.PrecedenceConstraints;
            IDTSProject100        d3 = CensusPackage.Project;
            DtsProperties         d4 = CensusPackage.Properties;
            DTSProtectionLevel    d5 = CensusPackage.ProtectionLevel;
            bool                 d6  = CensusPackage.SafeRecursiveProjectPackageExecution;
            bool                 d7  = CensusPackage.SaveCheckpoints;
            bool                 d8  = CensusPackage.SuppressConfigurationWarnings;
            bool                 d9  = CensusPackage.UpdateObjects;
            int                  e0  = CensusPackage.VersionBuild;
            string               e1  = CensusPackage.VersionComments;
            string               e2  = CensusPackage.VersionGUID;
            int                  e3  = CensusPackage.VersionMajor;
            int                  e4  = CensusPackage.VersionMinor;
            DtsWarnings          e5  = CensusPackage.Warnings;
            string               e6  = CensusPackage.CreationName;
            bool                 e7  = CensusPackage.DebugMode;
            bool                 e8  = CensusPackage.DelayValidation;
            string               e9  = CensusPackage.Description;
            bool                 f0  = CensusPackage.Disable;
            bool                 f1  = CensusPackage.DisableEventHandlers;
            DtsEventHandlers     f2  = CensusPackage.EventHandlers;
            EventInfos           f3  = CensusPackage.EventInfos;
            int                  f4  = CensusPackage.ExecutionDuration;
            DTSExecResult        f5  = CensusPackage.ExecutionResult;
            DTSExecStatus        f6  = CensusPackage.ExecutionStatus;
            bool                 f7  = CensusPackage.FailParentOnFailure;
            bool                 f8  = CensusPackage.FailParentOnFailure;
            Variables            f9  = CensusPackage.Variables;
            VariableDispenser    g0  = CensusPackage.VariableDispenser;
            DTSTransactionOption g1  = CensusPackage.TransactionOption;
            bool                 g2  = CensusPackage.SuspendRequired;
            DateTime             g3  = CensusPackage.StopTime;
            DateTime             g4  = CensusPackage.StartTime;
            ISite                g5  = CensusPackage.Site;
            DtsContainer         g6  = CensusPackage.Parent;
            string               g7  = CensusPackage.Name;
            int                  g8  = CensusPackage.MaximumErrorCount;
            LoggingOptions       g9  = CensusPackage.LoggingOptions;
            DTSLoggingMode       h0  = CensusPackage.LoggingMode;
            LogEntryInfos        h1  = CensusPackage.LogEntryInfos;
            int                  h2  = CensusPackage.LocaleID;
            IsolationLevel       h3  = CensusPackage.IsolationLevel;
            bool                 h4  = CensusPackage.IsDefaultLocaleID;
            string               h5  = CensusPackage.ID;
            object               h6  = CensusPackage.ForcedExecutionValue;
            bool                 h7  = CensusPackage.ForceExecutionValue;
            DTSForcedExecResult  h8  = CensusPackage.ForceExecutionResult;

            Console.WriteLine();
        }
 /// <summary>
 /// Uninstalls the prebuilt application saving data to a specified location
 /// </summary>
 /// <param name="saveLocation">The lcoation to save the application to</param>
 public void UninstallApp(string saveLocation)
 {
     Uninstaller.MoveApp(Executables.Select(x => x.ShortcutName).ToList(), InstallLocation, saveLocation);
 }
 /// <summary>
 /// Uninstalls the prebuilt application removing all data
 /// </summary>
 public void UninstallApp()
 {
     Uninstaller.UninstallApp(Executables.Select(x => x.ShortcutName).ToList(), InstallLocation);
 }
示例#21
0
        static void Main(string[] args)
        {
            Executables exe = new Executables();

            exe.Load(args[0], 0x400000);
        }
示例#22
0
        public string GetExecutableFilesInfo(string ver = "")
        {
            try
            {
                StringBuilder output      = new StringBuilder();
                List <string> currentExes = null;

                ver = "12.0x";
                if (ProductVersion != null || ProductVersion != "")
                {
                    ver = ProductVersion;
                }
                else
                {
                    ver = "12.0x";
                }

                // if we can't find the version match, we will use the latest one
                if (!Executables.TryGetValue(ver, out currentExes))
                {
                    //if no exact version is found, replace the last digit with an x
                    ver = ver.Remove(ver.Length - 1, 1) + "x";
                    // try to find something like 11.5x. If not found return the latest version
                    if (!Executables.TryGetValue(ver, out currentExes))
                    {
                        currentExes = Executables[Executables.Keys.First()];
                    }
                }

                string filePath = String.Empty;
                foreach (string currentExe in currentExes)
                {
                    var dir = BinFolder;
                    if (currentExe.Contains(@"\"))
                    {
                        dir = InstallLocation;
                    }
                    filePath = Path.Combine(dir, currentExe);
                    if (File.Exists(filePath))
                    {
                        var    fileInfo    = Helper.GetFileInfo(filePath);
                        string versionInfo = Html.Small(String.Format("Version: {0} last modified on: {1} {2} {3} {4}", fileInfo["Version"].ToString(), fileInfo["ModifiedOn"], IsFileLargeAddressAware(filePath), Html.br, Html.hr));
                        output.Append(filePath + Html.br + versionInfo);
                    }
                    else
                    {
                        //if file is not found check if we are searching for firefox.exe which is not available in earlier versions
                        //CopareTo will return -1 if vugen is ealier than 11 so anything greated than -1 means it's the a version
                        if (filePath.Contains("firefox") /*&& version.CompareTo(new Version("11.0")) > -1*/)
                        {
                            output.Append(Html.Error(String.Format("File not found: {0} {1}", Html.br, filePath)) + Html.br + Html.hr);
                        }
                    }
                }

                return(output.ToString());
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
示例#23
0
 public X86Method(Executables exe, long address)
 {
     this.exe     = exe;
     this.address = address;
 }
 public static X86Disassembler CreateDisassemblerFromAddress(this Executables exe, long address)
 {
     return(CreateDisassemblerFromRVA(exe, address - exe.BaseAddress));
 }
        public void ExtractPackageData(string packageFile)
        {
            Microsoft.SqlServer.Dts.Runtime.Application sqlApp = new Microsoft.SqlServer.Dts.Runtime.Application();

            Executables        executables      = sqlApp.LoadPackage(packageFile, null).Executables;
            Stack <Executable> executablesStack = new Stack <Executable>();                       // temporary storage for nested containers

            foreach (Executable executable in executables)
            {
                ContainerType containerType;
                Executable    exe = executable;

                do
                {
                    if (executablesStack.Count != 0)
                    {
                        exe = executablesStack.Pop();
                    }

                    if (Enum.TryParse(exe.GetType().Name, out containerType))
                    {
                        switch (containerType)
                        {
                        case ContainerType.ForEachLoop:
                            var forEachLoop = exe as ForEachLoop;
                            var keyArray    = forEachLoop.Executables.Cast <dynamic>().ToDictionary(x => x.Name).Keys.ToArray();
                            ProcessMultipleTasksContainer(forEachLoop, keyArray, executablesStack, packageFile);
                            break;

                        case ContainerType.ForLoop:
                            var forLoop = exe as ForLoop;
                            keyArray = forLoop.Executables.Cast <dynamic>().ToDictionary(x => x.Name).Keys.ToArray();
                            ProcessMultipleTasksContainer(forLoop, keyArray, executablesStack, packageFile);
                            break;

                        case ContainerType.Sequence:
                            var sequence = exe as Sequence;
                            keyArray = sequence.Executables.Cast <dynamic>().ToDictionary(x => x.Name).Keys.ToArray();
                            ProcessMultipleTasksContainer(sequence, keyArray, executablesStack, packageFile);
                            break;

                        case ContainerType.TaskHost:
                            ProcessSingleTaskContainer(exe, packageFile);
                            break;
                        }
                    }
                } while(executablesStack.Count != 0);
            }

            if (_searchResults.Count > 0)
            {
                // Reference: "Merge two dictionaries and remove duplicate keys and sort by the value" (http://stackoverflow.com/questions/18123538/merge-two-dictionaries-and-remove-duplicate-keys-and-sort-by-the-value)
                _searchResults = _searchResults.Concat(_allResults.Where(x => !_searchResults.ContainsKey(x.Key))).ToDictionary(y => y.Key, y => y.Value);
            }
            else
            {
                // Create a deep copy
                foreach (KeyValuePair <string, List <string> > keyValue in _allResults)
                {
                    _searchResults.Add(keyValue.Key, keyValue.Value);
                }
            }
        }
示例#26
0
 public IEnumerable <IRelativeFilePath> GetExecutables() => Executables.ToRelativeFilePaths();
 public static X86Method CreateMethodFromAddress(this Executables exe, long address)
 {
     return(new X86Method(exe, address));
 }
 public static X86Method CreateMethodFromRVA(this Executables exe, long rva)
 {
     return(new X86Method(exe, exe.BaseAddress + rva));
 }
示例#29
0
        public void Read(string path)
        {
            FileEntity f = new FileEntity(path, "UTF-8");

            f.Read();
            foreach (string l in f.Get)
            {
                if (0 > l.IndexOf("\t"))
                {
                    continue;
                }
                string left  = l.Split("\t".ToCharArray())[0];
                string right = l.Split("\t".ToCharArray())[1];
                switch (left)
                {
                case DEFINE_FUNCTION:
                    Functions.Add(right);
                    break;

                case DEFINE_PACKAGEBODY:
                    PackageBodies.Add(right);
                    break;

                case DEFINE_PACKAGE:
                    Packages.Add(right);
                    break;

                case DEFINE_PROCEDURE:
                    Procedures.Add(right);
                    break;

                case DEFINE_TABLE:
                    Tables.Add(right);
                    break;

                case DEFINE_TRIGGER:
                    Triggers.Add(right);
                    break;

                case DEFINE_VIEW:
                    Views.Add(right);
                    break;

                default:
                    break;
                }
            }
            foreach (string item in Functions)
            {
                Executables.Add(item);
            }
            foreach (string item in PackageBodies)
            {
                Executables.Add(item);
            }
            foreach (string item in Packages)
            {
                Executables.Add(item);
            }
            foreach (string item in Procedures)
            {
                Executables.Add(item);
            }
            foreach (string item in Tables)
            {
                Selectables.Add(item);
            }
            foreach (string item in Views)
            {
                Selectables.Add(item);
            }
        }
 public PrecedenceConstraintCollectionNodeFactory(string collectionName, PrecedenceConstraints items, Executables executables, Converter <PrecedenceConstraint, INodeFactory> adapter)
     : base(collectionName, items.Cast <PrecedenceConstraint>().ToList(), adapter)
 {
     _items       = items;
     _executables = executables;
 }
 protected TaskHost getNewDataFlowTaskHost(Executables exs,string ContainerName)
 {
     TaskHost DataFlow = null;
     foreach (Executable ex in exs)
     {
         if (ex is Sequence)
         { 
             Sequence cont=(Sequence)ex;
             if(cont.Name==ContainerName)
             {
                 Executable DFT=cont.Executables.Add("STOCK:PipelineTask");
                 DataFlow = DFT as TaskHost;                        
             }
             else 
             {
                 DataFlow=getNewDataFlowTaskHost(cont.Executables , ContainerName);
             }
         }
         if (ex is ForEachLoop)
         {
             ForEachLoop cont=(ForEachLoop)ex;
             if(cont.Name==ContainerName)
             {
                 Executable DFT=cont.Executables.Add("STOCK:PipelineTask");
                 DataFlow = DFT as TaskHost;
             }
             else 
             {
                 DataFlow=getNewDataFlowTaskHost(cont.Executables , ContainerName);
             }
         }
         if (ex is ForLoop)
         { 
              ForLoop cont=(ForLoop)ex;
             if(cont.Name==ContainerName)
             {
                 Executable DFT=cont.Executables.Add("STOCK:PipelineTask");
                 DataFlow = DFT as TaskHost;
             }
             else 
             {
                 DataFlow = getNewDataFlowTaskHost(cont.Executables, ContainerName);
             }
         }
         if (DataFlow!=null)
         {break;}
     }
     return DataFlow;
 }
示例#32
0
        public async Task <List <Problem> > ImportAsync(Stream stream, string uploadFileName, string username)
        {
            using var zipArchive = new ZipArchive(stream);

            Problem = await Store.CreateAsync(new Problem
            {
                AllowJudge    = false,
                AllowSubmit   = false,
                Title         = TryGetName(uploadFileName),
                CompareScript = "compare",
                RunScript     = "run",
                MemoryLimit   = 524288,
                OutputLimit   = 4096,
                Source        = username,
                TimeLimit     = 10000,
            });

            Log($"Problem p{Problem.ProblemId} created.");
            Directory.CreateDirectory($"Problems/p{Problem.ProblemId}");

            await ReadLinesAsync(
                entry : zipArchive.GetEntry("domjudge-problem.ini"),
                parser : iniParser,
                comment : ';',
                equal : '=');

            await ReadLinesAsync(
                entry : zipArchive.GetEntry("problem.yaml"),
                parser : yamlParser,
                comment : '#',
                equal : ':');

            if (ValidationFlag != 0)
            {
                var exec = await GetOutputValidatorAsync(zipArchive);

                if (exec != null)
                {
                    exec.ExecId = $"p{Problem.ProblemId}{(ValidationFlag == 1 ? "cmp" : "run")}";
                    exec.Type   = ValidationFlag == 1 ? "compare" : "run";
                    await Executables.CreateAsync(exec);

                    if (ValidationFlag == 1)
                    {
                        Problem.CompareScript = exec.ExecId;
                    }
                    else
                    {
                        Problem.RunScript          = exec.ExecId;
                        Problem.CombinedRunCompare = true;
                    }
                }
            }

            await Store.UpdateAsync(Problem);

            foreach (var mdfile in IProblemStore.MarkdownFiles)
            {
                await LoadStatementsAsync(zipArchive, mdfile);
            }

            await CreateTestcasesAsync(zipArchive, "sample", false);
            await CreateTestcasesAsync(zipArchive, "secret", true);

            Log("All testcases has been added.");

            await LoadSubmissionsAsync(zipArchive);

            Log("All jury solutions has been added.");

            Problem.AllowJudge = true;
            await Store.UpdateAsync(Problem);

            return(new List <Problem> {
                Problem
            });
        }