亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uploadprocess.cs

?? 比較實用的上傳控件
?? CS
字號:
using System;
using System.IO;
using System.Text;
using System.Web;
using System.Collections;

namespace Webb.WAVE.Controls.Upload2
{
	/// <summary>
	/// Summary description for UploadProcess.
	/// </summary>
	public class UploadProcess:IDisposable
	{
		enum WriteMode{Content=0,File=1}

		#region Field
		static private readonly byte[] m_flag	= new byte[]{13,10,13,10};
		private DateTime m_startTime;
		private UploadFile m_currentFile;
		private WriteMode m_writeMode;
		private bool m_isPerloadData;
		private byte[] m_boundary;
		private MemoryStream m_tempData;
		private MemoryStream m_content;	
		private string m_tempFilePath;
		private UploadFileCollection m_fileCollection;
		private string m_currentFileName;
		
		public UploadLoger m_loger;

		#endregion

		#region Properties
		public string TempPath
		{
			get{return this.m_tempFilePath;}
			set{this.m_tempFilePath=value;}
		}
		public UploadFileCollection FileCollection
		{
			get{return this.m_fileCollection;}
		}
		public byte[] ContentData
		{
			get{return this.m_content.ToArray();}
		}
		public DateTime UploadTime
		{
			get{return this.m_startTime;}
			//set{this.m_startTime = value;}
		}
		public UploadFile CurrentUploadingFile
		{
			get{return this.m_currentFile;}
		}
		public string CurrentuploadFileName
		{
			get{return this.m_currentFileName;}
		}
		public byte[] BoundaryData
		{
			set{this.m_boundary=value;}
			get{return this.m_boundary;}
		}

		public int TempStreamLength
		{
			get
			{
				if(this.m_tempData!=null)
				{
					return (int)(this.m_tempData.Length);
				}
				else
				{
					return 0;
				}
			}
		}


		#endregion

		public UploadProcess()
		{
			//
			// TODO: Add constructor logic here
			//
			this.m_startTime		= DateTime.Now;
			this.m_content			= new MemoryStream();
			this.m_writeMode		= WriteMode.Content;
			this.m_currentFile		= null;
			this.m_tempData			= null;
			this.m_tempFilePath		= Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath,"UploadFile");
			this.m_isPerloadData	= true;
			this.m_fileCollection	= new UploadFileCollection();
		}

		/// <summary>
		/// Main funcion to analyze the data.
		/// </summary>
		/// <param name="i_data"></param>
		public void AnalyizeData(byte[] i_data)
		{
			if(this.m_tempData!=null&&this.m_tempData.Length!=0){this.AnalyizeTempData(ref i_data);}
			int m_totalLength	= i_data.Length;
			int m_currentPoint	= 0;
			int m_tempPoint		= 0; 
			//
			#region Preprocess data
			if(this.m_isPerloadData)
			{
				m_currentPoint	= this.AnalyizePerloadData(i_data);
				this.m_isPerloadData= false;
			}
			#endregion

			while(m_currentPoint<m_totalLength)
			{
				if(i_data[m_currentPoint]==13)
				{
					#region if current point byte is 13
					int m_analyzeSize	= this.AnalyzeContentHeader(i_data,m_currentPoint);
					if(m_analyzeSize==0)
					{
						this.WriteData(i_data,m_currentPoint,1);
					}
					else if(m_analyzeSize==-1)
					{
						this.WriteToTemp(i_data,m_currentPoint);
						break;
					}
					else
					{
						m_currentPoint	+= m_analyzeSize; 
					}
					#endregion
				}
				else
				{				
					#region write data until find next 13, wirte to content or write to file
					while(m_currentPoint+m_tempPoint<m_totalLength)
					{
						if(i_data[m_currentPoint+m_tempPoint]==13/*&&this.CheckBoundary(i_data,m_currentPoint+m_tempPoint+2)==0*/)
						{
							break;
						}
						m_tempPoint++;
					}
					//
					this.WriteData(i_data,m_currentPoint,m_tempPoint);
					m_currentPoint	+= m_tempPoint;
					m_tempPoint	= 0;
					m_currentPoint--;
					#endregion
				}
                m_currentPoint++;
			}
		//	this.FlushData();
		}

		#region Assistant fucntions

		/// <summary>
		/// 
		/// </summary>
		/// <param name="i_data"></param>
		/// <param name="i_offset"></param>
		/// <returns></returns>
		private int CheckBoundary(byte[] i_data,int i_offset)
		{
			int m_boundaryLength	= this.m_boundary.Length;
			if(i_data.Length<=i_offset+m_boundaryLength+4)
			{
				//Break point in the content head.
				return -1;
			}
			for(int i=0;i<m_boundaryLength;i++)
			{
				if(i_data[i_offset+i]!=this.m_boundary[i]){return 1;/*Not a boundary*/}
			}
			//This is a boundary.
			return 0;
		}

		/// <summary>
		/// Filter the data, and write to file or content.
		/// </summary>
		/// <param name="i_data"></param>
		/// <param name="i_start"></param>
		/// <param name="i_length"></param>
		/// <returns></returns>
		private void WriteData(byte[] i_data,int i_offset,int i_count)
		{
			switch(this.m_writeMode)
			{
				default:
				case WriteMode.Content:
					this.m_content.Write(i_data,i_offset,i_count);
					break;
				case WriteMode.File:
					try{this.m_currentFile.WriteFileStream.Write(i_data,i_offset,i_count);}
					catch(Exception ex)
					{
					//	this.m_loger.Writer.WriteLine("{0}\tWrite file error. MSG:{1}",DateTime.Now,ex.Message);
						this.m_loger.WriteLine("Write file error:"+ex.Message);
						this.m_currentFile.CloseFile();
					}
					break;
			}
		}
		private void WriteToTemp(byte[] i_data,int i_offset)
		{
        //  this.m_tempData	= new MemoryStream();
			if(this.m_tempData==null)
			{
				this.m_tempData	= new MemoryStream();
			}
			this.m_tempData.Write(i_data,i_offset,i_data.Length-i_offset);
		}

		public void FlushTempData()
		{
			if(this.m_tempData!=null&&this.m_tempData.Length!=0)
			{
				byte[] m_temp	= this.m_tempData.ToArray();
				this.WriteData(m_temp,0,(int)this.m_tempData.Length);
			}
		}

		/// <summary>
		/// 
		/// </summary>
		private void FlushData()
		{
			if(this.m_currentFile!=null&&this.m_currentFile.WriteFileStream!=null){
				try
				{
					this.m_currentFile.WriteFileStream.Flush();
				}
				catch
				{
					this.m_currentFile.CloseFile();
				}
			}
//			if(this.m_tempData!=null){this.m_tempData.Flush();}
//			if(this.m_content!=null){this.m_content.Flush();}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="i_data"></param>
		private void AnalyizeTempData(ref byte[] i_data)
		{
			this.m_tempData.Write(i_data,0,i_data.Length);
			i_data = this.m_tempData.ToArray();
			this.m_tempData.SetLength(0);
			this.m_tempData.Position = 0;
//			ArrayList m_tempList	= new ArrayList();
//			i_data = null;			
//			this.m_tempData.Close();
//			this.m_tempData	= null;
//			this.m_tempData.Position = 0;			
//			for(int i=0;i<this.m_tempData.Length;i++)
//			{
//				this.m_tempData.WriteByte((byte)0);	
//			}
//			this.m_tempData.Position = 0;
//			UploadModule.CollecteGC();
		}

		private int AnalyizePerloadData(byte[] i_data)
		{
			string m_insertStartTime	= Encoding.Default.GetString(this.m_boundary);
			m_insertStartTime			+= "\r\nContent-Disposition: form-data; name=\"WebbUploadStartTime\"\r\n\r\n";
			m_insertStartTime			+= this.m_startTime.ToString()+"\r\n";
			byte[] m_insertData			= Encoding.Default.GetBytes(m_insertStartTime);
			this.WriteData(m_insertData,0,m_insertData.Length);
			int m_index	=0;
			while(m_index+3<i_data.Length)
			{				
				if(i_data[m_index]==13&&i_data[m_index+1]==10&&i_data[m_index+2]==13&&i_data[m_index+3]==10)
				{
					break;
				}
				m_index++;
			}
			this.WriteData(i_data,0,m_index+4);
			return m_index+4;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="i_data"></param>
		/// <param name="i_offSet"></param>
		/// <returns></returns>
		private int AnalyzeContentHeader(byte[] i_data,int i_offSet)
		{
			int m_breakType	= this.CheckBoundary(i_data,i_offSet+2);
			if(m_breakType==1)	return 0; //Break point in the context head.
			if(m_breakType==-1) return -1;
			//break point==0, this is a boundary
			int m_index	= i_offSet+this.m_boundary.Length+4;
			while(m_index+3<i_data.Length)
			{				
				if(i_data[m_index]==13&&i_data[m_index+1]==10&&i_data[m_index+2]==13&&i_data[m_index+3]==10)
				{
					break;
				}
				m_index++;
			}
			if(m_index+3>=i_data.Length)return -1;
			//Analyze contenheader data
			int m_boundarySize	= this.m_boundary.Length+4;
			//include \r\n befor and \r\n behind.
			if(this.m_currentFile!=null&&this.m_writeMode==WriteMode.File)
			{
				this.m_currentFile.CloseFile();
				this.m_currentFile	= null;
				this.m_writeMode	= WriteMode.Content;
			}
			this.WriteData(i_data,i_offSet,this.m_boundary.Length+4);
			//start at this.m_boundary.Length+4, length: m_index-this.m_boundary.Length+4;
			string m_contentHeader	= HttpContext.Current.Request.ContentEncoding.GetString(i_data,i_offSet+m_boundarySize,m_index-m_boundarySize-i_offSet);
			if(m_contentHeader.IndexOf("\"; filename=\"")<0)
			{
				//This is other data.
				this.WriteData(i_data,i_offSet+m_boundarySize,m_index-m_boundarySize-i_offSet+4);
				return m_index-i_offSet+3;
			}
			else
			{
				this.m_currentFile			= new UploadFile();
				this.m_currentFile.FilePath	= this.m_tempFilePath;
				//This is a upload file data.
				string[] m_fileContent	= this.GetFileContent(m_contentHeader);	
				string[] sbArray	= new string[11];
				sbArray[0]	= m_fileContent[0];
				sbArray[1]	= ";";
				sbArray[2]	= m_fileContent[1];
				sbArray[3]	= "\r\n\r\n";
				sbArray[4]	= m_fileContent[3];
				sbArray[5]	= ";";
				sbArray[6]	= m_fileContent[2];
				sbArray[7]	= "; ";
				sbArray[8]	= "filename_server=\"";
				if(m_fileContent[2].IndexOf("\"\"")>=0)
				{
					sbArray[9]	= string.Empty;
				}
				else
				{	
					sbArray[9]	= this.m_currentFile.FullPathOnServer;
					this.m_currentFileName	= m_fileContent[2];
					//this.m_loger.Writer.WriteLine("{0}:\tStart upload file:{1}. Server path:\"{2}\"",DateTime.Now,m_fileContent[2],this.m_currentFile.FullPathOnServer);					
					this.m_loger.WriteLine(string.Format("Upload file. ServerPath=\"{0}\",{1}",this.m_currentFile.FullPathOnServer,m_fileContent[2]));
				}
				sbArray[10]	= "\"";
				//StringBuilder m_sb	= new StringBuilder();
				//m_sb.Append(string.Concat(sbArray));
				//byte[] m_tempContent	= Encoding.UTF8.GetBytes(sb.ToString().ToCharArray());
				byte[] m_tempContent	= HttpContext.Current.Request.ContentEncoding.GetBytes(string.Concat(sbArray));
                this.WriteData(m_tempContent,0,m_tempContent.Length);
				if(m_fileContent[2].IndexOf("\"\"")<=0)
				{
					this.m_currentFile.OpenFile(FileMode.OpenOrCreate,FileAccess.Write);
					this.m_writeMode = WriteMode.File;
					this.m_fileCollection.Add(this.m_currentFile);
				}
			}
			return m_index-i_offSet+3;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="m_contentHeader"></param>
		/// <returns></returns>
		private string[] GetFileContent(string m_contentHeader)
		{
			m_contentHeader = m_contentHeader.Replace("\r\n",";");
			return m_contentHeader.Split(new char[1]{';'});
		}
		#endregion

		#region IDisposable Members

		public void Dispose()
		{
			// TODO:  Add UploadProcess.Dispose implementation
			if(this.m_currentFile!=null&&this.m_currentFile.WriteFileStream!=null)
			{
				this.m_currentFile.CloseFile();
				this.m_currentFile	= null;
			}
			if(this.m_tempData!=null)
			{
				this.m_tempData.Close();
				this.m_tempData	= null;
			}
			if(this.m_content!=null)
			{
				this.m_content.Close();
				this.m_content	= null;
			}
			if(this.m_fileCollection!=null)
			{
				this.m_fileCollection.Clear();
				this.m_fileCollection	= null;
			}
		}
		#endregion
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品99久久久久| 国产精品不卡一区| 男人的j进女人的j一区| 国产麻豆精品视频| 91啪亚洲精品| 国产日本欧洲亚洲| 蜜桃一区二区三区四区| 欧美伊人久久久久久午夜久久久久| 欧美mv日韩mv国产| 三级成人在线视频| 欧美色图12p| 亚洲色图.com| 成人h精品动漫一区二区三区| 日韩精品在线一区二区| 亚洲成a人v欧美综合天堂下载| 99r精品视频| 国产精品天天摸av网| 国产一区二区中文字幕| 欧美va日韩va| 开心九九激情九九欧美日韩精美视频电影 | 一区二区三区欧美亚洲| 国产精品影视在线观看| 日韩久久久精品| 免播放器亚洲一区| 欧美精品丝袜中出| 视频在线观看国产精品| 欧美日韩成人综合| 日本特黄久久久高潮| 欧美日韩高清在线播放| 视频一区中文字幕国产| 3751色影院一区二区三区| 丝袜亚洲另类欧美综合| 欧美精品一二三| 日本91福利区| 精品国产乱码久久久久久影片| 狠狠色丁香婷婷综合久久片| 欧美电影免费观看高清完整版在线| 麻豆精品在线播放| 国产丝袜美腿一区二区三区| 国产精品综合av一区二区国产馆| 久久精品夜夜夜夜久久| 国产成人在线视频网站| 国产精品久久国产精麻豆99网站| 成人动漫av在线| 一区二区三区欧美| 在线播放欧美女士性生活| 免费成人av在线| 久久久99精品免费观看不卡| 波多野结衣精品在线| 悠悠色在线精品| 日韩一级高清毛片| 成人性生交大合| 一区二区久久久| 日韩精品在线网站| 国产成a人亚洲| 亚洲成人手机在线| 久久青草欧美一区二区三区| 99免费精品视频| 丝袜美腿亚洲综合| 欧美激情在线一区二区| 欧美亚洲综合在线| 黑人巨大精品欧美一区| 亚洲欧美日韩一区二区三区在线观看 | 日韩美女在线视频| 暴力调教一区二区三区| 亚洲gay无套男同| 久久久美女艺术照精彩视频福利播放 | 欧美精品18+| 成人av在线看| 日本vs亚洲vs韩国一区三区二区| 日本一区二区三区电影| 欧美手机在线视频| 国产91精品一区二区| 天天av天天翘天天综合网| 中文子幕无线码一区tr| 69久久夜色精品国产69蝌蚪网| 国产99精品国产| 日韩精品三区四区| 亚洲精选视频在线| 久久久欧美精品sm网站| 欧美日韩精品一区二区三区| 成人妖精视频yjsp地址| 青青青伊人色综合久久| 依依成人综合视频| 国产精品乱码一区二三区小蝌蚪| 日韩一级二级三级| 欧美三级日韩三级国产三级| 99久久夜色精品国产网站| 精品一区二区久久| 石原莉奈一区二区三区在线观看| 中文字幕中文在线不卡住| 精品国产三级a在线观看| 欧美日韩高清一区| 91色porny在线视频| 国产成人自拍网| 经典三级视频一区| 久久不见久久见免费视频1| 亚洲另类色综合网站| 国产日韩成人精品| 久久综合久久鬼色| 日韩女优av电影在线观看| 欧美日韩精品一区视频| 91视频你懂的| 99久久精品费精品国产一区二区| 久久国产视频网| 免费观看一级欧美片| 男女性色大片免费观看一区二区| 日韩在线a电影| 亚洲成人av一区二区三区| 一区二区三区日韩精品| 夜夜嗨av一区二区三区| 一区二区三区在线不卡| 亚洲一区二区三区四区在线观看 | 欧美一级片在线看| 91精品免费在线观看| 这里只有精品99re| 欧美一区二区三区免费视频| 欧美人xxxx| 日韩欧美在线网站| 2021中文字幕一区亚洲| 国产农村妇女精品| 亚洲欧洲无码一区二区三区| 一区在线中文字幕| 亚洲国产美女搞黄色| 蜜臀久久99精品久久久久久9 | 奇米影视7777精品一区二区| 麻豆国产精品一区二区三区 | 国产精品福利一区| 亚洲少妇30p| 爽爽淫人综合网网站| 久久爱www久久做| 成人一区在线观看| 在线欧美日韩国产| 欧美一区二区大片| 国产精品久久夜| 午夜久久久久久久久| 狠狠色丁香婷婷综合| 91伊人久久大香线蕉| 欧美日韩美少妇| 国产日韩精品视频一区| 一区二区三区四区在线免费观看 | 欧洲一区二区三区在线| 宅男噜噜噜66一区二区66| 精品日韩一区二区| 中文字幕一区日韩精品欧美| 亚洲一级片在线观看| 国产呦精品一区二区三区网站| 91老司机福利 在线| 91精品国产入口在线| 国产精品美女久久久久久| 亚洲图片欧美视频| 国产成人精品三级麻豆| 欧美日韩国产成人在线免费| 2014亚洲片线观看视频免费| 亚洲免费在线电影| 黑人巨大精品欧美一区| 在线免费av一区| 久久精品亚洲精品国产欧美| 亚洲国产精品综合小说图片区| 精品一区二区免费| 欧美日韩综合在线| 中文字幕一区在线观看视频| 麻豆精品一区二区三区| 欧美视频日韩视频| 中文字幕一区二区三区精华液| 男男视频亚洲欧美| 欧美综合天天夜夜久久| 国产精品国产馆在线真实露脸| 偷拍亚洲欧洲综合| 色婷婷国产精品综合在线观看| 精品日韩一区二区三区免费视频| 亚洲1区2区3区视频| 99精品在线观看视频| 国产欧美视频一区二区| 青青草国产精品亚洲专区无| 日韩免费视频一区| 亚洲一二三专区| 99精品偷自拍| 中文字幕日韩一区| 成人av在线播放网址| 国产亚洲视频系列| 国产在线一区观看| 欧美精品一区二| 蜜臀av性久久久久av蜜臀妖精| 在线看日韩精品电影| 亚洲精品国产成人久久av盗摄| 国产suv精品一区二区6| 国产亚洲欧洲一区高清在线观看| 久久99久久久久久久久久久| 欧美肥胖老妇做爰| 热久久免费视频| 91精品国产综合久久久久久漫画| 亚洲一卡二卡三卡四卡无卡久久| 91麻豆国产精品久久| 亚洲美腿欧美偷拍| 91啦中文在线观看| 亚洲尤物在线视频观看| 欧美系列在线观看| 亚洲成人资源网| 欧美久久久久中文字幕|