I'm working on a project to syndicate library content with RSS.... and learn .NET, C#, and AJAX

Friday, June 29, 2007

Successful RSS output creation

I may have gone about it in a backwards way, but I did actually produce valid RSS output today!!! I used a static List_ID, but got the Items from the rdb Items table. Below is my SQL query and also a screenshot. Also I discovered the ASP.NET 'Literal' which is what I used to tell my code-behind where to stick the RSS it generated. Bill used the ASP Repeater and a DataSet to fill it, and that might be smarter.

First, the SQL query:

SELECT Items.title, Items.default_abstract FROM [rdb-production].[dbo].Items INNER JOIN
([jewel-dev].[dbo].JMU_List_Items INNER JOIN [jewel-dev].[dbo].[JMU_Lists] ON [jewel-dev].[dbo].[JMU_List_Items].JMU_Lists_ID = [jewel-dev].[dbo].[JMU_Lists].List_ID)
ON [jewel-dev].[dbo].JMU_List_Items.Item_ID = [rdb-production].[dbo].Items.Item_ID
WHERE ([jewel-dev].[dbo].[JMU_Lists].List_ID = 38)

And the screenshot:


RSS Output and User Controls

Today I am reading up on "User Controls," an ASP.NET technique which is basically like include files. I'm also reading various articles on generating RSS output with C#. I'm surprised at the variety of strategies employed, and also at the relative (seeming) quietude. That is, I didn't get as many fabulous results with my Google searches as usual; no one seems to really be the expert, yet. There's an RSS Toolkit for ASP.NET - yet it has less than 1,000 downloads. Hmm...

Links:

Thursday, June 28, 2007

ListMaker 1.0

Today was good; user can now select items from her result list, move them to temporary part of screen, then save to database. Also, user can view lists that they've previously made. I need to ask Bill about whether I really need to make relationships in my database or whether I can just always use INNER JOINs.

Here's another crazy ListMaker snapshot. Functional problems with the below (after moving into AJAX accordion) include the thing that looks like a bulleted list (it is a reorder list) which is not letting me add items (so I'm using the plain ListBox); the search box in the maroon no longer functions to search, because it is being used to accordion. But, I am hungry. More later. Oh, and b4 u say anything about the colors, they are just so I can see what is what :)

Crazy ListMaker

I have a sort of secret self-Schadenfreude when I am creating something ... so I'm going to take screenshots of my lovely ListMaker especially when it looks most messed up. I mean, if someone asked me to create the below, I have no idea how I'd do it ... except that I've done it! All that was amiss was a fixed width for my AJAX accordion.

Wednesday, June 27, 2007

ListMaker 1.0

ListMaker now has an AJAX collabsible panel that displays results. Oh, and it allows the user to search for Items in the R2 database, displays the results (in aforementioned collapsible panel) with checkboxes for each item. Then user can select the items and click a button to save them, and for now they are saved in another part of the screen.

Next step will be saving the list into the database, then view, edit, or delete lists they created...

For now I am using a static variable to hold my user name and ID.

Hooking up the AJAX Collapsible Panel took me the most time -- because I was assuming it had to be much harder than it looked!

Tuesday, June 26, 2007

Hiatus - ALA Annual 2007

Started a blog for Professional Development, with ALA Annual being the first set of entries: http://jcf-pd.blogspot.com/ (I did very little at ALA related to my summer leave project).

Friday, June 22, 2007

The Birth of ListMaker

Yesterday sucked as I tried to separate out my JMU User Create List from the rest of R2. I made the new database successfully, and installed the AJAX Control Toolkit successfully, then things went to suck. First I made a new app ('LibraryListMaker") and tried to port in parts of R2. Apparently the "Web Applications" template doesn't have an App_Code folder, which is kind of important for beign able to keep random code files handy. So I restarted wtih a "Website" template (it did have an App_Code folder) and tried to port in files again. It couldn't ever find the code I put in the App_Code, though, I suspect because I didn't create the item within the App_Code folder correctly - that is, I just pasted stuff in place and generally munged it. I also suspect trouble with namespaces.

Anyway, this morning I started from scratch and set up a "Website" with a .cs in the App_Code that did some simple string manipulation and I managed to pass it a string and get a diff. string back. Emboldened by this, I went ahead and ported just the dbconnection parts of Bill's common.cs and commonbase and default, and managed to retrieve some data from Jewel into a label area. (Note: Jewel is my name for my database; JMU User Lists = JUL = Jewel). So far, I think the app name will be ListMaker. It was LibraryListMaker, but that's the one that never hooked up, and also that's a long name.

Bill was right that I should start with an empty document. (of course). Thanks, Bill.

Off to ALA now.

Wednesday, June 20, 2007

Hiatus

Sat. and Sun. were spent with Margie - awesome - and Monday was Moving Meris and doing some JWL housekeeping and e-mail catching upping. Tuesday was SPT lunch (at which Kevin urged me to take a closer look at Zotero). I did do one more database-connection thingummy in the a.m. with my new JMU User Create Lists so there was a small accomplishment. I made my own label and populated it from my new db tables.

Also on Tuesday, had a great conversation with Bill: I'm gonna rip my JMU User Create Lists out of R2 and even make its own database, rather than tables within the R2 db, so it is easily portable, just in case it works. Also Bill showed me the GetDS method and other basic functions he calls in. Thank you, Bill.

Today (Wed.) I spent getting ready for the ALA Annual Conference, including poster session-related stuff. And working on the new Digital Services person paperwork. So, no programming, alas! Tomorrow I hope to be able to do a bit, but then Fri-Monday I will be in absentia. Grr...

Friday, June 15, 2007

Create JMU User List

Today I created a new user control, "Create JMU_User List," aka Create_List_Fac within Bill's R2 Admin, following the pattern he used for the other user controls. I also added several database tables to rdb-prodcution that I will need for storing info about faculty lists. (Note: the "fac" suffix in the classname is unfortunate - I needed to differentiate them from librarian-created lists but hadn't thought through it yet. I did prefix the db table names JMU_User, which is a better nomenclature and maybe I'll go back and rename Create_List_Fac in the code).

Anyway, my goal for today was to successfully create the user control and make one successful connection to my new database tables. I modified the drop-down that gets librarian-created lists to instead get JMU User-created lists, and this works.

Next step will be to allow "JMU Users" to add items to their lists just like Create List. I'm hoping this is easy since Bill's code already does lots of this. Something I did that might make it not quite-so-easy is I removed the link between JMU Users and subjects, because they won't have subject-rights. They will be linked to subjects, but not in any way that relates to rights. For "JMU Users", Subjects will just help them narrow down searches to their interests, or display News or New Titles related to their interests.

In this sense, the "Subjects" are pretty lame - tags would serve better - if there was sufficient use and users. Maybe I will go ahead and put the tags in place, and populate the tag db with subjects for each existing item.... But that's for much later!

Sat, Sun, and Mon, I will be mostly "off" as Margie is coming to visit, I'm working with Chris on my PC, and helping Meris move.

Thursday, June 14, 2007

Hiatus

Took a few days away from .NET to go to Florida, review the galleys from JWL 1.2, and catch up on email. And (this morning) watch the STL Cardinals game I missed while in Florida (7-3 Cards! Go Wainwright!). I haven't solved my silly URL problem (below) but I need to move on toward my original goal of selecting R2 stuff for RSS lists. One of my problems with summer leave (maybe the only one) is that I keep thinking of more projects I could do, or want to do!! I'm reading a book about how to do just about anything with RSS/Atom, and now I want to go mashup crazy.

Sunday, June 10, 2007

Fun with HttpWebRequest

So I got HttpWebRequest working with everyday URLs, spitting web content into my app. But it choked on LEO XML server URLs such as:

http://leo.jmu.edu/xmlopac/?xml=<WXREQ_ROOT><KEY>i0143036610</KEY></WXREQ_ROOT>

I suspected the angle brackets but only within my code -- I didn't realize it was actually sending
http://leo.jmu.edu/xmlopac/?xml=%3CWXREQ_ROOT%3E%3CKEY%3Ei0143036610%3C/KEY%3E%3C/WXREQ_ROOT%3E
until I downloaded Fiddler debugging proxy and saw it for myself. So while the former URL went to the /dtd dir, the latter went to the /xmlopac dir.

Oh, and also, I noticed that LEO wants to set cookies, so I'd better enable that in my HttpWebRequest.

Friday, June 8, 2007

Things I learned today: C#, ASP.NET

I went back over some of the abstract concepts of C# that were not clear to me...

  • Local and Instance variables (turned out just to be what I call 'scoping')
  • overloading Methods (awesome)
  • passing parameters by value, by reference, and with 'out'

Also, I went through some of Programming ASP.NET's "advanced controls" and other exercises:

  • MultiView and Views
  • the Calendar object
  • Session State

Finally, I made my first AJAX application -- the simplest one on the AJAX ASP.NET site. Nice video, Scott Gu.

Why .NET is cool

One of my programming books suggeted that I check out the .NET Framework Class Library (FCL) and to reuse the classes and methods therein as much as possible. So I did. (The checking out part, at least) So anyway, suppose you wanted to something with a standard Windows File dialog box ... there's a whole class for this (duh.) That's tech speak for "you just say you want to use a File Dialog Box!!" You can basically make that metaphor your own! Suppose you want a file dialog that lists just .mp3 and .wma files. You just use the Filter property of SaveFileDialog! Or, as MSDN puts it, "Gets or sets the current filename filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box at the bottom of a file dialog."

Why is this cool? I once wrote a perl program for users to upload video files. I only wanted them to be able to use certain file types, since I had a specific media player I was using. I had to write all this validation to make sure the extensions were all "okay." And I had this stupid text note that told the user "file extension must be x, y, z, p, d, q." It would have been far cooler if the file dialog had just the acceptible types in it.

Not to mention the perl calendar (which I copied from someone else's code) for which I had to write all my own 'event handlers' so to speak. ASP.NET has a whole Calendar class with built in methods to do common calendar stuff.

For future reference, here's the list of magical .NET powers:
http://msdn2.microsoft.com/en-us/library/ms229335.aspx

Monday, June 4, 2007

Programming ASP.NET; C#

Finished Ch. 4, "Basic Controls" today, including Panels. I confess to skipping the typing for the Table control exercise ... perhaps this will be a major ingredient in a humble pie I will make later. I did read it. Ditto for the Image, but that is because I didn't want to go get an image. Lazy.

In the world of C#, I completed some exercises to illustrate classes, methods, and properties. These abstractions were previously boggling my mind. Next in this course will be figuring out what to call statements like this:
ScrollBars scrollBar = (ScrollBars)Enum.Parse(typeof(ScrollBars), strValue); pnlScroll.ScrollBars = scrollBar;

At this point, all I know is that "scrollBar" looks pretty silly after typing it a bajillion times. And that the above statement relates to ScrollBars and scrollBars. But not Scrollbars.

Now onto Final Fantasy...

Searching PL and LEO - success!

So, while the goal of my project is really just to make an RSS-constructor using the R2 database, it's been on my mind that LEO Library Catalog and Periodical Locator are crying out to be included. Yesterday afternoon I wrote my first successful PL and LEO search !!! User types in a search term and app goes and gets results and displays on my app's page, with checkboxes that user can select to "save" results. (at the moment, results are 'saved' to another area of the screen). The LEO one needs to be improved by using the MARC fields instead of what I'm using now (HTML!) PL thougthfully has comment tags that look pretty reliable. I'm not under any illusion that a screenscraper like I've written is a long term solution, but it might be good enough for a prototype. AND... it leads to possibilities such as:

  • App to look up multiple ISBNs in LEO or other systems simultaneously; first by ISBN, then by title keyword(?)

Also, yesterday I was so happy to use the Regex() to write my first regular expression within C# -- I almost felt at home there for a minute.

Saturday, June 2, 2007

Programming ASP.NET

I'm still on my little side trip from R2 into Programming ASP.NET, which is a great walkthrough of all the controls... I'm making one massive page with all my controls on it: AWESOME. Today, besides the book exercises, I learned...

  • use the StringBuilder instead of just concatenating, in order to save memory.
  • if you want onchange for radio or checkbox lists to change something (without AJAX) you must set AutoPostBack to true.
  • There's no "NotSet" value for BulletedListDisplayMode even though the book example says there is - you just use Text. See MSDN

Friday, June 1, 2007

Programming ASP.NET ... today I learned

OK I decided to go ahead and go through Programming ASP.NET's code examples. So far, today I've learned these things not in the book:


  • in C#, you need each case block that has a directive to end with something like break or goto (Book example must've been VB) or it won't compile

  • if you are using master pages, then your controls are given custom id numbers like this: ctl00$btnMyButton. (see http://www.codeproject.com/aspnet/InsideMasterPages.asp) for more. Meaning if you are trying to access them with getElementById you had better name them right.

  • Assigning a new txtHTML.Value does not seem to fire the JS onchange event

Also, I found a keen font for VS, called Consolas: http://www.microsoft.com/downloads/thankyou.aspx?familyId=22e69ae4-7e40-4807-8a86-b3d36fab68d3&displayLang=en