public List <ShareSpace> getSubSpaces(ShareSpace parentSpace) { List <ShareSpace> shareSubSpaces = new List <ShareSpace>(); SpaceApi spaceApi = new SpaceApi(session.GetApiClient()); PaginationRecord pg = new PaginationRecord(); pg.Limit = 10; pg.Page = "F"; FolderOptionsRecord options = new FolderOptionsRecord(); options.SortDir = "DESC"; GetSubSpacesResult subSpacesResult = spaceApi.GetSubSpaces(parentSpace.Key, pg.ToJson(), parentSpace.Key, options.ToJson(), null, "myvmoso"); if (subSpacesResult.Hdr.Rc == 0) { List <SpaceV2Record> subSpaces = subSpacesResult.Folders; foreach (SpaceV2Record subSpace in subSpaces) { ShareSpace childSpace = new ShareSpace(subSpace.Key, subSpace.DisplayName, subSpace); shareSubSpaces.Add(childSpace); } } else { log.Error("Error accesing subspaces for parent space " + parentSpace.Name); } return(shareSubSpaces); }
public List <AHAItem> NextPage() { PaginationRecord pg = pager.Pg; pg.Page = "N"; return(InvokeSearch(this.options, pg)); }
public List <StreamItem> NextPage() { PaginationRecord pg = pager.Pg; pg.Page = "N"; return(InvokeSearch(pg)); }
public List <StreamComment> NextCommentsPage(StreamItem streamItem) { PaginationRecord pg = commentsPager.Pg; pg.Page = "N"; return(GetComments(streamItem, pg)); }
private List <AHAItem> InvokeSearch(SearchStreamOptionsRecord options) { PaginationRecord pg = new PaginationRecord(); pg.Page = "F"; pg.Limit = 10; return(InvokeSearch(this.options, pg)); }
public List <StreamComment> GetComments(StreamItem streamItem) { PaginationRecord pg = new PaginationRecord(); pg.Page = "F"; pg.Limit = 10; return(GetComments(streamItem, pg)); }
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); } }
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"); } }
public List <StreamComment> GetComments(StreamItem streamItem, PaginationRecord pg) { CommentApi commentApi = new CommentApi(session.GetApiClient()); try { CommentListV2OptionsRecord options = new CommentListV2OptionsRecord(); options.SortDir = "DESC"; options.HighlightTag = "mark"; options.CreatorFilter = "all"; options.ReadFilter = "all"; options.SortFilter = "updateTime"; AdditionalDataRecord additionalData = new AdditionalDataRecord(); additionalData.SubType = "general"; additionalData.FirstLevelCount = true; GetCommentsResult getCommentsResult = commentApi.GetComments(streamItem.Key, options.ToJson(), pg.ToJson(), streamItem.CommentListKey, additionalData.ToJson()); if (getCommentsResult.Hdr.Rc == 0) { commentsPager = getCommentsResult.Pager; List <StreamComment> comments = new List <StreamComment>(); List <CommentV2Record> commentRecords = getCommentsResult.Comments; foreach (CommentV2Record commentRecord in commentRecords) { StreamComment comment = new StreamComment(commentRecord, streamItem.RecordType); comments.Add(comment); } return(comments); } else { throw new Exception("Error getting comments for contentKey " + streamItem.Key); } } catch (Exception ex) { throw new Exception("Error getting comments for contentKey " + streamItem.Key, ex); } }
public List <StreamItem> InvokeSearch(PaginationRecord pg) { try { StreamApi streamApi = new StreamApi(session.GetApiClient()); FormatRecord formatRecord = new FormatRecord(); formatRecord.ReturnCounts = true; formatRecord.ReturnRatings = true; formatRecord.ReturnSparc = true; formatRecord.ReturnAcl = true; StreamSearchResult result = streamApi.StreamSearch(options.ToJson(), pg.ToJson(), formatRecord.ToJson()); if (result.Hdr.Rc == 0) { pager = result.Pager; List <StreamItem> streamItems = new List <StreamItem>(); List <StreamRecordWrapper> recordWrappers = result.Stream; foreach (StreamRecordWrapper recordWrapper in recordWrappers) { StreamItem streamItem = new StreamItem(); streamItem.UnreadCount = (int)recordWrapper.BadgeCounts.TotalNewCount; streamItem.RecordType = recordWrapper.Recordtype; String recordJson = JsonConvert.SerializeObject(recordWrapper.Record); switch (streamItem.RecordType) { case RECORD_POSTV2: PostV2Record postRecord = JsonConvert.DeserializeObject <PostV2Record>(recordJson); streamItem.Key = postRecord.Key; streamItem.CommentListKey = postRecord.CommentlistKey; streamItem.Type = postRecord.Type; streamItem.SubType = postRecord.Subtype; streamItem.Name = postRecord.Title; streamItem.Record = postRecord; break; case RECORD_LINKV2: LinkV2Record linkRecord = JsonConvert.DeserializeObject <LinkV2Record>(recordJson); streamItem.Key = linkRecord.Key; streamItem.Type = linkRecord.Type; streamItem.SubType = linkRecord.Subtype; streamItem.Name = linkRecord.Title; streamItem.Record = linkRecord; break; case RECORD_TASK: TaskRecord taskRecord = JsonConvert.DeserializeObject <TaskRecord>(recordJson); streamItem.CommentListKey = taskRecord.CommentlistKey; streamItem.Key = taskRecord.Key; streamItem.Type = taskRecord.Type; streamItem.SubType = taskRecord.Subtype; streamItem.Name = taskRecord.Name; streamItem.Record = taskRecord; break; case RECORD_FILE: FileRecord fileRecord = JsonConvert.DeserializeObject <FileRecord>(recordJson); streamItem.Key = fileRecord.Key; streamItem.Type = fileRecord.Type; streamItem.SubType = fileRecord.Subtype; streamItem.Name = fileRecord.Name; streamItem.Record = fileRecord; break; default: Console.WriteLine(recordWrapper.Recordtype); break; } dynamic recordObject = JsonConvert.DeserializeObject(recordJson); dynamic destinations = recordObject.destinations; try { streamItem.SpacePath = destinations[0].fullPath + "/" + destinations[0].displayName; } catch (Exception ex) { } SparcActionRecord lastAction = recordWrapper.LastAction; if (lastAction != null) { Double timeUpdated = Convert.ToDouble(lastAction.Timestamp); DateTime timeStamp = UnixTimeStampToDateTime(timeUpdated); streamItem.TimeUpdated = timeStamp; List <StreamRecordWrapper> actors = lastAction.Actors; if (actors.Count > 0) { String actorRecordType = actors[0].Recordtype; String userRecordJson = JsonConvert.SerializeObject(actors[0].Record); switch (actorRecordType) { case USER_OBJECT_RECORD: UserObjectRecord userRecord = JsonConvert.DeserializeObject <UserObjectRecord>(userRecordJson); streamItem.LastUpdater = userRecord.DisplayName; streamItem.LastUpdaterFirstName = userRecord.FirstName; streamItem.LastUpdaterLastName = userRecord.LastName; streamItem.LastUpdaterIconKey = userRecord.IconSmall; break; } } String verb = ""; switch (lastAction.Verb) { case "create": verb = "Created"; break; case "update": verb = "Updated"; break; case "delete": verb = "Deleted"; break; case "rename": verb = "Renamed"; break; default: break; } switch (lastAction.Sparctype) { case "summary": switch (lastAction.Sparcsubtype) { case "all": streamItem.LastActionContent = verb + " a " + RECORDS[streamItem.RecordType]; break; default: break; } break; case "content": StreamRecordWrapper actionRecordWrapper = lastAction.Containers[0]; String actionRecordJson = JsonConvert.SerializeObject(actionRecordWrapper.Record); switch (lastAction.Sparcsubtype) { case "comment": CommentV2Record commentRecord = JsonConvert.DeserializeObject <CommentV2Record>(actionRecordJson); String textWithoutComments = Regex.Replace(commentRecord.Text, "<!--.*?-->", String.Empty, RegexOptions.Multiline); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(HttpUtility.HtmlDecode(textWithoutComments)); streamItem.LastActionContent = doc.DocumentNode.InnerText; break; default: break; } break; default: break; } String path = ""; if (PATHS.ContainsKey(streamItem.RecordType)) { path = PATHS[streamItem.RecordType]; } else { log.Error("URL for record type " + streamItem.RecordType + " not found"); } streamItem.Link = session.OriginalHost + "/" + path + "/" + streamItem.Key;; streamItems.Add(streamItem); } } return(streamItems); } else { throw new Exception("Error searching stream"); } } catch (Exception ex) { throw new Exception("Error searching stream", ex); } }
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)); }