Example #1
0
        public Roster()
        {
            // Clear the current roster
            rosterArr.Clear();

            ValueRange response = GDriveManager.readSpreadsheet(Constants.ROSTER_ID, "Sheet1");
            IDictionary <string, int> headerMap = GDriveManager.getHeaderMap(response.Values);

            IEnumerable <IList <Object> > sorted = response.Values.Skip(1).OrderBy(f => f.ElementAt(headerMap[NAME_COL]).ToString());
            List <BulkLoader>             rows   = new List <BulkLoader>();

            // Iterate through each row
            foreach (IList <Object> row in sorted)
            {
                RosterEntry r = new RosterEntry();
                r.name      = GDriveManager.readCell(row, headerMap[NAME_COL]);
                r.classType = GDriveManager.readCell(row, headerMap[CLASS_COL]);
                r.rank      = GDriveManager.readCell(row, headerMap[RANK_COL]);
                r.active    = GDriveManager.readCell(row, headerMap[ACTIVE_COL]);

                rows.Add(r);
                rosterArr.Add(r);
            }

            DBManager.getManager().bulkInsert(rows, "roster");

            logger.Info("Roster loaded successfully. " + rosterArr.Count + " entries.");
        }
Example #2
0
        public void loadRoster()
        {
            // Clear the current roster
            rosterArr.Clear();

            // Get the first worksheet of the first spreadsheet.
            // TODO: Choose a worksheet more intelligently based on your
            // app's needs.
            WorksheetFeed wsFeed = spreadsheet.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            //listQuery.SpreadsheetQuery = ACTIVE_COL + " = 'Yes'";
            listQuery.OrderByColumn = NAME_COL;

            ListFeed listFeed = GDriveManager.getService().Query(listQuery);

            List<BulkLoader> rows = new List<BulkLoader>();

            // Iterate through each row, printing its cell values.
            foreach (ListEntry row in listFeed.Entries) {

                // Print the first column's cell value
                //logger.Debug(row.Title.Text);
                RosterEntry r = new RosterEntry();
                // Iterate over the remaining columns, and print each cell value
                foreach (ListEntry.Custom element in row.Elements) {
                    //logger.Debug(element.Value);
                    switch (element.LocalName.ToLower()) {
                        case NAME_COL:
                            r.name = element.Value;
                            break;
                        case CLASS_COL:
                            r.classType = element.Value;
                            break;

                        case RANK_COL:
                            r.rank = element.Value;
                            break;

                        case ACTIVE_COL:
                            r.active = element.Value;
                            break;
                    }
                }

                rows.Add(r);
                rosterArr.Add(r);
            }

            DBManager.getManager().bulkInsert(rows, "roster");

            logger.Info("Roster loaded successfully. " + rosterArr.Count + " entries.");
        }
Example #3
0
 public static bool isActive(RosterEntry e)
 {
     return e.active.Equals("Yes", StringComparison.InvariantCultureIgnoreCase);
 }
Example #4
0
 public static bool isActive(RosterEntry e)
 {
     return(e.active.Equals("Yes", StringComparison.InvariantCultureIgnoreCase));
 }