コード例 #1
0
 // TODO: Could we lose the constraint information in Container from doing this as ContainerBase?
 public SsisContainer(SequenceTask container, SSISEmitterContext context)
     : base(container, context)
 {
     this._logicalContainer = container;
     if (this.Name != null && this.ParentContainer != null)
     {
         if (this.ParentContainer.Executables.Contains(Name))
         {
             if (this.ParentContainer.Executables[Name] is DTS.IDTSSequence)
             {
                 _SSISContainer = (DTS.Sequence) this.ParentContainer.Executables[Name];
             }
         }
         else
         {
             DTS.Sequence sequence = (DTS.Sequence)context.SSISSequence.AppendExecutable("STOCK:Sequence");
             sequence.Name  = this.Name;
             _SSISContainer = sequence;
         }
     }
     else if (container is Package)
     {
         // Do Nothing
     }
     else
     {
         MessageEngine.Global.Trace(Severity.Error, new ArgumentException("parentContainer cannot be null"), "parentContainer cannot be null");
     }
 }
コード例 #2
0
ファイル: Tests.cs プロジェクト: Paha-Zul/SimpleBehaviourTree
        private static void TestSelectorOfSequences()
        {
            var bb = new BlackBoard();

            var main = new SelectorTask("Main Selector");

            var s1 = new SequenceTask("Sequence 1");
            var s2 = new SequenceTask("Sequence 2");
            var s3 = new SequenceTask("Sequence 3");

            s1.AddChildTask(new TestSuccessLeaf("1"));
            s1.AddChildTask(new TestSuccessLeaf("2"));
            s1.AddChildTask(new AlwaysTrueTask(new TestFailureLeaf("3")));

            s2.AddChildTask(new TestSuccessLeaf("1"));
            s2.AddChildTask(new TestFailureLeaf("2"));
            s2.AddChildTask(new TestSuccessLeaf("3"));

            s3.AddChildTask(new TestSuccessLeaf("1"));
            s3.AddChildTask(new TestSuccessLeaf("2"));
            s3.AddChildTask(new TestSuccessLeaf("3"));

            main.AddChildTask(s1);
            main.AddChildTask(s2);
            main.AddChildTask(s3);

            SetTimer(main, bb);
        }
コード例 #3
0
        public void SequenceWithChildFailureReturnsFailure(
            [Range(1, 10)] int iterations)
        {
            var childTasks = new List <ITask>();

            for (int i = 0; i < iterations; ++i)
            {
                childTasks.Add(i < iterations - 1
                    ? new StatusActionTask(TaskStatus.Success)
                    : new StatusActionTask(TaskStatus.Failure));
            }

            var sequenceTask = new SequenceTask(childTasks);

            for (int i = 0; i < iterations; ++i)
            {
                var taskStatus = sequenceTask.Tick();

                if (i < iterations - 1)
                {
                    Assert.AreEqual(TaskStatus.Incomplete, taskStatus);
                }
                else
                {
                    Assert.AreEqual(TaskStatus.Failure, taskStatus);
                }
            }
        }
コード例 #4
0
        public void SequenceWithSuccessChildrenReturnsIncompleteUntilAllChildrenSucceed(
            [Range(1, 10)] int iterations)
        {
            var childTasks = new List <ITask>();

            for (int i = 0; i < iterations; ++i)
            {
                childTasks.Add(new StatusActionTask(TaskStatus.Success));
            }

            var sequenceTask = new SequenceTask(childTasks);

            for (int i = 0; i < iterations; ++i)
            {
                var taskStatus = sequenceTask.Tick();

                if (i < iterations - 1)
                {
                    Assert.AreEqual(TaskStatus.Incomplete, taskStatus);
                }
                else
                {
                    Assert.AreEqual(TaskStatus.Success, taskStatus);
                }
            }
        }
コード例 #5
0
        public void Ctor(int endIndex)
        {
            // Act
            var actualValue = new SequenceTask(endIndex);

            // Assert
            Assert.Equal(endIndex, actualValue.End);
        }
コード例 #6
0
        public TaskStatus SequenceWithOneChildAfterOneTickReturns(TaskStatus taskStatus)
        {
            var task         = new StatusActionTask(taskStatus);
            var sequenceTask = new SequenceTask(new List <ITask> {
                task
            });

            return(sequenceTask.Tick());
        }
コード例 #7
0
ファイル: TasksTests.cs プロジェクト: suprot1ve/EasyQuiz
        public void TestAddSequenceAnswer()
        {
            CurrentQuiz.Data.AddNewTask(new CreatorSequenceTask());
            CurrentQuiz.Data.Tasks[0].AddNewAnswer();
            SequenceTask task = CurrentQuiz.Data.Tasks[0] as SequenceTask;

            Assert.AreEqual(task.Answers[0].Value, "Ваш ответ...");
            Assert.AreEqual(task.Answers[0].GetType(), typeof(SequenceAnswer));
        }
コード例 #8
0
 public SsisSequence(DTS.IDTSSequence dtsSequence, SequenceTask objContainer)
 {
     if (objContainer.ConstraintMode != "Linear" && objContainer.ConstraintMode != "Parallel")
     {
         MessageEngine.Global.Trace(Severity.Error, "Unknown ConstraintMode: {0} ", objContainer.ConstraintMode);
     }
     _constraintMode  = objContainer.ConstraintMode;
     _transactionMode = objContainer.TransactionMode;
     _dtsSequence     = dtsSequence;
 }
コード例 #9
0
        public void Calculate_Positive(int endIndex, params int[] args)
        {
            // Arrange
            var operation = new SequenceTask(endIndex);

            // Act
            var actualValue = (MathOperationResult)sequenceOperation.Calculate(operation);

            // Assert
            Assert.Equal(args, actualValue.Result);
        }
コード例 #10
0
        public void CanCalculate_Positive()
        {
            // Arrange
            var operation = new SequenceTask(0);

            // Act
            var actualValue = sequenceOperation.CanCalculate(operation);

            // Assert
            Assert.True(actualValue);
        }
コード例 #11
0
        public void CanCalculate_Negative()
        {
            // Arrange
            var operation = new SequenceTask(0);

            // Act
            var actualValue = fibonacciOperation.CanCalculate(operation);

            // Assert
            Assert.False(actualValue);
        }
コード例 #12
0
        public void Calculate_Sequence(int endIndex, params int[] result)
        {
            // Arrange
            var sequenceTask = new SequenceTask(endIndex);

            // Act
            var actualValue = (MathOperationResult)appEnvironment.Calculate(sequenceTask);

            // Assert
            Assert.Equal(result, actualValue.Result);
        }
コード例 #13
0
ファイル: TestBehaviorTree.cs プロジェクト: ajon542/Keyfall
    void Start()
    {
        var sequenceTask = new SequenceTask(new List <ITask>
        {
            new SucceederTask(new IsWithinSight(_sourceTransform, _targetTransform, 5)),
            new MoveTowardsAction(_sourceTransform, _targetTransform, 5)
        }, true);

        _behaviorTree = new BehaviourTree(sequenceTask);

        // Idle until player is within sight
    }
コード例 #14
0
        public void SequenceContinuesToReturnResultAfterMultipleTicks(
            [Values(TaskStatus.Success, TaskStatus.Failure)] TaskStatus taskStatus)
        {
            var task         = new StatusActionTask(taskStatus);
            var sequenceTask = new SequenceTask(new List <ITask> {
                task
            });

            Assert.AreEqual(taskStatus, sequenceTask.Tick());
            Assert.AreEqual(taskStatus, sequenceTask.Tick());
            Assert.AreEqual(taskStatus, sequenceTask.Tick());
        }
コード例 #15
0
ファイル: QuizTests.cs プロジェクト: suprot1ve/EasyQuiz
        public void TestAddSequenceTask()
        {
            Quiz quiz = new Quiz("MyQuiz");

            quiz.AddNewTask(new CreatorSequenceTask());
            Assert.AreEqual(quiz.Tasks.Count, 1);
            SequenceTask task = quiz.Tasks[0] as SequenceTask;

            Assert.IsNotNull(task);
            Assert.AreEqual(task.Question, "Введите вопрос...");
            Assert.AreEqual(task.Point, 1);
            Assert.AreEqual(task.Answers.Count, 0);
            Assert.AreEqual(task.Answers.GetType(), typeof(ObservableCollection <SequenceAnswer>));
        }
コード例 #16
0
ファイル: Tests.cs プロジェクト: Paha-Zul/SimpleBehaviourTree
        private static void TestSimpleSequence()
        {
            var bb = new BlackBoard();

            var sequence = new SequenceTask("Main Sequence");

            sequence.AddChildTask(new TestSuccessLeaf("1"));
            sequence.AddChildTask(new TestSuccessLeaf("2"));
            sequence.AddChildTask(new TestSuccessLeaf("3"));
            sequence.AddChildTask(new TestFailureLeaf("4"));
            sequence.AddChildTask(new TestSuccessLeaf("5"));

            SetTimer(sequence, bb);
        }
コード例 #17
0
        public void SequenceWithChildrenIncompleteReturnsIncomplete(
            [Range(1, 10)] int iterations)
        {
            var childTasks = new List <ITask>();

            for (int i = 0; i < iterations; ++i)
            {
                childTasks.Add(new StatusActionTask(TaskStatus.Incomplete));
            }

            var sequenceTask = new SequenceTask(childTasks);

            for (int i = 0; i < 1000; ++i)
            {
                Assert.AreEqual(TaskStatus.Incomplete, sequenceTask.Tick());
            }
        }
コード例 #18
0
ファイル: Sequence.cs プロジェクト: llenroc/KinectScan
        private void SaveThread(object o)
        {
            int          id = (int)o;
            bool         taskfound;
            SequenceTask task = new SequenceTask();

            while (SequenceRecording)
            {
                SaveAREs[id].WaitOne();
                Interlocked.Increment(ref SaveThreadsActive);
                while (SequenceTasks.Count > 0)
                {
                    lock (SequenceTasks)
                    {
                        if (SequenceTasks.Count > 0)
                        {
                            task      = SequenceTasks.Dequeue();
                            taskfound = true;
                        }
                        else
                        {
                            taskfound = false;
                        }
                    }

                    if (taskfound)
                    {
                        try
                        {
                            if (File.Exists(task.FileName))
                            {
                                File.Delete(task.FileName);
                            }
                            File.WriteAllBytes(task.FileName, task.Data);
                        }
                        catch { }
                    }
                }
                if (SaveThreadsActive == 0)
                {
                    Debugger.Break();
                }
                Interlocked.Decrement(ref SaveThreadsActive);
            }
        }
コード例 #19
0
ファイル: Tests.cs プロジェクト: Paha-Zul/SimpleBehaviourTree
        private static void TestSequenceInSequence()
        {
            var bb = new BlackBoard();

            var main = new SequenceTask("Main Sequence");
            var s2   = new SequenceTask("Child Sequence");

            main.AddChildTask(new TestSuccessLeaf("1"));
            main.AddChildTask(new TestSuccessLeaf("2"));
            main.AddChildTask(new TestSuccessLeaf("3"));

            s2.AddChildTask(new TestSuccessLeaf("c 1"));
            s2.AddChildTask(new TestSuccessLeaf("c 2"));
            main.AddChildTask(s2);

            main.AddChildTask(new TestSuccessLeaf("4"));

            SetTimer(main, bb);
        }
コード例 #20
0
        private void AddJobSteps(Data.Job sourceJob, MVPSI.JAMS.Job targetJob)
        {
            var sequenceTask = new SequenceTask();

            sequenceTask.Properties.SetValue("ParentTaskID", Guid.Empty);

            var archonSteps = Container.GetInstance <IJobStepRepository>().GetAllLive()
                              .Where(js => js.JobUID == sourceJob.JobUID)
                              .OrderBy(js => js.DisplayID)
                              .Select(js => new ArchonStepDto
            {
                ArchonStepName      = js.StepName,
                ArchonConfiguration = js.ConfigurationFile,
                ParentTaskID        = sequenceTask.ElementUid,
                DisplayTitle        = js.StepName,
                ExecutionModule     = Container.GetInstance <IExecutionModuleRepository>().GetAll()
                                      .FirstOrDefault(em => em.ModuleUID == js.ModuleUID)
            }).ToList();

            if (!archonSteps.Any())
            {
                return;
            }

            targetJob.SourceElements.Add(sequenceTask);

            //SelectAgent(archonSteps, targetJob);

            foreach (var archonStep in archonSteps)
            {
                if (!archonStep.ExecutionModule.ModuleObject.Equals("Archon.Modules.CommandEvent") &&
                    !archonStep.ExecutionModule.ModuleObject.Equals("Archon.Modules.SqlProcessEvent"))
                {
                    var task = new Element
                    {
                        ElementTypeName = "ArchonStep"
                    };
                    task.Properties.SetValue("ParentTaskID", archonStep.ParentTaskID);
                    task.Properties.SetValue("DisplayTitle", archonStep.DisplayTitle);
                    task.Properties.SetValue("ArchonStepName", archonStep.ArchonStepName);
                    task.Properties.SetValue("ArchonModuleName", archonStep.ExecutionModule.ModuleName);
                    task.Properties.SetValue("ArchonConfiguration", archonStep.ArchonConfiguration);
                    task.Properties.SetValue("ArchonModuleAssembly", ModuleAssemblyConverter.FromString(archonStep.ExecutionModule.ModuleAssembly));
                    task.Properties.SetValue("ArchonModuleObject", ModuleObjectConverter.FromString(archonStep.ExecutionModule.ModuleObject));
                    task.Properties.SetValue("ArchonCategoryName", CategoryConverter.FromGUID(sourceJob.Category));
                    targetJob.SourceElements.Add(task);
                }
                else
                {
                    string parsedPath = null;

                    try
                    {
                        parsedPath = JobConversionHelper.ParsePath(archonStep.ArchonConfiguration, sourceJob.Category);
                        var content     = File.ReadAllText($@"C:\Users\RoniAxelrad\Desktop\Woodforest\XMLs\{parsedPath}");
                        var xmlDocument = JobConversionHelper.ToXml(content);

                        if (archonStep.ExecutionModule.ModuleObject.Equals("Archon.Modules.CommandEvent"))
                        {
                            var task = new Element
                            {
                                ElementTypeName = "PowerShellScriptTask"
                            };
                            task.Properties.SetValue("ParentTaskID", archonStep.ParentTaskID);
                            task.Properties.SetValue("DisplayTitle", archonStep.DisplayTitle);

                            var command      = JobConversionHelper.ParseToCommand(xmlDocument);
                            var fixedCommand = JobConversionHelper.TranslateKeywords(command, sourceJob.Category.Value);
                            if (fixedCommand.Contains("YesterdayDate"))
                            {
                                var yesterdayParam = new Param("YesterdayDate")
                                {
                                    DataType = DataType.Date,
                                    Length   = 8,
                                };
                                yesterdayParam.Properties.SetValue("DefaultValue", "YESTERDAY");
                                targetJob.Parameters.Add(yesterdayParam);
                            }

                            task.Properties.SetValue("PSScript", fixedCommand);
                            targetJob.SourceElements.Add(task);
                        }

                        if (archonStep.ExecutionModule.ModuleObject.Equals("Archon.Modules.SqlProcessEvent"))
                        {
                            var elemList = xmlDocument.GetElementsByTagName("event");

                            foreach (XmlElement sqlActivity in elemList)
                            {
                                var task = new Element
                                {
                                    ElementTypeName = "SqlQueryTask"
                                };
                                task.Properties.SetValue("ParentTaskID", archonStep.ParentTaskID);
                                task.Properties.SetValue("DisplayTitle", archonStep.DisplayTitle);

                                var server   = JobConversionHelper.TranslateKeywords(sqlActivity.Attributes["server"].Value, sourceJob.Category.Value);
                                var database = JobConversionHelper.TranslateKeywords(sqlActivity.Attributes["database"].Value, sourceJob.Category.Value);

                                if (!_connectionStoreDictionary.TryGetValue(server, out var connectionStore))
                                {
                                    connectionStore = JobConversionHelper.CreateConnectionStore(sqlActivity, sourceJob.Category.Value);
                                    _connectionStoreDictionary.Add(connectionStore.AgentName, connectionStore);
                                }

                                var sqlCommand = JobConversionHelper.TranslateKeywords(
                                    GetInnerTexts(sqlActivity.GetElementsByTagName("executesql")),
                                    sourceJob.Category.Value
                                    );
                                task.Properties.SetValue("SqlQueryText", sqlCommand);
                                task.Properties.SetValue("DatabaseName", database);
                                task.Properties.SetValue("SqlAgent", new AgentReference(connectionStore));

                                targetJob.SourceElements.Add(task);
                            }
                        }

                        string GetInnerTexts(XmlNodeList nodeList)
                        {
                            var sb = new StringBuilder();

                            foreach (XmlNode node in nodeList)
                            {
                                sb.AppendLine($"{node.InnerText.Trim()};");
                            }

                            return(sb.ToString());
                        }
                    }
                    catch (FileNotFoundException)
                    {
                        Log.Logger.Error(
                            $"Config File Is Missing! {parsedPath} --> StepName: {archonStep.ArchonStepName}, Module: {archonStep.ExecutionModule.ModuleObject}");
                        return;
                    }
                    catch (DirectoryNotFoundException)
                    {
                        Log.Logger.Error(
                            $"Config Folder Is Missing! {parsedPath} --> StepName: {archonStep.ArchonStepName}, Module: {archonStep.ExecutionModule.ModuleObject}");
                        return;
                    }
                    catch (Exception ex)
                    {
                        Log.Logger.Error(ex, ex.Message);
                        return;
                    }
                }
            }
        }
コード例 #21
0
ファイル: LogPlatformEmitter.cs プロジェクト: mosamy/vulcan
        public string LogEnd(SequenceTask logContainer, string logIDName)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogEnd", logIDName);

            return(te.Emit(logContainer));
        }
コード例 #22
0
ファイル: LogPlatformEmitter.cs プロジェクト: mosamy/vulcan
        public string LogSetValue(SequenceTask logContainer, string logIDName, string pathVariable, string nameVariable, string value)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogSetValue", logIDName, pathVariable, nameVariable, value);

            return(te.Emit(logContainer));
        }
コード例 #23
0
ファイル: LogPlatformEmitter.cs プロジェクト: mosamy/vulcan
        public string LogPrepareToSetValue(SequenceTask logContainer)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogPrepareToSetValue");

            return(te.Emit(logContainer));
        }
コード例 #24
0
ファイル: LogPlatformEmitter.cs プロジェクト: mosamy/vulcan
        public string LogGetPredefinedValues(SequenceTask logContainer)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogGetPredefinedValues");

            return(te.Emit(logContainer));
        }
コード例 #25
0
ファイル: LogPlatformEmitter.cs プロジェクト: mosamy/vulcan
        public string LogStart(SequenceTask logContainer, string packageName, string taskName, string varScopeXML)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogStart", packageName, taskName, varScopeXML);

            return(te.Emit(logContainer));
        }