Ejemplo n.º 1
0
        private WornPercentage GetMeasurementPointWorn(List<MEASUREMENT_POINT_RECORD> readingGroup, int pointId, int inspectionDetailId)
        {
            // Average reading
            decimal sumReading = 0;
            var countReading = 0;
            decimal average = 0;
            int toolId = -1;
            decimal totalWorn = 0;
            decimal averageWorn = 0;
            BLL.Core.Domain.MiningShovelDomain.MeasurementPoint pointRecord = new MiningShovelDomain.MeasurementPoint(_context, pointId);
            foreach (var reading in readingGroup)
            {
                countReading++;
                sumReading = sumReading + reading.Reading;
                toolId = reading.ToolId;                
                totalWorn += pointRecord.CalcWornPercentage(
                    reading.Reading.ConvertMMToInch(),
                    toolId,
                    _Impact, 
                    pointId
                );
            }
            if (countReading > 0)
            {
                average = sumReading / countReading;
                averageWorn = totalWorn / countReading;
            }
            else return null;

            return new WornPercentage(toolId, average, averageWorn, averageWorn.toEvalChar());
        }
Ejemplo n.º 2
0
        public int SaveInspectionReading(
            int inspection_detail_auto, 
            int MeasurementPointId, 
            String ToolCode,
            String Notes,
            MeasurementPointReading reading, 
            int countReading)
        {
            ////////////////////////////////////
            // MEASUREMENT_POINT_RECORD
            DAL.MEASUREMENT_POINT_RECORD record = new DAL.MEASUREMENT_POINT_RECORD();

            // FK ID
            record.InspectionDetailId = inspection_detail_auto;

            // FK ID
            record.CompartMeasurePointId = MeasurementPointId;

            // InboardOutboard
            record.InboardOutborad = 0;

            // ToolId
            TrackTool tool = new TrackTool();
            int Id = -1;
            if (ToolCode != null)
                Id = tool.GetIdByToolCode(ToolCode);
            record.ToolId = Id;

            // Reading
            record.Reading = System.Convert.ToDecimal(reading.reading);

            // MeasureNumber
            record.MeasureNumber = reading.measureNo;

            // Worn
            BLL.Core.Domain.MiningShovelDomain.MeasurementPoint pointRecord = new MiningShovelDomain.MeasurementPoint(_context, MeasurementPointId);
            decimal worn = pointRecord.CalcWornPercentage(
                record.Reading.ConvertMMToInch(),
                record.ToolId,
                _Impact,
                MeasurementPointId
            );
            record.Worn = worn;

            // Eval code
            char charEval = record.Worn.toEvalChar();
            record.EvalCode = charEval.ToString();

            // Notes
            if (countReading == 0)
                record.Notes = Notes;

            // INSERT
            _MEASUREMENT_POINT_RECORD.Add(record);
            _context.SaveChanges();

            return record.Id;
        }