HttpApplication Application1 = sender as HttpApplication; HttpWorkerRequest request1 = (HttpWorkerRequest) ((IServiceProvider) httpcontext.current). GetService (typeof (HttpWorkerRequest)); Try { if (Application1. Context.Request.ContentType.IndexOf ("Multipart/form-data") <=-1) { Return } Check the Hasentitybody if (!request1. Hasentitybody ()) { Return } int NUM1 = 0; TimeSpan span1 = DateTime.Now.Subtract (this.begintime);
String Text1 = Application1. Context.Request.ContentType.ToLower ();
byte[] Buffer1 = Encoding.ASCII.GetBytes ("\r\n--" + Text1. Substring (Text1. IndexOf ("boundary=") + 9). ToCharArray ()); int num2 = Convert.ToInt32 (request1. Getknownrequestheader (11)); Progress Progress1 = new Progress ();
Application1. CONTEXT.ITEMS.ADD ("FileList", New Hashtable ());
byte[] Buffer2 = Request1. Getpreloadedentitybody (); NUM1 + = Buffer2. Length;
String Text2 = this. Analysepreloadedentitybody (Buffer2, "Uploadguid"); if (Text2!= string. Empty) { Application1. CONTEXT.ITEMS.ADD ("Lionsky_uploadmodule_uploadguid", Text2); } BOOL Flag1 = true; if (Num2 > this. Uploadfilelength () && (0 > Span1. totalhours) | | (Span1. Totalhours > 3)) { Flag1 = false; } if (0 > Span1. totalhours) | | (Span1. Totalhours > 3)) { Flag1 = false; } String Text3 = this. Analysepreloadedentitybody (Buffer2, "Uploadfolder"); ArrayList List1 = new ArrayList (); Requeststream stream1 = new Requeststream (buffer2, buffer1, NULL, RequestStream.FileStatus.Close, RequestStream.ReadStatus.NoRead, Text3, Flag1, Application1. Context, String. Empty); List1. AddRange (stream1. Readbody); if (Text2!= string. Empty) { Progress1. Filelength = num2; Progress1. Receivedlength = NUM1; Progress1. FileName = stream1. OriginalFilename; Progress1. FileCount = ((Hashtable) Application1. context.items["FileList"]). Count; Application1. application["_uploadguid_" + text2] = Progress1; } if (!request1. Isentireentitybodyispreloaded ()) { Byte[] Buffer4; ArrayList List2; int num3 = 204800; byte[] Buffer3 = new BYTE[NUM3]; while ((NUM2-NUM1) >= num3) { if (!application1. Context.Response.IsClientConnected) { This. Clearapplication (Application1); } num3 = Request1. Readentitybody (Buffer3, Buffer3. Length); NUM1 + = num3; List2 = stream1. Contentbody; if (List2. Count > 0) { Buffer4 = new Byte[list2. Count + Buffer3. Length]; List2. CopyTo (buffer4, 0); Buffer3. CopyTo (Buffer4, List2. Count); stream1 = new Requeststream (buffer4, Buffer1, stream1. FileStream, stream1. Fstatus, stream1. Rstatus, Text3, Flag1, Application1. Context, stream1. OriginalFilename); } Else { stream1 = new Requeststream (Buffer3, Buffer1, stream1. FileStream, stream1. Fstatus, stream1. Rstatus, Text3, Flag1, Application1. Context, stream1. OriginalFilename); } List1. AddRange (stream1. Readbody); if (Text2!= string. Empty) { Progress1. Receivedlength = NUM1; Progress1. FileName = stream1. OriginalFilename; Progress1. FileCount = ((Hashtable) Application1. context.items["FileList"]). Count; Application1. application["_uploadguid_" + text2] = Progress1; } } Buffer3 = new BYTE[NUM2-NUM1]; if (!application1. Context.Response.IsClientConnected && (stream1. Fstatus = = RequestStream.FileStatus.Open)) { This. Clearapplication (Application1); } num3 = Request1. Readentitybody (Buffer3, Buffer3. Length); List2 = stream1. Contentbody; if (List2. Count > 0) { Buffer4 = new Byte[list2. Count + Buffer3. Length]; List2. CopyTo (buffer4, 0); Buffer3. CopyTo (Buffer4, List2. Count); stream1 = new Requeststream (buffer4, Buffer1, stream1. FileStream, stream1. Fstatus, stream1. Rstatus, Text3, Flag1, Application1. Context, stream1. OriginalFilename); } Else { stream1 = new Requeststream (Buffer3, Buffer1, stream1. FileStream, stream1. Fstatus, stream1. Rstatus, Text3, Flag1, Application1. Context, stream1. OriginalFilename); } List1. AddRange (stream1. Readbody); if (Text2!= string. Empty) { Progress1. Receivedlength = Num1 + buffer3. Length; Progress1. FileName = stream1. OriginalFilename; Progress1. FileCount = ((Hashtable) Application1. context.items["FileList"]). Count; if (FLAG1) { Progress1. Uploadstatus = Progress.UploadStatusEnum.Uploaded; } Else { Application1. Application.remove ("_uploadguid_" + text2); } } } byte[] Buffer5 = new Byte[list1. Count]; List1. CopyTo (BUFFER5); This. Populaterequestdata (Request1, BUFFER5); } catch (Exception Exception1) { This. Clearapplication (Application1); Throw Exception1; }
|