source: trunk/CrypPlugins/KeySearcher/P2P/Storage/StatusUpdater.cs @ 2391

Last change on this file since 2391 was 1727, checked in by Paul Lelgemann, 11 years ago

+ P2PEditor can display the status of jobs, if available; Participating displays overlay while loading workspace data
+ KeySearcher can upload status for P2PEditor display

File size: 1.2 KB
Line 
1using Cryptool.P2PEditor.Distributed;
2using Cryptool.P2PEditor.Helper;
3using KeySearcher.P2P.Presentation;
4
5namespace KeySearcher.P2P.Storage
6{
7    class StatusUpdater
8    {
9        private readonly StatusContainer status;
10        private readonly string statusKey;
11
12        public StatusUpdater(StatusContainer status, string statusKey)
13        {
14            this.status = status;
15            this.statusKey = statusKey;
16        }
17
18        public void SendUpdate()
19        {
20            var currentStatus = DistributedJobStatus.Status.Active;
21            if (status.GlobalProgress == 1)
22                currentStatus = DistributedJobStatus.Status.Finished;
23
24            SendUpdate(currentStatus);
25        }
26
27        public void SendUpdate(DistributedJobStatus.Status currentStatus)
28        {
29            var globalProgress = status.GlobalProgress;
30            if (currentStatus == DistributedJobStatus.Status.Finished) globalProgress = 1;
31
32            DistributedStatusUpdater.UpdateStatus(statusKey, currentStatus, (long) status.TotalAmountOfParticipants,
33                                                  globalProgress, status.StartDate.ToUniversalTime());
34        }
35    }
36}
Note: See TracBrowser for help on using the repository browser.