Moving the site to ASP.NET 2.0: Part 2

Posted by Dave Bouwman | Posted in .NET, General | Posted on 30-01-2006

0

I had some time over the
weekend, and made a bunch of progress…

I overcame the styling issues
by simply using themes, and apply styles to the menu via the properties. This
was much easier than trying to sort out how to use CSS directly. Perhaps I’ll go
back to that once I’m a little more experienced with these controls.

Next
up was adding in Membership & Roles. I want to be able to manage much of the
content with out opening Visual Studio, so I need to support logins. I also want
to have non-public photo albums, which means I need some roles for the logins.
Of course I could just use the SQL providers, but I also want to avoid a
database on this site. Thus, my plan was to look for an example Membership
Provider, and re-work it to use an XML file for persistance. Conveniently,
Microsoft actually has a sample Read Only XML Membership Provider . And they did the Role provider as well.
Thanks! That made things go much faster.

Then it was on to integrating
the Free Text Box. Again, this was so simple that it suprised me. Now, when I
login, I can edit the content on the front page. Ta-dah!

From here, I
jumped into the photos section. My plan is to upload the photos into folders on
the web server, and then “register” the folder with the application. The
registration process will create a “view” version of the photo, as well as a
thumbnail. These will be persisted as files on disk to lower the CPU load when
viewing the photos (no dynamic thumbnailing).

Rick Strahl had some handy
code that does the image re-sizing part. Then it came to persisting the photos
into an XML document. For this, I cooked up a simple little set of objects which
contain the PhotoCollection, and can be serialized to XML. I left things at a
point where I can register a folder via the web page, and it will correctly
re-size all the images, and write out the XML file.

Next up – displaying
the photos…

.NET Social Bookmarking = DotNetKicks.com

Posted by Dave Bouwman | Posted in .NET | Posted on 27-01-2006

0

If you are doing .NET development and have not found DotNetKicks.com yet, I highly recommend it. It’s basically  Digg
but for .NET related information.

From the site…

What is dotnetkicks.com?
dotnetkicks.com is a community based news site edited by our members.
It specialises in Microsoft development techniques, technologies and
tools including ASP.NET, C#, VB.NET, C++, Visual Studio, Team System,
SQL Server and Microsoft Vista.

Individual users of the site submit and review stories, the most
popular of which make it to the homepage. Users are encouraged to
‘kick’ stories that they would like to appear on the homepage. If a
story receives enough kicks, it will be promoted.

Whenever I check it, I find something cool.

Moving the site to ASP.NET 2.0: Part 1

Posted by Dave Bouwman | Posted in .NET, General | Posted on 26-01-2006

0

I thought I’d share how this little project is going through a number of postings. The main goal of this evening’s work was to transfer the design from photoshop into ASP.NET, which I managed to accomplish in just over 3 hours. At this point, I’ve cut up the images, created the page framework, jammed this into a master page, built out a set of empty content pages and hammered out a stylesheet. Whew.

For the most part, things went pretty smoothly. I may as well state this now – up until today, I have not done anything with ASP.NET 2.0 – I attended a half day launch event, and from that and simply fiddling around, sorted out the main parts of Master pages. However, when I have a content file in a sub-folder, for some reason the master page does not get attached/injected. Ah! As I type this, I get it – the problem is that the stylesheet is linked as “main.css”, which of course is not pointing to it’s real location of http://localhost/main.css if the page is in http://localhost/somefolder. So, writing this blog just helped me!

The Menu control is also somewhat baffling. Attaching it to the sitemap was easy enough (think I saw that demoed), but styling it is a dog. I’ve kludged it together for now, but still need to add Hover styles. It’s nice that the control exposes a zillion properties for all kinds of styling, but what I really want is an easy way to apply the style from a linked sheet. Specifying cssClass seems to work to some extent, but I need more info.

At this point, I think I need a book – at least it will make things go faster.

For anyone interested, the site as it stands is at http://www.davebouwman.net/sandbox

Maybe it’s just my wireless connection, but it seems pretty slow to me – especially as compated to this blog page, which is doing a lot more “work”. I may have to ask to be moved to a faster server. Again.

New Site Design…

Posted by Dave Bouwman | Posted in .NET, General | Posted on 24-01-2006

0

I’ve started working on a new version of my site. My reasons are two-fold:
1) Learn ASP.NET 2, and
2) This is not really a “site” per-se. More a loose collection of pages with a blog. Time to consolidate!

I started by looking at the Personal Web Site started kit that you can get from ASP.net. While this is a neat starter kit, it’s got way too much overhead for a simple site – storing photos in SQL rather than the file system?? Membership? I guess the idea was to show concepts more than an streamlined personal site. Anyhow, here are my general goals for this little endeavor:

No Database
While I’m sure that the whole SQLExpress-just-upload-the-file-and-it-will-work thing is great when you have a dedicated server, I’ve got shared hosting. So, I’m going to use XML files to lower the load, and hopefully have the site load faster. Mix in some caching, and it ought to scream. This works really well for dasBlog, so it should work for the very simple site I’m going to cookup.

XHTML Compliant
This should be fun. I’m lucky if I can get a single posting to be compliant, so building an entire site should be a real learning experience.

All C#
While I do think that there is nothing “lesser” about VB.NET, and I do the vast majority of my coding with it, it’s always good to keep my curly brackts and semi-colons in check.

Open Source
Once it’s up and going, if you like it, I’ll post the code for the main framework. Seems only fitting as I’ll be leaning heavily on the community for tips and tricks.

Better Design
Not sure if I have the time/patience to go for a rounded-corner look, but at a minimum, I want have a nicer design. Not that I don’t like what I’ve got going on, but I was really just learning CSS when I did this. I like what I did on ArcDeveloper a lot more.

That’s it for now. Right now I’ve got the graphic design done, and will start in on the master page over the next few evenings.

Edting ArcSDE data using SQL & Multi-Version Views

Posted by Dave Bouwman | Posted in ArcSDE, ESRI | Posted on 21-01-2006

0

This is a run down of things to be aware of if you are trying to edit attribute data stored in ArcSDE via Multi-Version Views.

I’m writing this up because the ESRI documentation on
using multi-version views is rather lean, particularly with respect to
managing ObjectID’s and dealing with versions after you’ve made your
updates.

Editing Data Via Multi-Version Views
Multi-version
views can be used to edit attribute data stored in ArcSDE via SQL
statements, but some very specific conditions must exist for this to
occur. The most important condition being that when doing inserts
(creating new records, which will lack a spatial representation), the
multi-version view can not be referencing a version currently in use by
ArcMap. This is explicitly stated in the Multi-Version View documentation.

While
no explanation is given, my investigation leads me to believe that this
is related to the fact that ArcSDE controls the value of the ObjectID
column, but that inserts through the multi-version view’s do not
automatically utilize this functionality. Rather, the developer must
manage the ObjectIDs. The easiest way to deal with this is to use SQL
and get MAX(ObjectID) from the multi-version view , and add 1. However,
if there is an ArcMap session that is also editing this same layer in
the same version, this scheme does not work. This is because ArcMap
“checks out” a block of ObjectIDs as soon as an edit occurs on a
feature in a particular feature class. (This is what those
i[reg#]_get_ids stored procedure is for).

Thus, if edits are
occurring in ArcMap, and an multi-version view is used to insert a
record, assigning ObjectID to MAX(ObjectID) +1, this feature will be in
conflict with any newly added features that are created in the ArcMap
editing session.

Overcoming ObjectID Issues
After
some digging around, I believe that you can use the i[reg#]_get_ids and
i[reg#]_return_ids stored procedures to “check out” a block of
ObjectID’s just like ArcSDE does. I say “believe” because the
application I’m building does not require this because of it’s business
process (inserts go into another set of tables, which are never loaded
into ArcMap or anyother ArcSDE client – thus Max(ObjectID) + 1 works
just fine. Anyhow, as long as you “get” a block of ID’s (I’d suggest 1
at a time so that you avoid having to “return” them) you should be able
to insert records.

Named Versions
Another wrinkle,
which is noted in the documentation, is that you can not make edits
into a version currently in use by ArcGIS. If you try to run an UPDATE
or INSERT query against the MVV while the version is open in ArcMap, an
error is returned. If you run the query in SQL Analyzer, you’ll get
something like this:

Server: Msg 2627,
Level 14, State 2, Procedure SDE_state_def_insert, Line 21 Violation of
UNIQUE KEY constraint ’states_uk’. Cannot insert duplicate key in
object ‘SDE_states’. The statement has been terminated.

Thus,
if there is any chance that there may be an edit session underway, you
will need to create a named version and run the queries against that
version. This works as shown in the documentation – just make a call to
the sde.CREATE_VERSION stored procedure. What the documentation leaves
out is how to then post & reconcile this named version back into
the version that you actually wanted to work with!

While there
are not stored procedures that can deal with this, the developer kit
has is a sample which can help out with this part – check out the “Versioning Service” sample.
Essentially,
you need to use some ArcObjects code to actually post and reconcile the
newly created version. Again, this can be pretty simple, but if there
are edits occuring in ArcMap, then there is a chance you will have
conflicts, which leads to the question of how to resolve them. For my
application, this is not a real problem the data being added via the
multi-version view’s is field data, and thus more correct than anything
that would result from ArcMap edits. Additionally, the user who is
adding this data into the system is the only user who actually has edit
permission to the features that would be effected. (maybe I’ll cook up
a post on feature level security…) Anyhow, if a conflict occurs, the
data from the multi-version view version always overwrites the other
data.. However, this is just another fluke of our client’s business
process.

Summary
While Multi-Version views support
editing, the limitations are onerous, and I suspect by design (I
suspect someone wants you to use a pricy ArcSomething license to edit
your ArcSDE data). However, for read-only usage, they are a really
powerful way to create reports against your enterprise geodatabase.

[UPDATE]
In a comment on the original post when this was on ArcDeveloper.net, Neil noted the following:

Here’s some additional stuff on the objectids issues you mentioned, at
least for the version of sde I’m working with – 9.1 SP1 with MSSQL
2005.

It looks like you can just leave the OBJECTID column out of the insert statement.

There is an insert trigger on the multi-version view that calls the
_get_ids & _return_ids stored procedures that you mentioned to
generate the objectid.

New PC…

Posted by Dave Bouwman | Posted in General | Posted on 08-01-2006

0

While my trusty old (2001) Micron is still good for email & surfing, it just could not handle Visual Studio 2005 + SQL + IIS. So it was time to get something new. Of course I wanted fast, cheap, quite and small. I went to a local computer store that does custom systems, and they were willing to hook me up with a loud, tower, mid-range box for ~ $1000. Of course for a couple of hundred more, it could be quiter, with a better CPU… Ummmm. no.

Enter TigerDirect.com – Long story short, I hooked up a Shuttle XPC, with an AMD Athlon 64 (3700), 1GB of 3700 DDR Ram, 160GM of disk, card reader, DVD+-R/RW/CD-R/RW, 128Mb ATI something card for ~$700. And it’s quite (can barely hear it when there is no other sound in the room), small (8″ high, 8″ wide, 12″ deep), and for the price – really fast.

I had been hesitant about going the total DIY route, but I just could not stomach spending about $600 more just to have someone set it up. So, if you are considering building their own box (and saving a bunch of cash), I highly recommend doing it. The only thing that was at all complex was determining how much power the system would need. Handily, digg had a link to a really cool power calculator. Just select the parts you’re going to be running, and it will tell you what size power supply you’ll need.

Actual assembly is trivial compared to setting up a home theater system. From opening the boxes to logging into XP it took less than 2 hours.

Now to update my site to .NET 2.0!

DNN3 Module Development…

Posted by Dave Bouwman | Posted in .NET, DNN | Posted on 05-01-2006

0

Over the last few months I’ve been building DNN 3.x module for a local non-profit. I’ve built a couple of DNN 2.x modules, and armed with the Wrox Press DNN book, I dove in. These are some things that really stuck with me from this experience…

Page Caching
Its not obvious that your module is cached by default. Thus if you create a module that has dynamic content, it’s pretty confusing to see that it works as expected when logged in as Admin or Host, but does not work when logged in as some other user (or anonymous). The caching can be changed in the module definition, or when the module is added to the page (Settings –>Page –>Advanced), but if you know your page is gonna be dynamic, then it’s best to set in the module like so:

MyBase.ModuleConfiguration.CacheTime = 0

Unit Testing
I tried a bunch of things to get some unit tests to work for my Data Access Layer. In previous experience with DNN, I’ve found that a lot of time was spent trying to sort out the DAL (even using templates – more below). Thus adding in unit tests would be a great way to validate that the DAL is working correctly. I was a while ago now, but I tried all kinds of stuff to get it working, and eventually found a post on the DNN Forums about this. I had ended up doing something similar, and then tried to reproduce what was outlined on the thread. No luck. And some others have also tried without luck. Anyhow, I hope someone can help sort this out because it would really help all of us who are developing for DNN.

Code Smith Templates
First off, thanks to all who have worked to create the DNN Jungle Code Smith templates. I would say that they are pretty handy for getting to know the DNN provider model, and can easily be used for very simple database schemas (1 or 2 tables for your module). However, if you are dealing with 1-M or M-M relationships, or more than say 5 tables, it’s more of a pain to code using the output of the templates than it is to roll your own.

For example – if I have a 1-Many relationship in the database, I want my DAL class for the “1″ table to contain a typed collection of classes from the “Many” table. Trying to manually maintain this sort of relationship using a set of other “controller” and “info” objects is a real pain. It also makes the DAL model more complex to use. This in turn makes it difficult to have a team made up of various skill and experience levels.

And finally (and this is likey personal preference) – I like having a single Controller for all the ‘Info’ classes – makes it easier to know what you’re working with, and you have to create fewer objects.

MyGeneration
More recently David Wright left a comment over on ArcDeveloper suggesting I check out MyGeneration. Turns out that AppTheory has created some DNN 3 templates for it. I have not had a chance to look at how these work, but I’m thinking we’re going to start using MyGeneration (free) rather than buying into CodeSmith ($400 / developer). In the little playing I’ve done with MyGeneration, I think that I’ll be able to create templates which more closely meet my needs outlined above.

Another thing – (this could be my inexperience with CodeSmith), but all the templates I’ve seen deal with one table or one database at a time (think this is related to the interaface options in CodeSmith) – I’d like to be able to select a group of tables (i.e. all the tables related to my module) and have it do all the code gen at once. From reading in the CodeSmith forums, it sounds like people run the tool once for each table, export the settings and then run it in a batch mode. This seems a little long winded to me, but if it works, it’s great. However, just doing a little playing around with MyGeneration, it looks very easy to select groups of tables within the default interface.

Another interesting option is to create your own database connector – and what comes to mind for me is a geodatabase connector. That would allow us to create feature class extensions / multi-version view DAL / wrapper classes via code gen. Since this would be a big boon for us, I’ll be looking at this in the coming weeks.

Getting back at it…

Posted by Dave Bouwman | Posted in General | Posted on 05-01-2006

0

The New Year has rung through, and we’re all getting back to work again. Unfortunately I’ve been lagging behind a little due to a mighty head cold. Uggh.

Regardless, we’ve got a bunch of cool projects coming up, which should generate some good posts both here and on ArcDeveloper. Right now I’m just finishing up two Geoportal projects, and will post some screen caps and URLs when they are finalized (one is public, the other internal to the US Forest Service).

We’re also working on a very burly geoprocessing system that will produce “fire risk” maps – this is a derivative project that spun off our work on the Souther Wildfire Risk Assessment (SFRAS) project (GeoWorld Article). We’re building this as a command line batch processing tool, designed to be intergrated into an image processing workflow. The modelling involved is very complex – elliptical filters, external fire science dlls, and some fun grid math. Thankfully Joe Berry is helping us with that aspect of things.

After that we’re going to spend some time working with the ESRI .NET ADF and Image Server as part of the 9.2 beta programs – should be very interesting. Then the new projects hit. And somewhere in there we are going to have our first child!! So, things are going to be moving pretty fast for the next few months, but I’ll try to keep a steady stream of relevant posts coming out.