Skip to content

Commit b39ceaa

Browse files
committed
Added project for getting agent statistics by ID
1 parent 53a1778 commit b39ceaa

File tree

7 files changed

+138
-5
lines changed

7 files changed

+138
-5
lines changed

Common/Tools.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
24
using ZendeskApi_v2;
5+
using ZendeskApi_v2.Models.AccountsAndActivities;
6+
using ZendeskApi_v2.Models.Tickets;
37

48
namespace Common
59
{
@@ -19,7 +23,6 @@ public static void PrintError()
1923
public static void PrintHelp(ZendeskApi api)
2024
{
2125
Console.WriteLine("You have to specify a group name or id as parameter");
22-
Console.WriteLine("List of groups:");
2326
PrintGroups(api);
2427
}
2528

@@ -28,6 +31,7 @@ public static void PrintHelp(ZendeskApi api)
2831
/// </summary>
2932
public static void PrintGroups(ZendeskApi api)
3033
{
34+
Console.WriteLine("List of groups:");
3135
foreach (var group in api.Groups.GetGroups().Groups)
3236
{
3337
Console.WriteLine(group.Id + ": " + group.Name);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
<appSettings>
7+
<add key="Zendesk_subdomain" value="domain"/>
8+
<add key="Username" value="user"/>
9+
<add key="Password" value="pass"/>
10+
</appSettings>
11+
</configuration>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace GetZendeskAgentStatisticsByAgentId
8+
{
9+
class Program
10+
{
11+
static void Main(string[] args)
12+
{
13+
}
14+
}
15+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{B4F36DFB-44F0-439F-A777-2C69446C1701}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>GetZendeskAgentStatisticsByAgentId</RootNamespace>
11+
<AssemblyName>GetZendeskAgentStatisticsByAgentId</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
54+
Other similar extension points exist, see Microsoft.Common.targets.
55+
<Target Name="BeforeBuild">
56+
</Target>
57+
<Target Name="AfterBuild">
58+
</Target>
59+
-->
60+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("GetZendeskAgentStatisticsByAgentId")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("GetZendeskAgentStatisticsByAgentId")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("b4f36dfb-44f0-439f-a777-2c69446c1701")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
4+
<package id="ZendeskApi_v2" version="3.2.14" targetFramework="net452" />
5+
</packages>

GetZendeskGroupStats/GetZendeskGroupStats.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,24 @@ public class GetZendeskGroupStats
2222
/// All the OPEN tickets in the group supplied as parameter
2323
/// </summary>
2424
private static List<ZendeskApi_v2.Models.Tickets.Ticket> _allOpenTicketsInGroup;
25+
2526
/// <summary>
2627
/// All tickets in the group
2728
/// </summary>
2829
private static List<ZendeskApi_v2.Models.Tickets.Ticket> _allTicketsInGroup;
30+
2931
/// <summary>
3032
/// The start of today in DateTimeOffset
3133
/// </summary>
32-
private static DateTimeOffset dayStartDateTimeOffset;
34+
private static DateTimeOffset _dayStartDateTimeOffset;
3335

3436
static void Main(string[] args)
3537
{
3638
_api = Common.ZendeskApiManager.ZendeskApi;
3739
_xml = new PrtgXmlOutput();
3840

3941
var today = DateTime.Today;
40-
dayStartDateTimeOffset = (DateTimeOffset)today;
42+
_dayStartDateTimeOffset = (DateTimeOffset)today;
4143

4244
if (args == null || args.Length == 0)
4345
{
@@ -159,7 +161,7 @@ private static void GetResult(string groupName)
159161
/// </summary>
160162
private static void GetNumSolvedToday()
161163
{
162-
var todaysTickets = _allTicketsInGroup.Where(t => t.UpdatedAt >= dayStartDateTimeOffset && t.UpdatedAt <= DateTimeOffset.Now).ToList();
164+
var todaysTickets = _allTicketsInGroup.Where(t => t.UpdatedAt >= _dayStartDateTimeOffset && t.UpdatedAt <= DateTimeOffset.Now).ToList();
163165

164166
var numSolvedToday = todaysTickets.Count(t => t.Status.ToLower().Equals("solved"));
165167
_xml.AddChannel("Tickets solved today", numSolvedToday.ToString());
@@ -171,7 +173,7 @@ private static void GetNumSolvedToday()
171173
private static void GetNewTicketsToday()
172174
{
173175

174-
var numNewTicketsToday = _allTicketsInGroup.Count(t => t.CreatedAt >= dayStartDateTimeOffset && t.CreatedAt <= DateTimeOffset.Now);
176+
var numNewTicketsToday = _allTicketsInGroup.Count(t => t.CreatedAt >= _dayStartDateTimeOffset && t.CreatedAt <= DateTimeOffset.Now);
175177
_xml.AddChannel("New tickets today", numNewTicketsToday.ToString());
176178
}
177179
}

0 commit comments

Comments
 (0)