Monday, March 08, 2010
#
So I was playing around with NavigationNodeCollection, which is basically like SPNavigationNodeCollection just to make sure it worked without a hitch…Here is a little sample snippet of what should work:
Unfortunately, you get a nice little javascript error that does not allow you to access the child nodes. I tried a foreach() loop that gets a NavigationNode for each parent then loops through the NavigationNode.Children that did not work either. I threw in two ExecuteQueryAsync statements thinking that would help, unfortunately adding a second statement provides no different results. This appears to be a bug in the Silverlight Client Object Model. I reported the error. Hopefully, we get a fix by RTM so that we can use the easier method to get items into Silverlight, otherwise it’s back to WCF and cross domain policies. We all love cross domain policies right?
Friday, March 05, 2010
#
I’m not sure if this bug exists on any other environment, but here are a few issues I ran into when trying to use SPRoleAssignment and SPGroup:
- When trying to use Web.Groups[“GroupName”] it basically told me the group did not exist, so I had to change the code to use Web.SiteGroups[“GroupName”].
- I could not add the Role Assignment to the Web and run a Web.Update() without adding an additional Web.AllowUnsafeUpdates= true; , however on my virtual machine I could do a Web.Update() without the extra piece of code. I kept receiving an error in my browser stating that I should hit the back button and update my permissions.
So after fixing those two issues I was able to copy the permissions from a page item into a Site for my migration. Hopefully, one of you can learn from my error messages if you have any issues in the future.
Sunday, February 28, 2010
#
Conferences:
SSWUG.org VConference, 4 sessions, April 7,8, and 9, Register at
http://www.vconferenceonline.com/shows/spring10/uvc/ SharePoint .org Conference, 2 sessions, April 18-21,
http://www.sharepointconference.org/Pages/default.aspx The Expert's Conference, Silverlight, April 25-28, enter the code "Gambit" when you register at:
http://www.theexpertsconference.com/general-information/sharepoint-training/ SharePoint Saturdays:
SharePoint Saturday Charlotte, Silverlight, April 10th, Regiser at
http://www.sharepointsaturday.org/charlotte Code Camps:
New York City Code Camp, March 6th, Register at
http://ny.codecamp.us User Groups:
TRISPUG, March 2nd, Register at
http://www.trispug.com/default.aspx Central NJ .Net User Group, March 11th, Register at
http://www.njdotnet.net/
Here is a link to the slides and code samples on my Sky Drive:
http://cid-8e2654c5f01e6069.skydrive.live.com/summary.aspx?sa=624379842 In the future I will be doing a bunch of Stickam test presentations. Check this blog for information and my twitter account. I need more practice and I think Stickam or some other sharing outlet would help a lot.
Saturday, February 06, 2010
#
I’ve been running around trying to find my place in the community not quite situated yet. This past Monday I attended a community social event where all the community leaders in the area got together and discussed upcoming plans for the year. It was a lot of fun and surprisingly interesting. I thought there would be a lot more people in attendance of this event. I always assumed this area had so many more people. That I would be this tiny itty bitty fish in a very large pond. It didn’t really feel that way at all. I guess for one it’s because I was one of two SharePoint people in attendance. Also, there were only about 5 other girls. I thought there would be more girls, but 5 or 6 girls is about 5 or 6 more girls than the Kansas City area ever had in attendance at one of these events. The coolest thing in the world that hey discussed was women in tech events. They want to do something for young girls. I really hope we can get something together, because I’ve wanted to get more young girls involved in technology in high school and college (maybe even younger). I want them to know that this is a field where everyone can thrive. Just because there are more guys does not mean there isn’t room for girls by showing them how the rest of us are doing in the technology community. That was not the only thing discussed there is another event I am helping someone out with in the works for the area. I am going to heavily immerse myself in helping that person plan this event. It’s funny I leave one area to start doing almost the same thing in another area. Anyway, check back on my blog and I’ll be posting more details in the upcoming months. Also, I will probably post some progress as it occurs. Right now I’ve decided I’m attending NY Silverlight, NY SPUG, NY Dev SPUG (when it starts), Princeton SPUG, and Central Jersey .Net. These are all pending topics and if I still have train money to attend all the events. It gets incredibly expensive, but I really enjoy attending these events. I see something really cool with Silverlight or SharePoint and something just clicks. Plus on the friend front it’s not huge, but I’m trying to force myself socially to gain a few of these in the area. I miss all the cool people I knew in Kansas City. Right now I still haven’t found anyone local I could just hang out with easily. I miss all my old friends. Everything is so spread out and different. Time will present me more opportunities. Things just don’t happen overnight.
This week and the following weeks I will be working through a ton of recursive functions to move a rather hefty page library into a Site Collection and subwebs. I figure while I am having some “fun” you guys will profit will a few of my scripts. For any of you out there who are interested in how to create a publishing page in a library here is a little sample code on how to copy items from the page content area and create a new page then replace a welcome page. Here is a small sample:
PublishingSite PubSite = new PublishingSite(NewSite); //pass in an SPSite Object
PageLayoutCollection SiteLayouts = PubSite.GetPageLayouts(false);
PageLayout MyLayout = SiteLayous[“urlforlayout”];
PublishingWeb PubWeb = PublishingWeb.GetPublishingWeb(Web); //pass in an SPWeb Object
PublishingPageCollection Pages = PubWeb.GetPublishingPages();
PublishingPage MyPage = PubWeb.GetPublishingPages().Add(ChildItem["Name"].ToString(), MyLayout);
MyPage.ListItem["Page Content"] = ChildItem["Page Content"];
MyPage.ListItem.Update();
MyPage.Update();
MyPage.CheckIn("New Page Creation");
PubWeb.DefaultPage = Web.GetFile(MyPage.Url);
PubWeb.Update();
So basically if you look at the top you get the Publishing Site and then you get the Publishing Web. What you want to do next is get one of the layout pages. You could instead of hard-coding in a URL step through a foreach loop and search for the specific layout that you want. What you want to do next is create a new page and then give it the name of the old item, so it will create the item with the same page name and you want to pass in the layout page from the previous step. Next you want to get the Page Content from the Content Area in the “Page Content” field and then update the page. Remember you need to check the item in before you set the welcome page or you will receive a fun little error message. Then you can set the Publishing Web’s default page (welcome page) to your page and update the Publishing Web. I learned the hard way by not updating the Publishing Web the first few times. You also need to remember that you should turn on the flag for Web.AllowUnsafeUpdates otherwise you will not be able to create a page or update anything at all in code. After you are done turn this flag off as a good practice. Remember to dispose all SPWeb and SPSite object if necessary or wrap using statements around everything. I hope you enjoy!
Monday, January 25, 2010
#
Recently I was tasked to create a console application to get all the attachments from a list and copy them to a file share. Everyone has code out there, but I noticed not one single place had the correct formatting for everything.
First off there is gotcha. You cannot copy SPAttachmentCollection from the List Item and step through the list of strings. You need to pull in the Item.Attachments.UrlPrefix and throw it into an SPFolder Item like below:
SPFolder Folder = Web.GetFolder(Item.Attachments.UrlPrefix);
If you try and pull out the File.OpenBinary(); without using this specific method for some reason you cannot grab the full SPFile. It is malformed.
So here is what it could look like if you wanted to get the attachments and copy them to the file share:
foreach(SPListItem Item in List.Items)
{
if(Item.Attachments.Count !=0)
{
SPFolder Folder = Web.GetFolder(Item.Attachments.UrlPrefix);
foreach(SPFile File in Folder)
{
byte[] CopyFile = File.OpenBinary(); //this fails if you pull in SPFile directly
//Your fstream code to copy file, remember to close your fstream when done
}
}
}
I hope that this helps someone else in the long run. Good luck. Catch you all later.
Wednesday, January 20, 2010
#
Hey guys so if you want to download my databinding demos and hello world demos here you go: http://cid-8e2654c5f01e6069.skydrive.live.com/home.aspx. My slide deck from Virginia Beach alongside my 2007 demos are also posted up on my Sky Drive. The WCF Demos should work. You must remember though that if you are using a cross domain webservice that you need a policy file at the root of your IIS Directory. In the upcoming months as time permits I will post more demos. I’m sorry for the recent neglect and will try to keep a little more current. I just won a Silverlight 3 Book at the local .Net User Group and Silverlight 4 looks like it can also be fun. Lots to experiment with and so little time. I bet by the time I learn 4, then they will release 5. It’s crazy how fast we get the new versions of Silverlight. Anyway, enjoy the demos and I hope to see you all at event some day.
Wednesday, January 13, 2010
#
I have a couple posts coming to this respect, but I had the displeasure of working with Apache, SVN, and Perl these past few weeks. First off I tried learning Perl when I was 16 years old and it never took. I couldn’t understand it. I still don’t understand half of what it does and why you would use it over any other scripting language. The most I ever used it prior to these past few weeks was AOL .eml forms back in the day (http://members.aol.com/jadedixon yeah I know I’m not proud of my 17 year old self). I feel like I’ve been sitting pretty in my C# and ASP .Net world. This project was like a refresher of what I could be doing right now had I never been introduced to the .Net and SharePoint world.
So first off I had do all these insane configurations. You complain that SharePoint takes forever to configure correctly…DONOT ever complain to me about SharePoint. Apache and Subversion are 10x more painful to install. I swear when I installed these two technologies I had no idea what I was doing. What is even better is that I had to statically set the IP for Apache, so that it would not conflict with IIS. IIS is basically the Apache of the Microsoft world so the two just don’t like each other. I also had to set the port number for Apache to some obscure port that was not 80 obviously the port conflicts due to IIS monopolizing it. Oh yeah and did I mention the guide is not straight forward so you have to go into Event Viewer and the Apache and SVN error log files and basically google each error message. Eventually I got past all that insanity after about 2 days of configuration and I had a base environment.
Now at this point you wonder how do I get Perl to work. For me I need to create an Authentication script for SVN that ties into a .Net Webservice that will tie into a Membership Provider. As I said before I had no idea what I was doing. I didn’t know a lick of Perl. So I started by researching how to use Perl with Apache and how to hit a webservice using Perl. I came across a couple of items that could help me throughout the process. First off you want to install Active Perl, which is Perl for windows. You have to put it in the usr/bin folder on your main drive. Then what you want to do is remove all the IP address static junk you added, but remember to save it for later so you can add it back. Type in “PPM” in run and you will get a list of all the mods available for Perl. I noticed that mod_perl is a must have for Apache and Perl scripting. It makes things run faster and has a whole library that you can access tailored specifically for working with Apache. You need to right click on every prerequisite. I also found a great webservice module called SOAP::Lite that helped me pull the data from the webservice later on. Remember to right click on this module and then when you think you downloaded all the modules no you did not. You have to tell it to run all the actions. This will actually download the modules. If you left on your static ips you cannot download these items because you cannot hit the internet. So now you think your done right?
No you’re not even close, because you now need to go into the Apache configuration files and add some lines of text to tell Apache to recognize mod_perl. You also need to download a .so file and put it in the Apache directories. If you download the wrong one and reference it or mess up your configuration files when you try and start the Apache 2 service it will not budge and send you an obscure error message. If you get some crazy error message you need to go into the logs directory and open the error text file. If you are lucky you might get a nice clean error message that means something. If not well good luck you are going to be shooting in the dark for a few days.
So now I finally got everything setup and I had to figure out the syntax. This part was tricky because there are not a ton of blog posts an forums or documentation on this open source stuff. Everyone was calling there stuff wrong and from what I understand hitting a .Net webservice can be buggy at times with Perl. So at this point I downloaded a Perl Editor called Perl Express and started shooting in the dark. I wrote the entire module and I added it to the configuration files as the Authentication Handler for SVN. I got all kinds of crazy errors that I stepped through with the error logs. Each one more obscure than the last message. It felt like I was shooting at something with a blind fold. Finally I got to a point where I thought everything worked, however it was not popping up a username and password dialog box. So finally after hitting another 800 websites and trying different things it popped up the username and password. I received no more error messages and I thought the script was working.
I was so dead wrong, because the parameters had the username and password, however they were not passing them into the webservice. I spent an entire week trying to figure out what was going on reading forums and blog posts. No one had any documentation. Last night I finally thing hey what about the namespace in my webservice. Some people say you can use tempuri and other people just don’t use it at all. I decided to change my namespace to the uri plus the folder up to the asmx file. Finally everything works, so namespace apparently cannot be the default or Soap::Lite will not pass in the parameters. If you do a debug and a trace it will print the XML out correctly and everything will act fine until you want to pass in parameters. It was cool when everything worked, but I hate the open source world. The documentation is horrendous. At least Microsoft gives us MSDN and the people posting blogs are at least somewhat better. Plus I missed my debugger. I was using Fiddler and Apache error log files. At least with .Net I can attach a debugger and step through code. Maybe there is a way to do it in Perl, but I just don’t see it being easy. It just felt like too much work for something so simple.
If you are reading this blog post please take this with you that you could be working with Perl or Python or even PHP rather than .Net. It could be 10x worse. If you are working with SharePoint and complaining I will yell at you if you even begin to tell me how horrible the developer experience is right now. It could be so much worse guys. Don’t complain. You have it good. We could be working with punch cards or open source. Our salaries could be so much worse. Appreciate what you have, because it could go away in a heart beat.
Saturday, January 09, 2010
#
It was one year ago that SharePoint Saturday kicked off in Virginia Beach. Michael Lotter, Susan Lennon, and Kevin Israel thanks for creating one of the most successful events around the world. What started out as one or two events has multiplied into over a dozen events and then some. Thank you so much (especially Michael and Susan) for all that you have given to the rest of us. I wouldn't know most of you guys out there without them. It's been an awesome year. Keep up the good work.