Exemple #1
0
        private string CreateJsonObject(ProgressEvent progressEvent, string attemptName)
        {
            var kataStartTime       = progressEvent.KataStartTime;
            var attemptCreationTime = GetAttemptCreationTime(attemptName);

            if (kataStartTime == DateTime.MinValue)
            {
                kataStartTime = attemptCreationTime;
            }
            return(JsonConvert.SerializeObject(new
            {
                userName = GetUserName(),
                attemptName,
                timestamp = GetTimestamp(),
                attemptCreationTime,
                kataStartTime,
                appVersion = GetAppVersion(),
                kataName = _kataHelper.GetKataName(attemptName),
                progressEvent
            }, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
Exemple #2
0
        private AttemptLog CreateAttemptLog(ISpunkSearchLog spunkSearchLog)
        {
            var attemptLog = new AttemptLog
            {
                AttemptName     = spunkSearchLog.AttemptName,
                UserName        = spunkSearchLog.UserName,
                KataName        = _kataHelper.GetKataName(spunkSearchLog.AttemptName),
                AttemptDate     = Convert.ToDateTime(spunkSearchLog.KataStartTime),
                LengthInMinutes = Math.Round(Convert.ToDecimal(spunkSearchLog.TotalDuration) / 60, 2,
                                             MidpointRounding.AwayFromZero),
                HighestLevelAchieved = Convert.ToInt32(spunkSearchLog.HighestLevelAchieved)
            };
            var kataMaxLevel = _kataHelper.GetKataMaxLevel(attemptLog.KataName);

            if (kataMaxLevel != 0)
            {
                attemptLog.PercentCompleted = Math.Round((Convert.ToDecimal(attemptLog.HighestLevelAchieved) / kataMaxLevel * 100), 2,
                                                         MidpointRounding.AwayFromZero);
            }
            if (spunkSearchLog.TotalDuration == null)
            {
                SetDuration(spunkSearchLog, attemptLog);
            }
            if (attemptLog.HighestLevelAchieved == kataMaxLevel)
            {
                attemptLog.Completed = true;
            }
            return(attemptLog);
        }