Exemple #1
0
        private InflectionCalMethodViewModel ConvertCATEntityToViewModel(TRACK_COMPART_WORN_LIMIT_CAT cat, int WornCalculationMethodTypeId, int extId)
        {
            return(new InflectionCalMethodViewModel
            {
                WornCalculationMethodTypeId = WornCalculationMethodTypeId,
                WornCalculationMethodTableAutoId = cat.track_compart_worn_limit_cat_auto,
                CompartId = cat.compartid_auto,
                ToolId = cat.track_tools_auto,
                MeasurementPointId = cat.MeasurePointId,
                CompartEXTId = extId,

                Adjust_base = cat.adjust_base == null ? 0 : cat.adjust_base,
                Hi_InflectionPoint = cat.hi_inflectionPoint == null ? 0 : cat.hi_inflectionPoint,
                Hi_Intercept1 = cat.hi_intercept1 == null ? 0 : cat.hi_intercept1,
                Hi_Intercept2 = cat.hi_intercept2 == null ? 0 : cat.hi_intercept2,
                Hi_Slope1 = cat.hi_slope1 == null ? 0 : cat.hi_slope1,
                Hi_Slope2 = cat.hi_slope2 == null ? 0 : cat.hi_slope2,
                Mi_Intercept1 = cat.mi_intercept1 == null ? 0 : cat.mi_intercept1,
                Mi_Intercept2 = cat.mi_intercept2 == null ? 0 : cat.mi_intercept2,
                Mi_Slope1 = cat.mi_slope1 == null ? 0 : cat.mi_slope1,
                Mi_Slope2 = cat.mi_slope2 == null ? 0 : cat.mi_slope2,
                Slope = cat.slope == null ? 0 : cat.slope,
                Mi_InflectionPoint = cat.mi_inflectionPoint == null ? 0 : cat.mi_inflectionPoint,
            });
        }
Exemple #2
0
        private void InsertNewInflectionCalMethod(InflectionCalMethodViewModel item)
        {
            var newcat = new TRACK_COMPART_WORN_LIMIT_CAT
            {
                compartid_auto   = item.CompartId,
                MeasurePointId   = item.MeasurementPointId,
                track_tools_auto = item.ToolId,
                track_compart_worn_limit_cat_auto = item.WornCalculationMethodTypeId,

                adjust_base        = item.Adjust_base == null ? 0 : item.Adjust_base,
                hi_inflectionPoint = item.Hi_InflectionPoint == null ? 0 : item.Hi_InflectionPoint,
                hi_intercept1      = item.Hi_Intercept1 == null ? 0 : item.Hi_Intercept1,
                hi_intercept2      = item.Hi_Intercept2 == null ? 0 : item.Hi_Intercept2,
                hi_slope1          = item.Hi_Slope1 == null ? 0 : item.Hi_Slope1,
                hi_slope2          = item.Hi_Slope2 == null ? 0 : item.Hi_Slope2,
                mi_inflectionPoint = item.Mi_InflectionPoint == null ? 0 : item.Mi_InflectionPoint,
                mi_intercept1      = item.Mi_Intercept1 == null ? 0 : item.Mi_Intercept1,
                mi_intercept2      = item.Mi_Intercept2 == null ? 0 : item.Mi_Intercept2,
                mi_slope1          = item.Mi_Slope1 == null ? 0 : item.Mi_Slope1,
                mi_slope2          = item.Mi_Slope2 == null ? 0 : item.Mi_Slope2,
                slope = item.Slope == null ? 0 : item.Slope,
            };

            _context.TRACK_COMPART_WORN_LIMIT_CAT.Add(newcat);
        }
Exemple #3
0
 private void UpdateExsistingInflectionCalculationMethod(InflectionCalMethodViewModel item, TRACK_COMPART_WORN_LIMIT_CAT cat)
 {
     cat.adjust_base           = item.Adjust_base == null ? 0 : item.Adjust_base;
     cat.hi_inflectionPoint    = item.Hi_InflectionPoint == null ? 0 : item.Hi_InflectionPoint;
     cat.hi_intercept1         = item.Hi_Intercept1 == null ? 0 : item.Hi_Intercept1;
     cat.hi_intercept2         = item.Hi_Intercept2 == null ? 0 : item.Hi_Intercept2;
     cat.hi_slope1             = item.Hi_Slope1 == null ? 0 : item.Hi_Slope1;
     cat.hi_slope2             = item.Hi_Slope2 == null ? 0 : item.Hi_Slope2;
     cat.mi_inflectionPoint    = item.Mi_InflectionPoint == null ? 0 : item.Mi_InflectionPoint;
     cat.mi_intercept1         = item.Mi_Intercept1 == null ? 0 : item.Mi_Intercept1;
     cat.mi_intercept2         = item.Mi_Intercept2 == null ? 0 : item.Mi_Intercept2;
     cat.mi_slope1             = item.Mi_Slope1 == null ? 0 : item.Mi_Slope1;
     cat.mi_slope2             = item.Mi_Slope2 == null ? 0 : item.Mi_Slope2;
     _context.Entry(cat).State = EntityState.Modified;
 }
Exemple #4
0
        public static decimal CATReadingMapper(TRACK_COMPART_WORN_LIMIT_CAT r, decimal reading, InspectionImpact?i)
        {
            if (i == null)
            {
                return((decimal) - 0.0006);
            }
            InspectionImpact impact = (InspectionImpact)i;
            decimal?         slope;
            decimal?         intercept;

            if (impact == InspectionImpact.High)
            {
                if (r.slope == 0)
                {
                    if (reading >= r.hi_inflectionPoint)
                    {
                        slope     = r.hi_slope1;
                        intercept = r.hi_intercept1;
                    }
                    else
                    {
                        slope     = r.hi_slope2;
                        intercept = r.hi_intercept2;
                    }
                }
                else
                {
                    if (reading >= r.hi_inflectionPoint)
                    {
                        slope     = r.hi_slope2;
                        intercept = r.hi_intercept2;
                    }
                    else
                    {
                        slope     = r.hi_slope1;
                        intercept = r.hi_intercept1;
                    }
                }
            }
            else
            {
                if (r.slope == 0)
                {
                    if (reading >= r.mi_inflectionPoint)
                    {
                        slope     = r.mi_slope1;
                        intercept = r.mi_intercept1;
                    }
                    else
                    {
                        slope     = r.mi_slope2;
                        intercept = r.mi_intercept2;
                    }
                }
                else
                {
                    if (reading >= r.mi_inflectionPoint)
                    {
                        slope     = r.mi_slope2;
                        intercept = r.mi_intercept2;
                    }
                    else
                    {
                        slope     = r.mi_slope1;
                        intercept = r.mi_intercept1;
                    }
                }
            }

            if (slope == null || intercept == null)
            {
                return((decimal) - 0.00069);
            }
            return(Math.Round(((decimal)slope * reading) + ((decimal)intercept), 3));
        }