Exemple #1
0
        /*
         * countMonth sorts the months analytes
         * into the respective Analyte List via
         * its detailed matrix
         *
         */
        public void countMonth(int month)
        {
            //Sort analite to correct matrix array
            //and count correct ammount
            Analyte anly;
            int     foundIndex;

            for (int i = 2; i < srcSheet.UsedRange.Rows.Count; i++)
            {
                //ignore all results not from New York
                if (srcSheet.Cells[i, 4].Value2 == "NY")
                {
                    //anly is instance of Analyte class
                    //which will populate itself and add itself
                    //to the appropriate List<Analyte> which are
                    //a list of Analyte class instances
                    //If analyte is already populated in list
                    //it just adds the count to the analyte already
                    //in the array
                    anly = new Analyte(srcSheet.Cells[i, 5].Value2, srcSheet.Cells[i, 2].Value2, srcSheet.Cells[i, 3].Value2, Convert.ToInt32(srcSheet.Cells[i, 6].Value2), month);
                    String str = srcSheet.Cells[i, 3].Value2;
                    switch (str)
                    {
                    case "Air":
                        foundIndex  = getIndex(anly, airAnalytes);
                        airAnalytes = insertAnly(foundIndex, airAnalytes, anly, i, month);
                        break;

                    case "Drinking Water":
                        foundIndex            = getIndex(anly, drinkingWaterAnalytes);
                        drinkingWaterAnalytes = insertAnly(foundIndex, drinkingWaterAnalytes, anly, i, month);
                        break;

                    case "Solid":
                        foundIndex    = getIndex(anly, solidAnalytes);
                        solidAnalytes = insertAnly(foundIndex, solidAnalytes, anly, i, month);
                        break;

                    case "Water":
                        foundIndex    = getIndex(anly, waterAnalytes);
                        waterAnalytes = insertAnly(foundIndex, waterAnalytes, anly, i, month);
                        break;

                    case "Ground Water":
                        anly.setDetMatrix("Water");
                        foundIndex    = getIndex(anly, waterAnalytes);
                        waterAnalytes = insertAnly(foundIndex, waterAnalytes, anly, i, month);
                        break;

                    default:
                        foundIndex      = getIndex(anly, strangeAnalytes);
                        strangeAnalytes = insertAnly(foundIndex, strangeAnalytes, anly, i, month);
                        break;
                    }
                }
            }
        }
Exemple #2
0
 public List <Analyte> insertAnly(int foundIndex, List <Analyte> analytes, Analyte anly, int i, int month)
 {
     if (foundIndex <= -1)
     {
         analytes.Add(anly);
         analytes = analytes.OrderBy(si => si.name).ToList();
         return(analytes);
     }
     else
     {
         analytes[foundIndex].addCount(Convert.ToInt32(srcSheet.Cells[i, 6].Value2), month);
         analytes = analytes.OrderBy(si => si.name).ToList();
         return(analytes);
     }
 }
Exemple #3
0
 public int getIndex(Analyte anly, List <Analyte> analytes)
 {
     return(analytes.BinarySearch(anly, new MyObjectIdComparer()));
 }