Example #1
0
        /// <summary>
        /// Create new action log.
        /// </summary>
        /// <param name="action">Action</param>
        /// <param name="authorId">Author</param>
        public void CreateLog(string action, string authorId)
        {
            ActionLogDTO log = new ActionLogDTO()
            {
                Action   = action,
                Time     = DateTime.Now,
                AuthorId = authorId
            };

            _logService.CreateActionLog(log);
        }
Example #2
0
 /// <summary>
 /// Save action log.
 /// </summary>
 /// <param name="log">Action log object</param>
 public void CreateActionLog(ActionLogDTO log)
 {
     try
     {
         var newLog = _logMapperDTO.ToActionLog.Map <ActionLogDTO, ActionLog>(log);
         _logUnitOfWork.ActionLogger.Create(newLog);
         _logUnitOfWork.Save();
     }
     catch
     {
     }
 }
Example #3
0
        // see requestActionLogList in gtmode.ad
        private async Task <ActionResult> OnActionPutLog(Player player, GrimRequest gRequest)
        {
            if (!gRequest.TryGetParameterByKey("action_type", out var actionTypeParam) || !int.TryParse(actionTypeParam.Text, out int action_type))
            {
                _logger.LogWarning($"Got actionlog.putActionLog request with missing 'action_type' parameter");
                return(BadRequest());
            }
            if (!gRequest.TryGetParameterByKey("value1", out var value1Param))
            {
                _logger.LogWarning($"Got actionlog.putActionLog request with missing 'value1' parameter");
                return(BadRequest());
            }
            if (!gRequest.TryGetParameterByKey("value2", out var value2Param))
            {
                _logger.LogWarning($"Got actionlog.putActionLog request with missing 'value2' parameter");
                return(BadRequest());
            }
            if (!gRequest.TryGetParameterByKey("value3", out var value3Param))
            {
                _logger.LogWarning($"Got actionlog.putActionLog request with missing 'value3' parameter");
                return(BadRequest());
            }
            if (!gRequest.TryGetParameterByKey("value4", out var value4Param))
            {
                _logger.LogWarning($"Got actionlog.putActionLog request with missing 'value4' parameter");
                return(BadRequest());
            }
            if (!gRequest.TryGetParameterByKey("value5", out var value5Param))
            {
                _logger.LogWarning($"Got actionlog.putActionLog request with missing 'value5' parameter");
                return(BadRequest());
            }

            if (!ActionLog.Tags.TryGetValue(value1Param.Text, out string def))
            {
                return(Ok());
            }

            // TODO: Some actionlog checks
            LogAction(player, def, value2Param.Text, value3Param.Text, value4Param.Text, value5Param.Text);

            var log = new ActionLogDTO(player.Data.Id, DateTime.Now, value1Param.Text, value2Param.Text,
                                       value3Param.Text, value4Param.Text, value5Param.Text);

            await _actionLogDb.AddAsync(log);

            return(Ok(GrimResult.FromBool(true)));
        }