Ejemplo n.º 1
0
 /// <summary>
 /// 更新正在运行的引擎列表{正在运行的引擎列表}对象(即:一条记录
 /// </summary>
 public int Update(TaskEngine taskEngine)
 {
     using (var dbContext = UnitOfWork.Get(Unity.ContainerName))
     {
         return(new TaskEngineRepository(dbContext).Update(taskEngine));
     }
 }
Ejemplo n.º 2
0
        public void Start()
        {
            using (var store = new Store(_configuration))
            {
                var handlers = new RequestHandlers(_configuration, store);

                var engine = new TaskEngine(
                    new SocketListener(ZMQ.SocketType.REP, _configuration.Port, handlers.MapHandlers),
                    new SocketListener(ZMQ.SocketType.PULL, _configuration.PullPort, handlers.MapHandlers),
                    new Flusher(_configuration, store));

                using (var token = new CancellationTokenSource())
                    using (engine)
                    {
                        var task1 = engine.Start(token.Token, Timeout.Infinite);

                        if (task1.Wait(Timeout.Infinite))
                        {
                            Console.WriteLine("Done without forced cancelation"); // This line shouldn't be reached
                        }
                        else
                        {
                            Console.WriteLine("\r\nRequesting to cancel...");
                        }

                        token.Cancel();
                    }
            }
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            // Whole bunch of setup code.
            XmlElement taskNode  = new XmlDocument().CreateElement("MockTask");
            LoadedType taskClass = new LoadedType(typeof(MockTask), new AssemblyLoadInfo(typeof(MockTask).Assembly.FullName, null));

            engine = new Engine(@"c:\");
            Project        project        = new Project(engine);
            EngineCallback engineCallback = new EngineCallback(engine);

            taskExecutionModule = new MockTaskExecutionModule(engineCallback);
            int        handleId   = engineCallback.CreateTaskContext(project, null, null, taskNode, EngineCallback.inProcNode, new BuildEventContext(BuildEventContext.InvalidNodeId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidProjectContextId, BuildEventContext.InvalidTaskId));
            TaskEngine taskEngine = new TaskEngine
                                    (
                taskNode,
                null,                     /* host object */
                "In Memory",
                project.FullFileName,
                engine.LoggingServices,
                handleId,
                taskExecutionModule,
                null
                                    );

            taskEngine.TaskClass = taskClass;

            engineProxy          = new EngineProxy(taskExecutionModule, handleId, project.FullFileName, project.FullFileName, engine.LoggingServices, null);
            taskExecutionModule2 = new MockTaskExecutionModule(engineCallback, TaskExecutionModule.TaskExecutionModuleMode.MultiProcFullNodeMode);
            engineProxy2         = new EngineProxy(taskExecutionModule2, handleId, project.FullFileName, project.FullFileName, engine.LoggingServices, null);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加正在运行的引擎列表{正在运行的引擎列表}对象(即:一条记录
 /// </summary>
 public long Add(TaskEngine taskEngine)
 {
     using (var dbContext = UnitOfWork.Get(Unity.ContainerName))
     {
         return(new TaskEngineRepository(dbContext).Add(taskEngine));
     }
 }
Ejemplo n.º 5
0
        public static void WhenRetrievingAListOfClients_ThenTheListIsReturnedAlphabetically()
        {
            var engine = new TaskEngine();

            engine.SaveClient(new Client {
                Name = "Alphabet"
            });
            engine.SaveClient(new Client {
                Name = "Dacia"
            });
            engine.SaveClient(new Client {
                Name = "Volkswagen"
            });
            engine.SaveClient(new Client {
                Name = "Audi"
            });
            engine.SaveClient(new Client {
                Name = "BMW"
            });

            var clients = engine.GetClients();

            Assert.AreEqual(clients[0].Name, "Alphabet");
            Assert.AreEqual(clients[1].Name, "Audi");
            Assert.AreEqual(clients[2].Name, "BMW");
            Assert.AreEqual(clients[3].Name, "Dacia");
            Assert.AreEqual(clients[4].Name, "Volkswagen");
        }
Ejemplo n.º 6
0
Archivo: Target.cs Proyecto: 3F/IeXod
        /// <summary>
        /// Executes a task within a target. This method initializes a task engine for the given task, and then executes the task
        /// using the engine.
        /// </summary>
        /// <param name="taskNode"></param>
        /// <param name="hostObject"></param>
        /// <returns>true, if successful</returns>
        internal bool ExecuteOneTask(XmlElement taskNode, ITaskHost hostObject)
        {
            bool taskExecutedSuccessfully = false;

            string            projectFileOfTaskNode   = XmlUtilities.GetXmlNodeFile(taskNode, parentProject.FullFileName);
            BuildEventContext targetBuildEventContext = new BuildEventContext
                                                        (
                ParentProject.ProjectBuildEventContext.NodeId,
                this.id,
                ParentProject.ProjectBuildEventContext.ProjectContextId,
                ParentProject.ProjectBuildEventContext.TaskId
                                                        );
            int handleId = parentEngine.EngineCallback.CreateTaskContext(ParentProject, this, null, taskNode,
                                                                         EngineCallback.inProcNode, targetBuildEventContext);
            TaskExecutionModule taskExecutionModule = parentEngine.NodeManager.TaskExecutionModule;
            TaskEngine          taskEngine          = new TaskEngine(taskNode, hostObject, parentProject.FullFileName, projectFileOfTaskNode, parentEngine.LoggingServices, handleId, taskExecutionModule, targetBuildEventContext);

            taskExecutedSuccessfully =
                taskEngine.ExecuteTask
                (
                    TaskExecutionMode.ExecuteTaskAndGatherOutputs,
                    new Lookup(parentProject.evaluatedItemsByName, parentProject.evaluatedProperties, ParentProject.ItemDefinitionLibrary)
                );

            return(taskExecutedSuccessfully);
        }
Ejemplo n.º 7
0
        protected void FinializeTest(int playerIndex, TaskInfo task, TaskEngineEvent <TaskInfo> callback, TaskEngineEvent <TaskInfo> childTaskCallback = null)
        {
            long identity = 0;

            TaskEngine.GenerateIdentitifers(task, ref identity);

            TaskEngineEvent <TaskInfo> taskStateChangedEventHandler = null;

            taskStateChangedEventHandler = taskInfo =>
            {
                if (taskInfo.TaskId == task.TaskId)
                {
                    if (taskInfo.State != TaskState.Active)
                    {
                        m_engine.GetTaskEngine(playerIndex).TaskStateChanged -= taskStateChangedEventHandler;
                        callback(taskInfo);
                    }
                }
                else
                {
                    if (childTaskCallback != null)
                    {
                        childTaskCallback(taskInfo);
                    }
                }
            };
            m_engine.GetTaskEngine(playerIndex).TaskStateChanged += taskStateChangedEventHandler;
            m_engine.Submit(playerIndex, new TaskCmd(SerializedTask.FromTaskInfo(task)));

            RunEngine();
            Assert.Fail();
        }
Ejemplo n.º 8
0
    // Use this for initialization
    void Awake()
    {
        _taskEngine = FindObjectOfType <TaskEngine>();
        _configView = FindObjectOfType <ConfigureViewModel>();

        _waitingSprites = Resources.LoadAll <Sprite>("Sprites/Others");
        _trigger        = Input.GetKeyDown(TaskSettingsManager.TaskSettings.TriggerKeyVal);
    }
Ejemplo n.º 9
0
 public Window(Canvas canvas, MainWindow content)
 {
     this.canvas        = canvas;
     task               = new TaskEngine(canvas);
     desktop            = new DesktopEngine(canvas);
     middle             = new MiddleEngine(canvas);
     middle.click_prev += OnPrev;
     this.content       = content;
 }
Ejemplo n.º 10
0
 public SoftContext(MetroWindow window)
 {
     DmSystem              = new DmSystem(new DmPlugin());
     MainWindow            = window;
     HttpClient            = new HttpClient();
     IsLogin               = false;
     TaskEngine            = new TaskEngine();
     TaskEngine.OutMessage = ShowMessage;
 }
Ejemplo n.º 11
0
    // Use this for initialization
    void Awake()
    {
        _taskEngine = FindObjectOfType <TaskEngine>();
        _configView = FindObjectOfType <ConfigureViewModel>();

        _waitingSprite = Resources.LoadAll <Sprite>("Sprites/hourglass");
        _trigger       = Input.GetKeyDown(TaskSettingsManager.TaskSettings.TriggerKeyVal);

        _scannerDelayStart = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TracerDataCatcherTask"/> class.
        /// </summary>
        /// <param name="engine">The engine.</param>
        /// <param name="timeout">The timeout.</param>
        public TracerDataCatcherTask(TaskEngine engine, long timeout)
            : base(engine, timeout)
        {
            actualTaskState = BasicTaskStates.TASK_STATE_ILDE;
            debugMode       = Debug.DEBUG_MODE.CONSOLE;

            frameStart = new byte[TracerFrame.HEADER_PREFIX_DATA_LENGTH];

            debug("TracerDataCatcherTask() - Created");
        }
Ejemplo n.º 13
0
        public static void WhenAddingATaskForAClientThatDoesNotExist_ThenAnExceptionIsThrown()
        {
            var engine = new TaskEngine();

            var exception = Assert.Throws(() => engine.SaveTask(new Task {
                Id = "1", ClientName = "Vauxhall", Description = "Ability to configure a new Vauxhall car."
            }));

            Assert.AreEqual(exception.Message, "The supplied Client could not be found.");
        }
Ejemplo n.º 14
0
        public static void AbilityToStoreClients()
        {
            var engine = new TaskEngine();

            engine.SaveClient(new Client {
                Name = "BMW"
            });
            var clients = engine.GetClients();

            Assert.AreEqual(clients[0].Name, "BMW");
        }
Ejemplo n.º 15
0
        private void ReassignTasks(Guid fromUserId, Guid toUserId)
        {
            var tasks = TaskEngine.GetByResponsible(fromUserId, TaskStatus.Open);

            foreach (var task in tasks.Where(r => r.Responsibles.Any()))
            {
                AddToTeam(task.Project, toUserId);
                task.Responsibles = task.Responsibles.Where(r => r != fromUserId).ToList();
                task.Responsibles.Add(toUserId);
                TaskEngine.SaveOrUpdate(task, null, false);
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Since we could not derrive from TaskEngine and have no Interface, we need to overide the method in here and
 /// replace the calls when testing the class because of the calls to TaskEngine. If at a future time we get a mock task
 /// engine, Interface or a non sealed TaskEngine these methods can disappear.
 /// </summary>
 /// <returns></returns>
 virtual internal bool TaskEngineExecuteTask(
     TaskEngine taskEngine,
     TaskExecutionMode howTaskShouldBeExecuted,
     Lookup lookup
     )
 {
     return(taskEngine.ExecuteTask
            (
                howTaskShouldBeExecuted,
                lookup
            ));
 }
Ejemplo n.º 17
0
    void Awake()
    {
        _gameManager = TaskSettingsManager.TaskSettings;
        _taskEngine  = FindObjectOfType <TaskEngine>();
        _scannerIn   = FindObjectOfType <ScannerHandler>();

        //bring in task length from config..
        int.TryParse(_gameManager.TaskDuration, out _taskLengthLimit);
        //convert to ms...
        _taskLengthLimit = _taskLengthLimit * 1000;

        //take time stamp at task start
        _taskStartTime = (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond);
    }
Ejemplo n.º 18
0
        //need to create a layer from this portion....
        TaskExecutionMessage ITaskManager.ExecuteTaskById(Guid tenantId, Guid entityId, string entityName, Guid userId, string taskName, JObject payload)
        {
            var taskEngine       = new TaskEngine();
            var executionPayload = new TaskExecutionPayload {
                Payload    = payload,
                TenantId   = tenantId,
                Id         = entityId,
                EntityName = entityName,
                UserId     = userId
            };
            var value = taskEngine.GetValue(taskName, executionPayload);

            return(value);
        }
Ejemplo n.º 19
0
        public static void AbilityToGetATaskById_ThenTheCorrectTaskIsRetrieved()
        {
            var engine = new TaskEngine();

            engine.SaveTask(new Task {
                Description = "Ability to login to the order system.", Id = "1"
            });
            engine.SaveTask(new Task {
                Description = "Ability to logout of the order system.", Id = "2"
            });

            var result = engine.RetrieveTaskById("2");

            Assert.AreEqual(result.Description, "Ability to logout of the order system.");
        }
Ejemplo n.º 20
0
        public void ReassignTask()
        {
            var task = DataGenerator.GenerateTask(Project);

            task.Responsibles = new List <Guid> {
                From
            };
            task = TaskEngine.SaveOrUpdate(task, new List <int>(), false);

            ProjectsReassign.Reassign(From, To);

            task = TaskEngine.GetByID(task.ID);
            Assert.That(task.Responsibles, Has.No.Member(From));
            Assert.That(task.Responsibles, Has.Member(To));
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WidgetSettings = SettingsManager.Instance.LoadSettingsFor <ProjectsWidgetSettings>(SecurityContext.CurrentAccount.ID);

            ShowFollowingProjects = WidgetSettings.ShowFollowingProjects;
            ShowFollowingTasks    = WidgetSettings.ShowFollowingTasks;

            var taskFilter = new TaskFilter
            {
                SortBy       = "deadline",
                SortOrder    = true,
                MyProjects   = true,
                TaskStatuses = new List <TaskStatus> {
                    TaskStatus.Open
                }
            };

            if (WidgetSettings.ShowOnlyMyTasks)
            {
                taskFilter.ParticipantId = SecurityContext.CurrentAccount.ID;
            }

            tasksInMyProjects = TaskEngine.GetByFilter(taskFilter);

            var myProjects = new List <Project>(tasksInMyProjects.Select(r => r.Project).Distinct().Take(WidgetSettings.MyProjectsCount));

            if (!tasksInMyProjects.Any())
            {
                myProjects.AddRange(RequestContext.GetCurrentUserProjects().Take(WidgetSettings.MyProjectsCount));
            }

            IsMyProjectsExist = myProjects.Any();

            MyProjectsRepeater.DataSource = myProjects.OrderBy(r => r.Title);
            MyProjectsRepeater.DataBind();

            if (ShowFollowingProjects)
            {
                var followingProjects = new List <Project>(RequestContext.GetCurrentUserFollowingProjects().Take(WidgetSettings.FollowingProjectsCount));
                IsFollowingProjectsExist = followingProjects.Any();

                if (IsFollowingProjectsExist)
                {
                    FollowingProjectsRepeater.DataSource = followingProjects;
                    FollowingProjectsRepeater.DataBind();
                }
            }
        }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            Mutex mutex = new Mutex(true, "DeviceExtractionService", out Boolean createdNew);

            if (createdNew)
            {
                LanguageManager.SwitchAll(LanguageType.Cn);
                PluginAdapter.Instance.Initialization(null);
                EngineSetup setup  = new EngineSetup("isolatedTask", null);
                TaskEngine  engine = new TaskEngine(setup);
                engine.Start();
                Console.WriteLine("Task engin is running...:{0}", engine.IsRuning);
                Console.Read();
                mutex.ReleaseMutex();
            }
        }
Ejemplo n.º 23
0
        public static void AbilityToDeleteAClient()
        {
            var engine = new TaskEngine();

            engine.SaveClient(new Client {
                Name = "Audi"
            });
            engine.SaveClient(new Client {
                Name = "BMW"
            });

            engine.RemoveClientByName("Audi");

            var clients = engine.GetClients();

            Assert.AreEqual(clients.Count, 1);
            Assert.AreEqual(clients[0].Name, "BMW");
        }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            TaskEngine.Run("HW", () =>
            {
                Console.WriteLine("Sup");
            });

            TaskEngine.Run("HW", () =>
            {
                Console.WriteLine("Yo");
            });

            var x = TaskEngine.GetTask("HW");

            TaskEngine.WaitAll();

            _ = 5;
        }
Ejemplo n.º 25
0
        public static void AbilityToReorderTasks()
        {
            var engine = new TaskEngine();

            engine.SaveClient(new Client {
                Name = "Audi"
            });
            engine.SaveTask(new Task {
                ClientName = "Audi", Description = "Ability to login to the order system.", Id = "1"
            });
            engine.SaveTask(new Task {
                ClientName = "Audi", Description = "Ability to update an order.", Id = "2"
            });
            engine.SaveTask(new Task {
                ClientName = "Audi", Description = "Ability to filter Audi cars in the stock feed.", Id = "3"
            });
            engine.SaveTask(new Task {
                ClientName = "Audi", Description = "Ability for users to manage stock preferences.", Id = "4"
            });
            engine.SaveTask(new Task {
                ClientName = "Audi", Description = "Ability for stock management team to see vehicles that need taxing.", Id = "5"
            });
            engine.SaveTask(new Task {
                ClientName = "Audi", Description = "Ability to track the delivery of orders being shipped into the country.", Id = "6"
            });

            // TODO - Extend the engine here to re-order tasks. Look at the test assertions to see the expected ordering.

            // TODO - Swap 3 and 4
            engine.SwapTasks("3", "4");
            // TODO - Swap 2 and 6
            engine.SwapTasks("2", "6");

            var tasks = engine.GetTasksForClient("Audi");

            Assert.AreEqual(tasks[0].Id, "1");
            Assert.AreEqual(tasks[1].Id, "6");
            Assert.AreEqual(tasks[2].Id, "4");
            Assert.AreEqual(tasks[3].Id, "3");
            Assert.AreEqual(tasks[4].Id, "5");
            Assert.AreEqual(tasks[5].Id, "2");
        }
Ejemplo n.º 26
0
        internal EngineProxy CreateEngineProxyWithDummyTaskEngine(Engine e, Project p)
        {
            // UNDONE need a real handle Id and a real TEM pointer
            XmlElement taskNode = new XmlDocument().CreateElement("MockTask");

            BuildRequest      request = new BuildRequest(EngineCallback.invalidEngineHandle, "mockproject", null, (BuildPropertyGroup)null, null, -1, false, false);
            ProjectBuildState context = new ProjectBuildState(request, new ArrayList(), new BuildEventContext(0, 0, 0, 0));
            int        handleId       = e.EngineCallback.CreateTaskContext(p, null, context, taskNode, 0, new BuildEventContext(0, 0, 0, 0));
            TaskEngine taskEngine     = new TaskEngine
                                        (
                taskNode,
                null,                     /* host object */
                p.FullFileName,
                p.FullFileName,
                e.LoggingServices,
                handleId,
                e.NodeManager.TaskExecutionModule,
                new BuildEventContext(0, 0, 0, 0)
                                        );

            e.Scheduler.Initialize(new INodeDescription[] { null });
            return(new EngineProxy(e.NodeManager.TaskExecutionModule, handleId, p.FullFileName, p.FullFileName, e.LoggingServices, new BuildEventContext(0, 0, 0, 0)));
        }
Ejemplo n.º 27
0
        public static void AbilityToGetAllTasksAssociatedWithAClient()
        {
            var engine = new TaskEngine();

            engine.SaveClient(new Client {
                Name = "Audi"
            });
            engine.SaveClient(new Client {
                Name = "BMW"
            });

            engine.SaveTask(new Task {
                Id = "1", Description = "Ability to add an item from the Audi stock system.", ClientName = "Audi"
            });
            engine.SaveTask(new Task {
                Id = "2", Description = "Ability to remove an item from Audi the stock system .", ClientName = "Audi"
            });
            engine.SaveTask(new Task {
                Id = "3", Description = "Ability to retrieve an item from the Audi stock system.", ClientName = "Audi"
            });
            engine.SaveTask(new Task {
                Id = "4", Description = "Ability to add an item from the BMW stock system.", ClientName = "BMW"
            });
            engine.SaveTask(new Task {
                Id = "5", Description = "Ability to remove an item from the BMW stock system.", ClientName = "BMW"
            });
            engine.SaveTask(new Task {
                Id = "6", Description = "Ability to retrieve an item from the BMW stock system.", ClientName = "BMW"
            });

            var tasks = engine.GetTasksForClient("Audi");

            Assert.AreEqual(tasks.Count, 3);
            Assert.AreEqual(tasks.Any(x => x.Id == "1"), true);
            Assert.AreEqual(tasks.Any(x => x.Id == "2"), true);
            Assert.AreEqual(tasks.Any(x => x.Id == "3"), true);
        }
Ejemplo n.º 28
0
        public void ReassignSubtasks()
        {
            var task = DataGenerator.GenerateTask(Project);

            task.Responsibles = new List <Guid> {
                Admin
            };
            task = TaskEngine.SaveOrUpdate(task, new List <int>(), false);

            var subtask1 = DataGenerator.GenerateSubtask(task);

            subtask1.Responsible = From;
            subtask1             = SubtaskEngine.SaveOrUpdate(subtask1, task);

            var subtask2 = DataGenerator.GenerateSubtask(task);

            subtask2.Responsible = From;
            subtask2             = SubtaskEngine.SaveOrUpdate(subtask2, task);

            var subtask3 = DataGenerator.GenerateSubtask(task);

            subtask3.Responsible = From;
            subtask3             = SubtaskEngine.SaveOrUpdate(subtask3, task);
            SubtaskEngine.ChangeStatus(task, subtask3, TaskStatus.Closed);

            ProjectsReassign.Reassign(From, To);

            subtask1 = SubtaskEngine.GetById(subtask1.ID);
            Assert.That(subtask1.Responsible, Is.EqualTo(To));

            subtask2 = SubtaskEngine.GetById(subtask2.ID);
            Assert.That(subtask2.Responsible, Is.EqualTo(To));

            subtask3 = SubtaskEngine.GetById(subtask3.ID);
            Assert.That(subtask3.Responsible, Is.EqualTo(From));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// The thread procedure executes the tasks and calls callback once it is done
        /// </summary>
        virtual internal void ExecuteTask()
        {
            bool taskExecutedSuccessfully = true;

            Exception thrownException = null;
            bool      dontPostOutputs = false;

            if (profileExecution)
            {
                startTime = DateTime.Now.Ticks;
            }

            try
            {
                TaskEngine taskEngine = new TaskEngine(
                    taskXmlNode,
                    hostObject,
                    projectFileOfTaskNode,
                    parentProjectFullFileName,
                    loggingService,
                    handleId,
                    parentModule,
                    buildEventContext);

                // Set the directory to the one appropriate for the task
                if (FileUtilities.GetCurrentDirectoryStaticBuffer(currentDirectoryBuffer) != executionDirectory)
                {
                    Directory.SetCurrentDirectory(executionDirectory);
                }
                // if we're skipping task execution because the target is up-to-date, we
                // need to go ahead and infer all the outputs that would have been emitted;
                // alternatively, if we're doing an incremental build, we need to infer the
                // outputs that would have been produced if all the up-to-date items had
                // been built by the task
                if ((howToExecuteTask & TaskExecutionMode.InferOutputsOnly) != TaskExecutionMode.Invalid)
                {
                    bool targetInferenceSuccessful = false;

                    targetInferenceSuccessful =
                        TaskEngineExecuteTask
                            (taskEngine,
                            TaskExecutionMode.InferOutputsOnly,
                            lookupForInference
                            );

                    ErrorUtilities.VerifyThrow(targetInferenceSuccessful, "A task engine should never fail to infer its task's up-to-date outputs.");
                }

                // execute the task using the items that need to be (re)built
                if ((howToExecuteTask & TaskExecutionMode.ExecuteTaskAndGatherOutputs) != TaskExecutionMode.Invalid)
                {
                    taskExecutedSuccessfully =
                        TaskEngineExecuteTask
                            (taskEngine,
                            TaskExecutionMode.ExecuteTaskAndGatherOutputs,
                            lookupForExecution
                            );
                }
            }
            // We want to catch all exceptions and pass them on to the engine
            catch (Exception e)
            {
                thrownException          = e;
                taskExecutedSuccessfully = false;

                // In single threaded mode the exception can be thrown on the current thread
                if (parentModule.RethrowTaskExceptions())
                {
                    dontPostOutputs = true;
                    throw;
                }
            }
            finally
            {
                if (!dontPostOutputs)
                {
                    long executionTime = profileExecution ? DateTime.Now.Ticks - startTime : 0;
                    // Post the outputs to the engine
                    parentModule.PostTaskOutputs(handleId, taskExecutedSuccessfully, thrownException, executionTime);
                }
            }
        }
Ejemplo n.º 30
0
 // Use this for initialization
 void Awake()
 {
     _taskEngine   = FindObjectOfType <TaskEngine>();
     _configView   = FindObjectOfType <ConfigureViewModel>();
     _evalResponse = FindObjectOfType <EvalResponse>();
 }
Ejemplo n.º 31
0
        static int Main(string[] args)
        {
            CmdArgs cmdArgs = null;
             Exception last_exception = null;
             string task_block;

             try
             {
            Setup.StandartSetup();
            cmdArgs = new CmdArgs(args);

            //======================================================================================
            //Load configuration
            //======================================================================================
            Config cfg = new Config(cmdArgs.Parameter("cfg"));
            if (!cfg.Load())
            {
               Console.WriteLine("[{0}] Was not possible to load the configuration file '{1}'", DateTime.Now, cmdArgs.Parameter("cfg"));
               return -1;
            }

            //======================================================================================
            //Check to see if there are a specific name for the task block
            //======================================================================================
            if (cmdArgs.HasParameter("task"))
               task_block = cmdArgs.Parameter("task");
            else
               task_block = "task.config";

            //======================================================================================
            //Execute task
            //======================================================================================
            ConfigNode task_cfg = cfg.Root.ChildNodes.Find(delegate(ConfigNode node) { return node.Name == task_block; });
            if (task_cfg != null)
            {
               TaskEngine te = new TaskEngine();
               if (!te.LoadConfig(task_cfg))
               {
                  if ((last_exception = te.LastException) == null)
                     last_exception = new Exception("Unknow error during process of task configuration.");
               }
               if (!te.CreateNewHDF())
               {
                  if ((last_exception = te.LastException) == null)
                     last_exception = new Exception("Unknow error during process of task execution.");
               }
               te.End();
            }
            else
            {
               last_exception = new Exception("No task.config block found in configuration.");
            }

            if (cmdArgs.HasOption("verbose"))
            {
               if (last_exception != null)
                  Console.WriteLine("MohidHDF5Processor FAILED to complete the process.");
               else
                  Console.WriteLine("MohidHDF5Processor SUCCESSFULLY completed the process.");
            }

            //======================================================================================
            //Send STATUS e-mail if mail.config block exists
            //======================================================================================
            ConfigNode mail_cfg = cfg.Root.ChildNodes.Find(delegate(ConfigNode node) { return node.Name == "mail.config"; });
            if (mail_cfg != null)
            {
               MailEngine mail_engine = new MailEngine();

               if (!mail_engine.SendMail(mail_cfg, last_exception))
               {
                  Console.WriteLine("[{0}] Was not possible to send the status e-mail.", DateTime.Now);
                  if ((last_exception = mail_engine.LastException) != null)
                     Console.WriteLine("The message returned was: {0}", last_exception);
                  return -1;
               }
            }
            else if (last_exception != null)
            {
               throw last_exception;
            }
             }
             catch(Exception ex)
             {
            Console.WriteLine("[{0}] An unexpected exception happened. The message returned was: {1}", DateTime.Now, ex.Message);
            return -1;
             }

             return 0;

              //   HDFEngine engine = new HDFEngine();
              //   Exception last_ex = null;

              //   Console.WriteLine("Starting...");

              //   if (!engine.InitializeLibrary())
              //   {
              //      Console.WriteLine("Library start failed.");
              //      if ((last_ex = engine.LastException) != null)
              //         Console.WriteLine("Message: {0}", last_ex.Message);
              //   }

              //   if (!engine.OpenHDF(new FileName(@"E:\Development\Tests\HDF5\basin.evtp.hdf5")))
              //   {
              //      Console.WriteLine("File Open failed.");
              //      if ((last_ex = engine.LastException) != null)
              //         Console.WriteLine("Message: {0}", last_ex.Message);
              //   }

              //   Console.WriteLine("ROOT: '/'");
              //   List<HDFObjectInfo> list = engine.GetTree(null, engine.FileID, "/");
              //   PrintList(list, 0);

              //   Console.WriteLine("");

              //   Console.WriteLine("ROOT: '/Grid/'");
              //   list.Clear();
              //   list = engine.GetTree(null, engine.FileID, "/Grid/");
              //   PrintList(list, 1);

              //   if (!engine.CloseHDF())
              //   {
              //      Console.WriteLine("File Close failed.");
              //      if ((last_ex = engine.LastException) != null)
              //         Console.WriteLine("Message: {0}", last_ex.Message);
              //   }

              //   if (!engine.CloseLibrary())
              //   {
              //      Console.WriteLine("Library close failed.");
              //      if ((last_ex = engine.LastException) != null)
              //         Console.WriteLine("Message: {0}", last_ex.Message);
              //   }

              //   Console.WriteLine("End. Press any key.");
              //   Console.ReadKey();
              //}

              //public static void PrintList(List<HDFObjectInfo> list, int level)
              //{
              //   foreach (HDFObjectInfo oi in list)
              //   {
              //      Console.WriteLine("{0}: {1}", level, oi.Name);
              //      if (oi.Children != null)
              //         PrintList(oi.Children, level + 1);
              //   }
        }