public static string XmlToUpdate(List<XmlDataDoc> lstKeyValues, string InternalColmnName, string listGuid, bool isDocLibrary)
{
StringBuilder methodBuilder = new StringBuilder();
string batchFormat =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<ows:Batch OnError=\"Continue\">{0}</ows:Batch>";
string methodFormat = "<Method ID=\"{0}\">" +
"<SetList>{1}</SetList>" +
"<SetVar Name=\"Cmd\">Save</SetVar>" +
"<SetVar Name=\"ID\">{2}</SetVar>" +
"<SetVar Name=\"urn:schemas-microsoft-com:office:office#{3}\">{4}</SetVar>" +
//Requiredf only for Document Library
((isDocLibrary) ? "<SetVar Name=\"owsfileref\">{5}</SetVar>" : "") +
"</Method>";
foreach (XmlDataDoc KeyValue in lstKeyValues)
{
methodBuilder.AppendFormat(methodFormat, KeyValue.ID, listGuid, KeyValue.ID, InternalColmnName, KeyValue.Value, KeyValue.RelativeUrl);
}
return string.Format(batchFormat, methodBuilder.ToString());
}
public static string XmlToNew(List<Dictionary<string, string>> lstColNameEtValue, string listGuid)
{
string batchFormat =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<ows:Batch OnError=\"Continue\">{0}</ows:Batch>";
StringBuilder methodFormat = new StringBuilder();
foreach (Dictionary<string, string> items in lstColNameEtValue)
{
methodFormat.Append("<Method ID=\"LaunchMeta\">" +
"<SetList>" + listGuid + "</SetList>" +
"<SetVar Name=\"Cmd\">Save</SetVar>" +
"<SetVar Name=\"ID\">New</SetVar>");
foreach (KeyValuePair<string, string> ColNameEtValue in items)
{
methodFormat.Append("<SetVar Name=\"urn:schemas-microsoft-com:office:office#" + ColNameEtValue.Key + "\">" + ColNameEtValue.Value + "</SetVar>");
}
methodFormat.Append("</Method>");
}
return string.Format(batchFormat, methodFormat.ToString());
}
public static string TaxoCollToXmlInput(TaxonomyFieldValueCollection TaxoColl)
{
string metaList = string.Empty;
foreach (TaxonomyFieldValue itm in TaxoColl)
{
metaList += itm.WssId + ";#" + itm.Label + "|" + itm.TermGuid + ";";
}
return metaList;
}
}
public class XmlDataDoc
{
public int ID { get; set; }
//item.file.RelativeUrl not item.url
public string RelativeUrl { get; set; }
public string Value { get; set; }
}
}
7.11.13
8.2.13
Vérification de la lecture du contenu
Chargement du contenu dans le DIV à partir d'une page html
WebClient client = new WebClient();
String htmlCode = client.DownloadString("http://localhost:18995/Content/ContentPage.html");
textAcceptation.Controls.Add(new LiteralControl(htmlCode));
Vérification de la lecture du contenu
$(".AcknowledgeOuterDiv").scroll(function () {
var outerDiv = $(this);
var innerDiv = $(">.AcknowledgeInnerDiv", $(this));
var ScrollMod = 1;
if (outerDiv.offset().top < innerDiv.outerHeight()) {
ScrollMod = -1;
}
var innerOuterHeight = innerDiv.outerHeight();
var boxHeight = outerDiv.height();
var boxOffsetTop = outerDiv.offset().top;
if (Math.ceil(Math.abs(boxHeight) - innerDiv.offset().top + boxOffsetTop + 1) >= innerOuterHeight) {
$("#CheckId").attr("disabled", false);
$(this).unbind("scroll");
}
else {
$("#CheckId").attr("disabled", true);
}
});
25.1.13
Sharepoint 2013: from app to host
E ora Sharepoint 2013, accediamo al nostro sharepoint host a partire da un app su office 365
var hostweburl;var appweburl;function sharePointReady() {// retrieve passed app web/host web URLs..hostweburl = decodeURIComponent($.getUrlVar("SPHostUrl"));appweburl = decodeURIComponent($.getUrlVar("SPAppWebUrl"));loadDependentScripts();}function loadDependentScripts() {var scriptbase = hostweburl + "/_layouts/15/";// Load the js files and continue to the successHandler$.getScript(scriptbase + "SP.Runtime.js",function () {$.getScript(scriptbase + "SP.js",function () { $.getScript(scriptbase + "SP.RequestExecutor.js", getAllHostWebPropsUsingREST); });});}function getAllHostWebPropsUsingREST() {var executor;// although we're fetching data from the host web, SP.RequestExecutor gets initialized with the app web URL..executor = new SP.RequestExecutor(appweburl);executor.executeAsync({url:appweburl +"/_api/SP.AppContextSite(@target)/web/?@target='" + hostweburl + "'",method: "GET",headers: { "Accept": "application/json; odata=verbose" },success: onGetAllHostWebPropsUsingRESTSuccess,error: onGetAllHostWebPropsUsingRESTFail});}function onGetAllHostWebPropsUsingRESTSuccess(data) {var jsonObject = JSON.parse(data.body);// note that here our jsonObject.d object (representing the web) has ALL properties because// we did not select specific ones in our REST URL. However, we're just displaying the web title here..$('#hostWebTitle').text(jsonObject.d.Title);}function onGetAllHostWebPropsUsingRESTFail(data, errorCode, errorMessage) {alert('Failed to get host site. Error:' + errorMessage);}// jQuery plugin for fetching querystring parameters..jQuery.extend({getUrlVars: function () {var vars = [], hash;var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');for (var i = 0; i < hashes.length; i++) {hash = hashes[i].split('=');vars.push(hash[0]);vars[hash[0]] = hash[1];}return vars;},getUrlVar: function (name) {return jQuery.getUrlVars()[name];}});
Subscribe to:
Posts (Atom)