Beispiel #1
0
        public async Task <JsonResult> MakeOperation(string operationName, int arg1, int arg2)
        {
            var operationCreator = _operationService.GetCreatorByOperationName(operationName);

            if (operationCreator == null)
            {
                return(Json(new { result = "" }));
            }
            var operation = operationCreator.CreateOperation();
            var result    = operation.Execute(arg1, arg2);
            var storeKey  = await _storage.SaveResultToStorage(result);

            if (_logger != null)
            {
                await _logger.WriteOperationLogAsync(OperationLogParameter.Create(operation, arg1, arg2, result, HttpContext?.Session?.SessionID));
            }
            return(Json(new { StoreResultKey = storeKey }));
        }
Beispiel #2
0
 public Task WriteOperationLogAsync(OperationLogParameter parameters)
 {
     return(Task.Run(() => {
         if (_writer != null)
         {
             lock (_locker) {
                 if (_writer != null)
                 {
                     _writer.WriteLine($"{DateTime.Now} {parameters.SessionId} - {parameters.Argument1} {parameters.Operation.OperationName} {parameters.Argument2} = {parameters.OperationResult}");
                     if (++_rowCount == 5)
                     {
                         _writer.Flush();
                         _rowCount = 0;
                     }
                 }
             }
         }
     }));
 }