-
Notifications
You must be signed in to change notification settings - Fork 0
/
SessionAPI.cs
65 lines (58 loc) · 2.02 KB
/
SessionAPI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Web;
using Arena.Core;
using Arena.Custom.NPM.DataLayer.Data;
using Arena.Custom.NPM.DataLayer.Services;
namespace Arena.Custom.NPM.WebServiceMatching
{
/// <summary>
/// SessionAPI handles all methods and functions dealing with the Arena Session and related objects.
/// </summary>
class SessionAPI
{
public static int GetPersonIdBySessionId(string sessionId)
{
Guid sessionIdGuid = new Guid(sessionId);
ApiSession apiSession = new ApiSession(sessionIdGuid);
if (apiSession.Found)
{
Person person = new Person(apiSession.LoginID);
return person.PersonID;
}
else
{
throw new Exception("Session was not found.");
}
}
public static string GetPersonNameBySessionId(string sessionId)
{
if (!String.IsNullOrEmpty(sessionId))
{
Guid sessionIdGuid = new Guid(sessionId);
ApiSession apiSession = new ApiSession(sessionIdGuid);
ApiApplication aa = new ApiApplication(apiSession.ApplicationID);
Person person = new Person(apiSession.LoginID);
return aa.Name + "(" + person.FirstName + " " + person.LastName + ", " + person.PersonID + ")";
}
else
{
return "Session was not specified.";
}
}
public static string GetPersonNameByApiKey(string apiKey)
{
if (!String.IsNullOrEmpty(apiKey))
{
Guid apiKeyGuid = new Guid(apiKey);
ApiApplication aa = new ApiApplication(apiKeyGuid);
return aa.Name + "(Anonymous)";
}
else
{
return "Api key was not specified.";
}
}
}
}