Esempio n. 1
0
        private void buttonCheckTask_Click(object sender, RoutedEventArgs e)
        {
            if (Singleton.Instance.cur < CurrentTasks.Count)
            {
                var task = CurrentTasks[Singleton.Instance.cur];
                task.TaskCode = TextBoxTaskAnswer.Text;
                var Res = new TaskChecker().CheckTask(task);
                if (Res.Result)
                {
                    Singleton.Instance.corans++;
                    this.CorrectAns.Content = Singleton.Instance.corans.ToString();
                }

                using (var context = new ApplicationDbContext())
                {
                    var statistic = new Statistic
                    {
                        Date = DateTime.Now,
                        Task = task,
                        Mark = Res.Result ? 1 : 0,
                        User = MainWindow.User
                    };
                    context.Statistics.Add(statistic);
                }
            }
        }
Esempio n. 2
0
 private void OnEnable()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         Instance = this;
     }
 }
Esempio n. 3
0
        //====================================================================================== Service methods

        /// <summary>
        /// Start monitoring and reviving task executor agents.
        /// </summary>
        /// <param name="executionBasePath">The absolute path of the folder where the code is executing. This will be used for finding the agent executable if its configured path is relative.</param>
        /// <param name="logger">Helper object for logging.</param>
        /// <param name="taskManagementFolderPath">Optional path of the TaskManagement folder. Default: current execution folder.</param>
        public static void Startup(string executionBasePath, ILogger logger, bool delayedAgents, string taskManagementFolderPath = null)
        {
            _logger            = logger;
            _executionBasePath = executionBasePath;

            // TaskManagement path is different in case of Local and Distributed mode
            if (string.IsNullOrEmpty(taskManagementFolderPath))
            {
                // service mode: we look for the agent in the execution folder
                _agentPath = _executionBasePath;
            }
            else if (Path.IsPathRooted(taskManagementFolderPath))
            {
                _agentPath = taskManagementFolderPath;
            }
            else
            {
                _agentPath = Path.GetFullPath(Path.Combine(_executionBasePath, taskManagementFolderPath));
            }

            // add the agent executable name to the path
            _agentPath = Path.GetFullPath(Path.Combine(_agentPath, AGENT_PROCESSNAME + ".exe"));

            _agentProcesses = new Process[Configuration.TaskAgentCount];

            if (delayedAgents)
            {
                Checker = new TaskChecker();
            }
            else
            {
                Checker = new AgentChecker();
            }

            // We need a few seconds due time here, because if the heartbeat beats too soon the first time,
            // than there is a possibility that the Updater tool process (that starts the service as its
            // last step) is still running. That would lead to unwanted behavior, e.g. not starting agents.
            _agentTimer = new Timer(HeartBeatTimerElapsed, null, 3000, 5000);
        }
Esempio n. 4
0
 public TaskCheckerDecorator(TaskChecker taskChecker)
 {
     this.taskChecker = taskChecker;
 }