|
From: <sv...@de...> - 2005-06-16 20:20:38
|
Author: pcamacho Date: 2005-06-16 16:20:35 -0400 (Thu, 16 Jun 2005) New Revision: 1338 Added: humano2/trunk/components/tests/attributes.xml humano2/trunk/components/tests/xmltools.cs humano2/trunk/web/portal/site/xsl/orderattributes.xsl Modified: humano2/trunk/components/import/Import.cs humano2/trunk/components/webTools/Adapter.cs humano2/trunk/components/webTools/xmltools.cs humano2/trunk/web/portal/site/instance.aspx.cs Log: FIX: bug #205. Use of xsl transformation to reorder the attributes when c= reating instance of form. Modified: humano2/trunk/components/import/Import.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/import/Import.cs 2005-06-16 19:11:17 UTC (re= v 1337) +++ humano2/trunk/components/import/Import.cs 2005-06-16 20:20:35 UTC (re= v 1338) @@ -7,7 +7,7 @@ // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // -// $Id: config.cs 295 2005-02-17 +// $Id$ =20 using System; using System.IO; @@ -315,7 +315,7 @@ } =20 pertRow =3D dsAtts.Tables["boolean"].Select("id_entity =3D" + attsA= rr[i,2]); - if (pertRow.Length > 0 ) + if (pertRow.Length > 0 ) { =20 } Property changes on: humano2/trunk/components/import/Import.cs ___________________________________________________________________ Name: svn:keywords + Id Added: humano2/trunk/components/tests/attributes.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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/tests/attributes.xml 2005-06-16 19:11:17 UTC= (rev 1337) +++ humano2/trunk/components/tests/attributes.xml 2005-06-16 20:20:35 UTC= (rev 1338) @@ -0,0 +1,125 @@ +<structure> +<entity> + <id_entity>10162</id_entity> + <domainId>10160</domainId> + <class>2</class> + <createDate>2005-06-03T13:43:27.9166650-04:00</createDate> + <modDate>2005-06-03T13:43:27.9166650-04:00</modDate> + </entity> + <class> + <id_entity>10162</id_entity> + <classType>29</classType> + <sysName>d10160cTicket</sysName> + <name>Ticket</name> + <parentId>3</parentId> + <isAbstract>false</isAbstract> + <isHidden>false</isHidden> + </class> + <class> + <id_entity>3</id_entity> + <classType>1</classType> + <sysName>entity</sysName> + <name>entity</name> + <isAbstract>true</isAbstract> + <isHidden>false</isHidden> + </class> + <attribute> + <id_entity>10181</id_entity> + <classId>10162</classId> + <sysAttName>c10162Title</sysAttName> + <attName>Title</attName> + <order>-10.00</order> + <isObligatory>false</isObligatory> + <isActive>true</isActive> + <isSearchable>false</isSearchable> + <isEditable>true</isEditable> + <isSelfLookup>false</isSelfLookup> + <isPrimary>true</isPrimary> + <isUnique>false</isUnique> + <isVirtual>false</isVirtual> + <protection>false</protection> + <refClassSysName>textline</refClassSysName> + </attribute> + <attribute> + <id_entity>10208</id_entity> + <classId>10162</classId> + <sysAttName>c10162Date</sysAttName> + <attName>Date</attName> + <order>-9.00</order> + <isObligatory>false</isObligatory> + <isActive>true</isActive> + <isSearchable>false</isSearchable> + <isEditable>true</isEditable> + <isSelfLookup>false</isSelfLookup> + <isPrimary>false</isPrimary> + <isUnique>false</isUnique> + <isVirtual>false</isVirtual> + <protection>false</protection> + <refClassSysName>dateTime</refClassSysName> + </attribute> + <attribute> + <id_entity>10229</id_entity> + <classId>10162</classId> + <sysAttName>c10162Request by1</sysAttName> + <attName>Request by</attName> + <order>-5.00</order> + <isObligatory>false</isObligatory> + <isActive>true</isActive> + <isSearchable>true</isSearchable> + <isEditable>true</isEditable> + <isSelfLookup>false</isSelfLookup> + <isPrimary>false</isPrimary> + <isUnique>false</isUnique> + <isVirtual>false</isVirtual> + <protection>false</protection> + <refClassSysName>pertinence</refClassSysName> + </attribute> + <textline> + <id_entity>10181</id_entity> + <maxLength>20</maxLength> + </textline> + <dateTime> + <id_entity>10208</id_entity> + </dateTime> + <pertinence> + <id_entity>10229</id_entity> + <owner>10229</owner> + <to>7</to> + <ratio>n:1</ratio> + </pertinence> + <option> + <id_entity>116</id_entity> + <group>132</group> + <value>dd/mm/aaaa</value> + <isActiveOption>true</isActiveOption> + <orderOption>1.00</orderOption> + </option> + <option> + <id_entity>117</id_entity> + <group>132</group> + <value>mm/dd/aaaa</value> + <isActiveOption>true</isActiveOption> + <orderOption>2.00</orderOption> + </option> + <option> + <id_entity>118</id_entity> + <group>133</group> + <value>none</value> + <isActiveOption>true</isActiveOption> + <orderOption>1.00</orderOption> + </option> + <option> + <id_entity>119</id_entity> + <group>133</group> + <value>hh:mm</value> + <isActiveOption>true</isActiveOption> + <orderOption>2.00</orderOption> + </option> + <option> + <id_entity>120</id_entity> + <group>133</group> + <value>hh:mm:ss</value> + <isActiveOption>true</isActiveOption> + </option> +</structure> + Added: humano2/trunk/components/tests/xmltools.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/tests/xmltools.cs 2005-06-16 19:11:17 UTC (r= ev 1337) +++ humano2/trunk/components/tests/xmltools.cs 2005-06-16 20:20:35 UTC (r= ev 1338) @@ -0,0 +1,58 @@ +// +// The Humano2 Business solution. +// Copyright (C) 2004,5 Humano2 Chile S.A. (http://www.humano2.com) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. =20 +// +// $Id$ +// + +using System; +using System.Data; +using System.IO; +using Humano2.Components.WebTools; +using NUnit.Framework; + +namespace Humano2.Components.Test.Xml +{ + [TestFixture] + public class Xml + { + private string readFile(string FileName, int FileSize) + { + string filereadbuf; + char[] buf =3D new char[FileSize]; // lets define an array o= f type char field (i.e. variable) buf + // for more help please see .net sdk + StreamReader sr =3D new StreamReader(new FileStream(FileName= , FileMode.Open, FileAccess.Read)); + int retval =3D sr.ReadBlock(buf, 0, FileSize); // no. of byt= es read + //Console.Write ("Total Bytes Read =3D " + retval + "\n"); + filereadbuf =3D new string(buf); // store it in our field + =20 + sr.Close(); + return filereadbuf; + } + =20 + [Test] + public void OrderAttributesInDataStructure() + { + //Loads the xml in a string + string xmlStructure =3D readFile("../components/tests/attrib= utes.xml",3492); //We now the size of file + //Console.Write("Length: " + xmlStructure.Length + "\n"); + //Console.Write("Value: " + xmlStructure + "\n"); + Assert.IsTrue(xmlStructure.Length =3D=3D 3492); //The file h= as not changed + string xslPath =3D "../web/portal/site/xsl/orderattributes.x= sl"; + string xmlStructureOrdered =3D Humano2.Components.WebTools.X= ml.OrderAttributesInDataStructure(xmlStructure, + = "10229,10208,10181", + = xslPath); = =20 + string resWaited =3D=20 + "<structure><entity><id_entity>10162</id_entity><domainI= d>10160</domainId><class>2</class><createDate>2005-06-03T13:43:27.9166650= -04:00</createDate><modDate>2005-06-03T13:43:27.9166650-04:00</modDate></= entity><class><id_entity>10162</id_entity><classType>29</classType><sysNa= me>d10160cTicket</sysName><name>Ticket</name><parentId>3</parentId><isAbs= tract>false</isAbstract><isHidden>false</isHidden></class><class><id_enti= ty>3</id_entity><classType>1</classType><sysName>entity</sysName><name>en= tity</name><isAbstract>true</isAbstract><isHidden>false</isHidden></class= ><attribute><id_entity>10229</id_entity><classId>10162</classId><sysAttNa= me>c10162Request by1</sysAttName><attName>Request by</attName><order>-5.0= 0</order><isObligatory>false</isObligatory><isActive>true</isActive><isSe= archable>true</isSearchable><isEditable>true</isEditable><isSelfLookup>fa= lse</isSelfLookup><isPrimary>false</isPrimary><isUnique>false</isUnique><= isVirtual>false</isVirtual><protection>false</protection><refClassSysName= >pertinence</refClassSysName></attribute><attribute><id_entity>10208</id_= entity><classId>10162</classId><sysAttName>c10162Date</sysAttName><attNam= e>Date</attName><order>-9.00</order><isObligatory>false</isObligatory><is= Active>true</isActive><isSearchable>false</isSearchable><isEditable>true<= /isEditable><isSelfLookup>false</isSelfLookup><isPrimary>false</isPrimary= ><isUnique>false</isUnique><isVirtual>false</isVirtual><protection>false<= /protection><refClassSysName>dateTime</refClassSysName></attribute><attri= bute><id_entity>10181</id_entity><classId>10162</classId><sysAttName>c101= 62Title</sysAttName><attName>Title</attName><order>-10.00</order><isOblig= atory>false</isObligatory><isActive>true</isActive><isSearchable>false</i= sSearchable><isEditable>true</isEditable><isSelfLookup>false</isSelfLooku= p><isPrimary>true</isPrimary><isUnique>false</isUnique><isVirtual>false</= isVirtual><protection>false</protection><refClassSysName>textline</refCla= ssSysName></attribute><textline><id_entity>10181</id_entity><maxLength>20= </maxLength></textline><dateTime><id_entity>10208</id_entity></dateTime><= pertinence><id_entity>10229</id_entity><owner>10229</owner><to>7</to><rat= io>n:1</ratio></pertinence><option><id_entity>116</id_entity><group>132</= group><value>dd/mm/aaaa</value><isActiveOption>true</isActiveOption><orde= rOption>1.00</orderOption></option><option><id_entity>117</id_entity><gro= up>132</group><value>mm/dd/aaaa</value><isActiveOption>true</isActiveOpti= on><orderOption>2.00</orderOption></option><option><id_entity>118</id_ent= ity><group>133</group><value>none</value><isActiveOption>true</isActiveOp= tion><orderOption>1.00</orderOption></option><option><id_entity>119</id_e= ntity><group>133</group><value>hh:mm</value><isActiveOption>true</isActiv= eOption><orderOption>2.00</orderOption></option><option><id_entity>120</i= d_entity><group>133</group><value>hh:mm:ss</value><isActiveOption>true</i= sActiveOption></option></structure>"; + //Console.Write("res=3D" + xmlStructureOrdered.Replace(" ","= ") + "\n"); =20 + //Console.Write("waited=3D" + resWaited.Replace(" ","")); = = =20 + string resWithoutSpaceAndBackspace =3D xmlStructureOrdered.R= eplace(" ","").Replace("\n",""); + Assert.IsTrue(resWaited.Replace(" ","") =3D=3D resWithoutSpa= ceAndBackspace); = =20 + } + } +} Property changes on: humano2/trunk/components/tests/xmltools.cs ___________________________________________________________________ Name: svn:keywords + Id Modified: humano2/trunk/components/webTools/Adapter.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/Adapter.cs 2005-06-16 19:11:17 UTC = (rev 1337) +++ humano2/trunk/components/webTools/Adapter.cs 2005-06-16 20:20:35 UTC = (rev 1338) @@ -958,6 +958,8 @@ return ds; } =20 + =20 + //FIXME: factorize these two next functions /// <summary> /// Lee la estructura de una entity (Instancia) /// </summary> @@ -987,7 +989,9 @@ =20 public string ReadStructureAndXsls1(int idEntity,ArrayList includes,st= ring idAttributes) { - //Hago el read estructural + Logger.Log("=3D=3D Adapter.cs =3D=3D ReadStructureAndXsls1",LogLevel.= Trace); + =20 + //Hago el read estructural DataSet ds =3D crud.ReadStructure(idEntity,false,idAttributes); ds.DataSetName =3D "structure"; =20 @@ -999,6 +1003,7 @@ for(int i=3D0;i<attRows.Count;i++) { attClassSysName =3D Convert.ToString(attRows[i]["refClassSysName"]); + Logger.Log("attClassSysName=3D " + attClassSysName,LogLe= vel.Trace); if(!includes.Contains(attClassSysName)) { includes.Add(attClassSysName); Modified: humano2/trunk/components/webTools/xmltools.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/xmltools.cs 2005-06-16 19:11:17 UTC= (rev 1337) +++ humano2/trunk/components/webTools/xmltools.cs 2005-06-16 20:20:35 UTC= (rev 1338) @@ -133,5 +133,45 @@ } return result; } + =20 + ///<summary> + ///Takes a xml string representing a structure of a form with cl= ass and attributes. + ///The objective is to reorder the tags "attribute" using a list= of attributes (that comes from the table [form]) + ///</summary> + ///<param name=3D"xmlStructure"></param> + ///<param name=3D"attributesList">The list of id of attributes: = we want this order for the xml struture string</param> + ///<returns>the xml datastruture with the tags "attributes" in s= ame order as in attributesList</returns> + public static string OrderAttributesInDataStructure( string xmlD= ataStructure, string attributesList, string xslPath) + { + //First add the list of attribute in the xml that will be pr= ocessed by the xsk + string xmlAttributesList =3D ""; + string [] xmlAttArr =3D attributesList.Split(",".ToCharArray= ()); + int size =3D xmlAttArr.Length; + =20 + if(attributesList!=3D"")=20 + { + for(int i=3D0;i<size;i++) + { + xmlAttributesList +=3D "<id>" + xmlAttArr[i] + "</id= >"; =20 + } + } + else //Nothing to change exit + { + return xmlDataStructure; =20 + } + =20 + string xmlWithAttributesList =3D ""; + xmlWithAttributesList =3D + "<dataWithAttributes>" + + xmlDataStructure + + "<attributesList>" + + xmlAttributesList + + "</attributesList>" =20 + + "</dataWithAttributes>"; + //Logger.Log("xmlWithAttributesList: " + xmlWithAttributesLi= st,LogLevel.Trace); + string res =3D TransformXML(xmlWithAttributesList, xslPath, = null); + //Logger.Log("res: " + res,LogLevel.Trace); + return res; + } } } Modified: humano2/trunk/web/portal/site/instance.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/instance.aspx.cs 2005-06-16 19:11:17 UT= C (rev 1337) +++ humano2/trunk/web/portal/site/instance.aspx.cs 2005-06-16 20:20:35 UT= C (rev 1338) @@ -35,44 +35,41 @@ =20 namespace Portal.site { - /// <summary> - /// Pagina encargada de desplegar las interfaces de read, update y crea= te - /// para instancias del modelo. - /// Recibe como parametro idEntity de la instancia o clase a crear (id_= entity) - /// El tipo de display a desplegar (display) - /// Atributos pre-seteados (id,value), solo valido para modo create - /// </summary> - public class instance : basePage - { - private void Page_Load(object sender, System.EventArgs e) - { - //Obtengo el adaptador con la base de datos. - adapter dbAdapter =3D userCred.CoreAdapter; - =20 - =20 + /// <summary> + /// Pagina encargada de desplegar las interfaces de read, update y c= reate + /// para instancias del modelo. + /// Recibe como parametro idEntity de la instancia o clase a crear (= id_entity) + /// El tipo de display a desplegar (display) + /// Atributos pre-seteados (id,value), solo valido para modo create + /// </summary> + public class instance : basePage + { + private void Page_Load(object sender, System.EventArgs e) + { + =20 + Logger.Log("=3D=3D instance.aspx.cs =3D=3D",LogLevel.Trace); + //Obtengo el adaptador con la base de datos. + adapter dbAdapter =3D userCred.CoreAdapter; + =20 //Paso los xsl que necesito a un nameValue. - //Debido a que .Net es idiot.. y agrega un "\r\n" en el ultimo elemen= to del - //del post hay que agregar un elemento mas. - //Los Xsl especificos que usaremos - ArrayList xslInclude =3D new ArrayList(); - =20 + //Debido a que .Net es idiot.. y agrega un "\r\n" en el ulti= mo elemento del + //del post hay que agregar un elemento mas. + //Los Xsl especificos que usaremos + ArrayList xslInclude =3D new ArrayList(); + =20 //WARNING: xslInclude is updated by this function, don't put= the call after the next loop!!!! string strXml =3D createXmlASP(dbAdapter,xslInclude); - =20 NameValueCollection xslToInclude =3D new NameValueCollectio= n(); - for(int i=3D0;i<xslInclude.Count;i++) - { - xslToInclude.Add("include",xslInclude[i].ToString()); - } - xslToInclude.Add("end",""); //.Net idiot... podria asegurar que esto = es un bug - =20 + for(int i=3D0;i<xslInclude.Count;i++) + { + xslToInclude.Add("include",xslInclude[i].ToString()); + } + xslToInclude.Add("end",""); //.Net idiot... podria asegurar = que esto es un bug =20 //Get the url to dowload the xsl object //Reconstruyo el url - string cUrl =3D Regex.Split(Request.Url.AbsoluteUri,"/[^/]*$")[0] += "/";=09 + string cUrl =3D Regex.Split(Request.Url.AbsoluteUri,"/[^/]= *$")[0] + "/";=09 string urlAspToXsl =3D cUrl + "readXslt.aspx"; - =09 - =20 //To show only the xml source bool onlyXml =3D Request["Xml"] =3D=3D "true";=20 if(onlyXml) @@ -81,221 +78,220 @@ string XmlTransformedResult =3D Humano2.Components.WebTo= ols.Xml.TransformXML(strXml, fullUrl, Response); Response.Write(XmlTransformedResult); =20 } - =20 - =20 //Ahora pido via web el xsl para generar la pagina html pedi= da - //La pagina que retormna el xsl resive los argumentos por post, - //asi que la tenemos que llamarla a mano - //La razon que sea via web, es para poder compartir el xsl con tercer= os. + //La pagina que retormna el xsl resive los argumentos por po= st, + //asi que la tenemos que llamarla a mano + //La razon que sea via web, es para poder compartir el xsl c= on terceros. string HtmlResult =3D Humano2.Components.WebTools.Xml.Transf= ormXMLASP(strXml,urlAspToXsl,xslToInclude,Response); - Response.Write(HtmlResult); - } - - =20 - /// <summary> - /// Get the XML used then to create Html code of the page - /// ATTENTION: This function is a little different from the = createXml one, because=20 - /// multiple xsl are involved. - ///<param name=3D'dbAdapter'>To get useful datas for the xml= </param> - ///<param name=3D'xslInclude'>An array list that is updated = by the dbAdapter</param> - /// </summary> - private string createXmlASP(adapter dbAdapter, ArrayList xsl= Include) + Response.Write(HtmlResult); + } + =20 + =20 + /// <summary> + /// Get the XML used then to create Html code of the page + /// ATTENTION: This function is a little different from the crea= teXml one, because=20 + /// multiple xsl are involved. + ///<param name=3D'dbAdapter'>To get useful datas for the xml</pa= ram> + ///<param name=3D'xslInclude'>An array list that is updated by t= he dbAdapter</param> + /// </summary> + private string createXmlASP(adapter dbAdapter, ArrayList xslIncl= ude) + { + //Para obtener la info que se nos manda. + int idEntity; + string displayType; + string theAction; + string pertinence; + string idView; + int formAttribute =3D 0; + string idforms =3D""; + //Logger.Log("createXmlASP: BEGIN",LogLevel.Trace); + //Generamos el XML con la informacion de la entidad pedida=20 + //El id de la instancia y us tipo de display + idEntity =3D Convert.ToInt32(Request.QueryString["id_enti= ty"]); + idforms =3D Request.QueryString["formsId"]; + displayType =3D Request.Params["display"]; + theAction =3D Request.Params["action"]; + idView =3D Request.Params["idView"]; + =20 + string listAtt=3D""; + DataSet dtrq; + =20 + if(idforms !=3D "" && idforms !=3D null) { - //Para obtener la info que se nos manda. - int idEntity; - string displayType; - string theAction; - string pertinence; - - string idView; - int formAttribute =3D 0; - string idforms =3D""; - - - - //Logger.Log("createXmlASP: BEGIN",LogLevel.Trace); - =20 - //Generamos el XML con la informacion de la entidad pedida=20 - =09 - //El id de la instancia y us tipo de display - idEntity =3D Convert.ToInt32(Request.QueryString["id_= entity"]); - idforms =3D Request.QueryString["formsId"]; - displayType =3D Request.Params["display"]; - theAction =3D Request.Params["action"]; - idView =3D Request.Params["idView"]; - - string listAtt=3D""; - DataSet dtrq; - =09 - if(idforms !=3D "" && idforms !=3D null) - { - formAttribute=3D Convert.ToInt32(idforms); - dtrq=3DdbAdapter.ReadDatarq(formAttribute,"1204"); - listAtt =3D dtrq.Tables[0].Rows[0]["data"].ToString(); - } - =09 - =09 - //Response.Write(idEntity); - - //agregamos tag que indica cuales son los objetos que cuelgan de mi - int classid =3D dbAdapter.GetClassByID(idEntity); - if(theAction.ToLower()!=3D"create" && theAction.ToLower()!=3D"delete= ") - { - pertinence =3D dbAdapter.PertinenceGet(Convert.ToString(classid),"f= "); - if(idEntity>0 && classid>0) - { - try - { - dbAdapter.FormulasForClass(classid,idEntity); - } - catch - { - //Nada - } - } - } - else - { - pertinence =3D ""; - } - =20 - string InfoClass; - =09 - - string nameClass =3D ""; - if(Convert.ToString(classid)!=3D"" && Convert.ToString(classid)!=3D"= 2") - nameClass =3D dbAdapter.GetClassNameById(classid); - else - nameClass =3D dbAdapter.GetClassNameById(idEntity); - - =09 -=09 - - InfoClass =3D "<Info><idClass>" + classid + "</idClass><nameClass>"= + nameClass + "</nameClass><id_entity>"+idEntity+"</id_entity><idView>"+= idView+"</idView></Info>"; - - =09 - //Verifico resibir un Xslt valido - if (displayType!=3DPortalXslt.readPageTag && - displayType!=3DPortalXslt.updatePageTag &&=20 - displayType!=3DPortalXslt.createPageTag) + formAttribute=3D Convert.ToInt32(idforms); + dtrq=3DdbAdapter.ReadDatarq(formAttribute,"1204"); + listAtt =3D dtrq.Tables[0].Rows[0]["data"].ToString(); + } + Logger.Log("listAtt=3D " + listAtt,LogLevel.Trace); + //Response.Write(idEntity); + //agregamos tag que indica cuales son los objetos que cuelga= n de mi + int classid =3D dbAdapter.GetClassByID(idEntity); + if(theAction.ToLower()!=3D"create" && theAction.ToLower()!=3D= "delete") + { + pertinence =3D dbAdapter.PertinenceGet(Convert.ToString(= classid),"f"); + if(idEntity>0 && classid>0) + { + try { - throw new Exception("Oops, invalid XSLT"); + dbAdapter.FormulasForClass(classid,idEntity); } - =09 - //Extraer Atributos a mostrar desde la clase FORM - //----------------------------------------------- - - //Intento leer la estrcutura de la instancia - string structure =3D dbAdapter.ReadStructureAndXsls1= (idEntity,xslInclude,listAtt); //AQUI - //SVERA string structure =3D dbAdapter.ReadStructure= AndXsls1(idEntity,xslInclude,formAttribute); - //Construction of the XML string - //Si corresponde intento leer los datos de la instan= cia - string data =3D ""; - string flagaction =3D ""; - - if(theAction =3D=3D "read") - flagaction +=3D "<flagaction>Read</flagactio= n>\n"; - else if(theAction =3D=3D "update") - flagaction +=3D "<flagaction>Update</flagact= ion>\n"; - else if(theAction =3D=3D "create") - flagaction +=3D "<flagaction>Create</flagact= ion>\n"; - else if(theAction =3D=3D "delete") - flagaction +=3D "<flagaction>Delete</flagact= ion>\n"; - - if(displayType=3D=3DPortalXslt.readPageTag) + catch { - data =3D dbAdapter.ReadDataAsXml(idEntity); + //Nada } - else if(displayType=3D=3DPortalXslt.updatePageTag) - { - data =3D dbAdapter.ReadDataAsXml(idEntity); - } - else if(displayType=3D=3DPortalXslt.createPageTag &&= Request.QueryString["id"]!=3Dnull) - { - string[] id =3D Request.QueryString["id= "].Split(','); - string[] value =3D Request.QueryString["va= lue"].Split(','); - - flagaction =3D "<flagaction>Create</flagacti= on>\n"; - =20 - data =3D "<data>\n"; - for(int i=3D0;i<id.Length;i++) - { - data +=3D "<hidden>\n"; - data +=3D "<id_entity>"+id[i]+"<id_e= ntity>\n"; - data +=3D "<data>"+value[i]+"<data>\= n"; - data +=3D "</hidden>\n"; - } - data +=3D "</data>\n"; - } - - //Logger.Log("createXmlASP: data(before)=3D" + data,= LogLevel.Trace); - //Construimos el Xml - string swXml =3D ""; - swXml +=3D "<?xml version=3D\"1.0\" encoding=3D\"UTF= -8\"?>"; - swXml +=3D "<?xml-stylesheet type=3D\"text/xsl\" hre= f=3D\"xsl/createPortal.xsl\"?>"; - swXml +=3D "<page>"; - swXml +=3D "<action>"; - swXml +=3D "<update>"+PortalInstanceC= rud.updatePage+"</update>"; - swXml +=3D "<delete>"+PortalInstanceC= rud.deletePage+"</delete>"; - swXml +=3D "<create>"+PortalInstanceC= rud.createPage+"</create>"; - swXml +=3D "</action>"; - swXml +=3D flagaction; - swXml +=3D "<classInstance>"; - swXml +=3D structure; - swXml +=3D clearDateTimeData(data); /= / don't forget to put date in good format - swXml +=3D "</classInstance>"; - swXml +=3D pertinence; =20 - swXml +=3D InfoClass; - swXml +=3D "</page>"; - =20 - //Logger.Log("createXmlASP: structure=3D" + structur= e,LogLevel.Trace); - //Logger.Log("createXmlASP: clearDateTime(data)=3D" = + clearDateTimeData(data),LogLevel.Trace); - //Logger.Log("swXml: " + swXml ,LogLevel.Trace); - return swXml; + } + } + else + { + pertinence =3D ""; + } =20 + string InfoClass; + string nameClass =3D ""; + if(Convert.ToString(classid)!=3D"" && Convert.ToString(class= id)!=3D"2") + { + nameClass =3D dbAdapter.GetClassNameById(classid); } + else + { + nameClass =3D dbAdapter.GetClassNameById(idEntity); + } + InfoClass =3D "<Info><idClass>" + classid + "</idClass><nam= eClass>" + nameClass + "</nameClass><id_entity>"+idEntity+"</id_entity><i= dView>"+idView+"</idView></Info>"; + //Verifico resibir un Xslt valido + if ( displayType!=3DPortalXslt.readPageTag && + displayType!=3DPortalXslt.updatePageTag &&=20 + displayType!=3DPortalXslt.createPageTag) + { + throw new Exception("Oops, invalid XSLT"); + } =20 - - /// <summary> - /// ATTENTION THIS IS ONLY A PATCH - /// The value of field are getted by the Adapter ReadDataAsX= ml method=20 - /// that returns a string. In this string we replace each da= te that is in format "date:time" - /// by the date in format "date" only...=20 - ///<param name=3D"structure"></param> - ///<returns></returns> - /// </summary> - private string clearDateTimeData(string data) + //Extraer Atributos a mostrar desde la clase FORM + //----------------------------------------------- + =20 + //Intento leer la estrcutura de la instancia + Logger.Log("idEntity=3D " + idEntity,LogLevel.Trace); + string structure =3D dbAdapter.ReadStructureAndXsls1(idEntit= y,xslInclude,listAtt); //AQUI + Logger.Log("structure(before)=3D" + structure,LogLevel.Trac= e); + //Reorder the attributes as they appear in the selected orde= r (form) + structure =3D Humano2.Components.WebTools.Xml.OrderAttribute= sInDataStructure(structure, listAtt, "portal/site/xsl/orderattributes.xsl= "); + Logger.Log("structure(after)=3D" + structure,LogLevel.Trace= ); + //SVERA string structure =3D dbAdapter.ReadStructureAndXsls1= (idEntity,xslInclude,formAttribute); + //Construction of the XML string + //Si corresponde intento leer los datos de la instancia + string data =3D ""; + string flagaction =3D ""; + =20 + //FIXME: change for a switch + if(theAction =3D=3D "read") { - //We use a xsl to do the transformation... :) - string urlXslToClearDate =3D baseUrl() + "xsl/cleardate= fromdata.xsl"; - string dateClearedData =3D Humano2.Components.WebTools.X= ml.TransformXML(data,urlXslToClearDate,Response); - //Logger.Log("\n\n[clearDateTimeData ]: " + dateClearedD= ata, LogLevel.Trace); - dateClearedData =3D dateClearedData.Replace("[","<"); = =20 - dateClearedData =3D dateClearedData.Replace("]",">"); = =20 - // NO SACAR: Ensucia los campos TEXT!! dateClearedData =3D= dateClearedData.Replace(" ",""); //trim - dateClearedData =3D dateClearedData.Trim(); - //Logger.Log("\n\n[clearDateTimeData ]: " + dateClearedD= ata, LogLevel.Trace); - return dateClearedData; + flagaction +=3D "<flagaction>Read</flagaction>\n"; } + else if(theAction =3D=3D "update") + { + flagaction +=3D "<flagaction>Update</flagaction>\n"; + } + else if(theAction =3D=3D "create") + { + flagaction +=3D "<flagaction>Create</flagaction>\n"; + } + else if(theAction =3D=3D "delete") + { + flagaction +=3D "<flagaction>Delete</flagaction>\n"; + } + =20 + =20 + if(displayType=3D=3DPortalXslt.readPageTag) + { + data =3D dbAdapter.ReadDataAsXml(idEntity); + } + else if(displayType=3D=3DPortalXslt.updatePageTag) + { + data =3D dbAdapter.ReadDataAsXml(idEntity); + } + else if(displayType=3D=3DPortalXslt.createPageTag && Request= .QueryString["id"]!=3Dnull) + { + string[] id =3D Request.QueryString["id"].Split(','= ); + string[] value =3D Request.QueryString["value"].Split(= ','); =20 - #region Web Form Designer generated code - override protected void OnInit(EventArgs e) - { - // - // CODEGEN: This call is required by the ASP.NET Web Form Designer. - // - InitializeComponent(); - base.OnInit(e); - } - =09 - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { =20 - this.Load +=3D new System.EventHandler(this.Page_Load); - } - #endregion - } + flagaction =3D "<flagaction>Create</flagaction>\n"; + =20 + data =3D "<data>\n"; + for(int i=3D0;i<id.Length;i++) + { + data +=3D "<hidden>\n"; + data +=3D "<id_entity>"+id[i]+"<id_entity>\n"; + data +=3D "<data>"+value[i]+"<data>\n"; + data +=3D "</hidden>\n"; + } + data +=3D "</data>\n"; + } + =20 + //Logger.Log("createXmlASP: data(before)=3D" + data,LogLevel= .Trace); + //Construimos el Xml + string swXml =3D ""; + swXml +=3D "<?xml version=3D\"1.0\" encoding=3D\"UTF-8\"?>"; + swXml +=3D "<?xml-stylesheet type=3D\"text/xsl\" href=3D\"xs= l/createPortal.xsl\"?>"; + swXml +=3D "<page>"; + swXml +=3D "<action>"; + swXml +=3D "<update>"+PortalInstanceCrud.upda= tePage+"</update>"; + swXml +=3D "<delete>"+PortalInstanceCrud.dele= tePage+"</delete>"; + swXml +=3D "<create>"+PortalInstanceCrud.crea= tePage+"</create>"; + swXml +=3D "</action>"; + swXml +=3D flagaction; + swXml +=3D "<classInstance>"; + swXml +=3D structure; + swXml +=3D clearDateTimeData(data); // don't = forget to put date in good format + swXml +=3D "</classInstance>"; + swXml +=3D pertinence; =20 + swXml +=3D InfoClass; + swXml +=3D "</page>"; + =20 + //Logger.Log("createXmlASP: structure=3D" + structure,LogLev= el.Trace); + //Logger.Log("createXmlASP: clearDateTime(data)=3D" + clearD= ateTimeData(data),LogLevel.Trace); + //Logger.Log("swXml: " + swXml ,LogLevel.Trace); + return swXml; + } + =20 + /// <summary> + /// ATTENTION THIS IS ONLY A PATCH + /// The value of field are getted by the Adapter ReadDataAsXml m= ethod=20 + /// that returns a string. In this string we replace each date t= hat is in format "date:time" + /// by the date in format "date" only...=20 + ///<param name=3D"structure"></param> + ///<returns></returns> + /// </summary> + private string clearDateTimeData(string data) + { + //We use a xsl to do the transformation... :) + string urlXslToClearDate =3D baseUrl() + "xsl/cleardatefrom= data.xsl"; + string dateClearedData =3D Humano2.Components.WebTools.Xml.T= ransformXML(data,urlXslToClearDate,Response); + //Logger.Log("\n\n[clearDateTimeData ]: " + dateClearedData,= LogLevel.Trace); + dateClearedData =3D dateClearedData.Replace("[","<"); = =20 + dateClearedData =3D dateClearedData.Replace("]",">"); = =20 + // NO SACAR: Ensucia los campos TEXT!! dateClearedData =3D d= ateClearedData.Replace(" ",""); //trim + dateClearedData =3D dateClearedData.Trim(); + //Logger.Log("\n\n[clearDateTimeData ]: " + dateClearedData,= LogLevel.Trace); + return dateClearedData; + } + =20 + #region Web Form Designer generated code + override protected void OnInit(EventArgs e) + { + // + // CODEGEN: This call is required by the ASP.NET Web Form De= signer. + // + InitializeComponent(); + base.OnInit(e); + } + =20 + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { =20 + this.Load +=3D new System.EventHandler(this.Page_Load); + } + #endregion + } } Added: humano2/trunk/web/portal/site/xsl/orderattributes.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/orderattributes.xsl 2005-06-16 19:1= 1:17 UTC (rev 1337) +++ humano2/trunk/web/portal/site/xsl/orderattributes.xsl 2005-06-16 20:2= 0:35 UTC (rev 1338) @@ -0,0 +1,24 @@ +<xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"http://www.w3.org/1999/XSL/= Transform"> <!-- xmlns:fo=3D"http://www.w3.org/1999/XSL/Format"> --> + <!-- $Id$ --> + <xsl:output method=3D"html" /> + <xsl:template match=3D"/"> + <structure> + <xsl:copy-of select=3D"/dataWithAttributes/structure/entity"= /> <!-- copy entity info --> + <xsl:for-each select=3D"/dataWithAttributes/structure/class"= > <!-- copy the classes --> + <xsl:copy-of select=3D"." /> + </xsl:for-each> + <!-- now copy the attributes in good order --> + <xsl:for-each select=3D"/dataWithAttributes/attributesList/i= d"> + <xsl:variable name=3D"currentId"> + <xsl:value-of select=3D"." /> + </xsl:variable> + <xsl:copy-of select=3D"/dataWithAttributes/structure/att= ribute[id_entity=3D$currentId]" /> + </xsl:for-each> + <!-- copy what remains --> + <xsl:for-each select=3D"/dataWithAttributes/structure/*[name= ()!=3D'class' and name()!=3D'attribute' and name()!=3D'entity']"> + <xsl:copy-of select=3D"."/> + </xsl:for-each> + </structure> + </xsl:template> +</xsl:stylesheet> + Property changes on: humano2/trunk/web/portal/site/xsl/orderattributes.xs= l ___________________________________________________________________ Name: svn:keywords + Id |