コード例 #1
0
 public DriveActivityHelper(DriveHelper drive)
 {
     this.drive = drive;
     // Create Google Drive Activity API service.
     service = new DriveActivityService(new BaseClientService.Initializer()
     {
         HttpClientInitializer = drive.Credential,
         ApplicationName       = drive.ApplicationName,
     });
 }
コード例 #2
0
        static void Main(string[] args)
        {
            Selection selection = Startup();

            Console.WriteLine("\nInitializing...");

            DriveHelper         drive          = new DriveHelper();
            DriveFileHelper     fileHelper     = new DriveFileHelper(drive);
            DriveActivityHelper activityHelper = new DriveActivityHelper(drive);

            List <DriveItem> filesToReparent = new List <DriveItem>();

            do
            {
                List <string> fileIDs = new List <string>();
                switch (selection)
                {
                case Selection.RestoreFolder:
                    fileIDs = fileHelper.GetFilesFromFolderById(restoreFolderId);     // finds all files that are in the given folder
                    break;

                case Selection.Orphan:
                    fileIDs = fileHelper.ScanForOrphans();     // finds all orphans
                    break;
                }

                try
                {
                    filesToReparent = activityHelper.FindOrphanParent(fileIDs);
                    // backup
                    //System.IO.File.WriteAllText("output.csv", DriveItem.Header() + string.Join("\r\n", (object[])filesToReparent.ToArray()));

                    fileHelper.MoveOrphanFilesToParent(restoreFolderId, filesToReparent);
                }
                catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); }
            } while (filesToReparent.Count > 0);

            Console.Write("All tasks done. Press any key to exit.");
            Console.ReadKey();
        }