示例#1
0
        public Task(HostState hostState, Result result)
        {
            HostId   = hostState.Id;
            HostName = hostState.Name;

            var rpcProject  = hostState.BoincState.Projects?.FirstOrDefault(p => p.MasterUrl == result.ProjectUrl);
            var rpcWorkunit = hostState.BoincState.Workunits?.FirstOrDefault(w => w.ProjectUrl == rpcProject?.MasterUrl && w.Name == result.WorkunitName);
            var rpcApp      = hostState.BoincState.Apps?.FirstOrDefault(a => a.ProjectUrl == rpcProject?.MasterUrl && a.Name == rpcWorkunit?.AppName);

            if (rpcProject == null || rpcWorkunit == null || rpcApp == null)
            {
                Status = Statuses.GetTaskStatus(result, rpcProject, hostState.BoincState);
                return;
            }

            Project          = rpcProject.ProjectName;
            Application      = rpcApp.UserFriendlyName;
            Workunit         = result.WorkunitName;
            Progress         = result.ReadyToReport ? 100 : Math.Round(result.FractionDone * 100, 3);
            ElapsedTime      = BoincManager.Utils.ConvertDuration(result.ElapsedTime);
            CpuTime          = BoincManager.Utils.ConvertDuration(result.CurrentCpuTime);
            CpuTimeRemaining = BoincManager.Utils.ConvertDuration(result.EstimatedCpuTimeRemaining);
            LastCheckpoint   = BoincManager.Utils.ConvertDuration(result.CurrentCpuTime - result.CheckpointCpuTime);
            Deadline         = BoincManager.Utils.ConvertDateTime(result.ReportDeadline);
            Status           = Statuses.GetTaskStatus(result, rpcProject, hostState.BoincState);
        }
示例#2
0
        public void Update(HostState hostState, BoincRpc.Result result)
        {
            RpcResult = result;

            Progress         = result.ReadyToReport ? 1 : result.FractionDone;
            ElapsedTime      = Utils.ConvertDuration(result.ElapsedTime);
            CpuTime          = Utils.ConvertDuration(result.CurrentCpuTime);
            CpuTimeRemaining = Utils.ConvertDuration(result.EstimatedCpuTimeRemaining);
            LastCheckpoint   = Utils.ConvertDuration(result.CurrentCpuTime - result.CheckpointCpuTime);
            Deadline         = Utils.ConvertDateTime(result.ReportDeadline);
            Status           = Statuses.GetTaskStatus(result, RpcProject, hostState.BoincState);
        }
示例#3
0
        public ObservableTask(HostState hostState, BoincRpc.Result result)
        {
            HostId   = hostState.Id;
            HostName = hostState.Name;

            RpcProject = hostState.BoincState.Projects?.FirstOrDefault(p => p.MasterUrl == result.ProjectUrl);
            var rpcWorkunit = hostState.BoincState.Workunits?.FirstOrDefault(w => w.ProjectUrl == RpcProject?.MasterUrl && w.Name == result.WorkunitName);
            var rpcApp      = hostState.BoincState.Apps?.FirstOrDefault(a => a.ProjectUrl == RpcProject?.MasterUrl && a.Name == rpcWorkunit?.AppName);

            if (RpcProject == null || rpcWorkunit == null || rpcApp == null)
            {
                Status = Statuses.GetTaskStatus(result, RpcProject, hostState.BoincState);
                return;
            }

            Project     = RpcProject.ProjectName;
            Application = rpcApp.UserFriendlyName;
            Workunit    = result.WorkunitName;

            Update(hostState, result);
        }