private void SetResponseHttpStatus(HttpStatusCode statusCode)
        {
#if NETSTANDARD2_0 // TODO CRM-47230
            HttpContext context = HttpContext.Current;
#else
            WebOperationContext context = WebOperationContext.Current;
#endif
            if (context == null)
            {
                return;
            }
#if NETSTANDARD2_0 // TODO CRM-47230
            var response = context.Response;
            response.StatusCode = (int)statusCode;
#else
            OutgoingWebResponseContext outgoingResponse = context.OutgoingResponse;
            outgoingResponse.StatusCode = statusCode;
#endif
        }
        public BaseResponse UploadReportTemplate(Stream fileContent)
        {
            HttpContext     httpContext    = HttpContextAccessor.GetInstance();
            string          reportId       = httpContext.Request.QueryString["reportId"];
            Guid            report         = new Guid(reportId);
            IFileUploadInfo fileUploadInfo = GetFileUploadInfo(fileContent);
            decimal         maxFileSize    = GetMaxFileSizeFromSysSettings();
            var             uploadSettings = new FileUploadConfig(fileUploadInfo)
            {
                SetCustomColumnsFromConfig = false,
                MaxFileSize = maxFileSize
            };

            try {
                FileUploader.UploadFile(uploadSettings);
                if (IsLastChunk(uploadSettings.ByteRange))
                {
                    Stream template = ReportWorker.ValidateTemplate(uploadSettings.FileId);
                    ReportWorker.SaveTemplate(template, report);
                    SetResponseHttpStatus(HttpStatusCode.Created);
                }
            } catch (ArgumentException ex) {
                SetResponseHttpStatus(HttpStatusCode.InternalServerError);
                return(GetResponse(false, (int)HttpStatusCode.NotAcceptable));
            } catch (ItemNotFoundException ex) {
                SetResponseHttpStatus(HttpStatusCode.InternalServerError);
                return(GetResponse(false, (int)HttpStatusCode.NotFound));
            } catch (MaxFileSizeExceededException ex) {
                SetResponseHttpStatus(HttpStatusCode.LengthRequired);
                return(GetResponse(false, (int)HttpStatusCode.LengthRequired, ConvertBytesToMb(uploadSettings.MaxFileSize)));
            } catch (Exception ex) {
                SetResponseHttpStatus(HttpStatusCode.InternalServerError);
                return(GetResponse(false, (int)HttpStatusCode.MethodNotAllowed));
            }
            return(GetResponse(true, null));
        }