diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-03-18 16:48:17 +0200 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2020-03-18 16:48:17 +0200 |
| commit | 19a6a9d026f3436afd9af7923db7ee6cbd861772 (patch) | |
| tree | b0841de3a13bfddd03ce9665f74e3f637517b1c9 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics | |
| parent | 18e15c056c25eccbd54f9f82c25630d900d2aa60 (diff) | |
| download | Tango-19a6a9d026f3436afd9af7923db7ee6cbd861772.tar.gz Tango-19a6a9d026f3436afd9af7923db7ee6cbd861772.zip | |
Job Runs, Action Logs - added async method to loading data.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics')
| -rw-r--r-- | Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs index b0c4975ee..3aa93cd3e 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Statistics/ViewModels/JobRunsViewVM.cs @@ -323,49 +323,51 @@ namespace Tango.MachineStudio.Statistics.ViewModels TimeSpan offsetTime = (EndSelectedDate.Date == DateTime.Now.Date) ? DateTime.Now.TimeOfDay : new TimeSpan(23, 59, 59); DateTime endUtc = EndSelectedDate.ToUniversalTime() + offsetTime; string jobName = SelectedJob == null ? "" : SelectedJob.Name; - - - var db_JobRuns = db.JobRuns.Where(x=> x.StartDate <= DbFunctions.TruncateTime(endUtc) && x.StartDate >= DbFunctions.TruncateTime(startUtc.Date)) + + + var db_JobRuns = db.JobRuns.Where(x => x.StartDate <= DbFunctions.TruncateTime(endUtc) && x.StartDate >= DbFunctions.TruncateTime(startUtc.Date)) .Select(x => new - { - x.ID, - x.ActualStartDate, - x.EndDate, - x.EndPosition, - x.GradientResolutionCm, - x.Guid, - x.HeatingStartDate, - x.IsGradient, - x.JobGuid, - x.JobLength, - x.JobName, - x.JobSource, - x.MachineGuid, - x.RmlGuid, - x.StartDate, - x.Status, - x.UploadingStartDate, - x.UserGuid, - x.LiquidQuantityString, - }); + { + x.ID, + x.ActualStartDate, + x.EndDate, + x.EndPosition, + x.GradientResolutionCm, + x.Guid, + x.HeatingStartDate, + x.IsGradient, + x.JobGuid, + x.JobLength, + x.JobName, + x.JobSource, + x.MachineGuid, + x.RmlGuid, + x.StartDate, + x.Status, + x.UploadingStartDate, + x.UserGuid, + x.LiquidQuantityString, + }); + + var machineIDs = new HashSet<string>(SelectedMachines.SynchedSource.ToList().Select(p => p.Guid)); - if(machineIDs.Count > 0) + if (machineIDs.Count > 0) { db_JobRuns = db_JobRuns.Where(x => machineIDs.Contains(x.MachineGuid)); } int[] jobRunSourceArr = JobRunSelectedSources.SynchedSource.Select(x => (int)x).ToArray(); - if(jobRunSourceArr.Length > 0) + if (jobRunSourceArr.Length > 0) { db_JobRuns = db_JobRuns.Where(x => jobRunSourceArr.Contains(x.JobSource)); } int[] jobRunStatusArr = JobRunSelectedStatuses.SynchedSource.Select(x => (int)x).ToArray(); - if(jobRunStatusArr.Length > 0) + if (jobRunStatusArr.Length > 0) { db_JobRuns = db_JobRuns.Where(x => jobRunStatusArr.Contains(x.Status)); } bool[] isGradientArr = IsGradientSelection.SynchedSource.Select(x => (bool)x).ToArray(); - if(isGradientArr.Length > 0) + if (isGradientArr.Length > 0) { db_JobRuns = db_JobRuns.Where(x => isGradientArr.Contains(x.IsGradient)); } @@ -374,13 +376,15 @@ namespace Tango.MachineStudio.Statistics.ViewModels { db_JobRuns = db_JobRuns.Where(x => rmlGuids.Contains(x.RmlGuid)); } - if(!String.IsNullOrEmpty(jobName)) + if (!String.IsNullOrEmpty(jobName)) { db_JobRuns = db_JobRuns.Where(x => x.JobName.ToLower().StartsWith(jobName.ToLower())); } - - List<JobRun> runs = db_JobRuns.ToList() - .Where(x => (x.JobLength < LengthUpperValue && x.JobLength >= LengthLowerValue)) + + var runs_db = await db_JobRuns.ToListAsync(); //Execute actual query. + + + List<JobRun> runs = runs_db.Where(x => (x.JobLength < LengthUpperValue && x.JobLength >= LengthLowerValue)) .Select(x => new JobRun() { ID = x.ID, @@ -473,7 +477,7 @@ namespace Tango.MachineStudio.Statistics.ViewModels var selection = JobRuns.Where(z => z.JobRun.EndPosition > 0 && z.JobRun.EndDate != null && z.JobRun.ActualStartDate != null); double val = 0d; double average = 0d; - if (selection != null && selection.Count<JobRunModel>() > 0) + if (selection != null && selection.Count<JobRunModel>() > 0) { val = selection.Sum(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalHours); average = selection.Average(x => (x.JobRun.EndDate - x.JobRun.ActualStartDate).Value.TotalMilliseconds); |
