|
From: <sv...@de...> - 2005-05-27 15:50:51
|
Author: pcamacho
Date: 2005-05-27 11:50:51 -0400 (Fri, 27 May 2005)
New Revision: 1164
Modified:
humano2/trunk/core/db/absComplex.cs
humano2/trunk/core/db/mssql/mssqlComplex.cs
humano2/trunk/core/db/pgsql/pgsqlComplex.cs
humano2/trunk/web/portal/site/leftbar.aspx.cs
Log:
FIX: the [1155] was not a good fix. Because doing an update of a folder w=
e could have a child before its father in=20
the folders' list used to build the tree. This new fix resolves the probl=
em by creating the list by level of the=20
trees, so a child can never be before its father.
Modified: humano2/trunk/core/db/absComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/absComplex.cs 2005-05-27 15:35:32 UTC (rev 1163=
)
+++ humano2/trunk/core/db/absComplex.cs 2005-05-27 15:50:51 UTC (rev 1164=
)
@@ -388,6 +388,14 @@
///</summary>
abstract public string GetBasicAttributeSysName(int classId);
=20
+ =20
+ ///<summary>
+ ///Get the childs' id of a given folder
+ ///<param name=3D"folderId">id of folder</param>
+ ///<returns>the list of id of the childs</returns>
+ ///</summary>
+ abstract public int [] GetChildsOfFolder(int folderId);
+ =20
#endregion
=20
public object doScalar(string query)
Modified: humano2/trunk/core/db/mssql/mssqlComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-05-27 15:35:32 UTC (=
rev 1163)
+++ humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-05-27 15:50:51 UTC (=
rev 1164)
@@ -1224,5 +1224,19 @@
return sysName;
}
=20
+ public override int [] GetChildsOfFolder(int folderId)
+ {
+ string req =3D "select \"id_entity\" from folder where \"fol=
derParent\" =3D " + folderId;
+ DataTable dt =3D doSelect(req);
+ int dtSize =3D dt.Rows.Count;
+ int [] res =3D new int [dtSize];
+ for(int i=3D0; i< dtSize; i++)
+ {
+ res[i] =3D Convert.ToInt32(dt.Rows[i]["id_entity"]);
+ }
+ =20
+ return res;
+ }
+ =20
}
}
Modified: humano2/trunk/core/db/pgsql/pgsqlComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-05-27 15:35:32 UTC (=
rev 1163)
+++ humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-05-27 15:50:51 UTC (=
rev 1164)
@@ -1241,5 +1241,19 @@
return res; =09
=20
}
+ =20
+ public override int [] GetChildsOfFolder(int folderId)
+ {
+ string req =3D "select \"id_entity\" from folder where \"fol=
derParent\" =3D " + folderId;
+ DataTable dt =3D doSelect(req);
+ int dtSize =3D dt.Rows.Count;
+ int [] res =3D new int [dtSize];
+ for(int i=3D0; i< dtSize; i++)
+ {
+ res[i] =3D Convert.ToInt32(dt.Rows[i]["id_entity"]);
+ }
+ =20
+ return res;
+ }
}
}
Modified: humano2/trunk/web/portal/site/leftbar.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/leftbar.aspx.cs 2005-05-27 15:35:32 UTC=
(rev 1163)
+++ humano2/trunk/web/portal/site/leftbar.aspx.cs 2005-05-27 15:50:51 UTC=
(rev 1164)
@@ -23,6 +23,8 @@
using System.IO;
using System.Text.RegularExpressions;
=20
+using Humano2.Core;
+using Humano2.Core.Db;
using Humano2.Components.WebTools;
=20
namespace Portal.site
@@ -33,8 +35,12 @@
public class leftbar : basePage
{
private string Mode;
+ private int domainId;=20
=09
- private void Page_Load(object sender, System.EventArgs e) { }
+ private void Page_Load(object sender, System.EventArgs e)
+ {
+ domainId =3D userCred.DomainIds[userCred.CurrentDomainIndex]=
;
+ }
=20
/// <summary>
/// Creates an xml with all needed data.=20
@@ -104,10 +110,8 @@
{
string Forms=3D"";
string filtro =3D String.Format("34|0|'{0}'|0|0",userCred.DomainIds[=
userCred.CurrentDomainIndex]);
- string folderOrder =3D "1401|0"; //We must order the folders because=
parents must appear before children=20
- // when the webfxjstree i=
s built in the leftbar
- =20
- DataTable DTFolder =3D dbAdapter.GenerateViewTools(1400,"0,1401,1403=
,1402",filtro,"","",folderOrder,0);
+ =09
+ DataTable DTFolder =3D getFoldersInTreeOrder();
=20
DataTable DTView =3D dbAdapter.GenerateViewTools(1011,"0,1017,1018",=
filtro,"","","",0);
=20
@@ -128,10 +132,14 @@
if (Dr[3].ToString() !=3D "" && Dr[3].ToString() !=3D "0")
{
xmlString +=3D " <parent>" + Dr[3] + "</parent>";
- }else{
+ }
+ else
+ {
xmlString +=3D " <parent></parent>";
}
- }else{
+ }
+ else
+ {
xmlString +=3D " <parent></parent>";
}
Forms =3D Convert.ToString(Dr[2]);
@@ -182,7 +190,84 @@
=20
return xmlString;
}
-
+ =20
+ ///<summary>
+ ///Get a datatable with all the folders in tree order. That mean=
s that a child of whatever folder always=20
+ ///appears after this folder.
+ ///<summary>
+ private DataTable getFoldersInTreeOrder()
+ {
+ DataTable resDt =3D updateLevelFolders(0); //Start from the =
root
+ return resDt;
+ }
+ =20
+ private DataTable updateLevelFolders(int folderId)
+ {
+ adapter dbAdapter =3D userCred.CoreAdapter;
+ absCrud crud =3D Factory.Crud();
+ absComplex complex =3D crud.GetCore().Complex;
+ int [] listOfChilds =3D complex.GetChildsOfFolder(folderId);
+ int listOfChildsSize =3D listOfChilds.Length;
+ =20
+ DataTable newDt;
+ =20
+ if(listOfChildsSize =3D=3D 0) //No childs. We're done =20
+ {
+ newDt =3D null;
+ }
+ else //Follow recursivity
+ {
+ //Build the filter for query
+ string filter;=20
+ string listOfChildsForFilter =3D "[(";
+ for(int i=3D0;i<listOfChildsSize;i++)
+ {
+ listOfChildsForFilter +=3D "'" + Convert.ToString(li=
stOfChilds[i]) + "'" + ",";
+ }
+ listOfChildsForFilter =3D listOfChildsForFilter.Substrin=
g(0,listOfChildsForFilter.Length-1); //Remove last ","
+ listOfChildsForFilter +=3D ")]";
+ filter =3D String.Format("34|0|'{0}'|1|0",userCred.Domai=
nIds[userCred.CurrentDomainIndex]) + ";"; //For the domain =20
+ filter +=3D "0|8|" + listOfChildsForFilter + "|0|0"; //T=
o reduce the query to the list of childs =20
+ Logger.Log("leftbar.aspx.cs: filter =3D " + filter, Log=
Level.Trace);
+ //The datatable with values of current level filtered wi=
th childs
+ DataTable currentDt =3D dbAdapter.GenerateViewTools(1400=
,"0,1401,1403,1402",filter,"","","",0);
+ =20
+ //Build the concatenation of all DataTables
+ DataTable auxDt =3D null; //empty table to start
+ for(int i=3D0;i<listOfChildsSize;i++)
+ {
+ auxDt =3D concatDataTables(updateLevelFolders(listO=
fChilds[i]), auxDt);=20
+ } =20
+ //Add the current DataTable before the childs' DataTable=
s
+ newDt =3D concatDataTables(currentDt,auxDt);
+ }
+ return newDt;
+ }
+ =20
+ private DataTable concatDataTables(DataTable dt1, DataTable dt2)
+ {
+ DataSet ds =3D new DataSet();
+ =20
+ if(dt1 !=3D null)
+ {
+ ds.Merge(dt1);=20
+ }
+ =20
+ if(dt2 !=3D null)
+ {
+ ds.Merge(dt2);
+ }
+ =20
+ if(dt1 =3D=3D null && dt2 =3D=3D null)
+ {
+ return null; =20
+ }
+ else
+ {
+ return ds.Tables[0];
+ }
+ }
+ =20
private string genExploreList(adapter dbAdapter)
{
string xmlString;
|