kamagra how much to take

Deploy a SharePoint Site Map by Applying Application Content to Local Server

Deploying sitemaps to a SharePoint server can take on many forms, however the most common seems to be placing it in a Feature Receiver to automate the provisioning on trapping. I like this approach too, however after looking at a few solutions online I thought I would throw out an approach to do this using the SPWebService.ContentService.ApplyApplicationContentToLocalServer method garnishing files in a generic format using SPUtility.GetGenericSetupPath.

Consider the following DeployMap method. In the first segment, you can see that the SPUtility.GetGenericSetupPath method is being used which will use the SPUtilityInternal.GetLocalMachineRegistryValue method to get the appropriate location in the twelve hive of the files in question. The source and destination strings represent where we are going to be copying the sitemap file from post-deployment, so this part might vary depending on your flavor of approach.

Following, a new SPServiceInstance object is created by using SPWebServiceInstance.LocalContent which will get the current Web service instance. This allows a guard clause to be constructed to check the status of the service by using the SPObjectStatus.Online enumeration. Following the ApplyApplicationContentToLocalServer  method can be leveraged.

  1. private void DeployMap(bool deploy)
  2. {
  3. try
  4. {
  5. string source = Path.Combine(SPUtility.GetGenericSetupPath("TEMPLATE"), string.Concat(new object[] { "FEATURES", Path.DirectorySeparatorChar, "<Your Feature>", Path.DirectorySeparatorChar, "layouts.sitemap.<YourSiteMap>.xml" }));
  6. string dest = Path.Combine(SPUtility.GetGenericSetupPath("TEMPLATE"), string.Format("LAYOUTS{0}layouts.sitemap.<YourSiteMap>.xml", Path.DirectorySeparatorChar));
  7. if (!deploy)
  8. {
  9. File.Delete(dest);
  10. }
  11. else
  12. {
  13. File.Copy(source, dest, true);
  14. }
  15. }
  16. catch (ArgumentException)
  17. {
  18. // do stuff for an argument exception
  19. }
  20. catch (IOException)
  21. {
  22. // do stuff for IO exception
  23. }
  24. catch (UnauthorizedAccessException)
  25. {
  26. // do stuff for access exception
  27. }
  28. SPServiceInstance localContent = SPWebServiceInstance.LocalContent;
  29. if ((localContent != null) && (Equals(localContent.Status, SPObjectStatus.Online)))
  30. {
  31. Web.ContentService.ApplyApplicationContentToLocalServer();
  32. }
  33. localContent = SPWebServiceInstance.LocalAdministration;
  34. if ((localContent != null) && (Equals(localContent.Status, SPObjectStatus.Online)))
  35. {
  36. Web.AdministrationService.ApplyApplicationContentToLocalServer();
  37. }
  38. }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>