private static void LogOperation(OperationCodes operationCode, ApiController controller) { if (controller.Request.Method == HttpMethod.Get) { return; } var repo = RepositoryManager.GetRepository <ISysOperationLogRepository>(); var operationLog = new SysOperationLog() { OperationCode = operationCode.ToString(), OperationName = operationCode.GetDescription(), Detail = string.Format("{0} {1}", controller.Request.Method, controller.Request.RequestUri), CreateDate = DateTime.Now, }; var identify = controller.User.Identity as BasicAuthenticationIdentity; if (identify != null) { operationLog.UserID = identify.AuthorizationOperatorInfo.OperatorID; operationLog.UserName = identify.Name; } repo.Insert(operationLog); }