示例#1
0
        public static List <Change> RetrieveAllChanges(DriveService service, long?startChangeId)
        {
            List <Change> result = new List <Change>();

            ChangesResource.ListRequest request = service.Changes.List();
            request.IncludeDeleted = true;

            if (!String.IsNullOrEmpty(startChangeId.ToString()))
            {
                request.StartChangeId = startChangeId;
            }
            do
            {
                try
                {
                    ChangeList changes = request.Execute();
                    result.AddRange(changes.Items);
                    request.PageToken = changes.NextPageToken;
                }
                catch (Exception e)
                {
                    Console.WriteLine("An error occurred: " + e.Message);
                    request.PageToken = null;
                }
            } while (!String.IsNullOrEmpty(request.PageToken));
            return(result);
        }
示例#2
0
 /// <summary>
 /// Returns all GCD changes within a zone of a project.
 /// </summary>
 private IEnumerable <Change> GetGcdChange(string project, string zone)
 {
     ChangesResource.ListRequest changeListRequest = Service.Changes.List(project, zone);
     do
     {
         ChangesListResponse changeListResponse = changeListRequest.Execute();
         IList <Change>      changeList         = changeListResponse.Changes;
         if (changeListResponse.Changes != null)
         {
             foreach (Change change in changeListResponse.Changes)
             {
                 yield return(change);
             }
         }
         changeListRequest.PageToken = changeListResponse.NextPageToken;
     }while (changeListRequest.PageToken != null);
 }
示例#3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (!String.IsNullOrEmpty(ChangeId))
            {
                ChangesResource.GetRequest changeGetRequest = Service.Changes.Get(Project, Zone, ChangeId);
                Change changeResponse = changeGetRequest.Execute();
                WriteObject(changeResponse);
            }
            else
            {
                ChangesResource.ListRequest changeListRequest  = Service.Changes.List(Project, Zone);
                ChangesListResponse         changeListResponse = changeListRequest.Execute();
                IList <Change> changeList = changeListResponse.Changes;
                WriteObject(changeList, true);
            }
        }
示例#4
0
            public IEnumerable <Change> UpdateRecordChanges(string change_token, out string new_change_token)
            {
                string        page_token = change_token;
                List <Change> changes    = new List <Change>();

                new_change_token = change_token;

                do
                {
                    ChangeList result;
                    ChangesResource.ListRequest request = drive_service.Changes.List(page_token);

                    request.Spaces = "drive";
                    request.Fields = "nextPageToken, changes(removed, fileId, file(id, name, md5Checksum, modifiedTime, parents))";

                    try
                    {
                        result = request.Execute();
                    }
                    catch (Google.GoogleApiException)
                    {
                        break;
                    }

                    changes.AddRange(result.Changes);

                    if (result.NewStartPageToken != null)
                    {
                        new_change_token = result.NewStartPageToken;
                    }

                    page_token = result.NextPageToken;
                }while (page_token != null);

                return(changes);
            }