Welcome
This demonstration provides web access to the new query language, TimeScape QL+,
and the TimeScape Analytics Library.
The Example Queries tab contains QL+ queries for you to try. Click a query and
hit the Query TimeScape button to request sample data from. You can also create your
own custom queries... enjoy!
The following C# code is used to power this demo. It was
developed with the .NET Framework 2.0 BETA, using Visual Studio 2005.
It has been tested on Windows 2000, IIS5, IE6.
public partial class _default
{
private static Type XENOMORPH_LIST = typeof(Xenomorph.List);
private static Type XENOMORPH_TIMESERIES = typeof(Xenomorph.TimeSeries);
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack)
{
string strError = "";
string strTmp = "";
string strQuery = tbxQuery.Text;
Xenomorph.TimeScape.DataServices.IData oData = DataServicesFactory.CreateData(DataServicesFactory.TransportType.Local, null);
try
{
object oRet = oData.Query(strQuery, null, null, null);
System.Data.DataTable oResultTable = new DataTable("ResultsTable");
if (XENOMORPH_LIST.IsInstanceOfType(oRet))
{
Xenomorph.List oList = (Xenomorph.List)oRet;
oResultTable.Columns.Clear();
foreach (List.Column oCol in oList.Columns)
{
oResultTable.Columns.Add();
}
for (int nRow = 0; nRow < oList.RowCount; nRow++)
{
System.Data.DataRow drRow = oResultTable.NewRow();
for (int nCol = 0; nCol < oList.ColCount; nCol++)
{
if (XENOMORPH_LIST.IsInstanceOfType(oList.GetElement(nRow, nCol)) )
{
drRow[nCol] = oList.GetElement(nRow, nCol).ToString()
+ "( " + oList.RowCount + " by " + oList.ColCount + " )";
}
else if ( XENOMORPH_TIMESERIES.IsInstanceOfType( oList.GetElement(nRow, nCol) ))
{
drRow[nCol] = XENOMORPH_TIMESERIES.ToString()
+ "( " + ((Xenomorph.TimeSeries)oList.GetElement(nRow, nCol)).Dates.Length
+ " by 2 )";
}
else
{
drRow[nCol] = oList.GetElement(nRow, nCol);
}
}
oResultTable.Rows.Add(drRow);
}
}
else if( XENOMORPH_TIMESERIES.IsInstanceOfType(oRet) )
{
Xenomorph.TimeSeries oTimeSeries = (Xenomorph.TimeSeries)oRet;
oResultTable.Columns.Add( "Date", typeof( String ) );
oResultTable.Columns.Add( "Value", typeof( String ) );
for (int nRow = 0; nRow < oTimeSeries.Dates.Length; nRow++)
{
System.Data.DataRow drRow = oResultTable.NewRow();
drRow[ 0 ] = oTimeSeries.Dates[ nRow ].DateTime.ToShortDateString();
drRow[ 1 ] = ((System.Array)oTimeSeries.Values).GetValue( nRow );
oResultTable.Rows.Add(drRow);
}
}
else
{
oResultTable.Columns.Add();
System.Data.DataRow drRow = oResultTable.NewRow();
drRow[0] = oRet.ToString();
oResultTable.Rows.Add(drRow);
}
gvQueryResult.DataSource = oResultTable;
gvQueryResult.DataBind();
}
catch (Exception ee)
{
strError = "<br /><b>The query returned the following error:</b> <span style='color: #900;'>";
strError += ee.Message + "</span>";
}
lblResultsHead.Text = "<p><b>Query:</b> " + tbxQuery.Text + strError + "</p>";
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
}
#endregion
}