How Long Is Shortly?

We’ve all heard those “Greatest Lies Ever Told.” (Apologies to Fulton Oursler!) You know, the ones like “The check’s in the mail” and “I’m from the government and I’m here to help.” Then there’s the lesser known ones like “But honey, I’m only going to buy a couple things” and “The tow truck will be there in 15 and 50 minutes.”

I propose that a new one be added to the list: “A representative will be with you shortly.” We’ve all been on hold at some point in our lives and heard the recording of the nice, usually female, voice that breaks in to the on-hold music and says: “Your call is important to us. Please hold and a representative will be with your shortly.” Although the exact wording may vary slightly, they all pretty much follow the same script. I call foul on them all!

Almost 15 years ago we moved into our new house. We had the house wired for security and shortly after moving in, we had ADT come and install a system for us. After a few years, we were sick of the high price and the lousy service and switched to Checkpoint Services. A few years after that, they were purchased by Brinks Security, who, after a few years, spun that division off into a wholly-owned subsidiary call Broadview Security. Well, when that happened we knew what was coming next and it happened, Broadview Security was sold to ADT.

Now, we’re back where we started again. Shortly after taking over, ADT couldn’t resist and increased the rates. With nowhere to go, we had no choice to put up with it. Recently, we accepted an offer on our house and the one thing I was the happiest about was getting rid of ADT. I called and arranged to have our service canceled. However, a few weeks later, the deal fell through.

So, here we were, having to call them back up and cancel our “cancellation.” You would expect that this would be a simple process, if I could get a hold of someone to talk to. Over the course of a day, I spent almost two hours on the phone, waiting for a chance to speak to “an associate.” This was over the course of three attempts. The first attempt I gave up after 45 minutes and the other two attempts I gave up after 30 minutes. On each of the calls, they played the same song (only one) and it was only interrupted by that friendly female voice every 90 seconds reminding me that “an associate will be with your shortly.”

After a day of frustrations, I finally took to the ADT web site and filled out the contact form. I selected “Moving” from the list of departments to contact and told them briefly (I was limited to 250 characters) of what I wanted. About 10 minutes after we activated the alarm that evening to go out to run some errands, ADT calls back. (My daughter believes they waited for this to happen before they called!) Was it a call to handle my cancellation issue? Nope, they were calling me to try to sell me a system.

So, not only does there not appear to be anyone working in the ADT “Moving Department,” they also don’t appear to have anyone that can read the contact request properly. I guess I shouldn’t expect anything more considering the state of our <sarcasm> wonderful </sarcasm> government educational systems.

Time to make a phone call again….and wait on hold. If I go crazy, you’ll know it’s because they’re still playing that same song…over…and over…and over…and over…

Creating an RSS Reader Using ASP.NET and LINQ – Part 2

Back in Part 1, we put together the first part of our application. We defined a list of RSS feeds and pulled in the list into a drop-down list box. In this post, we’ll get our selection from the user and build a list of atricles from the RSS feed data.

Entry Data Storage

The first step is to decide what data we want to display. In our example, we’ll display the following fields:

  • Title
  • Published Date
  • Tags

Along with these fields, we’ll need to know the entry’s URL so that we can allow the user to display the blog entry. As with the feed definitions, we’ll store this information in a basic class:

public class BlogEntryDefinition
{
   public string Title { get; set; }
   public string Url { get; set; }
   public IEnumerable Tags { get; set; }
   public DateTime Published { get; set; }
}

Getting The User’s Selection

Before we can process the feed data, we need to know what feed the user wants to display. In our display, we placed an Open button next to our combo box. When the user presses this button, this will let our program know when to process the selection.

We must fist update our display code for the button, specifying an event handler method that will be called when the user clicks on the button. We do this by specifying a method name for the OnClick parameter:

<asp:Button ID="OpenButton"
            Text="Open"
            OnClick="OpenButton_OnClick"
            runat="server" />

Back in our code-behind, we need to define the method:

protected void OpenButton_OnClick(object sender, EventArgs e)
{
}

When the user clicks on the button, this method will be called. The sender parameter will be the object that initiated the OnClick event, in this case our button, and the e parameter will contain the arguments for the event. In our example, we won’t use these parameters.

Loading The Blog Entry Definitions

To load up the list of blog entries, we process the data in the same way that we did when we loaded up our feed definitions. The only difference is that rather than getting the data from a file on our web server, we are loading the data from a URL. We get the URL from our drop-down list box control through the SelectedValue property:

XDocument rssFeed = XDocument.Load(FeedList.SelectedValue);
var posts = from item in rssFeed.Descendants("item")
select new BlogEntryDefinition()
{
   Title = (string)item.Element("title"),
   Url = (string)item.Element("link"),
   Published = DateTime.Parse((string)item.Element("pubDate")),
   Tags = from category in item.Elements("category")
          orderby (string)category
          select (string)category
};

Building The Display

There are multiple ways in which you could display the data. In our example, we’ll use a grid view control. We’ll manually define the columns of the control so that we can specify custom cell values:

<asp:GridView ID="FeedDetailsGrid"
              runat="server"
              AutoGenerateColumns="false"
              Font-Name="Verdana"
              Font-Size="10pt"
              Cellpadding="4"
              HeaderStyle-BackColor="#444444"
              HeaderStyle-ForeColor="White"
              AlternatingRowStyle-BackColor="#dddddd">
              <Columns>
                <asp:TemplateField>
                  <HeaderTemplate>Published</HeaderTemplate>
                  <ItemTemplate>
                    <%#Eval("Published", "{0:G}") %>
                  </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                  <HeaderTemplate>Article</HeaderTemplate>
                  <ItemTemplate>
                    <a href='<%#Eval("Url") %>' target="_blank"><%#Eval("Title") %></a>
                  </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                  <HeaderTemplate>Tags</HeaderTemplate>
                  <ItemTemplate>
                    <asp:Repeater ID="TagRepeater"
                                  DataSource='<%#Eval("Tags") %>'
                                  runat="server">
                      <ItemTemplate>
                        <%#Container.DataItem %>
                      </ItemTemplate>
                      <SeparatorTemplate>,</SeparatorTemplate>
                    </asp:Repeater>
                  </ItemTemplate>
                </asp:TemplateField>
              </Columns>
</asp:GridView>

Putting It Together

First we handled the processing when the user clicked on the Open button. Then we built a display to contain all the data. Now, we need tell our grid view control what data it will be displaying. This process is the same as it was with the drop-down list box control:

FeedDetailsGrid.DataSource = feeds;
FeedDetailsGrid.DataBind();

Now, when we click on the Open button, we get a nicely formatted grid with the list of blog entries from the selected feed:

Conclusion

As you’ve seen through these two posts, with just a little bit of code and a few screen controls, you can create a simple RSS reader. ASP.NET gives you a simple framework to leverage the .NET Framework to create a feature-rich website.

Creating an RSS Reader Using ASP.NET and LINQ – Part 1

With every release of the .NET Framework, more power has been placed in the developer’s hands.  We can now concentrate on the overall process of our applications rather than developing the low-level functionality.  In this post, I’ll start creating a simple RSS reader using ASP.NET and LINQ.

Feed Definitions

The first step is to decide how to define the RSS feed information and how our program will use it.  The basic information we’re going to need will be:

  • The name of the feed.
  • The URL of the feed.

For ease of maintenance, and to allow updating the list without having to edit our source code, we’ll store the feed definitions in an external file.  There are many options for this and we’ll use the easiest option: XML.  Our file will have a basic format, only storing the basic information that we need:

<!--?xml version="1.0" encoding="utf-8" ?-->
<Feeds>
  <Feed>
    <Name>Stuck In Customs</Name>
    <Url>http://www.stuckincustoms.com/feed/</Url>
  </Feed>
  <Feed>
    <Name>2000 Things You Should Know About C#</Name>
    <Url>http://csharp.2000things.com/feed/</Url>
  </Feed>
  <Feed>
    <Name>There, I Fixed It!</Name>
    <Url>http://feeds.feedburner.com/ThereIFixedIt</Url>
  </Feed>
</Feeds>

We’ll store this information in a basic class:

public class FeedDefinition
{
   public string Name { get; set; }
   public string Url { get; set; }
}

 

Loading the Feed Definitions

Now that we have our feed definitions stored in an external file and a class defined to store the information, we need to load that data into our application. Before we had the .NET Framework, we would have to read in the file and create our own XML parser in order to load the data. This process has become easier with each version of the .NET Framework.

By utilizing LINQ, the process of obtaining the data from an XML file has become quite easy:

XDocument feedDefinitions = XDocument.Load(Server.MapPath("Feeds.xml"));
var feeds = from feed in feedDefinitions.Descendants("Feed")
select new FeedDefinition()
{
  Name = (string)feed.Element("Name"),
  Url = (string)feed.Element("Url"),
};

Using just one line of code (line 1), the entire feed definition file is loaded and parsed for you. The contents are stored in an XDocument object.  Processing this object using LINQ (lines 3-8), we obtain a collection of FeedDefinition objects (IEnumerable<FeedDefinition>) that we will use in our web page.

Building The Display

Now that we have our data, we need to be able to display it to the user. We will use a drop-down list control that will allow the user to select a feed for reading. In our ASP.NET content page, we’ll define the our display as this:

<div class="feedList">
Feed:
<asp:DropDownList ID="FeedList"
                  DataValueField="Url"
                  DataTextField="Name"
                  runat="server" />
<asp:Button ID="OpenButton"
            Text="Open"
            runat="server" />
</div>

The drop-down list box will be bound to our feed data that we read in earlier. However, we have two fields in our data. Using the DropDownList control, we can display the Name property to the user and use the Url property for processing later on.

Putting It Together

Now that we have our feed definitions and our display, we just need to put them both together:

FeedList.DataSource = feeds;

FeedList.DataBind();

This code binds our feed definition collection to the drop-down list control. All we need to do now is put our code into our content page’s Page_Init method so that it’ll populate our control the first time our page is loaded.

protected void Page_Init()
{
XDocument feedDefinitions = XDocument.Load(Server.MapPath("Feeds.xml"));
var feeds = from feed in feedDefinitions.Descendants("Feed")
select new FeedDefinition()
{
   Name = (string)feed.Element("Name"),
   Url = (string)feed.Element("Url"),
};
FeedList.DataSource = feeds;
FeedList.DataBind();
}

It’s important that you load the feed definitions in Page_Init() rather than in Page_Load().  Putting them in Page_Init() will prevent the drop-down list control from getting reinitialized during postback when we implement our Open button in Part 2.

When we load our website, we get our list of feeds neatly displayed in our control:

Conclusion

In this post, we wrote the first half of our simple RSS reader web application. By using the .NET Framework and the LINQ feature, we were able to load a list of RSS feeds into our web page without writing a lot of code.

In part 2, we’ll show how to get a list of posts from the feed and display them along with other data related to the posts.

Boom Boom, Out Go The Lights

Shortly before 6am, those of us who live in Southwest Florida were treated, once again, to the signature “Boom Boom” from the space shuttle after another successful mission into space.  This is one of the many benefits that we get in this part of the country.

I remember the first time I heard the double sonic booms.  It rattled my whole house and my reaction was “WHAT WAS THAT!!!!”  I thought someone had set off an explosion and used a little bit too much nitro.  Then, I came to my senses and realized that the space shuttle was returning and that the sound I heard was the double sonic booms that I had heard so much about.

This morning, although it was a sweet sound to hear, it was also bitter.  This was the last time that I will ever hear that sound.  Today was the last time that a space shuttle will ever land because the entire program has been shut down.  For thirty years, the space shuttle has been the workhorse of our space program.  For most people in this country, the space shuttle is all that they know.

Sadly, there is no program that is ready to take its place.  For the foreseeable future, the United States will have to rely on other countries to get humans into space.  Much of the technology that exists in our society, from food preservation to computers, traces its roots back to NASA and the space program.  Many industries were formed as a result of the space program in the past forty years since the first Mercury flight in 1959.

Another sad result of the cancellation of the shuttle program is the hundreds of people connected with the program at NASA that are being laid off.  When you combine this with even more that will suffer the same fate at companies that are connected with the program, many thousands will loose their jobs during one of the worst economic times in our country.  This will have a drastic effect on our technology programs and our economics.

The NASA budget is just a small fraction of the budget of this country.  Yet, the economic benefit that has resulted from it more than pays for the program.  The “Return on Investment” from the NASA budget far exceeds that from any other budget item, including education, welfare and other pork projects that our “elected” leaders come up with.

My hope is that someday we will return to space.  The benefits of the space program far out-weigh the risks.

SUPER BOWL: Aaron Rodgers, other Packers, looking to ‘follow Jesus’ example’

 Originally Posted February 2, 2011 in the Baptist Press


Posted on Feb 2, 2011 | by Art Stricklin

ARLINGTON, Texas (BP)–NFL experts and newspaper headline writers have been quick to label Green Bay starting quarterback Aaron Rodgers the "Leader of the Pack."

Something about 4,712 yards passing and 34 touchdowns, and leading the Packers to the verge of their first Super Bowl title in more than a decade will do that for you.

But Rodgers made it clear in Tuesday’s jam-packed Super Bowl XLV Media Day he only wants to be a leader of God’s pack when it comes to influencing others to see his faith in Jesus Christ.

"We all have a platform, we all have a message in our lives," Rodgers told Baptist Press and a worldwide media turnout, which ringed his individual interview area. "I just try to follow Jesus’ example, leading by example."

During his six years with the Packers, his career has seen enough twists and turns, dead ends and detours to test anyone’s faith. An expected top 10 draft choice, he lasted until the end of the first round for reasons he never understood. He stood on the sidelines for three seasons while Packers quarterback Brett Favre went through his yearly will-he-or-won’t-he retirement routine as Packers QB.

Finally given a chance to start three years ago, he has matured into one of the top quarterbacks in the league, but not forgetting his past, present and future in Christ.

"God always has a plan for us, a path. Sometimes we wish we knew it sooner," Rodgers said with a bit of a laugh, "but He always shows up His way."

He credits his parents, Ed and Darla Rodgers, who still live in Northern California where he was raised, for showing him a loving and Christ-centered household. He also remains close to his two longtime accountability partners, Pastors Andrew Burchett of the Neighborhood Church in Chico, Calif., and Young Life Christian youth group leader Matt Hock.

Even in the midst of the craziness of Super Bowl week and Tuesday’s Media Day at Cowboys Stadium, Rodgers had already checked in with his accountability team.

"They won’t be here Sunday, but they’ve been calling and texting me," he said. "Matt sent me a photo of his entire Young Life group decked out in Packers gear."

Rodgers’ quiet and humble testimony has been enough to inspire Christian NFL fans everywhere and his own teammates as well.

Rookie defensive end C.J. Wilson, whose father is a Pentecostal minister in Mt. Olive, N.C., said he really didn’t know what to expect when he showed up for his first NFL season this year. But when he saw the experience of his star quarterback and his witness, Wilson felt encouraged with his own professional football faith.

"I think it does help when your superstar quarterback is walking with God. I’ve been blessed to be around him and see how God makes all things possible in our lives," Wilson said.

Packers wide receiver Greg Jennings is one of Rodgers’ receivers and teammates on the field, but more importantly, a spiritual brother on and off the field. He said he’s determined to let Sunday’s game against the Pittsburgh Steelers be his platform for God.

"I just want to let people know what it’s all about. One of the Scriptures I refer to a lot is, ‘to whom much is given, much is required,’ and I’m required to have a voice [for God] because I have a stage and a platform," Jennings said.

"Number one, all glory goes to God. That’s where it starts and that’s where it finishes."

His father, Greg, Sr., is the pastor of Progressive Deliverance Ministries in Kalamazoo, Mich.

Packers defensive tackle Ryan Pickett has been inspired to join an anti-pornography campaign in the NFL this year to help rid the destructive influence among his friends and teammates. He said he had to turn down the invitations of his teammates this week and other times who wanted him to go places he knew was not right.

"I value my family and my wife. I try to stay away from that," Pickett said.

Green Bay kicker Mason Crosby doesn’t have to be reminded about the number of Super Bowl games which have come down to a final touchdown or field goal, including the last Super Bowl held in Texas when the New England Patriots won on a last-second kick in Houston.

But he said his faith in Christ won’t allow him to be defined by a single kick.

"I think He helps me knowing that kicking is what I do, not who I am. It’s not everything that I am. I can escape knowing that my relationship with Christ is what carries me."

Crosby has also noticed his quarterback’s faith and his example to his teammates and the sports world.

"Aaron has a great relationship with the Lord," Crosby said. "He’s the face of the franchise and it helps to see he’s living the message all of the time.

"I’m always reading in the Proverbs and Psalms to relax my mind before we play," Crosby added. "I know that God cares for me all the time regardless of any outcome here."

–30–

Art Stricklin is a Dallas-based sports correspondent. With reporting by Jerry Pierce, managing editor of the Southern Baptist TEXAN (www.texanonline.net), newsjournal of the Southern Baptists of Texas Convention.

 

Afraid!?!

 A guy cruises through a stop sign,and gets pulled over by a local policeman.  Guy hands the cop his driver’s license, insurance verification, plus his concealed carry permit.

"Okay, Mr. Smith," the cop says, "I see your CCW permit. Are you carrying today?"

"Yes, I am."

"Well then, better tell me what you got."

Smith says, "Well, I got a .357 revolver in my inside coat pocket. There’s a 9mm semi-auto in the glove box. And, I’ve got a .22 magnum derringer in my right boot."

"Okay," the cop says. "Anything else?"

"Yeah, back in the trunk, there’s an AR15 and a shotgun. That’s about it."

"Mr. Smith, are you on your way to or from a gun range…?"

"Nope."

"Well then, what are you afraid of…?"

"Not a thing…"

Which Side Of The Fence Are You On?

If you ever wondered what side of the fence you sit on, this is a great test.

  • If a conservative doesn’t like guns, he doesn’t buy one.  If a liberal doesn’t like guns, he wants all guns outlawed.
  • If a conservative is a vegetarian, he doesn`t eat meat.  If a liberal is a vegetarian, he wants all meat products banned for everyone.
  • If a conservative is homosexual, he quietly leads his life.  If a liberal is homosexual, he demands legislated respect.
  • If a conservative is down-and-out, he thinks about how to better his situation.  A liberal wonders who is going to take care of him.
  • If a conservative doesn’t like a talk show host, he switches channels.  Liberals demand that those they don’t like be shut down.
  • If a conservative is a non-believer, he doesn’t go to church.  A liberal non-believer wants any mention of God and religion silenced. (Unless it’s a foreign religion, of course!)
  • If a conservative decides he needs health care, he goes about shopping for it, or may choose a job that provides it.  A liberal demands that the rest of us pay for his.
  • If a conservative reads this, he’ll forward it so his friends can have a good laugh.  A liberal will delete it because he’s “offended”.

Project 365 – 2010: Day 26

 

When you live out in the country, you have to deal with the wildlife.  On a regular basis we are visited by a black bear that takes a liking to our trash.  Who knew that trash could result in a photograph?!

Photo details: Exposure time 1/10 sec, Aperture f/4.5, Focal Length 34mm, ISO-200, Lens Nikon AF-S Nikkor 18-55mm 1:3.5-5.6 G II ED, Camera Nikon D40X. 

 

Project 365 – 2010: Day 19

This is the most intense drummer that I have seen.  This shot came out interesting with the effects lighting reflecting off of the shield in front of the drum kit.

Photo details: Exposure time 1/40 sec, Aperture f/5.6, Focal Length 200mm, Lens Nikon AF-S Nikkor 55-200mm 1.4-5.6 G ED, Camera Nikon D40X.

Project 365 – 2010: Day 18

This was the first SLR camera that I owned and the camera started it all.  It was originally owned by my mother and her photography work with it got me started.

Photo details: Exposure time 1/60 sec, Aperture f/4.8, Focal Length 38mm, ISO-200, Lens Nikon AF-S Nikkor 18-55mm 1:3.5-5.6 G II ED, Camera Nikon D40X.