/
AppStatistics.cs
74 lines (65 loc) · 2.84 KB
/
AppStatistics.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace Tizen.Context.AppHistory
{
/// <summary>
/// The Base class for application statistics.
/// </summary>
/// <since_tizen> 4 </since_tizen>
public abstract class AppStatistics
{
internal const string AppStatsQueryResult = "QueryResult";
internal const string AppStatsStartTime = "StartTime";
internal const string AppStatsEndTime = "EndTime";
internal const string AppStatsResultSize = "ResultSize";
internal const string AppStatsAppId = "AppId";
internal const int DefaultResultSize = 10;
internal string Uri;
internal AppStatistics()
{
}
internal static long ConvertDateTimeToUnixTimestamp(DateTime dateTime)
{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
long unixTimestampInTicks = (dateTime.ToUniversalTime() - unixStart).Ticks;
return unixTimestampInTicks / TimeSpan.TicksPerSecond;
}
internal static DateTime ConvertUnixTimestampToDateTime(long unixTime)
{
DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
long unixTimeStampInTicks = unixTime * TimeSpan.TicksPerSecond;
return new DateTime(unixStart.Ticks + unixTimeStampInTicks, System.DateTimeKind.Utc).ToLocalTime();
}
internal static void CheckTimeSpan(DateTime startTime, DateTime endTime)
{
if (startTime > endTime)
{
Log.Error(AppHistoryErrorFactory.LogTag, "endTime should be greater than startTime");
throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "endTime should be greater than startTime");
}
}
internal static void CheckResultSize(uint resultSize)
{
if (resultSize <= 0)
{
Log.Error(AppHistoryErrorFactory.LogTag, "resultSize should be greater than 0");
throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "resultSize should be greater than 0");
}
}
internal abstract string ConvertSortOrderToString(int order);
}
}