Direct SQL Access to ArcSDE Data

Posted by Dave Bouwman | Posted in ArcSDE, ESRI | Posted on 24-02-2006

0

For some time we’ve been working with
SDE’s multi-version views in order to allow direct SQL access to
versioned data stored in ArcSDE. We’ve used this exclusively for
reporting, and it has worked really well. We’ve got a new project on
the go where in we need to facilitate off-line (disconnected) editing
of tabular data in a Geodatabase. I’m just in the R & D phase right
now, but it looks like we’ll be able to use these same views to do data
editing. Granted, we can not facilitate editing of the shapes this way,
but this application does not require that. The nice thing is that the
data will still reside in a geodatabase, and thus will be accessible to
all the tools etc built into ArcMap/Catalog.

The basic architecture follows a simple ADO.NET offline client
application. The client app contacts a web-service and requests a set
of data (as a DataSet), and then switches to off-line mode. The user
makes edits as needed, and then re-connects, and the application sends
the DataSet diffgram to the web service, which re-sync’s the data. I’ll
post some code and links as I get further into this.

CAPTCHA Image Problem in dasBlog

Posted by Dave Bouwman | Posted in General, dasBlog | Posted on 22-02-2006

0

This is weird. On my development system, the Captcha images show up when adding comments into dasBlog. However, on this live site, they do not. No errors, but also no images. I have no idea what’s gone wrong, and I don’t have a lot of time to track this down now.

Thus, comments are likely down for a while.

UPDATE- Banged around in web.config a bit, and re-started IIS, and it’s working again.

Updated Blog Skin…

Posted by Dave Bouwman | Posted in General, dasBlog | Posted on 21-02-2006

0

Just updated the blog skin to keep with the theme on the main part of the site. With this, I think I’m finally done with the main parts of my site update – still adding content into the main area, but most of the picky CSS / photoshopping is complete.

Developer Fundamentals: Getting your Objects Oriented…

Posted by Dave Bouwman | Posted in .NET, Devt Tools, Fundamentals | Posted on 16-02-2006

0

Time for another dose of developer zen. This time I’ll try to take a
quick look at OOP (object oriented programming) and some issues which
can occur if you are transitioning from procedural languages (AML) or
pseudo OOP languages (VB6 & Avenue). To start with, I think it’s
worth noting that just because you are using an object oriented
language (Java,C#, VB.NET etc.) does not mean you are writing /
designing your code in an object oriented manner. I think this may be
an afront to some people, but it’s just the truth. You can write
procedural code in any OOP language. And it can work. But there’s just
so many reasons not to.

In this article, I am simply listing 3 things you should try to avoid. For more detail on
Object  oriented programming,
hit Google. Of course, you can ignore these warnings, but if you have
to try to maintain or grow your code, you will run into problems.

Design As You Code
This is also known as “no design”, or
hacking. Honestly, if you ever take anything away from this blog, I
hope it is this: Always design before you code. The level to which you
take this typically depends on what you are doing. If it’s a quick
one-off VBA script to rename a set of files, then just jotting down a
bullet list of “requirements” is enough. If you are trying to create
complex workflow managment system for a diverse set of users, you may
have several 1000 pages of requirements. In either case, having a
design is critical, if for no other reason that it can tell you when
you are done (i.e. all requirements are met). At some point I’ll post
about our design process, which tries to do “enough” design without
going crazy with UML, but that’s a little past the fundamentals.

GIS Data Objects “Special”
Many times I’ll see code where the
developer has used objects for all kinds of things, but when it comes
to the actual GIS datasets (feature classes etc), they are alway
treated differently. It’s important to understand that in most cases,
you can use these types just like any other types (string, int,
arraylist etc). The reason we model things as objects is that there is
some inherent relationship between them. And if one of the items that
particpates in the relationship is a featureclass, then add it as a
property of the class. Granted, you’re not going to be able to
serialize the class out to an XML file and expect the featureclass to
go along, but you can work around those cases. The point here is to not
be shy with these things. It’s also a departure from typical GIS
thinking, which can be hard for people just beginning to make the
shift.

Side Effects (or Why Globals are Evil)

Unlike special effects in movies, these are bad things to encounter. A
“Side Effect” occurs when something effects the internal
implementation, in a way which is not expected. The end result is code
which may “look” correct, but acts incorrectly in certain situations.
The code below show a pretty contrived example. It has a property
“ShoeSize” and a method “Add”. Add takes two integers, and returns an
integer. The developer would expect that add would simply return the
sum of the two numbers. However, if ShoeSize is set, it returns the sum
of the two numbers plus shoesize.

    1 Public Class SuperClass

    2 

    3     Private _shoeSize As Integer = 0

    4     Public Property ShoeSize() As Integer

    5         Get

    6             Return _shoeSize

    7         End Get

    8         Set(ByVal Value As Integer)

    9             _shoeSize = Value

   10         End Set

   11     End Property

   12 

   13     Public Function Add(ByVal firstNumber As Integer, ByVal secondNumber As Integer) As Integer

   14         Return firstNumber + secondNumber + _shoeSize

   15     End Function

   16 

   17 End Class

This is a very extreme example, but I think it shows the general idea.
The method Add does not indicate that anything else is involved, yet in
some cases (ShoeSize != 0) it will return an unexpected result, which
will be very difficult to track down. A very common way to end up with
a mess of side effects is through the use of “global” variables. In
this case, a the variable gets set in one place, and then used in some
other location which is not apparent to the developer. These sort of
problems are really tough to track down. I’ve seen projects where it
cheaper and faster to delete the application and start again rather
than trying to sort out what was going on. Good Luck!

Free APress eBooks on COM and .NET Interop…

Posted by Dave Bouwman | Posted in Devt Tools, Fundamentals | Posted on 16-02-2006

0

While reading Jackie Goldstein’s blog on .NET and “stuff”, I saw these two free
eBooks which would be good reading for the ArcObjects developer community.

Descriptions are from the APress Site…

COM and .NET
Interoperability

COM and .NET Interoperability provides a complete overview of the
process of building .NET applications that interact (interoperate) with existing
COM code. Before digging into that critical topic, author Andrew Troelsen offers
a concise overview of the COM architecture and provides examples using various
COM frameworks (C++, ATL, and VB 6.0) as well as the core .NET managed languages
(C# and VB .NET). After covering the preliminaries, the book explores numerous
issues that arise in interoperability, including interacting with the Win32 API,
dynamically generating source code via System.CodeDOM, creating serviced (COM+)
components using managed code, manually editing (and recompiling) .NET metadata,
and the process of constructing custom COM/.NET conversion utilities. Both
intermediate and advanced developers will welcome the practical information they
need to quickly work with COM and COM+ in .NET applications, and learn how to
create .NET components that are COM compatible.

It’s
792 pages, which is pretty weighty, but if you want to get some indepth
coverage of this topic, it sounds like a good starting place. I’m not a
huge fan of “reading” a PDF “cover-to-cover”, but you can’t beat them
for searchability.
Direct Download Link (6.36 MB
PDF File)

Programming VB .NET: A Guide For Experienced
Programmers

In Programming VB .NET: A Guide for Experienced Programmers, authors
Gary Cornell and Jonathan Morrison carefully explain the exciting new features
of Visual Basic .NET. Since VB .NET is, for all practical purposes, a whole new
language even for the most experienced Visual Basic programmers, developers need
to think differently about many familiar topics. Cornell and Morrison are there
to help you with careful discussions of each topic. All experienced programmers
wishing to take advantage of the amazing new powers of VB .NET will benefit from
this books careful treatment of fundamental topics, including inheritance,
interfaces, and exception handling, as well as all the powerful new features,
such as stream-based I/O and true multithreading. Cornell and Morrison write
from the point of view of the experienced programmer, with constant references
to the changes from earlier versions of VB. Developers learn how to use VB .NET
for database programming through ADO.NET and web programming through ASP.NET.
After reading Programming VB .NET: A Guide for Experienced Programmers,
developers will have a firm grasp of the exciting new VB .NET language and its
uses in creating powerful .NET applications.

This book would
dovetail really nicely with the Fundementals series I’ve been posting. If you’ve
got a background in programming, and are moving into VB.NET, this sounds like a
good bet.
Direct Download Link (4.9 MB
PDF File)

There are 6 other free books at the APress Site.

Issues linking from dasBlog to a “Parent” 2.0 application…

Posted by Dave Bouwman | Posted in .NET, ASP.NET, Software, dasBlog | Posted on 13-02-2006

0

Whoa! I just tried to follow the link to my main page on the previous post, and I got an ASP.NET config error! doh!

This is strange because when I hit the page, it will load and run – so this is somehow related to coming from dasBlog.?!?! Anyhow, this is something dasBloggers may want to be aware of…

UPDATE: This was due to a mangled URL that had a space on the end. Check your URLs when you copy/paste into the FTB “Create Link” tool, as you can’t see the “space” tacked on the end.

Emailing Map Images…

Posted by Dave Bouwman | Posted in .NET, ASP.NET, Web Mapping | Posted on 12-02-2006

0

So – I need to facilitate emailing a map from a custom .NET ArcIMS site. (built on DotNetNuke – screen shot below)

 In .NET we conventiently have the System.Web.Mail namespace and objects to help out with this. It’s almost trivial to use…


Dim Email As New MailMessage
Email.To = “address@something.com
Email.From = “from@something.com
Email.Subject = “Hello”
Email.Body = “This is the email.”
SmtpMail.SmtpServer = “localhost”
SmtpMail.Send(Email)

The issue is how to attach a map. There is an
Attachemet object, but it only supports attaching FILES. So you say -
big deal - ArcIMS has created a .gif file, just send that. Well,
that’s cool if ArcIMS is on the same physical machine as the .NET app,
or if you can map a drive to ArcIMS’s output location, but what happens
when that’s not possible? i.e. you need to retreive the map from the
output location, and then attach it. Ideally you do this by loading the
image from the URL using a WebClient object (this is easiest, maybe not
fastest)…


Dim webC As WebClient = New System.Net.WebClient
Dim OutputBitmap As Bitmap = New Bitmap(webC.OpenRead(http://myims/output/map2.gif))

Great. Now I can save the bitmap out to a file, and
attach it. Which is what I’ve done for v1 of this tool. The downside is
that you need to setup a directory that your ASP.NET application can
write to, and can clean up. This is a lot of work for very little gain.
Would’nt it be great if you could just create an attachment from a
stream?

Well, apparently there are a bunch of commercial SMTP
components which can do this, and while I’m not against them, I can’t
legitmize $200 per server for this little function – so I looked for
some open source stuff. I found some classes that send messages via
SMTP without using System.Web.Mail – they get all old skool and speak
SMTP and use TCP sockets. So this is the first part. They’re mostly C#
(and I’m a VB.NET kinda guy), but I may go ahead and extend them
to support adding attachments via streams. We’ll see if I need this,
but wanted to write it up anyhow…

Resources:
ComponentSpot is a great place for FREE components. Here are two SMTP projects
 
VB.NET Sending SMTP using Sockets

C# SMTP Mail without using SMTP Service or CDO (which is behind System.web.Mail)

Moving the site to ASP.NET 2.0: Part 4 – It’s done!

Posted by Dave Bouwman | Posted in .NET, ASP.NET, General | Posted on 12-02-2006

0

It seems that I’ve managed to get it all sorted out, and more or less working. I’ve found a couple of glitches related to the photos area of the site (the URLs are not properly formed – odd because it worked on my home system), but other that that, things are now running under 2.0.

Check it out at http://www.davebouwman.net

Anyone who was using my .com address will have some issues, but I’ll have that forwarding shortly.

Next thing (besides getting the photos working) – extend the theme into my blog.

Running dasBlog under ASP.NET 2.0 : Membership & Themes

Posted by Dave Bouwman | Posted in .NET, ASP.NET, dasBlog | Posted on 11-02-2006

0

Just a quick note on some issues I ran into getting dasBlog running in a subfolder under an ASP.NET 2.0 app
that uses membership, roles , master pages and themes…

The first step to getting dasBlog running under a .NET 2.0 is to make the suggested changes in your web.config. Search this file for “2.0″ and make those changes. In many cases, this may be all you need to do.

Membership & Role Providers
On my new site, I’m using the 2.0 membership and role capabilities. Since I’m trying to keep the site very lightweight, I’m using some read-only, XML based providers that I got from MSDN.

Links:
Read-Only XML Membership Provider,

Read-Only XMl Role Provider

These providers are setup in the web.config of the main application:


web.config for main application
<membership
  defaultProvider="AspNetReadOnlyXmlRoleProvider">
 <providers>
  <add name="AspNetReadOnlyXmlMembershipProvider"
     type="ReadOnlyXmlMembershipProvider, CustomProviders"
    description="Read-only XML membership provider"
      xmlFileName="~/App_Data/theUsers.xml"/>
  </providers>
</membership >
   similar section for the roles...

Since the xmlFileName is an app relative path, the file can not be found when running in the /blog subfolder. Not sure if this is the “best” way to get past this issue, since I could not find another way to disable the membership provider, I simply added this into the web.config in the /blog folder, and cleared the providers…


web.config for dasBlog
<membership defaultProvider="none">
 <providers>
   <clear />
  </providers>
</membership >

The Roles were much easier – I just set the enabled property to false in the dasBlog web.config…


web.config for dasBlog
<roleManager enabled="false" />

Of course this means that you have to log into the blog separately from the main site, but I can live with that for now.

Themes
As I mentioned, the main site uses themes. While struggling with themes, I had specified the theme this up in the <pages tag in the web.config, but when I hit dasBlog, ASP.NET would throw an error saying it could not find the theme ( another app relative path thing). I was able to get it working by simply removing the theme element from the pages tag. This worked for me because I’m also specifying the theme in the master page. If you are applying a theme directly to your pages without a master page, this could be a problem.

At this point, it’s all working on my local machine, but I still have to upload it to my host (webhost4life) and see what happens there!

Developer Fundamentals: Introduction

Posted by Dave Bouwman | Posted in .NET, Fundamentals | Posted on 10-02-2006

0

As we see the convergence
of IT and GIS, many more traditional GIS users (”GIS Analysts”) and
other people are finding themselves faced with creating stable,
maintainable GIS applications. To help out, I thought I’d start a
series of postings about software development fundamentals. While this
is not going to to replace “real” training, time spent reading books,
and actual hands-on-the-keyboard coding, hopefully these posts will
help people avoid common mistakes.