Esempio n. 1
0
		public SafeDynamicButtons(SplendidControl ctlPARENT, string sNAME, DataRow row)
		{
			this.ctlPARENT  = ctlPARENT ;
			this.rowCurrent = row       ;
			this.ctlDynamicButtons = ctlPARENT.FindControl(sNAME) as _controls.DynamicButtons;
		}
Esempio n. 2
0
		public static bool LoadImage(SplendidControl ctlPARENT, Guid gParentID, string sFIELD_NAME, IDbTransaction trn)
		{
			bool bNewFile = false;
			HtmlInputFile fileIMAGE = ctlPARENT.FindControl(sFIELD_NAME + "_File") as HtmlInputFile;
			if ( fileIMAGE != null )
			{
				HttpPostedFile pstIMAGE  = fileIMAGE.PostedFile;
				if ( pstIMAGE != null )
				{
					long lFileSize      = pstIMAGE.ContentLength;
					long lUploadMaxSize = Sql.ToLong(HttpContext.Current.Application["CONFIG.upload_maxsize"]);
					if ( (lUploadMaxSize > 0) && (lFileSize > lUploadMaxSize) )
					{
						throw(new Exception("ERROR: uploaded file was too big: max filesize: " + lUploadMaxSize.ToString()));
					}
					// 04/13/2005   File may not have been provided. 
					if ( pstIMAGE.FileName.Length > 0 )
					{
						string sFILENAME       = Path.GetFileName (pstIMAGE.FileName);
						string sFILE_EXT       = Path.GetExtension(sFILENAME);
						string sFILE_MIME_TYPE = pstIMAGE.ContentType;
						
						Guid gImageID = Guid.Empty;
						SqlProcs.spIMAGES_Insert
							( ref gImageID
							, gParentID
							, sFILENAME
							, sFILE_EXT
							, sFILE_MIME_TYPE
							, trn
							);
						// 09/06/2008   PostgreSQL does not require that we stream the bytes, so lets explore doing this for all platforms. 
						if ( Sql.StreamBlobs(trn.Connection) )
						{
							SplendidDynamic.LoadFile(gImageID, pstIMAGE.InputStream, trn);
						}
						else
						{
							using ( BinaryReader reader = new BinaryReader(pstIMAGE.InputStream) )
							{
								byte[] binBYTES = reader.ReadBytes((int) pstIMAGE.InputStream.Length);
								SqlProcs.spIMAGES_CONTENT_Update(gImageID, binBYTES, trn);
							}
						}
						// 04/17/2006   Update the dynamic control so that it can be accessed below. 
						DynamicControl ctlIMAGE = new DynamicControl(ctlPARENT, sFIELD_NAME);
						ctlIMAGE.ID = gImageID;
						bNewFile = true;
					}
				}
			}
			return bNewFile;
		}