コード例 #1
0
        static SPCachedNBFRepository()
        {
            IList <string> keys = new List <string>();

            keys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.NewBusinessFiles, keys);
        }
コード例 #2
0
        static SPCachedCountriesRepository()
        {
            IList <string> cacheKeys = new List <string>();

            cacheKeys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.CountryList, cacheKeys);
        }
コード例 #3
0
        static SPCachedRSRepository()
        {
            IList <string> keys = new List <string>();

            keys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.RegionalSummaries, keys);
        }
コード例 #4
0
        static SPCachedMarketingMaterialRepository()
        {
            IList <string> keys = new List <string>();

            keys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.MarketingMaterials, keys);
        }
コード例 #5
0
        public IList <Document> FetchDocuments(string countryCode)
        {
            IList <Document> docList = null;

            try
            {
                Dictionary <string, IList <Document> > countryToDocMap = SPObjectCache.Get(cacheKey) as Dictionary <string, IList <Document> >;

                if (countryToDocMap == null)
                {
                    countryToDocMap = new Dictionary <string, IList <Document> >();
                }

                if (countryToDocMap.ContainsKey(countryCode))
                {
                    docList = countryToDocMap[countryCode];
                }

                if (docList == null)
                {
                    SharePointHelper spHelper = new SharePointHelper();
                    docList = spHelper.GetCountryDocuments(countryCode);

                    countryToDocMap[countryCode] = docList;
                    SPObjectCache.Add(cacheKey, countryToDocMap);
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogError(string.Format(@"Error fetching document for {0}", countryCode), ex);
            }

            return(docList);
        }
コード例 #6
0
        static SPCachedRRDocRepository()
        {
            IList <string> keys = new List <string>();

            keys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.ResearchReferenceDocuments, keys);
        }
コード例 #7
0
        static SPCachedCountryDocRepository()
        {
            IList <string> keys = new List <string>();

            keys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.CountryDocumentsMappingList, keys);
        }
コード例 #8
0
        static SPCachedEEEDocRepository()
        {
            IList <string> keys = new List <string>();

            keys.Add(cacheKey);
            SPObjectCache.RegisterForNotification(Constants.EdelmanEdgeExplanatoryDocuments, keys);
        }
コード例 #9
0
ファイル: SPModel.cs プロジェクト: serenabenny/codeless
        /// <summary>
        /// Gets the default manager instantiated with the specified site and an existing SharePoint object cache.
        /// Actual type of the created manager can be set through <see cref="SPModelManagerDefaultTypeAttribute"/> on the model type.
        /// If there is no <see cref="SPModelManagerDefaultTypeAttribute"/> specified, an <see cref="SPModelManager{T}"/> object is instantiated with <paramref name="type"/>.
        /// </summary>
        /// <param name="type">Model type.</param>
        /// <param name="contextWeb">A site object.</param>
        /// <param name="cache">An instance of SharePoint object cache.</param>
        /// <returns>A manager object.</returns>
        public static ISPModelManager GetDefaultManager(Type type, SPWeb contextWeb, SPObjectCache cache)
        {
            SPModelDescriptor       descriptor = SPModelDescriptor.Resolve(type);
            ISPModelManagerInternal manager    = descriptor.CreateManager(contextWeb);

            manager.ObjectCache = cache;
            return(manager);
        }
コード例 #10
0
        internal IEnumerable <T> TryGetCachedModel <T>(ISPListItemAdapter source, string fieldName, params int[] lookupIds)
        {
            List <T>      collection  = new List <T>();
            SPObjectCache cache       = this.Manager.ObjectCache;
            SPFieldLookup lookupField = cache.GetField(source.WebId, source.ListId, fieldName) as SPFieldLookup;

            if (lookupField != null)
            {
                if (hashtable == null)
                {
                    hashtable = new Hashtable();
                }
                Guid       listId           = lookupField.LookupList == "Self" ? source.ListId : new Guid(lookupField.LookupList);
                List <int> lookupIdsToQuery = new List <int>();

                foreach (int id in lookupIds)
                {
                    LookupKey key = new LookupKey(listId, id);
                    if (hashtable.ContainsKey(key))
                    {
                        object cachedItem = hashtable[key];
                        if (cachedItem is T)
                        {
                            collection.Add((T)cachedItem);
                        }
                    }
                    else
                    {
                        lookupIdsToQuery.Add(id);
                    }
                }
                if (lookupIdsToQuery.Count > 0)
                {
                    ISPModelManagerInternal manager = hashtable.EnsureKeyValue(typeof(T), () => (ISPModelManagerInternal)SPModel.GetDefaultManager(typeof(T), this.manager.Site.RootWeb, cache));
                    SPList  list  = cache.GetList(lookupField.LookupWebId, listId);
                    SPQuery query = new SPQuery {
                        Query = Caml.EqualsAny(SPBuiltInFieldName.ID, lookupIdsToQuery).ToString()
                    };

                    foreach (SPListItem item in list.GetItems(query))
                    {
                        object model = manager.TryCreateModel(new SPListItemAdapter(item, cache), false);
                        hashtable[new LookupKey(listId, item.ID)] = model;
                        if (model is T)
                        {
                            collection.Add((T)model);
                        }
                        cache.AddListItem(item);
                    }
                }
            }
            return(collection);
        }
コード例 #11
0
        public void RefreshList([FromBody] string listName)
        {
            try
            {
                SPObjectCache.OnSPListupdated(listName);
            }
            catch (Exception exception)
            {
                LogHelper.LogError(string.Format(@"Error refreshing {0}, listName"), exception);

                throw;
            }
        }
コード例 #12
0
        public IList <Models.Document> FetchDocuments()
        {
            List <Document> docList = SPObjectCache.Get(cacheKey) as List <Document>;

            if (docList == null)
            {
                SharePointHelper spHelper = new SharePointHelper();
                docList = spHelper.GetDocumnentsByMenu(Constants.NewBusinessFiles);

                SPObjectCache.Add(cacheKey, docList);
            }

            return(docList);
        }
コード例 #13
0
        public IEnumerable <Models.Country> FetchAllCountries()
        {
            List <Country> countryList = SPObjectCache.Get(cacheKey) as List <Country>;

            //return from cache if record exists else fetch from sharepoint.
            if (countryList == null)
            {
                countryList = new List <Country>();
                ClientContext context           = new ClientContext(ConfigHelper.GetConfigValue(Constants.ClientSharePointSiteConfigKey));
                List          announcementsList = context.Web.Lists.GetByTitle(Constants.CountryList);

                // Get all the items from the Countries list
                CamlQuery query     = CamlQuery.CreateAllItemsQuery();
                string    queryText = @"<View ><Query>
                        <Where>
                            <Eq>
                                <FieldRef Name='IsActive'/>
                                <Value Type='Integer'>1</Value>
                            </Eq>
                        </Where>
                        <OrderBy>
                            <FieldRef Name='Country'/>
                        </OrderBy>
                        </Query>
                        </View>";
                query.ViewXml = queryText;
                ListItemCollection items = announcementsList.GetItems(query);

                context.Load(items);
                context.ExecuteQuery();
                foreach (ListItem listItem in items)
                {
                    if (listItem[Constants.CountryColoumnDisplayName] != null)
                    {
                        Country country = new Country();
                        country.Name        = listItem[Constants.CountryColoumnDisplayName].ToString();
                        country.Aplha3_Code = listItem[Constants.AlphaCodeColoumnDisplayName].ToString();
                        countryList.Add(country);
                    }
                }

                SPObjectCache.Add(cacheKey, countryList);
            }

            return(countryList);
        }
コード例 #14
0
ファイル: SPModelUsage.cs プロジェクト: serenabenny/codeless
 public SPModelUsage EnsureList(SPObjectCache objectCache)
 {
     CommonHelper.ConfirmNotNull(objectCache, "objectCache");
     if (this.List != null || this.ListId == Guid.Empty)
     {
         return(this);
     }
     try {
         using (new SPSecurity.SuppressAccessDeniedRedirectInScope()) {
             SPList list = objectCache.GetList(this.WebId, this.ListId);
             if (list != null)
             {
                 return(new SPModelUsage(list, this.ContentTypeId, true));
             }
         }
     } catch { }
     return(this);
 }
コード例 #15
0
ファイル: SPModelUsage.cs プロジェクト: serenabenny/codeless
        public IList <SPList> GetListCollection()
        {
            SPObjectCache objectCache = new SPObjectCache(parentSite);

            return(this.Distinct(ListIdComparer.Default).Select(v => v.EnsureList(objectCache).List).Where(v => v != null).ToArray());
        }