예제 #1
0
        private IEnumerable <T> GetSharepointList <T>(String listName, String query, IListItemConverter <T> converter, String sharepointName = null, bool isfirmware = false)
        {
            try
            {
                using (var sp = _sharepointClientFactory.Create(isfirmware))
                {
                    if (sharepointName == null)
                    {
                        sharepointName = SharepointToCacheNamesMapper.SharepointKeyByCacheKey(listName);
                    }

                    var items = sp.GetList(sharepointName, query);

                    var convertedList = new List <T>();

                    Log.Trace($"GetSharepointList is '{listName}' Count: '{items.Count}");



                    foreach (var item in items)
                    {
                        // Log.Trace($"Convert SharepointList is '{listName}' Item: {(item.FieldValues["Name"] as Microsoft.SharePoint.Client.Taxonomy.TaxonomyFieldValue).Label}'");
                        try
                        {
                            /*
                             * if (item.Id>349) {
                             * var    converted = converter.Convert(item, sp);
                             * }
                             */
                            var converted = converter.Convert(item, sp);

                            if (converted != null)
                            {
                                convertedList.Add(converted);
                            }
                        }
                        catch (Exception ex)
                        {
                            // Log.Error(ex, $"Conversion from ListItem error. Result type: '{typeof(T)}' Item: '{(item.FieldValues["Name"] as Microsoft.SharePoint.Client.Taxonomy.TaxonomyFieldValue).Label}' List: '{listName}'");
                            Log.Error(ex, $"Conversion from ListItem error. Result type: '{typeof(T)}' {listName}' ");
                            //throw;
                        }
                    }

                    return(convertedList);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"Unable to get sharepoint list'{listName}'");
                throw;
            }
        }
예제 #2
0
        private void LoadSharepointTerms(String setName)
        {
            try
            {
                using (var sp = _sharepointClientFactory.Create())
                {
                    var sharepointName = SharepointToCacheNamesMapper.SharepointKeyByCacheKey(setName);

                    var nameTerms = sp.GetTerms(sharepointName);

                    _storage.Set(setName, nameTerms);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Unable to load sharepoint terms");

                throw;
            }
        }