question

keith-stephens7892 avatar image
keith-stephens7892 asked Phong Vu answered

C# get names and call count from call logs

I got a c# web app, which I am now getting call logs returned to me but how do I loop through the results and just get the name of the person who made the call and a count of how many calls they made.

Here is my code so far.


rc = new RestClient(appKey, appSecret, isProduction);

await rc.Authorize(userName, "", password);

var mainAccount = rc.Restapi().Account();

DateTime input = DateTime.Today;

int delta = DayOfWeek.Monday - input.DayOfWeek;

DateTime monday = input.AddDays(delta);


var extension2 = rc.Restapi().Account().Extension();

var callLogs = await mainAccount.CallLog().List(new { dateFrom = monday.ToString("yyyy-MM-dd") });

string id = string.Empty;

var query = callLogs.records.SelectMany(x => x.from.name)

.GroupBy(s => s)

.Select(g => new { Name = g.Key, Count = g.Count() });

//var query = callLogs.records.SelectMany(x => x.id)

// .GroupBy(s => s)

// .Select(g => new { Name = g.Key, Count = g.Count() });

foreach (var result in query)

{


Console.WriteLine("Name: {0}, Count: {1}", result.Name, result.Count);

}


Thanks for helping,

Keith.


getting started
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered
Hi Keith,

The name will not be shown if the call is not from the same the account. See more from API reference.
Symbolic name associated with a party. If the phone does not belong to the known extension, only the  location is returned, the  name is not determined then.
If you want to get the name of a user, you have to call the company directory contact list and match the number with the number from the contact list to identify the name. To specify only users (extensions from your account) who made outgoing calls, you can shorten the call log result by set the direction to OutBound.

Hope this helps!
+ Phong
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys