|
From: <sv...@de...> - 2005-06-01 22:10:23
|
Author: marcelo
Date: 2005-06-01 18:10:19 -0400 (Wed, 01 Jun 2005)
New Revision: 1231
Modified:
humano2/trunk/components/viewTools/ViewTools.cs
humano2/trunk/components/viewTools/viewCache.cs
humano2/trunk/core/db/absComplex.cs
humano2/trunk/core/db/mssql/mssqlComplex.cs
humano2/trunk/core/db/pgsql/pgsqlComplex.cs
Log:
* Fixed paging with MsSql server
* Fixed paging which broke with caching
Modified: humano2/trunk/components/viewTools/ViewTools.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/viewTools/ViewTools.cs 2005-06-01 15:35:19 U=
TC (rev 1230)
+++ humano2/trunk/components/viewTools/ViewTools.cs 2005-06-01 22:10:19 U=
TC (rev 1231)
@@ -328,36 +328,38 @@
DataTable res =3D new DataTable();
int find =3D sql.IndexOf("tempTable");
string var;
- string dropTable =3D "", maxRecord, createTable, insert, select;
+ string dropTable =3D "";
if(find > -1)
{
var =3D sql;
dropTable =3D var.Substring(0,var.IndexOf(";"));
var =3D var.Substring(var.IndexOf(";") + 1,var.Length - var.IndexOf(=
";") - 1);
=09
- maxRecord =3D var.Substring(0,var.IndexOf(";"));
+ string maxRecord =3D var.Substring(0,var.IndexOf(";"));
var =3D var.Substring(var.IndexOf(";") + 1,var.Length - var.IndexOf(=
";") - 1);
=09
+ string alterTable =3D var.Substring(0,var.IndexOf(";"));
+ var =3D var.Substring(var.IndexOf(";") + 1,var.Length - var.IndexOf(=
";") - 1);
+ =09
//try
//{
=20
int pos =3D var.IndexOf(";");
- //string a =3D var.Substring(pos + 1,7);
- if(var.Substring(pos + 1,7).ToLower() =3D=3D "\ninsert")
+ // string a =3D var.Substring(pos + 1,7);
+ if(var.IndexOf("\" INTO temp")>0)
{
=20
- createTable =3D var.Substring(0,pos);
- var =3D var.Substring(var.IndexOf(";") + 2,var.Length - var.IndexO=
f(";") - 2);
+ string createTable =3D var.Substring(0,pos);
+ var =3D var.Substring(var.IndexOf(";") + 1,var.Length - var.IndexO=
f(";") - 1);
pos =3D var.IndexOf(";");
- //a =3D var.Substring(pos + 1,7);
+ // a =3D var.Substring(pos + 1,7);
=20
if(var.Substring(pos + 1,7).ToLower() =3D=3D "\nselect")
{
- =20
- insert =3D var.Substring(0,pos);
- select =3D var.Substring(var.IndexOf(";") + 2,var.Length - var.In=
dexOf(";") - 2);
+ // insert =3D var.Substring(0,pos);
+ string select =3D var; //.Substring(var.IndexOf(";") + 2,var.Leng=
th - var.IndexOf(";") - 2);
Complex.doCommand(createTable);
- Complex.doCommand(insert);
+ Complex.doCommand(alterTable);
_totalRecordCount =3D Convert.ToInt32(Complex.doScalar(maxRecord)=
);
sql =3D select;
}
@@ -466,28 +468,28 @@
values.Sort();
=09
disp =3D (DisplayOrder[])values.ToArray(typeof(DisplayOrder));
+
+ string tableName =3D "";
if(Page !=3D 0)
{
- string tableName =3D "";
- ArrayList vars =3D new ArrayList();
- foreach(DisplayOrder var2 in disp)
- {
- vars.Add(var2.Text + "," + var2.Type);
- //Logger.Log("ViewTools: vars[]=3D" + var2.Text + ",=
" + var2.Type,LogLevel.Trace);
- }
- //Logger.Log("ViewTools: call of BuildTempTable",LogLeve=
l.Trace);
- Query.Append(Complex.BuildTempTable((string[])vars.ToArray(typeof(st=
ring)),ref tableName));
- TempTable =3D tableName;
+ Query.Append(Complex.BuildTempTable(ref tableName));
+ TempTable =3D tableName;
}
+ =09
Query.Append("SELECT ");
foreach(DisplayOrder var in disp)
{
Query.Append(var.Text);
}
- =20
Query.Remove(Query.Length-2,2);
+ =09
+ if(Page !=3D 0)
+ {
+ Query.Append(" INTO " + tableName );
+ } =20
+
Query.Append(" ");
- //Logger.Log("Select Query: " + Query.ToString() ,LogLevel.T=
race);
+ //Logger.Log("Select Query: " + Query.ToString() ,LogLevel.Trace);
return Query.ToString();
}
=20
@@ -665,10 +667,10 @@
=20
objRow =3D Params.Rows[0];
=20
- string res =3D ViewCache.Instance().GetCachedStatement(objRow) ;
+ string res =3D ViewCache.Instance().GetCachedStatement(objRow, PageVi=
ew) ;
if( res !=3D null )
{ // We got the cached datatable result. lets return that and not con=
struct a new one again.
- return res;
+ // return res; //UNCOMENT THIS LINE
}
=20
objArray =3D objRow.ItemArray;
@@ -739,7 +741,7 @@
=20
res =3D Query.ToString();
//Logger.Log("Query=3D" + res,LogLevel.Trace);
- ViewCache.Instance().AddStatement(objRow, res);
+ // UNCOMENT THIS LINE ViewCache.Instance().AddStatement(objRow, res, =
Page);
=20
return res;
}
Modified: humano2/trunk/components/viewTools/viewCache.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/viewTools/viewCache.cs 2005-06-01 15:35:19 U=
TC (rev 1230)
+++ humano2/trunk/components/viewTools/viewCache.cs 2005-06-01 22:10:19 U=
TC (rev 1231)
@@ -43,9 +43,9 @@
return instance;
}
=20
- public string GetCachedStatement(DataRow dr)
+ public string GetCachedStatement(DataRow dr, int pageView)
{
- int rowHash =3D genStableHashKey(dr);
+ int rowHash =3D genStableHashKey(dr, pageView);
string res =3D (string) databaseStatementCache[rowHash];
/*
Logger.Log("GetCachedStatement: data count: " + databaseStatementCach=
e.Count, LogLevel.Trace);
@@ -62,13 +62,13 @@
return res;
}
=20
- public void AddStatement(DataRow dr, string statement)
+ public void AddStatement(DataRow dr, string statement, int pageView)
{
- int rowHash =3D genStableHashKey(dr);
+ int rowHash =3D genStableHashKey(dr, pageView);
databaseStatementCache.Add(rowHash, statement);
}
=20
- private int genStableHashKey(DataRow dr)
+ private int genStableHashKey(DataRow dr, int pageView)
{
StringBuilder res =3D new StringBuilder();
int colCount =3D dr.Table.Columns.Count;
@@ -76,6 +76,7 @@
{
res.Append(Convert.ToString(dr[c]));
}
+ res.Append(pageView.ToString());
string str =3D res.ToString();
int code =3D str.GetHashCode();
=20
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-06-01 15:35:19 UTC (rev 1230=
)
+++ humano2/trunk/core/db/absComplex.cs 2005-06-01 22:10:19 UTC (rev 1231=
)
@@ -53,7 +53,7 @@
/// </summary>
/// <param name=3D"args">columnas de la tabla temporal</param>
/// <returns>la consulta que crea la tabla temporal</returns>
- abstract public string BuildTempTable(string[] args, ref string tableN=
ame);
+ abstract public string BuildTempTable(ref string tableName);
=20
/// <summary>
/// get a list of the attributes Ids and their sysAttName that the use=
r can set/change of a class.
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-06-01 15:35:19 UTC (=
rev 1230)
+++ humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-06-01 22:10:19 UTC (=
rev 1231)
@@ -392,42 +392,17 @@
return tName;
}
=20
- public override string BuildTempTable(string[] args, ref string tableN=
ame)
+ public override string BuildTempTable(ref string tableName)
{
-
StringBuilder table =3D new StringBuilder();
- string[] var;
- string name;
- string type;
- int loop;
=09
tableName =3D "tempTable" + System.Guid.NewGuid().ToString();
tableName =3D tableName.Replace("-","");
=09
table.Append("drop table "+ tableName + ";");
table.Append("select max(\"row\") from "+ tableName + ";");
- table.Append("create table dbo."+ tableName +" (");
- loop =3D 0;
- foreach(string col in args)
- {
- var =3D col.Split(",".ToCharArray());
- name =3D var[0];
- name =3D name.Substring(name.IndexOf(".")+1);
- if ((loop > 0) && (name =3D=3D "id_entity")) name =3D name + loop.To=
String();
- //name =3D var[0].Replace(".","_");
- //name =3D name.Replace("\"","");
- //name =3D "\"" + name + "\"";
- type =3D core.Crud.AttributeTypeMapping(var[2].ToString());
- // FIXME: Get ols sizes from db
- if (type =3D=3D "varchar") type =3D type + " (50)";
- //string coDef =3D getColDef();
- if (type =3D=3D null) type =3D var[2].ToString();
- table.Append(name + " " + type + ",");
- loop++;
- }
- table.Append("\"row\" integer IDENTITY);\n");
- table.Append("insert into " + tableName + " " );
- =09
+ table.Append("alter table "+ tableName +" add \"row\" integer IDENTIT=
Y;");
+ =09
return table.ToString();
}
=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-06-01 15:35:19 UTC (=
rev 1230)
+++ humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-06-01 22:10:19 UTC (=
rev 1231)
@@ -427,46 +427,16 @@
return sysName;
}
=20
- public override string BuildTempTable(string[] args, ref string tableN=
ame)
+ public override string BuildTempTable(ref string tableName)
{
StringBuilder table =3D new StringBuilder();
- string[] var;
- string name;
- string type;
- int loop;
=09
tableName =3D "tempTable" + System.Guid.NewGuid().ToString();
tableName =3D tableName.Replace("-","");
=09
table.Append("drop table "+ tableName + ";");
table.Append("select max(\"row\") from "+ tableName + ";");
- table.Append("create table "+ tableName +" (");
- loop =3D 0;
- foreach(string col in args)
- {
- var =3D col.Split(",".ToCharArray());
- //Logger.Log("BuildTempTable: col[" + loop + "]=3D " + c=
ol,LogLevel.Trace);
- name =3D var[0];
- name =3D name.Substring(name.IndexOf(".")+1);
- if ((loop > 0) && (name =3D=3D "id_entity"))=20
- {
- name =3D name + loop.ToString();
- }
- //FIXME: This "AttributeTypeMapping" needs to change to support dyna=
mic derived types in view.
- //Logger.Log("BuildTempTable: var[2].ToString()=3D " + var[2].ToStri=
ng(),LogLevel.Trace);
- type =3D core.Crud.AttributeTypeMapping(var[0].ToString(=
)); //var[0] is of the form "d109cVerifAttribs"."c10007Text1" for example
- =
//The data we need is c10007Text1
- if (type =3D=3D null)=20
- {
- //Logger.Log("BuildTempTable: type=3D=3Dnull",LogLev=
el.Trace);
- type =3D var[2].ToString(); //FIXME ok but it is a b=
ig patch
- }
- table.Append(name + " " + type + ",");
- //Logger.Log("BuildTempTable. name=3D " + name + ", typ=
e=3D " + type,LogLevel.Trace);
- loop++;
- }
- table.Append("\"row\" Serial);\n");
- table.Append("insert into " + tableName + " " );
+ table.Append("alter table "+ tableName +" add column \"row\" Serial;"=
);
=09
return table.ToString();
}
|