// Quickstart: connect, log in, list the 10 most recently modified documents, log out. // // Configure with environment variables: MFILES_ADDRESS, MFILES_TLS, MFILES_VAULT, // MFILES_USERNAME and MFILES_PASSWORD (or MFILES_TOKEN, MFILES_AUTH_PLUGIN, MFILES_AUTH_SCOPE). // [START quickstart] using MFiles.Grpc; using MFiles.Grpc.Samples; using static MFiles.Grpc.Samples.MFilesValues; // Connect and log in with the MFILES_* settings. Disposing the connection logs out. await using var connection = await MFilesConnection.ConnectAsync( MFilesSettings.FromEnvironment(), clientName: "M-Files gRPC quickstart"); var request = new SearchObjectsRequest { // Documents (object type 0) that are not deleted. Conditions = { new SearchConditionArray { Value = { IsObjectType(0), IsNotDeleted() } } }, // Newest first by property 21, "Last modified". The server sorts, then takes 10. Sorting = new SearchResultsSorting { Rules = new SortRuleValueArray { Values = { new SortRule { Key = 21, Options = new SortRuleFlags { SortDescending = true } } }, }, }, Limit = 10, }; // Service clients run on the connection's call invoker, which adds the session to each call. var search = new IRPCSearch.IRPCSearchClient(connection.CallInvoker); var response = await search.SearchObjectsAsync(request); foreach (var item in response.Results) { var version = item.Object.VersionInfo; Console.WriteLine($"{version.Title} (ID {item.Object.ObjectInfo.ObjId.ItemId.InternalId}, " + $"version {version.Version.InternalVersion}, " + $"modified {version.LastModifiedAtUtc.ToDateTime():yyyy-MM-dd HH:mm:ss} UTC)"); } // [END quickstart]