0

我正在使用 C# 上的 .NET 客户端库来构建一个用于特定目的的小型应用程序。

我需要返回 'gmail_used_quota_in_mb' 和 'total_quota_in_mb' 和 'used_quota_in_mb' 的值

基于此页面(https://developers.google.com/admin-sdk/reports/v1/reference/usage-ref-appendix-a/users-accounts),我应该在我的请求的输出中获取参数应用程序,但是我没有得到这些值...

我正在使用以下代码进行操作:

string nl = Environment.NewLine;
UserCredential credential;
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
        GoogleClientSecrets.Load(stream).Secrets,
        new[] { ReportsService.Scope.AdminReportsUsageReadonly },
        "user", CancellationToken.None, new FileDataStore("Reports.ListSizes"));
}

// Create the service.
var service = new ReportsService(new BaseClientService.Initializer()
{
    HttpClientInitializer = credential,
    ApplicationName = "Reports API Sample",
});

try
{
    UserUsageReportResource.GetRequest request = service.UserUsageReport.Get("x@y.z", "2016-12-16");
    IList<UsageReport> result = request.Execute().UsageReportsValue;
    foreach (var item in result)
    {
        AppendTextBox(textBox1.Text + "User ID=" + item.Parameters[0].StringValue);
        // In the Parameters[] array, I get 46 items, none of them is one of the above 3 parameters I am looking for...
    }           
}
catch(Google.GoogleApiException ex)
{
    MessageBox.Show(ex.Message, "Error");
}

在 Parameters[] 数组中,我得到 46 个项目,它们都不是我正在寻找的上述 3 个参数之一......

我从以下页面获取了大部分代码,并对其进行了调整以满足我对 UsageReport 的需求: https ://developers.google.com/admin-sdk/reports/v1/quickstart/dotnet

我非常感谢任何帮助,因为我主要是一名系统工程师,并且正在从事 G Suite 迁移项目,并且需要使该应用程序能够完成数据迁移的关键部分。

编辑(额外细节):这是我从输出中得到的所有参数......

账户:admin_set_name=xxxxx 账户:is_disabled= 账户:disabled_reason= 账户:first_name=xxxxx 账户:is_2sv_enforced= 账户:is_2sv_enrolled= 账户:is_delegated_admin= 账户:is_less_secure_apps_access_allowed= 账户:is_super_admin= 账户:is_suspended= 账户:last_name=xxxxx 账户:num_authorized_apps = accounts:num_roles_assigned= accounts:num_security_keys= accounts:creation_time= accounts:last_login_time= accounts:last_sso_time= accounts:user_has_overridden_​​name= docs:num_owned_google_documents_created= docs:num_owned_google_documents_edited= docs:num_owned_google_documents_trashed= docs:num_owned_google_documents_viewed= docs:num_owned_google_drawings_created= docs:num_owned_google_drawings_edited= docs :num_owned_google_drawings_trashed= 文档:num_owned_google_drawings_viewed= docs:num_owned_google_forms_created= docs:num_owned_google_forms_edited= docs:num_owned_google_forms_trashed= docs:num_owned_google_forms_viewed= docs:num_owned_google_presentations_created= docs:num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited= docs:num_owned_other_types_trashed= docs:num_owned_other_types_viewed=num_owned_google_forms_created= docs:num_owned_google_forms_edited= docs:num_owned_google_forms_trashed= docs:num_owned_google_forms_viewed= docs:num_owned_google_presentations_created= docs:num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited= docs:num_owned_other_types_trashed= docs:num_owned_other_types_viewed=num_owned_google_forms_created= docs:num_owned_google_forms_edited= docs:num_owned_google_forms_trashed= docs:num_owned_google_forms_viewed= docs:num_owned_google_presentations_created= docs:num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited= docs:num_owned_other_types_trashed= docs:num_owned_other_types_viewed=num_owned_google_forms_trashed= docs:num_owned_google_forms_viewed= docs:num_owned_google_presentations_created= docs:num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed=文档:num_owned_items_viewed= 文档:num_owned_other_types_created= 文档:num_owned_other_types_edited= 文档:num_owned_other_types_trashed= 文档:num_owned_other_types_viewed=num_owned_google_forms_trashed= docs:num_owned_google_forms_viewed= docs:num_owned_google_presentations_created= docs:num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed=文档:num_owned_items_viewed= 文档:num_owned_other_types_created= 文档:num_owned_other_types_edited= 文档:num_owned_other_types_trashed= 文档:num_owned_other_types_viewed=num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited=文档:num_owned_other_types_trashed= 文档:num_owned_other_types_viewed=num_owned_google_presentations_edited= docs:num_owned_google_presentations_trashed= docs:num_owned_google_presentations_viewed= docs:num_owned_google_spreadsheets_created= docs:num_owned_google_spreadsheets_edited= docs:num_owned_google_spreadsheets_trashed= docs:num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited=文档:num_owned_other_types_trashed= 文档:num_owned_other_types_viewed=num_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited= docs:num_owned_other_types_trashed= docs:num_owned_other_typesviewnum_owned_google_spreadsheets_viewed= docs:num_owned_items_created= docs:num_owned_items_edited= docs:num_owned_items_trashed= docs:num_owned_items_viewed= docs:num_owned_other_types_created= docs:num_owned_other_types_edited= docs:num_owned_other_types_trashed= docs:num_owned_other_typesview

谢谢

4

1 回答 1

1

好的,因此如果用户在检索报告时没有数据,则以下值将不会出现在报告中:

  • drive_used_quota_in_mb
  • gmail_used_quota_in_mb
  • gplus_photos_used_quota_in_mb
  • total_quota_in_mb
  • used_quota_in_mb
  • used_quota_in_percentage

我想这对我来说是一种足够的验证方法,如果用户有数据会出现值,那么我可以比较数据大小。如果用户没有数据,则不会返回这些值,因此我假设他的数据使用量为 0。

我花了一段时间才发现,因为我运行报告的用户实际上有数据,但由于报告数据可用的机制,我在用户没有数据的时候搜索。当我输入“全部”搜索参数时,我在一些在搜索日期之前拥有数据的帐户中获得了这些值,这让我更加困惑。

但是今天在能够安静地坐下来检查每个案例之后,我得出了这个结论。我只希望谷歌在参数输出页面上指出更多...

于 2016-12-19T15:48:18.703 回答