|
From: <sv...@de...> - 2005-06-24 20:03:02
|
Author: pcamacho Date: 2005-06-24 16:03:06 -0400 (Fri, 24 Jun 2005) New Revision: 1421 Added: humano2/trunk/components/webTools/string.cs Modified: humano2/trunk/web/portal/site/report.aspx.cs Log: * FIX: bug #209. * ADD: string.cs file: to put all string tricky funny useful functions of= the code. Added: humano2/trunk/components/webTools/string.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/string.cs 2005-06-24 19:44:58 UTC (= rev 1420) +++ humano2/trunk/components/webTools/string.cs 2005-06-24 20:03:06 UTC (= rev 1421) @@ -0,0 +1,36 @@ +// +// 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.Web; +using System.Web.UI.WebControls; +using System.IO; + +using Humano2.Core; +using Humano2.Core.Db; + + +namespace Humano2.Components.WebTools +{ + /// <summary> + /// This class contains all useful string functions + /// </summary> + public class H2String + { + public static string EscapeStr(string strToEscape, string from, string= to) =20 + { + string res; + res =3D strToEscape.Replace(from,to); + return res; + } + } +} Property changes on: humano2/trunk/components/webTools/string.cs ___________________________________________________________________ Name: svn:keywords + Id Modified: humano2/trunk/web/portal/site/report.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/report.aspx.cs 2005-06-24 19:44:58 UTC = (rev 1420) +++ humano2/trunk/web/portal/site/report.aspx.cs 2005-06-24 20:03:06 UTC = (rev 1421) @@ -31,34 +31,34 @@ =20 namespace Portal.site { - /// <summary> - /// Summary description for showView. - /// </summary> - public class Report : basePage - { - =09 - int iniClass; + /// <summary> + /// Summary description for showView. + /// </summary> + public class Report : basePage + { + =20 + int iniClass; int idEntityReport; =20 -=09 - private void Page_Load(object sender, System.EventArgs e) - { + =20 + private void Page_Load(object sender, System.EventArgs e) + { } - + =20 /// <summary> /// </summary> override protected string createXml() { - string xmlString =3D""; //the result string - =20 - iniClass =3D 0; - idEntityReport =3D Convert.ToInt32(Request.QueryString["id_e= ntity"]); - =20 - DataTable viewRes =3D getViewTableRes(idEntityReport, out in= iClass); //For a report - =20 - xmlString =3D getXmlFromDatableView(viewRes,idEntityReport);= =20 - Logger.Log("report: xml: " + xmlString ,LogLevel.Trace); - return xmlString; + string xmlString =3D""; //the result string + =20 + iniClass =3D 0; + idEntityReport =3D Convert.ToInt32(Request.QueryString["id_entit= y"]); + =20 + DataTable viewRes =3D getViewTableRes(idEntityReport, out iniCla= ss); //For a report + =20 + xmlString =3D getXmlFromDatableView(viewRes,idEntityReport); = =20 + Logger.Log("report: xml: " + xmlString ,LogLevel.Trace); + return xmlString; } =20 ///<summary> @@ -79,106 +79,107 @@ =20 foreach(DataColumn col in viewRes.Columns)=20 { - string colName =3D col.ColumnName; - =20 - if(colName =3D=3D "instanceUrl") //Skip this col - {=20 - continue;=20 - } - =20 - if(colName =3D=3D "id_entity") //Skip this col and updat= e the list of group attributes - {=20 - xmlString +=3D"<attribute><value>id_entity</value><s= how>0</show></attribute>"; =20 - continue;=20 - } - if(colName.StartsWith("id_entity")) //Skip this col - {=20 - continue;=20 - } =20 - xmlString +=3D"<attribute>"; =20 - =20 - //Get the real user column name that corresponds to syst= em column name - string userColName =3D complex.ConvertSysAttNameToUserAt= tName(colName); - =20 - xmlString +=3D "<value>" - + userColName - + "</value><show>1</show>"; = =20 - xmlString +=3D "</attribute>"; + string colName =3D col.ColumnName; + =20 + if(colName =3D=3D "instanceUrl") //Skip this col + {=20 + continue;=20 } + =20 + if(colName =3D=3D "id_entity") //Skip this col and update th= e list of group attributes + {=20 + xmlString +=3D"<attribute><value>id_entity</value><show>0</s= how></attribute>"; =20 + continue;=20 + } + if(colName.StartsWith("id_entity")) //Skip this col + {=20 + continue;=20 + } =20 + xmlString +=3D"<attribute>"; =20 + =20 + //Get the real user column name that corresponds to system c= olumn name + string userColName =3D complex.ConvertSysAttNameToUserAttNam= e(colName); + =20 + xmlString +=3D "<value>" + + userColName + + "</value><show>1</show>"; =20 + xmlString +=3D "</attribute>"; + } xmlString +=3D "</attributes>"; =20 //Fill the xml string with the content of the table (view) foreach(DataRow row in viewRes.Rows) { - string groupValues =3D ""; //The list of values of attri= butes used in agrupation - xmlString +=3D "<instance>"; - foreach( DataColumn col in row.Table.Columns ) + string groupValues =3D ""; //The list of values of attribute= s used in agrupation + xmlString +=3D "<instance>"; + foreach( DataColumn col in row.Table.Columns ) + { + if(col.ColumnName =3D=3D "id_entity")//Get the id_entity= : for now it is not needed,=20 + { //but it may be us= eful later. + // xmlString +=3D "<id_entity>" + // row["id_entity"] + //+ "</id_entity>"; + =20 + xmlString +=3D "<value>" + + "<text>" + row[col] + "</text>"; + //Now check if the attribute is Primary + xmlString +=3D "<isPrimary>"; + if(complex.IsPrimary(col.ColumnName)) { - if(col.ColumnName =3D=3D "id_entity")//Get the i= d_entity: for now it is not needed,=20 - { //but it m= ay be useful later. - // xmlStri= ng +=3D "<id_entity>" - // row["i= d_entity"] - //+ "</id_= entity>"; - =20 - xmlString +=3D "<value>" - + "<text>" + row[col] = + "</text>"; - //Now check if the attribute is Primary - xmlString +=3D "<isPrimary>"; - if(complex.IsPrimary(col.ColumnName)) - { - xmlString +=3D "true"; - } - else - { - xmlString +=3D "false"; - } - xmlString +=3D "</isPrimary>"; - xmlString +=3D "<show>0</show>"; - xmlString +=3D "</value>"; - =20 - } - else //a standard value - { - string auxcolname; - =20 - auxcolname =3D col.ColumnName; - =20 - xmlString +=3D "<value>" - + "<text>" + row[c= ol] + "</text>"; - //Now check if the attribute is Primary - xmlString +=3D "<isPrimary>"; - if(complex.IsPrimary(col.ColumnName)) - { - xmlString +=3D "true"; - } - else - { - xmlString +=3D "false"; - } - xmlString +=3D "</isPrimary>"; - =20 - if(auxcolname.StartsWith("id_entity")) - { - xmlString +=3D "<show>0</show>"; - } - else - { - xmlString +=3D "<show>1</show>"; - } - =20 - //If the value corresponds to an attribute o= f group then add it to the list of values of group - string valueToCompare =3D Convert.ToString(c= omplex.ConvertSysAttNameToIdAttName(auxcolname)); - string fullValue; - if(isInArray( valueToCompare, - getGroupAttributes(idReport)= , - out fullValue)) //Careful: d= on't use fullValue as many target can have the same fullValue=3D> use the= NameValueCollection - { - groupValues +=3D row[col] + separator; - } - xmlString +=3D "</value>"; - } =20 + xmlString +=3D "true"; } + else + { + xmlString +=3D "false"; + } + xmlString +=3D "</isPrimary>"; + xmlString +=3D "<show>0</show>"; + xmlString +=3D "</value>"; =20 + } + else //a standard value + { + string auxcolname; + =20 + auxcolname =3D col.ColumnName; + =20 + xmlString +=3D "<value>" + + "<text>" + row[col] + "</text>"; + //Now check if the attribute is Primary + xmlString +=3D "<isPrimary>"; + if(complex.IsPrimary(col.ColumnName)) + { + xmlString +=3D "true"; + } + else + { + xmlString +=3D "false"; + } + xmlString +=3D "</isPrimary>"; + =20 + if(auxcolname.StartsWith("id_entity")) + { + xmlString +=3D "<show>0</show>"; + } + else + { + xmlString +=3D "<show>1</show>"; + } + =20 + //If the value corresponds to an attribute of group = then add it to the list of values of group + string valueToCompare =3D Convert.ToString(complex.C= onvertSysAttNameToIdAttName(auxcolname)); + string fullValue; + if(isInArray( valueToCompare, getGroupAttributes(i= dReport), out fullValue)) //Careful: don't use fullValue as many target c= an have the same fullValue=3D> use the NameValueCollection + { + groupValues +=3D row[col] + separator; + } + xmlString +=3D "</value>"; + } =20 + } + =20 + //Escape the groupValues string because a "/" of a date = is interpreted like path separator + groupValues =3D H2String.EscapeStr(groupValues,"/","%2F"= ); + =20 //Now add the details for every agrupacion //DataTable viewParamsTable =3D getViewTableRes(idEntity= Report, out iniClass); xmlString +=3D"<details>"; @@ -206,7 +207,7 @@ =20 return columnsTab; } - =20 + =20 private string getOperatorsList(int reportId, string separator) { string operators =3D ""; @@ -220,7 +221,7 @@ } return operators; } - =20 + =20 private string getXmlGroupAttributes(int reportId, string separa= tor) { string [] listAttGroup =3D getGroupAttributes(reportId); @@ -232,7 +233,7 @@ } return listAttGroupStr; } - + =20 private string getGroupByParam(int reportId) { absCrud crud =3D Factory.Crud(); @@ -288,23 +289,23 @@ =20 //FIXME this function exists also (identically) in search.aspx.c= s private DataTable makeDataTableInViewTools() - { - DataTable dt1 =3D new DataTable(); - DataColumn dc1; - dc1 =3D new DataColumn("columna",typeof(string)); - dt1.Columns.Add(dc1); - dc1 =3D new DataColumn("filtros",typeof(string)); - dt1.Columns.Add(dc1); - dc1 =3D new DataColumn("group",typeof(string)); - dt1.Columns.Add(dc1); - dc1 =3D new DataColumn("having",typeof(string)); - dt1.Columns.Add(dc1); - dc1 =3D new DataColumn("order",typeof(string)); - dt1.Columns.Add(dc1); - dc1 =3D new DataColumn("claves",typeof(string)); - dt1.Columns.Add(dc1); - return dt1; - } + { + DataTable dt1 =3D new DataTable(); + DataColumn dc1; + dc1 =3D new DataColumn("columna",typeof(string)); + dt1.Columns.Add(dc1); + dc1 =3D new DataColumn("filtros",typeof(string)); + dt1.Columns.Add(dc1); + dc1 =3D new DataColumn("group",typeof(string)); + dt1.Columns.Add(dc1); + dc1 =3D new DataColumn("having",typeof(string)); + dt1.Columns.Add(dc1); + dc1 =3D new DataColumn("order",typeof(string)); + dt1.Columns.Add(dc1); + dc1 =3D new DataColumn("claves",typeof(string)); + dt1.Columns.Add(dc1); + return dt1; + } =20 private DataTable getViewTableRes(int reportId, out int iniClass= ) { =20 @@ -383,27 +384,25 @@ return res; } =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 - #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 - - } - =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 + =20 + } } |