Ejemplo n.º 1
0
        public static void ExampleOne(string siteURL)
        {
            using (SPSite site = new SPSite(siteURL))
            {
                //Get a CbqQueryVersionInfo object from a ContentByQueryWebPart and use it to get a CrossListQueryInfo
                ContentByQueryWebPart cbq         = new ContentByQueryWebPart();
                CbqQueryVersionInfo   versionInfo = cbq.BuildCbqQueryVersionInfo();
                CrossListQueryInfo    queryInfo   = versionInfo.VersionCrossListQueryInfo;
                // Create a new CrossListQueryCache object with the queryInfo we just got
                CrossListQueryCache crossListCache = new CrossListQueryCache(queryInfo);

                SiteDataResults results = crossListCache.GetSiteDataResults(site, false);
            }
        }
        public static void ExampleOne(string siteURL)
        {
            using (SPSite site = new SPSite(siteURL))
            {
                //Get a CbqQueryVersionInfo object from a ContentByQueryWebPart and use it to get a CrossListQueryInfo
                ContentByQueryWebPart cbq = new ContentByQueryWebPart();
                CbqQueryVersionInfo versionInfo = cbq.BuildCbqQueryVersionInfo();
                CrossListQueryInfo queryInfo = versionInfo.VersionCrossListQueryInfo;
                // Create a new CrossListQueryCache object with the queryInfo we just got
                CrossListQueryCache crossListCache = new CrossListQueryCache(queryInfo);

                SiteDataResults results = crossListCache.GetSiteDataResults(site, false);

            }
        }
        //GetSiteDataResults(Microsoft.SharePoint.SPSite,System.Boolean)
        // Returns the results of the current query on the specified site.  The query will be run against
        // an SPList if useSpQueryOnList is set to true.  Otherwise the query will be run against a site or web
        // This version of GetSiteDataResults uses the web url in this object's CrossListQueryInfo to determine
        // either the web to query against or the web of the list being queried against depending on the value
        // of useSpQueryOnList.
        public static void Testing(string siteURL)
        {
            SPSite oSite = new SPSite(siteURL);
            SPWeb oWeb = oSite.RootWeb;

            string query = string.Empty;
            string websQuery = string.Format("<Webs Scope=\"{0}\"/>", "None");
            string lists = "<Lists ServerTemplate=\"101\"" + " ><List ID=\"4db0e78c-dd9c-45f2-8b9c-e5f602e7d0b7\" /></Lists>";
            bool useList = true;
            //string relativeUrl = this.GetRelativeUrl();
            //query = string.Format("<Where><Eq><FieldRef Name='FSObjType' /><Value Type='LookUp'>1</Value></Eq></Where>", relativeUrl);

            CrossListQueryInfo info = new CrossListQueryInfo();
            info.Lists = lists;
            info.Webs = websQuery;
            info.Query = query;
            info.ViewFields = "<FieldRef Name=\"FileLeafRef\"/>";
            info.WebUrl = oWeb.ServerRelativeUrl;
            CrossListQueryCache cache = new CrossListQueryCache(info);
            SiteDataResults sd = cache.GetSiteDataResults(oSite, true);
        }
Ejemplo n.º 4
0
        //GetSiteDataResults(Microsoft.SharePoint.SPSite,System.Boolean)
        // Returns the results of the current query on the specified site.  The query will be run against
        // an SPList if useSpQueryOnList is set to true.  Otherwise the query will be run against a site or web

        // This version of GetSiteDataResults uses the web url in this object's CrossListQueryInfo to determine
        // either the web to query against or the web of the list being queried against depending on the value
        // of useSpQueryOnList.
        public static void Testing(string siteURL)
        {
            SPSite oSite = new SPSite(siteURL);
            SPWeb  oWeb  = oSite.RootWeb;

            string query     = string.Empty;
            string websQuery = string.Format("<Webs Scope=\"{0}\"/>", "None");
            string lists     = "<Lists ServerTemplate=\"101\"" + " ><List ID=\"4db0e78c-dd9c-45f2-8b9c-e5f602e7d0b7\" /></Lists>";
            bool   useList   = true;
            //string relativeUrl = this.GetRelativeUrl();
            //query = string.Format("<Where><Eq><FieldRef Name='FSObjType' /><Value Type='LookUp'>1</Value></Eq></Where>", relativeUrl);

            CrossListQueryInfo info = new CrossListQueryInfo();

            info.Lists      = lists;
            info.Webs       = websQuery;
            info.Query      = query;
            info.ViewFields = "<FieldRef Name=\"FileLeafRef\"/>";
            info.WebUrl     = oWeb.ServerRelativeUrl;
            CrossListQueryCache cache = new CrossListQueryCache(info);
            SiteDataResults     sd    = cache.GetSiteDataResults(oSite, true);
        }