Пример #1
0
 public InventoryRepository(
     IGoogleSheetsService sheetsService,
     IBookRowMapper bookRowMapper)
 {
     this.sheetsService = sheetsService;
     this.bookRowMapper = bookRowMapper;
 }
Пример #2
0
 public SalesRepository(
     IGoogleSheetsService sheetsService,
     ISaleRowMapper saleRowMapper)
 {
     this.sheetsService = sheetsService;
     this.saleRowMapper = saleRowMapper;
 }
Пример #3
0
 public ClanLoader(
     IOptions <ClanListOptions> options,
     IGoogleSheetsService googleSheets)
 {
     this.options      = options;
     this.googleSheets = googleSheets;
 }
Пример #4
0
        public GoogleSheetsLogger(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            this._configuration       = configuration;
            this._dateTimeHelper      = serviceProvider.GetService <IDateTimeHelper>();
            this._googleSheetsService = serviceProvider.GetService <IGoogleSheetsService>();

            this._sheetsId = this._configuration["Google:Sheets:Id"];
        }
Пример #5
0
        public GoogleSheetsLogger(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            _configuration       = configuration;
            _dateTimeHelper      = serviceProvider.GetService <IDateTimeHelper>();
            _googleSheetsService = serviceProvider.GetService <IGoogleSheetsService>();

            _sheetsId = _configuration["Google:Sheets:Id"];
            _interval = int.Parse(_configuration["Google:Sheets:Interval"]);
        }
Пример #6
0
 public RoutesController(IIOServiceContext context, IHttpContextAccessor httpContextAccessor, IHttpClientFactory clientFactory, IGoogleSheetsService googleSheetsService, IVtexApiService vtexApiService, ISheetsCatalogImportRepository SheetsCatalogImportRepository)
 {
     this._context                       = context ?? throw new ArgumentNullException(nameof(context));
     this._httpContextAccessor           = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
     this._clientFactory                 = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
     this._googleSheetsService           = googleSheetsService ?? throw new ArgumentNullException(nameof(googleSheetsService));
     this._vtexApiService                = vtexApiService ?? throw new ArgumentNullException(nameof(vtexApiService));
     this._sheetsCatalogImportRepository = SheetsCatalogImportRepository ?? throw new ArgumentNullException(nameof(SheetsCatalogImportRepository));
 }
Пример #7
0
        public GoogleSheetsUpdater(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            this._configuration       = configuration;
            this._googleSheetsService = serviceProvider.GetService <IGoogleSheetsService>();

            this._sheetsId = this._configuration["Google:Sheets:Id"];

            Console.WriteLine($"Target Sheets ID: {this._sheetsId}");
        }
Пример #8
0
 public HomeController(
     ApplicationDbContext db,
     ILogger <HomeController> logger,
     IGoogleSheetsService googleSheets)
 {
     this.db           = db;
     this.logger       = logger;
     this.googleSheets = googleSheets;
 }
Пример #9
0
        /// <summary>
        /// Creates a new instance of a GoogleSheets connection.
        /// </summary>
        /// <param name="provider">The Google Sheets service provider. See <see cref="SheetsServiceProvider"/> for a default implementation.</param>
        public GoogleSheets(IGoogleSheetsService provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            SheetsService = provider;
        }
Пример #10
0
        public CoverageLogTests()
        {
            this._stubGoogleSheetsService = Substitute.For <IGoogleSheetsService>();
            this._stubConfiguration       = Substitute.For <IConfiguration>();
            this._stubDateTimeHelper      = Substitute.For <IDateTimeHelper>();

            this._stubServiceProvider = Substitute.For <IServiceProvider>();
            this._stubServiceProvider.GetService <IGoogleSheetsService>().Returns(this._stubGoogleSheetsService);
            this._stubServiceProvider.GetService <IDateTimeHelper>().Returns(this._stubDateTimeHelper);
        }
Пример #11
0
 public Application(IOptions <ApplicationConfig> applicationConfig,
                    IOptions <GoogleServiceConfig> googleConfig,
                    IDatabaseInfoService dbInfo,
                    IGoogleSheetsService googleSheets)
 {
     _applicationConfig   = applicationConfig.Value;
     _googleServiceConfig = googleConfig.Value;
     _dbInfo       = dbInfo;
     _googleSheets = googleSheets;
 }
Пример #12
0
 public Application(IOptions <ApplicationConfig> applicationConfig,
                    IOptions <GoogleServiceConfig> googleConfig,
                    IPgInfoService pgInfo,
                    IGoogleSheetsService googleSheets)
 {
     _applicationConfig   = applicationConfig.Value;
     _googleServiceConfig = googleConfig.Value;
     _pgInfo       = pgInfo;
     _googleSheets = googleSheets;
 }
Пример #13
0
        public GoogleSheetUpdaterTest()
        {
            this._stubFileHelper          = Substitute.For <IFileHelper>();
            this._stubConfiguration       = Substitute.For <IConfiguration>();
            this._stubGoogleSheetsService = Substitute.For <IGoogleSheetsService>();

            this._stubServiceProvider = Substitute.For <IServiceProvider>();
            this._stubServiceProvider.GetService <IFileHelper>().Returns(this._stubFileHelper);
            this._stubServiceProvider.GetService <IConfiguration>().Returns(this._stubConfiguration);
            this._stubServiceProvider.GetService <IGoogleSheetsService>().Returns(this._stubGoogleSheetsService);
        }
Пример #14
0
        public GoogleSheetsUpdater(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            _configuration       = configuration;
            _googleSheetsService = serviceProvider.GetService <IGoogleSheetsService>();
            _coverageReader      = serviceProvider.GetService <ICoverageReader>();

            _sheetsId = _configuration["Google:Sheets:Id"];
            _interval = int.Parse(_configuration["Google:Sheets:Interval"]);

            Console.WriteLine($"Target Sheets ID: {_sheetsId}");
        }
Пример #15
0
 public WeightSubmitService(
     IServiceScopeFactory scopeFactory,
     ILogger <WeightSubmitService> logger,
     IOptions <WeightSubmitOptions> submitOptions,
     IGoogleSheetsService googleSheets,
     IOptions <WeightResultOptions> resultDatabase,
     IClanLoader clanLoader)
 {
     this.scopeFactory   = scopeFactory;
     this.logger         = logger;
     this.submitOptions  = submitOptions;
     this.googleSheets   = googleSheets;
     this.resultDatabase = resultDatabase;
     this.clanLoader     = clanLoader;
 }
Пример #16
0
 public ClansController(
     ApplicationDbContext db,
     IClashApi api,
     ILogger <ClansController> logger,
     IGoogleSheetsService googleSheets,
     IClanLoader clanLoader,
     IOptions <WeightResultOptions> resultDatabase,
     WeightSubmitService submitService
     )
 {
     this.db             = db;
     this.api            = api;
     this.logger         = logger;
     this.googleSheets   = googleSheets;
     this.clanLoader     = clanLoader;
     this.resultDatabase = resultDatabase;
     this.submitService  = submitService;
 }
Пример #17
0
        private static void DuplicateCoverageLog(IServiceProvider serviceProvider, IGoogleSheetsService googleSheetsService, string sourceId, string targetId)
        {
            var dateTimeHelper = serviceProvider.GetService <IDateTimeHelper>();

            var now       = dateTimeHelper.Now;
            var sheetName = now.ToString("yyyy");

            //// Read
            var firstRow    = 1;
            var maxRow      = string.Empty;
            var startColumn = "A";
            var endColumn   = "BH";
            var range       = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{maxRow}";

            Console.WriteLine($"Source Range: {range}");
            var sourceList = googleSheetsService.GetValues(sourceId, range);

            //// Write
            var targetRange = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{sourceList.Count + 1}";

            Console.WriteLine($"Target Range: {targetRange}");
            googleSheetsService.SetValue(targetId, targetRange, sourceList);
        }
Пример #18
0
        private static void DuplicateCoverage(IGoogleSheetsService googleSheetsService, string sourceId, string targetId)
        {
            var sheetName = "Coverage";

            //// Read
            var firstRow    = 2;
            var maxRow      = string.Empty;
            var startColumn = "A";
            var endColumn   = "J";
            var range       = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{maxRow}";

            Console.WriteLine($"Source Range: {range}");
            var sourceList = googleSheetsService.GetValues(sourceId, range);
            var methodList = Program.SheetRangeToEntityList(sourceList);

            //// Write
            endColumn = "H";
            var targetRange = $"{sheetName}!{startColumn}{firstRow}:{endColumn}{sourceList.Count + 1}";

            Console.WriteLine($"Target Range: {targetRange}");
            var targetList = Program.EntityListToSheetRange(methodList);

            googleSheetsService.SetValue(targetId, targetRange, targetList);
        }
Пример #19
0
        public Query(IGoogleSheetsService googleSheetsService, ISheetsCatalogImportRepository sheetsCatalogImportRepository)
        {
            Name = "Query";

            FieldAsync <BooleanGraphType>(
                "haveToken",
                resolve: async context =>
            {
                Token token = await googleSheetsService.GetGoogleToken();
                return(token != null && !string.IsNullOrEmpty(token.RefreshToken));
            }
                );

            /// query Reviews($searchTerm: String, $from: Int, $to: Int, $orderBy: String, $status: Boolean)
            FieldAsync <StringGraphType>(
                "getOwnerEmail",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "accountName", Description = "Account Name"
            }
                    ),
                resolve: async context =>
            {
                string email       = string.Empty;
                string accountName = context.GetArgument <string>("accountName");
                Token token        = await googleSheetsService.GetGoogleToken();
                if (token != null)
                {
                    string productsFolderId = string.Empty;
                    FolderIds folderIds     = await sheetsCatalogImportRepository.LoadFolderIds(accountName);
                    if (folderIds != null)
                    {
                        if (!string.IsNullOrEmpty(folderIds.FolderOwner))
                        {
                            email = folderIds.FolderOwner;
                        }
                        else
                        {
                            productsFolderId = folderIds.ProductsFolderId;
                            ListFilesResponse listFilesResponse = await googleSheetsService.ListSheetsInFolder(productsFolderId);
                            if (listFilesResponse != null)
                            {
                                var owners = listFilesResponse.Files.Select(o => o.Owners.Distinct()).FirstOrDefault();
                                if (owners != null)
                                {
                                    email = owners.Select(o => o.EmailAddress).FirstOrDefault();
                                }
                            }
                        }
                    }
                }

                return(email);
            }
                );

            FieldAsync <StringGraphType>(
                "sheetLink",
                resolve: async context =>
            {
                return(await googleSheetsService.GetSheetLink());
            }
                );
        }
Пример #20
0
        public Mutation(IGoogleSheetsService googleSheetsService, ISheetsCatalogImportRepository sheetsCatalogImportRepository, IVtexApiService vtexApiService)
        {
            Name = "Mutation";

            Field <BooleanGraphType>(
                "revokeToken",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "accountName", Description = "Account Name"
            }
                    ),
                resolve: context =>
            {
                bool revoked = googleSheetsService.RevokeGoogleAuthorizationToken().Result;
                if (revoked)
                {
                    string accountName = context.GetArgument <string>("accountName");
                    sheetsCatalogImportRepository.SaveFolderIds(null, accountName);
                }

                return(revoked);
            });

            Field <StringGraphType>(
                "googleAuthorize",
                resolve: context =>
            {
                return(googleSheetsService.GetAuthUrl());
            });

            Field <StringGraphType>(
                "createSheet",
                resolve: context =>
            {
                var created = googleSheetsService.CreateSheet();
                vtexApiService.SetBrandList();
                return(created);
            });

            Field <StringGraphType>(
                "processSheet",
                resolve: context =>
            {
                return(vtexApiService.ProcessSheet());
            });

            Field <StringGraphType>(
                "clearSheet",
                resolve: context =>
            {
                var cleared         = vtexApiService.ClearSheet();
                var catalogAndBrand = vtexApiService.SetBrandList();
                return(!string.IsNullOrWhiteSpace(cleared.Result) && catalogAndBrand.Result);
            });

            Field <StringGraphType>(
                "addImages",
                resolve: context =>
            {
                return(vtexApiService.AddImagesToSheet());
            });

            Field <StringGraphType>(
                "exportProducts",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "exportQuery", Description = "Export Query"
            }
                    ),
                resolve: context =>
            {
                string query = context.GetArgument <string>("exportQuery");
                return(vtexApiService.ExportToSheet(query));
            });
        }
Пример #21
0
 public GoogleSheetsController(IGoogleSheetsService googleSheetsService)
 {
     _googleSheetsService = googleSheetsService;
 }
 /// <summary>
 ///     Конструктор.
 /// </summary>
 /// <param name="googleSheets"></param>
 public GoogleSheetsController(IGoogleSheetsService googleSheets)
 {
     _googleSheets = googleSheets;
 }
Пример #23
0
        public GoogleSheetsReader(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            this._googleSheetsService = serviceProvider.GetService <IGoogleSheetsService>();

            this._sheetsId = configuration["Google:Sheets:Id"];
        }