/// <summary>
        /// It is used to add view models and set current collection to another view model.
        /// </summary>
        private void AddChildViewModels()
        {
            this.ChildViewModels = new Collection <BaseViewModel>();

            JobManagerViewModel jobManagerViewModel = new JobManagerViewModel(this);

            this.ChildViewModels.Add(jobManagerViewModel);
            SummaryViewModel summaryViewModel = new SummaryViewModel(this, jobManagerViewModel);

            this.ChildViewModels.Add(summaryViewModel);

            this.CompletedStage = this.ChildViewModels.Count - 1;
        }
Beispiel #2
0
        public JobPoolControllerActor(IActorRef api, JobManagerViewModel mainVm)
        {
            _api = api;
            this.jobManagerViewModel = mainVm;

            this._initialDelayInMinutes = Utility.GetSettingValue("InitialDelayInMinutes");
            this._intervalInSeconds     = Utility.GetSettingValue("IntervalInSeconds");
            this._maxNoOfAttempts       = Utility.GetSettingValue("MaxNoOfAttempts");

            Receive <ScheduleJobMessage>(msg => HandleScheduleAllJobs());
            Receive <ProcessUnfinishedJobs>(msg => HandleProcessUnFinishedJobs());

            Receive <UnableToAcceptJobMessage>(job =>
            {
                if (!_jobsToProcessed.ContainsKey(job.ID))
                {
                    TaskItem taskItem = this.jobManagerViewModel.Tasks.Where(x => x.TaskID == job.ID).FirstOrDefault();
                    if (taskItem.Status == JobStatus.NotStarted.ToString())
                    {
                        _jobsToProcessed.Add(job.ID, new ProcessJobMessage(job.Description, job.ID, taskItem.TimeOut, Self));
                    }
                }
            });

            Receive <JobStartedMessage>(job =>
            {
                TaskItem taskItem  = this.jobManagerViewModel.Tasks.Where(x => x.TaskID == job.ID).FirstOrDefault();
                taskItem.Node      = Sender.Path.ToString().Split('@')[1].Split('/')[0];
                taskItem.StartTime = job.ProcessedTime;
                taskItem.Status    = JobStatus.Started.ToString();
                taskItem.NoOfAttempts++;
                if (_jobsToProcessed.ContainsKey(job.ID))
                {
                    _jobsToProcessed.Remove(taskItem.TaskID);
                }
            });

            Receive <JobCompletedMessage>(job =>
            {
                TaskItem taskItem = this.jobManagerViewModel.Tasks.Where(x => x.TaskID == job.ID).FirstOrDefault();
                taskItem.EndTime  = job.ProcessedTime;
                taskItem.Duration = TimeSpan.FromMilliseconds(job.Duration).ToString(@"hh\:mm\:ss");
                taskItem.Status   = JobStatus.Completed.ToString();
            });

            Receive <JobFailedMessage>(job =>
            {
                TaskItem taskItem = this.jobManagerViewModel.Tasks.Where(x => x.TaskID == job.ID).FirstOrDefault();
                taskItem.Status   = job.Status.ToString();
            });
        }
        public SummaryViewModel(MainViewModel mainVm, JobManagerViewModel jobMgrVM)
        {
            this.Header       = "Summary";
            this.mainVM       = mainVm;
            this.jobManagerVM = jobMgrVM;

            _taskStausView          = new CollectionViewSource();
            _taskStausView.Source   = _taskStatusViewCollection;
            _loadBalanceView        = new CollectionViewSource();
            _loadBalanceView.Source = _loadBalanceViewCollection;

            //  _dispatcherTimer.Tick += new EventHandler(DispatcherTimer_Tick);
            //  _dispatcherTimer.Interval = new TimeSpan(0, 0, 10);
        }