Пример #1
0
        public PowerShellResults ProcessFileUploadRequest(HttpContext httpContext)
        {
            HttpPostedFile httpPostedFile = httpContext.Request.Files["uploadFile"];

            if (httpPostedFile != null && !string.IsNullOrEmpty(httpPostedFile.FileName) && httpPostedFile.ContentLength > 0)
            {
                string         text          = httpContext.Request.Form["handlerClass"];
                IUploadHandler uploadHandler = this.CreateInstance(text);
                if (httpPostedFile.ContentLength <= uploadHandler.MaxFileSize)
                {
                    string            text2   = httpContext.Request.Form["parameters"];
                    object            obj     = text2.JsonDeserialize(uploadHandler.SetParameterType, null);
                    UploadFileContext context = new UploadFileContext(httpPostedFile.FileName, httpPostedFile.InputStream);
                    try
                    {
                        EcpEventLogConstants.Tuple_UploadRequestStarted.LogEvent(new object[]
                        {
                            EcpEventLogExtensions.GetUserNameToLog(),
                            text,
                            text2
                        });
                        return(uploadHandler.ProcessUpload(context, (WebServiceParameters)obj));
                    }
                    finally
                    {
                        EcpEventLogConstants.Tuple_UploadRequestCompleted.LogEvent(new object[]
                        {
                            EcpEventLogExtensions.GetUserNameToLog()
                        });
                    }
                }
                ByteQuantifiedSize byteQuantifiedSize = new ByteQuantifiedSize((ulong)((long)uploadHandler.MaxFileSize));
                throw new HttpException(Strings.FileExceedsLimit(byteQuantifiedSize.ToString()));
            }
            throw new HttpException(Strings.UploadFileCannotBeEmpty);
        }
Пример #2
0
 public ByteQuantifiedSizeSurrogate(ByteQuantifiedSize byteQuantifiedSize)
 {
     this.canonical = byteQuantifiedSize.ToString();
 }