public Google2uManualWorkbook(WorksheetFeed in_feed, string in_url, string in_name, Service in_service) { _Service = in_service; WorkbookUrl = in_url; Workbook = in_feed; WorkbookName = in_name; Worksheets = new List<Google2uWorksheet>(); }
//method for formatting list of multiple worksheets as single string private string worksheetList(WorksheetFeed feed) { List<string> list = new List<string>(); foreach (WorksheetEntry entry in feed.Entries) { list.Add(entry.Title.Text); } return String.Join(", ", list); }
private void GetWins(SpreadsheetsService service, SpreadsheetEntry entry, WorksheetFeed wsFeed, List<Player> Players) { int cellID = 0; List<CellFeed> cellFeeds = DoCellQuery(service, wsFeed, 2, 3, 3); for (int i = 0; i < cellFeeds.Count; i++) { CellFeed currentCellFeed = cellFeeds[i]; if (currentCellFeed != null) { foreach (CellEntry cell in currentCellFeed.Entries) { string playerList = cell.InputValue; string[] playerNames = null; if (!String.IsNullOrWhiteSpace(playerList)) { playerNames = playerList.Split(',').Select(sValue => sValue.Trim()).ToArray(); } else { break; } foreach (string playerName in playerNames) { string placement = null; string playerNameTrimmed = null; if (playerName.Contains("(")) { placement = Regex.Match(playerName, @"\(([^)]*)\)").Groups[1].Value; playerNameTrimmed = playerName.Remove(playerName.Length - 4); } else { playerNameTrimmed = playerName; } if (Players.Exists(player => player.Name == playerNameTrimmed)) { Player myPlayer = new Player(); myPlayer = Players.Find(player => player.Name == playerNameTrimmed); myPlayer.Wins += 1; if (placement != null) { if (myPlayer.Placement == null) { myPlayer.Placement = new List<int>(); } myPlayer.Placement.Add(Int32.Parse(placement)); } foreach (GameEvent gameEvent in GamesPlayed) { if (gameEvent.Name == wsFeed.Entries[i].Title.Text && gameEvent.ID == cellID) { if (gameEvent.Winners == null) { gameEvent.Winners = new List<Player>(); } gameEvent.Winners.Add(myPlayer); } } } } cellID++; } } } foreach (Player player in Players) { player.WinPercentage = player.GetWinPercentage(); } GetLosses(service, entry, wsFeed, Players); }
private void GetPlayers(SpreadsheetsService service, SpreadsheetEntry entry, WorksheetFeed wsFeed) { int cellID = 0; Players = new List<Player>(); List<CellFeed> cellFeeds = DoCellQuery(service, wsFeed, 2, 2, 2); for (int i = 0; i < cellFeeds.Count; i++) { CellFeed currentCellFeed = cellFeeds[i]; if (currentCellFeed != null) { foreach (CellEntry cell in currentCellFeed.Entries) { string playerList = cell.InputValue; string[] playerNames = null; if (!String.IsNullOrWhiteSpace(playerList)) { playerNames = playerList.Split(',').Select(sValue => sValue.Trim()).ToArray(); } else { break; } foreach (string playerName in playerNames) { if (!Players.Exists(player => player.Name == playerName)) { Players.Add(new Player() { Name = playerName }); } Player myPlayer = new Player(); myPlayer = Players.Find(player => player.Name == playerName); myPlayer.GamesPlayed += 1; foreach (GameEvent gameEvent in GamesPlayed) { if (gameEvent.Name == wsFeed.Entries[i].Title.Text && gameEvent.ID == cellID) { if (gameEvent.Participants == null) { gameEvent.Participants = new List<Player>(); } gameEvent.Participants.Add(myPlayer); } } } cellID++; } } } GetWins(service, entry, wsFeed, Players); }
private void GetGameDateName(SpreadsheetsService service, SpreadsheetEntry entry, WorksheetFeed wsFeed) { GamesPlayed = new List<GameEvent>(); List<CellFeed> cellFeeds = DoCellQuery(service, wsFeed, 2, 1, 1); int gameID = 0; for (int i = 0; i < cellFeeds.Count; i++) { CellFeed currentCellFeed = cellFeeds[i]; if (currentCellFeed != null) { foreach (CellEntry cell in currentCellFeed.Entries) { GameEvent newGameEvent = new GameEvent(); string dateTimeString = cell.InputValue; DateTime dateTime = DateTime.Parse(dateTimeString); newGameEvent.Date = dateTime; newGameEvent.Name = wsFeed.Entries[i].Title.Text; newGameEvent.ID = gameID; GamesPlayed.Add(newGameEvent); gameID++; } } } GetPlayers(service, entry, wsFeed); }
private List<CellFeed> DoCellQuery(SpreadsheetsService service, WorksheetFeed wsFeed, uint minRow, uint minColumn, uint maxColumn) { List<CellFeed> cellFeeds = new List<CellFeed>(); int i = 0; foreach (WorksheetEntry worksheet in wsFeed.Entries) { if (worksheet.Title.Text[0] != '0') { CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink); cellQuery.MinimumRow = minRow; cellQuery.MinimumColumn = minColumn; cellQuery.MaximumColumn = maxColumn; CellFeed cellFeed = service.Query(cellQuery); cellFeeds.Insert(i, cellFeed); i++; } else { CellFeed cellFeed = null; cellFeeds.Insert(i, cellFeed); i++; } } return cellFeeds; }
/// <summary> /// Sets the list view on the Worksheets page with the titles of the worksheets, /// and the row and column counts for demonstration of these extension elements /// </summary> /// <param name="feed">The worksheets feed for the spreadsheet selected on the Spreadsheets page</param> void SetWorksheetListView(WorksheetFeed feed) { this.worksheetListView.Items.Clear(); AtomEntryCollection entries = feed.Entries; for (int i = 0; i < entries.Count; i++) { // Get the cells feed URI AtomLink cellsLink = entries[i].Links.FindService(GDataSpreadsheetsNameTable.CellRel, AtomLink.ATOM_TYPE); // Get the list feed URI AtomLink listLink = entries[i].Links.FindService(GDataSpreadsheetsNameTable.ListRel, AtomLink.ATOM_TYPE); // Create an item that will display the title and hide the cells and list feed URIs ListViewItem item = new ListViewItem(new string[3]{ entries[i].Title.Text + " (Rows:" + ((WorksheetEntry)entries[i]).RowCount.Count + ", Cols:" + ((WorksheetEntry)entries[i]).ColCount.Count + ")", cellsLink.HRef.Content, listLink.HRef.Content}); this.worksheetListView.Items.Add(item); } }
public WorksheetEntry Insert(WorksheetFeed wsFeed, WorksheetEntry wsEntry) { Debug.WriteLine("Try WorksheetInsert"); return Service.Insert(wsFeed, wsEntry); }