Exemplo n.º 1
0
            /// <summary>
            /// Deserializes this object from the specified XmlSerializatonContext.
            /// </summary>
            /// <param name="xmlsc">The XmlSerializatonContext from which this object is to be reconstituted.</param>
            public void DeserializeFrom(XmlSerializationContext xmlsc)
            {
                model = (Model)xmlsc.ContextEntities["Model"];
                Task rootTask = (Task)xmlsc.LoadObject("Parent");

                tp = new TaskProcessor(model, "TP_Reloaded", Guid.NewGuid(), rootTask);
                tp.KeepGraphContexts = true;

                foreach (TestTask task in tp.MasterTask.GetChildTasks(false))
                {
                    if (task.Name.Equals("TaskA"))
                    {
                        ta = task;
                    }
                    if (task.Name.Equals("TaskB"))
                    {
                        tb = task;
                    }
                    if (task.Name.Equals("TaskC"))
                    {
                        tc = task;
                    }
                    if (task.Name.Equals("TaskD"))
                    {
                        td = task;
                    }
                }
            }
Exemplo n.º 2
0
            public TestGraph1()
            {
                model = new Model();
                model.AddService <ITaskManagementService>(new TaskManagementService());


                parent = new TestTask(model, "Parent");
                follow = new TestTask(model, "Follow");

                tp = new TaskProcessor(model, "TP", parent);
                tp.KeepGraphContexts = true;

                ta = new TestTask(model, "TaskA", TimeSpan.FromHours(4));
                tb = new TestTask(model, "TaskB", TimeSpan.FromHours(1));
                tc = new TestTask(model, "TaskC", TimeSpan.FromHours(1));
                td = new TestTask(model, "TaskD", TimeSpan.FromHours(1));

                parent.AddChildEdge(ta);
                parent.AddChildEdge(tb);
                parent.AddChildEdge(tc);
                parent.AddChildEdge(td);
                ta.AddSuccessor(tb);
                tc.AddSuccessor(td);
                parent.AddSuccessor(follow);
            }
Exemplo n.º 3
0
 /// <summary>
 /// Adds a task processor to this model. A Task Processor is an entity that knows when to
 /// start executing a given task graph. This method must be called before the model starts.
 /// </summary>
 /// <param name="taskProcessor">The task processor being added to this model.</param>
 public void AddTaskProcessor(TaskProcessor taskProcessor)
 {
     // TODO: Add this to an Errors & Warnings collection instead of dumping it to Trace.
     if (m_taskProcessors.Contains(taskProcessor.Guid))
     {
         _Debug.WriteLine("Model already contains task processor being added at:");
         _Debug.WriteLine((new StackTrace()).ToString());
         _Debug.WriteLine("...the request to add it will be ignored.");
         return;
     }
     m_taskProcessors.Add(taskProcessor.Guid, taskProcessor);
     TaskProcessorAddedEvent?.Invoke(this, taskProcessor);
 }
Exemplo n.º 4
0
        public void TestChildSequencing()
        {
            Model model = new Model();

            model.AddService <ITaskManagementService>(new TaskManagementService());

            TestTask parent = new TestTask(model, "Parent");

            TaskProcessor tp = new TaskProcessor(model, "TP", parent)
            {
                KeepGraphContexts = true
            };

            model.GetService <ITaskManagementService>().AddTaskProcessor(tp);


            TestTask[] children = new TestTask[5];
            for (int i = 0; i < children.Length; i++)
            {
                children[i] = new TestTask(model, "Child" + i, TimeSpan.FromHours(i));
                if (i > 0)
                {
                    children[i].AddPredecessor(children[i - 1]);
                }
                parent.AddChildEdge(children[i]);
            }

            model.Start();

            IDictionary gc = (IDictionary)tp.GraphContexts[0];

            Assert.AreEqual(new DateTime(1, 1, 1, 0, 0, 0), parent.GetStartTime(gc), "Parent task did't start at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 0, 0, 0), children[0].GetStartTime(gc), "Child task 1 did't start at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 0, 0, 0), children[1].GetStartTime(gc), "Child task 2 did't start at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 1, 0, 0), children[2].GetStartTime(gc), "Child task 3 did't start at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 3, 0, 0), children[3].GetStartTime(gc), "Child task 4 did't start at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 6, 0, 0), children[4].GetStartTime(gc), "Child task 5 did't start at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 0, 0, 0), children[0].GetFinishTime(gc), "Child task 1 did't finish at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 1, 0, 0), children[1].GetFinishTime(gc), "Child task 2 did't finish at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 3, 0, 0), children[2].GetFinishTime(gc), "Child task 3 did't finish at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 6, 0, 0), children[3].GetFinishTime(gc), "Child task 4 did't finish at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 10, 0, 0), children[4].GetFinishTime(gc), "Child task 5 did't finish at the correct time.");
            Assert.AreEqual(new DateTime(1, 1, 1, 10, 0, 0), parent.GetFinishTime(gc), "Parent task did't finish at the correct time.");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Removes a task processor from this model. This method must be called before the model starts.
 /// </summary>
 /// <param name="taskProcessor">The task processor being removed from this model.</param>
 public void RemoveTaskProcessor(TaskProcessor taskProcessor)
 {
     m_taskProcessors.Remove(taskProcessor.Guid);
     TaskProcessorRemovedEvent?.Invoke(this, taskProcessor);
 }