|
From: <sv...@de...> - 2005-05-31 15:58:21
|
Author: pcamacho Date: 2005-05-31 11:58:19 -0400 (Tue, 31 May 2005) New Revision: 1211 Added: humano2/trunk/web/portal/site/download.aspx humano2/trunk/web/portal/site/download.aspx.cs Modified: humano2/trunk/components/webTools/Html.cs humano2/trunk/components/webTools/basePage.cs humano2/trunk/config/config.xml.tmpl humano2/trunk/core/db/mssql/mssqlCrud.cs humano2/trunk/core/db/pgsql/pgsqlCrud.cs humano2/trunk/core/schema/pgsql/pgsql-1-metadata.sql humano2/trunk/web/portal/site/createInstance.aspx.cs humano2/trunk/web/portal/site/readXslt.aspx humano2/trunk/web/portal/site/updateInstance.aspx.cs humano2/trunk/web/portal/site/xsl/file.xsl Log: MERGE: branch fileupload. Revision 1178:1210. Modified: humano2/trunk/components/webTools/Html.cs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/components/webTools/Html.cs 2005-05-31 15:21:17 UTC (re= v 1210) +++ humano2/trunk/components/webTools/Html.cs 2005-05-31 15:58:19 UTC (re= v 1211) @@ -13,7 +13,9 @@ using System; using System.Web; using System.Web.UI.WebControls; +using System.IO; =20 + using Humano2.Core; =20 namespace Humano2.Components.WebTools @@ -81,5 +83,32 @@ { objPage.RegisterClientScriptBlock(strId, strJavascript); } - } + =20 + ///<summary> + /// Allows to upload a collection of file in the directory + /// specified in config.xml=20 + ///</summary> + public static void UploadFile(HttpPostedFile file,int idEntity, = string attId, System.Web.HttpResponse Response) + { + string strFileName; =20 + + if (file.FileName !=3D "")=20 + { + strFileName =3D idEntity + "_" + attId + "_" + file.File= Name; + =20 + //Here create a new path with domainId if it does not ex= ists yet + string upLoadPath =3D Config.Instance().GetOption("locat= ions", "uploadPath"); + =20 + try + { + string fullFileName =3D upLoadPath + Path.Directory= SeparatorChar + strFileName; + file.SaveAs(fullFileName); + } + catch (Exception err)=20 + { + Response.Write("Failed uploading " + strFileName + "= : " + err.ToString()+"<br>"); =20 + } + } + } + } } Modified: humano2/trunk/components/webTools/basePage.cs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/components/webTools/basePage.cs 2005-05-31 15:21:17 UTC= (rev 1210) +++ humano2/trunk/components/webTools/basePage.cs 2005-05-31 15:58:19 UTC= (rev 1211) @@ -127,6 +127,15 @@ return baseUrl; } =20 + ///<summary> + ///To get the filename that will be used to store files uploaded= by the user + ///<summary> + protected string buildFileName(int idEntity, string attId, strin= g filename) + { + string res =3D idEntity + "_" + attId + "_" + filename; + return res; + } + =20 /// <summary> /// Sends a message to the user (in the browser) /// <param name=3D"message">The message to send</param> Modified: humano2/trunk/config/config.xml.tmpl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/config/config.xml.tmpl 2005-05-31 15:21:17 UTC (rev 121= 0) +++ humano2/trunk/config/config.xml.tmpl 2005-05-31 15:58:19 UTC (rev 121= 1) @@ -12,6 +12,7 @@ <dbdrivers>C:\h2_install\bin</dbdrivers> <!-- Where is the datab= ase driver direcotory --> <session>C:\h2_sessions</session> <!-- Directory where ar= e the session xml files stored --> <webbase>http://localhost:8080</webbase> <!-- what's the base lo= cation where the humano2 installation lives? -->=20 + <uploadPath>C:\upload</uploadPath> <!-- Where the user will uplo= ad his files --> </locations> <log> <level>0</level> <!-- detail of error logging. higher numer is high= er logging level. 0 =3D off. --> Modified: humano2/trunk/core/db/mssql/mssqlCrud.cs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/core/db/mssql/mssqlCrud.cs 2005-05-31 15:21:17 UTC (rev= 1210) +++ humano2/trunk/core/db/mssql/mssqlCrud.cs 2005-05-31 15:58:19 UTC (rev= 1211) @@ -46,6 +46,7 @@ map.Add( "numeric", "numeric" ); map.Add( "boolean", "boolean" ); map.Add( "dateTime", "datetime" ); + map.Add( "file", "varchar" );=20 return map; } =09 Modified: humano2/trunk/core/db/pgsql/pgsqlCrud.cs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/core/db/pgsql/pgsqlCrud.cs 2005-05-31 15:21:17 UTC (rev= 1210) +++ humano2/trunk/core/db/pgsql/pgsqlCrud.cs 2005-05-31 15:58:19 UTC (rev= 1211) @@ -46,8 +46,7 @@ map.Add( "numeric", "numeric" ); map.Add( "boolean", "boolean" ); map.Add( "dateTime", "timestamp" ); - - //map.Add( "file", "varchar" ); // does not work anyway. + map.Add( "file", "varchar" );=20 //map.Add( "image", "varchar" ); // don't work anyway. return map; } =09 Modified: humano2/trunk/core/schema/pgsql/pgsql-1-metadata.sql =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/core/schema/pgsql/pgsql-1-metadata.sql 2005-05-31 15:21= :17 UTC (rev 1210) +++ humano2/trunk/core/schema/pgsql/pgsql-1-metadata.sql 2005-05-31 15:58= :19 UTC (rev 1211) @@ -245,7 +245,7 @@ INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (14,1,'inheritance','inheritance',5,'= f', 't'); INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (15,1,'choice','choice',81,'f', 't'); INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (26,27,'user_domain','user_domain',3,= 'f', 'f'); -INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (39,1,'file','file',5,'f', 't'); +INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (39,1,'file','file',5,'f', 'f'); INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (80,1, 'option','option',3,'f', 'f'); INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (81,1,'pertinence','pertinence',5,'f'= , 'f'); INSERT INTO "class" ("id_entity","classType","sysName","name","parentId= ","isAbstract", "isHidden") VALUES (82,1,'boolean','boolean',5,'f', 'f')= ; Modified: humano2/trunk/web/portal/site/createInstance.aspx.cs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/web/portal/site/createInstance.aspx.cs 2005-05-31 15:21= :17 UTC (rev 1210) +++ humano2/trunk/web/portal/site/createInstance.aspx.cs 2005-05-31 15:58= :19 UTC (rev 1211) @@ -12,6 +12,7 @@ =20 using System; using System.Collections; +using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Drawing; @@ -52,7 +53,20 @@ // Create the instance from the user data.. returns the id of the new= instance. int idEntity =3D dbAdapter.CreateInstance(classId, domainId, Request.= Params); =20 - + =20 + //Upload Files if needed + NameValueCollection InstanceParams =3D new NameValueCollecti= on(); + foreach(string attributeId in Request.Files.AllKeys) + { + Html.UploadFile(Request.Files[attributeId],idEntity,attr= ibuteId,Response); + InstanceParams.Add(attributeId,Request.Files[attributeId= ].FileName); + } + //Update the instance with the names of files + if(InstanceParams.Count !=3D 0) + { + dbAdapter.UpdateInstance(idEntity, domainId, InstancePar= ams); + } + =20 if(idEntity>0 && classId>0) { try @@ -79,7 +93,7 @@ HttpContext.Current.Response.Redirect(Html.genAbsoluteUrl("/portal/s= ite/Data_structured.aspx?id_entity=3D" + idview + "&classId=3D"+classId))= ; } } - + =20 #region Web Form Designer generated code override protected void OnInit(EventArgs e) { Copied: humano2/trunk/web/portal/site/download.aspx (from rev 1210, human= o2/branches/fileupload/web/portal/site/download.aspx) Copied: humano2/trunk/web/portal/site/download.aspx.cs (from rev 1210, hu= mano2/branches/fileupload/web/portal/site/download.aspx.cs) Modified: humano2/trunk/web/portal/site/readXslt.aspx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/web/portal/site/readXslt.aspx 2005-05-31 15:21:17 UTC (= rev 1210) +++ humano2/trunk/web/portal/site/readXslt.aspx 2005-05-31 15:58:19 UTC (= rev 1211) @@ -44,7 +44,6 @@ else return "no date"; } </script> - =20 </head> <body style=3D"MARGIN: 10px" text=3D"#000000" vLink=3D"#000= 000" aLink=3D"#000000" link=3D"#000000" bgColor=3D"#ffffff"> <form method=3D"POST" name=3D"MainForm" enctype=3D"multi= part/form-data"> Modified: humano2/trunk/web/portal/site/updateInstance.aspx.cs =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/web/portal/site/updateInstance.aspx.cs 2005-05-31 15:21= :17 UTC (rev 1210) +++ humano2/trunk/web/portal/site/updateInstance.aspx.cs 2005-05-31 15:58= :19 UTC (rev 1211) @@ -12,6 +12,7 @@ =20 using System; using System.Collections; +using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Drawing; @@ -50,6 +51,20 @@ // Create the instance from the user data.. dbAdapter.UpdateInstance(idEntity, domainId, Request.Params); =09 + //Upload Files if needed + NameValueCollection InstanceParams =3D new NameValueCollecti= on(); + foreach(string attributeId in Request.Files.AllKeys) + { + Html.UploadFile(Request.Files[attributeId],idEntity,attr= ibuteId,Response); + InstanceParams.Add(attributeId,Request.Files[attributeId= ].FileName); + } + //Update the instance with the names of files + if(InstanceParams.Count !=3D 0) + { + dbAdapter.UpdateInstance(idEntity, domainId, InstancePar= ams); + } + =20 + =20 int[] formulas =3D dbAdapter.GetAllFormulasForClass(classId); =20 foreach(int formulaId in formulas) Modified: humano2/trunk/web/portal/site/xsl/file.xsl =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- humano2/trunk/web/portal/site/xsl/file.xsl 2005-05-31 15:21:17 UTC (r= ev 1210) +++ humano2/trunk/web/portal/site/xsl/file.xsl 2005-05-31 15:58:19 UTC (r= ev 1211) @@ -4,20 +4,26 @@ <xsl:param name=3D"idEntity" select=3D"$idEntity"/> <xsl:variable name=3D"data" select=3D"/page/classInstance/data/file[id= _entity=3D$idEntity]/data"/> <xsl:variable name=3D"path" select=3D"/page/classInstance/structure/fi= le[id_entity=3D$idEntity]/path"/> -=09 + <xsl:variable name=3D"sysAttName" select=3D"/page/classInstance/= structure/attribute[id_entity=3D$idEntity]/sysAttName"/> + <xsl:variable name=3D"instanceEntity" select=3D"/page/classInsta= nce/structure/entity/id_entity" /> + =20 <xsl:choose>=09 <xsl:when test=3D"/page/flagaction=3D'Read'">=09 - <a href=3D"{$path}{$data}"><xsl:value-of select=3D"$data"/></a> + <a href=3D"download.aspx?file=3D{$data}&instanceEntity=3D{$insta= nceEntity}&attName=3D{$sysAttName}"><xsl:value-of select=3D"$data"/><= /a> </xsl:when> - =09 <xsl:when test=3D"/page/flagaction=3D'Update'"> - <input name=3D"file" value=3D"{$data}" type=3D"file" /> + <input name=3D"{$sysAttName}" value=3D"{$data}" type=3D"= file" /> </xsl:when> -=09 <xsl:when test=3D"/page/flagaction=3D'Create'"> - <input name=3D"file" type=3D"file"/> + <input name=3D"{$sysAttName}" type=3D"file" /> </xsl:when> </xsl:choose> + <xsl:if test=3D"/page/flagaction!=3D'Read'"> <!-- Only for creat= e and update --> + <script language=3D"Javascript"> + var aInputToCheck =3D new InputToCheck('TEXT',''); //By = default, does no verification + allInputsToCheck.Add(aInputToCheck); + </script> + </xsl:if> </xsl:template> </xsl:stylesheet> =20 |