Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        public List <StreamRule> getPresetRules()
        {
            List <StreamRule> rules = new List <StreamRule>();

            try
            {
                RuleApi ruleApi             = new RuleApi(session.GetApiClient());
                GetPresetRulesResult result = ruleApi.GetPresetRules("activities");
                if (result.Hdr.Rc == 0)
                {
                    List <RuleRecord> ruleRecords = result.Rules;
                    foreach (RuleRecord ruleRecord in ruleRecords)
                    {
                        StreamRule rule = new StreamRule();
                        rule.RuleRecord = ruleRecord;
                        rule.Key        = ruleRecord.Key;
                        rule.Name       = ruleRecord.Name;
                        rules.Add(rule);
                    }
                    return(rules);
                }
                else
                {
                    throw new Exception("Error getting preset rules");
                }
            }
            catch (ApiException ex)
            {
                throw new Exception("Error getting preset rules", ex);
            }
        }
Esempio n. 3
0
        public ContactItem searchUserByEmail(String email)
        {
            try
            {
                log.Debug("Searching email " + email);
                UserApi userApi = new UserApi(session.GetApiClient());

                ContactcardApi       contactCartApi = new ContactcardApi(session.GetApiClient());
                GetUserByEmailResult result         = userApi.GetUserByEmail(email);
                if (result.Hdr.Rc == 0)
                {
                    DisplayRecord displayRecord = result.DisplayRecord;
                    ContactItem   contactItem   = getContact(displayRecord.Key);
                    contactItem.Key  = displayRecord.Key;
                    contactItem.Link = session.OriginalHost + "/c/" + contactItem.Key;
                    return(contactItem);
                }
                else
                {
                    throw new Exception("Email " + email + " not found");
                }
            } catch (Exception ex)
            {
                throw new Exception("Email searching email " + email, ex);
            }
        }
Esempio n. 4
0
        public void Start()
        {
            PushApi             pushApi             = new PushApi(session.GetApiClient());
            GetPushConfigResult getPushConfigResult = pushApi.GetPushConfig("ws");

            if (getPushConfigResult.Hdr.Rc == 0)
            {
                pushServer = getPushConfigResult.Host;
                GetTokenResult getTokenResult = pushApi.GetToken(session.UserKey);
                if (getTokenResult.Hdr.Rc == 0)
                {
                    signature = getTokenResult.Token;

                    BuildChannel();
                    Connect();
                    UserAuth();
                    Subscribe();
                    BuildChannelMonitor();
                }
            }
        }
Esempio n. 5
0
        public List <ShareSpace> GetRootSpaces()
        {
            log.Debug("Getting root spaces...");
            SpaceApi spaceApi = new SpaceApi(session.GetApiClient());

            GetSpacesResult getSpacesResult = spaceApi.GetSpaces(CUSTOM_SPACE_TAG);

            if (getSpacesResult.Hdr.Rc == 0)
            {
                List <SpaceV2Record> spaces      = getSpacesResult.Folders;
                List <ShareSpace>    shareSpaces = new List <ShareSpace>();
                foreach (SpaceV2Record space in spaces)
                {
                    if (space.NameKey.Equals(CORPORATE_SPACE) || space.NameKey.Equals(CUSTOM_SPACE) || space.NameKey.Equals(MUTUAL_SPACE) || space.NameKey.Equals(PUBLIC_SPACE))
                    {
                        ShareSpace shareSpace = new ShareSpace(space.Key, space.DisplayName, space);
                        shareSpaces.Insert(0, shareSpace);
                    }
                }

                return(shareSpaces);
            }
            else
            {
                throw new Exception("Vmoso error getting root spaces. Rc=" + getSpacesResult.Hdr.Rc);
            }
        }