My scenario was simple. Our company uses a financial vendor which has a web service for retrieving our Stock information and republishing it on our Sharepoint 2010 Intranet site. I successfully built a Timer Job that runs every 5 minutes during market open and close (deleting items older than a few days when market is closed) and it adds an item to a Sharepoint list attaching an XML file containing the results of the web service call. Working with past Stock applications in other languages I have found having the original, archived XML results is important to debug issues with the data provider.
The Timer Job works great and saves the files perfectly. Now I needed a Visual Web Part the user could add to their pages which would consume this XML file for the most recent entry, parse the information necessary then show the Stock Price in a pretty fashion per our marketing company's design. Honestly, I did not expect it to be difficult as I have done this a lot outside of .NET and Sharepoint. I setup the code to connect to my list, query the most recent item so I could grab its attachments. All good. With plenty of examples on the Google-nets, I quickly discovered how to get the URL of the attachment and could pass this to an XmlDocument object via Load() which lead to this code:
However, my code would not work and I continually received 404 errors trying to load the document via URL. I could take the same URL I was generating and put it in a browser window and successfully get to the list, but the code did not see it. I looked through logs, used Fiddler and even tried using HttpWebRequest and the LoadXml command as well with nothing shedding light on why this was erroring. I could not find any information from other people having this problem and even posted on MS' forums with no replies (although I was impatient and did not give it long).
My Timer Job was able to access urls outside the network, but this took some tricks by our Network and Server guys due to proxy issues. As such, I assume that maybe there was some permission/proxy issue hiding the list from my code, so I dug for other ways to try and load up this attachment. I found some references to people doing the same type of thing in Sharepoint 2003. Although I hate using old code since you never know what problems may exist using it in newer versions of Sharepoint and .NET, I was racing against my vacation and did not want to leave this hanging for weeks before I got back to it. So I replaced my code with the following which appears to be accessing the file in the list by its local folder structure and passing the binary stream to the XmlDocument Load command.
So far this is working and I have been able to use XPathNavigator to get the nodes I needed from the XML file. As is my MO, I posted this hoping to help anyone running into this issue and to get feedback from anyone that might have a better understanding of what is going on or a better way to accomplish this.
Wednesday, August 1, 2012
Monday, July 23, 2012
Sharepoint 2010 and List Picker Custom Web Part Property
One of the frustrations I have learning to code for Sharepoint is that the amount of information available is miserable. Either you get incomplete or unhelpful information in the way of sterile Microsoft Documentation, or any fool with a blog that has the potential to understand just as little as the reader about the subject matter. And YES I do - in fact - understand I fall into that category as well, but at least I try to be open about my ignorance and only try to post information which was helpful to me and my process of learning. So if you are learning to code from me, I sincerely apologize and hope you have some other resources at your disposal.
In any case, even when you find some one knowledgeable you also run into the fact that they may not specify whether they are talking about Sharepoint 2003, 2007 or 2010 (I ONLY deal with Sharepoint 2010 on my blog) or maybe leave off information they deem too complex or too simple. As was the case when I needed to have a custom webpart property that allowed a users to search for a List. I found DOZENS of ways to accomplish this that ranged from super simple (and useless) to absurdly complex. I tried many of these and most did not work properly or how I would expect. MS has several webparts that to do this (i.e. Content Query Web Part), so why is doing it yourself such a mystery?
As some background, for my project I needed a web part that would take a list, read in the rows and items and display this in a branding friendly manner for our publishing sites. As such, I wanted Content Owners to be able to add the web part and select a list they created somewhere in the site for it to use. I called this web part "QuickLinks" so keep that in mind as you read my code.
First off, you should understand a bit about adding custom properties to a web part. Here are a few links I found very helpful:
http://morshemesh.blogspot.com/2011/05/adding-custom-properties-to-visual-web.html
http://www.lamber.info/post/2010/05/21/How-do-I-create-custom-properties-in-Visual-Web-Parts.aspx
http://naimishpandya.wordpress.com/2012/01/12/how-to-add-custom-web-part-properties-to-visual-web-part-in-sharepoint-2010/
Once you have a handle on adding a custom property then a List Picker will not contain many surprises. The main difference is that you have to (for lack of a better term) build your picker before it can be added as a functional control. Even though you are calling a built in tool that MS uses and has available, you have to set the stage and provide some code before you add it. This seems like a little overkill to me, but I guess MS likes to make us developers sweat a little.
Here is my code for the ListPicker. As a note, I pieced this together from a variety of sources. Many of which served other purposes, so please forgive me if there is something weird in there.
Now you have your ListPicker ready for use, so we will use the other tricks to add this as a custom property. Next make sure your webpart.cs file defines the ToolboxItem as IWebEditable. I have included my entire QuickLinks.cs file below for an example.
Finally you will want to add the few lines to your main webpart code behind to so you can use the custom property. I have a stub of code below to demonstrate how I added it:
If this works for you like it worked for me, you just spent less time adding the List Picker than searching for how to do it. One thing that bothers me is I have seen this code for 2007 and it is not much different, so hopefully this is a supported way of doing this. However, if it works maybe its worth the risk.
Happy Sharepointing!
In any case, even when you find some one knowledgeable you also run into the fact that they may not specify whether they are talking about Sharepoint 2003, 2007 or 2010 (I ONLY deal with Sharepoint 2010 on my blog) or maybe leave off information they deem too complex or too simple. As was the case when I needed to have a custom webpart property that allowed a users to search for a List. I found DOZENS of ways to accomplish this that ranged from super simple (and useless) to absurdly complex. I tried many of these and most did not work properly or how I would expect. MS has several webparts that to do this (i.e. Content Query Web Part), so why is doing it yourself such a mystery?
As some background, for my project I needed a web part that would take a list, read in the rows and items and display this in a branding friendly manner for our publishing sites. As such, I wanted Content Owners to be able to add the web part and select a list they created somewhere in the site for it to use. I called this web part "QuickLinks" so keep that in mind as you read my code.
First off, you should understand a bit about adding custom properties to a web part. Here are a few links I found very helpful:
http://morshemesh.blogspot.com/2011/05/adding-custom-properties-to-visual-web.html
http://www.lamber.info/post/2010/05/21/How-do-I-create-custom-properties-in-Visual-Web-Parts.aspx
http://naimishpandya.wordpress.com/2012/01/12/how-to-add-custom-web-part-properties-to-visual-web-part-in-sharepoint-2010/
Once you have a handle on adding a custom property then a List Picker will not contain many surprises. The main difference is that you have to (for lack of a better term) build your picker before it can be added as a functional control. Even though you are calling a built in tool that MS uses and has available, you have to set the stage and provide some code before you add it. This seems like a little overkill to me, but I guess MS likes to make us developers sweat a little.
Here is my code for the ListPicker. As a note, I pieced this together from a variety of sources. Many of which served other purposes, so please forgive me if there is something weird in there.
Now you have your ListPicker ready for use, so we will use the other tricks to add this as a custom property. Next make sure your webpart.cs file defines the ToolboxItem as IWebEditable. I have included my entire QuickLinks.cs file below for an example.
Finally you will want to add the few lines to your main webpart code behind to so you can use the custom property. I have a stub of code below to demonstrate how I added it:
If this works for you like it worked for me, you just spent less time adding the List Picker than searching for how to do it. One thing that bothers me is I have seen this code for 2007 and it is not much different, so hopefully this is a supported way of doing this. However, if it works maybe its worth the risk.
Happy Sharepointing!
Tuesday, May 15, 2012
Tex Murphy on Kickstarter
"I love murder mysteries. Ah, to be a *fictional* detective. Everything would be so much simpler then." Tex Murphy in Under a Killing Moon.
So Kickstarter has been a way for long lost and loved brands to make it back into the world. So far all the projects I have back have been successfully funded, and are in progress of being made. One, however, has just started up and it is the one I worry about the most.
Tex Murphy, an Private Detective in the future who takes inspiration from the gumshoes of the past. A man out of time and a hilarious series of adventure games. I loved the humor in these and the mixture of old school PI lingo with mutants, laser guns and flying cars. It was a fun series with a lot of wit, and one of the projects I desperately want to get funded.
Kickstarter is a great way to help get these games developed. It frees developers from fighting with publishers to get games funded and allows them to just make the fucking thing. This is why so few original ideas and soulless games get published. So if you can help, please do!
http://www.kickstarter.com/projects/251414413/tex-murphy-project-fedora?ref=live
"Ah, the Rodent Tracker 8000. Just like on TV. 'Because household pests *never* build up an immunity to bullets.'" Tex Murphy in Under a Killing Moon.
So Kickstarter has been a way for long lost and loved brands to make it back into the world. So far all the projects I have back have been successfully funded, and are in progress of being made. One, however, has just started up and it is the one I worry about the most.
Tex Murphy, an Private Detective in the future who takes inspiration from the gumshoes of the past. A man out of time and a hilarious series of adventure games. I loved the humor in these and the mixture of old school PI lingo with mutants, laser guns and flying cars. It was a fun series with a lot of wit, and one of the projects I desperately want to get funded.
Kickstarter is a great way to help get these games developed. It frees developers from fighting with publishers to get games funded and allows them to just make the fucking thing. This is why so few original ideas and soulless games get published. So if you can help, please do!
http://www.kickstarter.com/projects/251414413/tex-murphy-project-fedora?ref=live
"Ah, the Rodent Tracker 8000. Just like on TV. 'Because household pests *never* build up an immunity to bullets.'" Tex Murphy in Under a Killing Moon.
Friday, March 16, 2012
Kickstarter Gaming Division
Congrats to Double Fine on an awesome run on Kickerstarter! With 3,336,371 million, we will see one of the greats create an Adventure game: a genre that has almost completely died in a realm of cut-throat developers focusing only on games as a cash-cow.
Now we have the chance to bring back another genre: the top down, turn-based Role Playing Game. Gone from circulation, these gems are probably alien creatures to today's games. I am talking about Wasteland 2. Wasteland was a great game in the classic style of the Ultima series and lead to the inspiration for the Fallout series, which ended up regaining life as a 1st Person, Action RPG. However, all of this came from the roots of party, turn based RPGs.
The folks behind the original Wasteland have taken the lead from Double Fine and are funding on Kickstarter, which seems to be my latest Game Distribution Channel. Being the highest pledge amount on Kickstarter to be reached (over $900,000 in 2 days), this is really the rattling of the swords for those of us not satisfying with the over-sensationalized, shallow games that flood the market today.
For those of you interested, there is still 31 days to go to help an awesome game once again see the light of day!
http://www.kickstarter.com/projects/inxile/wasteland-2
Now if only publishers will learn that people play and want more than just 1st Person Shooters and MMOs!
Now we have the chance to bring back another genre: the top down, turn-based Role Playing Game. Gone from circulation, these gems are probably alien creatures to today's games. I am talking about Wasteland 2. Wasteland was a great game in the classic style of the Ultima series and lead to the inspiration for the Fallout series, which ended up regaining life as a 1st Person, Action RPG. However, all of this came from the roots of party, turn based RPGs.
The folks behind the original Wasteland have taken the lead from Double Fine and are funding on Kickstarter, which seems to be my latest Game Distribution Channel. Being the highest pledge amount on Kickstarter to be reached (over $900,000 in 2 days), this is really the rattling of the swords for those of us not satisfying with the over-sensationalized, shallow games that flood the market today.
For those of you interested, there is still 31 days to go to help an awesome game once again see the light of day!
http://www.kickstarter.com/projects/inxile/wasteland-2
Now if only publishers will learn that people play and want more than just 1st Person Shooters and MMOs!
Thursday, February 9, 2012
More Than Double Fine (Updated)
Today I feel giddy. As video gamer gaming for almost the full history of video games, I have played a LOT of them. I view games as an art form that may do not attribute to things "functional" or "interactive". Although I can enjoy the thrills of the world's Halos and other popular fodder, I prefer games with more depth and artistic merits. Fun is not the amount of headshots you gather, but the emotion you take away when the playing stops. Many of my personal favorites do not show up in the top 10 lists and are normally punished by publishers who don't see enormous blockbuster profits.
Tim Schafer is at the top of my list of gods within the gaming world. His games are always strange and alluring experiences that challenge the traditions of typical games. Not always do these types of games gather mainstream audiences as Tim has experienced with both Pyschonauts and Brutal Legend. This week was already going well for me with news that Pyschonauts 2 may actually happen with the help of Minecraft creator Markus "Notch" Persson, but then I discovered a link to kickstarter:
http://www.kickstarter.com/projects/66710809/double-fine-adventure
For someone that is never the target audience for the most popular Movies, TV Shows, Games, Music, (insert random entertainment form here), this is great news. A game being developed by a legend with his team working directly with gamers, and without a publisher, to make a game. This is how it should be done: without corporate greed or influence. It may not be the game for everyone and may not make millions of dollars, but this is where the future of game development needs to head. And this will be my first kickstarter investment and I hope other people help out too.
Rock the crap out of it Tim! Keep making games for the rest of us!
(UPDATE) 1.3 Million raised already. Congrats Double Fine!
Tim Schafer is at the top of my list of gods within the gaming world. His games are always strange and alluring experiences that challenge the traditions of typical games. Not always do these types of games gather mainstream audiences as Tim has experienced with both Pyschonauts and Brutal Legend. This week was already going well for me with news that Pyschonauts 2 may actually happen with the help of Minecraft creator Markus "Notch" Persson, but then I discovered a link to kickstarter:
http://www.kickstarter.com/projects/66710809/double-fine-adventure
For someone that is never the target audience for the most popular Movies, TV Shows, Games, Music, (insert random entertainment form here), this is great news. A game being developed by a legend with his team working directly with gamers, and without a publisher, to make a game. This is how it should be done: without corporate greed or influence. It may not be the game for everyone and may not make millions of dollars, but this is where the future of game development needs to head. And this will be my first kickstarter investment and I hope other people help out too.
Rock the crap out of it Tim! Keep making games for the rest of us!
(UPDATE) 1.3 Million raised already. Congrats Double Fine!
Tuesday, January 17, 2012
Umbrae's Tower Goes Dark for SOPA Protest on Jan 18th
This blog will go dark on January 18th in protest of SOPA and PIPA like may other sites:
http://abcnews.go.com/Technology/wikipedia-blackout-websites-wikipedia-reddit-dark-wednesday-protest/story?id=15373251#.TxWXQ29SRwg
Be prepared to see this page alot!
http://www.sopastrike.com/strike/
Keep Freedom of Speech Alive!
http://abcnews.go.com/Technology/wikipedia-blackout-websites-wikipedia-reddit-dark-wednesday-protest/story?id=15373251#.TxWXQ29SRwg
Be prepared to see this page alot!
http://www.sopastrike.com/strike/
Keep Freedom of Speech Alive!
Tuesday, December 13, 2011
The Great American Censorship Firewall
SOPA is set to pass on Thursday (12/15/2011) which will change the face of the internet as we know it. Most people do not understand the incredible complexities of copyright law, and the simple fact is that nearly all of us are in breach of these laws every day. Simply uploading a video to YouTube with a movie poster on the wall or music playing in the background is infringing if you do not have permission. Once SOPA is passed and the safe habor for internet and service providers is eliminated, you will find these player filtering and censoring most stuff you try to post: if they even still allow it.
This might sound apocalyptic, but there are many cases today of companies over reaching or removing content without even verifying it is in fact infringing. Now add to that SOPA which would block IPs, poison DNS records, require removal from search results and basically remove any content for any reason without ANY OVERSIGHT OR VERIFICATION. Someone simply has to accuse you of something and your business, your likelihood, your opinion will be wiped clean. This will ruin small businesses and mean only large companies with the ability to sue other large companies will survive.
Don't believe me? Do a search for Dajaz1.com and read about it. They were taken down a year ago (without SOPA) and had no recourse to get their business back until the government just decided to release it.
Regardless of what you thing about copyright law and piracy, allowing the government and large media companies to take down any content and sites without any judicial oversight does not make any sense. This is something out of science fiction stories depicting overreaching government and corporation control. This cannot be left alone. Please contact your elected officials and speak out against SOPA and Internet Censorship. Stop American Censorship (http://americancensorship.org/) has great tools that make this seamless and easy, as does the Electronic Frontier Foundation (https://www.eff.org/).
This is not just an attack on the internet, but our entire American Culture!
This might sound apocalyptic, but there are many cases today of companies over reaching or removing content without even verifying it is in fact infringing. Now add to that SOPA which would block IPs, poison DNS records, require removal from search results and basically remove any content for any reason without ANY OVERSIGHT OR VERIFICATION. Someone simply has to accuse you of something and your business, your likelihood, your opinion will be wiped clean. This will ruin small businesses and mean only large companies with the ability to sue other large companies will survive.
Don't believe me? Do a search for Dajaz1.com and read about it. They were taken down a year ago (without SOPA) and had no recourse to get their business back until the government just decided to release it.
- How a Music Site Disappeared for a Year (NY Times)
- DHS abruptly abandons copyright seizure of hip-hop blog (C|NET)
- Universal music files fraudulent copyright complaints with YouTube, censors pro-Megaupload song (Boing Boing)
- Tech News Today blocked for commenting on Megaupload video (+Tom Merritt)
Regardless of what you thing about copyright law and piracy, allowing the government and large media companies to take down any content and sites without any judicial oversight does not make any sense. This is something out of science fiction stories depicting overreaching government and corporation control. This cannot be left alone. Please contact your elected officials and speak out against SOPA and Internet Censorship. Stop American Censorship (http://americancensorship.org/) has great tools that make this seamless and easy, as does the Electronic Frontier Foundation (https://www.eff.org/).
This is not just an attack on the internet, but our entire American Culture!
Subscribe to:
Posts (Atom)