예제 #1
0
        public List <string> CheckForOutOfDateGames(Dictionary <DrawGame, DateTime> timeRetrievedGames)
        {
            var fileList       = _service.ListFiles();
            var outOfDateGames = timeRetrievedGames.Where(a => a.Value < fileList.FirstOrDefault(b => b.FileName == a.Key.GameName).LastModified);
            var newGames       = fileList.Where(a => !timeRetrievedGames.Keys.Any(b => b.GameName == a.FileName)).GroupBy(a => a.FileName).Select(a => a.First()).ToList();

            return(outOfDateGames.ToList().Select(a => a.Key.GameName).ToList().Concat(newGames.Select(a => a.FileName)).ToList());
        }
예제 #2
0
        public List <FileDto> ListFolder()
        {
            List <FileDto> response = null;

            try
            {
                var service = _googleDriveOperation.GetDriveService();
                response = _googleDriveOperation.ListFiles(service);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.StackTrace);
            }
            return(response);
        }
예제 #3
0
        public Query(IGoogleDriveService googleDriveService, IDriveImportRepository driveImportRepository)
        {
            Name = "Query";

            FieldAsync <BooleanGraphType>(
                "haveToken",
                resolve: async context =>
            {
                Token token = await googleDriveService.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 googleDriveService.GetGoogleToken();
                if (token != null)
                {
                    string newFolderId  = string.Empty;
                    FolderIds folderIds = await driveImportRepository.LoadFolderIds(accountName);
                    if (folderIds != null)
                    {
                        newFolderId = folderIds.NewFolderId;
                    }
                    else
                    {
                        newFolderId = await googleDriveService.FindNewFolderId(accountName);
                    }

                    ListFilesResponse listFilesResponse = await googleDriveService.ListFiles();
                    if (listFilesResponse != null)
                    {
                        var owners = listFilesResponse.Files.Where(f => f.Id.Equals(newFolderId)).Select(o => o.Owners.Distinct()).FirstOrDefault();
                        if (owners != null)
                        {
                            email = owners.Select(o => o.EmailAddress).FirstOrDefault();
                        }
                        else
                        {
                            newFolderId = await googleDriveService.FindNewFolderId(accountName);
                            owners      = listFilesResponse.Files.Where(f => f.Id.Equals(newFolderId)).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 googleDriveService.GetSheetLink());
            }
                );
        }
예제 #4
0
 public async Task <IActionResult> ListFiles()
 {
     Response.Headers.Add("Cache-Control", "no-cache");
     return(Json(await _googleDriveService.ListFiles()));
 }