示例#1
0
文件: Game.cs 项目: joebu23/GV-2015
        public Game(string fileName)
        {
            using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, false))
            {
                // Retrieve a reference to the workbook part.
                WorkbookPart wbPart = document.WorkbookPart;

                Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().FirstOrDefault();

                // Throw an exception if there is no sheet.
                if (theSheet == null)
                {
                    throw new ArgumentException("sheetName Not Found");
                }

                WorksheetPart wsPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id));

                var excelService = new ExcelService(wbPart, wsPart);

                this.GameTitle = excelService.GetValueFromCell("A1");
                this.GameVenue = excelService.GetValueFromCell("A2");
                this.GameLocation = excelService.GetValueFromCell("A3");
                this._defaultTimerMinutes = excelService.GetValueFromCell("A6").GetInt();

                this.Announcer1 = excelService.GetValueFromCell("A11");
                this.Announcer2 = excelService.GetValueFromCell("A12");

                this.Officials = new List<Official>();
                var i = 2;
                do
                {
                    try
                    {
                        if (excelService.GetValueFromCell("B" + i.ToString()) != "XXX")
                        {
                            var newOfficial = new Official
                            {
                                Name = excelService.GetValueFromCell("C" + i.ToString()),
                                Title = excelService.GetValueFromCell("B" + i.ToString()),
                            };
                            this.Officials.Add(newOfficial);
                        }
                        else
                        {
                            i = 10;
                        }
                        i++;
                    }
                    catch (Exception er)
                    {
                        throw new ArgumentException("Problem getting officials information");
                    }
                } while (i < 9);

            }

            gameClock = new Clock(_defaultTimerMinutes);
            this.DownInt = 1;
            this.YardsToGo = "10";
            this.QuarterInt = 1;
        }
示例#2
0
文件: Team.cs 项目: joebu23/GV-2015
        public Team(string teamFile)
        {
            this.Score = 0;

            using (SpreadsheetDocument document = SpreadsheetDocument.Open(teamFile, false))
            {
                // Retrieve a reference to the workbook part.
                WorkbookPart wbPart = document.WorkbookPart;

                Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().FirstOrDefault();

                // Throw an exception if there is no sheet.
                if (theSheet == null)
                {
                    throw new ArgumentException("sheetName Not Found");
                }

                WorksheetPart wsPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id));

                var excelService = new ExcelService(wbPart, wsPart);

                this.Name = excelService.GetValueFromCell("A1");
                this.Mascot = excelService.GetValueFromCell("B1");
                this.BugName = excelService.GetValueFromCell("C1");
                this.Logo = excelService.GetValueFromCell("E1");

                this.Record = excelService.GetValueFromCell("F1");
                this.ShortName = excelService.GetValueFromCell("G1");

                this.CoachName = excelService.GetValueFromCell("A2");
                this.CoachInfo = excelService.GetValueFromCell("B2") + " (" + excelService.GetValueFromCell("C2") + ")";

                this.Players = new List<Player>();
                var i = 3;
                do
                {
                    try
                    {
                        if(excelService.GetValueFromCell("A" + i.ToString()) != "XXX")
                        {
                            var newPlayer = new Player
                            {
                                Number = excelService.GetValueFromCell("A" + i.ToString()).GetInt(),
                                Name = excelService.GetValueFromCell("B" + i.ToString()),
                                Position = excelService.GetValueFromCell("C" + i.ToString()),
                                Height = excelService.GetValueFromCell("D" + i.ToString()),
                                Weight = excelService.GetValueFromCell("E" + i.ToString()),
                                Year = excelService.GetValueFromCell("F" + i.ToString()),
                                Hometown = excelService.GetValueFromCell("G" + i.ToString())
                            };
                            this.Players.Add(newPlayer);
                        }
                        else
                        {
                            i = 104;
                        }
                        i++;
                    }
                    catch (Exception er)
                    {
                        throw new ArgumentException("Error Getting Players");
                    }
                } while (i < 102);
            }
        }