Ejemplo n.º 1
0
        public ReactionsParser(SheetsService service, Models.Spreadsheet spreadsheet, SupportMethods supportMethods)
        {
            _service = service;

            _spreadsheet = spreadsheet;

            _supportMethods = supportMethods;
        }
Ejemplo n.º 2
0
        private SheetsService GetSheetsService(Credentials credentials, Models.Spreadsheet spreadsheet)
        {
            //getting credentials from appsettings.json
            var json = Newtonsoft.Json.JsonConvert.SerializeObject(credentials);
            GoogleCredential credential = GoogleCredential.FromJson(json).CreateScoped(Scopes);
            var service = new SheetsService(new Google.Apis.Services.BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = spreadsheet.ApplicationName
            });

            return(service);
        }
        private SpreadsheetInstance(string spreadsheetId, string databaseSheet, string databaseFamilyNamesColumn, int databaseHeadersRow, string partiesSheet, int partiesHeadersRow)
        {
            UserCredential credential;

            using (var stream =
                       new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = Environment.GetFolderPath(
                    Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Google Sheets API service.
            Service = new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            Spreadsheet = new Models.Spreadsheet(spreadsheetId)
            {
                DatabaseSheet = new DatabaseSheet(databaseSheet),
                PartiesSheet  = new DatabaseSheet(partiesSheet)
            };

            SupportMethods = new SupportMethods(Service, Spreadsheet);
            PopulateSpreadsheetModel(databaseFamilyNamesColumn, databaseHeadersRow, partiesHeadersRow);

            CommandsParser  = new CommandsParser(Service, Spreadsheet, SupportMethods);
            ReactionsParser = new ReactionsParser(Service, Spreadsheet, SupportMethods);
        }
Ejemplo n.º 4
0
 public RowsRepository(Models.Spreadsheet spreadsheet, Credentials credentials)
 {
     this.spreadsheet = spreadsheet;
     service          = GetSheetsService(credentials, spreadsheet);
     rows             = LoadAllRows(service);
 }
Ejemplo n.º 5
0
 public SupportMethods(SheetsService service, Models.Spreadsheet spreadsheet)
 {
     _service     = service;
     _spreadsheet = spreadsheet;
 }