Skip to content

Custom Configuration Sections in a .NET config file

I’ve been working on a basic rules based web service for InfoPath forms.  The basic idea is to allow us to do “poor man’s integration.” to some back end systems now and then swap that out later without modifying the forms — since the forms will be adapted by several people and there may be more forms than we want to go back through. So a single web service that all InfoPath forms call on submission — by the way one they call in addition to whatever else they want to do — for instance, post themselves to a SharePoint site.

Anyway, so I needed a rules section in the config file where each rule had some attributes.  The problem is that .NET isn’t setup to easily hand you back the XML from a section in the configuration file — actually it gets pretty upset about the section even being in the file.  The solution is a IConfigurationSectionHandler.  Here’s what it takes to implement…

1) Modify the web.config file.

a) Add a <configSections> tag.  Note this must be the first tag in the <configuration> node.  This looks something like…

 

<configSections>
  <sectionGroup name=”customConfig”>
    <section name=”rules” type=”InfoPathRouting.Classes.XMLConfigurationSectionHandler, infopathrouting” />
  </sectionGroup>
</configSections>

In this case, I’m creating a new section called customConfig and adding a section in it called rules, which my class (InfoPathRouting.Classes.XMLConfigurationSectionHandler) in my DLL will handle.  (InfoPathRouting is the ASP.NET project name)

b) Add the actual section in the file.  In this case I’d add something like:

 

<customConfig>
<rules>
  <!– Whatever I want in here —>
</rules>

 

2) Add the class to the project.  Here’s the XMLConfigurationSectionHandler that I wrote.  The only restriction is that it must support the IConfigurationSectionHandler interface.  That interface only defines one method, Create().

 

using System;
using System.Configuration;
using System.Xml;
namespace InfoPathRouting.Classes
{
  public class XMLConfigurationSectionHandler : IConfigurationSectionHandler
{
    public object Create(object parent, object configContext, XmlNode section)
{
      return (section);
    }
}
}

In this case I wanted the XMLNode back so I could do my own thing with the XML fragment, so that’s what I returned.

 

3) Reference the configuration section in your code.  The following line of code fetches the XMLNode for my new rules section:

 

XmlNode rules = (XmlNode) System.Configuration.ConfigurationSettings.GetConfig(“customConfig/rules”);

That’s it.  I now have a repeatable way to store any kind of XML configuration I want in my app.config and web.config files.

Anatomy of a Software Development Role: Training

Wrapping up the software development lifecycle and turning over the completed product to the users is the training role. The training professional is the last one in the process since they are the ones who get the mass of users to use the software that has been created. Their purpose is to help the users understand how to use the software that’s been created. (If you’ve not been following the series, you should read Cracking the Code: Breaking Down the Software Development Roles.)

What’s the Training role?

The training professional first and foremost creates the materials necessary to train users how to use software. For that reason, training professionals are often tapped to create user documentation and help files in smaller organizations.

The training professional is ideally someone who has an instructional design background and therefore understands how to create materials that are effective in helping adults learn. They are also, ideally, someone who can approach the problems that the software solves in a way which makes sense to the users. Click here to see how the Deployment role fits within the full organizational chart.

http://www.developer.com/java/other/article.php/3523171

Four Things you’re missing in your backup strategy

Backup Strategies aren’t always about when to backup and what to backup. They are often about how to create the right systems to allow you to discover problems when they occur.

When most people think of a backup strategy they think about tape rotation and backup schedules. While these are important parts of a backup strategy they’re not the whole story. As an organization begins to assimilate more and more servers, a reliable backup strategy becomes more challenging. Instead of one tape drive that backs up the entire network, libraries become necessary. Instead of doing one backup job and schedule, you need several. Here are four fundamentals for developing your backup strategy.

Plan for growth

Most organizations have begun to start monitoring their disk storage needs. While disk storage is cheap, the cost of maintaining all those files, including archives and backups, starts to become a real expense. When an organization plans its disk needs, it needs to review its growth and determine how much extra disk space will need to be purchased over the next year.

But here’s the rub. Adding more disk space is relatively easy. You just add new drives to the disk array or you swap out smaller disks for larger ones. The process takes time but it’s relatively transparent. Upgrading tape capacity isn’t so easy for most organizations.

http://www.techrepublic.com/article/four-things-youre-missing-in-your-backup-strategy/

 

Getting the original display name for an internal name

Bil Simser posted on a problem with CAML where he mentioned reverse engineering the internal field name to the original display name that created it.  I had to do just this thing for one of migration utilities.  Here’s the code (C#):

// Fixup an internal name back to the regular way that it should be so that we can get the same
// internal name back when we create a title.
private static string FixInternalName(string internalName)
{
// Get the most common one out of the way as quickly as possible
string f1 = internalName.Replace(“_x0020_”, ” “);
int pos;
// while we have more processing to do
while ((pos = f1.IndexOf(“_”)) >= 0)
{
int chrVal;
if (pos + 6 > f1.Length)
{
chrVal = PartialEncoding(f1,pos);
}
else
{
chrVal = int.Parse(f1.Substring(pos+2, 4), System.Globalization.NumberStyles.HexNumber);
}

if (f1.Length > pos + 7)
{
// char isn’t at the end of the string
f1 = f1.Substring(0, pos) + Convert.ToChar(chrVal) + f1.Substring(pos+7);
}
else
{
f1 = f1.Substring(0, pos) + Convert.ToChar(chrVal);
}
}
return (f1);
}

private static char PartialEncoding(string fix, int pos)
{
pos += “_x”.Length;
if (fix.Length > pos)
{
string nw = String.Empty;
while(pos < fix.Length)
{
nw = nw + fix[pos];
pos++;
}
while(nw.Length < 4)
{
nw = nw + ‘0’;
}
return (Convert.ToChar(int.Parse(nw, System.Globalization.NumberStyles.HexNumber)));
}
else
{
// Not even enough to start — return a space it will get encoded
return ‘ ‘;
}
}

Quick Tip: Don’t forget Outlook’s ability to display a web page for a folder

While working with a client recently we were discussing the issues with the Exchange web parts that are shipped as a part of SPS.  (This spawned the development on the new Exchange web parts, see my previous post.)

However, we came to the conclusion that it might be too small to include some email items in SharePoint.  So I mentioned the idea of doing things the reverse way.  Use Outlook to host your SharePoint site.  It’s a feature that’s been around in Outlook for a while.  All you have to do is…

  1. Create a folder in Outlook.
  2. Right click, select properties.
  3. Click the home page tab.
  4. Enter the address of your SharePoint site in the address text box.
  5. Select the show home page by default for this folder checkbox
  6. Click the OK button.

Now when you navigate to this folder in Outlook you’ll see your SharePoint site.  Not a bad deal when you’re looking to have a single dashboard to the organization and you live in email — as many of us do.

Beta Opportunities

I’ve got a series of web part packs and utilities of various sorts that I have on my radar to release in the next few months.  As I’m getting geared up for that, I’d like to see if anyone would be interested in doing some beta testing.  Here’s what’s on the plate short term…

  • SharePoint URL Management – If you let your users enter URLs on your SharePoint sites then you know that they can and do link EVERYWHERE.  The point of the URL management utility is to first, identify where users are linking to — in every URL field in every list in every site in a site collection.  The links are organized by server by URL and finally by where they are used from.  The second feature of the application is to do wholesale replacements of URLs and parts of URLs.  So you can change the server that a URL points to, the path of the page, or even everything about the URL including any querystring parameters provided.
  • Exchange Web Parts – SharePoint Portal Server offers some basic Exchange Outlook Web Access web parts. From my perspective they have two fundamental flaws.  First, they can’t be used in Windows SharePoint Services.  Second, they require that the user personalize the web part properties.  This web part pack won’t need the users to personalize the properties to be able to use it.  Thus it doesn’t require personalization at all.  The web parts figure out who the user is based on their login name.
  • Site Properties Pack – Site properties in SharePoint are very powerful.  They are a quick way to provide some “state“ information about the site which can be used to connect to other applications.  The site properties pack will contain a web part to visually display and modify site properties, a content editor web part which will take content and display it while doing property substitutions, and a list display web part that allows for display of a list with property substitutions in the URLs.  Together they are a toolkit to get you started with working with site properties for integration.

There are more applications to come but these are the ones that I’m to the point of writing documentation for.

Four steps for reducing project risk

Risks in a project are inevitable. However, carefully collecting, evaluating, prioritizing, and controlling risks can increase the chances of success for your next project.

Whether it’s small or large, complex or simple, every project has risk. It’s our job as managers to do our best to not only minimize the risk in our projects but to minimize it as soon as we can. In this article, you’ll learn a simple four-step approach for doing just that.

Inventory

The first step to managing the risk of a project is to inventory the situation. That is, identify all of the risks that you think are possible in the project. The inventory should include all internal factors for the project such as resource changes, assumption failures, and sponsor availability. It should also include all external factors such as a change in company direction or a change of technology direction. Most of all, however, it should include the things that are new in the project. If the project is working with a new technology, is using a new development methodology, or even if there are new, relatively unknown team members, these need to be listed as potential risks to the project.

http://techrepublic.com.com/article/four-steps-for-reducing-project-risk

No Wake Before 10:00 AM

Every Parent’s Dream…

I saw a sign that every parent has dreamed of…

No Wake Before 10:00 AM
KONICA MINOLTA DIGITAL CAMERA

Maybe they weren’t talking about that kind of wake.

Submission — Anti-Virus Software

I broke down today and bought Anti-Virus software for the primary computer that I use.  I’ve had anti-virus software on customer computers, my son’s computer, and my wife’s computer.  The reason I didn’t have it on the computer that I work on is because I think it’s an unnecessary evil.  If you’re suspicious and careful you should be able to avoid infection by a virus.  OK, so I hedged my bets and occaisionally ran Trend Micro’s House Call solution. Still, I didn’t feel like it was necessary software — and supporting an industry which has caused so many hours of problems with software that blocks things in unexpected ways has never been high on my list.

However, I realize that in today’s environment, the only way for corporations to protect themselves is to ensure that the laptops connecting to their network have current anti-virus software and that the definitions are up to date.  The goal being, of course, to provide some measure of assurance that the computer isn’t infected.

So, I’ve joined the masses in using Anti-Virus software.  Even if I don’t like the whole concept.

-rlb

Of Chickens and Eggs

While working with a client yesterday we were discussing the idea of having email (or parts of your email) as a window in SharePoint.  They were discussing how the limited space made things difficult while simultaneously discussing how it was important to have a one stop experience for the portal.  Then the comment came up that one member of the group always started their day with email.

A light bulb went off.  You can set an HTML (web) page as the default view for a folder in outlook.  Simply right click the folder, select properties, select the Home Page tab, enter your URL, Click the ‘Show home page by default for this folder’ checkbox and click OK.  Now whenever you click on the folder the web page appears.

Now they can decide whether they want Outlook housing SharePoint or SharePoint housing email via Outlook Web Access.  While on that note.  Send me an email if you’ld like to beta some utilities that are like the ‘My Inbox’, ‘My Calendar’, and ‘My Tasks’ web parts in SPS.  I have written a set which don’t require the user name to be set in properties so they can be deployed on a shared view.  I’d like to get some testing done on them.

Recent Posts

Public Speaking