コード例 #1
0
        // Helper
        public void CalculateMWQMSiteStat(List <MWQMSample> mwqmSampleList, TVLocation tvlNew, int MinFC, int MaxFC, int SampCount)
        {
            List <double> GeoMeanList = (from c in mwqmSampleList
                                         orderby c.FecCol_MPN_100ml
                                         select(c.FecCol_MPN_100ml < 2 ? 1.9D : (double)c.FecCol_MPN_100ml)).ToList <double>();

            double P90         = (float)_TVItemService.GetP90(GeoMeanList);
            double GeoMean     = (float)_TVItemService.GeometricMean(GeoMeanList);
            double Median      = (float)_TVItemService.GetMedian(GeoMeanList);
            double PercOver43  = (float)((((double)mwqmSampleList.Where(c => c.FecCol_MPN_100ml > 43).Count()) / (double)mwqmSampleList.Count()) * 100.0D);
            double PercOver260 = (float)((((double)mwqmSampleList.Where(c => c.FecCol_MPN_100ml > 260).Count()) / (double)mwqmSampleList.Count()) * 100.0D);
            int    MinYear     = mwqmSampleList.Select(c => c.SampleDateTime_Local).Min().Year;
            int    MaxYear     = mwqmSampleList.Select(c => c.SampleDateTime_Local).Max().Year;

            CalculateMWQMSiteStatLetterAndSubTVType(tvlNew, P90, GeoMean, Median, PercOver43, PercOver260);

            tvlNew.TVText += " - " + ServiceRes.GM + ": [" + (GeoMean < 2.0D ? "<2" : string.Format("{0:F2}", GeoMean)) +
                             "] " + ServiceRes.Med + ": [" + (Median < 2.0D ? "<2" :string.Format("{0:F2}", Median)) +
                             "] " + ServiceRes.P90 + ": [" + string.Format("{0:F2}", P90) +
                             "] >43: [" + string.Format("{0:F2}%", PercOver43) +
                             "] >260: [" + string.Format("{0:F2}%", PercOver260) +
                             "] " + ServiceRes.Min + ": [" + (MinFC < 2.0D ? "<2" : string.Format("{0:F0}", MinFC)) +
                             "] " + ServiceRes.Max + ": [" + (MaxFC < 2.0D ? "<2" : string.Format("{0:F0}", MaxFC)) +
                             "] " + ServiceRes.NumberOfSamples + ": [" + string.Format("{0:F0}", SampCount) +
                             "] " + ServiceRes.StatPeriod + ": [" + string.Format("{0} - {1}", MinYear, MaxYear) + "]";
        }
コード例 #2
0
        private TVLocation GetFilledRandomTVLocation(string OmitPropName)
        {
            TVLocation tvLocation = new TVLocation();

            if (OmitPropName != "TVItemID")
            {
                tvLocation.TVItemID = GetRandomInt(1, 11);
            }
            if (OmitPropName != "TVText")
            {
                tvLocation.TVText = GetRandomString("", 6);
            }
            if (OmitPropName != "TVType")
            {
                tvLocation.TVType = (TVTypeEnum)GetRandomEnumType(typeof(TVTypeEnum));
            }
            if (OmitPropName != "SubTVType")
            {
                tvLocation.SubTVType = (TVTypeEnum)GetRandomEnumType(typeof(TVTypeEnum));
            }
            if (OmitPropName != "TVTypeText")
            {
                tvLocation.TVTypeText = GetRandomString("", 5);
            }
            if (OmitPropName != "SubTVTypeText")
            {
                tvLocation.SubTVTypeText = GetRandomString("", 5);
            }
            //CSSPError: property [MapObjList] and type [TVLocation] is  not implemented

            return(tvLocation);
        }
コード例 #3
0
        public void CalculateMWQMSiteStatOneDay(List <MWQMSample> mwqmSampleList, TVLocation tvlNew)
        {
            double Mean = (from c in mwqmSampleList
                           orderby c.FecCol_MPN_100ml
                           select(double) c.FecCol_MPN_100ml).Average();

            CalculateMWQMSiteStatOneDayLetterAndSubTVType(tvlNew, Mean);


            tvlNew.TVText += " - (" + string.Format("{0:F0}", Mean) + ")";
        }
コード例 #4
0
        // Get
        public void GetMWQMSiteMapInfoStatDB(int TVItemID, TVLocation tvlNew, int NumberOfSamples)
        {
            string            routineNumberText = ((int)SampleTypeEnum.Routine).ToString() + ",";
            List <MWQMSample> mwqmSampleList    = (from w in db.MWQMSites
                                                   from s in db.MWQMSamples
                                                   where w.MWQMSiteTVItemID == s.MWQMSiteTVItemID &&
                                                   w.MWQMSiteTVItemID == TVItemID &&
                                                   s.SampleTypesText.Contains(routineNumberText)
                                                   orderby s.SampleDateTime_Local descending
                                                   select s).Take(NumberOfSamples).ToList <MWQMSample>();

            int SampCount = mwqmSampleList.Count();
            int MinFC     = 0;
            int MaxFC     = 0;

            if (SampCount > 0)
            {
                MinFC = (int)mwqmSampleList.Min(c => c.FecCol_MPN_100ml);
                MaxFC = (int)mwqmSampleList.Max(c => c.FecCol_MPN_100ml);

                if (mwqmSampleList.Count >= 4)
                {
                    CalculateMWQMSiteStat(mwqmSampleList, tvlNew, MinFC, MaxFC, SampCount);
                }
                else
                {
                    tvlNew.SubTVType = TVTypeEnum.LessThan10;
                    tvlNew.TVText    = SampCount.ToString() + " - " + tvlNew.TVText;
                    tvlNew.TVText   += " - " + ServiceRes.LessThan10Samples + " - " + ServiceRes.NumberOfSamples + ": [" + string.Format("{0:F0}", SampCount) + "]";
                }
            }
            else
            {
                tvlNew.SubTVType = TVTypeEnum.NoData;
                tvlNew.TVText    = SampCount.ToString() + " - " + tvlNew.TVText;
                tvlNew.TVText   += " - " + ServiceRes.NoData;
            }
        }
コード例 #5
0
        public void GetMWQMSiteMapInfoStatOneDayDB(int TVItemID, TVLocation tvlNew, DateTime SampleDate)
        {
            string            routineNumberText = ((int)SampleTypeEnum.Routine).ToString() + ",";
            List <MWQMSample> mwqmSampleList    = (from w in db.MWQMSites
                                                   from s in db.MWQMSamples
                                                   where w.MWQMSiteTVItemID == s.MWQMSiteTVItemID &&
                                                   w.MWQMSiteTVItemID == TVItemID &&
                                                   (s.SampleDateTime_Local.Year == SampleDate.Year &&
                                                    s.SampleDateTime_Local.Month == SampleDate.Month &&
                                                    s.SampleDateTime_Local.Day == SampleDate.Day) &&
                                                   s.SampleTypesText.Contains(routineNumberText)
                                                   orderby s.SampleDateTime_Local descending
                                                   select s).ToList <MWQMSample>();

            if (mwqmSampleList.Count >= 1)
            {
                CalculateMWQMSiteStatOneDay(mwqmSampleList, tvlNew);
            }
            else
            {
                tvlNew.SubTVType = TVTypeEnum.NoData;
                tvlNew.TVText   += " - " + ServiceRes.NoData;
            }
        }
コード例 #6
0
        public void CalculateMWQMSiteStatOneDayLetterAndSubTVType(TVLocation tvlNew, double Mean)
        {
            int MeanInt = (int)Math.Round((double)Mean, 0);

            if ((MeanInt > 88))
            {
                tvlNew.SubTVType = TVTypeEnum.NoDepuration;
                if (MeanInt > 181)
                {
                    tvlNew.TVText = "F - " + tvlNew.TVText;
                }
                else if (MeanInt > 163)
                {
                    tvlNew.TVText = "E - " + tvlNew.TVText;
                }
                else if (MeanInt > 144)
                {
                    tvlNew.TVText = "D - " + tvlNew.TVText;
                }
                else if (MeanInt > 125)
                {
                    tvlNew.TVText = "C - " + tvlNew.TVText;
                }
                else if (MeanInt > 107)
                {
                    tvlNew.TVText = "B - " + tvlNew.TVText;
                }
                else
                {
                    tvlNew.TVText = "A - " + tvlNew.TVText;
                }
            }
            else if (MeanInt > 14)
            {
                tvlNew.SubTVType = TVTypeEnum.Failed;
                if (MeanInt > 76)
                {
                    tvlNew.TVText = "F - " + tvlNew.TVText;
                }
                else if (MeanInt > 63)
                {
                    tvlNew.TVText = "E - " + tvlNew.TVText;
                }
                else if (MeanInt > 51)
                {
                    tvlNew.TVText = "D - " + tvlNew.TVText;
                }
                else if (MeanInt > 39)
                {
                    tvlNew.TVText = "C - " + tvlNew.TVText;
                }
                else if (MeanInt > 26)
                {
                    tvlNew.TVText = "B - " + tvlNew.TVText;
                }
                else
                {
                    tvlNew.TVText = "A - " + tvlNew.TVText;
                }
            }
            else
            {
                tvlNew.SubTVType = TVTypeEnum.Passed;
                if (MeanInt > 12)
                {
                    tvlNew.TVText = "F - " + tvlNew.TVText;
                }
                else if (MeanInt > 9)
                {
                    tvlNew.TVText = "E - " + tvlNew.TVText;
                }
                else if (MeanInt > 7)
                {
                    tvlNew.TVText = "D - " + tvlNew.TVText;
                }
                else if (MeanInt > 5)
                {
                    tvlNew.TVText = "C - " + tvlNew.TVText;
                }
                else if (MeanInt > 2)
                {
                    tvlNew.TVText = "B - " + tvlNew.TVText;
                }
                else
                {
                    tvlNew.TVText = "A - " + tvlNew.TVText;
                }
            }
        }
コード例 #7
0
        public void CalculateMWQMSiteStatLetterAndSubTVType(TVLocation tvlNew, double P90, double GeoMean, double Median, double PercOver43, double PercOver260)
        {
            int P90Int         = (int)Math.Round((double)P90, 0);
            int GeoMeanInt     = (int)Math.Round((double)GeoMean, 0);
            int MedianInt      = (int)Math.Round((double)Median, 0);
            int PercOver43Int  = (int)Math.Round((double)PercOver43, 0);
            int PercOver260Int = (int)Math.Round((double)PercOver260, 0);

            if ((GeoMeanInt > 88) || (MedianInt > 88) || (P90Int > 260) || (PercOver260Int > 10))
            {
                tvlNew.SubTVType = TVTypeEnum.NoDepuration;
                if ((GeoMeanInt > 181) || (MedianInt > 181) || (P90Int > 460) || (PercOver260Int > 18))
                {
                    tvlNew.TVText = "F - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 163) || (MedianInt > 163) || (P90Int > 420) || (PercOver260Int > 17))
                {
                    tvlNew.TVText = "E - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 144) || (MedianInt > 144) || (P90Int > 380) || (PercOver260Int > 15))
                {
                    tvlNew.TVText = "D - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 125) || (MedianInt > 125) || (P90Int > 340) || (PercOver260Int > 13))
                {
                    tvlNew.TVText = "C - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 107) || (MedianInt > 107) || (P90Int > 300) || (PercOver260Int > 12))
                {
                    tvlNew.TVText = "B - " + tvlNew.TVText;
                }
                else
                {
                    tvlNew.TVText = "A - " + tvlNew.TVText;
                }
            }
            else if ((GeoMeanInt > 14) || (MedianInt > 14) || (P90Int > 43) || (PercOver43Int > 10))
            {
                tvlNew.SubTVType = TVTypeEnum.Failed;
                if ((GeoMeanInt > 76) || (MedianInt > 76) || (P90Int > 224) || (PercOver43Int > 27))
                {
                    tvlNew.TVText = "F - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 63) || (MedianInt > 63) || (P90Int > 188) || (PercOver43Int > 23))
                {
                    tvlNew.TVText = "E - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 51) || (MedianInt > 51) || (P90Int > 152) || (PercOver43Int > 20))
                {
                    tvlNew.TVText = "D - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 39) || (MedianInt > 39) || (P90Int > 115) || (PercOver43Int > 17))
                {
                    tvlNew.TVText = "C - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 26) || (MedianInt > 26) || (P90Int > 79) || (PercOver43Int > 13))
                {
                    tvlNew.TVText = "B - " + tvlNew.TVText;
                }
                else
                {
                    tvlNew.TVText = "A - " + tvlNew.TVText;
                }
            }
            else
            {
                tvlNew.SubTVType = TVTypeEnum.Passed;
                if ((GeoMeanInt > 12) || (MedianInt > 12) || (P90Int > 36) || (PercOver43Int > 8))
                {
                    tvlNew.TVText = "F - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 9) || (MedianInt > 9) || (P90Int > 29) || (PercOver43Int > 7))
                {
                    tvlNew.TVText = "E - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 7) || (MedianInt > 7) || (P90Int > 22) || (PercOver43Int > 5))
                {
                    tvlNew.TVText = "D - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 5) || (MedianInt > 5) || (P90Int > 14) || (PercOver43Int > 3))
                {
                    tvlNew.TVText = "C - " + tvlNew.TVText;
                }
                else if ((GeoMeanInt > 2) || (MedianInt > 2) || (P90Int > 7) || (PercOver43Int > 2))
                {
                    tvlNew.TVText = "B - " + tvlNew.TVText;
                }
                else
                {
                    tvlNew.TVText = "A - " + tvlNew.TVText;
                }
            }
        }
コード例 #8
0
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string     retStr     = "";
            Enums      enums      = new Enums(LanguageRequest);
            TVLocation tvLocation = validationContext.ObjectInstance as TVLocation;

            tvLocation.HasErrors = false;

            if (tvLocation.TVItemID < 1)
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "TVItemID", "1"), new[] { "TVItemID" }));
            }

            if (string.IsNullOrWhiteSpace(tvLocation.TVText))
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "TVText"), new[] { "TVText" }));
            }

            if (!string.IsNullOrWhiteSpace(tvLocation.TVText) && (tvLocation.TVText.Length < 1 || tvLocation.TVText.Length > 255))
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "TVText", "1", "255"), new[] { "TVText" }));
            }

            retStr = enums.EnumTypeOK(typeof(TVTypeEnum), (int?)tvLocation.TVType);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "TVType"), new[] { "TVType" }));
            }

            retStr = enums.EnumTypeOK(typeof(TVTypeEnum), (int?)tvLocation.SubTVType);
            if (!string.IsNullOrWhiteSpace(retStr))
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "SubTVType"), new[] { "SubTVType" }));
            }

            if (!string.IsNullOrWhiteSpace(tvLocation.TVTypeText) && tvLocation.TVTypeText.Length > 100)
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "TVTypeText", "100"), new[] { "TVTypeText" }));
            }

            if (!string.IsNullOrWhiteSpace(tvLocation.SubTVTypeText) && tvLocation.SubTVTypeText.Length > 100)
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "SubTVTypeText", "100"), new[] { "SubTVTypeText" }));
            }

            //CSSPError: Type not implemented [MapObjList] of type [List`1]

            //CSSPError: Type not implemented [MapObjList] of type [MapObj]
            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                tvLocation.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
コード例 #9
0
 public TVLocationTest()
 {
     tVLocation = new TVLocation();
 }