Пример #1
0
        public string Create(TableInfo tableInfo, DrivePath path)
        {
            if (!AuthService.HasDriveAccess())
            {
                throw new InsufficientPermissionException();
            }

            tableInfo.Location = EstablishLocationForPath(new DrivePath(path));

            GoogleFile file = CreateFile(GoogleFileTypes.GoogleSpreadsheet, tableInfo.Name, "id", tableInfo.Location,
                                         tableInfo.Description);

            SpreadsheetId = file.Id;
            tableInfo.Id  = file.Id;

            return(file.Id);
        }
Пример #2
0
        private string EstablishLocationForPath(DrivePath path)
        {
            string location = null;

            foreach (string folder in path)
            {
                string folderId = SearchFileId(GoogleFileTypes.Folder, folder, location);

                if (folderId != null)
                {
                    location = folderId;
                }
                else
                {
                    location = CreateFile(GoogleFileTypes.Folder, folder, "id", location).Id;
                    Logger.Log($"Created folder named: {folder}, with id: {location}");
                }
            }

            return(location);
        }