Codeine .Net RSS 2.0
# Wednesday, 26 December 2007

    While having lunch today at Old Chicago with Nick we began discussing Windows Workflow a bit and I started to realize that even though I have been pounding away on a project for six months that is highly dependent on WF I have yet to write a single blog post on the topic. I found the need today to work on an activity that simply applies a regular expression against a string and returns the value that it finds. Since this is a fairly basic activity I thought I would go ahead and blog about the process of creating it.

First off you need to create a new activity:

 

Visual Studio 2008 will create the skeleton of an activity for us that inherits from SequenceActivity. For my purposes I need to have it inherit from Activity so I will go ahead and change this. The next thing we need to do is to define a dependency property for our input string. To do this we do the following

#region "Dependency Properties"

 

public static DependencyProperty InputStringProperty = DependencyProperty.Register("InputString", typeof(String), typeof(RegEx));

 

#endregion

What we are doing here is registering a dependency property called InputStringProperty that is bound to the property InputString (which we will be creating in a second), the property of InputString is of type string and the owner of InputString (our activity) is of type RegEx. Now we need to define our property InputString.

 

     #region "Properties"

 

public string InputString

{

get { return ((String)(base.GetValue(RegEx.InputStringProperty))); }

set { base.SetValue(RegEx.InputStringProperty, value); }

}

 

#endregion

The layout of this property is fairly similar to what you should be useto, but instead of getting and setting from a private member variable you instead set and get from the dependency property. Piece of cake right? The next thing we are going to do is define our output parameter the same way. The only thing that we are going to do differently with this property is to put an attribute on it of readonly. This will prevent the user from binding this property to something since the user should only be binding the properties on other activities to this property.

 

public static DependencyProperty OutputStringProperty = DependencyProperty.Register("OutputString", typeof(String), typeof(RegEx));

 

     [ReadOnly(true)]

public string OutputString

{

get { return ((String)(base.GetValue(RegEx.OutputStringProperty))); }

set { base.SetValue(RegEx.OutputStringProperty, value); }

}

 

 

Though we are not complete yet, if you build this activity and drop it onto a test workflow you will see the following in your Visual Studio Properties Window. We have a property call input string that is bindable and a property called OutputString that is readonly.

 

 

The next things we need to do is to declare a property that will hold our regular expression for the user of our activity to input. The will not be a dependency property, but a standard property as it will not need the ability for binding.

     private string _regexpression;

     public string RegExpression

     {

get { return _regexpression; }

set { _regexpression = value;}

     }

 

If you now drop this activity onto a test workflow you will see the following on the properties window.

 

 

We're almost done and all that is left to do is to implement the Execute method of our activity which will actually evaluate our regular expression against the input string. First off make sure you put using System.Text.RegularExpressions at the top of the class as we will obviously be using the .Net RegEx features. Then we just have the following function left.

 

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

{

Regex myRegEx = new Regex(RegExpression, RegexOptions.IgnoreCase);

OutputString = myRegEx.Match(InputString).Value;

return ActivityExecutionStatus.Closed;

}

 

The Exceute function is the meat of the activity where our processing actually happens. We first create a new RegEx object using our RegExpression property and in this case we are passing the option to ignore case. We then evaluate the regular expression and place the value into our OutputString property. Finally we return with a closed status and that's it. Just to test it out I put together a basic workflow that consists of my activity with the InputString property set to "my email address is testperson@test.com and of course it isn't a real email" and the RegExpression property set to "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" which should pull out the email address. I then used a basic code activity to output the email address to the console.

 

 

There you have it, a workflow activity that evaluates a regular expression against a string. If an email address had not been found then a blank line would have been written out to the console, but in our case we got testpersion@test.com. Obviously in a more practical scenario you would not type the string directly into the InputString property, but instead you would bind that property to the string property on an activity earlier in the workflow, but you get the idea. That's it for now folks. If you enjoyed this posting or found it helpful and would like to see me post more on WF feel free to post a comment.

Wednesday, 26 December 2007 21:39:10 (Central Standard Time, UTC-06:00)  #    Comments [3] - Trackback - Save to del.icio.us - Digg This! - Follow me on Twitter
.Net 3.0 | Development | Windows Workflow
# Friday, 14 December 2007

For quite some time now I have been wanting internet access on my cell phone, but I didn't want to increase my monthly bill by another $30. When I originally got my new cell phone, the T-Mobile MDA, over a year ago I did quite a bit of research to make sure I got exactly what I wanted which included being about to provide internet access to my laptop via Bluetooth from my cell phone. The other day I noticed that T-Mobile dropped the price of the total internet add on service down to $20 and decided to go ahead and add this feature to my plan. I originally setup the internet connection sharing to my laptop using the usb cable which provided me with a connection speed of about 385kbps, but tonight when I went to get my laptop setup I remembered that the usb cable was sitting at home on my coffee table. After a few minutes of cursing myself and rechecking my bag I fired up the browser on the phone and Googled the steps needed to setup the internet connection sharing via Bluetooth and now I'm connected to the internet at a whopping 115.2kps. At least it is faster than dialup! I wanted to go ahead and post the steps need to get you going so here goes.

First off you need to setup a new dialup connection through your phone:

  1. Select Create a new connection from the network connections window.

 

  1. Select Connect to the Internet.

 

  1. Select Setup my connection manually.

 

  1. Select Connect using a dial-up modem.

  1. Check you Bluetooth modem. For me it is the Bluetooth Modem (COM8). I believe this is automatically showing up for me because I have connected to my phone before to discover services and run ActiveSync.

 

  1. Name your connection.

 

  1. Enter your ISP's phone number. For T-Mobile this is *99# .

     

     

     

  2. Leave Username and password blank and uncheck the box next to Make this the default Internet connection. Click next and then click finish.

     

     

 

    You are about set, but there are a couple more modem configuration changes you need to make. Go to Start -> Settings -> Control Panel and double click on Phone and Modem Options. Select the Bluetooth Modem and click properties.

 

 

Next, uncheck the Wait for dial tone before dialing box.

 

 

Finally go to the advance tab and enter AT+cgdcont=1,"IP","internet2.voicestream.com","",0,0 into the Extra initialization commands box.

 

 

 

All you have left to do is to pair up you phone and laptop through My Bluetooth Places and then go to your network connections and connect through this new connection. Hopefully if you've done everything correctly and I've explained everything correctly then you'll be surfing the web via Bluetooth on your cell phone. Since the usb connection is about three times faster I plan to use that in the future so I will post the instructions on how to set that up sometime as it is a bit different. I'm sure I'll still be using the Bluetooth connection often though as it is pretty easy to forget that darn usb cord.

Friday, 14 December 2007 22:53:31 (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to del.icio.us - Digg This! - Follow me on Twitter
Bluetooth | Mobile Computing | T-Mobile
# Wednesday, 28 November 2007

    Back in July I posted up a brief entry about Twitter which is basically a social networking site that allows you to submit short postings (140 characters) to your own personal page. (You can follow mine here.) The posting are meant to be short comments or updates throughout the day that you add via the website, IM, or cell phone text messages. The social networking comes into play when other members of Twitter begin following you postings and can subscribe to receive your updates over IM and text messages. You can also send direct messages to individuals using a special syntax.

    I've heard Twitter referred to as a human side bus, the ability to put your message on the wire and anyone who is subscribing to it can see it and everyone else doesn't even know it exists. The question is, is this ability useful? I've went over a couple scenarios in my head where I could see a benefit. One nice time when I could see it useful is, for example, if you want to go to a bar and you are interested in seeing who else wants to go. If you could get your friends to subscribe to your Twitter feed (which would most likely be a feat in itself) you could through it out on the wire and see if you get any responses. In this particular case you don't care who doesn't want to go, you only want to ping everyone at once and see if you get any interest. It's immediate and saves you the time of randomly calling people in a hit and miss fashion. I could also see it being beneficial if you are having a problem with something and want to throw it out to see if anyone can help. You don't care about who's not available and who doesn't know the answer; you just want a response back if someone can help you out.

    As with any technology it can also be abused and Twitter, in my humble opinion has been turned into the Turrets of the Internet. Individuals are using it to throw out every idea in their head and a play by play update on what they are doing each day. "I ate lunch"….. "I'm in a meeting"…."I'm going to the restroom". Random nonsense blurted out that is irrelevant to the listener. The postings turn into Turrets when they don't benefit any of the readers and in most cases don't benefit the writer as well. Who benefits from your posting that you were in a meeting or went to lunch?

Just my two cents. Get the human side bus a bus driver (or at least some category filters).

Wednesday, 28 November 2007 21:29:59 (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to del.icio.us - Digg This! - Follow me on Twitter


Navigation
Archive
<2007 December>
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
David A. Osborn
Sign In
Statistics
Total Posts: 69
This Year: 1
This Month: 0
This Week: 0
Comments: 33
Themes
Pick a theme:
All Content © 2017, David A. Osborn
DasBlog theme 'Business' created by Christoph De Baene (delarou)