Example #1
0
        public static void UpdateWithSpreadsheet(string editInfoPath,
                                                 string keySpreadsheet, string worksheetId)
        {
            // Get the service.
            var service = new SpreadsheetsService();

            // Get all the info from spreadsheet parsing the spreadsheet with keys.
            Console.WriteLine("Downloading spreadsheet");
            var keys         = service.RetrieveWorksheet(keySpreadsheet, worksheetId);
            var spreadsheets = new List <SpreadsheetData>(keys.Rows);

            for (int r = 0; r < keys.Rows; r++)
            {
                // If the path is null, skip.
                if (string.IsNullOrEmpty(keys[r, 0]))
                {
                    continue;
                }

                // The first column is the path and the second the key
                string path = keys[r, 0];
                string name = path.Substring(path.LastIndexOf("\\") + 1);
                string key  = keys[r, 1];

                // Special case for tutorial, say below.
                if (name.StartsWith("Tut0"))
                {
                    name = "Tutorial_" + name.Substring(3, 2) + "/" + name.Substring(6, 2);
                }

                spreadsheets.Add(new SpreadsheetData(name, key));
            }

            Console.WriteLine("Updating edit info");
            UpdateEditInfo(editInfoPath, spreadsheets);
        }