Exemple #1
0
        internal void ExecuteTask()
        {
            this.IsRunning = true;
            var task = this.CreateTaskInstance();

            if (task != null)
            {
                this.LastRunStart = DateTime.Now;
                try
                {
                    task.Execute(this.XTaskElement);
                    this.IsLastRunSuccessful = true;
                }
                catch (Exception exception)
                {
                    this.IsLastRunSuccessful = false;
                    SueetieLogs.LogTaskException("Task Exception: " + exception.Message);
                }
                finally
                {
                    this.LastRunEnd = DateTime.Now;
                }
            }
            this.IsRunning = false;
        }
        private void Initialize()
        {
            _tasks = new List <SueetieTask>();

            var tasknodes = from tasknode in this.TaskConfig.Descendants("Task")
                            select new
            {
                Minutes      = (double)tasknode.Attribute("minutes"),
                Name         = (string)tasknode.Attribute("name"),
                TaskType     = Type.GetType((string)tasknode.Attribute("type"), true),
                Enabled      = (bool)tasknode.Attribute("enabled"),
                XTaskElement = tasknode
            };

            foreach (var _tasknode in tasknodes)
            {
                try
                {
                    var sueetieTask = new SueetieTask(_tasknode.Minutes * 60000);
                    sueetieTask.Minutes      = _tasknode.Minutes;
                    sueetieTask.Name         = _tasknode.Name;
                    sueetieTask.TaskType     = _tasknode.TaskType;
                    sueetieTask.Enabled      = _tasknode.Enabled;
                    sueetieTask.XTaskElement = _tasknode.XTaskElement;
                    _tasks.Add(sueetieTask);
                }
                catch (Exception exception)
                {
                    SueetieLogs.LogTaskException("Task Exception: " + exception.Message);
                }
            }
        }