public static PlayerRating getPlayerRating(string pid)
        {
            PlayerRating p = null;

            foreach (PlayerRating playerRating in playersRatings)
            {
                if (playerRating.Id.Equals(pid))
                {
                    return(playerRating);
                }
            }
            return(p);
        }
示例#2
0
        private void parseExcelFile()
        {
            Excel.Application xlApp = new Excel.Application();
            string            file  = "C:\\fantabz\\voti" + day + ".xls";

            Excel.Workbook   xlWorkbook  = xlApp.Workbooks.Open(file);
            Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range      xlRange     = xlWorksheet.UsedRange;

            int rowCount = xlRange.Rows.Count;

            //int colCount = xlRange.Columns.Count;

            for (int i = 5; i <= rowCount; i++)
            {
                PlayerRating pr = new PlayerRating();
                string       id = xlRange.Cells[i, 1].Value2.ToString();
                if (!id.Equals("ALL."))
                {
                    pr.Id = id;

                    string test = xlRange.Cells[i, 7].Value2 + "";
                    if (test.Equals("s,v,"))
                    {
                        pr.VotoGazzetta = 0;
                    }
                    else
                    {
                        pr.VotoGazzetta = Math.Round((double)xlRange.Cells[i, 7].Value2, 1);
                    }
                    pr.GolFattiGazzetta  = xlRange.Cells[i, 8].Value2;
                    pr.GolSubitiGazzetta = xlRange.Cells[i, 9].Value2;
                    pr.AutoRetiGazzetta  = xlRange.Cells[i, 10].Value2;
                    pr.AssistGazzetta    = xlRange.Cells[i, 11].Value2;

                    test = xlRange.Cells[i, 12].Value2 + "";
                    if (test.Equals("s,v,"))
                    {
                        pr.VotoCorriere = 0;
                    }
                    else
                    {
                        pr.VotoCorriere = Math.Round((double)xlRange.Cells[i, 12].Value2, 1);
                    }
                    pr.GolFattiCorriere  = xlRange.Cells[i, 13].Value2;
                    pr.GolSubitiCorriere = xlRange.Cells[i, 14].Value2;
                    pr.AutoRetiCorriere  = xlRange.Cells[i, 15].Value2;
                    pr.AssistCorriere    = xlRange.Cells[i, 16].Value2;

                    pr.Ammonizione = xlRange.Cells[i, 24].Value2;
                    pr.Esplusione  = xlRange.Cells[i, 25].Value2;
                    pr.GolVittoria = xlRange.Cells[i, 26].Value2;
                    pr.GolPareggio = xlRange.Cells[i, 27].Value2;

                    pr.RigoreSbagliato   = xlRange.Cells[i, 28].Value2;
                    pr.RigoreParato      = xlRange.Cells[i, 29].Value2;;
                    pr.RigoreTrasformato = xlRange.Cells[i, 30].Value2;
                    PlayerRatingsList.addPlayerRating(pr);
                }


                //Console.Out.WriteLine(pr.toString());
            }

            //cleanup
            GC.Collect();
            GC.WaitForPendingFinalizers();
            Marshal.ReleaseComObject(xlRange);
            Marshal.ReleaseComObject(xlWorksheet);
            xlWorkbook.Close();
            Marshal.ReleaseComObject(xlWorkbook);
            xlApp.Quit();
            Marshal.ReleaseComObject(xlApp);
        }
 public static void addPlayerRating(PlayerRating p)
 {
     playersRatings.Add(p);
 }