diff --git a/.gitignore b/.gitignore
index 55f0bbe8..bb307b5b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,7 +70,7 @@ paket-files/
# End of https://www.gitignore.io/api/aspnetcore
node_modules
-**/wwwroot/dist
+#**/wwwroot/dist
# nunit test results
TestResult.xml
@@ -85,3 +85,7 @@ bootstrap-datetimepicker-build.min.css
colorpicker.css
colorpicker.min.css
*.log
+CCMWeb/appsettings.Development.json
+
+logs
+CCM.Web/appsettings.Development.json
diff --git a/CCM.Core/Attributes/FilterPropertyAttribute.cs b/CCM.Core/Attributes/FilterPropertyAttribute.cs
index 859d23eb..82aed7d4 100644
--- a/CCM.Core/Attributes/FilterPropertyAttribute.cs
+++ b/CCM.Core/Attributes/FilterPropertyAttribute.cs
@@ -28,6 +28,9 @@
namespace CCM.Core.Attributes
{
+ ///
+ /// Used to collect possible discovery filter properties, use as '[FilterProperty(TableName = "Locations", ColumnName = "Name")]'
+ ///
public class FilterPropertyAttribute : Attribute
{
public string TableName { get; set; }
diff --git a/CCM.WebCommon/Authentication/Credentials.cs b/CCM.Core/Authentication/AuthenticationCredentials.cs
similarity index 95%
rename from CCM.WebCommon/Authentication/Credentials.cs
rename to CCM.Core/Authentication/AuthenticationCredentials.cs
index 7dcc431b..ea774e49 100644
--- a/CCM.WebCommon/Authentication/Credentials.cs
+++ b/CCM.Core/Authentication/AuthenticationCredentials.cs
@@ -24,9 +24,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-namespace CCM.WebCommon.Authentication
+namespace CCM.Core.Authentication
{
- public class Credentials
+ public class AuthenticationCredentials
{
public string Username { get; set; }
public string Password { get; set; }
diff --git a/CCM.WebCommon/Authentication/BasicAuthenticationAttributeBase.cs b/CCM.Core/Authentication/BasicAuthenticationAttributeBase.cs
similarity index 50%
rename from CCM.WebCommon/Authentication/BasicAuthenticationAttributeBase.cs
rename to CCM.Core/Authentication/BasicAuthenticationAttributeBase.cs
index 777d622a..04db9d65 100644
--- a/CCM.WebCommon/Authentication/BasicAuthenticationAttributeBase.cs
+++ b/CCM.Core/Authentication/BasicAuthenticationAttributeBase.cs
@@ -25,94 +25,80 @@
*/
using System;
-using System.Net;
-using System.Net.Http;
-using System.Net.Http.Headers;
+using System.Security.Claims;
using System.Security.Principal;
+using System.Text.Encodings.Web;
using System.Threading;
using System.Threading.Tasks;
-using System.Web.Http.Filters;
-using System.Web.Http.Results;
+using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Http.Extensions;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
using NLog;
-namespace CCM.WebCommon.Authentication
+namespace CCM.Core.Authentication
{
///
/// Based on code from
/// http://www.asp.net/web-api/overview/security/authentication-filters
/// >
- public abstract class BasicAuthenticationAttributeBase : Attribute, IAuthenticationFilter
+ //public abstract class BasicAuthenticationAttributeBase : Attribute, IAuthenticationFilter
+ public abstract class BasicAuthenticationAttributeBase : AuthenticationHandler
{
protected static readonly Logger log = LogManager.GetCurrentClassLogger();
- public bool AllowMultiple => false;
+ public BasicAuthenticationAttributeBase(
+ IOptionsMonitor options,
+ ILoggerFactory logger,
+ UrlEncoder encoder,
+ ISystemClock clock)
+ : base(options, logger, encoder, clock)
+ {
+ }
- public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken)
+ protected override async Task HandleAuthenticateAsync()
{
- HttpRequestMessage request = context.Request;
- AuthenticationHeaderValue authorization = request.Headers.Authorization;
+ var authReqHeader = (string)Request.Headers["Authorization"];
- if (authorization == null)
+ if (!string.IsNullOrEmpty(authReqHeader))
{
// No authentication was attempted (for this authentication method).
// Do not set either Principal (which would indicate success) or ErrorResult (indicating an error).
- log.Debug("No authentication header in request for {0}", request.RequestUri);
- return;
+ log.Debug("No authentication header in request for {0}", new Uri(Request.GetDisplayUrl()).ToString());
+ return AuthenticateResult.Fail("Missing authorization header");
}
- if (authorization.Scheme != AuthenticationSchemes.Basic.ToString())
+ if (authReqHeader != null && !authReqHeader.StartsWith("basic", StringComparison.OrdinalIgnoreCase))
{
// No authentication was attempted (for this authentication method).
// Do not set either Principal (which would indicate success) or ErrorResult (indicating an error).
- log.Debug("Not a Basic authentication header in request for {0}", request.RequestUri);
- return;
+ log.Debug("Not a Basic authentication header in request for {0}", new Uri(Request.GetDisplayUrl()).ToString());
+ return AuthenticateResult.Fail("Not using basic authorization scheme");
}
- if (string.IsNullOrEmpty(authorization.Parameter))
- {
- // Authentication was attempted but failed. Set ErrorResult to indicate an error.
- log.Debug("Missing authentication credentials in request for {0}", request.RequestUri);
- context.ErrorResult = new AuthenticationFailureResult("Missing credentials", request, HttpStatusCode.BadRequest);
- return;
- }
-
- Credentials credentials = BasicAuthenticationHelper.ParseCredentials(authorization.Parameter);
- if (credentials == null)
+ AuthenticationCredentials authenticationCredentials = BasicAuthenticationHelper.ParseCredentials(authReqHeader);
+ if (authenticationCredentials == null)
{
// Authentication was attempted but failed. Set ErrorResult to indicate an error.
- log.Debug("No username and password in request for {0}", request.RequestUri);
- context.ErrorResult = new AuthenticationFailureResult("Invalid credentials", request, HttpStatusCode.BadRequest);
- return;
+ log.Debug("No username and password in request for {0}", new Uri(Request.GetDisplayUrl()).ToString());
+ return AuthenticateResult.Fail("Missing or invalid credentials");
}
- try
- {
- IPrincipal principal = await AuthenticateAsync(credentials.Username, credentials.Password, cancellationToken);
-
- if (principal == null)
- {
- // Authentication was attempted but failed. Set ErrorResult to indicate an error.
- log.Debug("Invalid username ({0}) or password in request for {1}, Req From: {2}, Req Host: {3}", credentials.Username, request.RequestUri, request.Headers.From, request.Headers.Host);
- context.ErrorResult = new AuthenticationFailureResult("Invalid username or password", request);
- return;
- }
+ // Setting up some claims
+ // TODO: See if things are actually still forwarded
+ var claims = new[] {
+ new Claim(ClaimTypes.Role, "Discovery endpoint verified"),
+ new Claim(ClaimTypes.NameIdentifier, authenticationCredentials.Username),
+ };
+ var identity = new ClaimsIdentity(claims, Scheme.Name);
+ // Claims principal, an array of Claim Identities or Claims (Many authorities can say how you are)
+ var principal = new ClaimsPrincipal(identity);
+ var ticket = new AuthenticationTicket(principal, Scheme.Name);
- // Authentication succeeded.
- context.Principal = principal;
- }
- catch (Exception ex)
- {
- log.Error(ex, $"Error in BasicAuthenticationAttribute on request to {request.RequestUri}");
- context.ErrorResult = new InternalServerErrorResult(request);
- }
+ return AuthenticateResult.Success(ticket);
}
protected abstract Task AuthenticateAsync(string userName, string password, CancellationToken cancellationToken);
-
- public Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken)
- {
- return Task.FromResult(0);
- }
}
}
diff --git a/CCM.WebCommon/Authentication/BasicAuthenticationHelper.cs b/CCM.Core/Authentication/BasicAuthenticationHelper.cs
similarity index 87%
rename from CCM.WebCommon/Authentication/BasicAuthenticationHelper.cs
rename to CCM.Core/Authentication/BasicAuthenticationHelper.cs
index 2d34b7b9..8dd73c30 100644
--- a/CCM.WebCommon/Authentication/BasicAuthenticationHelper.cs
+++ b/CCM.Core/Authentication/BasicAuthenticationHelper.cs
@@ -25,22 +25,28 @@
*/
using System;
+using System.Diagnostics;
using System.Text;
-namespace CCM.WebCommon.Authentication
+namespace CCM.Core.Authentication
{
public static class BasicAuthenticationHelper
{
- public static Credentials ParseCredentials(string authorizationString)
+ public static AuthenticationCredentials ParseCredentials(string authorizationString)
{
- byte[] credentialBytes;
+ if (String.IsNullOrEmpty(authorizationString))
+ {
+ return null;
+ }
+ byte[] credentialBytes;
try
{
credentialBytes = Convert.FromBase64String(authorizationString);
}
- catch (FormatException)
+ catch (Exception ex)
{
+ Debug.WriteLine(ex);
return null;
}
@@ -75,7 +81,7 @@ public static Credentials ParseCredentials(string authorizationString)
return null;
}
- return new Credentials() { Username = credentials[0], Password = credentials[1] };
+ return new AuthenticationCredentials() { Username = credentials[0], Password = credentials[1] };
}
}
}
diff --git a/CCM.Core/CCM.Core.csproj b/CCM.Core/CCM.Core.csproj
index e246d148..f6c198e7 100644
--- a/CCM.Core/CCM.Core.csproj
+++ b/CCM.Core/CCM.Core.csproj
@@ -1,291 +1,37 @@
-
-
-
+
+
- Debug
- AnyCPU
- {2B04CC56-7DFE-40F0-BA17-21D8B93E0B75}
- Library
- Properties
- CCM.Core
- CCM.Core
- v4.6.2
- 512
- ..\
- true
- 3e12f533
-
+ netstandard2.1
+ 8.0
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- bin\ReleaseRed\
- TRACE
- true
- pdbonly
- AnyCPU
- prompt
- MinimumRecommendedRules.ruleset
-
-
- bin\ReleaseUtv\
- TRACE
- true
- pdbonly
- AnyCPU
- prompt
- MinimumRecommendedRules.ruleset
-
-
- bin\Production\
-
-
-
- ..\packages\AutoMapper.6.2.2\lib\net45\AutoMapper.dll
-
-
- ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll
-
-
- ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll
-
-
- ..\packages\LazyCache.0.7.1.44\lib\net45\LazyCache.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Identity.Core.1.0.0\lib\net45\Microsoft.AspNet.Identity.Core.dll
- True
-
-
- ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
-
-
- False
- ..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll
-
-
- ..\packages\NLog.4.5.3\lib\net45\NLog.dll
-
-
-
-
-
-
-
-
-
-
- ..\packages\Microsoft.AspNet.WebApi.Client.5.2.4\lib\net45\System.Net.Http.Formatting.dll
-
-
- ..\packages\IPNetwork2.2.0.3\lib\net40\System.Net.IPNetwork.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Code
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
ResXFileCodeGenerator
Resources.Designer.cs
-
-
-
-
-
\ No newline at end of file
+
+
+
+ Resources.resx
+ True
+ True
+
+
+
+
diff --git a/CCM.Core/Cache/CachedCallHistoryRepository.cs b/CCM.Core/Cache/CachedCallHistoryRepository.cs
index db8097d0..b7ceda11 100644
--- a/CCM.Core/Cache/CachedCallHistoryRepository.cs
+++ b/CCM.Core/Cache/CachedCallHistoryRepository.cs
@@ -26,22 +26,29 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
namespace CCM.Core.Cache
{
- public class CachedCallHistoryRepository : ICallHistoryRepository
+ public class CachedCallHistoryRepository : ICachedCallHistoryRepository
{
private readonly ICallHistoryRepository _internalRepository;
private readonly IAppCache _lazyCache;
+ private readonly ISettingsManager _settingsManager;
- public CachedCallHistoryRepository(IAppCache cache, ICallHistoryRepository internalRepository)
+ public CachedCallHistoryRepository(
+ IAppCache cache,
+ ICallHistoryRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = cache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public bool Save(CallHistory callHistory)
@@ -58,44 +65,126 @@ public CallHistory GetById(Guid id)
public CallHistory GetCallHistoryByCallId(Guid callId)
{
- return _internalRepository.GetCallHistoryByCallId(callId);
+ try
+ {
+ var history = _lazyCache.GetOrAddCallHistories(() => _internalRepository.GetOneMonthCallHistories(), _settingsManager.CacheTimeLiveData);
+ return history?.FirstOrDefault(c => c.CallId == callId);
+ }
+ catch (Exception)
+ {
+ return null;
+ }
}
- public IList GetOldCalls(int callCount, bool anonymize)
+ public IList GetOldCalls(int callCount = 0)
{
- return _lazyCache.GetOrAddCallHistory(() => _internalRepository.GetOldCalls(callCount, anonymize));
+ var history = _lazyCache.GetOrAddOldCalls(() => _internalRepository.GetOneMonthOldCalls(), _settingsManager.CacheTimeLiveData);
+ return history.Take(callCount).ToList();
}
- public IList GetOldCallsFiltered(string region, string codecType, string sipAddress, string searchString, bool anonymize, bool onlyPhoneCalls, int callCount)
+ public IList GetOldCallsFiltered(string region, string codecType, string sipAddress, string searchString, bool onlyPhoneCalls, int callCount, bool limitByMonth)
{
- return _internalRepository.GetOldCallsFiltered(region, codecType, sipAddress, searchString, anonymize,
- onlyPhoneCalls, callCount);
+ var oldCalls = _lazyCache.GetOrAddOldCalls(() => _internalRepository.GetOneMonthOldCalls(), _settingsManager.CacheTimeLiveData).AsEnumerable();
+ if (oldCalls == null)
+ {
+ return null;
+ }
+
+ if (!string.IsNullOrEmpty(region))
+ {
+ oldCalls = oldCalls.Where(ch => ch.FromRegionName == region || ch.ToRegionName == region);
+ }
+
+ if (!string.IsNullOrEmpty(codecType))
+ {
+ oldCalls = oldCalls.Where(ch => ch.FromCodecTypeName == codecType || ch.ToCodecTypeName == codecType);
+ }
+
+ if (!string.IsNullOrEmpty(sipAddress))
+ {
+ oldCalls = oldCalls.Where(ch => ch.FromSip.Contains(sipAddress) || ch.ToSip.Contains(sipAddress));
+ }
+
+ if (onlyPhoneCalls)
+ {
+ oldCalls = oldCalls.Where(ch => ch.IsPhoneCall);
+ }
+
+ if (!string.IsNullOrEmpty(searchString))
+ {
+ searchString = searchString.ToLower();
+ oldCalls = oldCalls.Where(ch =>
+ ch.FromDisplayName.ToLower().Contains(searchString) ||
+ ch.ToDisplayName.ToLower().Contains(searchString) ||
+ ch.FromSip.Contains(searchString) ||
+ ch.ToSip.Contains(searchString) ||
+ ch.FromLocationName.Contains(searchString) ||
+ ch.ToLocationName.Contains(searchString) ||
+ ch.FromLocationShortName.Contains(searchString) ||
+ ch.ToLocationShortName.Contains(searchString)
+ );
+ }
+
+ if (limitByMonth)
+ {
+ var monthLimit = DateTime.Today.AddMonths(-1);
+ oldCalls = oldCalls.Where(ch => ch.Ended >= monthLimit);
+ }
+
+ var calls = oldCalls.OrderByDescending(callHistory => callHistory.Ended).Take(callCount).ToList();
+ return calls;
}
- public IList GetCallHistoriesByDate(DateTime startTime, DateTime endTime)
+ #region Statistics
+ private IReadOnlyList GetOneYearCallHistory()
{
- return _internalRepository.GetCallHistoriesByDate(startTime, endTime);
+ return _lazyCache.GetOrAddOneYearCallHistory(() => _internalRepository.GetOneYearCallHistory(), _settingsManager.CacheTimeLiveData);
+ }
+
+ public IList GetCallHistoriesByDate(DateTime startDate, DateTime endDate)
+ {
+ if (startDate > DateTime.Now.AddYears(-1))
+ {
+ return _internalRepository.GetCallHistoriesByDate(GetOneYearCallHistory(), startDate, endDate);
+ }
+ return _internalRepository.GetCallHistoriesByDate(startDate, endDate);
}
public IList GetCallHistoriesForRegion(DateTime startDate, DateTime endDate, Guid regionId)
{
+ if (startDate > DateTime.Now.AddYears(-1))
+ {
+ return _internalRepository.GetCallHistoriesForRegion(GetOneYearCallHistory(), startDate, endDate, regionId);
+ }
return _internalRepository.GetCallHistoriesForRegion(startDate, endDate, regionId);
}
public IList GetCallHistoriesForRegisteredSip(DateTime startDate, DateTime endDate, string sipId)
{
+ if (startDate > DateTime.Now.AddYears(-1))
+ {
+ return _internalRepository.GetCallHistoriesForRegisteredSip(GetOneYearCallHistory(), startDate, endDate, sipId);
+ }
return _internalRepository.GetCallHistoriesForRegisteredSip(startDate, endDate, sipId);
}
public IList GetCallHistoriesForCodecType(DateTime startDate, DateTime endDate, Guid codecTypeId)
{
+ if (startDate > DateTime.Now.AddYears(-1))
+ {
+ return _internalRepository.GetCallHistoriesForCodecType(GetOneYearCallHistory(), startDate, endDate, codecTypeId);
+ }
return _internalRepository.GetCallHistoriesForCodecType(startDate, endDate, codecTypeId);
}
public IList GetCallHistoriesForLocation(DateTime startDate, DateTime endDate, Guid locationId)
{
+ if (startDate > DateTime.Now.AddYears(-1))
+ {
+ return _internalRepository.GetCallHistoriesForLocation(GetOneYearCallHistory(), startDate, endDate, locationId);
+ }
return _internalRepository.GetCallHistoriesForLocation(startDate, endDate, locationId);
}
-
+ #endregion Statistics
}
}
diff --git a/CCM.Core/Cache/CachedCallRepository.cs b/CCM.Core/Cache/CachedCallRepository.cs
index 238ab609..3bb4aa1c 100644
--- a/CCM.Core/Cache/CachedCallRepository.cs
+++ b/CCM.Core/Cache/CachedCallRepository.cs
@@ -28,26 +28,36 @@
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
namespace CCM.Core.Cache
{
- public class CachedCallRepository : ICallRepository
+ public class CachedCallRepository : ICachedCallRepository
{
private readonly ICallRepository _internalRepository;
private readonly IAppCache _lazyCache;
+ private readonly ISettingsManager _settingsManager;
- public CachedCallRepository(IAppCache cache, ICallRepository internalRepository)
+ public CachedCallRepository(
+ IAppCache cache,
+ ICallRepository internalRepository,
+ ISettingsManager settingsManager)
{
- // TODO: Use cache call on the other queries
_lazyCache = cache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public IReadOnlyCollection GetOngoingCalls(bool anonymize)
{
- return _lazyCache.GetOrAddOngoingCalls(() => _internalRepository.GetOngoingCalls(anonymize));
+ return _lazyCache.GetOrAddOngoingCalls(() => _internalRepository.GetOngoingCalls(anonymize), _settingsManager.CacheTimeLiveData);
+ }
+
+ public OnGoingCall GetOngoingCallById(Guid callId)
+ {
+ return _internalRepository.GetOngoingCallById(callId);
}
public bool CallExists(string callId, string hashId, string hashEnt)
@@ -81,6 +91,5 @@ public void CloseCall(Guid callId)
_internalRepository.CloseCall(callId);
_lazyCache.ClearOngoingCalls();
}
-
}
}
diff --git a/CCM.Core/Cache/CachedLocationRepository.cs b/CCM.Core/Cache/CachedLocationRepository.cs
index 70e1831b..b874e726 100644
--- a/CCM.Core/Cache/CachedLocationRepository.cs
+++ b/CCM.Core/Cache/CachedLocationRepository.cs
@@ -28,20 +28,26 @@
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
namespace CCM.Core.Cache
{
- public class CachedLocationRepository : ILocationRepository
+ public class CachedLocationRepository : ICachedLocationRepository
{
private readonly IAppCache _lazyCache;
private readonly ILocationRepository _internalRepository;
+ private readonly ISettingsManager _settingsManager;
- public CachedLocationRepository(IAppCache lazyCache, ILocationRepository internalRepository)
+ public CachedLocationRepository(
+ IAppCache lazyCache,
+ ILocationRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = lazyCache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public Location GetById(Guid id)
@@ -73,12 +79,17 @@ public void Delete(Guid id)
public List GetAllLocationNetworks()
{
- return _lazyCache.GetOrAddLocationNetworks(() => _internalRepository.GetAllLocationNetworks());
+ return _lazyCache.GetOrAddLocationNetworks(() => _internalRepository.GetAllLocationNetworks(), _settingsManager.CacheTimeConfigData);
}
public Dictionary GetLocationsAndProfiles()
{
- return _lazyCache.GetOrAddLocationsAndProfiles(() => _internalRepository.GetLocationsAndProfiles());
+ return _lazyCache.GetOrAddLocationsAndProfiles(() => _internalRepository.GetLocationsAndProfiles(), _settingsManager.CacheTimeConfigData);
+ }
+
+ public List GetAllLocationInfo()
+ {
+ return _lazyCache.GetOrAddLocationsInfo(() => _internalRepository.GetAllLocationInfo(), _settingsManager.CacheTimeConfigData);
}
}
}
diff --git a/CCM.Core/Cache/CachedProfileGroupRepository.cs b/CCM.Core/Cache/CachedProfileGroupRepository.cs
index a1b5f5b3..b0dd4ec7 100644
--- a/CCM.Core/Cache/CachedProfileGroupRepository.cs
+++ b/CCM.Core/Cache/CachedProfileGroupRepository.cs
@@ -27,20 +27,26 @@
using System;
using System.Collections.Generic;
using CCM.Core.Entities;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
namespace CCM.Core.Cache
{
- public class CachedProfileGroupRepository : IProfileGroupRepository
+ public class CachedProfileGroupRepository : ICachedProfileGroupRepository
{
private readonly IAppCache _lazyCache;
private readonly IProfileGroupRepository _internalRepository;
+ private readonly ISettingsManager _settingsManager;
- public CachedProfileGroupRepository(IAppCache lazyCache, IProfileGroupRepository internalRepository)
+ public CachedProfileGroupRepository(
+ IAppCache lazyCache,
+ IProfileGroupRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = lazyCache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public ProfileGroup GetById(Guid id)
@@ -50,24 +56,23 @@ public ProfileGroup GetById(Guid id)
public List GetAll()
{
- return _lazyCache.GetOrAddProfileGroups(() => _internalRepository.GetAll());
+ return _lazyCache.GetOrAddProfileGroups(() => _internalRepository.GetAll(), _settingsManager.CacheTimeConfigData);
}
- public void Save(ProfileGroup location)
+ public List FindProfileGroups(string search)
{
- _internalRepository.Save(location);
- _lazyCache.ClearProfileGroups();
+ return _internalRepository.FindProfileGroups(search);
}
- public void Delete(Guid id)
+ public void Save(ProfileGroup profileGroup)
{
- _internalRepository.Delete(id);
+ _internalRepository.Save(profileGroup);
_lazyCache.ClearProfileGroups();
}
- public void SetProfileGroupSortWeight(IList> profileGroupTuples)
+ public void Delete(Guid id)
{
- _internalRepository.SetProfileGroupSortWeight(profileGroupTuples);
+ _internalRepository.Delete(id);
_lazyCache.ClearProfileGroups();
}
}
diff --git a/CCM.Core/Cache/CachedProfileRepository.cs b/CCM.Core/Cache/CachedProfileRepository.cs
index f06d00e1..8f2bb98c 100644
--- a/CCM.Core/Cache/CachedProfileRepository.cs
+++ b/CCM.Core/Cache/CachedProfileRepository.cs
@@ -28,33 +28,39 @@
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
namespace CCM.Core.Cache
{
- public class CachedProfileRepository : IProfileRepository
+ public class CachedProfileRepository : ICachedProfileRepository
{
private readonly IAppCache _lazyCache;
private readonly IProfileRepository _internalRepository;
+ private readonly ISettingsManager _settingsManager;
- public CachedProfileRepository(IAppCache lazyCache, IProfileRepository internalRepository)
+ public CachedProfileRepository(
+ IAppCache lazyCache,
+ IProfileRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = lazyCache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
- public Profile GetById(Guid id)
+ public ProfileCodec GetById(Guid id)
{
return _internalRepository.GetById(id);
}
- public List GetAll()
+ public List GetAll()
{
return _internalRepository.GetAll();
}
- public void Save(Profile profile)
+ public void Save(ProfileCodec profile)
{
_internalRepository.Save(profile);
_lazyCache.ClearProfiles();
@@ -66,14 +72,14 @@ public void Delete(Guid id)
_lazyCache.ClearProfiles();
}
- public List FindProfiles(string searchString)
+ public List FindProfiles(string searchString)
{
return _internalRepository.FindProfiles(searchString);
}
public IList GetAllProfileNamesAndSdp()
{
- return _lazyCache.GetOrAddAllProfileNamesAndSdp(() => _internalRepository.GetAllProfileNamesAndSdp());
+ return _lazyCache.GetOrAddAllProfileNamesAndSdp(() => _internalRepository.GetAllProfileNamesAndSdp(), _settingsManager.CacheTimeConfigData);
}
public IList GetAllProfileInfos()
@@ -81,11 +87,9 @@ public IList GetAllProfileInfos()
return _internalRepository.GetAllProfileInfos();
}
- public void SetProfileSortIndex(IList> profileTuples)
+ public IReadOnlyCollection GetFullDetails()
{
- _internalRepository.SetProfileSortIndex(profileTuples);
- _lazyCache.ClearProfiles();
+ return _lazyCache.GetOrAddFullDetailProfiles(() => _internalRepository.GetFullDetails(), _settingsManager.CacheTimeConfigData);
}
-
}
}
diff --git a/CCM.Core/Cache/CachedRegisteredSipRepository.cs b/CCM.Core/Cache/CachedRegisteredCodecRepository.cs
similarity index 77%
rename from CCM.Core/Cache/CachedRegisteredSipRepository.cs
rename to CCM.Core/Cache/CachedRegisteredCodecRepository.cs
index 20b96b04..5a3aa734 100644
--- a/CCM.Core/Cache/CachedRegisteredSipRepository.cs
+++ b/CCM.Core/Cache/CachedRegisteredCodecRepository.cs
@@ -26,48 +26,49 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using CCM.Core.Entities;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
using CCM.Core.SipEvent;
+using CCM.Core.SipEvent.Models;
namespace CCM.Core.Cache
{
- public class CachedRegisteredSipRepository : IRegisteredSipRepository
+ public class CachedRegisteredCodecRepository : ICachedRegisteredCodecRepository
{
- private readonly IRegisteredSipRepository _internalRepository;
+ private readonly IRegisteredCodecRepository _internalRepository;
private readonly IAppCache _lazyCache;
+ private readonly ISettingsManager _settingsManager;
- public CachedRegisteredSipRepository(IAppCache cache, IRegisteredSipRepository internalRepository)
+ public CachedRegisteredCodecRepository(
+ IAppCache cache,
+ IRegisteredCodecRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = cache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public IEnumerable GetRegisteredUserAgentsDiscovery()
{
- return _lazyCache.GetOrAddRegisteredUserAgentsDiscovery(() => _internalRepository.GetRegisteredUserAgentsDiscovery());
+ return _lazyCache.GetOrAddRegisteredUserAgentsDiscovery(() => _internalRepository.GetRegisteredUserAgentsDiscovery(), _settingsManager.CacheTimeLiveData);
}
public IEnumerable GetRegisteredUserAgents()
{
- return _lazyCache.GetOrAddRegisteredUserAgents(() => _internalRepository.GetRegisteredUserAgents());
+ return _lazyCache.GetOrAddRegisteredUserAgents(() => _internalRepository.GetRegisteredUserAgents(), _settingsManager.CacheTimeLiveData);
}
public SipEventHandlerResult UpdateRegisteredSip(UserAgentRegistration userAgentRegistration)
{
var result = _internalRepository.UpdateRegisteredSip(userAgentRegistration);
- // When reregistration of codec already in cache, just update timestamp
+ // When reregistration of codec already in cache
if (result.ChangeStatus == SipEventChangeStatus.NothingChanged && result.ChangedObjectId != Guid.Empty)
{
- // TODO: When GetRegisteredSips is gone, decide over this
- //var regSip = GetRegisteredSips().FirstOrDefault(rs => rs.Id == result.ChangedObjectId);
- //if (regSip != null)
- //{
- // regSip.Updated = DateTime.UtcNow;
- // return result;
- //}
return result;
}
@@ -90,8 +91,12 @@ public SipEventHandlerResult DeleteRegisteredSip(string sipAddress)
public IEnumerable GetRegisteredUserAgentsCodecInformation()
{
- return _lazyCache.GetOrAddRegisteredUserAgentsCodecInformation(() => _internalRepository.GetRegisteredUserAgentsCodecInformation());
+ return _lazyCache.GetOrAddRegisteredUserAgentsCodecInformation(() => _internalRepository.GetRegisteredUserAgentsCodecInformation(), _settingsManager.CacheTimeLiveData);
}
+ public IEnumerable GetRegisteredCodecsUpdateTimes()
+ {
+ return _internalRepository.GetRegisteredCodecsUpdateTimes();
+ }
}
}
diff --git a/CCM.Core/Cache/CachedSettingsRepository.cs b/CCM.Core/Cache/CachedSettingsRepository.cs
index 137d4702..d308bc09 100644
--- a/CCM.Core/Cache/CachedSettingsRepository.cs
+++ b/CCM.Core/Cache/CachedSettingsRepository.cs
@@ -31,7 +31,7 @@
namespace CCM.Core.Cache
{
- public class CachedSettingsRepository : ISettingsRepository
+ public class CachedSettingsRepository : ICachedSettingsRepository
{
private readonly ISettingsRepository _internalRepository;
private readonly IAppCache _lazyCache;
diff --git a/CCM.Core/Cache/CachedSipAccountRepository.cs b/CCM.Core/Cache/CachedSipAccountRepository.cs
index bd23beb0..658c6756 100644
--- a/CCM.Core/Cache/CachedSipAccountRepository.cs
+++ b/CCM.Core/Cache/CachedSipAccountRepository.cs
@@ -26,22 +26,29 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using CCM.Core.Entities;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
using System.Threading.Tasks;
+using CCM.Core.Interfaces.Managers;
namespace CCM.Core.Cache
{
- public class CachedSipAccountRepository : ISipAccountRepository
+ public class CachedSipAccountRepository : ICachedSipAccountRepository
{
private readonly ISipAccountRepository _internalRepository;
private readonly IAppCache _lazyCache;
+ private readonly ISettingsManager _settingsManager;
- public CachedSipAccountRepository(IAppCache cache, ISipAccountRepository internalRepository)
+ public CachedSipAccountRepository(
+ IAppCache cache,
+ ISipAccountRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = cache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public SipAccount GetById(Guid id)
@@ -56,17 +63,19 @@ public SipAccount GetByRegisteredSipId(Guid registeredSipId)
public SipAccount GetByUserName(string userName)
{
+ // TODO: XXXX Is already????
return _internalRepository.GetByUserName(userName);
}
- public List GetAllIncludingRelations()
+ public SipAccount GetSipAccountByUserName(string username)
{
- return _internalRepository.GetAllIncludingRelations();
+ // TODO: XXXX Is already????
+ return GetAll().FirstOrDefault(u => u.UserName.ToLower() == username);
}
public List GetAll()
{
- return _lazyCache.GetOrAddSipAccounts(() => _internalRepository.GetAll());
+ return _lazyCache.GetOrAddSipAccounts(() => _internalRepository.GetAll(), _settingsManager.CacheTimeConfigData);
}
public List Find(string startsWith)
@@ -74,6 +83,11 @@ public List Find(string startsWith)
return _internalRepository.Find(startsWith);
}
+ public void Save(SipAccount ccmUser)
+ {
+ _internalRepository.Save(ccmUser);
+ }
+
public void Create(SipAccount ccmUser)
{
_internalRepository.Create(ccmUser);
@@ -92,6 +106,13 @@ public void UpdateComment(Guid id, string comment)
// TODO: Maybe this needs to clear more things? like registeredUserAgents
}
+ public void UpdateSipAccountQuick(Guid id, string presentationName, string externalReference)
+ {
+ _internalRepository.UpdateSipAccountQuick(id, presentationName, externalReference);
+ _lazyCache.ClearSipAccounts();
+ // TODO: Maybe this needs to clear more things? like registeredUserAgents
+ }
+
public void UpdatePassword(Guid id, string password)
{
_internalRepository.UpdatePassword(id, password);
@@ -108,6 +129,5 @@ public Task AuthenticateAsync(string username, string password)
{
return _internalRepository.AuthenticateAsync(username, password);
}
-
}
}
diff --git a/CCM.Core/Cache/CachedUserAgentRepository.cs b/CCM.Core/Cache/CachedUserAgentRepository.cs
index a88668ef..ea3083ef 100644
--- a/CCM.Core/Cache/CachedUserAgentRepository.cs
+++ b/CCM.Core/Cache/CachedUserAgentRepository.cs
@@ -27,20 +27,26 @@
using System;
using System.Collections.Generic;
using CCM.Core.Entities;
+using CCM.Core.Interfaces.Managers;
using CCM.Core.Interfaces.Repositories;
using LazyCache;
namespace CCM.Core.Cache
{
- public class CachedUserAgentRepository : IUserAgentRepository
+ public class CachedUserAgentRepository : ICachedUserAgentRepository
{
private readonly IUserAgentRepository _internalRepository;
private readonly IAppCache _lazyCache;
+ private readonly ISettingsManager _settingsManager;
- public CachedUserAgentRepository(IAppCache cache, IUserAgentRepository internalRepository)
+ public CachedUserAgentRepository(
+ IAppCache cache,
+ IUserAgentRepository internalRepository,
+ ISettingsManager settingsManager)
{
_lazyCache = cache;
_internalRepository = internalRepository;
+ _settingsManager = settingsManager;
}
public void Save(UserAgent userAgent)
@@ -60,12 +66,12 @@ public UserAgent GetById(Guid id)
public List GetAll()
{
- return _lazyCache.GetOrAddUserAgents(() => _internalRepository.GetAll());
+ return _lazyCache.GetOrAddUserAgents(() => _internalRepository.GetAll(), _settingsManager.CacheTimeConfigData);
}
public Dictionary GetUserAgentsTypesAndProfiles()
{
- return _lazyCache.GetOrAddUserAgentsAndProfiles(() => _internalRepository.GetUserAgentsTypesAndProfiles());
+ return _lazyCache.GetOrAddUserAgentsAndProfiles(() => _internalRepository.GetUserAgentsTypesAndProfiles(), _settingsManager.CacheTimeConfigData);
}
public List Find(string search)
diff --git a/CCM.Core/Cache/LazyCacheExtensions.cs b/CCM.Core/Cache/LazyCacheExtensions.cs
index 8b173b7f..f86be2b5 100644
--- a/CCM.Core/Cache/LazyCacheExtensions.cs
+++ b/CCM.Core/Cache/LazyCacheExtensions.cs
@@ -28,7 +28,6 @@
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
-using CCM.Core.Helpers;
using LazyCache;
using NLog;
@@ -36,41 +35,32 @@ namespace CCM.Core.Cache
{
public static class LazyCacheExtensions
{
- // Cache time in seconds
- public static int CacheTimeLiveData = ApplicationSettings.CacheTimeLiveData;
-
- public static int CacheTimeFilter = ApplicationSettings.CacheTimeConfigData;
- public static int CacheTimeProfiles = ApplicationSettings.CacheTimeConfigData;
- public static int CacheTimeProfileGroups = ApplicationSettings.CacheTimeConfigData;
- public static int CacheTimeLocations = ApplicationSettings.CacheTimeConfigData;
- public static int CacheTimeUserAgents = ApplicationSettings.CacheTimeConfigData;
- public static int CacheTimeUserAgentsAndProfiles = ApplicationSettings.CacheTimeConfigData;
- public static int CacheTimeSipAccounts = ApplicationSettings.CacheTimeConfigData;
-
// Cache keys
private const string RegisteredUserAgentsDiscoveryKey = "RegisteredUserAgentsDiscovery";
private const string RegisteredUserAgentsCodecInformationKey = "RegisteredUserAgentsCodecInformation";
private const string RegisteredUserAgentsKey = "RegisteredUserAgents";
private const string OngoingCallsKey = "OngoingCalls";
private const string CallHistoryKey = "CallHistory";
+ private const string OldCallHistoryKey = "OldCallHistory";
+ private const string OneYearCallHistoryKey = "OneYearCallHistory";
private const string SettingsKey = "Settings";
private const string LocationNetworksKey = "LocationNetworks";
private const string LocationsAndProfilesKey = "LocationsAndProfiles";
+ private const string LocationsInfoKey = "LocationsInfoKey";
private const string AvailableFiltersKey = "AvailableFilters";
private const string AllProfileNamesAndSdpKey = "AllProfileNamesAndSdp";
private const string ProfileGroupsKey = "ProfileGroups";
+ private const string FullDetailProfilesKey = "FullDetailProfilesKey";
private const string UserAgentsKey = "UserAgents";
private const string UserAgentsAndProfilesKey = "UserAgentsAndProfiles";
private const string SipAccountsKey = "SipAccounts";
private static readonly Logger log = LogManager.GetCurrentClassLogger();
- // TODO: Make some decisions on how we deal with replication changes that doesn't trigger a reload of cache if this instance was not the one saving changes.
-
#region SipAccounts
- public static List GetOrAddSipAccounts(this IAppCache cache, Func> sipAccountsLoader)
+ public static List GetOrAddSipAccounts(this IAppCache cache, Func> sipAccountsLoader, int cacheTimeSipAccounts)
{
- return cache.GetOrAdd(SipAccountsKey, sipAccountsLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeSipAccounts));
+ return cache.GetOrAdd(SipAccountsKey, sipAccountsLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeSipAccounts));
}
public static void ClearSipAccounts(this IAppCache cache)
@@ -81,19 +71,19 @@ public static void ClearSipAccounts(this IAppCache cache)
#endregion
#region RegisteredUserAgents
- public static IEnumerable GetOrAddRegisteredUserAgents(this IAppCache cache, Func> registeredUserAgentsLoader)
+ public static IEnumerable GetOrAddRegisteredUserAgents(this IAppCache cache, Func> registeredUserAgentsLoader, int cacheTimeLiveData)
{
- return cache.GetOrAdd(RegisteredUserAgentsKey, registeredUserAgentsLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLiveData));
+ return cache.GetOrAdd(RegisteredUserAgentsKey, registeredUserAgentsLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
}
- public static IEnumerable GetOrAddRegisteredUserAgentsDiscovery(this IAppCache cache, Func> registeredUserAgentsDiscoveryLoader)
+ public static IEnumerable GetOrAddRegisteredUserAgentsDiscovery(this IAppCache cache, Func> registeredUserAgentsDiscoveryLoader, int cacheTimeLiveData)
{
- return cache.GetOrAdd(RegisteredUserAgentsDiscoveryKey, registeredUserAgentsDiscoveryLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLiveData));
+ return cache.GetOrAdd(RegisteredUserAgentsDiscoveryKey, registeredUserAgentsDiscoveryLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
}
- public static IEnumerable GetOrAddRegisteredUserAgentsCodecInformation(this IAppCache cache, Func> registeredUserAgentsCodecInformationLoader)
+ public static IEnumerable GetOrAddRegisteredUserAgentsCodecInformation(this IAppCache cache, Func> registeredUserAgentsCodecInformationLoader, int cacheTimeLiveData)
{
- return cache.GetOrAdd(RegisteredUserAgentsCodecInformationKey, registeredUserAgentsCodecInformationLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLiveData));
+ return cache.GetOrAdd(RegisteredUserAgentsCodecInformationKey, registeredUserAgentsCodecInformationLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
}
public static void ClearRegisteredUserAgents(this IAppCache cache)
@@ -110,9 +100,9 @@ public static void ClearRegisteredUserAgents(this IAppCache cache)
#endregion
#region OngoingCalls
- public static IReadOnlyCollection GetOrAddOngoingCalls(this IAppCache cache, Func> ongoingCallsLoader)
+ public static IReadOnlyCollection GetOrAddOngoingCalls(this IAppCache cache, Func> ongoingCallsLoader, int cacheTimeLiveData)
{
- return cache.GetOrAdd(OngoingCallsKey, ongoingCallsLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLiveData));
+ return cache.GetOrAdd(OngoingCallsKey, ongoingCallsLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
}
public static void ClearOngoingCalls(this IAppCache cache)
@@ -123,15 +113,27 @@ public static void ClearOngoingCalls(this IAppCache cache)
#endregion
#region CallHistory
- public static IList GetOrAddCallHistory(this IAppCache cache, Func> callHistoryLoader)
+ public static IReadOnlyCollection GetOrAddOldCalls(this IAppCache cache, Func> callHistoryLoader, int cacheTimeLiveData)
+ {
+ return cache.GetOrAdd(OldCallHistoryKey, callHistoryLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
+ }
+
+ public static IReadOnlyCollection GetOrAddCallHistories(this IAppCache cache, Func> callHistoryLoader, int cacheTimeLiveData)
+ {
+ return cache.GetOrAdd(CallHistoryKey, callHistoryLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
+ }
+
+ public static IReadOnlyList GetOrAddOneYearCallHistory(this IAppCache cache, Func> oneYearCallHistoryLoader, int cacheTimeLiveData)
{
- return cache.GetOrAdd(CallHistoryKey, callHistoryLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLiveData));
+ return cache.GetOrAdd(OneYearCallHistoryKey, oneYearCallHistoryLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLiveData));
}
public static void ClearCallHistory(this IAppCache cache)
{
log.Debug("Removing call history from cache");
cache.Remove(CallHistoryKey);
+ cache.Remove(OldCallHistoryKey);
+ cache.Remove(OneYearCallHistoryKey);
}
#endregion
@@ -149,15 +151,20 @@ public static void ClearSettings(this IAppCache cache)
#endregion
#region LocationNetworks
- public static List GetOrAddLocationNetworks(this IAppCache cache, Func> loader)
+ public static List GetOrAddLocationNetworks(this IAppCache cache, Func> loader, int cacheTimeLocations)
{
- var list = cache.GetOrAdd(LocationNetworksKey, loader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLocations));
+ var list = cache.GetOrAdd(LocationNetworksKey, loader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLocations));
return list;
}
- public static Dictionary GetOrAddLocationsAndProfiles(this IAppCache cache, Func> loader)
+ public static Dictionary GetOrAddLocationsAndProfiles(this IAppCache cache, Func> loader, int cacheTimeLocations)
{
- return cache.GetOrAdd(LocationsAndProfilesKey, loader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeLocations));
+ return cache.GetOrAdd(LocationsAndProfilesKey, loader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLocations));
+ }
+
+ public static List GetOrAddLocationsInfo(this IAppCache cache, Func> loader, int cacheTimeLocations)
+ {
+ return cache.GetOrAdd(LocationsInfoKey, loader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeLocations));
}
public static void ClearLocationNetworks(this IAppCache cache)
@@ -167,14 +174,17 @@ public static void ClearLocationNetworks(this IAppCache cache)
log.Debug("Removing locations and profiles from cache");
cache.Remove(LocationsAndProfilesKey);
+
+ log.Debug("Removing locations info from cache");
+ cache.Remove(LocationsInfoKey);
}
#endregion
#region AvailableFilters
- public static IList GetAvailableFilters(this IAppCache cache, Func> loader)
+ public static IList GetAvailableFilters(this IAppCache cache, Func> loader, int cacheTimeFilter)
{
// TODO: Should not be called like this?!
- var list = cache.GetOrAdd(AvailableFiltersKey, loader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeFilter));
+ var list = cache.GetOrAdd(AvailableFiltersKey, loader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeFilter));
return list;
}
@@ -186,22 +196,30 @@ public static void ClearAvailableFilters(this IAppCache cache)
#endregion
#region Profiles
- public static IList GetOrAddAllProfileNamesAndSdp(this IAppCache cache, Func> allProfileNamesAndSdpLoader)
+ public static IList GetOrAddAllProfileNamesAndSdp(this IAppCache cache, Func> allProfileNamesAndSdpLoader, int cacheTimeProfiles)
{
- return cache.GetOrAdd(AllProfileNamesAndSdpKey, allProfileNamesAndSdpLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeProfiles));
+ return cache.GetOrAdd(AllProfileNamesAndSdpKey, allProfileNamesAndSdpLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeProfiles));
+ }
+
+ public static IReadOnlyCollection GetOrAddFullDetailProfiles(this IAppCache cache, Func> loader, int cacheTime)
+ {
+ return cache.GetOrAdd(FullDetailProfilesKey, loader, DateTimeOffset.UtcNow.AddSeconds(cacheTime));
}
public static void ClearProfiles(this IAppCache cache)
{
log.Debug("Removing all profile names and sdp from cache");
cache.Remove(AllProfileNamesAndSdpKey);
+
+ log.Debug("Clearing full detail profiles from cache");
+ cache.Remove(FullDetailProfilesKey);
}
#endregion
#region ProfileGroups
- public static List GetOrAddProfileGroups(this IAppCache cache, Func> profileGroupsLoader)
+ public static List GetOrAddProfileGroups(this IAppCache cache, Func> profileGroupsLoader, int cacheTimeProfileGroups)
{
- return cache.GetOrAdd(ProfileGroupsKey, profileGroupsLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeProfileGroups));
+ return cache.GetOrAdd(ProfileGroupsKey, profileGroupsLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeProfileGroups));
}
public static void ClearProfileGroups(this IAppCache cache)
@@ -212,14 +230,14 @@ public static void ClearProfileGroups(this IAppCache cache)
#endregion
#region UserAgent
- public static List GetOrAddUserAgents(this IAppCache cache, Func> userAgentsLoader)
+ public static List GetOrAddUserAgents(this IAppCache cache, Func> userAgentsLoader, int cacheTimeUserAgents)
{
- return cache.GetOrAdd(UserAgentsKey, userAgentsLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeUserAgents));
+ return cache.GetOrAdd(UserAgentsKey, userAgentsLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeUserAgents));
}
- public static Dictionary GetOrAddUserAgentsAndProfiles(this IAppCache cache, Func> userAgentsAndProfilesLoader)
+ public static Dictionary GetOrAddUserAgentsAndProfiles(this IAppCache cache, Func> userAgentsAndProfilesLoader, int cacheTimeUserAgentsAndProfiles)
{
- return cache.GetOrAdd(UserAgentsAndProfilesKey, userAgentsAndProfilesLoader, DateTimeOffset.UtcNow.AddSeconds(CacheTimeUserAgentsAndProfiles));
+ return cache.GetOrAdd(UserAgentsAndProfilesKey, userAgentsAndProfilesLoader, DateTimeOffset.UtcNow.AddSeconds(cacheTimeUserAgentsAndProfiles));
}
public static void ClearUserAgents(this IAppCache cache)
diff --git a/CCM.Core/Entities/Call.cs b/CCM.Core/Entities/Call.cs
index 565c3900..e28f3b17 100644
--- a/CCM.Core/Entities/Call.cs
+++ b/CCM.Core/Entities/Call.cs
@@ -32,28 +32,28 @@ namespace CCM.Core.Entities
{
public class Call : CoreEntityBase
{
- public string CallId { get; set; } // Id from Kamailio
- public string DlgHashId { get; set; }
- public string DlgHashEnt { get; set; }
-
- public Guid FromId { get; set; }
- public RegisteredSip From { get; set; }
- public string FromSip { get; set; }
- public string FromDisplayName { get; set; }
-
- public Guid ToId { get; set; }
- public RegisteredSip To { get; set; }
- public string ToSip { get; set; }
- public string ToDisplayName { get; set; }
-
+ public string CallId { get; set; }
+ public string DialogHashId { get; set; }
+ public string DialogHashEnt { get; set; }
public DateTime Started { get; set; }
public DateTime Updated { get; set; }
-
public SipCallState State { get; set; }
public bool Closed { get; set; }
- public bool IsPhoneCall { get; set; } // True if it's a phone call
+ public bool IsPhoneCall { get; set; }
+ public string SDP { get; set; }
- public string ToTag { get; set; } // TODO: Doesn't seem to be in use
- public string FromTag { get; set; } // TODO: Doesn't seem to be in use
+ public Guid? FromId { get; set; }
+ public CallRegisteredCodec From { get; set; }
+ public string FromSip { get; set; }
+ public string FromDisplayName { get; set; }
+ public string FromTag { get; set; }
+ public string FromCategory { get; set; }
+
+ public Guid? ToId { get; set; }
+ public CallRegisteredCodec To { get; set; }
+ public string ToSip { get; set; }
+ public string ToDisplayName { get; set; }
+ public string ToTag { get; set; }
+ public string ToCategory { get; set; }
}
}
diff --git a/CCM.Core/Entities/CallHistory.cs b/CCM.Core/Entities/CallHistory.cs
index af20e942..f6f32158 100644
--- a/CCM.Core/Entities/CallHistory.cs
+++ b/CCM.Core/Entities/CallHistory.cs
@@ -24,22 +24,23 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
+
namespace CCM.Core.Entities
{
- using System;
-
public class CallHistory
{
public Guid CallHistoryId { get; set; }
public Guid CallId { get; set; }
- public string SipCallId { get; set; }
+ public string DialogCallId { get; set; }
public DateTime Started { get; set; }
public DateTime Ended { get; set; }
- public string DlgHashId { get; set; }
- public string DlgHashEnt { get; set; }
- public string ToTag { get; set; }
- public string FromTag { get; set; }
+ public bool IsPhoneCall { get; set; }
+ public string DialogHashId { get; set; }
+ public string DialogHashEnt { get; set; }
+
public Guid FromId { get; set; }
+ public string FromTag { get; set; }
public string FromSip { get; set; }
public string FromUsername { get; set; }
public string FromDisplayName { get; set; }
@@ -48,15 +49,19 @@ public class CallHistory
public string FromLocationName { get; set; }
public string FromLocationComment { get; set; }
public string FromLocationShortName { get; set; }
+ public string FromLocationCategory { get; set; }
public Guid FromCodecTypeId { get; set; }
public string FromCodecTypeName { get; set; }
public string FromCodecTypeColor { get; set; }
+ public string FromCodecTypeCategory { get; set; }
public Guid FromOwnerId { get; set; }
public string FromOwnerName { get; set; }
public Guid FromRegionId { get; set; }
public string FromRegionName { get; set; }
- public string FromUserAgentHead { get; set; }
+ public string FromUserAgentHeader { get; set; }
+
public Guid ToId { get; set; }
+ public string ToTag { get; set; }
public string ToSip { get; set; }
public string ToUsername { get; set; }
public string ToDisplayName { get; set; }
@@ -65,14 +70,15 @@ public class CallHistory
public string ToLocationName { get; set; }
public string ToLocationComment { get; set; }
public string ToLocationShortName { get; set; }
+ public string ToLocationCategory { get; set; }
public Guid ToCodecTypeId { get; set; }
public string ToCodecTypeName { get; set; }
public string ToCodecTypeColor { get; set; }
+ public string ToCodecTypeCategory { get; set; }
public Guid ToOwnerId { get; set; }
public string ToOwnerName { get; set; }
public Guid ToRegionId { get; set; }
public string ToRegionName { get; set; }
- public string ToUserAgentHead { get; set; }
- public bool IsPhoneCall { get; set; }
+ public string ToUserAgentHeader { get; set; }
}
}
diff --git a/CCM.Web/Models/ApiExternal/CodecInfo.cs b/CCM.Core/Entities/CallRegisteredCodec.cs
similarity index 80%
rename from CCM.Web/Models/ApiExternal/CodecInfo.cs
rename to CCM.Core/Entities/CallRegisteredCodec.cs
index 41fad9ae..90ea403a 100644
--- a/CCM.Web/Models/ApiExternal/CodecInfo.cs
+++ b/CCM.Core/Entities/CallRegisteredCodec.cs
@@ -24,12 +24,17 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-namespace CCM.Web.Models.ApiExternal
+using CCM.Core.Entities.Base;
+
+namespace CCM.Core.Entities
{
- public class CodecInfo
+ public class CallRegisteredCodec : CoreEntityBase
{
- public string SipAddress { get; set; }
+ public string SIP { get; set; }
+ public string UserAgentHead { get; set; }
+ public string UserName { get; set; }
public string DisplayName { get; set; }
- public bool InCall { get; set; }
+ public string PresentationName { get; set; }
+ public CallRegisteredCodecSipAccount User { get; set; }
}
}
diff --git a/CCM.Web/Models/Profile/GuidSortIndexTuple.cs b/CCM.Core/Entities/CallRegisteredCodecSipAccount.cs
similarity index 90%
rename from CCM.Web/Models/Profile/GuidSortIndexTuple.cs
rename to CCM.Core/Entities/CallRegisteredCodecSipAccount.cs
index 8dbe4a2f..f54e3654 100644
--- a/CCM.Web/Models/Profile/GuidSortIndexTuple.cs
+++ b/CCM.Core/Entities/CallRegisteredCodecSipAccount.cs
@@ -26,11 +26,12 @@
using System;
-namespace CCM.Web.Models.Profile
+namespace CCM.Core.Entities
{
- public class GuidSortIndexTuple
+ public class CallRegisteredCodecSipAccount
{
public Guid Id { get; set; }
- public int SortIndex { get; set; }
+ public string UserName { get; set; }
+ public string DisplayName { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/CCM.Web/Extensions/EnumDto.cs b/CCM.Core/Entities/Category.cs
similarity index 79%
rename from CCM.Web/Extensions/EnumDto.cs
rename to CCM.Core/Entities/Category.cs
index 0e362449..92bd9a9c 100644
--- a/CCM.Web/Extensions/EnumDto.cs
+++ b/CCM.Core/Entities/Category.cs
@@ -24,26 +24,23 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
-using CCM.Core.Helpers;
+using System.Collections.Generic;
+using CCM.Core.Entities.Base;
+using CCM.Core.Interfaces;
-namespace CCM.Web.Extensions
+namespace CCM.Core.Entities
{
- public class EnumDto
+ public class Category : CoreEntityWithTimestamps, ISipFilter
{
- public int Value { get; set; }
public string Name { get; set; }
public string Description { get; set; }
+ public List Locations { get; set; }
+ public List UserAgents { get; set; }
- public static EnumDto Create(Enum e)
+ public Category()
{
- return new EnumDto
- {
- Value = Convert.ToInt32(e),
- Name = e.ToString(),
- Description = e.DescriptionAsResource()
- };
+ Locations = new List();
+ UserAgents = new List();
}
-
}
}
diff --git a/CCM.Core/Entities/CodecType.cs b/CCM.Core/Entities/CodecType.cs
index 1d9100fa..e20f1040 100644
--- a/CCM.Core/Entities/CodecType.cs
+++ b/CCM.Core/Entities/CodecType.cs
@@ -34,7 +34,7 @@ public class CodecType : CoreEntityWithTimestamps, ISipFilter
{
public string Name { get; set; }
public string Color { get; set; }
- public List Users { get; set; }
+ public List Users { get; set; } // TODO: Mode out to specific class
public CodecType()
{
diff --git a/CCM.Core/Entities/Discovery/UserAgentSearchParamsDto.cs b/CCM.Core/Entities/Discovery/UserAgentSearchParamsDto.cs
index c67983e8..12435d4e 100644
--- a/CCM.Core/Entities/Discovery/UserAgentSearchParamsDto.cs
+++ b/CCM.Core/Entities/Discovery/UserAgentSearchParamsDto.cs
@@ -25,14 +25,19 @@
*/
using System.Collections.Generic;
+using Newtonsoft.Json;
namespace CCM.Core.Entities.Discovery
{
public class UserAgentSearchParamsDto
{
+ [JsonProperty("caller")]
public string Caller { get; set; }
+ [JsonProperty("callee")]
public string Callee { get; set; }
+ [JsonProperty("filters")]
public IList> Filters { get; set; }
+ [JsonProperty("includeCodecsInCall")]
public bool IncludeCodecsInCall { get; set; }
}
}
diff --git a/CCM.Core/Entities/DocumentDb/CodecControlApi.cs b/CCM.Core/Entities/DocumentDb/CodecControlApi.cs
deleted file mode 100644
index 76d3a686..00000000
--- a/CCM.Core/Entities/DocumentDb/CodecControlApi.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System.Runtime.Serialization;
-
-namespace CCM.Core.Entities.DocumentDb
-{
- ///
- /// Used for JSON Document Db Storage
- ///
- [DataContract]
- public class CodecControlApi : DocumentDbObjectBase
- {
- [DataMember] public string Name { get; set; }
- [DataMember] public string Description { get; set; }
- [DataMember] public string DeviceSerial { get; set; }
- }
-}
diff --git a/CCM.Core/Entities/Filter.cs b/CCM.Core/Entities/Filter.cs
index b0088a6d..2c95efdb 100644
--- a/CCM.Core/Entities/Filter.cs
+++ b/CCM.Core/Entities/Filter.cs
@@ -31,8 +31,17 @@ namespace CCM.Core.Entities
public class Filter : CoreEntityWithTimestamps
{
public string Name { get; set; }
- public string ColumnName { get; set; } // Property/column name name in db
- public string TableName { get; set; } // Type (table) in db
- public string FilteringName { get; set; } // Property on cached registered sip object
+ ///
+ /// Property/column name name in db
+ ///
+ public string ColumnName { get; set; }
+ ///
+ /// Type (table) in db
+ ///
+ public string TableName { get; set; }
+ ///
+ /// Property on cached registered sip object
+ ///
+ public string FilteringName { get; set; }
}
}
diff --git a/CCM.Core/Entities/Location.cs b/CCM.Core/Entities/Location.cs
index 1b403b0a..dd3e3f62 100644
--- a/CCM.Core/Entities/Location.cs
+++ b/CCM.Core/Entities/Location.cs
@@ -36,7 +36,10 @@ public class Location : CoreEntityWithTimestamps, ISipFilter
public string ShortName { get; set; }
public string Comment { get; set; }
- public string Net { get; set; } // First IP-address for the network. Together with CIDR it describes a net-span
+ ///
+ /// First IP-address for the network. Together with CIDR it describes a net-span
+ ///
+ public string Net { get; set; }
public byte? Cidr { get; set; }
public string Net_v6 { get; set; }
@@ -46,6 +49,7 @@ public class Location : CoreEntityWithTimestamps, ISipFilter
public City City { get; set; }
public ProfileGroup ProfileGroup { get; set; }
public Region Region { get; set; }
+ public Category Category { get; set; }
public string ToIpV4String() { return !string.IsNullOrEmpty(Net) ? string.Format("{0} / {1}", Net, Cidr) : string.Empty; }
public string ToIpV6String() { return !string.IsNullOrEmpty(Net_v6) ? string.Format("{0} / {1}", Net_v6, Cidr_v6) : string.Empty; }
@@ -58,6 +62,5 @@ public byte[] ToIpV4SortString()
}
return ipAddress.GetAddressBytes();
}
-
}
}
diff --git a/CCM.Core/Entities/Profile.cs b/CCM.Core/Entities/ProfileCodec.cs
similarity index 91%
rename from CCM.Core/Entities/Profile.cs
rename to CCM.Core/Entities/ProfileCodec.cs
index 5e69df54..97957dc9 100644
--- a/CCM.Core/Entities/Profile.cs
+++ b/CCM.Core/Entities/ProfileCodec.cs
@@ -29,16 +29,17 @@
namespace CCM.Core.Entities
{
- public class Profile : CoreEntityWithTimestamps
+ public class ProfileCodec : CoreEntityWithTimestamps
{
public string Name { get; set; }
public string Description { get; set; }
+ public string LongDescription { get; set; }
public string Sdp { get; set; }
public ICollection Groups { get; set; }
public List UserAgents { get; set; }
- public int SortIndex { get; set; }
+ public int OrderIndex { get; set; }
- public Profile()
+ public ProfileCodec()
{
UserAgents = new List();
}
diff --git a/CCM.Core/Entities/ProfileGroup.cs b/CCM.Core/Entities/ProfileGroup.cs
index 9fe1cfc2..43bba10e 100644
--- a/CCM.Core/Entities/ProfileGroup.cs
+++ b/CCM.Core/Entities/ProfileGroup.cs
@@ -33,7 +33,7 @@ public class ProfileGroup: CoreEntityWithTimestamps
{
public ProfileGroup()
{
- Profiles = new List(); // TODO: This whole class needs some work.. Why this?
+ Profiles = new List(); // TODO: This whole class needs some work.. Why this?
}
public string Name { get; set; }
@@ -41,6 +41,6 @@ public ProfileGroup()
// Decides how valuable this group is compared to other groups
public int? GroupSortWeight { get; set; }
- public List Profiles { get; set; }
+ public List Profiles { get; set; }
}
}
diff --git a/CCM.Core/Entities/RegisteredSip.cs b/CCM.Core/Entities/RegisteredSip.cs
deleted file mode 100644
index 92bbc63f..00000000
--- a/CCM.Core/Entities/RegisteredSip.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using CCM.Core.Entities.Base;
-
-namespace CCM.Core.Entities
-{
- public class RegisteredSip : CoreEntityBase
- {
- // Properties from codec message
- public string SIP { get; set; }
- public string UserAgentHead { get; set; } // User-agent string that the codec is reporting. TODO: Try to rename this?
- public string Username { get; set; }
- public string DisplayName { get; set; }
- public string Registrar { get; set; }
- public string IP { get; set; }
- public int Port { get; set; }
- public int Expires { get; set; }
- public long ServerTimeStamp { get; set; }
-
- // Properties set on server
- public DateTime Updated { get; set; }
- public Location Location { get; set; }
- public SipAccount User { get; set; }
- }
-}
diff --git a/CCM.Core/Entities/RegisteredUserAgent.cs b/CCM.Core/Entities/RegisteredUserAgent.cs
index af83811b..4fdbaddf 100644
--- a/CCM.Core/Entities/RegisteredUserAgent.cs
+++ b/CCM.Core/Entities/RegisteredUserAgent.cs
@@ -36,26 +36,32 @@ public RegisteredUserAgent(
string displayName,
string location,
string locationShortName,
+ string locationCategory,
string image,
string codecTypeName,
string codecTypeColor,
- string username,
+ string codecTypeCategory,
+ string userExternalReference,
string userDisplayName,
string userComment,
- string regionName)
+ string regionName,
+ string codecApi)
{
SipUri = sipUri;
Id = id;
DisplayName = displayName;
Location = location;
LocationShortName = locationShortName;
+ LocationCategory = locationCategory;
Image = image;
CodecTypeName = codecTypeName;
CodecTypeColor = codecTypeColor;
- Username = username;
+ CodecTypeCategory = codecTypeCategory;
+ UserExternalReference = userExternalReference;
UserDisplayName = userDisplayName;
UserComment = userComment;
RegionName = regionName;
+ CodecApi = codecApi;
}
public string SipUri { get; }
@@ -63,10 +69,13 @@ public RegisteredUserAgent(
public string DisplayName { get; }
public string Location { get; }
public string LocationShortName { get; }
+ public string LocationCategory { get; }
public string Image { get; }
public string CodecTypeName { get; }
public string CodecTypeColor { get; }
- public string Username { get; }
+ public string CodecTypeCategory { get; }
+ public string CodecApi { get; }
+ public string UserExternalReference { get; }
public string UserDisplayName { get; }
public string UserComment { get; }
public string RegionName { get; }
diff --git a/CCM.Core/Entities/RegisteredUserAgentAndProfilesDiscovery.cs b/CCM.Core/Entities/RegisteredUserAgentAndProfilesDiscovery.cs
index 2879519b..08f55c00 100644
--- a/CCM.Core/Entities/RegisteredUserAgentAndProfilesDiscovery.cs
+++ b/CCM.Core/Entities/RegisteredUserAgentAndProfilesDiscovery.cs
@@ -40,7 +40,6 @@ public RegisteredUserAgentAndProfilesDiscovery(
Guid id,
string sipUri,
string displayName,
- string username,
string ipAddress,
string userAgentHeader,
string userAgentName,
@@ -62,7 +61,6 @@ public RegisteredUserAgentAndProfilesDiscovery(
Id = id;
SipUri = sipUri;
DisplayName = displayName;
- Username = username;
IpAddress = ipAddress;
UserAgentHeader = userAgentHeader;
UserAgentName = userAgentName;
@@ -87,32 +85,24 @@ public RegisteredUserAgentAndProfilesDiscovery(
public Guid Id { get; }
public string SipUri { get; }
public string DisplayName { get; }
- public string Username { get; }
+ //public string Username { get; } // TODO: remove med...
+ [FilterProperty(TableName = "UserAgents", ColumnName = "Identifier")]
public string IpAddress { get; }
public string UserAgentHeader { get; }
-
[FilterProperty(TableName = "UserAgents", ColumnName = "Name")]
public string UserAgentName { get; }
-
[FilterProperty(TableName = "Locations", ColumnName = "Name")]
public string LocationName { get; }
-
[FilterProperty(TableName = "Locations", ColumnName = "ShortName")]
public string LocationShortName { get; }
-
[FilterProperty(TableName = "Regions", ColumnName = "Name")]
public string RegionName { get; }
-
[FilterProperty(TableName = "Cities", ColumnName = "Name")]
public string CityName { get; }
-
public string UserOwnerName { get; }
-
public string UserDisplayName { get; }
-
[FilterProperty(TableName = "CodecTypes", ColumnName = "Name")]
public string CodecTypeName { get; }
-
public List> MetaData { get; }
// Profiles
@@ -124,6 +114,5 @@ public RegisteredUserAgentAndProfilesDiscovery(
public string InCallWithId { get; }
public string InCallWithSip { get; }
public string InCallWithName { get; }
-
}
}
diff --git a/CCM.Core/Entities/RegisteredUserAgentCodecInformation.cs b/CCM.Core/Entities/RegisteredUserAgentCodecInformation.cs
index 4f90c4ae..4a9afd1a 100644
--- a/CCM.Core/Entities/RegisteredUserAgentCodecInformation.cs
+++ b/CCM.Core/Entities/RegisteredUserAgentCodecInformation.cs
@@ -32,23 +32,17 @@ public RegisteredUserAgentCodecInformation(
string sipAddress,
string ip,
string api,
- string gpoNames,
- int nrOfInputs,
- int nrOfGpos)
+ string userAgent)
{
SipAddress = sipAddress;
Ip = ip;
Api = api;
- GpoNames = gpoNames;
- NrOfInputs = nrOfInputs;
- NrOfGpos = nrOfGpos;
+ UserAgent = userAgent;
}
public string SipAddress { get; }
public string Ip { get; }
public string Api { get; }
- public string GpoNames { get; }
- public int NrOfInputs { get; }
- public int NrOfGpos { get; }
+ public string UserAgent { get; }
}
}
diff --git a/CCM.Core/Entities/RegisteredUserAgentDiscovery.cs b/CCM.Core/Entities/RegisteredUserAgentDiscovery.cs
index 71e0fbc9..7f874f54 100644
--- a/CCM.Core/Entities/RegisteredUserAgentDiscovery.cs
+++ b/CCM.Core/Entities/RegisteredUserAgentDiscovery.cs
@@ -42,7 +42,6 @@ public RegisteredUserAgentDiscovery(
DateTime updated,
string sipUri,
string displayName,
- string username,
string ipAddress,
string userAgentHeader,
Guid? userAgentId,
@@ -62,7 +61,6 @@ List> metaData
Updated = updated;
SipUri = sipUri;
DisplayName = displayName;
- Username = username;
IpAddress = ipAddress;
UserAgentHeader = userAgentHeader;
UserAgentId = userAgentId;
@@ -77,41 +75,23 @@ List> metaData
CodecTypeName = codecTypeName;
MetaData = metaData;
}
- // TODO: This one doesn't need the FilterProperties. Should also change the editor for the filtering
+ // TODO: Should also change the editor for the filtering
public Guid Id { get; }
public DateTime Updated { get; }
public string SipUri { get; }
public string DisplayName { get; }
- public string Username { get; }
public string IpAddress { get; }
public string UserAgentHeader { get; }
-
public Guid? UserAgentId { get; }
-
- //[FilterProperty(TableName = "UserAgents", ColumnName = "Name")]
public string UserAgentName { get; }
-
public Guid? LocationId { get; }
-
- //[FilterProperty(TableName = "Locations", ColumnName = "Name")]
public string LocationName { get; }
-
- //[FilterProperty(TableName = "Locations", ColumnName = "ShortName")]
public string LocationShortName { get; }
-
- //[FilterProperty(TableName = "Regions", ColumnName = "Name")]
public string RegionName { get; }
-
- //[FilterProperty(TableName = "Cities", ColumnName = "Name")]
public string CityName { get; }
-
public string UserOwnerName { get; }
-
public string UserDisplayName { get; }
-
- //[FilterProperty(TableName = "CodecTypes", ColumnName = "Name")]
public string CodecTypeName { get; }
-
public List> MetaData { get; }
}
}
diff --git a/CCM.Core/Entities/RegisteredUserAgentMiniInformation.cs b/CCM.Core/Entities/RegisteredUserAgentMiniInformation.cs
new file mode 100644
index 00000000..3aeaa383
--- /dev/null
+++ b/CCM.Core/Entities/RegisteredUserAgentMiniInformation.cs
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+
+namespace CCM.Core.Entities
+{
+ public class RegisteredUserAgentMiniInformation
+ {
+ public RegisteredUserAgentMiniInformation(
+ Guid id,
+ string sip,
+ int expires,
+ long serverTimeStamp,
+ DateTime updated)
+ {
+ Id = id;
+ SIP = sip;
+ Expires = expires;
+ ServerTimeStamp = serverTimeStamp;
+ Updated = updated;
+ }
+
+ public Guid Id { get; }
+ public string SIP { get; }
+ public int Expires { get; }
+ public long ServerTimeStamp { get; }
+ public DateTime Updated { get; }
+ }
+}
diff --git a/CCM.Core/Entities/Registration/UserAgentInfo.cs b/CCM.Core/Entities/Registration/UserAgentInfo.cs
index 206f993f..66ce4cc8 100644
--- a/CCM.Core/Entities/Registration/UserAgentInfo.cs
+++ b/CCM.Core/Entities/Registration/UserAgentInfo.cs
@@ -38,7 +38,7 @@ public class UserAgentInfo
public UserAgentInfo(
Guid userAgentId,
string identifier,
- MatchType matchType)
+ UserAgentPatternMatchType matchType)
{
UserAgentId = userAgentId;
Identifier = identifier;
@@ -47,6 +47,6 @@ public UserAgentInfo(
public Guid UserAgentId { get; }
public string Identifier { get; }
- public MatchType MatchType { get; }
+ public UserAgentPatternMatchType MatchType { get; }
}
}
diff --git a/CCM.Core/Entities/SipAccount.cs b/CCM.Core/Entities/SipAccount.cs
index f95f578f..e80ffbdb 100644
--- a/CCM.Core/Entities/SipAccount.cs
+++ b/CCM.Core/Entities/SipAccount.cs
@@ -24,6 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using CCM.Core.Entities.Base;
using CCM.Core.Enums;
using CCM.Core.Interfaces;
@@ -39,7 +40,13 @@ public class SipAccount : CoreEntityWithTimestamps, ISipFilter
public SipAccountType AccountType { get; set; }
public bool AccountLocked { get; set; }
public string Password { get; set; }
+ public DateTime? LastUsed { get; set; }
+ public string LastUserAgent { get; set; }
+ public string LastKnownAddress { get; set; }
+ public string ExternalReference { get; set; }
public CodecType CodecType { get; set; }
public Owner Owner { get; set; }
+
+ public bool IsUnused => LastUsed == null || LastUsed < DateTime.UtcNow.AddDays(-360);
}
}
diff --git a/CCM.Core/Entities/Specific/OldCall.cs b/CCM.Core/Entities/Specific/OldCall.cs
index 665e27e9..8f637c2c 100644
--- a/CCM.Core/Entities/Specific/OldCall.cs
+++ b/CCM.Core/Entities/Specific/OldCall.cs
@@ -28,9 +28,37 @@
namespace CCM.Core.Entities.Specific
{
- public class OldCall : OnGoingCall
+ public class OldCall
{
+ public string CallId { get; set; }
+ public DateTime Started { get; set; }
public DateTime Ended { get; set; }
public string Duration { get; set; }
+ public bool IsPhoneCall { get; set; }
+ public string SDP { get; set; }
+
+ public string FromDisplayName { get; set; }
+ public string FromSip { get; set; }
+ public string FromId { get; set; }
+ public string FromLocationName { get; set; }
+ public string FromLocationShortName { get; set; }
+ public string FromLocationCategory { get; set; }
+ public string FromComment { get; set; }
+ public string FromRegionName { get; set; }
+ public string FromCodecTypeName { get; set; }
+ public string FromCodecTypeColor { get; set; }
+ public string FromCodecTypeCategory { get; set; }
+
+ public string ToDisplayName { get; set; }
+ public string ToSip { get; set; }
+ public string ToId { get; set; }
+ public string ToLocationName { get; set; }
+ public string ToLocationShortName { get; set; }
+ public string ToLocationCategory { get; set; }
+ public string ToComment { get; set; }
+ public string ToRegionName { get; set; }
+ public string ToCodecTypeName { get; set; }
+ public string ToCodecTypeColor { get; set; }
+ public string ToCodecTypeCategory { get; set; }
}
}
diff --git a/CCM.Core/Entities/Specific/OnGoingCall.cs b/CCM.Core/Entities/Specific/OnGoingCall.cs
index c8b179e9..a5f945a4 100644
--- a/CCM.Core/Entities/Specific/OnGoingCall.cs
+++ b/CCM.Core/Entities/Specific/OnGoingCall.cs
@@ -33,24 +33,35 @@ public class OnGoingCall
public string CallId { get; set; }
public DateTime Started { get; set; }
public bool IsPhoneCall { get; set; }
+ public string SDP { get; set; }
+
public string FromDisplayName { get; set; }
public string FromSip { get; set; }
public string FromId { get; set; }
public string FromLocationName { get; set; }
public string FromLocationShortName { get; set; }
+ public string FromLocationCategory { get; set; }
public string FromComment { get; set; }
public string FromRegionName { get; set; }
public string FromCodecTypeName { get; set; }
public string FromCodecTypeColor { get; set; }
+ public string FromCodecTypeCategory { get; set; }
+ public string FromCategory { get; set; }
+ public string FromExternalReference { get; set; }
+
public string ToDisplayName { get; set; }
public string ToSip { get; set; }
public string ToId { get; set; }
public string ToLocationName { get; set; }
public string ToLocationShortName { get; set; }
+ public string ToLocationCategory { get; set; }
public string ToComment { get; set; }
public string ToRegionName { get; set; }
public string ToCodecTypeName { get; set; }
public string ToCodecTypeColor { get; set; }
+ public string ToCodecTypeCategory { get; set; }
+ public string ToCategory { get; set; }
+ public string ToExternalReference { get; set; }
public int DurationSeconds => Convert.ToInt32(DateTime.UtcNow.Subtract(Started).TotalSeconds);
}
diff --git a/CCM.Data/Repositories/LocationInfoRepository.cs b/CCM.Core/Entities/Specific/ProfileFullDetail.cs
similarity index 69%
rename from CCM.Data/Repositories/LocationInfoRepository.cs
rename to CCM.Core/Entities/Specific/ProfileFullDetail.cs
index a519a811..04a1f2fd 100644
--- a/CCM.Data/Repositories/LocationInfoRepository.cs
+++ b/CCM.Core/Entities/Specific/ProfileFullDetail.cs
@@ -24,31 +24,29 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using System.Collections.Generic;
-using System.Linq;
-using CCM.Core.Entities.Specific;
-using CCM.Core.Interfaces.Repositories;
-using LazyCache;
-namespace CCM.Data.Repositories
+namespace CCM.Core.Entities.Specific
{
- // TODO: Maybe move info LocationRepository?
- public class LocationInfoRepository : BaseRepository, ILocationInfoRepository
+ public class ProfileFullDetail
{
- public LocationInfoRepository(IAppCache cache) : base(cache)
+ public ProfileFullDetail(Guid id, string name, string description, string longDescription, string sdp, List supportedUserAgents)
{
+ Id = id;
+ Name = name;
+ Description = description;
+ LongDescription = longDescription;
+ Sdp = sdp;
+ SupportedUserAgents = supportedUserAgents;
}
- public List GetAll()
- {
- using (var db = GetDbContext())
- {
- return db.Locations.Select(l => new LocationInfo()
- {
- Id = l.Id,
- Name = l.Name
- }).ToList();
- }
- }
+ public Guid Id;
+ public string Name { get; }
+ public string Description { get; }
+ public string LongDescription { get; }
+ public string Sdp { get; }
+
+ public List SupportedUserAgents { get; }
}
}
diff --git a/CCM.Core/Entities/Specific/RegisteredSipDetails.cs b/CCM.Core/Entities/Specific/RegisteredSipDetails.cs
index bf96eed4..1bd0ea2c 100644
--- a/CCM.Core/Entities/Specific/RegisteredSipDetails.cs
+++ b/CCM.Core/Entities/Specific/RegisteredSipDetails.cs
@@ -25,43 +25,36 @@
*/
using System;
-using System.Collections.Generic;
namespace CCM.Core.Entities.Specific
{
public class RegisteredSipDetails
{
public Guid Id { get; set; }
+ public string Sip { get; set; }
public string DisplayName { get; set; }
- public string Comment { get; set; }
- public bool InCall { get; set; }
- public string CallWithName { get; set; }
+ public string UserDisplayName { get; set; }
+ public string Ip { get; set; }
+ public string Api { get; set; }
+ public string Image { get; set; }
+ public string Registrar { get; set; }
+ public string Comment { get; set; }
+ public string UserExternalReference { get; set; }
+
+ public string UserAgentHeader { get; set; }
+ public string UserAgentName { get; set; }
+
public string LocationName { get; set; }
public string LocationComment { get; set; }
-
+
public string RegionName { get; set; }
public string CityName { get; set; }
-
- public string Ip { get; set; }
- public string Api { get; set; }
- public string UserAgentHeader { get; set; }
- public string Sip { get; set; }
- public string Registrar { get; set; }
- public string UserDisplayName { get; set; }
+
public string UserInterfaceLink { get; set; }
public bool UserInterfaceIsOpen { get; set; }
public bool UseScrollbars { get; set; }
- public string Image { get; set; }
- public bool ActiveX { get; set; }
public int Width { get; set; }
public int Height { get; set; }
- public int Inputs { get; set; }
- public int NrOfGpos { get; set; }
- public int InputMinDb { get; set; }
- public int InputMaxDb { get; set; }
- public int InputGainStep { get; set; }
- public int Lines { get; set; }
- public List CodecPresets { get; set; }
}
}
diff --git a/CCM.Core/Enums/MatchType.cs b/CCM.Core/Entities/Statistics/CallEventTypeStatistics.cs
similarity index 92%
rename from CCM.Core/Enums/MatchType.cs
rename to CCM.Core/Entities/Statistics/CallEventTypeStatistics.cs
index d1c581b0..511eee29 100644
--- a/CCM.Core/Enums/MatchType.cs
+++ b/CCM.Core/Entities/Statistics/CallEventTypeStatistics.cs
@@ -24,12 +24,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-namespace CCM.Core.Enums
+namespace CCM.Core.Entities.Statistics
{
- public enum MatchType
+ public enum CallEventTypeStatistics
{
- Begins_With = 0,
- Contains = 1,
- Ends_With = 2
+ End = 0,
+ Start = 1
}
-}
+}
\ No newline at end of file
diff --git a/CCM.Core/Entities/Statistics/CategoryBasedStatistics.cs b/CCM.Core/Entities/Statistics/CategoryBasedStatistics.cs
new file mode 100644
index 00000000..08e02c84
--- /dev/null
+++ b/CCM.Core/Entities/Statistics/CategoryBasedStatistics.cs
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System.Collections.Generic;
+
+namespace CCM.Core.Entities.Statistics
+{
+ public class CategoryCallStatistic
+ {
+ public int NumberOfCalls { get; set; } = 0;
+ public string Part1Category { get; set; } = "";
+ public string Part2Category { get; set; } = "";
+ public List CallTimes { get; set; } = new List();
+ public double TotalCallTime { get; set; } = 0;
+ }
+
+ public class CategoryItemStatistic
+ {
+ public int NumberOfCalls { get; set; } = 0;
+ public string Category { get; set; } = "";
+ public List CallTimes { get; set; } = new List();
+ public double TotalCallTime { get; set; } = 0;
+ }
+}
diff --git a/CCM.Core/Entities/Statistics/DateBasedStatistics.cs b/CCM.Core/Entities/Statistics/DateBasedStatistics.cs
index ab84beb5..d1bf31c4 100644
--- a/CCM.Core/Entities/Statistics/DateBasedStatistics.cs
+++ b/CCM.Core/Entities/Statistics/DateBasedStatistics.cs
@@ -32,16 +32,16 @@ namespace CCM.Core.Entities.Statistics
{
public class DateBasedStatistics
{
- public double AverageTime
- {
- get { return NumberOfCalls == 0 ? 0 : TotaltTimeForCalls/NumberOfCalls; }
- }
-
public DateTime Date { get; set; }
+ public int NumberOfCalls { get; private set; }
public double MaxCallTime { get; private set; }
+ public string MaxCallTimeView => TimeSpan.FromMinutes(Convert.ToInt32(MaxCallTime)).ToString(@"hh\:mm\:ss");
public double MinCallTime { get; private set; }
- public int NumberOfCalls { get; private set; }
- public double TotaltTimeForCalls { get; private set; }
+ public string MinCallTimeView => TimeSpan.FromMinutes(Convert.ToInt32(MinCallTime)).ToString(@"hh\:mm\:ss");
+ public double TotalTimeForCalls { get; private set; }
+ public string TotalTimeForCallsView => TimeSpan.FromMinutes(Convert.ToInt32(TotalTimeForCalls)).ToString(@"hh\:mm");
+ public double AverageTime => NumberOfCalls == 0 ? 0 : TotalTimeForCalls / NumberOfCalls;
+ public string AverageTimeView => TimeSpan.FromMinutes(Convert.ToInt32(AverageTime)).ToString(@"hh\:mm");
public void AddTime(double timeInMinutes)
{
@@ -59,7 +59,7 @@ public void AddTime(double timeInMinutes)
MaxCallTime = timeInMinutes;
}
- TotaltTimeForCalls += timeInMinutes;
+ TotalTimeForCalls += timeInMinutes;
NumberOfCalls++;
}
}
diff --git a/CCM.Core/Entities/Statistics/HourBasedStatistics.cs b/CCM.Core/Entities/Statistics/HourBasedStatistics.cs
index 70796bbd..f9618fe4 100644
--- a/CCM.Core/Entities/Statistics/HourBasedStatistics.cs
+++ b/CCM.Core/Entities/Statistics/HourBasedStatistics.cs
@@ -77,7 +77,7 @@ public bool AddEvent(HourBasedCallEvent callEvent)
if (_maxSimultaneousCallsPerDay.Count < 1)
_maxSimultaneousCallsPerDay.Add(0);
if (callEvent.EventTime > Date.AddHours(1)) return false;
- if (callEvent.EventType == CallEventType.Start)
+ if (callEvent.EventType == CallEventTypeStatistics.Start)
{
OngoingCalls++;
if (OngoingCalls > _maxSimultaneousCallsPerDay[0])
@@ -148,33 +148,32 @@ public static List Aggregate(IEnumerable GetOrderedEvents(IList callHistories,
- Guid locationId)
+ public static IEnumerable GetOrderedEvents(IList callHistories, Guid locationId)
{
return GetEvents(callHistories, locationId).OrderBy(e => e.EventTime).ThenBy(e => (int)e.EventType);
}
- public static IEnumerable GetEvents(IList callHistories, Guid locationId)
+ private static IEnumerable GetEvents(IList callHistories, Guid locationId)
{
foreach (var call in callHistories)
{
if (call.FromLocationId == locationId || call.ToLocationId == locationId)
{
yield return
- Create(CallEventType.Start, call);
+ Create(CallEventTypeStatistics.Start, call);
yield return
- Create(CallEventType.End, call);
+ Create(CallEventTypeStatistics.End, call);
}
}
}
- public static HourBasedCallEvent Create(CallEventType eventType, CallHistory call)
+ private static HourBasedCallEvent Create(CallEventTypeStatistics eventType, CallHistory call)
{
return new HourBasedCallEvent
{
- EventTime = eventType == CallEventType.Start ? call.Started : call.Ended,
+ EventTime = eventType == CallEventTypeStatistics.Start ? call.Started : call.Ended,
EventType = eventType,
};
}
@@ -185,6 +184,7 @@ public class HourBasedStatisticsForLocation
public Guid LocationId { get; set; }
public string LocationName { get; set; }
public IList Statistics { get; set; }
+ public int MaxCallCount => Statistics.Max(data => data.MaxSimultaneousCalls);
public IEnumerable> GetSeries()
{
diff --git a/CCM.Core/Entities/Statistics/LocationBasedStatistics.cs b/CCM.Core/Entities/Statistics/LocationBasedStatistics.cs
index 45174593..200f7685 100644
--- a/CCM.Core/Entities/Statistics/LocationBasedStatistics.cs
+++ b/CCM.Core/Entities/Statistics/LocationBasedStatistics.cs
@@ -36,7 +36,7 @@ public class LocationBasedStatistics
public double AverageTime
{
- get { return NumberOfCalls == 0 ? 0 : TotaltTimeForCalls/NumberOfCalls; }
+ get { return NumberOfCalls == 0 ? 0 : TotalTimeForCalls/NumberOfCalls; }
}
public Guid LocationId { get; set; }
@@ -44,7 +44,7 @@ public double AverageTime
public double MaxCallTime { get; private set; }
public double MinCallTime { get; private set; }
public int NumberOfCalls { get; private set; }
- public double TotaltTimeForCalls { get; private set; }
+ public double TotalTimeForCalls { get; private set; }
public int MaxSimultaneousCalls { get; private set; }
public int OngoingCalls { get; private set; }
@@ -58,7 +58,7 @@ public IEnumerable MaxSimultaneousEventDates
public void AddEvent(LocationCallEvent callEvent, DateTime reportPeriodStart, DateTime reportPeriodEnd)
{
- if (callEvent.EventType == CallEventType.Start)
+ if (callEvent.EventType == CallEventTypeStatistics.Start)
{
OngoingCalls++;
if (OngoingCalls == MaxSimultaneousCalls)
@@ -89,52 +89,51 @@ public void AddEvent(LocationCallEvent callEvent, DateTime reportPeriodStart, Da
var durationInReportPeriod = ((callEvent.EndTime > reportPeriodEnd ? reportPeriodEnd : callEvent.EndTime) -
(callEvent.StartTime < reportPeriodStart ? reportPeriodStart : callEvent.StartTime)).TotalMinutes;
- TotaltTimeForCalls += durationInReportPeriod;
+ TotalTimeForCalls += durationInReportPeriod;
}
}
public class LocationCallEvent
{
public DateTime EventTime { get; set; }
- public CallEventType EventType { get; set; }
+ public CallEventTypeStatistics EventType { get; set; }
public Guid LocationId { get; set; }
public string LocationName { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
- public static IEnumerable GetOrderedEvents(IList callHistories,
- CallHistoryFilter filter)
+ public static IEnumerable GetOrderedEvents(IList callHistories, CallHistoryFilter filter)
{
return GetEvents(callHistories, filter).OrderBy(e => e.EventTime).ThenBy(e => (int)e.EventType);
}
- public static IEnumerable GetEvents(IList callHistories, CallHistoryFilter filter)
+ private static IEnumerable GetEvents(IList callHistories, CallHistoryFilter filter)
{
foreach (var call in callHistories)
{
if ((call.FromLocationId == call.ToLocationId && filter.IsMatch(call)) || filter.IsFromMatch(call))
{
yield return
- Create(CallEventType.Start, call, c => Tuple.Create(c.FromLocationId, c.FromLocationName));
+ Create(CallEventTypeStatistics.Start, call, c => Tuple.Create(c.FromLocationId, c.FromLocationName));
yield return
- Create(CallEventType.End, call, c => Tuple.Create(c.FromLocationId, c.FromLocationName));
+ Create(CallEventTypeStatistics.End, call, c => Tuple.Create(c.FromLocationId, c.FromLocationName));
}
if (call.FromLocationId != call.ToLocationId && filter.IsToMatch(call))
{
yield return
- Create(CallEventType.Start, call, c => Tuple.Create(c.ToLocationId, c.ToLocationName));
+ Create(CallEventTypeStatistics.Start, call, c => Tuple.Create(c.ToLocationId, c.ToLocationName));
yield return
- Create(CallEventType.End, call, c => Tuple.Create(c.ToLocationId, c.ToLocationName));
+ Create(CallEventTypeStatistics.End, call, c => Tuple.Create(c.ToLocationId, c.ToLocationName));
}
}
}
- public static LocationCallEvent Create(CallEventType eventType, CallHistory call, Func> locationSelector)
+ private static LocationCallEvent Create(CallEventTypeStatistics eventType, CallHistory call, Func> locationSelector)
{
var location = locationSelector(call);
return new LocationCallEvent
{
- EventTime = eventType == CallEventType.Start ? call.Started : call.Ended,
+ EventTime = eventType == CallEventTypeStatistics.Start ? call.Started : call.Ended,
EventType = eventType,
EndTime = call.Ended,
LocationId = location.Item1,
@@ -142,13 +141,6 @@ public static LocationCallEvent Create(CallEventType eventType, CallHistory call
StartTime = call.Started
};
}
-
- }
-
- public enum CallEventType
- {
- End = 0,
- Start = 1
}
public class CallHistoryFilter
diff --git a/CCM.Core/Entities/Studio.cs b/CCM.Core/Entities/Studio.cs
deleted file mode 100644
index 646290a2..00000000
--- a/CCM.Core/Entities/Studio.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using CCM.Core.Entities.Base;
-
-namespace CCM.Core.Entities
-{
- public class Studio : CoreEntityWithTimestamps
- {
- public string Name { get; set; }
- public string CodecSipAddress { get; set; }
- public string CameraAddress { get; set; }
- public bool CameraActive { get; set; }
- public string CameraUsername { get; set; }
- public string CameraPassword { get; set; }
- public string CameraVideoUrl { get; set; }
- public string CameraImageUrl { get; set; }
- public string CameraPlayAudioUrl { get; set; }
- public string AudioClipNames { get; set; }
- public string InfoText { get; set; }
- public string MoreInfoUrl { get; set; }
- public int NrOfAudioInputs { get; set; }
- public string AudioInputNames { get; set; }
- public int AudioInputDefaultGain { get; set; }
- public int NrOfGpos { get; set; }
- public string GpoNames { get; set; }
- public int InactivityTimeout { get; set; }
- }
-}
diff --git a/CCM.Core/Entities/UserAgent.cs b/CCM.Core/Entities/UserAgent.cs
index b3c09454..dafbf4e4 100644
--- a/CCM.Core/Entities/UserAgent.cs
+++ b/CCM.Core/Entities/UserAgent.cs
@@ -33,35 +33,26 @@ namespace CCM.Core.Entities
{
public class UserAgent : CoreEntityWithTimestamps, ISipFilter
{
- // TODO: XXX Limit the amount of things returned here. Functions don't really need api information. That's mostly codec control
-
public UserAgent()
{
- Profiles = new List();
- CodecPresets = new List();
+ Profiles = new List();
}
public string Name { get; set; }
public string Identifier { get; set; }
- public MatchType MatchType { get; set; }
+ public UserAgentPatternMatchType MatchType { get; set; }
+ public string Api { get; set; }
+ public Category Category { get; set; }
+ // TODO: XXX Limit the amount of things returned here. Functions don't really need api information. That's mostly codec control
+ // Everything below move to separate table
public string Image { get; set; }
public string UserInterfaceLink { get; set; }
- public bool Ax { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public string Comment { get; set; }
- public string Api { get; set; }
- public int Lines { get; set; }
- public int Inputs { get; set; }
- public int NrOfGpos { get; set; }
- public int InputMinDb { get; set; }
- public int InputMaxDb { get; set; }
- public int InputGainStep { get; set; }
- public string GpoNames { get; set; }
public bool UserInterfaceIsOpen { get; set; }
public bool UseScrollbars { get; set; }
- public List Profiles { get; set; }
- public List CodecPresets { get; set; }
+ public List Profiles { get; set; }
}
}
diff --git a/CCM.Core/Entities/UserAgentAndProfiles.cs b/CCM.Core/Entities/UserAgentAndProfiles.cs
index 2fa92365..3fc28ba2 100644
--- a/CCM.Core/Entities/UserAgentAndProfiles.cs
+++ b/CCM.Core/Entities/UserAgentAndProfiles.cs
@@ -36,25 +36,16 @@ public UserAgentAndProfiles(
Guid id,
string name,
string identifier,
- MatchType matchType,
+ UserAgentPatternMatchType matchType,
string imagePath,
string userInterfaceLink,
- bool activeX,
int width,
int height,
string comment,
string apiType,
- int connectionLines,
- int inputs,
- int outputs,
- int nrOfGpos,
- int inputMinDb,
- int inputMaxDb,
- int inputGainStep,
- string gpoNames,
bool userInterfaceIsOpen,
bool useScrollbars,
- List profiles)
+ List profiles)
{
Id = id;
Name = name;
@@ -62,19 +53,10 @@ public UserAgentAndProfiles(
MatchType = matchType;
Image = imagePath;
UserInterfaceLink = userInterfaceLink;
- Ax = activeX;
Width = width;
Height = height;
Comment = comment;
Api = apiType;
- Lines = connectionLines;
- Inputs = inputs;
- Outputs = outputs; // TODO: add this
- NrOfGpos = nrOfGpos;
- InputMinDb = inputMinDb;
- InputMaxDb = inputMaxDb;
- InputGainStep = inputGainStep;
- GpoNames = gpoNames;
UserInterfaceIsOpen = userInterfaceIsOpen;
UseScrollbars = useScrollbars;
Profiles = profiles;
@@ -83,24 +65,15 @@ public UserAgentAndProfiles(
public Guid Id { get; }
public string Name { get; }
public string Identifier { get; }
- public MatchType MatchType { get; }
+ public UserAgentPatternMatchType MatchType { get; }
public string Image { get; }
public string UserInterfaceLink { get; }
- public bool Ax { get; }
public int Width { get; }
public int Height { get; }
public string Comment { get; }
public string Api { get; }
- public int Lines { get; }
- public int Inputs { get; }
- public int Outputs { get; } // New addition
- public int NrOfGpos { get; }
- public int InputMinDb { get; }
- public int InputMaxDb { get; }
- public int InputGainStep { get; }
- public string GpoNames { get; }
public bool UserInterfaceIsOpen { get; }
public bool UseScrollbars { get; }
- public List Profiles { get; }
+ public List Profiles { get; }
}
}
diff --git a/CCM.Core/Enums/Settings.cs b/CCM.Core/Enums/Settings.cs
index 24759058..4cd91a57 100644
--- a/CCM.Core/Enums/Settings.cs
+++ b/CCM.Core/Enums/Settings.cs
@@ -24,15 +24,53 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
+
namespace CCM.Core.Enums
{
public enum SettingsEnum
{
+ [DefaultSetting("Time in seconds before SIP registration is obsolete","120")]
MaxRegistrationAge,
+ [DefaultSetting("The SIP domain", "@domain.sip.com")] // TODO: Is this in use? and really necessary??
SIPDomain,
+ [DefaultSetting("Number of closed calls to show on startpage", "50")]
LatestCallCount,
+ [DefaultSetting("Codec Control on/off", "true")]
CodecControlActive,
+ [DefaultSetting("Receive Kamailio messages in old '::' string separated format", "false")]
UseOldKamailioEvent,
- UseSipEvent
+ [DefaultSetting("Receive Kamailio messages in JSON-format", "true")]
+ UseSipEvent,
+ [DefaultSetting("Folder for User-Agent images", "")]
+ UserAgentImagesFolder,
+ [DefaultSetting("URL to CCM Discovery service", "http://ccm.discovery.com")]
+ DiscoveryServiceUrl,
+ [DefaultSetting("URL to Codec Control service for startpage codec control", "https://codeccontrol.com")]
+ CodecControlHost,
+ [DefaultSetting("Username for Codec Control authentication", "")]
+ CodecControlUserName,
+ [DefaultSetting("Password for Codec Control authentication", "")]
+ CodecControlPassword,
+ [DefaultSetting("Cache time for information that changes more frequently in seconds", "30")]
+ CacheTimeLiveData,
+ [DefaultSetting("Cache time for information that is changed less often in seconds", "60")]
+ CacheTimeConfigData,
+ }
+
+ [AttributeUsage(AttributeTargets.All)]
+ public class DefaultSettingAttribute : Attribute
+ {
+ protected string DefaultValue { get; set; }
+ protected string DefaultDescription { get; set; }
+
+ public virtual string Value => DefaultValue;
+ public virtual string Description => DefaultDescription;
+
+ public DefaultSettingAttribute(string defaultDescription, string defaultValue)
+ {
+ DefaultValue = defaultValue;
+ DefaultDescription = defaultDescription;
+ }
}
}
diff --git a/CCM.Core/Enums/UserAgentPatternMatchType.cs b/CCM.Core/Enums/UserAgentPatternMatchType.cs
new file mode 100644
index 00000000..4f0e15bc
--- /dev/null
+++ b/CCM.Core/Enums/UserAgentPatternMatchType.cs
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System.ComponentModel;
+
+namespace CCM.Core.Enums
+{
+ public enum UserAgentPatternMatchType
+ {
+ [Description("Begins_With")] Begins_With = 0,
+ [Description("Contains")] Contains = 1,
+ [Description("Ends_With")] Ends_With = 2,
+ [Description("Regular_Expression")] Regular_Expression = 3
+ }
+}
diff --git a/CCM.Core/Helpers/ApplicationBuildInformation.cs b/CCM.Core/Helpers/ApplicationBuildInformation.cs
new file mode 100644
index 00000000..54fd4209
--- /dev/null
+++ b/CCM.Core/Helpers/ApplicationBuildInformation.cs
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+namespace CCM.Core.Helpers
+{
+ public class ApplicationBuildInformation
+ {
+ public string Name { get; set; } = "";
+ public string LogFolder { get; set; }
+ public string ReleaseDate { get; set; }
+ public string Version { get; set; }
+ public string Environment { get; set; } = "Dev";
+ public string Server { get; set; } = "localhost";
+ }
+}
\ No newline at end of file
diff --git a/CCM.Core/Helpers/ApplicationConstants.cs b/CCM.Core/Helpers/ApplicationConstants.cs
deleted file mode 100644
index d0e6a1c1..00000000
--- a/CCM.Core/Helpers/ApplicationConstants.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace CCM.Core.Helpers
-{
- public static class Roles
- {
- public const string Admin = "Admin";
- public const string Remote = "Remote";
- public const string AccountManager = "AccountManager";
- }
-
- public static class Owners
- {
- public const string SrOwnerName = "SR"; // TODO: This is way to hardcoded Owners.SrOwnerName
- }
-
- public static class CodecTypes
- {
- public const string Personliga = "Personliga"; // TODO: This is way to hardcoded CodecTypes.Personliga
- }
-}
diff --git a/CCM.Core/Helpers/ApplicationSettings.cs b/CCM.Core/Helpers/ApplicationSettings.cs
deleted file mode 100644
index ea04f448..00000000
--- a/CCM.Core/Helpers/ApplicationSettings.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Configuration;
-
-namespace CCM.Core.Helpers
-{
- public static class ApplicationSettings
- {
- public static Uri DiscoveryHost => new Uri(ConfigurationManager.AppSettings["DiscoveryHost"]);
- public static string DiscoveryLogLevelUrl => new Uri(DiscoveryHost, "api/loglevel").ToString();
- public static int CacheTimeLiveData => Int32.Parse(ConfigurationManager.AppSettings["CacheTimeLiveData"]);
- public static int CacheTimeConfigData => Int32.Parse(ConfigurationManager.AppSettings["CacheTimeConfigData"]);
-
- }
-}
diff --git a/CCM.Core/Interfaces/Kamailio/IKamailioDataParser.cs b/CCM.Core/Helpers/AuthenticationAccountRoles.cs
similarity index 87%
rename from CCM.Core/Interfaces/Kamailio/IKamailioDataParser.cs
rename to CCM.Core/Helpers/AuthenticationAccountRoles.cs
index fbdca473..d27aea7e 100644
--- a/CCM.Core/Interfaces/Kamailio/IKamailioDataParser.cs
+++ b/CCM.Core/Helpers/AuthenticationAccountRoles.cs
@@ -24,12 +24,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using CCM.Core.SipEvent.Parser;
-
-namespace CCM.Core.Interfaces.Kamailio
+namespace CCM.Core.Helpers
{
- public interface IKamailioDataParser
+ public static class Roles
{
- KamailioData ParseToKamailioData(string message);
+ public const string Admin = "Admin";
+ public const string Remote = "Remote";
+ public const string AccountManager = "AccountManager";
}
}
diff --git a/CCM.Core/Helpers/DisplayNameHelper.cs b/CCM.Core/Helpers/DisplayNameHelper.cs
index e4c18d67..4fb7e463 100644
--- a/CCM.Core/Helpers/DisplayNameHelper.cs
+++ b/CCM.Core/Helpers/DisplayNameHelper.cs
@@ -26,29 +26,96 @@
using System;
using CCM.Core.Entities;
+using CCM.Core.Entities.Specific;
using CCM.Core.Extensions;
-using CCM.Core.Properties;
namespace CCM.Core.Helpers
{
+ ///
+ /// TODO: important, all displaynames that is created with this process should be called presentationName instead...
+ /// Presentationname should be in this order:
+ /// - Saved user DisplayName
+ /// - Displayname from the codec/user-agent
+ /// - Call Displayname from the service because the codec is not registered
+ /// - Username/SIP-Address as told by the registrar (with our domain removed if there is one)
+ /// - Call Username from the service because the codec is not registered
+ ///
public class DisplayNameHelper
{
- public static string GetDisplayName(RegisteredSip registeredSip, string sipDomain)
+ public static string GetDisplayName(CallRegisteredCodec registeredCodec, string callDisplayName, string callUserName, string sipDomain)
{
- return GetDisplayName(registeredSip.DisplayName, registeredSip.User != null ? registeredSip.User.DisplayName : string.Empty, string.Empty, registeredSip.Username, registeredSip.SIP, "", sipDomain);
+ return GetDisplayName(
+ registeredCodec?.User?.DisplayName ?? string.Empty,
+ registeredCodec?.DisplayName ?? string.Empty,
+ callDisplayName,
+ registeredCodec?.SIP ?? string.Empty,
+ callUserName,
+ string.Empty,
+ sipDomain);
}
- //public static string GetDisplayName(RegisteredSipDto registeredSip, string sipDomain)
- //{
- // return GetDisplayName(registeredSip.DisplayName, registeredSip.UserDisplayName, string.Empty, registeredSip.UserName, registeredSip.Sip, "", sipDomain);
- //}
+ public static string GetDisplayName(RegisteredSipDetails registeredSip, string sipDomain)
+ {
+ return GetDisplayName(
+ registeredSip.UserDisplayName,
+ registeredSip.DisplayName,
+ string.Empty,
+ registeredSip.Sip,
+ string.Empty,
+ string.Empty,
+ sipDomain);
+ }
+
+ public static string GetDisplayName(RegisteredUserAgent registeredUserAgent, string sipDomain)
+ {
+ return GetDisplayName(
+ registeredUserAgent.UserDisplayName,
+ registeredUserAgent.DisplayName,
+ string.Empty,
+ registeredUserAgent.SipUri,
+ string.Empty,
+ string.Empty,
+ sipDomain);
+ }
+
+ public static string GetDisplayName(SipAccount sipAccount, string sipDomain)
+ {
+ return GetDisplayName(
+ sipAccount.DisplayName,
+ string.Empty,
+ string.Empty,
+ sipAccount.UserName,
+ string.Empty,
+ string.Empty,
+ sipDomain);
+ }
- public static string GetDisplayName(string primaryDisplayName, string secondaryDisplayName, string tertiaryDisplayName, string primaryUserName, string secondaryUserName, string tertiaryUserName,
- string homeDomain, string defaultDisplayName = "")
+ public static string GetDisplayName(RegisteredUserAgentDiscovery registeredUserAgentDiscovery, string sipDomain)
+ {
+ return GetDisplayName(
+ registeredUserAgentDiscovery.UserDisplayName,
+ registeredUserAgentDiscovery.DisplayName,
+ string.Empty,
+ registeredUserAgentDiscovery.SipUri,
+ string.Empty,
+ string.Empty,
+ sipDomain);
+ }
+
+ // TODO: make general but better...
+ public static string GetDisplayName(
+ string primaryDisplayName,
+ string secondaryDisplayName,
+ string tertiaryDisplayName,
+ string primaryUserName,
+ string secondaryUserName,
+ string tertiaryUserName,
+ string homeDomain,
+ string defaultDisplayName = "")
{
if (!string.IsNullOrWhiteSpace(primaryDisplayName)) { return primaryDisplayName; }
if (!string.IsNullOrWhiteSpace(secondaryDisplayName)) { return secondaryDisplayName; }
- if (!string.IsNullOrEmpty(tertiaryDisplayName)) { return tertiaryDisplayName; }
+ if (!string.IsNullOrWhiteSpace(tertiaryDisplayName)) { return tertiaryDisplayName; }
if (!string.IsNullOrEmpty(primaryUserName)) { return GetUserNameWithoutHomeDomain(primaryUserName, homeDomain); }
if (!string.IsNullOrEmpty(secondaryUserName)) { return GetUserNameWithoutHomeDomain(secondaryUserName, homeDomain); }
@@ -59,7 +126,7 @@ public static string GetDisplayName(string primaryDisplayName, string secondaryD
private static string GetUserNameWithoutHomeDomain(string userName, string homeDomain)
{
- var domainIndex = userName.IndexOf(string.Format("@{0}", homeDomain), StringComparison.CurrentCulture);
+ var domainIndex = userName.IndexOf($"@{homeDomain}", StringComparison.CurrentCulture);
if (domainIndex > 0)
{
return userName.Remove(domainIndex);
@@ -75,19 +142,17 @@ public static string AnonymizePhonenumber(string s)
}
s = s.Trim();
-
var username = s.LeftOf("@");
-
+ // Phone number
if (username.IsNumeric())
{
- // Phone number
if (username.Length <= 6)
{
// Internal short phone number
- return username;
+ return s;
}
- return Resources.External_Phone_Number;
+ return Resources.Resources.External_Phone_Number;
}
return s;
}
@@ -100,20 +165,16 @@ public static string AnonymizeDisplayName(string s)
}
s = s.Trim();
-
var username = s.LeftOf("@");
-
+ // Phone number
if (username.IsNumeric())
{
- // Phone number
if (username.Length <= 6)
{
// Internal short phone number
- return string.Format("Ank {0}", username);
- // TODO: Resourcify so that it becomes international
+ return $"{Resources.Resources.Internal_Phone_Connection_Prefix} {username}";
}
-
- return Resources.External_Phone_Number;
+ return Resources.Resources.External_Phone_Number;
}
return s;
}
diff --git a/CCM.Core/Helpers/EnumHelper.cs b/CCM.Core/Helpers/EnumHelper.cs
index fbed3256..2a021bd8 100644
--- a/CCM.Core/Helpers/EnumHelper.cs
+++ b/CCM.Core/Helpers/EnumHelper.cs
@@ -24,16 +24,23 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using Microsoft.Extensions.Localization;
using System;
+using System.Collections.Generic;
using System.ComponentModel;
+using System.Reflection;
using System.Resources;
-using CCM.Core.Properties;
+using CCM.Core.Enums;
namespace CCM.Core.Helpers
{
public static class EnumHelper
{
- private static ResourceManager coreResourceManager = new ResourceManager(typeof(Resources));
+ // Tobias tillgg: Denna smller inte men frgan r vad som ska hnda.
+ private static ResourceManager coreResourceManager = new ResourceManager("CCM.Core.Resources.Resources", Assembly.GetExecutingAssembly());
+
+ //private static ResourceManager coreResourceManager = new ResourceManager("Resources.resx", Assembly.GetExecutingAssembly());
+ //private static ResourceManager coreResourceManager = new ResourceManager(typeof(Resources));
public static string DescriptionAsResource(this Enum enumValue)
{
@@ -48,12 +55,25 @@ public static string DescriptionAsResource(this Enum enumValue)
return coreResourceManager.GetString(((DescriptionAttribute)attributes[0]).Description) ?? string.Format($"Update your resource file with resource key in '{enumType.ToString()}'.");
}
- public static string Description(this Enum enumValue)
+ //public static string DefaultDescription(this Enum enumValue)
+ //{
+ // var enumType = enumValue.GetType();
+ // var field = enumType.GetField(enumValue.ToString());
+ // var attributes = field.GetCustomAttributes(typeof(DescriptionAttribute), false);
+ // return attributes.Length == 0 ? enumValue.ToString() : ((DescriptionAttribute)attributes[0]).Description;
+ //}
+
+ public static (string, string) DefaultValue(this Enum enumValue)
{
var enumType = enumValue.GetType();
var field = enumType.GetField(enumValue.ToString());
- var attributes = field.GetCustomAttributes(typeof(DescriptionAttribute), false);
- return attributes.Length == 0 ? enumValue.ToString() : ((DescriptionAttribute)attributes[0]).Description;
+ var attributes = field.GetCustomAttributes(typeof(DefaultSettingAttribute), false);
+
+ if (attributes.Length == 0)
+ {
+ return (enumValue.ToString(), "Unknown description");
+ }
+ return (((DefaultSettingAttribute) attributes[0]).Value, ((DefaultSettingAttribute)attributes[0]).Description);
}
}
}
diff --git a/CCM.Core/Helpers/GuidHelper.cs b/CCM.Core/Helpers/GuidHelper.cs
index dca6daad..f9647f55 100644
--- a/CCM.Core/Helpers/GuidHelper.cs
+++ b/CCM.Core/Helpers/GuidHelper.cs
@@ -30,6 +30,9 @@ namespace CCM.Core.Helpers
{
public static class GuidHelper
{
- public static string GuidString(Guid? guid) { return guid == null || guid == Guid.Empty ? String.Empty : guid.ToString(); }
+ public static string AsString(Guid? guid)
+ {
+ return guid == null || guid == Guid.Empty ? String.Empty : guid.ToString();
+ }
}
}
diff --git a/CCM.Core/Helpers/HttpService.cs b/CCM.Core/Helpers/HttpService.cs
deleted file mode 100644
index a66d304d..00000000
--- a/CCM.Core/Helpers/HttpService.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Net;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using Newtonsoft.Json;
-using NLog;
-
-namespace CCM.Core.Helpers
-{
- // TODO: Remove me if im not in use
- //public class HttpService
- //{
- // protected static readonly Logger Log = LogManager.GetCurrentClassLogger();
-
- // public static async Task GetAsync(Uri url) where T : class
- // {
- // using (var client = new HttpClient())
- // {
- // var response = await client.GetAsync(url);
-
- // if (!response.IsSuccessStatusCode)
- // {
- // Log.Warn("Request to {0} failed.", url);
- // return null;
- // }
- // string jsonString = await response.Content.ReadAsStringAsync();
- // return JsonConvert.DeserializeObject(jsonString);
- // }
- // }
-
- // public static async Task PostJsonAsync(Uri url, object data = null)
- // {
- // using (var client = new HttpClient())
- // {
- // try
- // {
- // HttpContent content = null;
- // if (data != null)
- // {
- // var s = JsonConvert.SerializeObject(data);
- // content = new StringContent(s, Encoding.UTF8, "application/json");
- // }
- // return await client.PostAsync(url, content);
- // }
- // catch (Exception)
- // {
- // return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
- // }
- // }
- // }
-
- //}
-}
diff --git a/CCM.Core/Helpers/TimeMeasurer.cs b/CCM.Core/Helpers/TimeMeasurer.cs
index 1e884f9d..87da7aa6 100644
--- a/CCM.Core/Helpers/TimeMeasurer.cs
+++ b/CCM.Core/Helpers/TimeMeasurer.cs
@@ -1,110 +1,110 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Diagnostics;
-using System.Linq;
-using NLog;
-using NLog.Config;
-
-namespace CCM.Core.Helpers
-{
- public class TimeMeasurer : IDisposable
- {
- protected static readonly Logger LogSystem = LogManager.GetCurrentClassLogger();
- private readonly LogLevel _level;
- private readonly Stopwatch _stopwatch;
- private readonly string _message;
- private readonly bool _isEnabled;
-
- public TimeMeasurer(string message, bool logStartMessage = false, LogLevel level = null)
- {
- _level = level ?? LogLevel.Debug;
-
- LoggingRule rule = LogManager.Configuration.LoggingRules.FirstOrDefault();
- _isEnabled = rule != null && rule.IsLoggingEnabledForLevel(_level);
-
- if (_isEnabled)
- {
- _message = message;
-
- if (logStartMessage)
- {
- string s = string.Format("BEGIN:{0}", _message);
- Log(s);
- }
-
- _stopwatch = new Stopwatch();
- _stopwatch.Start();
- }
- }
-
- private void Log(string s)
- {
- LogSystem.Log(_level, s);
-
- if (_level <= LogLevel.Debug)
- {
- Debug.WriteLine(s);
- }
- }
-
- public TimeSpan ElapsedTime
- {
- get
- {
- return _isEnabled ? _stopwatch.Elapsed : TimeSpan.Zero;
- }
- }
-
- public void Dispose()
- {
-
- Dispose(true);
- // Use SupressFinalize in case a subclass
- // of this type implements a finalizer.
- GC.SuppressFinalize(this);
- }
-
- // The bulk of the clean-up code is implemented in Dispose(bool)
- protected virtual void Dispose(bool disposing)
- {
- if (_isEnabled)
- {
- _stopwatch.Stop();
- TimeSpan runTime = _stopwatch.Elapsed;
-
- string runTimeString = runTime.TotalSeconds > 1
- ? string.Format("{0} s", runTime.TotalSeconds)
- : string.Format("{0} ms", runTime.TotalMilliseconds);
-
- var formattedString = string.Format("END:{0} [{1}]", _message, runTimeString);
- Log(formattedString);
- }
-
- }
- }
-}
+///*
+// * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
+// *
+// * Redistribution and use in source and binary forms, with or without
+// * modification, are permitted provided that the following conditions
+// * are met:
+// * 1. Redistributions of source code must retain the above copyright
+// * notice, this list of conditions and the following disclaimer.
+// * 2. Redistributions in binary form must reproduce the above copyright
+// * notice, this list of conditions and the following disclaimer in the
+// * documentation and/or other materials provided with the distribution.
+// * 3. The name of the author may not be used to endorse or promote products
+// * derived from this software without specific prior written permission.
+// *
+// * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+// * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+// * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+// * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+// * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+// * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+// * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// */
+
+//using System;
+//using System.Diagnostics;
+//using System.Linq;
+//using NLog;
+//using NLog.Config;
+
+//namespace CCM.Core.Helpers
+//{
+// public class TimeMeasurer : IDisposable
+// {
+// protected static readonly Logger LogSystem = LogManager.GetCurrentClassLogger();
+// private readonly LogLevel _level;
+// private readonly Stopwatch _stopwatch;
+// private readonly string _message;
+// private readonly bool _isEnabled;
+
+// public TimeMeasurer(string message, bool logStartMessage = false, LogLevel level = null)
+// {
+// _level = level ?? LogLevel.Debug;
+
+// LoggingRule rule = LogManager.Configuration.LoggingRules.FirstOrDefault();
+// _isEnabled = rule != null && rule.IsLoggingEnabledForLevel(_level);
+
+// if (_isEnabled)
+// {
+// _message = message;
+
+// if (logStartMessage)
+// {
+// string s = string.Format("BEGIN:{0}", _message);
+// Log(s);
+// }
+
+// _stopwatch = new Stopwatch();
+// _stopwatch.Start();
+// }
+// }
+
+// private void Log(string s)
+// {
+// LogSystem.Log(_level, s);
+
+// if (_level <= LogLevel.Debug)
+// {
+// Debug.WriteLine(s);
+// }
+// }
+
+// public TimeSpan ElapsedTime
+// {
+// get
+// {
+// return _isEnabled ? _stopwatch.Elapsed : TimeSpan.Zero;
+// }
+// }
+
+// public void Dispose()
+// {
+
+// Dispose(true);
+// // Use SupressFinalize in case a subclass
+// // of this type implements a finalizer.
+// GC.SuppressFinalize(this);
+// }
+
+// // The bulk of the clean-up code is implemented in Dispose(bool)
+// protected virtual void Dispose(bool disposing)
+// {
+// if (_isEnabled)
+// {
+// _stopwatch.Stop();
+// TimeSpan runTime = _stopwatch.Elapsed;
+
+// string runTimeString = runTime.TotalSeconds > 1
+// ? string.Format("{0} s", runTime.TotalSeconds)
+// : string.Format("{0} ms", runTime.TotalMilliseconds);
+
+// var formattedString = string.Format("END:{0} [{1}]", _message, runTimeString);
+// Log(formattedString);
+// }
+
+// }
+// }
+//}
diff --git a/CCM.Core/Interfaces/IDiscoveryService.cs b/CCM.Core/Interfaces/IDiscoveryServiceManager.cs
similarity index 97%
rename from CCM.Core/Interfaces/IDiscoveryService.cs
rename to CCM.Core/Interfaces/IDiscoveryServiceManager.cs
index 7b603ef8..c205ed99 100644
--- a/CCM.Core/Interfaces/IDiscoveryService.cs
+++ b/CCM.Core/Interfaces/IDiscoveryServiceManager.cs
@@ -29,7 +29,7 @@
namespace CCM.Core.Interfaces
{
- public interface IDiscoveryService
+ public interface IDiscoveryServiceManager
{
UserAgentsResultDto GetUserAgents(string caller, string callee, IList> filters, bool includeCodecsInCall = false);
List GetProfiles();
diff --git a/CCM.Core/Interfaces/Managers/IExternalStoreMessageManager.cs b/CCM.Core/Interfaces/Managers/IExternalStoreMessageManager.cs
new file mode 100644
index 00000000..29f7f452
--- /dev/null
+++ b/CCM.Core/Interfaces/Managers/IExternalStoreMessageManager.cs
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using CCM.Core.SipEvent;
+using CCM.Core.SipEvent.Messages;
+using CCM.Core.SipEvent.Models;
+
+namespace CCM.Core.Interfaces.Managers
+{
+ public interface IExternalStoreMessageManager
+ {
+ SipEventHandlerResult HandleDialog(ExternalDialogMessage dialogMessage);
+ }
+}
diff --git a/CCM.Core/Interfaces/Managers/IRegisteredSipsManager.cs b/CCM.Core/Interfaces/Managers/IRegisteredCodecsManager.cs
similarity index 97%
rename from CCM.Core/Interfaces/Managers/IRegisteredSipsManager.cs
rename to CCM.Core/Interfaces/Managers/IRegisteredCodecsManager.cs
index 6073a15b..9a3c5e4a 100644
--- a/CCM.Core/Interfaces/Managers/IRegisteredSipsManager.cs
+++ b/CCM.Core/Interfaces/Managers/IRegisteredCodecsManager.cs
@@ -29,7 +29,7 @@
namespace CCM.Core.Interfaces.Managers
{
- public interface IRegisteredSipsManager
+ public interface IRegisteredCodecsManager
{
IEnumerable GetRegisteredUserAgentsAndProfiles();
}
diff --git a/CCM.Core/Interfaces/Managers/ISettingsManager.cs b/CCM.Core/Interfaces/Managers/ISettingsManager.cs
index 30432681..d3d5d119 100644
--- a/CCM.Core/Interfaces/Managers/ISettingsManager.cs
+++ b/CCM.Core/Interfaces/Managers/ISettingsManager.cs
@@ -40,5 +40,12 @@ public interface ISettingsManager
bool CodecControlActive { get; }
bool UseOldKamailioEvent { get; }
bool UseSipEvent { get; }
+ string UserAgentImagesFolder { get; }
+ string DiscoveryServiceUrl { get; }
+ string CodecControlHost { get; }
+ string CodecControlUserName { get; }
+ string CodecControlPassword { get; }
+ int CacheTimeLiveData { get; }
+ int CacheTimeConfigData { get; }
}
}
diff --git a/CCM.Core/Interfaces/Managers/ISipAccountManager.cs b/CCM.Core/Interfaces/Managers/ISipAccountManager.cs
deleted file mode 100644
index 3471eaec..00000000
--- a/CCM.Core/Interfaces/Managers/ISipAccountManager.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2018 Sveriges Radio AB, Stockholm, Sweden
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Collections.Generic;
-using CCM.Core.Entities;
-
-namespace CCM.Core.Interfaces.Managers
-{
- public interface ISipAccountManager
- {
- SipAccount GetById(Guid userId);
- SipAccount GetByUserName(string userName);
- SipAccount GetByRegisteredSip(Guid registeredSipId);
- SipAccount GetSipAccountByUserName(string username);
- List GetAll();
- List Find(string startsWith);
- void Create(SipAccount account);
- void Update(SipAccount account);
- void UpdatePassword(Guid id, string password);
- void UpdateComment(Guid id, string comment);
- bool Delete(Guid id);
- }
-}
diff --git a/CCM.Core/Interfaces/Managers/ISipMessageManager.cs b/CCM.Core/Interfaces/Managers/ISipMessageManager.cs
index 0d34f9d4..9708092b 100644
--- a/CCM.Core/Interfaces/Managers/ISipMessageManager.cs
+++ b/CCM.Core/Interfaces/Managers/ISipMessageManager.cs
@@ -26,6 +26,7 @@
using CCM.Core.SipEvent;
using CCM.Core.SipEvent.Messages;
+using CCM.Core.SipEvent.Models;
namespace CCM.Core.Interfaces.Managers
{
diff --git a/CCM.Core/Interfaces/Managers/IStatisticsManager.cs b/CCM.Core/Interfaces/Managers/IStatisticsManager.cs
index ff0dc70a..aaca9af5 100644
--- a/CCM.Core/Interfaces/Managers/IStatisticsManager.cs
+++ b/CCM.Core/Interfaces/Managers/IStatisticsManager.cs
@@ -34,14 +34,19 @@ namespace CCM.Core.Interfaces.Managers
public interface IStatisticsManager
{
List GetCodecTypes();
- List GetLocationStatistics(DateTime startTime, DateTime endTime, Guid regionId, Guid ownerId, Guid codecTypeId);
List GetOwners();
List GetRegions();
- List GetRegionStatistics(DateTime startDate, DateTime endDate, Guid regionId);
- List GetSipUsers();
- List GetSipStatistics(DateTime startDate, DateTime endDate, Guid userId);
- IList GetCodecTypeStatistics(DateTime startDate, DateTime endDate, Guid codecTypeId);
+ List GetSipAccounts();
IList GetLocationsForRegion(Guid regionId);
- HourBasedStatisticsForLocation GetHourStatisticsForLocation(DateTime startTime, DateTime endTime, Guid locationId, bool noAggregation);
+
+ List GetLocationStatistics(DateTime startDate, DateTime endDate, Guid regionId, Guid ownerId, Guid codecTypeId);
+ HourBasedStatisticsForLocation GetHourStatisticsForLocation(DateTime startDate, DateTime endDate, Guid locationId, bool noAggregation);
+
+ IList GetRegionStatistics(DateTime startDate, DateTime endDate, Guid regionId);
+ IList GetSipAccountStatistics(DateTime startDate, DateTime endDate, Guid userId);
+ IList GetCodecTypeStatistics(DateTime startDate, DateTime endDate, Guid codecTypeId);
+
+ IList GetCategoryCallStatistics(DateTime startDate, DateTime endDate);
+ IList GetCategoryStatistics(DateTime startDate, DateTime endDate);
}
}
diff --git a/CCM.Core/Interfaces/Kamailio/IKamailioMessageParser.cs b/CCM.Core/Interfaces/Parser/IKamailioEventParser.cs
similarity index 94%
rename from CCM.Core/Interfaces/Kamailio/IKamailioMessageParser.cs
rename to CCM.Core/Interfaces/Parser/IKamailioEventParser.cs
index ea00025b..5ef3c91c 100644
--- a/CCM.Core/Interfaces/Kamailio/IKamailioMessageParser.cs
+++ b/CCM.Core/Interfaces/Parser/IKamailioEventParser.cs
@@ -26,9 +26,9 @@
using CCM.Core.SipEvent.Messages;
-namespace CCM.Core.Interfaces.Kamailio
+namespace CCM.Core.Interfaces.Parser
{
- public interface IKamailioMessageParser
+ public interface IKamailioEventParser
{
SipMessageBase Parse(string message);
}
diff --git a/CCM.Core/Interfaces/Kamailio/ISipEventParser.cs b/CCM.Core/Interfaces/Parser/ISipEventParser.cs
similarity index 92%
rename from CCM.Core/Interfaces/Kamailio/ISipEventParser.cs
rename to CCM.Core/Interfaces/Parser/ISipEventParser.cs
index d535671c..123b2fb7 100644
--- a/CCM.Core/Interfaces/Kamailio/ISipEventParser.cs
+++ b/CCM.Core/Interfaces/Parser/ISipEventParser.cs
@@ -24,13 +24,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using CCM.Core.SipEvent;
+using CCM.Core.SipEvent.Event;
using CCM.Core.SipEvent.Messages;
-namespace CCM.Core.Interfaces.Kamailio
+namespace CCM.Core.Interfaces.Parser
{
public interface ISipEventParser
{
- SipMessageBase Parse(KamailioSipEvent sipEvent);
+ SipMessageBase Parse(KamailioSipEventData sipEventData);
}
}
\ No newline at end of file
diff --git a/CCM.Core/Interfaces/Repositories/ICallHistoryRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedCallHistoryRepository.cs
similarity index 57%
rename from CCM.Core/Interfaces/Repositories/ICallHistoryRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedCallHistoryRepository.cs
index 09d91846..d80f6c67 100644
--- a/CCM.Core/Interfaces/Repositories/ICallHistoryRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedCallHistoryRepository.cs
@@ -31,17 +31,43 @@
namespace CCM.Core.Interfaces.Repositories
{
- public interface ICallHistoryRepository
+ public interface ICachedCallHistoryRepository
{
bool Save(CallHistory callHistory);
CallHistory GetById(Guid id);
CallHistory GetCallHistoryByCallId(Guid callId);
- IList GetOldCalls(int callCount, bool anonymize);
- IList GetOldCallsFiltered(string region, string codecType, string sipAddress, string searchString, bool anonymize, bool onlyPhoneCalls, int callCount);
+ IList GetOldCalls(int callCount);
+ IList GetOldCallsFiltered(string region, string codecType, string sipAddress, string searchString, bool onlyPhoneCalls, int callCount, bool limitByMonth);
+
+ IList GetCallHistoriesByDate(DateTime startDate, DateTime endDate);
+ IList GetCallHistoriesForRegion(DateTime startDate, DateTime endDate, Guid regionId);
+ IList GetCallHistoriesForRegisteredSip(DateTime startDate, DateTime endDate, string sipId);
+ IList GetCallHistoriesForCodecType(DateTime startDate, DateTime endDate, Guid codecTypeId);
+ IList GetCallHistoriesForLocation(DateTime startDate, DateTime endDate, Guid locationId);
+ }
+
+ public interface ICallHistoryRepository
+ {
+ bool Save(CallHistory callHistory);
+ CallHistory GetById(Guid id);
+ IReadOnlyCollection GetOneMonthOldCalls();
+ IReadOnlyCollection GetOneMonthCallHistories();
+
+ IReadOnlyList GetOneYearCallHistory();
+
IList GetCallHistoriesByDate(DateTime startTime, DateTime endTime);
+ IList GetCallHistoriesByDate(IReadOnlyList callHistories, DateTime startTime, DateTime endTime);
+
IList GetCallHistoriesForRegion(DateTime startDate, DateTime endDate, Guid regionId);
+ IList GetCallHistoriesForRegion(IReadOnlyList callHistories, DateTime startDate, DateTime endDate, Guid regionId);
+
IList GetCallHistoriesForRegisteredSip(DateTime startDate, DateTime endDate, string sipId);
+ IList GetCallHistoriesForRegisteredSip(IReadOnlyList callHistories, DateTime startDate, DateTime endDate, string sipId);
+
IList GetCallHistoriesForCodecType(DateTime startDate, DateTime endDate, Guid codecTypeId);
+ IList GetCallHistoriesForCodecType(IReadOnlyList callHistories, DateTime startDate, DateTime endDate, Guid codecTypeId);
+
IList GetCallHistoriesForLocation(DateTime startDate, DateTime endDate, Guid locationId);
+ IList GetCallHistoriesForLocation(IReadOnlyList callHistories, DateTime startDate, DateTime endDate, Guid locationId);
}
}
diff --git a/CCM.Core/Interfaces/Repositories/ICallRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedCallRepository.cs
similarity index 78%
rename from CCM.Core/Interfaces/Repositories/ICallRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedCallRepository.cs
index e4ec5a44..258006c0 100644
--- a/CCM.Core/Interfaces/Repositories/ICallRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedCallRepository.cs
@@ -31,9 +31,22 @@
namespace CCM.Core.Interfaces.Repositories
{
+ public interface ICachedCallRepository
+ {
+ IReadOnlyCollection GetOngoingCalls(bool anonymize);
+ OnGoingCall GetOngoingCallById(Guid callId);
+ bool CallExists(string callId, string hashId, string hashEnt);
+ void UpdateCall(Call call);
+ void CloseCall(Guid callId);
+ Call GetCallBySipAddress(string sipAddress);
+ CallInfo GetCallInfo(string callId, string hashId, string hashEnt);
+ CallInfo GetCallInfoById(Guid callId);
+ }
+
public interface ICallRepository
{
IReadOnlyCollection GetOngoingCalls(bool anonymize);
+ OnGoingCall GetOngoingCallById(Guid callId);
bool CallExists(string callId, string hashId, string hashEnt);
void UpdateCall(Call call);
void CloseCall(Guid callId);
diff --git a/CCM.Core/Interfaces/Repositories/ILocationRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedLocationRepository.cs
similarity index 83%
rename from CCM.Core/Interfaces/Repositories/ILocationRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedLocationRepository.cs
index c2354616..8cc9eecb 100644
--- a/CCM.Core/Interfaces/Repositories/ILocationRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedLocationRepository.cs
@@ -24,7 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
+using System;
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
@@ -32,10 +32,19 @@
namespace CCM.Core.Interfaces.Repositories
{
+ public interface ICachedLocationRepository : IRepository
+ {
+ List FindLocations(string searchString);
+ List GetAllLocationNetworks();
+ Dictionary GetLocationsAndProfiles();
+ List GetAllLocationInfo();
+ }
+
public interface ILocationRepository : IRepository
{
List FindLocations(string searchString);
List GetAllLocationNetworks();
Dictionary GetLocationsAndProfiles();
+ List GetAllLocationInfo();
}
}
diff --git a/CCM.Core/Interfaces/Repositories/IProfileGroupRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedProfileGroupRepository.cs
similarity index 88%
rename from CCM.Core/Interfaces/Repositories/IProfileGroupRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedProfileGroupRepository.cs
index 9eca65c9..ad82ca26 100644
--- a/CCM.Core/Interfaces/Repositories/IProfileGroupRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedProfileGroupRepository.cs
@@ -31,8 +31,13 @@
namespace CCM.Core.Interfaces.Repositories
{
+ public interface ICachedProfileGroupRepository : IRepository
+ {
+ List FindProfileGroups(string search);
+ }
+
public interface IProfileGroupRepository : IRepository
{
- void SetProfileGroupSortWeight(IList> profileGroupTuples);
+ List FindProfileGroups(string search);
}
}
diff --git a/CCM.Core/Interfaces/Repositories/IProfileRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedProfileRepository.cs
similarity index 77%
rename from CCM.Core/Interfaces/Repositories/IProfileRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedProfileRepository.cs
index fb41fb5b..78d90897 100644
--- a/CCM.Core/Interfaces/Repositories/IProfileRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedProfileRepository.cs
@@ -24,7 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-using System;
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.Entities.Specific;
@@ -32,11 +31,19 @@
namespace CCM.Core.Interfaces.Repositories
{
- public interface IProfileRepository : IRepository
+ public interface ICachedProfileRepository : IRepository
{
- List FindProfiles(string searchString);
+ List FindProfiles(string searchString);
IList GetAllProfileNamesAndSdp();
IList GetAllProfileInfos();
- void SetProfileSortIndex(IList> profileTuples);
+ IReadOnlyCollection GetFullDetails();
+ }
+
+ public interface IProfileRepository : IRepository
+ {
+ List FindProfiles(string searchString);
+ IList GetAllProfileNamesAndSdp();
+ IList GetAllProfileInfos();
+ IReadOnlyCollection GetFullDetails();
}
}
diff --git a/CCM.Core/Interfaces/Repositories/IRegisteredSipRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedRegisteredCodecRepository.cs
similarity index 73%
rename from CCM.Core/Interfaces/Repositories/IRegisteredSipRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedRegisteredCodecRepository.cs
index 9bf9d027..4bf601df 100644
--- a/CCM.Core/Interfaces/Repositories/IRegisteredSipRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedRegisteredCodecRepository.cs
@@ -27,15 +27,27 @@
using System.Collections.Generic;
using CCM.Core.Entities;
using CCM.Core.SipEvent;
+using CCM.Core.SipEvent.Models;
namespace CCM.Core.Interfaces.Repositories
{
- public interface IRegisteredSipRepository
+ public interface ICachedRegisteredCodecRepository
{
SipEventHandlerResult UpdateRegisteredSip(UserAgentRegistration registration);
IEnumerable GetRegisteredUserAgentsDiscovery();
IEnumerable GetRegisteredUserAgents();
SipEventHandlerResult DeleteRegisteredSip(string sipAddress);
IEnumerable GetRegisteredUserAgentsCodecInformation();
+ IEnumerable GetRegisteredCodecsUpdateTimes();
+ }
+
+ public interface IRegisteredCodecRepository
+ {
+ SipEventHandlerResult UpdateRegisteredSip(UserAgentRegistration registration);
+ IEnumerable GetRegisteredUserAgentsDiscovery();
+ IEnumerable GetRegisteredUserAgents();
+ SipEventHandlerResult DeleteRegisteredSip(string sipAddress);
+ IEnumerable GetRegisteredUserAgentsCodecInformation();
+ IEnumerable GetRegisteredCodecsUpdateTimes();
}
}
diff --git a/CCM.Core/Interfaces/Repositories/ISettingsRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedSettingsRepository.cs
similarity index 91%
rename from CCM.Core/Interfaces/Repositories/ISettingsRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedSettingsRepository.cs
index 06b841a9..2ef31ed8 100644
--- a/CCM.Core/Interfaces/Repositories/ISettingsRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedSettingsRepository.cs
@@ -29,6 +29,12 @@
namespace CCM.Core.Interfaces.Repositories
{
+ public interface ICachedSettingsRepository
+ {
+ List GetAll();
+ void Save(List settings, string userName);
+ }
+
public interface ISettingsRepository
{
List GetAll();
diff --git a/CCM.Core/Interfaces/Repositories/ISipAccountRepository.cs b/CCM.Core/Interfaces/Repositories/ICachedSipAccountRepository.cs
similarity index 69%
rename from CCM.Core/Interfaces/Repositories/ISipAccountRepository.cs
rename to CCM.Core/Interfaces/Repositories/ICachedSipAccountRepository.cs
index 6bed64d2..01a10702 100644
--- a/CCM.Core/Interfaces/Repositories/ISipAccountRepository.cs
+++ b/CCM.Core/Interfaces/Repositories/ICachedSipAccountRepository.cs
@@ -28,22 +28,35 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using CCM.Core.Entities;
+using CCM.Core.Interfaces.Repositories.Base;
namespace CCM.Core.Interfaces.Repositories
{
- public interface ISipAccountRepository
+ public interface ICachedSipAccountRepository : IRepository