Exemple #1
0
        private List <AHAItem> InvokeSearch(SearchStreamOptionsRecord options)
        {
            PaginationRecord pg = new PaginationRecord();

            pg.Page  = "F";
            pg.Limit = 10;
            return(InvokeSearch(this.options, pg));
        }
Exemple #2
0
        private List <AHAItem> InvokeSearch(SearchStreamOptionsRecord options, PaginationRecord pg)
        {
            try
            {
                log.Debug("Search options: " + options.ToJson());
                log.Debug("Search page: " + pg.ToJson());
                this.options = options;
                ObjectApi objectApi = new ObjectApi(session.GetApiClient());
                log.Debug("Calling SearchObjects API");
                SearchObjectsResult result = objectApi.SearchObjects(options.ToJson(), pg.ToJson());
                if (result.Hdr.Rc == 0)
                {
                    pager = result.Pager;
                    List <AHAItem> items   = new List <AHAItem>();
                    List <Record>  records = result.Records;
                    log.Debug(records.Count + " records returned");

                    foreach (var record in records)
                    {
                        String jsonString = record.Json;
                        log.Debug("Record: " + jsonString);
                        log.Debug("Creating AHA item");
                        AHAItem item = itemFromJson(jsonString);
                        log.Debug("AHAItem: " + JsonConvert.SerializeObject(item));

                        if (item.Type.Equals(FILE_TYPE))
                        {
                            log.Debug("Getting additional info for file");
                            FileApi        fileApi        = new FileApi(session.GetApiClient());
                            ViewFileResult viewFileResult = fileApi.ViewFile(item.Key);
                            if (viewFileResult.Hdr.Rc == 0)
                            {
                                FileRecord fileRecord = viewFileResult.File;
                                item.LastUpdater = fileRecord.LastUpdater.DisplayName;
                                item.Version     = fileRecord.UiVersion;
                                log.Debug("Last updater: " + item.LastUpdater);
                                log.Debug("Version: " + item.Version);
                            }
                            else
                            {
                                log.Error("Vmoso error getting additional info for file. Rc=" + viewFileResult.Hdr.Rc);
                            }
                        }

                        items.Add(item);
                    }
                    return(items);
                }
                else
                {
                    throw new Exception("Vmoso error searching objects. Rc=" + result.Hdr.Rc);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error searching objects from Vmoso", ex);
            }
        }
Exemple #3
0
        public StreamItem GetStreamItem(String contentKey)
        {
            List <StreamRule> rules = new List <StreamRule>();
            PaginationRecord  pg    = new PaginationRecord();

            pg.Page  = "F";
            pg.Limit = 10;
            SearchStreamOptionsRecord options = new SearchStreamOptionsRecord();

            if (rules != null)
            {
                List <String> ruleKeys = new List <String>();
                foreach (StreamRule rule in rules)
                {
                    ruleKeys.Add(rule.Key);
                }
                options.RuleKey = ruleKeys;
            }

            options.ObjectKey = contentKey;
            options.SortAttr  = new List <String>()
            {
                "DOMINANT_ACTIVITY_TIME"
            };
            options.StatusFilter = new List <String>()
            {
                "online"
            };
            options.CreatorFilter     = "all";
            options.SortDir           = "DESC";
            options.UnreadFilter      = "all";
            options.RelevanceFilter   = "most";
            options.FolderLevelFilter = "current";
            options.ZoneFilter        = "engage";
            options.LocaleFilter      = new List <String>()
            {
                "user"
            };
            options.RuleType = "activities";
            FormatRecord formatRecord = new FormatRecord();

            formatRecord.ReturnCounts  = true;
            formatRecord.ReturnRatings = true;
            formatRecord.ReturnSparc   = true;
            formatRecord.ReturnAcl     = true;
            options.Format             = formatRecord.ToJson();

            List <StreamItem> items = InvokeSearch(pg);

            if (items.Count > 0)
            {
                return(items[0]);
            }
            else
            {
                throw new Exception("Error getting stream item");
            }
        }
Exemple #4
0
        public List <AHAItem> Search(String query, Dictionary <String, List <String> > types)
        {
            log.Debug("Searching " + query);
            query = removeAHASymbol(query);
            query = query.Replace("/", "*");

            this.options = new SearchStreamOptionsRecord();
            options.Q    = query;

            List <ObjectTypeRecord> typeFilters = new List <ObjectTypeRecord>();

            if (types != null && types.Count > 0)
            {
                foreach (String typeKey in types.Keys)
                {
                    ObjectTypeRecord typeFilter = new ObjectTypeRecord();
                    typeFilter.Type     = typeKey;
                    typeFilter.Subtypes = types[typeKey];

                    typeFilters.Add(typeFilter);
                    if (typeFilter.Subtypes == null)
                    {
                        log.Debug("Type " + typeFilter.Type);
                    }
                    else
                    {
                        log.Debug("Type " + typeFilter.Type + ", Subtypes " + string.Join(",", typeFilter.Subtypes.ToArray()));
                    }
                }
            }
            options.TypeFilters = typeFilters;
            options.SortAttr    = new List <String> {
                "USAGE_SORT"
            };
            return(InvokeSearch(options));
        }
Exemple #5
0
        public List <StreamItem> GetStream(List <StreamRule> rules, String query)
        {
            PaginationRecord pg = new PaginationRecord();

            pg.Page  = "F";
            pg.Limit = 10;
            options  = new SearchStreamOptionsRecord();

            if (!string.IsNullOrEmpty(query))
            {
                options.SearchString = query;
                options.SortAttr     = new List <String>()
                {
                    "FULLTEXT_SEARCH_SCORE"
                };
            }
            else
            {
                options.SortAttr = new List <String>()
                {
                    "DOMINANT_ACTIVITY_TIME"
                };
            }

            if (rules != null)
            {
                List <String> ruleKeys = new List <String>();
                foreach (StreamRule rule in rules)
                {
                    ruleKeys.Add(rule.Key);
                }
                options.RuleKey = ruleKeys;
            }


            options.StatusFilter = new List <String>()
            {
                "online"
            };
            options.CreatorFilter     = "all";
            options.SortDir           = "DESC";
            options.UnreadFilter      = "all";
            options.RelevanceFilter   = "most";
            options.FolderLevelFilter = "current";
            options.ZoneFilter        = "engage";
            options.LocaleFilter      = new List <String>()
            {
                "user"
            };
            options.RuleType = "activities";
            FormatRecord formatRecord = new FormatRecord();

            formatRecord.ReturnCounts  = true;
            formatRecord.ReturnRatings = true;
            formatRecord.ReturnSparc   = true;
            formatRecord.ReturnAcl     = true;
            options.Format             = formatRecord.ToJson();


            return(InvokeSearch(pg));
        }