Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. function consultBP() {
  2.  
  3. try
  4. {
  5. var customlist ;
  6. var clientContext = new SP.ClientContext.get_current();
  7. var oWebsite = clientContext.get_web();
  8. var oList = oWebsite.get_lists().getByTitle( 'WO_Projects' );
  9. var camlQuery = new SP.CamlQuery();
  10.  
  11. camlQuery.set_viewXml( '<View><Query><Where><Geq><FieldRef Name='ID'/>' +
  12. '<Value Type='Number'>1</Value></Geq></Where></Query></View>' );
  13.  
  14. this.customlist = oList.getItems( camlQuery );
  15. clientContext.load( this.customlist );
  16. clientContext.executeQueryAsync(
  17. Function.createDelegate( this, onQuerySucceededClarityID ),
  18. Function.createDelegate( this, onQueryFailedClarityID ));
  19.  
  20. }catch(err){
  21. erroSearchBP++;
  22. if( erroSearchBP < 100 ) setTimeout( function() { consultBP(); } ,200 );
  23. else alert( erroCarregarPagina );
  24. }
  25. }
  26.  
  27. function onQuerySucceededClarityID(){
  28. //........
  29. }
  30.  
  31. function onQueryFailedClarityID( sender, args ) {
  32. alert( "Failed" );
  33. }
  34.  
  35. function getSubWebProjStatus() {
  36. $.each(subWebsArray, function() {
  37. var subSiteUrl = this.Url;
  38. var targetUrl = this.Url + "/_vti_bin/lists.asmx";
  39. var listName = "Project Tasks";
  40. var soapEnv = "<?xml version="1.0" encoding="utf-8"?>" +
  41. "<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">" +
  42. " <soap:Body> <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>" + listName +
  43. "</listName> <viewName></viewName> <query></query> <viewFields></viewFields>" +
  44. " <rowLimit>2000</rowLimit> <queryOptions><QueryOptions xmlns="">" +
  45. "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
  46. "<ViewAttributes Scope="RecursiveAll"/>" +
  47. "</QueryOptions></queryOptions>" +
  48. " </GetListItems> </soap:Body> </soap:Envelope>";
  49. $.ajax({
  50. cache: false,
  51. url: targetUrl,
  52. type: "POST",
  53. dataType: "xml",
  54. data: soapEnv,
  55. contentType: "text/xml; charset=utf-8",
  56. beforeSend: function(xhr) {
  57. xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems");
  58. },
  59. complete: function(msg) {
  60. var siteStatus = "N/A";
  61. var percentComplete = 0;
  62. if (msg.status === 200) {
  63. var totalTaskCount = $(msg.responseXML).find("z\:row, row").length;
  64. var completedTaskCount = 0;
  65. if (totalTaskCount > 0) {
  66. $(msg.responseXML).find("z\:row, row").each(function() {
  67. if ($(this).attr("ows_Status") !== undefined && $(this).attr("ows_Status").length > 0) {
  68. var taskStatus = $(this).attr("ows_Status").split("#")[1];
  69. if (taskStatus === "Completed") {
  70. completedTaskCount++;
  71. }
  72. }
  73. });
  74. percentComplete = Math.round(completedTaskCount / totalTaskCount * 100);
  75. siteStatus = completedTaskCount + " of " + totalTaskCount + " (" + percentComplete + "%) Tasks Completed";
  76. }
  77. displayProjStatus(subSiteUrl, siteStatus, percentComplete);
  78. } else {
  79. //Failure
  80. var errorCode = $(msg.responseXML).find("errorcode").text();
  81. var errorString = $(msg.responseXML).find("errorstring").text();
  82. if (errorString.length === 0) {
  83. errorString = $(msg.responseXML).find("faultstring").text();
  84. }
  85. errorString = errorString.replace(/(rn|n|r)/gm, "");
  86. showStatusBar("Oh no! " + errorString + "(" + errorCode + ")");
  87. }
  88. },
  89. });
  90. });
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement