Fringe SharePoint Continued
Site Sections
Home
Contact
Syndication
Login
Posts
48
Comments
32
Trackbacks
0
July 2009 Entries
Why Blog and Reference Code that does no Work??
In the last week, I have been working on a project that involves web services. It has been an interesting project, SharePoint projects are always a surprise in that code is supposed to work a certain way and it never really seems to work the way it's supposed to.
I feel as though i need to apologize for this post because it's kind of a rant. I still feel like it needs to be said. If someone out there is going to blog please post up code that is your own! and more importantly post up code that actually works!!!I We can't seem to do a whole lot about msdn, it appears they are always going to post up bad code. Do take MSDN code with a grain of salt, it will point you in the right direction but in my experience I have found only 10% of the code posted there actually works as is!
My example is from thsi MSDN blog
post
. It seems as though every blog post I read referenced this post. I'm not going to posts links to those other blogs. The sad thing was that They actually cut paste this code and posted it as their own. No reference to the MSDN post. And it seems as thought they did not even run the code cause it realy does not work.
Issues with this code:
1) the webID that is supposed to be the last input paramater, cannot be blank. Some people have been reporting this issue. I personally did not have this issue, but I was using WCF not a web service code.
2) I don't know if this is because I used WCF but the input variables are not XmlNode they are XmlElements. My code does not even compile with the posted code. Why is there no documentaion on Msdn about thsi? It is minor but it's a change in the object model, and input variables that deserves some documentation.
3) The Query string is nto complete, Msdn does not claim to have this finished. It is more of a template for the CAML querey. I guess I was just frustrated because a web service call would just throw an exception and would not return any helpful message about what was wrong with the call. It turns out it was my CAML query.
4) Once I got the web service call working with basically blank XmlElements. I was able to add xml that I wanted to incorporate. The QueryOptions xml, is set to not return mandatory fields, yet it seems to return extra fields.
5) The ViewFields is quite confusing, one thing to keep in mind with the view fields is that it does not refer to the "Display Name" of the columns. This is important not only to viewfields, but to the Query as well. My suggestion is to download a
CAML
tool. Build your query first and then cut paste it from the generated CAML in the tool.
After my battling I friend of mine found this
post
, wich was exactly what I was doing. And at the very least, it had working code!!! Please don't regurgitate code that is not yours withouth any reference, and don't post up code that does not work!
Juan
Share This Post:
Short Url:
http://wblo.gs/Yoc
Posted On
Friday, July 31, 2009 9:45 AM
|
Feedback (0)
Linking Documents in SharePoint 2007
I recently met with a client that asked if you could like documents in SharePoint. I had many internal reactions the client asked but one specific memory stood out for me. A year ago I performed a migration from a document management system called DocuShare to SharePoint 2007.
Docushare Migration to SharePoint 2007
There is very little out there on Docushare Migration, I thought maybe I would take the time to write a paragraph about this. I'm sure that Quest Software and DocAve have something to migrate Docushare. As far as I know they don't but I could be wrong. They do have powerful products that are very very good. Unfortunately for a one time migration it can be very pricy. I don't want to advertise those products cause I don't feel that's my job. Check out the feature sets and decide for your self. What I used to migrate the content was to use a custom tool that my company developed to migrate content over. Not only did it migrate content over but it was able to correct any potential errors that are caused in SharePoint. It was able to take folder structures in Docushare and create sharepoint sites and document libraries right from a UI we designed.
Potential errors we fixed before migration with the custom tool:
1) errors in naming conventions Ex. (*&*(*%^$#@!) ...etc...
2) 255 character length. There were situations where the folder structure was too deep and sites had to be broken up into multiple sub sites.
The only problem we could not fix was linked Documents!!!
This brings e back to the linking in documents in SharePoint. I highly recommend against Linking documents in SP. I think the plan should always be to design a taxonomy that makes sense and stored documents in a logical grouping. I also understand that there scenarios where linking is cannot be avoided. In the case of the client I am involved with, it appears that this is the case.
How to link documents in SharePoint.
Documents can be linked by creating a content type that has a parent or inheriting content type of "Document", when you create a content type.
Once you create the content type. Add this content type to your document library. The process is pretty self explanatory after that. You can create new entries in your document library that are not documents but actual links to other documents or document libraries. It does not have to link to a specific document, it is a generic link so you can be creative and do what you want.
Things to consider:
Manageability of links - Once you start adding links you will have to manage the change of these links, Location of documents, moving of document libraries , and sites. SharePoint has the ability to re-link and fix broken links so this is something I'm going to have to test and see how links to documents would react to moving document libraries or subsites. Even a plain back up and restore to another environment!
Use Metadata - Although I did not demonstrate it in this post, use as much metadata in your content type. Make sure you capture as much information about your document and locations. Trust me it will go a long way to managing these links.
Have a Logic - what I mean by this is have a system of linking documents. One of the most frustrating parts about the docushare migration was that it was an unmanaged system, when it came to links. There was no rhyme or reason to the actual linking. Have a clear plan as to wich documents and how and where they will be referenced from. That way, even if you don't know the actual link , you can have an idea of what the linking scheme is like.
I will be performing other tests on linking as I have to weigh out the pros and cons to this linking issue and I will post them up for everyone.
Juan
Share This Post:
Short Url:
http://wblo.gs/Ykn
Posted On
Monday, July 20, 2009 10:46 AM
|
Feedback (4)
Web Config Changes Security Issue
Hi all ,
I recently was working with a client that implemented a telerik navigation control as a quicklaunch. They decided to split up all the sub-sites into their own site collection. They wanted to place quotas on subs sites, and if you don't know, you can only set quotas on site collections and not sub sites.
This switch or splitting of sites posed some interesting problems.
1) Telerik Control now needed to be added to each sub site for navigation. The control specifics were added to a master page. So this master page needed to be uploaded to the site collection (each one) and set as default master page.
2) Because code is running on page, a web config entry needs to be added to allow the control to work on the master page. The entry looks like the following:
<PageParserPaths>
<PageParserPath VirtualPath="/_catalogs/masterpage/customdefault.master" CompilationMode="Auto"
AllowServerSideScript="True" />
</PageParserPaths>
Now the problem is not too bad except you have to do this for hundreds if not, over a thousdand sites. So I figured there was a way to upload the master page and set the default master page in code. What I was having issues with was writting the entry to web.config. I was pointed toward a
blog
post that outlined the entire feature that I needed to implement.
I was thinking great! it's all done for me, my client just wants me to re-write it, and test it properly and then i will send it their way! Well, I was half way there, I still needed to write to web config. I wrote the following code to write to web config. The 'owner' object is a string that is the complete url to the master page.
SPWebConfigModification webConfig = new SPWebConfigModification("PageParserPath",
"configuration/SharePoint/SafeMode/PageParserPaths");
webConfig.Owner = string.Format("{0}{1}", siteCollection.ServerRelativeUrl,
owner);
webConfig.Sequence = 0;
webConfig.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webConfig.Value = string.Format(
"<PageParserPath VirtualPath=\"{0}{1}\" CompilationMode=\"Auto\" AllowServerSideScript=\"True\" />",
siteCollection.ServerRelativeUrl, owner);
siteCollection.WebApplication.WebConfigModifications.Add(webConfig);
siteCollection.WebApplication.Farm.Servers.GetValue<SPWebService>().ApplyWebConfigModifications();
siteCollection.WebApplication.Update();
This is all great except that, not just anyeone can edit the Web.Config. You need elevated permissions to do this. So I decided to run the code under
elevated priveledges
. But I got unexpected results.
You can google around and find out all the issues with eleveated priveleges and how it impersonates the System account. It just turns out that this code worked fine in my test environment, but not in production. The only difference is my web applications run under the network service, and the production environment runs under a windows account. When debugging I had my instance of Visual Studio 2008 freeze on me and this is the error message that I got:
A Zombie state!!! I had never ever heard of this!! I'm assuming that the proccess that I was attachedu to during debugging was stuck, I assume it was stuck trying to sort out credentials. In my test environment I would get weird prompts for credentails once in a while, and sometimes it did not work at all. In production environment, it simply did not work. These are the methods in the feature.cs.
private void WriteToConfig(string owner)
{
using (SPSite siteCollection = SPContext.Current.Site)
{
SPWebConfigModification webConfig = new SPWebConfigModification("PageParserPath",
"configuration/SharePoint/SafeMode/PageParserPaths");
webConfig.Owner = string.Format("{0}{1}", siteCollection.ServerRelativeUrl,
owner);
webConfig.Sequence = 0;
webConfig.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
webConfig.Value = string.Format(
"<PageParserPath VirtualPath=\"{0}{1}\" CompilationMode=\"Auto\" AllowServerSideScript=\"True\" />",
siteCollection.ServerRelativeUrl, owner);
siteCollection.WebApplication.WebConfigModifications.Add(webConfig);
siteCollection.WebApplication.Farm.Servers.GetValue<SPWebService>().ApplyWebConfigModifications();
siteCollection.WebApplication.Update();
}
}
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
var newmaster = properties.Feature.Properties["MasterPage"].Value;
if (!string.IsNullOrEmpty(newmaster))
{
using (var curSite = (SPSite)properties.Feature.Parent)
{
using (var curWeb = curSite.OpenWeb())
{
curWeb.CustomMasterUrl = curWeb.MasterUrl.Replace(curWeb.MasterUrl, newmaster);
curWeb.MasterUrl = curWeb.CustomMasterUrl;
SPSecurity.RunWithElevatedPrivileges(this.WriteToConfig(curSite.ServerRelativeUrl+curWeb.MasterUrl));
curWeb.Update();
}
}
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
var defmaster = properties.Feature.Properties["DefaultPage"].Value;
using (var curSite = (SPSite)properties.Feature.Parent)
{
using (var curWeb = curSite.OpenWeb())
{
curWeb.CustomMasterUrl = curWeb.MasterUrl.Replace(curWeb.MasterUrl, defmaster);
curWeb.MasterUrl = curWeb.CustomMasterUrl;
SPSecurity.RunWithElevatedPrivileges(this.DeleteWebConfig());
curWeb.Update();
}
}
}
private void DeleteWebConfig()
{
using (SPSite siteCollection = SPContext.Current.Site)
{
Collection<SPWebConfigModification> collection = siteCollection.WebApplication.WebConfigModifications;
string owner = string.Format("{0}{1}", siteCollection.ServerRelativeUrl,
siteCollection.RootWeb.CustomMasterUrl);
int iStartCount = collection.Count;
for (int c = iStartCount - 1; c >= 0; c--)
{
SPWebConfigModification configmod = collection[c];
if (configmod.Owner.Equals(owner))
{
collection.Remove(configmod);
}
}
siteCollection.WebApplication.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
siteCollection.WebApplication.Update();
}
}
I had run into problems with the
elevated previledges
and blogged about it. So I'm going to chalk this up under the same thread.
Another thing I tried was making sure the windows accounts associated with the web application had the
right permissions
but it still did not work.
I ended up removing the control and editing the quicklauch navigation and allow for accordian style type navigation with some hover over color changes. I tried to re-create all the features that the control added. My next post will describe what and how I edited to re-create the navigation. It involved, CSS changes, Master Page changes, QuickLaunch navigation control changes, and JQuery!!! Stay tuned.
If anyone figures this out or can shed some light please let me know.
Good luck
Juan Larios
Share This Post:
Short Url:
http://wblo.gs/YjE
Posted On
Tuesday, July 14, 2009 9:32 PM
|
Feedback (2)
SharePoint MVP!
Hi all,
Just wanted to tell you all that I am now a SharePoint MVP!! Thanks to Darcy Lussier for the nomination.So what does this mean? I certainly don't feel smarter, or that I'm any more compitent than before. This Brings me back to evaluate why I blog and why I give to the community. Make no mistake, this award is something that means a lot to me but it does not magically give me special powers! It is nice to be recognized by my peers and I look forward to all the perks that come along with being an MPV. I know many developers that are more talented than me, and SharePoint Developers and architects that have more certifications and know just as much as me if not more. The difference I notice is attitude. They are the kind of people that profit from blogs and comments and feedback on problems posted online, but if they figure things out they don't bother blogging about things or writing a comment on blog that posted the issue.
So why do I blog?
1. I have a terrible memory! - I find myself referencing my blog a lot. I keep on forgetting how I did things. How I solved the problem, and how I dealt with things.
2. I need help! - I don't claim to know everything, but I kind of know where to look. When I get stuck I like to post something online and create discussions to get the community involved in helping each me.
3. I love to teach - one of my passions is teaching and instructing. I'd like to think that I am good at it. I don't like blogging useless things just for the sake of writing a lot of posts. I often think, "would this blog post be useful to me before I figured things out? and can it help someone else?" I hope it helps others, and the community can educate and help each other out. Some of the best MVP's out there help by pointing people in the right direction and struggle through things with you.
So now some of you ask, why switch where you blog? Well, I have another
blog
which I will now stop blogging at. I will not delete those blog posts but I will slowly move those blog posts to this blog. There are 2 main reasons why. I wanted to have more exposure and was told "Geeks with Blogs" is just awesome for that. My good friend Darcy Lussier suggested this site and swears by it. I also wanted to start blogging independently of the place I work.
So thanks to everyone that has helped me along the way in becoming an MVP and in my career, hope to keep it going!!
Best Regards
Juan Larios
Share This Post:
Short Url:
http://wblo.gs/YjD
Posted On
Tuesday, July 14, 2009 8:19 PM
|
Feedback (0)
Archives
March, 2012 (3)
February, 2012 (3)
August, 2011 (2)
July, 2011 (1)
June, 2011 (1)
May, 2011 (2)
April, 2011 (2)
March, 2011 (2)
January, 2011 (1)
December, 2010 (1)
November, 2010 (3)
October, 2010 (4)
August, 2010 (1)
June, 2010 (1)
May, 2010 (1)
April, 2010 (1)
March, 2010 (2)
February, 2010 (2)
January, 2010 (2)
December, 2009 (1)
November, 2009 (3)
September, 2009 (2)
August, 2009 (3)
July, 2009 (4)
Post Categories
SharePoint
TFS
Development
Web Parts
Workflow
ALM
SharePointUserGroup
BUGS
Twitter
juan_larios
Headed to the first training session of my professional career! Although I will be working during the sessions
http://t.co/miYzvPHs
about 5 days ago
juan_larios
"is that Brandy? She's not dead?" -
@RuddyWine
about 6 days ago
juan_larios
Wasted half the day today catching up on all my favorite tv shows. Much needed down time!
about 7 days ago
juan_larios
Late night…working, wish the day had 35 hours.
about 10 days ago
juan_larios
Did you know, when developing
#SharePoint
Workflows in VS2010 the Event Receiver of feature receiver interferes with the workflow receiver?
about 10 days ago
juan_larios
http://t.co/9jDDpF4W
There are a couple of things you can do to optimize this. First, you have two Round trips in this call. Since you...
about 10 days ago
juan_larios
What a busy week! Glad it's the weekend and I can refresh.
about 22 days ago
juan_larios
I'm at Mulligans Restaraunt
http://t.co/c2HJQGuy
about 22 days ago
juan_larios
@robertregnier
I'm coming after you! I'm still getting used to the game! but getting closer and closer! I need re-string my raquet now!
about 30 days ago
juan_larios
@edblankenship
@TFService
Thanks Ed. I wasn't aware of this but I suspected. Just wanted to check with the master!
about 30 days ago
Tag Cloud
cloud computing
SharePoint 2007
SP 2010
visual studio 2008
Copyright © 2005 juanlarios
This work is licensed under a
Creative Commons License