|
From: <sv...@de...> - 2005-06-16 21:18:19
|
Author: pcamacho
Date: 2005-06-16 17:18:20 -0400 (Thu, 16 Jun 2005)
New Revision: 1339
Modified:
humano2/trunk/components/webTools/interfacetools.cs
humano2/trunk/web/builder/site/createreport.aspx.cs
humano2/trunk/web/builder/site/viewmain.aspx.cs
Log:
CHANGE: factorisation again between viewmain and createreport... Still re=
mains things to simplify!
Modified: 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-16 20:20:=
35 UTC (rev 1338)
+++ humano2/trunk/components/webTools/interfacetools.cs 2005-06-16 21:18:=
20 UTC (rev 1339)
@@ -247,5 +247,97 @@
string res =3D columns[1] + "|0";=20
return res; =20
}
+ =20
+ ///<summary>
+ ///Get the attributes of a class
+ ///<param name=3D"classId">The id of class</param>
+ ///<param name=3D"userCred">Session object of user</param>
+ ///<return>A xml string with the list of attributes for a class<=
/returns>
+ ///</summary>
+ public static string GetXmlAttribListForClass(int classId,SessionCrede=
ncial userCred)=20
+ {
+ string salida=3D"";
+ int attlogin =3D 0;
+ int idatt =3D 0;
+ DataTable dtpert;
+ DataTable dtrel;
+ int idClassRel =3D 0;
+ string className =3D "";
+
+ DataTable dt =3D userCred.CoreAdapter.GetAttributesFromClass(classId)=
;
+
+ adapter dbAdapter =3D new adapter();
+ className =3D dbAdapter.GetClassNameById(classId);
+ //className =3D dt.Rows[0]["name"].ToString();
+
+ salida +=3D "<class>";
+ salida +=3D "<id>" + classId + "</id>";
+ salida +=3D "<name>" + className + "</name>";
+ salida +=3D "<attributes>";
+ =09
+ foreach(DataRow row in dt.Rows)=20
+ {
+ string attName =3D Convert.ToString(row["attName"]);
+ string attType =3D Convert.ToString(row["attType"]);
+ if(attType=3D=3D"pertinence")
+ {
+ idatt =3D Convert.ToInt32(row["id_entity"]);
+ dtpert =3D userCred.CoreAdapter.GetClassesFromPertinence(idatt);
+ DataRow dr2 =3D dtpert.Rows[0];
+ idClassRel =3D Convert.ToInt32(dr2["to"].ToString());
+ =09
+ //For each attribute of pertinence put the id with t=
ogo and=20
+ // the pertname.attname
+ int [] listAttId =3D GetAttributeIdListForClass(idCl=
assRel,userCred);
+ string [] listAttName =3D getAttributeNameListForCla=
ss(idClassRel,userCred);
+ int size =3D listAttId.Length;
+ for(int i=3D0;i<size;i++)
+ {
+ attlogin =3D listAttId[i];
+ salida +=3D "<attribute>";
+ salida +=3D "<id>" + idatt + "^" + attlogin + "<=
/id>";
+ salida +=3D "<name>" + attName + "." + listAttN=
ame[i]+ "</name>";
+ salida +=3D "</attribute>";
+ }
+ }
+ else
+ {
+ salida +=3D "<attribute>";
+ salida +=3D "<id>" + row["id_entity"].ToString() + "</id>";
+ salida +=3D "<name>" + attName + "</name>";
+ salida +=3D "</attribute>";
+ }
+ }
+ salida +=3D "</attributes>";
+ salida +=3D "</class>";
+ =20
+ return salida;
+ }
+ =20
+ ///<summary> The list of all attributes id for a class</summary>
+ public static int[] GetAttributeIdListForClass(int classId, Sess=
ionCredencial userCred)
+ {
+ DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
+ int [] idArr =3D new int[res.Rows.Count];
+ int i=3D0;
+ foreach(DataRow row in res.Rows)
+ {
+ idArr[i++] =3D Convert.ToInt32(row["id_entity"]);
+ }
+ return idArr;
+ }
+ =20
+ ///<summary> The list of all attributes name for a class </summa=
ry>
+ private static string[] getAttributeNameListForClass(int classId=
,SessionCredencial userCred)
+ {
+ DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
+ string [] nameArr =3D new string[res.Rows.Count];
+ int i=3D0;
+ foreach(DataRow row in res.Rows)
+ {
+ nameArr[i++] =3D Convert.ToString(row["attName"]);
+ }
+ return nameArr;
+ }
}
}
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-16 20:20:=
35 UTC (rev 1338)
+++ humano2/trunk/web/builder/site/createreport.aspx.cs 2005-06-16 21:18:=
20 UTC (rev 1339)
@@ -130,7 +130,7 @@
//relacionadas...
if(Convert.ToInt32(classId) > 0)
{
- strXml +=3D getXmlAttribListForClass(Convert.ToInt32(cla=
ssId));
+ strXml +=3D Interface.GetXmlAttribListForClass(Convert.T=
oInt32(classId),userCred);
}
strXml +=3D Interface.GetClassListForUser(userCred=
);
strXml +=3D "</classes>";
@@ -167,7 +167,6 @@
return res;
}
=20
- =20
private string getReportPersoColumnsXml(string columns)
{
string [] allColumns =3D columns.Split(new char[] {','});
@@ -346,7 +345,7 @@
=09
//For each attribute of pertinence put the id with t=
ogo
int attLogin =3D 0;
- int [] listAttId =3D getAttributeIdListForClass(idCl=
assRel);
+ int [] listAttId =3D Interface.GetAttributeIdListFor=
Class(idClassRel,userCred);
int size =3D listAttId.Length;
for(int k=3D0;k<size;k++)
{
@@ -413,8 +412,6 @@
return xmlRes;
}
=20
- =20
- =20
private void deleteReport()
{
Logger.Log("deleteReport called", LogLevel.Trace);
@@ -461,7 +458,6 @@
return dt;
}
=20
- =20
///<summary>
/// The persoCol string comes from the web in this format idAtt0=
|idFunc0;idAtt1|idFunc1; ...
/// It has to be converted to:=20
@@ -545,124 +541,8 @@
sendMessageToUser(UserMessage.UPDATEREPORTOK); //Cha=
nge
}
}=09
- =09
}
-
- ///<summary>
- ///Get the attributes of a class
- ///</summary>
- private string getXmlAttribListForClass(int classId)=20
- {
- string salida=3D"";
- int attlogin =3D 0;
- int idatt =3D 0;
- DataTable dtpert;
- DataTable dtrel;
- int idClassRel =3D 0;
- string className =3D "";
-
- DataTable dt =3D userCred.CoreAdapter.GetAttributesFromClass(classId)=
;
-
- adapter dbAdapter =3D new adapter();
- className =3D dbAdapter.GetClassNameById(classId);
- //className =3D dt.Rows[0]["name"].ToString();
-
- salida +=3D "<class>";
- salida +=3D "<id>" + classId + "</id>";
- salida +=3D "<name>" + className + "</name>";
- salida +=3D "<attributes>";
- =09
- foreach(DataRow row in dt.Rows)=20
- {
- string attName =3D Convert.ToString(row["attName"]);
- string attType =3D Convert.ToString(row["attType"]);
- if(attType=3D=3D"pertinence")
- {
- idatt =3D Convert.ToInt32(row["id_entity"]);
- dtpert =3D userCred.CoreAdapter.GetClassesFromPertinence(idatt);
- DataRow dr2 =3D dtpert.Rows[0];
- idClassRel =3D Convert.ToInt32(dr2["to"].ToString());
- =09
- //For each attribute of pertinence put the id with t=
ogo and=20
- // the pertname.attname
- int [] listAttId =3D getAttributeIdListForClass(idCl=
assRel);
- string [] listAttName =3D getAttributeNameListForCla=
ss(idClassRel);
- int size =3D listAttId.Length;
- for(int i=3D0;i<size;i++)
- {
- attlogin =3D listAttId[i];
- salida +=3D "<attribute>";
- salida +=3D "<id>" + idatt + "^" + attlogin + "<=
/id>";
- salida +=3D "<name>" + attName + "." + listAttN=
ame[i]+ "</name>";
- salida +=3D "</attribute>";
- }
- }
- else
- {
- salida +=3D "<attribute>";
- salida +=3D "<id>" + row["id_entity"].ToString() + "</id>";
- salida +=3D "<name>" + attName + "</name>";
- salida +=3D "</attribute>";
- }
- }
- salida +=3D "</attributes>";
- salida +=3D "</class>";
- =20
- return salida;
- }
- =20
- public int GetAttributePrimary(int idClass)
- {
- int iniClass;
- DataTable dt1;
- adapter dbAdapter =3D userCred.CoreAdapter;
-
- //DataTable dtParam =3D myform.makeDataTableInReportTools();
- DataTable dtParam =3D this.makeDataTableInViewTools();
- DataRow dr =3D dtParam.NewRow();
-
- //clase de los atributos.
- iniClass =3D 5;
-
- dr["columna"] =3D "0";
-
- //Explicacion de los filtros...
- //atributo 67|4|'true' =3D> isPrimary=3D'true'
- //atributo 40|4|idClass =3D> classId=3DidClass
- dr["filtros"] =3D "67|4|'true'|1|0;40|4|'"+idClass+"'|0|0";
-
- dtParam.Rows.Add(dr);
-
- dt1 =3D dbAdapter.GetDataTableView(dtParam, iniClass);
- if(dt1.Rows.Count=3D=3D1)
- {
- return Convert.ToInt32(dt1.Rows[0][0].ToString());
- }
- else
- {
- return -1;
- }
- }
- =20
- 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;
- }
-
+ =20
private DataTable createReportDataTable()
{
DataTable dt =3D new DataTable();
@@ -675,33 +555,5 @@
dt.Columns.Add("reportName");
return dt;
}
- =20
- =20
- ///<summary> The list of all attributes id for a class</summary>
- private int[] getAttributeIdListForClass(int classId)
- {
- DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
- int [] idArr =3D new int[res.Rows.Count];
- int i=3D0;
- foreach(DataRow row in res.Rows)
- {
- idArr[i++] =3D Convert.ToInt32(row["id_entity"]);
- }
- =20
- return idArr;
- }
- =20
- ///<summary> The list of all attributes name for a class </summa=
ry>
- private string[] getAttributeNameListForClass(int classId)
- {
- DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
- string [] nameArr =3D new string[res.Rows.Count];
- int i=3D0;
- foreach(DataRow row in res.Rows)
- {
- nameArr[i++] =3D Convert.ToString(row["attName"]);
- }
- return nameArr;
- }
}
}
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-16 20:20:35 U=
TC (rev 1338)
+++ humano2/trunk/web/builder/site/viewmain.aspx.cs 2005-06-16 21:18:20 U=
TC (rev 1339)
@@ -68,7 +68,6 @@
=20
override protected string createXml()
{
- =20
DataTable currView =3D null;
Logger.Log("ViewMain: viewId =3D " + Convert.ToString(viewId=
),LogLevel.Trace);
if(viewId !=3D 0)
@@ -128,7 +127,7 @@
//relacionadas...
if(Convert.ToInt32(classId) > 0)
{
- strXml +=3D getXmlAttribListForClass(Convert.ToInt32(cla=
ssId));
+ strXml +=3D Interface.GetXmlAttribListForClass(Convert.T=
oInt32(classId),userCred);
}
strXml +=3D Interface.GetClassListForUser(userCred=
);
strXml +=3D "</classes>";
@@ -281,7 +280,7 @@
=09
//For each attribute of pertinence put the id with t=
ogo
int attLogin =3D 0;
- int [] listAttId =3D getAttributeIdListForClass(idCl=
assRel);
+ int [] listAttId =3D Interface.GetAttributeIdListFor=
Class(idClassRel,userCred);
int size =3D listAttId.Length;
for(int k=3D0;k<size;k++)
{
@@ -445,125 +444,9 @@
}
}=09
}
+ =20
+ =09
=20
- // Funcion agregada por negro que solo traera la informacion necesaria=
...
- private string getXmlAttribListForClass(int classId)=20
- {
- string salida=3D"";
- int attlogin =3D 0;
- int idatt =3D 0;
- DataTable dtpert;
- DataTable dtrel;
- int idClassRel =3D 0;
- string className =3D "";
-
- DataTable dt =3D userCred.CoreAdapter.GetAttributesFromClass(classId)=
;
-
- adapter dbAdapter =3D new adapter();
- className =3D dbAdapter.GetClassNameById(classId);
- //className =3D dt.Rows[0]["name"].ToString();
-
- salida +=3D "<class>";
- salida +=3D "<id>" + classId + "</id>";
- salida +=3D "<name>" + className + "</name>";
- salida +=3D "<attributes>";
- =09
- foreach(DataRow row in dt.Rows)=20
- {
- string attName =3D Convert.ToString(row["attName"]);
- string attType =3D Convert.ToString(row["attType"]);
-
- if(attType=3D=3D"pertinence")
- {
- idatt =3D Convert.ToInt32(row["id_entity"]);
- dtpert =3D userCred.CoreAdapter.GetClassesFromPertinence(idatt);
- if (dtpert.Rows.Count > 0 )
- {
- DataRow dr2 =3D dtpert.Rows[0];
- idClassRel =3D Convert.ToInt32(dr2["to"].ToString());
- =09
- //For each attribute of pertinence put the id with togo and=20
- // the pertname.attname
- int [] listAttId =3D getAttributeIdListForClass(idClassRel);
- string [] listAttName =3D getAttributeNameListForClass(idClassRel)=
;
- int size =3D listAttId.Length;
- for(int i=3D0;i<size;i++)
- {
- attlogin =3D listAttId[i];
- salida +=3D "<attribute>";
- salida +=3D "<id>" + idatt + "^" + attlogin + "</id>";
- salida +=3D "<name>" + attName + "." + listAttName[i]+ "</name>"=
;
- salida +=3D "</attribute>";
- }
- }
- }
- else
- {
- salida +=3D "<attribute>";
- salida +=3D "<id>" + row["id_entity"].ToString() + "</id>";
- salida +=3D "<name>" + attName + "</name>";
- salida +=3D "</attribute>";
- }
- }
- salida +=3D "</attributes>";
- salida +=3D "</class>";
-
- return salida;
- }
- =20
- public int GetAttributePrimary(int idClass)
- {
- int iniClass;
- DataTable dt1;
- adapter dbAdapter =3D userCred.CoreAdapter;
-
- //DataTable dtParam =3D myform.makeDataTableInViewTools();
- DataTable dtParam =3D this.makeDataTableInViewTools();
- DataRow dr =3D dtParam.NewRow();
-
- //clase de los atributos.
- iniClass =3D 5;
-
- dr["columna"] =3D "0";
-
-
- //Explicacion de los filtros...
- //atributo 67|4|'true' =3D> isPrimary=3D'true'
- //atributo 40|4|idClass =3D> classId=3DidClass
- dr["filtros"] =3D "67|4|'true'|1|0;40|4|'"+idClass+"'|0|0";
-
- dtParam.Rows.Add(dr);
-
- dt1 =3D dbAdapter.GetDataTableView(dtParam, iniClass);
- if(dt1.Rows.Count=3D=3D1)
- {
- return Convert.ToInt32(dt1.Rows[0][0].ToString());
- }
- else
- {
- return -1;
- }
- }
- =20
- 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;
- }
-
private DataTable createViewDataTable()
{
DataTable dt =3D new DataTable();
@@ -576,33 +459,5 @@
dt.Columns.Add("viewName");
return dt;
}
- =20
- =20
- ///<summary> The list of all attributes id for a class</summary>
- private int[] getAttributeIdListForClass(int classId)
- {
- DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
- int [] idArr =3D new int[res.Rows.Count];
- int i=3D0;
- foreach(DataRow row in res.Rows)
- {
- idArr[i++] =3D Convert.ToInt32(row["id_entity"]);
- }
- =20
- return idArr;
- }
- =20
- ///<summary> The list of all attributes name for a class </summa=
ry>
- private string[] getAttributeNameListForClass(int classId)
- {
- DataTable res =3D userCred.CoreAdapter.GetAttributesFromClas=
s(classId);
- string [] nameArr =3D new string[res.Rows.Count];
- int i=3D0;
- foreach(DataRow row in res.Rows)
- {
- nameArr[i++] =3D Convert.ToString(row["attName"]);
- }
- return nameArr;
- }
}
}
|