有没有办法通过Web服务获取Sharepoint网站的语言环境?

有没有办法通过Web服务获取Sharepoint网站的语言环境?

问题描述:

我已经浏览了wss 3.0文档,但找不到任何东西.我想使用Web服务(无法访问服务器,因此无法在服务器上部署任何东西)来检索Sharepoint 2007网站的语言环境,以便知道在哪个时区中配置了网站?

I've looked through the wss 3.0 documentation, but I can't find anything. I would like to retrieve the locale for a Sharepoint 2007 site using web services (no access to server so can't deploy anything on it), so as to know what time zone is site the configured in. Is that possible?

thx

好,这是我要解决的问题:

Ok, here's what I did to solve this:

  • 查询列表中的1个元素,以获取网站区域设置的时间
  • 查询该元素,获取UTC时间
  • 计算2个结果之间的差异.

代码:

    /// <summary>
    /// Gets the difference between local time and UTC to calculate offset.
    /// Makes a query to the list that returns 1 element with times using the locale as set in the site's settings.
    /// Then makes another query for the same element with UTC times to calculate the difference.
    /// </summary>
    /// <param name="list">list to query</param>
    /// <param name="client">WS object</param>
    /// <returns>Time offset as TimeSpan object</returns>
    private TimeSpan getSiteTZOffset(List list, WSLists.Lists client )
    {
        //Set up query parameters
        XmlDocument xmlDoc = new XmlDocument();
        XmlNode emptyQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
        XmlNode queryWithID = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");

        XmlNode ndOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
        ndOptions.InnerXml = "<DateInUtc>True</DateInUtc>";

        XmlNamespaceManager xnm = new XmlNamespaceManager(xmlDoc.NameTable);
        xnm.AddNamespace("z", "#RowsetSchema");

        // Gets the attribute that serves as modified date
        MapAttribute modifiedDateAttr = attributes.Single(x => x.Value.DateTimeModifiedField).Value;
        // Gets the Id attribute
        MapAttribute idAttr = attributes.Single(x => x.Value.KeyReference).Value;

        //Get 1 result with site's local time
        XmlNode resLocalTime = client.GetListItems(list.ListID, list.ViewID, emptyQuery, null, "1", null, null);
        XmlNodeList itemsLocalTime = resLocalTime.SelectNodes("//z:row", xnm);

        // 2nd query filters on ID of the item returned by 1st query
        queryWithID.InnerXml = string.Format("<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>{0}</Value></Eq></Where>",
            itemsLocalTime[0].Attributes[idAttr.Name].Value);

        //get the result with UTC time
        XmlNode resUtc = client.GetListItems(list.ListID, list.ViewID, queryWithID, null, "1", ndOptions, null);
        XmlNodeList itemsUtc = resUtc.SelectNodes("//z:row", xnm);

        //Converts string values to DateTime objects
        DateTime localTime = DateTime.Parse(itemsLocalTime[0].Attributes[modifiedDateAttr.Name].Value);
        DateTime utcTime = getUtcTime(itemsUtc[0].Attributes[modifiedDateAttr.Name].Value);
        // Gets offset
        TimeSpan offset = localTime - utcTime;

        return offset;
    }