Friday, April 11, 2008

SQL Nested Gridview to Excel

I've been looking these days to extend the GridView native class so i can have export to Excel. So i have tried and built another class, that will make the export. The class doesn't relay on a specific control, but on a list of objects, every object also having a child list of objects (list meaning everything what IEnumerable means). In this way, for every property in a class a new column in XSL can be generated.

Here's the code (alin.berce - RONUA):

using System;
using System.Data;
using System.Configuration;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public class ExportToXls
{
public static void Export(string fileName, GridView gv, string title)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";

using (StringWriter sw = new StringWriter())
{
HtmlTextWriter htw = new HtmlTextWriter(sw);
try
{
// render the table into the htmlwriter
RenderGrid(gv).RenderControl(htw);
// render the htmlwriter into the response
HttpContext.Current.Response.Write("


" + title + "

");
HttpContext.Current.Response.Write("Generated in: " + DateTime.Now.ToString());
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
finally
{
htw.Close();
}
}
}

private static Table RenderGrid(GridView grd)
{
// Create a form to contain the grid
Table table = new Table();
table.GridLines = grd.GridLines;

// add the header row to the table
if (grd.HeaderRow != null)
{
ExportToXls.PrepareControlForExport(grd.HeaderRow);
table.Rows.Add(grd.HeaderRow);
}

// add each of the data rows to the table
foreach (GridViewRow row in grd.Rows)
{
//to allign top
row.VerticalAlign = VerticalAlign.Top;


ExportToXls.PrepareControlForExport(row);
table.Rows.Add(row);
}

// add the footer row to the table
if (grd.FooterRow != null)
{
ExportToXls.PrepareControlForExport(grd.FooterRow);
table.Rows.Add(grd.FooterRow);
}
return table;
}

private static void PrepareControlForExport(Control control)
{
for (int i = 0; i < current =" control.Controls;">

Google Earth and Integration onto Windows Applications

Few week ago i was playing with Google API trying to make an online tracker and offline data viewer. I mess it up lamentably. Cause of many thing, but I'm concentrate in here only over the most important ones.


1. Lack of support and integration for FAI recommended formats. As a sample, .IGC files are not supported by GE. Well, i said i can handle that. Using a 3'rd party freeware application and a script for auto processing the .IGC files, i was converting all files while i was starting the application. Task done !

2. Lack of Google Earth options available in GE API. Hell, I've found like maximum(probably less though) 15 functions/extends that i can use in my code. I found out in the end, it's lost time. Everyday i worked on this project means lost time.

3. Problems integrating GE in your application. HA ! Was a mess trying this. You loose focus, need to PInvoke to hide screens, windows. Even more, it's not only implementing (at the beginning the map only), but the controls too.

Final conclusions. They have a lot to work so make this API developer related, for all kinds of developers, for novice ones till guru's. Thought it's a start.

Thursday, April 10, 2008

Windows XP / RAID 1/ drivers

Yesterday, i was trying to install Windows XP Professional on a server. I prepared the hardware, connect those 2 hard drives in RAID 1 (mirroring), got the drivers from Intel's website and here we go, i got prepared to install stuffs.

Everything went great till that moment. We got licensed Windows XP Service Pack 1. Well, don't know how many of you know, but SP1 has no SATA/RAID drivers support. I installed 3'rd party drivers, but again, when he reached copying files into temporary hard disk folder, BAM !, insert the CD with appropriate drivers. How could i do that if when it loads them, it asks for a floppy disk !!! and now he's looking for CD. Well, i managed it out. Skipped copying those files, enter again in repair console mode, then copy the files to System32/drivers and Inf folders under Windows directory.
Everything is great, till BAM ! again. Error after loading mup.sys. In fact, can be some reasons of the error: ACPI Enable in BIOS, SATA driver, RAID driver, Video Card... I got confused and mad. I got all drivers from Intel website, and guild my own unattended Windows version.
Works like a charm ! Congrats to me ! :D

Well the day haven't passed over so fast. I'm still after some SDK for mouse gesture recognition. I need to make a PHP date site, in fact, a community-dating portal; i have some other mate waiting for the images and text for a website to do.

Been thinking...all the Trojans, Rats are using internet communication for sending data from your computer. How would be, if will use Bluetooth communication. You infect your girlfriend for example, for example, power your laptop next to her PC/Laptop then, start the client who automatically will download all the collected data. Amazing ! No anti-virus/trojan/spyware/malware will detect this. I'll try build something like that, well, when I'm gonna have some spare time.

Back to my business, i wanna recommend some sites for some of you, sites i have found useful on today's work, on everyday life, in fact, in lots of things.

First, Steve Pavlina will explain us the "10 reasons you should never get a job". It's a well made article, great one in fact.

Then, Veerle's blog. Another great place for web design and development tutorials and examples.
And in the end, magnificent article from The Future of the Web: "Freelancing: First eight months".

If you need a change in life, want something better, no more stress, under payment and you have the capabilities to do that, do it. Freelancing is one of the best job ever. More profitable. Time+Money/4-10 hours/day > 5.

Wednesday, April 9, 2008

Neural Networks, Mouse Gestures, Gesture Recognizer

Hell, yesterday i got a new task. To implement for our company mobile software applications a IPhone gesture based user interface(UI). It's really shitty, no matter what. In fact, the main problem is that i have to use a complex neural network algorithm combined with gesture management. Normally, it will take like 3 months to complete the this, except the 3D part using DirectX(preferably) or OpenGL.

Then the problems starts. Creating a 3D interface using DX implies a lot of things, and if we do a economic feasibility study we get nowhere. Technically it's feasible, at the limit though.

Been founding this: .NET C# Application to Create and Recognize Mouse Gestures

Looking around over it, seems to me that it's a point of start. I'll try contact Daniele to talk with him about this. Till then, I'll put an eye over the code provided.

More informations and links about this can be found on the following websites:

Artificial neural network
Project Doc-WMG
Mouse gesture recognition

PS: I have forgot, Liverpool won 4-2 against Arsenal. Great game ! Bring the Cup to the KOP !!