New project, new opportunities

Starting own software development consultancy & outsource company, check it out at hellowebapps.com

Move data from MySQL to MS SQL

Yesterday I’ve faced the problem with moving data from MySQL to MSSQL Server. I’ve used Integration Services (DTS) to transfer data with ADO.NET connection to MySQL (via Connector/NET). After running the import process a lot of conversation errors occurs. Main problem is in difference between MySQL Int and MS SQL Int, but I used to think that in ADO.NET all datatypes are mapped to some virtual types and then back to correct types in chosen database. I had no enough time to figure out the problem, so I’ve resolved it by adding DataConversion module and I have converted all integers from MySQL to strings, and it works now, but I hate situations when I don’t now what is the problem exactly.

How to write custom action manager for ASP.NET MVC or explenation of how things works there

1. ActionResult it’s acctually the return of standart ASP.NET MVC controller. ActionResult is used to return presentation (view, html, other kinds of presentation) of result returned by action method and write it to ControllerContext response.

    Existing implementations of AcctionResult :

        a) ContentResult : writes to output returned value (converted to string using the toString method of the value).

        b) EmptyResult : writes nothind to output.

        c) HttpUnauthorizedResult : set’s the response code to unauthorized. Writes nothing to output.

        d) JsonResult : serialize returned result to JSON and writes serialized object to Response stream.

        e) RedirectResult : basically redirects a user to another page.

        f) RedirectToRouteResult : redirects to anothere page using routing engine. Example :

            public ActionResult Create(int? categoryId)

            {

                return

                    new RedirectToRouteResult(

                        new RouteValueDictionary(new {controller = “Home”, action = “List”, categoryId = new int?()}));

            }

        g) ViewResultBase : Base class for a result which renders a view. Contains the method FindView which should be overided return ViewEngineResult (?what is ViewEngineResult? explein a bit). There are two existing         specifications :

            I) PartialViewResult : is used to return PartialView

            II) ViewResult : used to return View

            Both of implementation are using strange behaviour. They are calling a method from ViewResultBase class, which is implementation of IViewEngine as well.

    Cool stuff isn’t it?

    Create your own ActionResult – nice example : http://haacked.com/archive/2008/05/10/writing-a-custom-file-download-action-result-for-asp.net-mvc.aspx

2. ActionResult can cont

 

3. ControllerBase class is basically to be used if you whant you controllers to support following tasks

    ? how ControllerBase is creating? How the ControllerContext is getting there? Because it’s really interesting to have it in your controller method execution process (is it?)

        public ControllerContext ControllerContext { get; set; }

public TempDataDictionary TempData { get; set; }

public IValueProvider ValueProvider { get; set; }

public ViewDataDictionary ViewData { get; set; }

 

4. Possible implementations of MVC Engine :

    a) Create new ActionResult (ExtActionResult) which will contains exact information about html page to be used, and Mode (possible modes are: List, Single). This one is to be used with Wicket-like style of developing a wicket-style framework.

    b) Result of method execution can be not just a HTML page, but also – it can be preconfigured ExtJS control with a data returned from a method. ? Should be this case specified by some annotatation on method or special attribute in HTML template?

 

NOTES :

        Section 4:

                    1) Search for a View algorithm :

                        a) Look for a HTML page which corresponds to exact Method which is called from controller

                        b) Look for a HTML page which represents the type which is returned by method. (Can contains 2 presentations : Single and List) If List<?> is returned and List html-template doesnt exists engine should use Single-item template for every returned item.

Categorization of search results

I’ve found today that Yahoo! lunches the Yahoo! Glue – search service which combines categorized search result from different search sources – the strategy which was chosen for one of our main projects now.

Check it out on mashable : http://mashable.com/2008/11/19/yahoo-glue-2/.

 

Seedcamp is going to Kyiv!!!

I’ve received unexpected message where Seedcamp announced their event in Kyiv. I’m really excited about new opportunity for startups in Ukraine. It will be nice to start internet entrepreneurship in Ukraine!!!

I’d like to say guess a good luck for every participant!!!

Do world need a new Web Application development framework?

I’ve started to work for a new company 1 month and a half and a few days ago (1st of march). Company name is Componence (www.componence.com). We have started new office in L’viv, Ukraine with a new great team. I’m working in position of team leader here.

Componence works on bringing power of enterprise portals to big companies. We have own product and it’s named PortalSuite. It’s a set of portals for a WebLogic Portal server. It’s good enough to sell it. But now it’s time to build a new product for rapid portal development to respond for a new times coming.

CEO of our company wrote on his blog post about choosing a framework for our new product. And a lot of guys have responded to his posts on LinkedIn and other sites. All of them said about existing frameworks, their props and cons, but no one said it’s time to develop new framework.

All of existing and famous framework has been designed years ago. And goal for all of them was to provide easier way to build web applications, separate different kinds of logic and help to build UI more effectively. Sometimes ago they added some AJAX support (2 years ago or so). But now we have new big players on market of UI development frameworks for web applications – ExtJS and a Yahoo! UI. Both of them bring new way of abstraction for a building of web-based UI. And no one server framework consider on that.

So … I’m wondering is it a time to build a new server-side framework which will be integrated with ExtJS to bring new wave to web applications (portals) development?

 

    

CheckboxSelectionModel in ExtJS grid

I’ve tried to use CheckboxSelectionModel on grid, and there are no examples in documents for. It’s not clear in documentation. Ok, so you should create CheckboxSelectionModel object before it’s passing to grid as selModel, because you should specify it in columns config property. So there is example by the steps.

  1. Create CheckboxSelectionModel:
var sm = new Ext.grid.CheckboxSelectionModel();
  1. Include created object in columns list:
columns:[

sm,


{….. rest of your columns …..}

]

  1. Provide selectionModel object as current selection model for grid. You should provide selModel property in config options:
selMode: sm

Result:


SQL bug (or a feature) which allows to combine both assignment of value to a variable and retrieval data operation in the same query

I’ve found interesting issue today. Everyone knows “A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.”

So it’s impossible to do something like:

declare @a int

select @a = 1, 1

If you will do so error is raised. But interesting thing is if you will combine assign operation with another assignment in union query you will get no error. Here you have code for an experiment:

declare @a int

select @a = 1

union all

select @a = @a where 0 = 1

With this query you will have 1 displayed J I don’t know what it can be used for, but it’s funny.

And I’ve noticed – minimal variable name which can be declared in SQL Server is no symbol. Following query will work just fine: declare @ int. So you can assign values to @ and do whatever you want.



StackTrace in .net difference for Debug and Release compilation modes

Today I’ve tried to build new version of our DataLayer – Diego. Unsuccessfully L But I have discovered some interesting stuff around StackFrames in .net I’ve build sample project. In debug mode .net gives access to full stack trace. And in release mode we have just information about method that makes call and called method. There is test project to check it :

using System;

using System.Collections.Generic;

using System.Text;

using System.Diagnostics;

using System.Reflection;

namespace Tester

{


class Program

{


static void Main(string[] args)

{
Child r = new
Child();

r.runit(“hello”, 4);

}

}


class
Base

{


public
void Execute()

{


StackTrace trace = new
StackTrace();


StackFrame[] frames = trace.GetFrames();


Console.WriteLine(“Frames count : {0}”, trace.FrameCount);


foreach (StackFrame frame in frames)

{

processFrame(frame);

}

}


private
void processFrame(StackFrame frame)

{


MethodBase method = frame.GetMethod();


ParameterInfo[] parameters = method.GetParameters();


Console.WriteLine();


Console.WriteLine(“\tMethod name:\t{0}”, method.Name);


foreach (ParameterInfo param in parameters)

{


Console.WriteLine(“\tParameter name : \t{0}”, param.Name);

}

}

}


class
Child : Base

{


public
void runit(string name, int count)

{

Execute();

}

}

}

And there we have result for Debug mode:

Frames count : 3

Method name: Execute

Method name: runit

Parameter name : name

Parameter name : count

Method name: Main

Parameter name : args

Results for Release mode:

Frames count : 2

Method name: Execute

Method name: Main

Parameter name : args

Try to parse XML (similar to Integer.TryParse).

I’ve facing following problem during my current project. We have a lot of automation here. We have plug-ins architecture inside. Plug-ins are simple classes which inherits our special interface off-course. But main issue for plug-in is to persist his status. It’s possible with properties. So plug-ins are classes with properties which are processed automatically. Under processing I’m talking about setting/getting values and storing in our system. But plug-in can contains not just properties with simple types but complex types as well. Here complex type is some class which can easily be serialized/deserialized to/from XML. So we should be able to store complex types in properties. BTW: all values are storing as strings in our system. If can’t then I’m trying to convert value to a type of property. During conversation I’m checking if the passed value can be deserialized to complex type if yes – then it’s deserialized and value successfully set. If not I’m looking for a converter if no converter found I’m trying to set value directly.

    So my actual problem is that I can’t check that string can be parsed by XML processor. For example if we have in the string special symbols it can’t be processed. So I need to do try … catch to handle errors during deserialization. So I’m wondering why haven’t Microsoft add TryParse method to XML processor.