Mini SQL Query now using XML based connection definitions

by Paul Kohler 10. June 2009 00:00

I have finally completed the connection definition text to XML conversion for Mini SQL Query. The raw carrot (^) delimited line of text describing a connection string was the source of many email requests! Years ago the thing used to simply be the actual connection string (because they were all for MSSQL databases), then I expanded it to include a provider type and then when I decided to go public I thought a "named connection" string would be nice, appending another delimited field was the quick path...

That's all gone (well, is obsolete) in the latest source, I still need to update the GUI a bit but there is an automatic upgrade included for your convenience :-)

Quick note on Mini SQL Query

by Paul Kohler 27. April 2009 01:33

I am in the middle of some major refactoring, mainly from a structural point of view. The interfaces etc should not change but some of the plug-ins have moved. Go to the latest source for the updates if you wish, there are a few extras in there now compared to the official release…

see… http://minisqlquery.codeplex.com/SourceControl/ListDownloadableCommits.aspx

PK :)

Mini SQL Query Updates

by Paul Kohler 3. April 2009 02:10

I had some more questions regarding Mini SQL Query recently, this time via http://minisqlquery.codeplex.com/Thread/List.aspx (most have come come via email to date)

I thought I would post the response too just as a general update on activities…

----

Thanks for the detailed feedback and questions. I’ll answer in order of difficulty/priority:

Status

The status bar stuff is there – I think I just forgot about making good use of it - Ahem! I know that the lack of knowing that you are connected has been an issue in the past.

Query Execution

Background execution of the query has been on the cards for a long time just not a high priority (again, this is use style driven, i.e. most of my queries are against development tables etc). The ability to cancel the query it falls in the same category, it's been a rare need to date but I will look at adding it as part of the background runner enhancement.

Regarding events on completion etc, that’s easy to add. I would just create an event for Before/After query execution with reference to the executing editor (in turn giving access to the query and results). That would probably be raised via the service manager or host window etc. I’ll have a look.

Connections

I can see where you are coming from. Personally almost all my connections use SSPI so I don’t have the password save problem. Probably the easiest way to do it would be a “don’t save the password” option for each connection definition.

To be honest the connection stuff has always been an issue. I would class it as “passable” but definitely not a good interface – it’s just really basic and gets me by. I think I did it in my “anti-XML” phase. I am over that not but just have not revisited the problem!

Minimise/Notify Icon

Fairly easy to do but probably won’t make my to-do list. As always a patch is welcome if you are willing (failing that a straight forward snippet of code etc)

Current Activities

I am actually in the middle of refactoring the projects together as some things have changed over time (and the fact that the app is now open source). I will look at these tasks above in the order above but there is no timeframe to it – again, if you have changes you are willing to make let me know. On that, just let me know if you are working on an area and I’ll stay clear of it for a bit! I have had really useful contributions in the past and have put most in but some haven't made it but only because I was too busy at the time etc...

PK :-)

New Project on Codeplex - File System Database

by Paul Kohler 24. March 2009 01:00

See http://filesystemdatabase.codeplex.com/

Technorati Tags:

It’s a pretty basic set of classes (repository) using JSON files to store data. The intention is for small websites. I’ll add more as I implement it…

The hard stuff is done by

Some sample code…

// get all people...
Person[] people = Repository.GetAll<Person>();
// get a Pet instance (where "Kofi" is the "ID" of the "Pet" object) Pet myDog = Repository.Get<Pet>("Kofi");
// save changes Repository.Save(myDog);

Tags:

Application Architecture Guidance on CodePlex (rant)

by Paul Kohler 22. January 2009 02:43

See

http://www.codeplex.com/AppArch / http://www.codeplex.com/AppArchGuide

for some Microsoft guidance material...

Then… see http://codebetter.com/blogs/gregyoung/archive/2009/01/22/the-data-centric-universe.aspxfor some reactions!

The problem I tend to see (especially being in a fairly small city – Brisbane, Australia) is that people will tend to follow the Microsoft lead without too much thought. Almost everywhere I go the reactions to more pragmatic approaches tend to fall on deaf ears! If I were in a bigger town I would have more choice, that said, Brissy is growing rapidly…

One thing that annoys me a lot is that Microsoft will improve over time but its sooo slow, in the meantime you just want everyone to catch up!! Take the ASP.NET MVC Framework for example. There some really mature ones around but until Microsoft produces one people don’t really jump on the band wagon, then all of a sudden we realise how great it is to work with MVC style web sites.

Then there’s Dependency Injection. Until Unity takes off people will still baulk at something as easy to use as Castle or StructureMap… Arrggghhh!! Then there's unit testing, tdd, bla bla blaa…

I do like what they have done with using CodePlex as a deployment area for these tools though (MVC, the WPF toolkit etc)

We’ll get there, perhaps the guys at http://codebetter.com/ release their own P&P guides… oh yes, they do, every day and code better in general!!

Go read: http://codebetter.com/blogs/karlseguin/archive/2008/06/24/foundations-of-programming-ebook.aspx

Robot, Robot

by Paul Kohler 22. January 2009 02:00

I have always had a fascination with robots, check out “A review of the best Robots of 2008” for some geekness…

From http://singularityhub.com/2009/01/12/a-review-of-the-best-robots-of-2008/

I thought this one was very cool :)

Tags:

Back online at last!

by Paul Kohler 13. January 2009 01:44

I have been “offline” for a long time now due to Internet security and access restrictions at work and lack of time at home. I now have wireless broadband… oh the joy!

:)

Tags:

F5 is an Ad Hock Test Case - Capture It!

by Paul Kohler 19. November 2008 03:15

Derik Whittaker made a post on the "reasons" why we don't use unit tests in developing our apps. The title captures the result of the "don't use tests" approach well I thought (and what I have noticed over time).

Development Rule:
If you don't develop using unit tests, you will spend a lot of time in the debugger!

The thing to note here is that a unit test does not need to be created TDD style (ooooh, heresy!) No really, you can cut some code and then write a unit test, it is allowed!! I prefer TDD style coding but sometimes (especially in an integration environment) it's just really, really hard! If I get on a roll cutting code to meet a requirement I let that flow. Once the rolling stops you re-evaluate your approach. Simple. I am not at all dogmatic about that sort of thing - everything is influenced by many variables.

On helping others getting into unit testing, I find that thinking of unit tests as "small test harnesses" useful. If you are hitting F5 a lot, write a test harness, use a unit test. In time you will get used to using those tests to help from a regression point of view. A few basic tests can go a long way and setup your regression test base.

Also, just keeping the tests simple. Complicated tests just make people ill and hate "testing" in turn rolling back to the lowest common form of test, F5!

Another thing I have found to really help indirectly is a good refactoring tool, I am a Resharper fan (not a plug!) It keeps your tests in shape. Nothing worse than cutting a bunch of tests only to have them stuffed by a bad refactoring session.

A fix for the Blog Engine Importer tool problem...?

by Paul Kohler 24. October 2008 14:03

The problem with the importer is more that it hides the real issue. An exception in the BlogImporter web service is caused when a DateTime.MinValue is mdoified for the timezone - so depending on your timezone you will get the error :)  This throws an unhandled exception resulting in a SOAP error and the blog importer client interprets this as a username/password issue.

IMHO (!) the easiest fix is...

Open up BlogEngine.NET\api\BlogImporter.asmx from the website.

Find the "AddPost" Method, duplicate (what in my build is) line 84 but assign to "post.DateModified = import.PostDate" or "post.DateModified = DateTime.Now". Updating it to the current time is possibly "more correct"... up to you...

Now you should be able to run the importer :-)

The code should look something like this:

    [SoapHeader("AuthenticationHeader")]
    [WebMethod]
    public string AddPost(ImportPost import, string previousUrl, bool removeDuplicate) {
        ...snip...

        Post post = new Post();
        post.Title = import.Title;
        post.Author = import.Author;
        post.DateCreated = import.PostDate;
        post.DateModified = import.PostDate; // or "DateTime.Now"
        post.Content = import.Content;
        post.Description = import.Description;
        post.IsPublished = import.Publish;
        ...snip... 
        post.Import();

        return post.Id.ToString();

    }

 

ASP.NET MVC Generator - First Cut

by Paul Kohler 16. October 2008 07:44

[Update – due to the very nice T4 support and addins the MVC team have enabled (see http://www.pnpguidance.net/Post/ASPNETMVCGetsIDataErrorInfoUICodeGenerationScaffoldingSupport.aspx for example) this side project has been shelved]

I’ll keep this brief, this is the kind of thing you are better off trying for yourself.

Rails and MVC Stuff

One of the things the rails guys enjoy with developing their sites is basic code generation (skeleton files) for models, controllers and views (and whatever else). This "ASP.NET MVC Generator" is a C# implementation of the same idea making use of the standard ASP.NET MVC templates that come with the framework (currently preview 5 the beta).

(Note that for now there is a minor issue around the VB generation because of the lack or namespaces etc...)

Generators

I implemented controller and view generators with a hybrid of the two I call a "controller set". The generator I like the best is the "Controller Set". This generator creates the controller with its actions and the relevant views for each action in the appropriate view area. For example, I have an MVC website (called mvc1) setup in "C:\DEV\MvcSample\". I copy the generator and its templates to the root of the project. I have not worried so much about a Model generator yet because most of us will probably go for LINQ to SQL or SubSonic etc. I plan on adding the Model soon (not that it's hard!) but it's geared more towards the NHibernate/Active Record style of persistence.

C:\DEV\MvcSample>dir
Directory of C:\DEV\MvcSample
15/10/2008  01:50 PM            26,112 AspNetMvcGenerator.exe
15/10/2008  04:42 PM    <DIR>          mvc1
15/10/2008  04:39 PM    <DIR>          MvcTemplates 

I type the following command, sets the root namespace of the code generator to "MVC1" and the base directory to "mvc1" (where the website is from this dir) and the writes out a settings file (called "mvcsettings.xml"). The settings file is loaded if present by default to save typing the namespace etc every time.

C:\DEV\MvcSample>AspNetMvcGenerator.exe /ns:MVC1 /basedir:mvc1 /ws
C:\DEV\MvcSample>dir
Directory of C:\DEV\MvcSample
15/10/2008  01:50 PM            26,112 AspNetMvcGenerator.exe
15/10/2008  04:42 PM    <DIR>          mvc1
15/10/2008  04:44 PM               631 mvcsettings.xml
15/10/2008  04:39 PM    <DIR>          MvcTemplates 

Let's check the contents of the settings file:

C:\DEV\MvcSample>type mvcsettings.xml

<?xml version="1.0" encoding="utf-8"?>

<SiteProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 

<BaseDirectory>mvc1</BaseDirectory>

  <Area />

  <AutoEventWireup>true</AutoEventWireup>

  <ContentTags />

  <Language>C#</Language>

  <LanguageExt>cs</LanguageExt>

  <SafeItemName />

  <ActionMethods />

  <RootNamespace>MVC1</RootNamespace>

  <MasterPage>~/Views/Shared/Site.Master</MasterPage>

  <ControllersPath>Controllers\</ControllersPath>

  <ViewsPath>Views\</ViewsPath>

  <BaseClassControllerName>Controller</BaseClassControllerName>

</SiteProperties>

These are the parameters that are used for substitution in the templates. You can make other changes etc if for example your views or controllers do not reside in the default locations.

For this example I am going to delete the Home controller and its view area (actually one thing I have not got around to doing yet is checking for existing files etc.) The solution looks like this before the code generation:

 

Boring! Now for the good stuff. Type the following command:

C:\DEV\MvcSample>AspNetMvcGenerator ControllerSet Home Index AboutUs Contact

Wrote: C:\DEV\MvcSample\mvc1\Controllers\HomeController.cs

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\Index.aspx

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\Index.aspx.cs

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\Index.aspx.designer.cs

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\AboutUs.aspx

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\AboutUs.aspx.cs

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\AboutUs.aspx.designer.cs

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\Contact.aspx

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\Contact.aspx.cs

Wrote: C:\DEV\MvcSample\mvc1\Views\Home\Contact.aspx.designer.cs

We just generated a "controller set" of files for a controller called "Home" and three actions, Index, AboutUs and Contact....

OK, now jump back into Visual Studio, show all files and include the new files.

 

Now we have a generated "controller set":

(Note that the menu code in the master page is out of wack. Menu items at this level are usually cross controller or make use of multiple master pages etc...)

Now how about another set of files. Try a members area, some actions could be index, list, search, inbox, send message.

C:\DEV\MvcSample>AspNetMvcGenerator.exe controllerset Members Index List Search Inbox SendMessage

Wrote: C:\DEV\MvcSample\mvc1\Controllers\MembersController.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\Index.aspxWrote: C:\DEV\MvcSample\mvc1\Views\Members\Index.aspx.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\Index.aspx.designer.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\List.aspxWrote: C:\DEV\MvcSample\mvc1\Views\Members\List.aspx.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\List.aspx.designer.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\Search.aspxWrote: C:\DEV\MvcSample\mvc1\Views\Members\Search.aspx.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\Search.aspx.designer.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\Inbox.aspxWrote: C:\DEV\MvcSample\mvc1\Views\Members\Inbox.aspx.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\Inbox.aspx.designer.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\SendMessage.aspxWrote: C:\DEV\MvcSample\mvc1\Views\Members\SendMessage.aspx.csWrote: C:\DEV\MvcSample\mvc1\Views\Members\SendMessage.aspx.designer.cs

Again, show all files and include the new controller and view folder. You just got another huge kick-start :-)

The Templates

The main reason that the templates are copied along with the generator executable is that you will tend to tweak them for the individual project – especially the view ones. They are based directly off the standard VS.NET MVC Preview 5 templates. This is partly so that maintenance is easy (a good thing). The only one I added was the view page content (ViewContentPageContent.txt) and a token in the view page ($ContentTags$).

Note that I do need to include the VB stuff yet...

Other Enhancements

Firstly I'll get the VB issues sorted...

One thing I would like to do is add some smarts for the actions – something like if the action is "List" then the controller will generate some basic LINQ against a model. The views could spit out a simple foreach loop or include a control etc. They are not a big priority though seeing as you can code them pretty quick anyway! It would only be if you were working on a real big site.

---

Anyway, let me know what you think, kick it, link it - whatever, all feedback is good!

kick it on DotNetKicks.com

AspNetMvcGenerator-bin.zip (12.86 kb) / AspNetMvcGenerator-source.zip (29.54 kb)

Powered by BlogEngine.NET 1.4.5.10
Theme by Mads Kristensen