< Summary

Information
Class: ReportingServices.Shared.ViewModels.ProductionReport.ToolStateByType
Assembly: ReportingServices.Shared
File(s): C:\Users\wathen\source\repos\ReportingServices\ReportingServices.Shared\ViewModels\ProductionReport\ToolStateByType.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 50
Coverable lines: 50
Total lines: 71
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 28
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

File(s)

C:\Users\wathen\source\repos\ReportingServices\ReportingServices.Shared\ViewModels\ProductionReport\ToolStateByType.cs

#LineLine coverage
 1using ReportingServices.Shared.Models.ProductionReport;
 2
 3namespace ReportingServices.Shared.ViewModels.ProductionReport
 4{
 5    public class ToolStateByType
 6    {
 07        public int DownTools { get; set; }
 08        public int UpTools { get; set; }
 09        public List<ToolStateCurrent> ToolStateCurrents { get; set; }
 010        public List<string> ToolsDownGreaterThan12Hours { get; set; }
 11
 012        public ToolStateByType(List<ToolStateCurrent> toolStateCurrents)
 013        {
 014            ToolStateCurrents = toolStateCurrents;
 015            ToolsDownGreaterThan12Hours = new List<string>();
 016            UpTools = 0;
 017            DownTools = 0;
 18
 019            GetToolsDownGreaterThan12Hours();
 020            GetMostRecentTransactions();
 021            DetermineUpAndDownTools();
 022        }
 23
 24        public void GetMostRecentTransactions()
 025        {
 026            for (int i = ToolStateCurrents.Count - 2; i >= 0; i--)
 027            {
 028                if (ToolStateCurrents[i].Tool == ToolStateCurrents[i + 1].Tool)
 029                    ToolStateCurrents.RemoveAt(i);
 030            }
 031        }
 32
 33        public void GetToolsDownGreaterThan12Hours()
 034        {
 035            float elapsedTime = 0f;
 36
 037            if (ToolStateCurrents[^1].BasicStateDescription.ToUpper() is not "PRODUCTIVE" and not "OUT OF SERVICE")
 038                float.Parse(ToolStateCurrents[^1].GanttElapsedHours);
 39
 040            for (int i = ToolStateCurrents.Count - 2; i >= 0; i--)
 041            {
 042                if (ToolStateCurrents[i].Tool == ToolStateCurrents[i + 1].Tool)
 043                {
 044                    if (ToolStateCurrents[i].BasicStateDescription.ToUpper() != "PRODUCTIVE" && ToolStateCurrents[^1].Ba
 045                        elapsedTime += float.Parse(ToolStateCurrents[i].GanttElapsedHours);
 046                }
 47                else
 048                {
 049                    if (elapsedTime >= 12)
 050                        ToolsDownGreaterThan12Hours.Add(ToolStateCurrents[i + 1].Tool);
 51
 052                    if (ToolStateCurrents[i].BasicStateDescription.ToUpper() != "PRODUCTIVE" && ToolStateCurrents[^1].Ba
 053                        elapsedTime = float.Parse(ToolStateCurrents[i].GanttElapsedHours);
 54                    else
 055                        elapsedTime = 0;
 056                }
 057            }
 058        }
 59
 60        public void DetermineUpAndDownTools()
 061        {
 062            foreach (ToolStateCurrent tools in ToolStateCurrents)
 063            {
 064                if (tools.BasicStateDescription == "Productive")
 065                    UpTools++;
 066                else if (tools.ReactorStatus != "Out of Service")
 067                    DownTools++;
 068            }
 069        }
 70    }
 71}