|
From: <sv...@de...> - 2005-06-14 22:21:30
|
Author: pcamacho Date: 2005-06-14 18:21:31 -0400 (Tue, 14 Jun 2005) New Revision: 1326 Added: humano2/trunk/components/webTools/interfacetools.cs Modified: humano2/trunk/components/webTools/xmltools.cs humano2/trunk/web/builder/site/createreport.aspx.cs humano2/trunk/web/builder/site/js/createinterfacetools.js humano2/trunk/web/builder/site/viewmain.aspx.cs humano2/trunk/web/builder/site/xsl/createreport.xsl humano2/trunk/web/builder/site/xsl/createview.xsl Log: CHANGE: * factorization of C# code for creation of view and report * factorization of Reload function in createview.xsl / createreport.xsl Added: humano2/trunk/components/webTools/interfacetools.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/interfacetools.cs 2005-06-14 21:50:= 38 UTC (rev 1325) +++ humano2/trunk/components/webTools/interfacetools.cs 2005-06-14 22:21:= 31 UTC (rev 1326) @@ -0,0 +1,200 @@ +// +// 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. +// +// $Id$ + +using System; +using System.IO; +using System.Web; +using System.Xml.Xsl; +using System.Collections; +using System.Collections.Specialized; +using System.Net; +using System.Text.RegularExpressions; + +using Humano2.Core; + +namespace Humano2.Components.WebTools +{ + public class Interface + { + ///<summary> + /// A order string is received from the web page in this format: + /// idAtt0 | 0 or 1,idAtt1 | 0 or 1 etc... + /// We have to add the queue to each where condition (1|0 or 0|0= ) + ///</summary> + public static string ParseOrder(string order) =20 + { + if(order=3D=3D"" || order =3D=3D null) + { + return ""; =20 + } + =20 + string res =3D ""; + string [] orderSplit =3D order.Split((";").ToCharArray()); /= /First get the lines + =20 + for(int i=3D0;i<orderSplit.Length;i++) + { + string [] lineSplit =3D orderSplit[i].Split(("|").ToChar= Array()); + string line =3D ""; + =20 + line +=3D lineSplit[0]; + line +=3D '|'; =20 + line +=3D lineSplit[1]; + =20 + res +=3D line; + if(i!=3D orderSplit.Length-1) + { + res +=3D ","; =20 + } + //Last line nothing to add + } + =20 + Logger.Log("parseOrder=3D " + res,LogLevel.Trace); + =20 + return res; + } + =20 + ///<summary> + /// A where string is received from the web page in this format: + /// idAtt0 | idOp0 | 'value'|;idAtt1 | idOp1 | 'value'|; ... etc + /// We have to add the queue to each where condition (1|0 or 0|0= ) + ///</summary> + public static string ParseWhere(string where) =20 + { + + if(where=3D=3D"" || where =3D=3D null) //Nothing to do + { + return ""; //Don't return "" because in this case the fi= eld of database won't be updated + } + =20 + string res =3D ""; + string [] whereSplit =3D where.Split((";").ToCharArray()); /= /First get the lines + =20 + for(int i=3D0;i<whereSplit.Length;i++) + { + string [] lineSplit =3D whereSplit[i].Split(("|").ToChar= Array()); + string line =3D ""; + for(int j=3D0; j<lineSplit.Length;j++) + { + line +=3D lineSplit[j]; + line +=3D '|'; =20 + =20 + } + res +=3D line; + if(i!=3D whereSplit.Length-1) + { + res +=3D "1|0;"; =20 + } + else //Last line + { + res +=3D"0|0"; + } + } + Logger.Log("parseWhere(before treatin)=3D " + res,LogLevel.= Trace); + =20 + res =3D treatInSpecialCase(res);=20 + =20 + Logger.Log("parseWhere=3D " + res,LogLevel.Trace); + =20 + return res; + } + =20 + ///<summary> + /// The IN filter must be treated in a special maner. If the val= ue to compare to is "20 30", then=20 + /// this value must be changed to ['20','30']; (ReportToolsDoc) + ///</summary> =20 + private static string treatInSpecialCase(string where) + { + if(where =3D=3D "") + { + return ""; =20 + } + string [] whereArr =3D where.Split(new char [] {'|',';'}); + =20 + for(int i=3D0;i<whereArr.Length;i++) + { + Logger.Log("whereArr" +"[" + Convert.ToString(i) + "]=3D= " + whereArr[i],LogLevel.Trace); + } + =20 + string newWhere=3D"";=20 + for(int i=3D0;i<whereArr.Length;i+=3D5) + { =20 + if(whereArr[i+1] =3D=3D "8") //In case + { + string [] inStrArr =3D whereArr[i+2].Split(new char = [] {' ','\''}); + //rebuild the where str + string whereValueStr =3D ""; + whereValueStr +=3D "[("; + for(int j=3D0;j<inStrArr.Length;j++)=20 + { + if(inStrArr[j] !=3D "") //Remove empty strings a= fter split + whereValueStr +=3D "'" + inStrArr[j] + "'" += ","; =20 + } + whereValueStr =3D whereValueStr.Substring(0,whereVal= ueStr.Length-1); //Remove last coma + whereValueStr +=3D")]"; + =20 + newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereValueStr + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; + } + else + { + newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereArr[2+i] + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; + } + } + newWhere =3D newWhere.Substring(0,newWhere.Length-1); //remo= ve last ';' + Logger.Log("viewmain: treatInSpecialCase return=3D " + newWh= ere, LogLevel.Trace); + return newWhere; + } + + + ///<summary> + /// A having string is received from the web page in this format= : + /// idFunc0 |idAtt0 | idOp0 | 'value'|;idFunc1|idAtt1 | idOp1 | = 'value'|; ... etc + /// We have to add the queue to each where condition (1|0 or 0|0= ) + ///</summary> + public static string ParseHavings(string havings) =20 + { + + if(havings=3D=3D"") //Nothing to do + { + return ""; + } + =20 + string res =3D ""; + string [] havingsSplit =3D havings.Split((";").ToCharArray()= ); //First get the lines + =20 + for(int i=3D0;i<havingsSplit.Length;i++) + { + string [] lineSplit =3D havingsSplit[i].Split(("|").ToCh= arArray()); + string line =3D ""; + for(int j=3D0; j<lineSplit.Length;j++) + { + line +=3D lineSplit[j]; + line +=3D '|'; =20 + } + res +=3D line; + if(i!=3D havingsSplit.Length-1) + { + res +=3D "1|0;"; =20 + } + else //Last line + { + res +=3D"0|0"; + } + } + Logger.Log("parseHavings(before treatin)=3D " + res,LogLeve= l.Trace); + =20 + //res =3D treatInSpecialCase(res);=20 + =20 + Logger.Log("parseHavings=3D " + res,LogLevel.Trace); + =20 + return res; + } =20 + } +} Property changes on: humano2/trunk/components/webTools/interfacetools.cs ___________________________________________________________________ Name: svn:keywords + Id 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-14 21:50:38 UTC= (rev 1325) +++ humano2/trunk/components/webTools/xmltools.cs 2005-06-14 22:21:31 UTC= (rev 1326) @@ -7,7 +7,7 @@ // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // -// $Id $ +// $Id$ =20 using System; using System.IO; @@ -22,118 +22,116 @@ =20 namespace Humano2.Components.WebTools { - public class Xml + public class Xml + { + ///<summary> + ///Applies an xsl transformation to a xml document + ///</summary> + ///<param name=3D'strXML'>The string of the xml document</param> + ///<param name=3D'strXSLURL'>The url of the xsl</param> + ///<param name=3D'Response'>The html response object to send exc= eption if needed</param> + ///<returns>The result of transformation</returns> + public static string TransformXML(string strXML, string strXSLUR= L, System.Web.HttpResponse Response) { - ///<summary> - ///Applies an xsl transformation to a xml document - ///</summary> - ///<param name=3D'strXML'>The string of the xml document= </param> - ///<param name=3D'strXSLURL'>The url of the xsl</param> - ///<param name=3D'Response'>The html response object to = send exception if needed</param> - ///<returns>The result of transformation</returns> - public static string TransformXML(string strXML, string = strXSLURL, System.Web.HttpResponse Response) - { - System.Xml.Xsl.XslTransform oXSLT =3D new System= .Xml.Xsl.XslTransform(); - oXSLT.Load(strXSLURL); - return TransformXML(strXML,oXSLT,Response); - } - =20 - ///<summary> - ///Build a xsl via APS page and a list of names (that re= presents xsl) and applies - ///the transformation to an xml string - ///</summary> - ///<param name=3D'strXML'>The string of the xml document= </param> - ///<param name=3D'strXSLURL'>The url of the xsl</param> - ///<param name=3D'parameters'>La lista de nombre que rep= resentan xsl</param> - ///<param name=3D'Response'>The html response object to = send exception if needed</param> - ///<returns>The result of transformation</returns> - public static string TransformXMLASP( string strXML,=20 - string strXSLURL= ,=20 - NameValueCollect= ion parameters, - System.Web.HttpR= esponse Response) - { - System.Xml.Xsl.XslTransform oXSLT =3D GetXSLFrom= ASP(strXSLURL,parameters); - return TransformXML(strXML,oXSLT,Response); - } - =20 - ///<summary> - ///Do an XSLT transform with an xml string and an System= .Xml.Xsl.XslTransform object - ///</summary> - ///<param name=3D'strXML'>The string of the xml document= </param> - ///<param name=3D'xsl'>The url of the xsl</param> - ///<param name=3D'Response'>The html response object to = send exception if needed</param> - ///<returns>The result of transformation</returns> - private static string TransformXML(string strXML, System= .Xml.Xsl.XslTransform xsl, System.Web.HttpResponse Response) - { - =20 - //Logger.Log("Result of transformation: " + strX= ML, LogLevel.Trace); - System.IO.StringWriter oSW =3D new System.IO.Str= ingWriter(); - try - { - System.Xml.XmlTextReader oXR =3D new Sy= stem.Xml.XmlTextReader(new StringReader(strXML)); - System.Xml.XPath.XPathDocument oXPath =3D= new System.Xml.XPath.XPathDocument(oXR); - xsl.Transform(oXPath,null,oSW); - } - catch (System.Exception e) - { - //Put in custom error handler here... - //string x =3D e.ToString(); - //Response.Write(x); - } - =20 - return oSW.ToString(); - } - =20 - ///<summary> - ///Call an asp page that will build an xsl object from p= arameters that represents other xsl... Whoaw! - ///</summary> - ///<param name=3D'url'>The string of the xml document</p= aram> - ///<param name=3D'parameters'>The url of the xsl</param> - ///<returns>An xsl object ; ready to apply a transformat= ion</returns> - private static System.Xml.Xsl.XslTransform GetXSLFromASP= (string url, NameValueCollection parameters) - { - System.Net.WebClient wcXsl =3D new WebClient(); - byte[] page =3D wcXsl.UploadValues(url,"POST",parameters); - - System.Xml.Xsl.XslTransform xsl =3D new System.Xml.Xsl.XslTransform()= ; + System.Xml.Xsl.XslTransform oXSLT =3D new System.Xml.Xsl.Xsl= Transform(); + oXSLT.Load(strXSLURL); + return TransformXML(strXML,oXSLT,Response); + } + =20 + ///<summary> + ///Build a xsl via APS page and a list of names (that represents= xsl) and applies + ///the transformation to an xml string + ///</summary> + ///<param name=3D'strXML'>The string of the xml document</param> + ///<param name=3D'strXSLURL'>The url of the xsl</param> + ///<param name=3D'parameters'>La lista de nombre que representan= xsl</param> + ///<param name=3D'Response'>The html response object to send exc= eption if needed</param> + ///<returns>The result of transformation</returns> + public static string TransformXMLASP( string strXML,=20 + string strXSLURL,=20 + NameValueCollection para= meters, + System.Web.HttpResponse = Response) + { + System.Xml.Xsl.XslTransform oXSLT =3D GetXSLFromASP(strXSLUR= L,parameters); + return TransformXML(strXML,oXSLT,Response); + } + =20 + ///<summary> + ///Do an XSLT transform with an xml string and an System.Xml.Xsl= .XslTransform object + ///</summary> + ///<param name=3D'strXML'>The string of the xml document</param> + ///<param name=3D'xsl'>The url of the xsl</param> + ///<param name=3D'Response'>The html response object to send exc= eption if needed</param> + ///<returns>The result of transformation</returns> + private static string TransformXML(string strXML, System.Xml.Xsl= .XslTransform xsl, System.Web.HttpResponse Response) + { + //Logger.Log("Result of transformation: " + strXML, LogLevel= .Trace); + System.IO.StringWriter oSW =3D new System.IO.StringWriter(); + try + { + System.Xml.XmlTextReader oXR =3D new System.Xml.Xml= TextReader(new StringReader(strXML)); + System.Xml.XPath.XPathDocument oXPath =3D new Syste= m.Xml.XPath.XPathDocument(oXR); + xsl.Transform(oXPath,null,oSW); + } + catch (System.Exception e) + { + //Put in custom error handler here... + //string x =3D e.ToString(); + //Response.Write(x); + } =20 + return oSW.ToString(); + } + =20 + ///<summary> + ///Call an asp page that will build an xsl object from parameter= s that represents other xsl... Whoaw! + ///</summary> + ///<param name=3D'url'>The string of the xml document</param> + ///<param name=3D'parameters'>The url of the xsl</param> + ///<returns>An xsl object ; ready to apply a transformation</ret= urns> + private static System.Xml.Xsl.XslTransform GetXSLFromASP(string = url, NameValueCollection parameters) + { + System.Net.WebClient wcXsl =3D new WebClient(); + byte[] page =3D wcXsl.UploadValues(url,"POST",parameters); + =20 + System.Xml.Xsl.XslTransform xsl =3D new System.Xml.Xsl.XslTr= ansform(); =20 page =3D cleanXsl(page); //Throw the bad charact= ers (\r,\n that causes trouble in windows) System.IO.MemoryStream memPage =3D new MemoryStr= eam(page); - xsl.Load(new System.Xml.XmlTextReader(memPage),new System.Xml.XmlUrlR= esolver() ,null); =09 - return xsl; - } - =20 - private static byte [] cleanXsl(byte [] xslArray) - { - string xslString =3D ByteArrayToString(xslArray)= ; - //xslString =3D xslString.Replace("\n",""); //th= row \n - //xslString =3D xslString.Replace("\r",""); // t= hrow \r - if(xslString[0]!=3D'<') - xslString=3D xslString.Substring(2); //S= kip the two first caracters - =20 - return StringToByteArray(xslString); - } - =20 - private static byte [] StringToByteArray(string str) - { - byte [] array =3D new byte[str.Length]; - =20 - for(int i=3D0; i< str.Length;i++) - { - array[i] =3D Convert.ToByte(str[i]); - } - =20 - return array; - } - =20 - private static string ByteArrayToString(byte [] array) - { - string result =3D ""; - for(int i=3D0; i<array.Length;i++) =20 - { - result +=3D Convert.ToChar(array[i]); - } - return result; - } + xsl.Load(new System.Xml.XmlTextReader(memPage),new System.Xm= l.XmlUrlResolver() ,null); =09 + return xsl; } + =20 + private static byte [] cleanXsl(byte [] xslArray) + { + string xslString =3D ByteArrayToString(xslArray); + //xslString =3D xslString.Replace("\n",""); //throw \n + //xslString =3D xslString.Replace("\r",""); // throw \r + if(xslString[0]!=3D'<') + xslString=3D xslString.Substring(2); //Skip the two firs= t caracters + =20 + return StringToByteArray(xslString); + } + =20 + private static byte [] StringToByteArray(string str) + { + byte [] array =3D new byte[str.Length]; + =20 + for(int i=3D0; i< str.Length;i++) + { + array[i] =3D Convert.ToByte(str[i]); + } + =20 + return array; + } + =20 + private static string ByteArrayToString(byte [] array) + { + string result =3D ""; + for(int i=3D0; i<array.Length;i++) =20 + { + result +=3D Convert.ToChar(array[i]); + } + return result; + } + } } Property changes on: humano2/trunk/components/webTools/xmltools.cs ___________________________________________________________________ Name: svn:keywords + Id Modified: humano2/trunk/web/builder/site/createreport.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/builder/site/createreport.aspx.cs 2005-06-14 21:50:= 38 UTC (rev 1325) +++ humano2/trunk/web/builder/site/createreport.aspx.cs 2005-06-14 22:21:= 31 UTC (rev 1326) @@ -474,9 +474,6 @@ return null; } =20 - // List of attributes to show. - //string columnsStr =3D "0,"; - =20 if(receivedColumnsStr =3D=3D "0") //No columns =3D> No Updat= e/Create { Logger.Log("No columns for report",LogLevel.Trace); @@ -487,26 +484,14 @@ DataRow dr =3D dt.NewRow(); dr["idClassReport"] =3D receivedClassId; dr["reportName"] =3D receivedReportName; - =20 - //Logger.Log("reportmain: checkForPertinence: " + userCred.C= oreAdapter.CheckForPertinence(receivedColumnsStr),LogLevel.Trace); - =20 - //dr["columns"] =3D userCred.CoreAdapter.CheckForPertinence(= receivedColumnsStr); //If a column is a pertinence, change it dr["groupby"] =3D receivedColumnsStr; //The columns selected= by user are to put in group by - =20 - //Special case for IN filter - dr["where"] =3D parseWhere(receivedWhereStr); - =20 + dr["where"] =3D Interface.ParseWhere(receivedWhereStr); dr["columns"] =3D buildColumnsForReport(receivedPersoColumns= Str,dr["groupby"].ToString()); // - =20 - dr["order"] =3D parseOrder(receivedOrderStr); - =20 - dr["having"] =3D parseHavings(receivedHavingsStr); - =20 + dr["order"] =3D Interface.ParseOrder(receivedOrderStr); + dr["having"] =3D Interface.ParseHavings(receivedHavingsStr); Logger.Log("receivedOrderStr" + receivedOrderStr, LogLevel.T= race); Logger.Log("receivedWhereStr" + receivedWhereStr, LogLevel.T= race); - =09 dt.Rows.Add(dr); - =20 return dt; } =20 @@ -551,182 +536,7 @@ =20 return res; } - =20 - ///<summary> - /// A order string is received from the web page in this format: - /// idAtt0 | 0 or 1,idAtt1 | 0 or 1 etc... - /// We have to add the queue to each where condition (1|0 or 0|0= ) - ///</summary> - private string parseOrder(string order) =20 - { - if(order=3D=3D"" || order =3D=3D null) - { - return ""; =20 - } =20 - string res =3D ""; - string [] orderSplit =3D order.Split((";").ToCharArray()); /= /First get the lines - =20 - for(int i=3D0;i<orderSplit.Length;i++) - { - string [] lineSplit =3D orderSplit[i].Split(("|").ToChar= Array()); - string line =3D ""; - =20 - line +=3D lineSplit[0]; - line +=3D '|'; =20 - line +=3D lineSplit[1]; - =20 - res +=3D line; - if(i!=3D orderSplit.Length-1) - { - res +=3D ","; =20 - } - //Last line nothing to add - } - =20 - Logger.Log("parseOrder=3D " + res,LogLevel.Trace); - =20 - return res; - } - =20 - =20 - ///<summary> - /// A where string is received from the web page in this format: - /// idAtt0 | idOp0 | 'value'|;idAtt1 | idOp1 | 'value'|; ... etc - /// We have to add the queue to each where condition (1|0 or 0|0= ) - ///</summary> - private string parseWhere(string where) =20 - { - - if(where=3D=3D"" || where =3D=3D null) //Nothing to do - { - return ""; //Don't return "" because in this case the fi= eld of database won't be updated - } - =20 - string res =3D ""; - string [] whereSplit =3D where.Split((";").ToCharArray()); /= /First get the lines - =20 - for(int i=3D0;i<whereSplit.Length;i++) - { - string [] lineSplit =3D whereSplit[i].Split(("|").ToChar= Array()); - string line =3D ""; - for(int j=3D0; j<lineSplit.Length;j++) - { - line +=3D lineSplit[j]; - line +=3D '|'; =20 - =20 - } - res +=3D line; - if(i!=3D whereSplit.Length-1) - { - res +=3D "1|0;"; =20 - } - else //Last line - { - res +=3D"0|0"; - } - } - Logger.Log("parseWhere(before treatin)=3D " + res,LogLevel.= Trace); - =20 - res =3D treatInSpecialCase(res);=20 - =20 - Logger.Log("parseWhere=3D " + res,LogLevel.Trace); - =20 - return res; - } - =20 - =20 - ///<summary> - /// A having string is received from the web page in this format= : - /// idFunc0 |idAtt0 | idOp0 | 'value'|;idFunc1|idAtt1 | idOp1 | = 'value'|; ... etc - /// We have to add the queue to each where condition (1|0 or 0|0= ) - ///</summary> - private string parseHavings(string havings) =20 - { - - if(havings=3D=3D"") //Nothing to do - { - return ""; - } - =20 - string res =3D ""; - string [] havingsSplit =3D havings.Split((";").ToCharArray()= ); //First get the lines - =20 - for(int i=3D0;i<havingsSplit.Length;i++) - { - string [] lineSplit =3D havingsSplit[i].Split(("|").ToCh= arArray()); - string line =3D ""; - for(int j=3D0; j<lineSplit.Length;j++) - { - line +=3D lineSplit[j]; - line +=3D '|'; =20 - } - res +=3D line; - if(i!=3D havingsSplit.Length-1) - { - res +=3D "1|0;"; =20 - } - else //Last line - { - res +=3D"0|0"; - } - } - Logger.Log("parseHavings(before treatin)=3D " + res,LogLeve= l.Trace); - =20 - //res =3D treatInSpecialCase(res);=20 - =20 - Logger.Log("parseHavings=3D " + res,LogLevel.Trace); - =20 - return res; - } - =20 - =20 - ///<summary> - /// The IN filter must be treated in a special maner. If the val= ue to compare to is "20 30", then=20 - /// this value must be changed to ['20','30']; (ReportToolsDoc) - ///</summary> =20 - private string treatInSpecialCase(string where) - { - if(where =3D=3D "") - { - return ""; =20 - } - string [] whereArr =3D where.Split(new char [] {'|',';'}); - =20 - for(int i=3D0;i<whereArr.Length;i++) - { - Logger.Log("whereArr" +"[" + Convert.ToString(i) + "]=3D= " + whereArr[i],LogLevel.Trace); - } - =20 - string newWhere=3D"";=20 - for(int i=3D0;i<whereArr.Length;i+=3D5) - { =20 - if(whereArr[i+1] =3D=3D "8") //In case - { - string [] inStrArr =3D whereArr[i+2].Split(new char = [] {' ','\''}); - //rebuild the where str - string whereValueStr =3D ""; - whereValueStr +=3D "[("; - for(int j=3D0;j<inStrArr.Length;j++)=20 - { - if(inStrArr[j] !=3D "") //Remove empty strings a= fter split - whereValueStr +=3D "'" + inStrArr[j] + "'" += ","; =20 - } - whereValueStr =3D whereValueStr.Substring(0,whereVal= ueStr.Length-1); //Remove last coma - whereValueStr +=3D")]"; - =20 - newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereValueStr + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; - } - else - { - newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereArr[2+i] + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; - } - } - newWhere =3D newWhere.Substring(0,newWhere.Length-1); //remo= ve last ';' - Logger.Log("reportmain: treatInSpecialCase return=3D " + new= Where, LogLevel.Trace); - return newWhere; - } =20 - =20 private void ProcessCreationUpdate() { =20 Modified: humano2/trunk/web/builder/site/js/createinterfacetools.js =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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/builder/site/js/createinterfacetools.js 2005-06-14 = 21:50:38 UTC (rev 1325) +++ humano2/trunk/web/builder/site/js/createinterfacetools.js 2005-06-14 = 22:21:31 UTC (rev 1326) @@ -178,13 +178,14 @@ return optionArray; } =20 -function Reload() + +function Reload(page) { var indice =3D document.formulario.classList.selectedIndex; if(indice>0) { valor =3D document.formulario.classList.options[indice].value; - self.location =3D "createreport.aspx?classList=3D"+valor; + self.location =3D page + "?classList=3D"+valor; } } =20 Modified: humano2/trunk/web/builder/site/viewmain.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/builder/site/viewmain.aspx.cs 2005-06-14 21:50:38 U= TC (rev 1325) +++ humano2/trunk/web/builder/site/viewmain.aspx.cs 2005-06-14 22:21:31 U= TC (rev 1326) @@ -412,7 +412,6 @@ // List of attributes to show. //string columnsStr =3D "0,"; =20 - =20 if(receivedColumnsStr =3D=3D "0") //No columns =3D> No Updat= e/Create { Logger.Log("No columns for view",LogLevel.Trace); @@ -424,15 +423,11 @@ dr["idClassView"] =3D receivedClassId; dr["viewName"] =3D receivedViewName; =20 - //Logger.Log("viewmain: checkForPertinence: " + userCred.Cor= eAdapter.CheckForPertinence(receivedColumnsStr),LogLevel.Trace); - =20 //dr["columns"] =3D userCred.CoreAdapter.CheckForPertinence(= receivedColumnsStr); //If a column is a pertinence, change it dr["columns"] =3D receivedColumnsStr; //If a column is a per= tinence, change it - =20 //Special case for IN filter - dr["where"] =3D parseWhere(receivedWhereStr);=20 - =20 - dr["order"] =3D parseOrder(receivedOrderStr); + dr["where"] =3D Interface.ParseWhere(receivedWhereStr);=20 + dr["order"] =3D Interface.ParseOrder(receivedOrderStr); Logger.Log("receivedOrderStr" + receivedOrderStr, LogLevel.T= race); Logger.Log("receivedWhereStr" + receivedWhereStr, LogLevel.T= race); =09 @@ -440,187 +435,9 @@ =20 return dt; } - =20 - ///<summary> - /// A order string is received from the web page in this format: - /// idAtt0 | 0 or 1,idAtt1 | 0 or 1 etc... - /// We have to add the queue to each where condition (1|0 or 0|0= ) - ///</summary> - private string parseOrder(string order) =20 - { - if(order=3D=3D"" || order =3D=3D null) - { - return ""; =20 - } - =20 - string res =3D ""; - string [] orderSplit =3D order.Split((";").ToCharArray()); /= /First get the lines - =20 - for(int i=3D0;i<orderSplit.Length;i++) - { - string [] lineSplit =3D orderSplit[i].Split(("|").ToChar= Array()); - string line =3D ""; - =20 - line +=3D lineSplit[0]; - line +=3D '|'; =20 - line +=3D lineSplit[1]; - =20 - res +=3D line; - if(i!=3D orderSplit.Length-1) - { - res +=3D ","; =20 - } - //Last line nothing to add - } - =20 - Logger.Log("parseOrder=3D " + res,LogLevel.Trace); - =20 - return res; - } =20 - =20 - =20 - ///<summary> - /// The IN filter must be treated in a special maner. If the val= ue to compare to is "20 30", then=20 - /// this value must be changed to ['20','30']; (ViewToolsDoc) - ///</summary> =20 - /* - private string treatInSpecialCase(string where) - { - if(where =3D=3D "") - { - return ""; =20 - } - string [] whereArr =3D where.Split(new char [] {'|',';'}); - =20 - for(int i=3D0;i<whereArr.Length;i++) - { - Logger.Log("whereArr" +"[" + Convert.ToString(i) + "]=3D= " + whereArr[i],LogLevel.Trace); - } - =20 - string newWhere=3D"";=20 - for(int i=3D0;i<whereArr.Length;i+=3D5) - { =20 - if(whereArr[i+1] =3D=3D "8") //In case - { - string [] inStrArr =3D whereArr[i+2].Split(new char = [] {' ','\''}); - //rebuild the where str - string whereValueStr =3D ""; - whereValueStr +=3D "[("; - for(int j=3D0;j<inStrArr.Length;j++)=20 - { - if(inStrArr[j] !=3D "") //Remove empty strings a= fter split - whereValueStr +=3D "'" + inStrArr[j] + "'" += ","; =20 - } - whereValueStr =3D whereValueStr.Substring(0,whereVal= ueStr.Length-1); //Remove last coma - whereValueStr +=3D")]"; - =20 - newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereValueStr + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; - } - else - { - newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereArr[2+i] + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; - } - } - newWhere =3D newWhere.Substring(0,newWhere.Length-1); //remo= ve last ';' - Logger.Log("viewmain: treatInSpecialCase return=3D " + newWh= ere, LogLevel.Trace); - return newWhere; - } =20 - */ - ///<summary> - /// The IN filter must be treated in a special maner. If the val= ue to compare to is "20 30", then=20 - /// this value must be changed to ['20','30']; (ReportToolsDoc) - ///</summary> =20 - private string treatInSpecialCase(string where) - { - if(where =3D=3D "") - { - return ""; =20 - } - string [] whereArr =3D where.Split(new char [] {'|',';'}); - =20 - for(int i=3D0;i<whereArr.Length;i++) - { - Logger.Log("whereArr" +"[" + Convert.ToString(i) + "]=3D= " + whereArr[i],LogLevel.Trace); - } - =20 - string newWhere=3D"";=20 - for(int i=3D0;i<whereArr.Length;i+=3D5) - { =20 - if(whereArr[i+1] =3D=3D "8") //In case - { - string [] inStrArr =3D whereArr[i+2].Split(new char = [] {' ','\''}); - //rebuild the where str - string whereValueStr =3D ""; - whereValueStr +=3D "[("; - for(int j=3D0;j<inStrArr.Length;j++)=20 - { - if(inStrArr[j] !=3D "") //Remove empty strings a= fter split - whereValueStr +=3D "'" + inStrArr[j] + "'" += ","; =20 - } - whereValueStr =3D whereValueStr.Substring(0,whereVal= ueStr.Length-1); //Remove last coma - whereValueStr +=3D")]"; - =20 - newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereValueStr + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; - } - else - { - newWhere +=3D whereArr[0+i] + "|" + whereArr[1+i] + = "|" + whereArr[2+i] + "|" +whereArr[3+i] + "|" +whereArr[4+i] + ";"; - } - } - newWhere =3D newWhere.Substring(0,newWhere.Length-1); //remo= ve last ';' - Logger.Log("viewmain: treatInSpecialCase return=3D " + newWh= ere, LogLevel.Trace); - return newWhere; - } =20 - =20 - =20 - ///<summary> - /// A where string is received from the web page in this format: - /// idAtt0 | idOp0 | 'value'|;idAtt1 | idOp1 | 'value'|; ... etc - /// We have to add the queue to each where condition (1|0 or 0|0= ) - ///</summary> - private string parseWhere(string where) =20 - { =20 - if(where=3D=3D"" || where =3D=3D null) //Nothing to do - { - return ""; //Don't return "" because in this case the fi= eld of database won't be updated - } - =20 - string res =3D ""; - string [] whereSplit =3D where.Split((";").ToCharArray()); /= /First get the lines - =20 - for(int i=3D0;i<whereSplit.Length;i++) - { - string [] lineSplit =3D whereSplit[i].Split(("|").ToChar= Array()); - string line =3D ""; - for(int j=3D0; j<lineSplit.Length;j++) - { - line +=3D lineSplit[j]; - line +=3D '|'; =20 - =20 - } - res +=3D line; - if(i!=3D whereSplit.Length-1) - { - res +=3D "1|0;"; =20 - } - else //Last line - { - res +=3D"0|0"; - } - } - Logger.Log("parseWhere(before treatin)=3D " + res,LogLevel.= Trace); - =20 - res =3D treatInSpecialCase(res);=20 - =20 - Logger.Log("parseWhere=3D " + res,LogLevel.Trace); - =20 - return res; - } - =20 private void ProcessCreationUpdate() { - =20 Logger.Log("ViewMain: ProcessCreationUpdate", LogLevel.Trace= ); =20 receivedClassId =3D Request["sendClassId"]; Modified: humano2/trunk/web/builder/site/xsl/createreport.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/builder/site/xsl/createreport.xsl 2005-06-14 21:50:= 38 UTC (rev 1325) +++ humano2/trunk/web/builder/site/xsl/createreport.xsl 2005-06-14 22:21:= 31 UTC (rev 1326) @@ -223,7 +223,7 @@ <!-- Only show classes f= or select when creating --> <xsl:if test=3D"/report/= reportDatas/saveName=3D'Create'" >=20 <td> - <select class=3D"drp= dwn2" id=3D"classList" onchange=3D"Reload();"> + <select class=3D"drp= dwn2" id=3D"classList" onchange=3D"Reload('createreport.aspx');"> <xsl:for-each se= lect=3D"report/classes/class"> <option> <xsl:att= ribute name=3D"name"> Modified: humano2/trunk/web/builder/site/xsl/createview.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/builder/site/xsl/createview.xsl 2005-06-14 21:50:38= UTC (rev 1325) +++ humano2/trunk/web/builder/site/xsl/createview.xsl 2005-06-14 22:21:31= UTC (rev 1326) @@ -42,10 +42,7 @@ i++; </xsl:for-each> </xsl:for-each> - =20 - =20 =20 - =20 ////////////////// //Filter =20 @@ -157,16 +154,6 @@ leftAttribsArr =3D splitColTab["left"]; rightAttribsArr =3D splitColTab["right"]; =20 - function recargar() - { - var indice =3D document.formulario.classList.selecte= dIndex; - if(indice>0) - { - valor =3D document.formulario.classList.options[= indice].value; - self.location =3D "viewmain.aspx?classList=3D"+v= alor; - } - } - =20 </script> </head> <body> @@ -207,7 +194,7 @@ = Form.UpdateFilter(expandFormFilter,this.value); = ">=20 = --> - <select class=3D= "drpdwn2" id=3D"classList" onchange=3D"recargar();"> + <select class=3D= "drpdwn2" id=3D"classList" onchange=3D"Reload('viewmain.aspx');"> <xsl:for-eac= h select=3D"view/classes/class"> <option> <xsl= :attribute name=3D"name"> |