Կարգավիճակի արխիվներ: Sharepoint զարգացում

HTTP 406 Error When Using Angular $http.get Against SharePoint REST End Points

Թարմացնել: Marc AD ndersson pointed out this great piece of info: http :/://blogs.office.com/2014/08/13/json-light-support-rest-sharepoint-api-released/. That explains a lot :).

That may be the worst title of a blog post ever! Anyhoo.

I typically do all of my prototyping against an O365 instance. I have my personal instance so that I don’t have to be worried about affecting anyone else. As an aside – remember when we call carried around virtual machines on our laptops with MOSS – SQL Server, IIS, deciding Hyper-V vs. VMWare? Anyhoo…

I had developed an app using Angular in this environment that does, ի թիվս այլ բաների,, սա:

$http.get(serverUrl)
.success(ֆունկցիա(տվյալներ, կարգավիճակ, headers, config) {

var getLinksResponse = data;

getLinksResponse.value.forEach(ֆունկցիա(theResult) {

// and so on and so froth

This was working just fine in two different SharePoint online environments. Սակայն, when my colleague ported it to a Cloudshare instance, he was getting an HTTP 406 սխալ (which was the first time I ever got that one, so … yay, I guess). We did a bit of research and noticed that the “Accept” header was off. SharePoint online was perfectly happy with:

Accept: application/json

But the cloudshare instance (which is SP on prem, hosted in a virtual server) wanted the classic “odata=verbose” added in as well:

Accept: application/json;odata=verbose

To fix that, we added the header as such:

var config = {headers: {
‘Accept’: ‘application/json;odata=verbose’
}
};

$http.get(serverUrl,config)
.success(ֆունկցիա(տվյալներ, կարգավիճակ, headers, config) {

var getLinksResponse = data;

getLinksResponse.value.forEach(ֆունկցիա(theResult) {

// and so on and so froth

That got rid of the 406, but it also changed the format of the response. It was more … verbose. (haha!) More changes were required and here’s the final result:

var config = {headers: {
‘Accept’: ‘application/json;odata=verbose’
}
};

$http.get(serverUrl,config)
.success(ֆունկցիա(տվյալներ, կարգավիճակ, headers, config) {

var getLinksResponse = data;

getLinksResponse.d.results.forEach(ֆունկցիա(theResult) {

// and so on and so froth

This only turned into a 30 minute problem for us, so we lucked out. Hopefully someone finds this useful.

</վերջ>

Աճող իրազեկում / Ընդունումը Դեկտեմբեր շրջանակները

Իմ գործընկեր, Javed Ansari (http://www.bigapplesharepoint.com/team?showExpertName=Javed%20Ansari&rsource=pgblog), wrote a short summary blog post on frameworks he likes or at least has been using with with SharePoint: http://www.bigapplesharepoint.com/pages/View-An-Insight.aspx?BlogID=53&rsource=PGBlog).

jQuery seems to have been the victor on the field, so to speak, for years now, but the others are more new and stills sort of battling it, like Angular. (SPServices, Իհարկե, has been a life saver for years and will continue to be so I think).

What are people using? Are they focused more on Microsoft’s tooling (CSOM / JSOM) or moving more toward Angular, Knockout, Ember, եւ այլն:?

I have a growing bias toward these non-Microsoft frameworks. I think the MSFT stuff is harder and harder to work with, requiring almost as much of learning curve as old-style server-side dev.

Post a comment here or over at Big Apple SharePoint if you want to discuss (Big Apple will have more likelihood of a good discussion).

</վերջ>

Մանում SharePoint ժմչփ աշխատատեղեր կայքի հավաքածուի տեսքը

Իմ գործընկեր, Ashish Patel, wrote a blog post describing a flexible timer job architecture that affords some nice flexibility to support long-running tasks and/or reports.  In his words:

1. Analyzing Checked out files and sending reminders to the individuals if the number of days (since the file was checked out) exceed certain threshold limits

2. Removing links from other content when a particular content is removed or archived from the system

3. User wants to see all the alerts that he subscribed in all webs in the site collection

4. Sending a reminders to authors to review the content when a review time was specified in the content and that date is approaching

Լավ, the list goes on…

– See more at: http :/://www.bigapplesharepoint.com/pages/View-An-Insight.aspx?BlogID=40#sthash.7cKuiwly.dpuf

There are times in my past when having something like this would have been very helpful.

</վերջ>

Ինչպես: Կարգավորել Միավորի համար Test եւ փորձարկել լուսաբանումը QUnit.js եւ Blanket.js է գրասենյակի համար: 365 SharePoint App

Intro

I’ve been exploring unit testing and test coverage for JavaScript as I work on a new SharePoint app for SharePoint online in the Office 365 suite.  The obvious research paths led me to Qunit.js and right after that, դեպի Blanket.js.

QUnit let me set up unit tests and group them into modules.  A module is just a simple way to organize related tests. (I’m not sure I’m using it as intended, but it’s working for me so far with the small set of tests I have thus far defined).

Blanket.js integrates with Qunit and it will show me the actual lines of JavaScript that were – and more importantly – were not actually executed in the course of running the tests.  This is “coverage” – lines that executed are covered by the test while others are not.

Between setting up good test cases and viewing coverage, we can reduce the risk that our code has hidden defects.  Good times.

Qunit

Assuming you have your Visual Studio project set up, start by downloading the JavaScript package from http://qunitjs.com.  Add the JavaScript and corresponding CSS to your solution.  Mine looks like this:

image

Figure 1

Ինչպես տեսնում եք,, I was using 1.13.0 at the time I wrote this blog post. Don’t forget to download and add the CSS file.

That out of the way, next step is to create some kind of test harness and reference the Qunit bits.  I’m testing a bunch of functions in a script file called “QuizUtil.js” so I created an HTML page called “QuizUtil_test.html” as shown:

image Figure 2

Here’s the code:

<!DOCTYPE html>
<html xmlns= "Http :/://www.w3.org/1999/xhtml">
<head>
    <վերնագիր>QuizUtil test with Qunit</վերնագիր>
    <ՈՒղեցույց rel="stylesheet" Ռաֆֆի Չ.="../CSS/qunit-1.13.0.css" />
    <ձեռագիր տիպ="text/javascript" Բացել="QuizUtil.js" data-cover></ձեռագիր>
    <script տեսակ ="Text / JavaScript" Բացել ="qunit-1.13.0.js"></ձեռագիր>
    <script տեսակ ="Text / JavaScript" Բացել ="blanket.min.js"></ձեռագիր>

    <ձեռագիր>
        module("getIDFromLookup");
        փորձարկում("QuizUtil getIDFromLookupField", ֆունկցիա () {
            էր goodValue = "1;#Paul Galvin";

            equal(getIDFromLookupField(goodValue) + 1, 2), "ID of [" + goodValue + "] + 1 should be 2";
            equal(getIDFromLookupField(undefined), undefined, "Undefined input argument should return undefined result.");
            equal(getIDFromLookupField(""), undefined, "Empty input argument should return an undefined value.");
            equal(getIDFromLookupField("gobbledigood3-thq;dkvn ada;skfja sdjfbvubvqrubqer0873407t534piutheqw;vn"), undefined,"Should always return a result convertible to an Integer");
            equal(getIDFromLookupField("2;#some other person"), "2", "Checking [2;#some other person].");
            equal(getIDFromLookupField("9834524;#long value"), "9834524", "Large value test.");
            notEqual(getIDFromLookupField("5;#anyone", 6), 6, "Testing a notEqual (5 is not equal to 6 for this sample: [5;#anyone]");

        });

        module("htmlEscape");
        փորձարկում("QuizUtil htmlEscape()", ֆունկցիա () {
            equal(htmlEscape("<"), "&LT;", "Escaping a less than operator ('<')");
            equal(htmlEscape("<div class=\"someclass\">Some text</div>"), "&LT;div class=&quot;someclass&quot;&GT;Some text&LT;/div&GT;", "More complex test string.");
        });

        module("getDateAsCaml");
        փորձարկում("QuizUtil getDateAsCaml()", ֆունկցիա () {
            equal(getDateAsCaml(նոր Ամսաթիվ("12/31/2013")), "2013-12-31T:00:00:00", "Testing hard coded date: [12/31/2013]");
            equal(getDateAsCaml(նոր Ամսաթիվ("01/05/2014")), "2014-01-05T:00:00:00", "Testing hard coded date: [01/05/2014]");
            equal(getDateAsCaml(նոր Ամսաթիվ("01/31/2014")), "2014-01-31T:00:00:00", "Testing hard coded date: [01/31/2014]");
            equal(getTodayAsCaml(), getDateAsCaml(նոր Ամսաթիվ()), "getTodayAsCaml() should equal getDateAsCaml(new Date())");
            equal(getDateAsCaml("nonsense value"), undefined, "Try to get the date of a nonsense value.");
            equal(getDateAsCaml(undefined), undefined, "Try to get the date of the [undefined] date.");
        });

        module("getParameterByName");
        փորձարկում("QuizUtil getParameterByName (from the query string)", ֆունկցիա () {
            equal(getParameterByName(undefined), undefined, "Try to get undefined parameter should return undefined.");
            equal(getParameterByName("does not exist"), undefined, "Try to get parameter value when we know the parameter does not exist.");

        });

        module("Cookies");
        փորձարկում("QuizUtil various cookie functions.", ֆունկցիա () {
            equal(setCookie("test", "1", -1), getCookieValue("test"), "Get a cookie I set should work.");
            equal(setCookie("anycookie", "1", -1), ճիշտ, "Setting a valid cooking should return 'true'.");
            equal(setCookie("crazy cookie name !@#$%\"%\\^&*(()?/><.,", "1", -1), ճիշտ, "Setting a bad cookie name should return 'false'.");
            equal(setCookie(undefined, "1", -1), undefined, "Passing undefined as the cookie name.");
            equal(getCookieValue("does not exist"), "", "Cookie does not exist test.");
        });

    </ձեռագիր>
</head>
<մարմին>
    <div id="qunit"></div>
    <div id="qunit-fixture"></div>

</մարմին>
</html>

There are several things happening here:

  1. Referencing my code (QuizUtil.js)
  2. Referencing Qunity.js
  3. Defining some modules (getIDFromLookup, Cookies, եւ այլք)
  4. Placing a <div> whose ID is “qunit”.

Ապա, I just pull up this page and you get something like this:

image

Figure 3

If you look across the top, you have a few options, two of which are interesting:

  • Hide passed tests: Pretty obvious.  Can help your eye just see the problem areas and not a lot of clutter.
  • Module: (drop down): This will filter the tests down to just those groups of tests you want.

As for the tests themselves – a few comments:

  • It goes without saying that you need to write your code such that it’s testable in the first place.  Using the tool can help enforce that discipline. Օրինակ, I had a function called “getTodayAsCaml()".  This isn’t very testable since it takes no input argument and to test it for equality, we’d need to constantly update the test code to reflect the current date.  I refactored it by adding a data input parameter then passing the current date when I want today’s date in CAML format.
  • The Qunit framework documents its own tests and it seems pretty robust.  It can do simple things like testing for equality and also has support for ajax style calls (both “real” or mocked using your favorite mocker).
  • Going through the process also forces you to think through edge cases – what happens with “undefined” or null is passed into a function.  It makes it dead simple to test these scenarios out.  Good stuff.

Coverage with Blanket.js

Blanket.js complements Qunit by tracking the actual lines of code that execute during the course of running your tests.  It integrates right into Qunit so even though it’s a whole separate app, it plays nicely – it really looks like it’s one seamless app.

This is blanket.js in action:

image Figure 4

image

Figure 5

(You actually have to click on the “Enable coverage” checkbox at the top [see Figure 3] to enable this.)

The highlighted lines in Figure 5 have not been executed by any of my tests, so I need to devise a test that does cause them to execute if I want full coverage.

Get blanket.js working by following these steps:

  1. Download it from http://blanketjs.org/.
  2. Add it to your project
  3. Update your test harness page (QuizUtil_test.html in my case) as follows:
    1. Reference the code
    2. Decorate your <ձեռագիր> reference like this:
    <ձեռագիր տիպ="text/javascript" Բացել="QuizUtil.js" data-cover></ձեռագիր>

Blanket.js picks up the “data-cover” attribute and does its magic.  It hooks into Qunit, updates the UI to add the “Enable coverage” option and voila!

Ամփոփում (TL; DR)

Use Qunit to write your test cases.

  • Download it
  • Add it to your project
  • Write a test harness page
  • Create your tests
    • Refactor some of your code to be testable
    • Be creative!  Think of crazy, impossible scenarios and test them anyway.

Use blanket.js to ensure coverage

  • Make sure Qunit is working
  • Download blanket.js and add it to your project
  • Add it to your test harness page:
    • Add a reference to blanket.js
    • Add a “data-cover” attribute to your <ձեռագիր> օր
  • Run your Qunit tests.

I never did any of this before and had some rudimentary stuff working in a handful of hours. 

Happy testing!

</վերջ>

undefinedԱնդամագրվել իմ բլոգում.

Գտեք Twitter-ում http://www.twitter.com/pagalvin

Lists.asmx, GetList եւ "Value չի կարող լինել առ”

Այսօր ես հայտնաբերեցի, որ GetList() մեթոդ lists.asmx Վեբ ծառայություն է կոչվել շատ ուշադիր, կամ էլ հակված շպրտել մի խորհրդավոր "արժեք չի կարող լինել առ»: Բացառություն (եւ որ ինչ ենթադրելով, դուք կարող եք ստանալ նախկինում ավելի վատ ընդհանուր error message, “Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ էին նետում »:)  Մասնավորապես, Ես գտա, որ դուք չեք կարող ապահովել որեւէ տեսակի նախածանցը վրա GetList մեթոդով.  Հետեւյալ jQuery պատառներ ցույց կետը:

image

Եթե ​​դուք դա, Վեբ ծառայությունը արձագանքում է «Արժեքների չի կարող առ»: Սույն ջութակահար-նախատեսված HTTP պատճեն:

<?XML տարբերակ = "1.0" encoding="utf-8"?>
  <օճառ:Ծրար
     xmlns:օճառ ="
http :/://schemas.xmlsoap.org / օճառ / ծրար /"    
     xmlns:xsi = "
http :/://www.w3.org/2001/XMLSchema-instance"
     xmlns:xsd ="
http :/://www.w3.org/2001/XMLSchema">

  <օճառ:Մարմին>
    <օճառ:Մեղք>
      <faultcode>օճառ:Server</faultcode>
      <faultstring>
        Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ էր նետում.
      </faultstring>
      <մանրամասն>
        <error լարային xmlns ="
http :/://schemas.microsoft.com / Sharepoint / օճառ /">
Value կարող լինել առ.
        </errorstring>
      </մանրամասն>
    </օճառ:Մեղք>
  </օճառ:Մարմին>
</օճառ:Ծրար>

Իհարկե, Դուք հավանաբար չէր ավելացնել, որ «S0" նախածանցը ձեր սեփական, սակայն որոշ գործիքներ, որոնք հակված է դա անել (նման Խավարման).

Այս ամենը ավելի շփոթեցնող / խախտելով, քանի որ այլ մեթոդներ հանդուրժում prefixes.  Օրինակ, որ GetListCollection մեթոդը դեմ չէ, եթե դա եղել prefixed, նույնիսկ անհեթեթություն prefixes նման "xyzzy":

image

Այս «արժեք չի կարող լինել առ»: Թվում է, բավականին հետ lists.asmx ուստի հուսով եմ սա կօգնի մեկին դուրս ապագայում.

</վերջ>

Անդամագրվել իմ բլոգում.

Գտեք Twitter-ում http://www.twitter.com/pagalvin

Անվերջ nesting <div> Tags եւ jQuery

Սա կարծես այդպիսի oddball թեմա, Վստահ չեմ, որ դա իրոք արժե բլոգերներ մասին, բայց դա երբեք չի դադարել էր ինձ համար:, այնպես որ այստեղ ենք ժպիտ

Ես աշխատում է մի նախագծի, որտեղ ես եմ քաշվել որոշ տվյալներ է որոնում, Փաթեթավորման այն վերածել XML հաղորդագրությունը, ապա այդ մասին XML Նամակ հարցը վերջնականապես վերածվել HTML միջոցով XSLT.  Կա մի շատ jQuery մեջ, մի քիչ, որոնք իրականացնում են tabbing ֆունկցիոնալությունը.  Երբ սեղմում է էջանիշը (իրոք, ա <div>), jQuery վկայակոչում. թաքցնել() եւ շոու() տարբեր DIVS (նախնական էջը բեռը ներլցումներ բոլոր բովանդակությունը այնպես չկան postbacks այս դեպքում).

Մի փունջ ժամ առաջ, պիտակը անցումը տրամաբանությունը սկսեց վարվել erratically եւ այն չի ցույց մեկը իմ թարգմանությունը.  Ես վերջնականապես առ այն, որ Internet Explorer-ի (առնվազն) կարծում է, որ <div> tags nested հեռու, շատ խորն է, քան intended.The մշակողի գործիքների ցույց տալ:

-<div մականունը = "Tab1Content">
  -<div>
    -<div>
      -<div մականունը = "Tab2Content">
        -<div>
           ..............................
                   </div>  <- Վերջապես ցուցադրում է փակվել ամբողջ ճանապարհը ներքեւ այստեղ!

Այնքան, եթե ես մի $("# Tab1Content").թաքցնել(), Ես էլ թաքցնում Tab2 եւ ես երբեք չեմ կարող ցույց տալ Tab2, եթե ես չեմ էլ ցույց Tab1.  Ես պատճենահանված եւ pasted կոդը մինչեւ մեջ Visual Studio եւ այն ցույց տվեց, բոլորը ձեզ հետ պաստառում մինչեւ լավ, ճիշտ այնպես, ինչպես նրանք պետք է անում, փնտրում նման:

-<div մականունը = "Tab1Content">
  +<div>
  +<div>
-<div մականունը = "Tab2Content">
  +<div>
  +<div>

Ես ծեծում իմ գլուխը դեմ պատի մի որոշ ժամանակ, եւ նկատեց, որ բուն HTML կոդը հանձնարարված էր արտադրող մի շատ դատարկ է <div> Tags, նման:

<մարմին>

  <div մականունը = "Tab1Content">

    <div մականունը = "row1" />
    <div մականունը = "row2" />

  </div>

  <div մականունը = "Tab2Content">

    <div մականունը = "row1" />
    <div մականունը = "row2" />

  </div>

</մարմին>

(Վերը նշված է waaaaaaaaaaaay oversimplified.  Դատարկ div tags ամբողջովին ուժի մեջ. Իմ մի քանի <div> tags լիքն էին բովանդակության, բայց շատ ավելին էին, ոչ.  Եկա իրականացմանը, որ իմ <xsl:համար յուրաքանչյուր> դիրեկտիվներ, որոնք emitting կարճ ձեւը DIV տեգերը, երբ xsl:համար յուրաքանչյուր չեն, գտնել որեւէ տվյալներ.  Ես ստիպված մի օրերի մեկնաբանել է արտադրանքի, ինչպես ցուցադրված է:

image

 

Դրանից հետո ես, որ, բոլոր div է կնճռոտ լավ ու թերթ անցումը սկսել է աշխատել.

Ինչպես միշտ, Հուսով եմ, որ դա օգնում է մեկին մի պտղունց.

</վերջ>

Անդամագրվել իմ բլոգում.

Գտեք Twitter-ում http://www.twitter.com/pagalvin

Պատճառներից մեկը կարող է «ստեղծողի Այս մեղքով չի նշել պատճառը.”

Ես անում շատ աշխատել Sharepoint որոնմամբ վերջերս, եւ մասնավորապես KeywordQuery դասը, հատկությունները եւ մեթոդները.

Եթե ​​ցանկանում եք արդյունքն ստեղծվել է վերադառնալ արդյունքները վեր ու վեր է սովորական կասկածյալների (տես այստեղ), եք ավելացնել այն SelectedProperties հավաքածուի մեջ, ինչպես:

myKeywordQuery.SelectProperties.Add("Xyzzy");

Many thanks եւ հուշում է գլխարկը է Corey Ռոթ իսկ Սա մեծապես օգտակար օրագրում Հաղորդագրություն (http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/19/how-to-use-the-moss-enterprise-search-keywordquery-class.aspx)

Իմ դեպքում,, «Xyzzy" չէ իրականում հասցրել գույքը.  Երբ ես ավելացրել է SelectedProperties դեպքում, SharePoint շպրտեց մեկը իմ երբեւէ Runtime բացառություններով:

"The ստեղծող այս մեղքով չի նշել պատճառը».

Ես հատկապես սիրում կապիտալը "R" - ի պատճառով.  Դա հնչում է ինձ նման. NET համարժեք է "Չունեմ բերանը, եւ ես պետք է գոռալ."

</վերջ>

Անդամագրվել իմ բլոգում.

Գտեք Twitter-ում http://www.twitter.com/pagalvin

Հարմար Reference: Էջը արդյունքները KeywordQuery Որոնել

Երբ վկայակոչել է մահապատժի() մեթոդն է KeywordQuery, Դուք կարող եք ստեղծել ResultTable վրա հիմնված ResultType.RelevantResults.  Այս կոդը պատառներ ցույց է տալիս, թե ինչ նկատի ունեմ:

ResultTableCollection resultsTableCollection = myKeywordQuery.Execute();

ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];

Իսկ արդյունքում աղյուսակը կունենա հետեւյալ սյունյակները տեղեկատվության: 

WorkId
Դաս
Վերնագիր
Հեղինակ
Չափ
Ճանապարհ
Նկարագրություն
Գրել
SiteName
CollapsingStatus
HitHighlightedSummary
HitHighlightedProperties
Contentclass
IsDocument
PictureThumbnailURL
ServerRedirectedURL

Ես բխում այդ ցանկը մի SharePoint 2010 միջավայր, ձեռնարկության հրատարակություն.  Հուսով կլինի հարմար է որեւէ մեկին ապագայում.

</վերջ>

Անդամագրվել իմ բլոգում.

Գտեք Twitter-ում http://www.twitter.com/pagalvin

One պատճառը: Msgstr "Չհաջողվեց հանել այդ Քաբ ֆայլի մեջ լուծմանը”

Թեեւ աշխատում է Visual Studio վեբ մասին նախագիծը: Այսօր, Ես մի փոքր վերագրանցում կազմ որոշ ֆայլեր չի դնելու մեջ _layouts թղթապանակում քանի մասի տեղակայման հարցում. Մասնավորապես, Ես վերանվանվել է: JS ֆայլ է «TypeAhead.js" են դեպի TypeAhead(հին).JS "  Ես պլանավորում եմ հեռացնել այն շուտ իր իրավահաջորդը: «TypeAhead.js» ապացուցում է ճիշտ:  Այն նայեց նման:

image

Սա անմիջապես պատճառ խնդիր Visual Studio, երբ ես փորձեցի տեղակայել նախագիծը:

Error occurred in deployment step ‘Add Solution’: Չհաջողվեց հանել Քաբ ֆայլը լուծմանը.

Ստացվում է, որ դուք չպետք է տեղադրել միջանկյալ բառ կամ նախադասություն է ֆայլի անվանումների:  Ես հանել parens եւ լուծել խնդիրը.

</վերջ>

Անդամագրվել իմ բլոգում.

Գտեք Twitter-ում http://www.twitter.com/pagalvin