Skip to main content

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.


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

Reply